A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
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.
 
 
 
 
 

259 lines
9.5 KiB

  1. {{define "upgrade"}}
  2. <p><a href="/me/plan?to=/me/c/{{.Alias}}">Upgrade</a> for <span>$40 / year</span> to edit.</p>
  3. {{end}}
  4. {{define "collection"}}
  5. {{template "header" .}}
  6. <style>
  7. textarea.section.norm {
  8. font-family: Lora,'Palatino Linotype','Book Antiqua','New York','DejaVu serif',serif !important;
  9. min-height: 10em;
  10. max-height: 20em;
  11. resize: vertical;
  12. }
  13. </style>
  14. <div class="content-container snug">
  15. <div id="overlay"></div>
  16. {{if .Silenced}}
  17. {{template "user-silenced"}}
  18. {{end}}
  19. <h2>Customize {{.DisplayTitle}} <a href="{{if .SingleUser}}/{{else}}/{{.Alias}}/{{end}}">view blog</a></h2>
  20. {{if .Flashes}}<ul class="errors">
  21. {{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
  22. </ul>{{end}}
  23. <form name="customize-form" action="/api/collections/{{.Alias}}" method="post" onsubmit="return disableSubmit()">
  24. <div id="collection-options">
  25. <div style="text-align:center">
  26. <h1><input type="text" name="title" id="title" value="{{.DisplayTitle}}" placeholder="Title" /></h1>
  27. <p><input type="text" name="description" id="description" value="{{.Description}}" placeholder="Description" /></p>
  28. </div>
  29. <div class="option">
  30. <h2><a name="preferred-url"></a>URL</h2>
  31. <div class="section">
  32. {{if eq .Alias .Username}}<p style="font-size: 0.8em">This blog uses your username in its URL{{if .Federation}} and fediverse handle{{end}}. You can change it in your <a href="/me/settings">Account Settings</a>.</p>{{end}}
  33. <ul style="list-style:none">
  34. <li>
  35. {{.FriendlyHost}}/<strong>{{.Alias}}</strong>/
  36. </li>
  37. <li>
  38. <strong id="normal-handle-env" class="fedi-handle" {{if not .Federation}}style="display:none"{{end}}>@<span id="fedi-handle">{{.Alias}}</span>@<span id="fedi-domain">{{.FriendlyHost}}</span></strong>
  39. </li>
  40. </ul>
  41. </div>
  42. </div>
  43. <div class="option">
  44. <h2>Publicity</h2>
  45. <div class="section">
  46. <ul style="list-style:none">
  47. <li>
  48. <label><input type="radio" name="visibility" id="visibility-unlisted" value="0" {{if .IsUnlisted}}checked="checked"{{end}} />
  49. Unlisted
  50. </label>
  51. <p>This blog is visible to {{if .Private}}any registered user on this instance{{else}}anyone with its link{{end}}.</p>
  52. </li>
  53. <li>
  54. <label class="option-text"><input type="radio" name="visibility" id="visibility-private" value="2" {{if .IsPrivate}}checked="checked"{{end}} />
  55. Private
  56. </label>
  57. <p>Only you may read this blog (while you're logged in).</p>
  58. </li>
  59. <li>
  60. <label class="option-text"><input type="radio" name="visibility" id="visibility-protected" value="4" {{if .IsProtected}}checked="checked"{{end}} />
  61. Password-protected: <input type="password" class="low-profile" name="password" id="collection-pass" autocomplete="new-password" placeholder="{{if .IsProtected}}xxxxxxxxxxxxxxxx{{else}}a memorable password{{end}}" />
  62. </label>
  63. <p>A password is required to read this blog.</p>
  64. </li>
  65. {{if not .SingleUser}}
  66. <li>
  67. <label class="option-text{{if not .LocalTimeline}} disabled{{end}}"><input type="radio" name="visibility" id="visibility-public" value="1" {{if .IsPublic}}checked="checked"{{end}} {{if not .LocalTimeline}}disabled="disabled"{{end}} />
  68. Public
  69. </label>
  70. {{if .LocalTimeline}}<p>This blog is displayed on the public <a href="/read">reader</a>, and is visible to {{if .Private}}any registered user on this instance{{else}}anyone with its link{{end}}.</p>
  71. {{else}}<p>The public reader is currently turned off for this community.</p>{{end}}
  72. </li>
  73. {{end}}
  74. </ul>
  75. </div>
  76. </div>
  77. <div class="option">
  78. <h2>Display Format</h2>
  79. <div class="section">
  80. <p class="explain">Customize how your posts display on your page.
  81. </p>
  82. <ul style="list-style:none">
  83. <li>
  84. <label><input type="radio" name="format" id="format-blog" value="blog" {{if or (not .Format) (eq .Format "blog")}}checked="checked"{{end}} />
  85. Blog
  86. </label>
  87. <p>Dates are shown. Latest posts listed first.</p>
  88. </li>
  89. <li>
  90. <label class="option-text"><input type="radio" name="format" id="format-novel" value="novel" {{if eq .Format "novel"}}checked="checked"{{end}} />
  91. Novel
  92. </label>
  93. <p>No dates shown. Oldest posts first.</p>
  94. </li>
  95. <li>
  96. <label class="option-text"><input type="radio" name="format" id="format-notebook" value="notebook" {{if eq .Format "notebook"}}checked="checked"{{end}} />
  97. Notebook
  98. </label>
  99. <p>No dates shown. Latest posts first.</p>
  100. </li>
  101. </ul>
  102. </div>
  103. </div>
  104. <div class="option">
  105. <h2>Text Rendering</h2>
  106. <div class="section">
  107. <p class="explain">Customize how plain text renders on your blog.</p>
  108. <ul style="list-style:none">
  109. <li>
  110. <label class="option-text disabled"><input type="checkbox" name="markdown" checked="checked" disabled />
  111. Markdown
  112. </label>
  113. </li>
  114. <li>
  115. <label><input type="checkbox" name="mathjax" {{if .RenderMathJax}}checked="checked"{{end}} />
  116. MathJax
  117. </label>
  118. </li>
  119. </ul>
  120. </div>
  121. </div>
  122. <div class="option">
  123. <h2>Custom CSS</h2>
  124. <div class="section">
  125. <textarea id="css-editor" class="section codable" name="style_sheet">{{.StyleSheet}}</textarea>
  126. <p class="explain">See our guide on <a href="https://guides.write.as/customizing/#custom-css">customization</a>.</p>
  127. </div>
  128. </div>
  129. <div class="option">
  130. <h2>Post Signature</h2>
  131. <div class="section">
  132. <p class="explain">This content will be added to the end of every post on this blog, as if it were part of the post itself. Markdown, HTML, and shortcodes are allowed.</p>
  133. <textarea id="signature" class="section norm" name="signature">{{.Signature}}</textarea>
  134. </div>
  135. </div>
  136. <div class="option" style="text-align: center; margin-top: 4em;">
  137. <input type="submit" id="save-changes" value="Save changes" />
  138. <p><a href="{{if .SingleUser}}/{{else}}/{{.Alias}}/{{end}}">View Blog</a></p>
  139. {{if ne .Alias .Username}}<p><a class="danger" href="#modal-delete" onclick="promptDelete();">Delete Blog...</a></p>{{end}}
  140. </div>
  141. </div>
  142. </form>
  143. </div>
  144. <div id="modal-delete" class="modal">
  145. <h2>Are you sure you want to delete this blog?</h2>
  146. <div class="body short">
  147. <p style="text-align:left">This will permanently erase <strong>{{.DisplayTitle}}</strong> ({{.FriendlyHost}}/{{.Alias}}) from the internet. Any posts on this blog will be saved and made into drafts (found on your <a href="/me/posts/">Drafts</a> page).</p>
  148. <p>If you're sure you want to delete this blog, enter its name in the box below and press <strong>Delete</strong>.</p>
  149. <ul id="delete-errors" class="errors"></ul>
  150. <input id="confirm-text" placeholder="{{.Alias}}" type="text" class="boxy" style="margin-top: 0.5em;" />
  151. <div style="text-align:right; margin-top: 1em;">
  152. <a id="cancel-delete" style="margin-right:2em" href="#">Cancel</a>
  153. <button id="btn-delete" class="danger" onclick="deleteBlog(); return false;">Delete</button>
  154. </div>
  155. </div>
  156. </div>
  157. <script src="/js/h.js"></script>
  158. <script src="/js/ace.js" type="text/javascript" charset="utf-8"></script>
  159. <script>
  160. // Begin shared modal code
  161. function showModal(id) {
  162. document.getElementById('overlay').style.display = 'block';
  163. document.getElementById('modal-'+id).style.display = 'block';
  164. }
  165. var closeModals = function(e) {
  166. e.preventDefault();
  167. document.getElementById('overlay').style.display = 'none';
  168. var modals = document.querySelectorAll('.modal');
  169. for (var i=0; i<modals.length; i++) {
  170. modals[i].style.display = 'none';
  171. }
  172. };
  173. H.getEl('overlay').on('click', closeModals);
  174. H.getEl('cancel-delete').on('click', closeModals);
  175. // end
  176. var deleteBlog = function(e) {
  177. if (document.getElementById('confirm-text').value != '{{.Alias}}') {
  178. document.getElementById('delete-errors').innerHTML = '<li class="urgent">Enter <strong>{{.Alias}}</strong> in the box below.</li>';
  179. return;
  180. }
  181. // Clear errors
  182. document.getElementById('delete-errors').innerHTML = '';
  183. document.getElementById('btn-delete').innerHTML = 'Deleting...';
  184. var http = new XMLHttpRequest();
  185. var url = "/api/collections/{{.Alias}}?web=1";
  186. http.open("DELETE", url, true);
  187. http.setRequestHeader("Content-type", "application/json");
  188. http.onreadystatechange = function() {
  189. if (http.readyState == 4) {
  190. if (http.status == 204) {
  191. window.location = '/me/c/';
  192. } else {
  193. var data = JSON.parse(http.responseText);
  194. document.getElementById('delete-errors').innerHTML = '<li class="urgent">'+data.error_msg+'</li>';
  195. document.getElementById('btn-delete').innerHTML = 'Delete';
  196. }
  197. }
  198. };
  199. http.send(null);
  200. };
  201. function createHidden(theForm, key, value) {
  202. var input = document.createElement('input');
  203. input.type = 'hidden';
  204. input.name = key;
  205. input.value = value;
  206. theForm.appendChild(input);
  207. }
  208. function disableSubmit() {
  209. var $form = document.forms['customize-form'];
  210. createHidden($form, 'style_sheet', cssEditor.getSession().getValue());
  211. var $btn = document.getElementById("save-changes");
  212. $btn.value = "Saving changes...";
  213. $btn.disabled = true;
  214. return true;
  215. }
  216. function promptDelete() {
  217. showModal("delete");
  218. }
  219. var $fediDomain = document.getElementById('fedi-domain');
  220. var $fediCustomDomain = document.getElementById('fedi-custom-domain');
  221. var $customDomain = document.getElementById('domain-alias');
  222. var $customHandleEnv = document.getElementById('custom-handle-env');
  223. var $normalHandleEnv = document.getElementById('normal-handle-env');
  224. var opt = {
  225. showLineNumbers: false,
  226. showPrintMargin: 0,
  227. };
  228. var theme = "ace/theme/chrome";
  229. var cssEditor = ace.edit("css-editor");
  230. cssEditor.setTheme(theme);
  231. cssEditor.session.setMode("ace/mode/css");
  232. cssEditor.setOptions(opt);
  233. </script>
  234. {{template "footer" .}}
  235. {{end}}