You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

components.html 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. {% macro post(post, type) %}
  2. {% if not post.draft or logged_in %}
  3. <div class="post">
  4. {% if type != 'index' and post.draft %}
  5. <p class="message message--success">this post is a draft</p>
  6. {% endif %}
  7. <div class="post__heading">
  8. <div class="post__title">
  9. <span class="post__date">:: {{ post.date }} //</span>
  10. <a class="post__link" href="/posts/{{ post.slug }}">
  11. {{ post.title }}
  12. </a>
  13. </div>
  14. {% if logged_in %}
  15. <div class="post__meta">
  16. <a class="post__link" href="/posts/{{ post.slug }}/edit">edit</a>
  17. <span class="post__link danger" data-delete="{{ post.slug }}">delete</span>
  18. {% if post.draft %}
  19. <strong>~ draft</strong>
  20. {% endif %}
  21. </div>
  22. {% endif %}
  23. </div>
  24. {% if type != "index" %}
  25. <div class="post__body">
  26. {{ post.html | safe }}
  27. </div>
  28. {% endif %}
  29. </div>
  30. {% endif %}
  31. {% endmacro %}
  32. {% macro form(post=false, action) %}
  33. <form class="form" method="POST" action="{{ action }}" id="post-form">
  34. <input
  35. type="hidden"
  36. name="date"
  37. value="{% if post %}{{ post.date }}{% endif %}"
  38. />
  39. <input type="hidden" name="html" />
  40. <div class="form__field">
  41. <label for="title" class="form__label">Title</label>
  42. <input
  43. class="form__text-field"
  44. type="text"
  45. name="title"
  46. required
  47. value="{% if post %}{{ post.title }}{% endif %}"
  48. />
  49. </div>
  50. <div class="form__field">
  51. <label for="slug" class="form__label">Slug</label>
  52. <input
  53. class="form__text-field"
  54. type="text"
  55. name="slug"
  56. required
  57. value="{% if post %}{{ post.slug }}{% endif %}"
  58. />
  59. </div>
  60. <div class="form__field">
  61. <label for="body" class="form__label">Body</label>
  62. <div class="editor-helpers">
  63. <button class="btn" data-editor-helper="bold">bold</button>
  64. <button class="btn" data-editor-helper="italic">italic</button>
  65. <button class="btn" data-editor-helper="link">link</button>
  66. <button class="btn" data-editor-helper="code">code</button>
  67. </div>
  68. <textarea
  69. class="form__textarea"
  70. name="body"
  71. required
  72. >{% if post %}{{ post.body }}{% endif %}</textarea>
  73. </div>
  74. <div class="form__field">
  75. <label for="draft">
  76. Save as Draft?
  77. <input type="checkbox" name="draft" value="1" {% if post.draft %}checked{% endif %}>
  78. </label>
  79. </div>
  80. <div class="form__field">
  81. <a class="btn" href="#" data-preview>Preview</a>
  82. <input class="btn btn--green" type="submit" value="Post">
  83. </div>
  84. </form>
  85. {% endmacro %}