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.
 
 
 
 
 

196 lines
5.6 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. {{ if or .OAuth.SlackEnabled .OAuth.WriteAsEnabled .OAuth.GitLabEnabled }}
  70. <div class="row content-container signinbtns">
  71. {{ if .OAuth.SlackEnabled }}
  72. <a class="loginbtn" href="/oauth/slack{{if .Invite}}?invite_code={{.Invite}}{{end}}"><img alt="Sign in with Slack" height="40" width="172" src="/img/sign_in_with_slack.png" srcset="/img/sign_in_with_slack.png 1x, /img/sign_in_with_slack@2x.png 2x" /></a>
  73. {{ end }}
  74. {{ if .OAuth.WriteAsEnabled }}
  75. <a class="btn cta loginbtn" id="writeas-login" href="/oauth/write.as{{if .Invite}}?invite_code={{.Invite}}{{end}}">Sign in with <strong>Write.as</strong></a>
  76. {{ end }}
  77. {{ if .OAuth.GitLabEnabled }}
  78. <a class="btn cta loginbtn" id="gitlab-login" href="/oauth/gitlab{{if .Invite}}?invite_code={{.Invite}}{{end}}">Sign in with <strong>{{.OAuth.GitLabDisplayName}}</strong></a>
  79. {{ end }}
  80. </div>
  81. <div class="or">
  82. <p>or</p>
  83. <hr class="short" />
  84. </div>
  85. {{ end }}
  86. <form action="/auth/signup" method="POST" id="signup-form" onsubmit="return signup()">
  87. <input type="hidden" name="invite_code" value="{{.Invite}}" />
  88. <dl class="billing">
  89. <label>
  90. <dt>Username</dt>
  91. <dd>
  92. <input type="text" id="alias" name="alias" style="width: 100%; box-sizing: border-box;" tabindex="1" autofocus />
  93. {{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}}
  94. </dd>
  95. </label>
  96. <label>
  97. <dt>Password</dt>
  98. <dd><input type="password" id="password" name="pass" autocomplete="new-password" placeholder="" tabindex="2" style="width: 100%; box-sizing: border-box;" /></dd>
  99. </label>
  100. <label>
  101. <dt>Email (optional)</dt>
  102. <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>
  103. </label>
  104. <dt>
  105. <button id="btn-create" type="submit" style="margin-top: 0">Create blog</button>
  106. </dt>
  107. </dl>
  108. </form>
  109. </div>
  110. {{ end }}
  111. </div>
  112. </div>
  113. <script type="text/javascript" src="/js/h.js"></script>
  114. <script type="text/javascript">
  115. function signup() {
  116. var $pass = document.getElementById('password');
  117. // Validate input
  118. if (!aliasOK) {
  119. var $a = $alias;
  120. $a.el.className = 'error';
  121. $a.el.focus();
  122. $a.el.scrollIntoView();
  123. return false;
  124. }
  125. if ($pass.value == "") {
  126. var $a = $pass;
  127. $a.className = 'error';
  128. $a.focus();
  129. $a.scrollIntoView();
  130. return false;
  131. }
  132. var $btn = document.getElementById('btn-create');
  133. $btn.disabled = true;
  134. $btn.value = 'Creating...';
  135. return true;
  136. }
  137. var $alias = H.getEl('alias');
  138. var $aliasSite = document.getElementById('alias-site');
  139. var aliasOK = true;
  140. var typingTimer;
  141. var doneTypingInterval = 750;
  142. var doneTyping = function() {
  143. // Check on username
  144. var alias = $alias.el.value;
  145. if (alias != "") {
  146. var params = {
  147. username: alias
  148. };
  149. var http = new XMLHttpRequest();
  150. http.open("POST", '/api/alias', true);
  151. // Send the proper header information along with the request
  152. http.setRequestHeader("Content-type", "application/json");
  153. http.onreadystatechange = function() {
  154. if (http.readyState == 4) {
  155. data = JSON.parse(http.responseText);
  156. if (http.status == 200) {
  157. aliasOK = true;
  158. $alias.removeClass('error');
  159. $aliasSite.className = $aliasSite.className.replace(/(?:^|\s)demo(?!\S)/g, '');
  160. $aliasSite.className = $aliasSite.className.replace(/(?:^|\s)error(?!\S)/g, '');
  161. $aliasSite.innerHTML = '{{ if .Federation }}@<strong>' + data.data + '</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>' + data.data + '</strong>/{{ end }}';
  162. } else {
  163. aliasOK = false;
  164. $alias.setClass('error');
  165. $aliasSite.className = 'error';
  166. $aliasSite.textContent = data.error_msg;
  167. }
  168. }
  169. }
  170. http.send(JSON.stringify(params));
  171. } else {
  172. $aliasSite.className += ' demo';
  173. $aliasSite.innerHTML = '{{ if .Federation }}@<strong>your-username</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>your-username</strong>/{{ end }}';
  174. }
  175. };
  176. $alias.on('keyup input', function() {
  177. clearTimeout(typingTimer);
  178. typingTimer = setTimeout(doneTyping, doneTypingInterval);
  179. });
  180. </script>
  181. {{end}}