post_wizard.tx 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <script type="text/javascript" src="/scripts/post_wizard.js"></script>
  2. <div id="backoffice">
  3. <p class="title">
  4. Existing Post Types:
  5. </p>
  6. A "post type" is just a template living in <code>templates/html/components/forms/</code>.
  7. Every post picks exactly one of them &mdash; it's what the <em>Content Template</em> dropdown
  8. selects when you edit a Series.
  9. <hr />
  10. <ul id="existing-post-types">
  11. : for $forms -> $form {
  12. <li><: $form :></li>
  13. : }
  14. </ul>
  15. <hr />
  16. <p class="title">
  17. Create a new Post Type:
  18. </p>
  19. This writes a new template into the forms directory currently in use
  20. (<code><: $forms_dir :></code>) along with a matching <code>.json</code> sidecar describing
  21. any custom fields, so that the data model knows to keep them when a post is saved.
  22. <hr />
  23. <form class="Submissions" id="postTypeWizard" method="post" action="/admin/wyzzerdd/save">
  24. Type Name * &mdash; letters, numbers, dash and underscore only<br />
  25. <input required class="cooltext" type="text" name="name" pattern="[A-Za-z0-9_-]+" placeholder="recipe" value="<: $name :>" />
  26. <p class="title">Canned Fields</p>
  27. Most post types reuse the same handful of blocks. Tick whichever ones this type needs.
  28. The title input, the visibility selector (visibility.tx) and the ACL selector (acls.tx)
  29. are always included &mdash; every post has all three, and a type whose editor cannot set
  30. them produces posts nobody can title, find or restrict.
  31. <br />
  32. <label for="wiz-wrapper">Wrap output in the standard post &lt;div&gt;<input id="wiz-wrapper" class="coolcb" type="checkbox" name="wrapper" value="1" <: $checked.wrapper :> /></label><br />
  33. <label for="wiz-post_title">Post title &amp; permalink (post_title.tx)<input id="wiz-post_title" class="coolcb" type="checkbox" name="inc_post_title" value="1" <: $checked.inc_post_title :> /></label><br />
  34. <label for="wiz-post_tags">Post tag list (post_tags.tx)<input id="wiz-post_tags" class="coolcb" type="checkbox" name="inc_post_tags" value="1" <: $checked.inc_post_tags :> /></label><br />
  35. <label for="wiz-preview">Preview image upload (preview.tx)<input id="wiz-preview" class="coolcb" type="checkbox" name="inc_preview" value="1" <: $checked.inc_preview :> /></label><br />
  36. <label for="wiz-tags">Tag editor (tags.tx)<input id="wiz-tags" class="coolcb" type="checkbox" name="inc_tags" value="1" <: $checked.inc_tags :> /></label><br />
  37. <label for="wiz-aliases">Alias URL editor (aliases.tx)<input id="wiz-aliases" class="coolcb" type="checkbox" name="inc_aliases" value="1" <: $checked.inc_aliases :> /></label><br />
  38. <label for="wiz-attachments">Attachment uploader (attachments.tx)<input id="wiz-attachments" class="coolcb" type="checkbox" name="inc_attachments" value="1" <: $checked.inc_attachments :> /></label><br />
  39. <br />
  40. Title placeholder text<br />
  41. <input class="cooltext" type="text" name="title_placeholder" placeholder="Iowa Man Destroys Moon" value="<: $title_placeholder :>" />
  42. <br />
  43. Where the posts come from<br />
  44. <select class="cooltext" name="datasource">
  45. <option value="" <: $datasource ? '' : 'selected' :> >The datastore &mdash; posts people write</option>
  46. : for $datasources -> $source {
  47. <option value="<: $source :>" <: $datasource == $source ? 'selected' : '' :> ><: $source :></option>
  48. : }
  49. </select>
  50. <br />
  51. A datasource builds this type's posts from somewhere else every time the page is drawn, rather
  52. than from posts anybody wrote &mdash; and if it says its posts cannot be written, no editor is
  53. generated at all, because there would be nothing behind the form to save.
  54. <br />
  55. Content Body &mdash; this is always the last thing in the editor, and is what carries the post body itself.<br />
  56. <select class="cooltext" name="body_form">
  57. <option value="form_common.tx" <: $body_form == 'form_multi.tx' ? '' : 'selected' :> >Single page (form_common.tx)</option>
  58. <option value="form_multi.tx" <: $body_form == 'form_multi.tx' ? 'selected' : '' :> >Multiple pages, like presentations (form_multi.tx)</option>
  59. </select>
  60. <p class="title">Custom Fields</p>
  61. These become extra inputs in the editor, and are available in your display template below
  62. as <code>&lt;: $post.your_field_name :&gt;</code>.
  63. Uploads aren't supported here &mdash; use the Attachment uploader above for those.
  64. <br />
  65. A field set to <em>editors only</em> is dropped before the page is rendered for anyone who
  66. cannot edit it, so it is safe to refer to in the display template below without guarding it
  67. yourself &mdash; useful for a connection string or anything else that shouldn't be public.
  68. <br />
  69. An <em>Another Post</em> field depends on a different post type.
  70. <em>Pick one</em> stores a single post's ID, chosen from a dropdown in the editor, and hands you
  71. the whole post as <code>&lt;: $post.your_field_name_post :&gt;</code>.
  72. <em>All of them</em> stores nothing and simply hands you every post of that type as
  73. <code>&lt;: $post.your_field_name :&gt;</code> to loop over.
  74. <div id="wizard-params"></div>
  75. <button type="button" style="float:right;" class="coolbutton" onclick="addParam(); return false;">Add Field</button>
  76. <br style="clear:both;" />
  77. <p class="title">Display Template</p>
  78. <a href="https://metacpan.org/pod/Text::Xslate::Syntax::Kolon" title="GET UR MIND RITE">Kolon</a>
  79. markup for how this post type renders when someone looks at it.
  80. <br />
  81. <code>&lt;: $tiled :&gt;</code> is true when the series asked for its posts to be tiled, so branch on it
  82. if this type wants a compact view &mdash; see <code>forms/file.tx</code> for the shape.
  83. The wrapper gets the <code>tile</code> class either way.
  84. Note that it is only ever true for logged-out visitors: an editor needs the full view.
  85. Use <code>&lt;: $post.yourfield :&gt;</code> for your custom fields, and
  86. <code>&lt;: render_it($post.data) | mark_raw :&gt;</code> for the post body.
  87. <br />
  88. <textarea class="cooltext" name="display" rows="12" placeholder="&lt;div class=&quot;postData responsive-text&quot;&gt;&#10; &lt;: render_it($post.data) | mark_raw :&gt;&#10;&lt;/div&gt;"><: $display :></textarea>
  89. <br />
  90. <label for="wiz-overwrite">Overwrite it if this type already exists?<input id="wiz-overwrite" class="coolcb" type="checkbox" name="overwrite" value="1" <: $checked.overwrite :> /></label>
  91. <br />
  92. <input type="submit" class="coolbutton" value="Create Post Type" />
  93. </form>
  94. <template id="wizard-param-template">
  95. <div class="wizard-param-row">
  96. <hr />
  97. Name <input required class="cooltext" type="text" name="param_name" pattern="[A-Za-z][A-Za-z0-9_]*" placeholder="cook_time" />
  98. Type <select class="cooltext param-type" name="param_type" onchange="syncRelationRow(this);">
  99. <option value="text">Text</option>
  100. <option value="url">URL</option>
  101. <option value="number">Number</option>
  102. <option value="date">Date</option>
  103. <option value="textarea">Long Text</option>
  104. <option value="checkbox">Checkbox</option>
  105. <option value="relation">Another Post</option>
  106. </select>
  107. <span class="wizard-relation" style="display:none;">
  108. of type <select class="cooltext" name="param_relation_form">
  109. : for $forms -> $form {
  110. <option value="<: $form :>"><: $form :></option>
  111. : }
  112. </select>
  113. <select class="cooltext" name="param_relation_mode">
  114. <option value="one">pick one</option>
  115. <option value="all">all of them</option>
  116. </select>
  117. </span>
  118. Label <input class="cooltext" type="text" name="param_label" placeholder="Cook Time" />
  119. Placeholder <input class="cooltext" type="text" name="param_placeholder" placeholder="45 minutes" />
  120. <select class="cooltext" name="param_required">
  121. <option value="0">Optional</option>
  122. <option value="1">Required</option>
  123. </select>
  124. <select class="cooltext" name="param_private">
  125. <option value="0">Shown to everyone</option>
  126. <option value="1">Shown to editors only</option>
  127. </select>
  128. <!--
  129. The checkbox has no name, so it never submits; the hidden input beside
  130. it carries the value and always submits exactly one, ticked or not.
  131. A named checkbox would submit nothing when clear, and the server zips
  132. the param_* arrays together positionally, so one short row shifts
  133. every row after it.
  134. -->
  135. <label class="wizard-index" title="Give this field its own column and index, so queries on it do not have to read every post. Costs a little on save and some disk; only worth it for a field you actually search or filter on.">
  136. Index this field
  137. <input type="hidden" name="param_indexed" value="0" />
  138. <input class="coolcb" type="checkbox" onchange="syncIndexedRow(this);" />
  139. </label>
  140. <button type="button" class="coolbutton" onclick="delParam(this); return false;">Remove</button>
  141. </div>
  142. </template>
  143. </div>