A Python content management system designed for kirsle.net featuring a blog, comments and photo albums. https://rophako.kirsle.net/
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.
 
 
 
 
 

165 lines
4.9 KiB

  1. {% extends "layout.html" %}
  2. {% block title %}Update Blog{% endblock %}
  3. {% block content %}
  4. {% if preview %}
  5. <h1>Preview: {{ subject }}</h1>
  6. {{ rendered_body|safe }}
  7. <hr>
  8. {% endif %}
  9. <h1>Update Blog</h1>
  10. <form name="editor" action="{{ url_for('blog.update') }}" method="POST">
  11. <input type="hidden" name="id" value="{{ post_id }}">
  12. <input type="hidden" name="author" value="{{ author }}">
  13. <input type="hidden" name="token" value="{{ csrf_token() }}">
  14. <strong>Subject:</strong><br>
  15. <input type="text" class="form-control" size="80" name="subject" value="{{ subject }}"><p>
  16. <strong>Friendly ID:</strong><br>
  17. You can leave this blank if this is a new post. It defaults to be based
  18. on the subject.<br>
  19. <input type="text" class="form-control" size="80" name="fid" value="{{ fid }}"><p>
  20. <strong>Body:</strong><br>
  21. <label>
  22. <input type="radio" name="format" value="markdown"{% if format == "markdown" %} checked{% endif %}> Markdown
  23. </label>
  24. <label>
  25. <input type="radio" name="format" value="html"{% if format == "html" %} checked{% endif %}> HTML
  26. </label><br>
  27. <textarea class="form-control input-lg" cols="80" rows="12" name="body">{{ body }}</textarea><br>
  28. <a href="/markdown" target="_blank">Markdown cheatsheet</a> /
  29. <a href="{{ url_for('emoticons.index') }}" target="_blank">Emoticon reference</a> (opens in new window)<br>
  30. Optional: separate your summary from the rest of the post by typing <code>&lt;snip&gt;</code>
  31. where you want the division to appear.<p>
  32. <strong>Avatar:</strong><br>
  33. <span id="avatar-preview"></span>
  34. <select name="avatar" id="avatar" class="form-control">
  35. <option value=""{% if avatar == "" %} selected{% endif %}>Use my profile picture</option>
  36. {% for pic in avatars %}
  37. <option value="{{ pic }}"{% if avatar == pic %} selected{% endif %}>{{ pic }}</option>
  38. {% endfor %}
  39. </select><p>
  40. <strong>Categories:</strong><br>
  41. <small>Comma-separated list, e.g. General, HTML, Perl, Web Design</small><br>
  42. <input type="text" class="form-control" size="40" name="categories" value="{{ categories }}"><p>
  43. <strong>Privacy:</strong><br>
  44. <select name="privacy" class="form-control">
  45. <option value="public"{% if privacy == "public" %} selected{% endif %}>
  46. Public: everybody can see this blog entry
  47. </option>
  48. <option value="draft"{% if privacy == "draft" %} selected{% endif %}>
  49. Draft: don't show this on the blog anywhere
  50. </option>
  51. <option value="private"{% if privacy == "private" %} selected{% endif %}>
  52. Private: only site admins can see this blog entry
  53. </option>
  54. </select><p>
  55. <strong>Options:</strong><br>
  56. <label>
  57. <input type="checkbox" name="sticky" value="true"{% if sticky %} checked{% endif %}>
  58. Make this post sticky (always on top)
  59. </label><br>
  60. <label>
  61. <input type="checkbox" name="emoticons" value="true"{% if emoticons %} checked{% endif %}>
  62. Enable graphical emoticons
  63. </label><br>
  64. <label>
  65. <input type="checkbox" name="comments" value="true"{% if comments %} checked{% endif %}>
  66. Enable comments on this entry
  67. </label><p>
  68. <input type="hidden" name="time" value="{{ time }}">
  69. {% if post_id != "" %}
  70. <strong>Reset Time Stamp:</strong><br>
  71. <label>
  72. <input type="checkbox" name="reset-time" value="yes"{% if post_id == "" %} checked{% endif %}>
  73. Reset the post's time stamp to the current time.
  74. </label><p>
  75. {% endif %}
  76. <button type="submit" class="btn btn-default" name="action" value="preview">Preview</button>
  77. <button type="submit" class="btn btn-primary" name="action" value="publish">Publish Entry</button>
  78. </form>
  79. {% endblock %}
  80. {% block scripts %}
  81. <script>
  82. var userPic = "{% if userpic %}{{ app['photo_url'] }}/{{ userpic }}{% else %}/static/avatars/default.png{% endif %}";
  83. $(document).ready(function() {
  84. // Preview their selected avatar.
  85. updateAvatar();
  86. $("#avatar").on("change", updateAvatar);
  87. // Start ticking the timestamp updater.
  88. setInterval(timestamps, 500)
  89. });
  90. function updateAvatar() {
  91. var chosen = $("#avatar").val();
  92. var picture = ""; // which pic to show
  93. if (chosen === "") {
  94. picture = userPic;
  95. }
  96. else {
  97. picture = "/static/avatars/" + chosen;
  98. }
  99. // Show the pic
  100. if (picture.length) {
  101. $("#avatar-preview").html("<img src=\"" + picture + "\" alt=\"Preview\"><br>");
  102. }
  103. else {
  104. $("#avatar-preview").html("");
  105. }
  106. }
  107. function timestamps() {
  108. function padout(num) {
  109. if (num < 10) {
  110. return '0' + num;
  111. }
  112. return num;
  113. }
  114. if ($("#autoup").is(":checked")) {
  115. var d = new Date();
  116. var mon = d.getMonth(); // 0..11
  117. var day = d.getDate(); // 1..31
  118. var year = d.getFullYear(); // 2014
  119. var hour = d.getHours(); // 0..23
  120. var min = d.getMinutes(); // 0..59
  121. var sec = d.getSeconds(); // 0..59
  122. // Adjust the dates.
  123. mon++;
  124. mon = padout(mon);
  125. day = padout(day);
  126. hour = padout(hour);
  127. min = padout(min);
  128. sec = padout(sec);
  129. // Update the fields.
  130. $("#month").val(mon);
  131. $("#day").val(day);
  132. $("#year").val(year);
  133. $("#hour").val(hour);
  134. $("#min").val(min);
  135. $("#sec").val(sec);
  136. }
  137. }
  138. </script>
  139. {% endblock %}