Wiki source code of Templates
Version 2.1 by Sergey Lebedev on 2019/04/13 05:15
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{include reference="Help.Code.VelocityMacros" /}} | ||
| 2 | |||
| 3 | {{velocity output="false"}} | ||
| 4 | #set ($actionCards = [{ | ||
| 5 | 'title': 'Use templates', | ||
| 6 | 'description': 'Templates are predefined pages that can be copied when creating a new page.', | ||
| 7 | 'tip': "<a href=""http://platform.xwiki.org/xwiki/bin/view/Features/DocumentLifecycle#HCreate"" class=""wikiexternallink"">Creating pages</a> based on templates makes it faster to adapt predefined content to your needs.", | ||
| 8 | 'thumbnail': 'Template', | ||
| 9 | 'actions': [{ | ||
| 10 | 'label': 'Try it!', | ||
| 11 | 'type': 'success', | ||
| 12 | 'url': $xwiki.getURL('Sandbox.WebHome', 'create', $escapetool.url({ | ||
| 13 | 'title': "New Page $datetool.get('dd MMM yyyy, HH:mm')" | ||
| 14 | })) | ||
| 15 | }] | ||
| 16 | }, { | ||
| 17 | 'title': 'Create your template', | ||
| 18 | 'description': 'Integrate structure and macros in an existing page, and transform it in a template.', | ||
| 19 | 'tip': "<a href=""http://extensions.xwiki.org/xwiki/bin/view/Extension/Administration+Application#HCreatetheTemplateProvider"" class=""wikiexternallink"">Template Providers</a> expose templates on the Create Page dialog so that the users can use them.", | ||
| 20 | 'thumbnail': 'Administration', | ||
| 21 | 'actions': [{ | ||
| 22 | 'label': 'Learn more', | ||
| 23 | 'url': 'http://extensions.xwiki.org/xwiki/bin/view/Extension/Administration+Application#HCreatetheTemplateProvider' | ||
| 24 | }] | ||
| 25 | }]) | ||
| 26 | |||
| 27 | #if ($hasAdmin) | ||
| 28 | #set ($discard = $actionCards[1].actions.add(0, { | ||
| 29 | 'label': 'Browse', | ||
| 30 | 'url': $xwiki.getURL('XWiki.XWikiPreferences', 'admin', 'editor=globaladmin§ion=Templates') | ||
| 31 | })) | ||
| 32 | #end | ||
| 33 | |||
| 34 | #macro (getTemplateExample $inputCard $outputCard) | ||
| 35 | #set ($templateReference = $services.model.resolveDocument($inputCard.templateReference)) | ||
| 36 | #if ($xwiki.getDocument($templateReference).isNew()) | ||
| 37 | #set ($outputCard = { | ||
| 38 | 'title': $inputCard.title, | ||
| 39 | 'description': $inputCard.description, | ||
| 40 | 'documentation': 'http://extensions.xwiki.org/xwiki/bin/view/Extension/Templates+Application/', | ||
| 41 | 'thumbnail': $inputCard.thumbnail | ||
| 42 | }) | ||
| 43 | #else | ||
| 44 | #set ($outputCard = { | ||
| 45 | 'title': $inputCard.title, | ||
| 46 | 'description': $inputCard.description, | ||
| 47 | 'examples': $inputCard.templateReference, | ||
| 48 | 'thumbnail': $inputCard.thumbnail | ||
| 49 | }) | ||
| 50 | #end | ||
| 51 | #end | ||
| 52 | |||
| 53 | #set ($exampleCards = [{ | ||
| 54 | 'title': 'Article', | ||
| 55 | 'description': 'Article page', | ||
| 56 | 'templateReference': 'Templates.Article.Template.WebHome', | ||
| 57 | 'thumbnail': 'Help.Templates.WebHome@article.png' | ||
| 58 | }, { | ||
| 59 | 'title': 'Encyclopedia', | ||
| 60 | 'description': 'Encyclopedia page', | ||
| 61 | 'templateReference': 'Templates.Encyclopedia.Template.WebHome', | ||
| 62 | 'thumbnail': 'Help.Templates.WebHome@encyclopedia.png' | ||
| 63 | }, { | ||
| 64 | 'title': 'Meeting Report', | ||
| 65 | 'description': 'Agenda and notes', | ||
| 66 | 'templateReference': 'Templates.Meeting.Template.WebHome', | ||
| 67 | 'thumbnail': 'Help.Templates.WebHome@meeting.png' | ||
| 68 | }, { | ||
| 69 | 'title': 'Simple Page', | ||
| 70 | 'description': 'With table of contents', | ||
| 71 | 'templateReference': 'Templates.SimplePage.Template.WebHome', | ||
| 72 | 'thumbnail': 'Help.Templates.WebHome@simple.png' | ||
| 73 | }]) | ||
| 74 | {{/velocity}} | ||
| 75 | |||
| 76 | {{velocity}} | ||
| 77 | {{html clean="false"}} | ||
| 78 | <div class="row"> | ||
| 79 | #foreach ($card in $actionCards) | ||
| 80 | ## See http://getbootstrap.com/css/#grid-responsive-resets . | ||
| 81 | #if ($foreach.index > 0 && $foreach.index % 2 == 0) | ||
| 82 | <div class="clearfix visible-sm-block visible-md-block visible-lg-block"></div> | ||
| 83 | #end | ||
| 84 | <div class="col-xs-12 col-sm-6"> | ||
| 85 | #helpActionCard($card) | ||
| 86 | </div> | ||
| 87 | #end | ||
| 88 | </div> | ||
| 89 | <h3 id="HExamples">Examples</h3> | ||
| 90 | <p>Want to start from a predefined template? Here are some examples of available templates inside XWiki.</p> | ||
| 91 | <div class="row"> | ||
| 92 | #foreach ($card in $exampleCards) | ||
| 93 | ## See http://getbootstrap.com/css/#grid-responsive-resets . | ||
| 94 | #if ($foreach.index > 0 && $foreach.index % 2 == 0) | ||
| 95 | <div class="clearfix visible-sm-block "></div> | ||
| 96 | #end | ||
| 97 | #if ($foreach.index > 0 && $foreach.index % 3 == 0) | ||
| 98 | <div class="clearfix visible-md-block"></div> | ||
| 99 | #end | ||
| 100 | #if ($foreach.index > 0 && $foreach.index % 4 == 0) | ||
| 101 | <div class="clearfix visible-lg-block"></div> | ||
| 102 | #end | ||
| 103 | <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3"> | ||
| 104 | #set ($outputCard = {}) | ||
| 105 | #getTemplateExample($card $outputCard) | ||
| 106 | #helpExampleCard($outputCard) | ||
| 107 | </div> | ||
| 108 | #end | ||
| 109 | </div> | ||
| 110 | <p><a href="http://extensions.xwiki.org/xwiki/bin/view/Extension/Templates+Application/" class="wikiexternallink">View more templates</a></p> | ||
| 111 | {{/html}} | ||
| 112 | {{/velocity}} |