post_wizard.tx 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. <br />
  29. <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 />
  30. <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 />
  31. <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 />
  32. <label for="wiz-title_input">Title input in the editor<input id="wiz-title_input" class="coolcb" type="checkbox" name="inc_title_input" value="1" <: $checked.inc_title_input :> /></label><br />
  33. <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 />
  34. <label for="wiz-visibility">Visibility selector (visibility.tx)<input id="wiz-visibility" class="coolcb" type="checkbox" name="inc_visibility" value="1" <: $checked.inc_visibility :> /></label><br />
  35. <label for="wiz-acls">ACL selector (acls.tx)<input id="wiz-acls" class="coolcb" type="checkbox" name="inc_acls" value="1" <: $checked.inc_acls :> /></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. Content Body &mdash; this is always the last thing in the editor, and is what carries the post body itself.<br />
  44. <select class="cooltext" name="body_form">
  45. <option value="form_common.tx" <: $body_form == 'form_multi.tx' ? '' : 'selected' :> >Single page (form_common.tx)</option>
  46. <option value="form_multi.tx" <: $body_form == 'form_multi.tx' ? 'selected' : '' :> >Multiple pages, like presentations (form_multi.tx)</option>
  47. </select>
  48. <p class="title">Custom Fields</p>
  49. These become extra inputs in the editor, and are available in your display template below
  50. as <code>&lt;: $post.your_field_name :&gt;</code>.
  51. Uploads aren't supported here &mdash; use the Attachment uploader above for those.
  52. <br />
  53. An <em>Another Post</em> field depends on a different post type.
  54. <em>Pick one</em> stores a single post's ID, chosen from a dropdown in the editor, and hands you
  55. the whole post as <code>&lt;: $post.your_field_name_post :&gt;</code>.
  56. <em>All of them</em> stores nothing and simply hands you every post of that type as
  57. <code>&lt;: $post.your_field_name :&gt;</code> to loop over.
  58. <div id="wizard-params"></div>
  59. <button type="button" style="float:right;" class="coolbutton" onclick="addParam(); return false;">Add Field</button>
  60. <br style="clear:both;" />
  61. <p class="title">Display Template</p>
  62. <a href="https://metacpan.org/pod/Text::Xslate::Syntax::Kolon" title="GET UR MIND RITE">Kolon</a>
  63. markup for how this post type renders when someone looks at it.
  64. <br />
  65. <code>&lt;: $tiled :&gt;</code> is true when the series asked for its posts to be tiled, so branch on it
  66. if this type wants a compact view &mdash; see <code>forms/file.tx</code> for the shape.
  67. The wrapper gets the <code>tile</code> class either way.
  68. Note that it is only ever true for logged-out visitors: an editor needs the full view.
  69. Use <code>&lt;: $post.yourfield :&gt;</code> for your custom fields, and
  70. <code>&lt;: render_it($post.data) | mark_raw :&gt;</code> for the post body.
  71. <br />
  72. <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>
  73. <br />
  74. <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>
  75. <br />
  76. <input type="submit" class="coolbutton" value="Create Post Type" />
  77. </form>
  78. <template id="wizard-param-template">
  79. <div class="wizard-param-row">
  80. <hr />
  81. Name <input required class="cooltext" type="text" name="param_name" pattern="[A-Za-z][A-Za-z0-9_]*" placeholder="cook_time" />
  82. Type <select class="cooltext param-type" name="param_type" onchange="syncRelationRow(this);">
  83. <option value="text">Text</option>
  84. <option value="url">URL</option>
  85. <option value="number">Number</option>
  86. <option value="date">Date</option>
  87. <option value="textarea">Long Text</option>
  88. <option value="checkbox">Checkbox</option>
  89. <option value="relation">Another Post</option>
  90. </select>
  91. <span class="wizard-relation" style="display:none;">
  92. of type <select class="cooltext" name="param_relation_form">
  93. : for $forms -> $form {
  94. <option value="<: $form :>"><: $form :></option>
  95. : }
  96. </select>
  97. <select class="cooltext" name="param_relation_mode">
  98. <option value="one">pick one</option>
  99. <option value="all">all of them</option>
  100. </select>
  101. </span>
  102. Label <input class="cooltext" type="text" name="param_label" placeholder="Cook Time" />
  103. Placeholder <input class="cooltext" type="text" name="param_placeholder" placeholder="45 minutes" />
  104. <select class="cooltext" name="param_required">
  105. <option value="0">Optional</option>
  106. <option value="1">Required</option>
  107. </select>
  108. <button type="button" class="coolbutton" onclick="delParam(this); return false;">Remove</button>
  109. </div>
  110. </template>
  111. </div>