aboutsummaryrefslogtreecommitdiff
path: root/doc/plugins/contrib/ymlfront.mdwn
blob: 2805be04fd838429e71be664f12558e1f1003635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
[[!template id=plugin name=ymlfront author="[[rubykat]]"]]
[[!tag type/meta]]
[[!toc]]
## NAME

IkiWiki::Plugin::ymlfront - add YAML-format data to a page

## SYNOPSIS

    # activate the plugin
    add_plugins => [qw{goodstuff ymlfront ....}],

    # configure the plugin
    ymlfront_delim => [qw(--YAML-- --YAML--)],

## DESCRIPTION

This plugin provides a way of adding arbitrary meta-data (data fields) to any
page by prefixing the page with a YAML-format document.  This also provides
the [[ikiwiki/directive/ymlfront]] directive, which enables one to put
YAML-formatted data inside a standard IkiWiki [[ikiwiki/directive]].

This is a way to create per-page structured data, where each page is
treated like a record, and the structured data are fields in that record.  This
can include the meta-data for that page, such as the page title.

This plugin is meant to be used in conjunction with the [[field]] plugin.

## DETAILS

There are three formats for adding YAML data to a page.  These formats
should not be mixed - the result is undefined.

1. ymlfront directive
   
   See [[ikiwiki/directive/ymlfront]] for more information.

2. default YAML-compatible delimiter

   By default, the YAML-format data in a page is placed at the start of
   the page and delimited by lines containing precisely three dashes.
   This is what YAML itself uses to delimit multiple documents.
   The "normal" content of the page then follows.

   For example:

    	---
    	title: Foo does not work
    	Urgency: High
    	Status: Assigned
    	AssignedTo: Fred Nurk
    	Version: 1.2.3
    	---
    	When running on the Sprongle system, the Foo function returns incorrect data.

   What will normally be displayed is everything following the second line of dashes.  That will be htmlized using the page-type of the page-file.

3. user-defined delimiter

   Instead of using the default "---" delimiter, the user can define,
   in the configuration file, the **ymlfront_delim** value, which is an
   array containing two strings. The first string defines the markup for
   the start of the YAML data, and the second string defines the markip
   for the end of the YAML data. These two strings can be the same, or
   they can be different. In this case, the YAML data section is not
   required to be at the start of the page, but as with the default, it
   is expected that only one data section will be on the page.

   For example:

    	--YAML--
    	title: Foo does not work
    	Urgency: High
    	Status: Assigned
    	AssignedTo: Fred Nurk
    	Version: 1.2.3
    	--YAML--
    	When running on the Sprongle system, the Foo function returns incorrect data.

   What will normally be displayed is everything outside the delimiters,
   both before and after.  That will be htmlized using the page-type of the page-file.

### Accessing the Data

There are a few ways to access the given YAML data.

* [[getfield]] plugin

  The **getfield** plugin can display the data as individual variable values.

  For example:

    	---
    	title: Foo does not work
    	Urgency: High
    	Status: Assigned
    	AssignedTo: Fred Nurk
    	Version: 1.2.3
    	---
    	# {{$title}}

    	**Urgency:** {{$Urgency}}\\
    	**Status:** {{$Status}}\\
    	**Assigned To:** {{$AssignedTo}}\\
    	**Version:** {{$Version}}

    When running on the Sprongle system, the Foo function returns incorrect data.

* [[ftemplate]] plugin

  The **ftemplate** plugin is like the [[plugins/template]] plugin, but it is also aware of [[field]] values.

  For example:

    	---
    	title: Foo does not work
    	Urgency: High
    	Status: Assigned
    	AssignedTo: Fred Nurk
    	Version: 1.2.3
    	---
    	\[[!ftemplate id="bug_display_template"]]

    	When running on the Sprongle system, the Foo function returns incorrect data.

* [[report]] plugin

  The **report** plugin is like the [[ftemplate]] plugin, but it reports on multiple pages, rather than just the current page.

* write your own plugin

  In conjunction with the [[field]] plugin, you can write your own plugin to access the data.

## PREREQUISITES

    IkiWiki
    IkiWiki::Plugin::field
    YAML::Any

## DOWNLOAD

* browse at GitHub: <http://github.com/rubykat/ikiplugins/blob/master/IkiWiki/Plugin/ymlfront.pm>
* git repo at git://github.com/rubykat/ikiplugins.git