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.
 
 
 
 
 

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