A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

181 řádky
4.7 KiB

  1. {{define "head"}}
  2. <title>Sign up &mdash; {{.SiteName}}</title>
  3. <style type="text/css">
  4. h2 {
  5. font-weight: normal;
  6. }
  7. #pricing.content-container div.form-container #payment-form {
  8. display: block !important;
  9. }
  10. #pricing #signup-form table {
  11. max-width: inherit !important;
  12. width: 100%;
  13. }
  14. #pricing #payment-form table {
  15. margin-top: 0 !important;
  16. max-width: inherit !important;
  17. width: 100%;
  18. }
  19. tr.subscription {
  20. border-spacing: 0;
  21. }
  22. #pricing.content-container tr.subscription button {
  23. margin-top: 0 !important;
  24. margin-bottom: 0 !important;
  25. width: 100%;
  26. }
  27. #pricing tr.subscription td {
  28. padding: 0 0.5em;
  29. }
  30. #pricing table.billing > tbody > tr > td:first-child {
  31. vertical-align: middle !important;
  32. }
  33. .billing-section {
  34. display: none;
  35. }
  36. .billing-section.bill-me {
  37. display: table-row;
  38. }
  39. #btn-create {
  40. color: white !important;
  41. }
  42. #total-price {
  43. padding-left: 0.5em;
  44. }
  45. #alias-site.demo {
  46. color: #999;
  47. }
  48. #alias-site {
  49. text-align: left;
  50. margin: 0.5em 0;
  51. }
  52. form dd {
  53. margin: 0;
  54. }
  55. </style>
  56. {{end}}
  57. {{define "content"}}
  58. <div id="pricing" class="content-container wide-form">
  59. <div class="row">
  60. <div style="margin: 0 auto; max-width: 25em;">
  61. <h1>Sign up</h1>
  62. {{ if .Error }}
  63. <p style="font-style: italic">{{.Error}}</p>
  64. {{ else }}
  65. {{if .Flashes}}<ul class="errors">
  66. {{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
  67. </ul>{{end}}
  68. <div id="billing">
  69. {{template "oauth-buttons" .}}
  70. {{if not .DisablePasswordAuth}}
  71. <form action="/auth/signup" method="POST" id="signup-form" onsubmit="return signup()">
  72. <input type="hidden" name="invite_code" value="{{.Invite}}" />
  73. <dl class="billing">
  74. <label>
  75. <dt>Username</dt>
  76. <dd>
  77. <input type="text" id="alias" name="alias" style="width: 100%; box-sizing: border-box;" tabindex="1" autofocus />
  78. {{if .Federation}}<p id="alias-site" class="demo">@<strong>your-username</strong>@{{.FriendlyHost}}</p>{{else}}<p id="alias-site" class="demo">{{.FriendlyHost}}/<strong>your-username</strong></p>{{end}}
  79. </dd>
  80. </label>
  81. <label>
  82. <dt>Password</dt>
  83. <dd><input type="password" id="password" name="pass" autocomplete="new-password" placeholder="" tabindex="2" style="width: 100%; box-sizing: border-box;" /></dd>
  84. </label>
  85. <label>
  86. <dt>Email (optional)</dt>
  87. <dd><input type="email" name="email" id="email" style="letter-spacing: 1px; width: 100%; box-sizing: border-box;" placeholder="me@example.com" tabindex="3" /></dd>
  88. </label>
  89. <dt>
  90. <button id="btn-create" type="submit" style="margin-top: 0">Create blog</button>
  91. </dt>
  92. </dl>
  93. </form>
  94. {{end}}
  95. </div>
  96. {{ end }}
  97. </div>
  98. </div>
  99. <script type="text/javascript" src="/js/h.js"></script>
  100. <script type="text/javascript">
  101. function signup() {
  102. var $pass = document.getElementById('password');
  103. // Validate input
  104. if (!aliasOK) {
  105. var $a = $alias;
  106. $a.el.className = 'error';
  107. $a.el.focus();
  108. $a.el.scrollIntoView();
  109. return false;
  110. }
  111. if ($pass.value == "") {
  112. var $a = $pass;
  113. $a.className = 'error';
  114. $a.focus();
  115. $a.scrollIntoView();
  116. return false;
  117. }
  118. var $btn = document.getElementById('btn-create');
  119. $btn.disabled = true;
  120. $btn.value = 'Creating...';
  121. return true;
  122. }
  123. var $alias = H.getEl('alias');
  124. var $aliasSite = document.getElementById('alias-site');
  125. var aliasOK = true;
  126. var typingTimer;
  127. var doneTypingInterval = 750;
  128. var doneTyping = function() {
  129. // Check on username
  130. var alias = $alias.el.value;
  131. if (alias != "") {
  132. var params = {
  133. username: alias
  134. };
  135. var http = new XMLHttpRequest();
  136. http.open("POST", '/api/alias', true);
  137. // Send the proper header information along with the request
  138. http.setRequestHeader("Content-type", "application/json");
  139. http.onreadystatechange = function() {
  140. if (http.readyState == 4) {
  141. data = JSON.parse(http.responseText);
  142. if (http.status == 200) {
  143. aliasOK = true;
  144. $alias.removeClass('error');
  145. $aliasSite.className = $aliasSite.className.replace(/(?:^|\s)demo(?!\S)/g, '');
  146. $aliasSite.className = $aliasSite.className.replace(/(?:^|\s)error(?!\S)/g, '');
  147. $aliasSite.innerHTML = '{{ if .Federation }}@<strong>' + data.data + '</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>' + data.data + '</strong>/{{ end }}';
  148. } else {
  149. aliasOK = false;
  150. $alias.setClass('error');
  151. $aliasSite.className = 'error';
  152. $aliasSite.textContent = data.error_msg;
  153. }
  154. }
  155. }
  156. http.send(JSON.stringify(params));
  157. } else {
  158. $aliasSite.className += ' demo';
  159. $aliasSite.innerHTML = '{{ if .Federation }}@<strong>your-username</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>your-username</strong>/{{ end }}';
  160. }
  161. };
  162. $alias.on('keyup input', function() {
  163. clearTimeout(typingTimer);
  164. typingTimer = setTimeout(doneTyping, doneTypingInterval);
  165. });
  166. </script>
  167. {{end}}