| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <script type="text/javascript" src="/scripts/post_wizard.js"></script>
- <script type="application/json" id="wizard-types"><: $types | mark_raw :></script>
- <div id="backoffice">
- <p class="title">
- Existing Post Types:
- </p>
- A "post type" is just a template living in <code>templates/html/components/forms/</code>.
- Every post picks exactly one of them — it's what the <em>Content Template</em> dropdown
- selects when you edit a Series.
- <hr />
- <label for="wizard-existing">Start from</label>
- <select class="cooltext" id="wizard-existing" name="wizard_existing" onchange="fillFromType(this);">
- <option value="">A new post type</option>
- : for $forms -> $form {
- <option value="<: $form :>"><: $form :></option>
- : }
- </select>
- <p id="wizard-type-description" class="wizard-type-description"></p>
- <form class="Submissions" id="postTypeWizard" method="post" action="/admin/wyzzerdd/save">
- <details id="wizard-description-editor">
- <summary>Description — what this post type is for</summary>
- Shown here when somebody picks this type. It is stored in the sidecar under
- x-tcms-post-type, which the validator never sees, so it can say whatever is useful.
- <br />
- <textarea class="cooltext" name="description" rows="3" form="postTypeWizard"
- placeholder="A recipe, with its cook time and servings."><: $description :></textarea>
- </details>
- <hr />
- <p class="title">
- Create a new Post Type:
- </p>
- Picking an existing type above fills this form in with what that type was made from,
- so you can change one thing and save it back. Overwrite is ticked for you when you do,
- since saving it under the same name is the point — change the name and you get a
- copy instead.
- <br />
- This writes a new template into the forms directory currently in use
- (<code><: $forms_dir :></code>) along with a matching <code>.json</code> sidecar describing
- any custom fields, so that the data model knows to keep them when a post is saved.
- <hr />
- Type Name * — letters, numbers, dash and underscore only<br />
- <input required class="cooltext" type="text" name="name" pattern="[A-Za-z0-9_-]+" placeholder="recipe" value="<: $name :>" />
- <p class="title">Canned Fields</p>
- Most post types reuse the same handful of blocks. Tick whichever ones this type needs.
- The title input, the visibility selector (visibility.tx) and the ACL selector (acls.tx)
- are always included — every post has all three, and a type whose editor cannot set
- them produces posts nobody can title, find or restrict.
- <br />
- <label for="wiz-wrapper">Wrap output in the standard post <div><input id="wiz-wrapper" class="coolcb" type="checkbox" name="wrapper" value="1" <: $checked.wrapper :> /></label><br />
- <label for="wiz-post_title">Post title & 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 />
- <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 />
- <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 />
- <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 />
- <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 />
- <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 />
- <br />
- Title placeholder text<br />
- <input class="cooltext" type="text" name="title_placeholder" placeholder="Iowa Man Destroys Moon" value="<: $title_placeholder :>" />
- <br />
- Where the posts come from<br />
- <select class="cooltext" name="datasource">
- <option value="" <: $datasource ? '' : 'selected' :> >The datastore — posts people write</option>
- : for $datasources -> $source {
- <option value="<: $source :>" <: $datasource == $source ? 'selected' : '' :> ><: $source :></option>
- : }
- </select>
- <br />
- A datasource builds this type's posts from somewhere else every time the page is drawn, rather
- than from posts anybody wrote — and if it says its posts cannot be written, no editor is
- generated at all, because there would be nothing behind the form to save.
- <br />
- Content Body — this is always the last thing in the editor, and is what carries the post body itself.<br />
- <select class="cooltext" name="body_form">
- <option value="form_common.tx" <: $body_form == 'form_multi.tx' ? '' : 'selected' :> >Single page (form_common.tx)</option>
- <option value="form_multi.tx" <: $body_form == 'form_multi.tx' ? 'selected' : '' :> >Multiple pages, like presentations (form_multi.tx)</option>
- </select>
- <p class="title">Custom Fields</p>
- These become extra inputs in the editor, and are available in your display template below
- as <code><: $post.your_field_name :></code>.
- Uploads aren't supported here — use the Attachment uploader above for those.
- <br />
- Whatever a canned block already collects isn't listed here — each one has a sidecar
- beside it saying so (preview.tx has preview.json), so a preview image is that box being
- ticked rather than a field you have to add.
- <br />
- A field set to <em>editors only</em> is dropped before the page is rendered for anyone who
- cannot edit it, so it is safe to refer to in the display template below without guarding it
- yourself — useful for a connection string or anything else that shouldn't be public.
- <br />
- An <em>Another Post</em> field depends on a different post type.
- <em>Pick one</em> stores a single post's ID, chosen from a dropdown in the editor, and hands you
- the whole post as <code><: $post.your_field_name_post :></code>.
- <em>All of them</em> stores nothing and simply hands you every post of that type as
- <code><: $post.your_field_name :></code> to loop over.
- <div id="wizard-params"></div>
- <button type="button" style="float:right;" class="coolbutton" onclick="addParam(); return false;">Add Field</button>
- <br style="clear:both;" />
- <p class="title">Display Template</p>
- <a href="https://metacpan.org/pod/Text::Xslate::Syntax::Kolon" title="GET UR MIND RITE">Kolon</a>
- markup for how this post type renders when someone looks at it.
- <br />
- <code><: $tiled :></code> is true when the series asked for its posts to be tiled, so branch on it
- if this type wants a compact view — see <code>forms/file.tx</code> for the shape.
- The wrapper gets the <code>tile</code> class either way.
- Note that it is only ever true for logged-out visitors: an editor needs the full view.
- Use <code><: $post.yourfield :></code> for your custom fields, and
- <code><: render_it($post.data) | mark_raw :></code> for the post body.
- <br />
- <textarea class="cooltext" name="display" rows="12" placeholder="<div class="postData responsive-text"> <: render_it($post.data) | mark_raw :> </div>"><: $display :></textarea>
- <br />
- <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>
- <br />
- <input type="submit" class="coolbutton" value="Create Post Type" />
- </form>
- <template id="wizard-param-template">
- <div class="wizard-param-row">
- <hr />
- Name <input required class="cooltext" type="text" name="param_name" pattern="[A-Za-z][A-Za-z0-9_]*" placeholder="cook_time" />
- Type <select class="cooltext param-type" name="param_type" onchange="syncRelationRow(this);">
- <option value="text">Text</option>
- <option value="url">URL</option>
- <option value="number">Number</option>
- <option value="date">Date</option>
- <option value="textarea">Long Text</option>
- <option value="checkbox">Checkbox</option>
- <option value="relation">Another Post</option>
- </select>
- <span class="wizard-relation" style="display:none;">
- of type <select class="cooltext" name="param_relation_form">
- : for $forms -> $form {
- <option value="<: $form :>"><: $form :></option>
- : }
- </select>
- <select class="cooltext" name="param_relation_mode">
- <option value="one">pick one</option>
- <option value="all">all of them</option>
- </select>
- </span>
- Label <input class="cooltext" type="text" name="param_label" placeholder="Cook Time" />
- Placeholder <input class="cooltext" type="text" name="param_placeholder" placeholder="45 minutes" />
- <select class="cooltext" name="param_required">
- <option value="0">Optional</option>
- <option value="1">Required</option>
- </select>
- <select class="cooltext" name="param_private">
- <option value="0">Shown to everyone</option>
- <option value="1">Shown to editors only</option>
- </select>
- <!--
- The checkbox has no name, so it never submits; the hidden input beside
- it carries the value and always submits exactly one, ticked or not.
- A named checkbox would submit nothing when clear, and the server zips
- the param_* arrays together positionally, so one short row shifts
- every row after it.
- -->
- <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.">
- Index this field
- <input type="hidden" name="param_indexed" value="0" />
- <input class="coolcb" type="checkbox" onchange="syncIndexedRow(this);" />
- </label>
- <button type="button" class="coolbutton" onclick="delParam(this); return false;">Remove</button>
- </div>
- </template>
- </div>
|