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.
 
 
 
 
 

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