154 |
154 |
end
|
155 |
155 |
|
156 |
156 |
# Sets description for the next macro to be defined
|
157 |
|
def desc(txt)
|
158 |
|
@@desc = txt
|
|
157 |
# For complex descriptions that use textile syntax, you may also
|
|
158 |
# provide a markdown equivalent using the :markdown option.
|
|
159 |
def desc(*args)
|
|
160 |
options = args.extract_options!
|
|
161 |
options.symbolize_keys!
|
|
162 |
if default = args.shift
|
|
163 |
options[:default] = default
|
|
164 |
end
|
|
165 |
@@desc = ->(){
|
|
166 |
options[Setting.text_formatting.to_sym] || options[:default]
|
|
167 |
}
|
159 |
168 |
end
|
160 |
169 |
end
|
161 |
170 |
|
... | ... | |
173 |
182 |
out = ''.html_safe
|
174 |
183 |
@@available_macros.each do |macro, options|
|
175 |
184 |
out << content_tag('dt', content_tag('code', macro.to_s))
|
176 |
|
out << content_tag('dd', textilizable(options[:desc]))
|
|
185 |
desc = options[:desc]
|
|
186 |
desc = desc.call if desc.respond_to?(:call)
|
|
187 |
out << content_tag('dd', textilizable(desc.to_s))
|
177 |
188 |
end
|
178 |
189 |
content_tag('dl', out)
|
179 |
190 |
end
|
180 |
191 |
|
181 |
192 |
desc "Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" +
|
182 |
193 |
" !{{child_pages}} -- can be used from a wiki page only\n" +
|
183 |
|
" !{{child_pages(depth=2)}} -- display 2 levels nesting only\n"
|
|
194 |
" !{{child_pages(depth=2)}} -- display 2 levels nesting only\n" +
|
184 |
195 |
" !{{child_pages(Foo)}} -- lists all children of page Foo\n" +
|
185 |
|
" !{{child_pages(Foo, parent=1)}} -- same as above with a link to page Foo"
|
|
196 |
" !{{child_pages(Foo, parent=1)}} -- same as above with a link to page Foo",
|
|
197 |
markdown:("Displays a list of child pages. With no argument, it displays the child pages of the current wiki page. Examples:\n\n" +
|
|
198 |
"~~~~\n" +
|
|
199 |
"!{{child_pages}} -- can be used from a wiki page only\n" +
|
|
200 |
"!{{child_pages(depth=2)}} -- display 2 levels nesting only\n" +
|
|
201 |
"!{{child_pages(Foo)}} -- lists all children of page Foo\n" +
|
|
202 |
"!{{child_pages(Foo, parent=1)}} -- same as above with a link to page Foo\n" +
|
|
203 |
"~~~~\n\n")
|
186 |
204 |
macro :child_pages do |obj, args|
|
187 |
205 |
args, options = extract_macro_options(args, :parent, :depth)
|
188 |
206 |
options[:depth] = options[:depth].to_i if options[:depth].present?
|
... | ... | |
200 |
218 |
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
|
201 |
219 |
end
|
202 |
220 |
|
203 |
|
desc "Include a wiki page. Example:\n\n !{{include(Foo)}}\n\nor to include a page of a specific project wiki:\n\n !{{include(projectname:Foo)}}"
|
|
221 |
desc "Include a wiki page. Example:\n\n !{{include(Foo)}}\n\nor to include a page of a specific project wiki:\n\n !{{include(projectname:Foo)}}",
|
|
222 |
markdown: "Include a wiki page. Example:\n\n~~~~\n!{{include(Foo)}}\n~~~~\n\nor to include a page of a specific project wiki:\n\n~~~~\n!{{include(projectname:Foo)}}\n~~~~\n"
|
204 |
223 |
macro :include do |obj, args|
|
205 |
224 |
page = Wiki.find_page(args.first.to_s, :project => @project)
|
206 |
225 |
raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
|
... | ... | |
212 |
231 |
out
|
213 |
232 |
end
|
214 |
233 |
|
215 |
|
desc "Inserts of collapsed block of text. Example:\n\n {{collapse(View details...)\nThis is a block of text that is collapsed by default.\nIt can be expanded by clicking a link.\n}}"
|
|
234 |
desc "Inserts of collapsed block of text. Example:\n\n {{collapse(View details...)\nThis is a block of text that is collapsed by default.\nIt can be expanded by clicking a link.\n}}",
|
|
235 |
markdown: "Inserts of collapsed block of text. Example:\n\n~~~~\n{{collapse(View details...)\nThis is a block of text that is collapsed by default.\nIt can be expanded by clicking a link.\n}}\n~~~~\n"
|
216 |
236 |
macro :collapse do |obj, args, text|
|
217 |
237 |
html_id = "collapse-#{Redmine::Utils.random_hex(4)}"
|
218 |
238 |
show_label = args[0] || l(:button_show)
|
... | ... | |
225 |
245 |
out
|
226 |
246 |
end
|
227 |
247 |
|
228 |
|
desc "Displays a clickable thumbnail of an attached image. Examples:\n\n<pre>{{thumbnail(image.png)}}\n{{thumbnail(image.png, size=300, title=Thumbnail)}}</pre>"
|
|
248 |
desc "Displays a clickable thumbnail of an attached image. Examples:\n\n<pre>{{thumbnail(image.png)}}\n{{thumbnail(image.png, size=300, title=Thumbnail)}}</pre>", markdown: "Displays a clickable thumbnail of an attached image. Examples:\n\n~~~~\n{{thumbnail(image.png)}}\n{{thumbnail(image.png, size=300, title=Thumbnail)}}\n~~~~\n"
|
229 |
249 |
macro :thumbnail do |obj, args|
|
230 |
250 |
args, options = extract_macro_options(args, :size, :title)
|
231 |
251 |
filename = args.first
|
... | ... | |
246 |
266 |
end
|
247 |
267 |
end
|
248 |
268 |
|
249 |
|
desc <<DESC
|
|
269 |
desc "Wraps the enclosed image/thumbnail/text in a box with an optional caption. Example:
|
|
270 |
|
|
271 |
<pre>
|
|
272 |
{{figure(This is a caption)
|
|
273 |
!some-image.jpg!
|
|
274 |
}}
|
|
275 |
</pre>
|
|
276 |
", markdown: "
|
250 |
277 |
Wraps the enclosed image/thumbnail/text in a box with an optional caption. Example:
|
251 |
278 |
|
252 |
|
<pre>{{figure(This is a caption)
|
|
279 |
~~~~
|
|
280 |
{{figure(This is a caption)
|
253 |
281 |
!some-image.jpg!
|
254 |
|
}}</pre>
|
255 |
|
DESC
|
|
282 |
}}
|
|
283 |
~~~~
|
|
284 |
"
|
256 |
285 |
macro :figure do |obj, args, text|
|
257 |
|
puts obj.inspect
|
258 |
286 |
args, options = extract_macro_options(args, :size)
|
259 |
287 |
caption = args.first
|
260 |
288 |
content_tag :figure do
|