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.
 
 
 
 
 

274 lines
10 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. {{if .Monetization}}
  139. <div class="option">
  140. <h2>Web Monetization</h2>
  141. <div class="section">
  142. <p class="explain">Web Monetization enables you to receive micropayments from readers that have a <a href="https://coil.com">Coil membership</a>. Add your payment pointer to enable Web Monetization on your blog.</p>
  143. <input type="text" name="monetization_pointer" style="width:100%" value="{{.MonetizationPointer}}" placeholder="$wallet.example.com/alice" />
  144. </div>
  145. </div>
  146. {{end}}
  147. <div class="option" style="text-align: center; margin-top: 4em;">
  148. <input type="submit" id="save-changes" value="Save changes" />
  149. <p><a href="{{if .SingleUser}}/{{else}}/{{.Alias}}/{{end}}">View Blog</a></p>
  150. {{if ne .Alias .Username}}<p><a class="danger" href="#modal-delete" onclick="promptDelete();">Delete Blog...</a></p>{{end}}
  151. </div>
  152. </div>
  153. </form>
  154. </div>
  155. <div id="modal-delete" class="modal">
  156. <h2>Are you sure you want to delete this blog?</h2>
  157. <div class="body short">
  158. <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>
  159. <p>If you're sure you want to delete this blog, enter its name in the box below and press <strong>Delete</strong>.</p>
  160. <ul id="delete-errors" class="errors"></ul>
  161. <input id="confirm-text" placeholder="{{.Alias}}" type="text" class="boxy" style="margin-top: 0.5em;" />
  162. <div style="text-align:right; margin-top: 1em;">
  163. <a id="cancel-delete" style="margin-right:2em" href="#">Cancel</a>
  164. <button id="btn-delete" class="danger" onclick="deleteBlog(); return false;">Delete</button>
  165. </div>
  166. </div>
  167. </div>
  168. <script src="/js/h.js"></script>
  169. <script src="/js/ace.js" type="text/javascript" charset="utf-8"></script>
  170. <script>
  171. // Begin shared modal code
  172. function showModal(id) {
  173. document.getElementById('overlay').style.display = 'block';
  174. document.getElementById('modal-'+id).style.display = 'block';
  175. }
  176. var closeModals = function(e) {
  177. e.preventDefault();
  178. document.getElementById('overlay').style.display = 'none';
  179. var modals = document.querySelectorAll('.modal');
  180. for (var i=0; i<modals.length; i++) {
  181. modals[i].style.display = 'none';
  182. }
  183. };
  184. H.getEl('overlay').on('click', closeModals);
  185. H.getEl('cancel-delete').on('click', closeModals);
  186. // end
  187. var deleteBlog = function(e) {
  188. if (document.getElementById('confirm-text').value != '{{.Alias}}') {
  189. document.getElementById('delete-errors').innerHTML = '<li class="urgent">Enter <strong>{{.Alias}}</strong> in the box below.</li>';
  190. return;
  191. }
  192. // Clear errors
  193. document.getElementById('delete-errors').innerHTML = '';
  194. document.getElementById('btn-delete').innerHTML = 'Deleting...';
  195. var http = new XMLHttpRequest();
  196. var url = "/api/collections/{{.Alias}}?web=1";
  197. http.open("DELETE", url, true);
  198. http.setRequestHeader("Content-type", "application/json");
  199. http.onreadystatechange = function() {
  200. if (http.readyState == 4) {
  201. if (http.status == 204) {
  202. window.location = '/me/c/';
  203. } else {
  204. var data = JSON.parse(http.responseText);
  205. document.getElementById('delete-errors').innerHTML = '<li class="urgent">'+data.error_msg+'</li>';
  206. document.getElementById('btn-delete').innerHTML = 'Delete';
  207. }
  208. }
  209. };
  210. http.send(null);
  211. };
  212. function createHidden(theForm, key, value) {
  213. var input = document.createElement('input');
  214. input.type = 'hidden';
  215. input.name = key;
  216. input.value = value;
  217. theForm.appendChild(input);
  218. }
  219. function disableSubmit() {
  220. var $form = document.forms['customize-form'];
  221. createHidden($form, 'style_sheet', cssEditor.getSession().getValue());
  222. var $btn = document.getElementById("save-changes");
  223. $btn.value = "Saving changes...";
  224. $btn.disabled = true;
  225. return true;
  226. }
  227. function promptDelete() {
  228. showModal("delete");
  229. }
  230. var $fediDomain = document.getElementById('fedi-domain');
  231. var $fediCustomDomain = document.getElementById('fedi-custom-domain');
  232. var $customDomain = document.getElementById('domain-alias');
  233. var $customHandleEnv = document.getElementById('custom-handle-env');
  234. var $normalHandleEnv = document.getElementById('normal-handle-env');
  235. var opt = {
  236. showLineNumbers: false,
  237. showPrintMargin: 0,
  238. };
  239. var theme = "ace/theme/chrome";
  240. var cssEditor = ace.edit("css-editor");
  241. cssEditor.setTheme(theme);
  242. cssEditor.session.setMode("ace/mode/css");
  243. cssEditor.setOptions(opt);
  244. </script>
  245. {{template "footer" .}}
  246. {{end}}