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.

152 lines
4.9KB

  1. {% extends "layout.html" %}
  2. {% block title %}Update Blog{% endblock %}
  3. {% block content %}
  4. {% if preview %}
  5. <h1>Preview: {{ subject }}</h1>
  6. {{ 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" 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" size="80" name="fid" value="{{ fid }}"><p>
  20. <strong>Body:</strong><br>
  21. <textarea cols="80" rows="12" name="body">{{ body }}</textarea><br>
  22. <a href="/emoticons" target="_blank">Emoticon reference</a> (opens in new window)<p>
  23. <strong>Avatar:</strong><br>
  24. <span id="avatar-preview"></span>
  25. <select name="avatar" id="avatar">
  26. <option value=""{% if avatar == "" %} selected{% endif %}>Use my profile picture</option>
  27. {% for pic in avatars %}
  28. <option value="{{ pic }}"{% if avatar == pic %} selected{% endif %}>{{ pic }}</option>
  29. {% endfor %}
  30. </select><p>
  31. <strong>Categories:</strong><br>
  32. <small>Comma-separated list, e.g. General, HTML, Perl, Web Design</small><br>
  33. <input type="text" size="40" name="categories" value="{{ categories }}"><p>
  34. <strong>Privacy:</strong><br>
  35. <select name="privacy">
  36. <option value="public"{% if privacy == "public" %} selected{% endif %}>
  37. Public: everybody can see this blog entry
  38. </option>
  39. <option value="private"{% if privacy == "private" %} selected{% endif %}>
  40. Private: only site admins can see this blog entry
  41. </option>
  42. </select><p>
  43. <strong>Options:</strong><br>
  44. <label>
  45. <input type="checkbox" name="emoticons" value="true"{% if emoticons %} checked{% endif %}>
  46. Enable graphical emoticons
  47. </label><br>
  48. <label>
  49. <input type="checkbox" name="comments" value="true"{% if comments %} checked{% endif %}>
  50. Enable comments on this entry
  51. </label><p>
  52. <strong>Time Stamp:</strong><br>
  53. <input type="text" size="2" name="month" id="month" value="{{ month }}"> /
  54. <input type="text" size="2" name="day" id="day" value="{{ day }}"> /
  55. <input type="text" size="4" name="year" id="year" value="{{ year }}"> @
  56. <input type="text" size="2" name="hour" id="hour" value="{{ hour }}"> :
  57. <input type="text" size="2" name="min" id="min" value="{{ min }}"> :
  58. <input type="text" size="2" name="sec" id="sec" value="{{ sec }}"><br>
  59. mm / dd / yyyy @ hh:mm:ss<br>
  60. <label>
  61. <input type="checkbox" id="autoup" value="yes"{% if post_id == "" %} checked{% endif %}>
  62. Automatically update
  63. </label><p>
  64. <button type="submit" name="action" value="preview">Preview</button>
  65. <button type="submit" name="action" value="publish">Publish Entry</button>
  66. </form>
  67. {% endblock %}
  68. {% block scripts %}
  69. <script>
  70. var userPic = "/static/avatars/default.png"; // TODO
  71. $(document).ready(function() {
  72. // Preview their selected avatar.
  73. updateAvatar();
  74. $("#avatar").on("change", updateAvatar);
  75. // Start ticking the timestamp updater.
  76. setInterval(timestamps, 500)
  77. });
  78. function updateAvatar() {
  79. var chosen = $("#avatar").val();
  80. var picture = ""; // which pic to show
  81. if (chosen === "") {
  82. picture = userPic;
  83. }
  84. else {
  85. picture = "/static/avatars/" + chosen;
  86. }
  87. // Show the pic
  88. if (picture.length) {
  89. $("#avatar-preview").html("<img src=\"" + picture + "\" alt=\"Preview\"><br>");
  90. }
  91. else {
  92. $("#avatar-preview").html("");
  93. }
  94. }
  95. function timestamps() {
  96. function padout(num) {
  97. if (num < 10) {
  98. return '0' + num;
  99. }
  100. return num;
  101. }
  102. if ($("#autoup").is(":checked")) {
  103. var d = new Date();
  104. var mon = d.getMonth(); // 0..11
  105. var day = d.getDate(); // 1..31
  106. var year = d.getFullYear(); // 2014
  107. var hour = d.getHours(); // 0..23
  108. var min = d.getMinutes(); // 0..59
  109. var sec = d.getSeconds(); // 0..59
  110. // Adjust the dates.
  111. mon++;
  112. mon = padout(mon);
  113. day = padout(day);
  114. hour = padout(hour);
  115. min = padout(min);
  116. sec = padout(sec);
  117. // Update the fields.
  118. $("#month").val(mon);
  119. $("#day").val(day);
  120. $("#year").val(year);
  121. $("#hour").val(hour);
  122. $("#min").val(min);
  123. $("#sec").val(sec);
  124. }
  125. }
  126. </script>
  127. {% endblock %}