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.
 
 
 
 
 

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