forked from reddit-archive/reddit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
createsubreddit.html
415 lines (377 loc) · 15 KB
/
createsubreddit.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
## The contents of this file are subject to the Common Public Attribution
## License Version 1.0. (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License at
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
## License Version 1.1, but Sections 14 and 15 have been added to cover use of
## software over a computer network and provide for limited attribution for the
## Original Developer. In addition, Exhibit A has been modified to be consistent
## with Exhibit B.
##
## Software distributed under the License is distributed on an "AS IS" basis,
## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
## the specific language governing rights and limitations under the License.
##
## The Original Code is Reddit.
##
## The Original Developer is the Initial Developer. The Initial Developer of
## the Original Code is CondeNet, Inc.
##
## All portions of the code written by CondeNet are Copyright (c) 2006-2010
## CondeNet, Inc. All Rights Reserved.
################################################################################
<%!
from r2.lib.filters import keep_space
from r2.lib.pages import UserText
%>
<%namespace file="utils.html" import="error_field, language_tool, plain_link"/>
<%namespace file="utils.html" import="image_upload"/>
<%namespace file="printablebuttons.html" import="toggle_button, simple_button" />
<%namespace name="utils" file="utils.html"/>
<div class="create-reddit fancy-settings thing"
%if thing.site:
id="${thing.site._fullname}"
%endif
>
%if thing.site:
<h1>${_("community settings")}
%if thing.site:
|  <strong>${thing.site.name}</strong>
%endif
</h1>
%else:
%if thing.name:
<p class="infobar">
${_("that subreddit doesn't exist, but you can create it here.")}</p>
%endif
<h1>${_("create a community")}</h1>
%endif
<div class="pretty-form" id="sr-form">
%if not thing.site:
<%utils:line_field title="${_('name')}"
description='${_("no spaces, e.g., slashdot")}'>
<input type="text" name="name" id="name" class="text"
value="${thing.name}"
onchange="update_title(this)"/>
%if not thing.site:
${error_field("SUBREDDIT_EXISTS", "name")}
${error_field("BAD_SR_NAME", "name")}
%endif
</%utils:line_field>
%else:
<input type="hidden" name="sr" id="name" value="${thing.site._fullname}"/>
%endif
<%utils:line_field title="${_('title')}"
description='${_("e.g., slashdot: news for nerds, stuff that matters")}'>
%if thing.site:
<input id="title" type="text" name="title" class="text"
value="${thing.site.title}"/>
%else:
<input id="title" type="text" name="title" class="text" />
%endif
${error_field("NO_TEXT", "title")}
${error_field("TOO_LONG", "title")}
</%utils:line_field>
<%utils:line_field title="${_('description')}" css_class="usertext"
description="${_('500 characters max. Make them count.')}">
%if thing.site and thing.site.description:
${UserText(None, text = thing.site.description or "", editable = True, creating = True, name="description", have_form = False)}
%else:
${UserText(None, text = "", creating = True, name="description", have_form = False)}
%endif
</%utils:line_field>
<%utils:line_field title="${_('language')}">
<div class="delete-field">
<%
default_lang = thing.site and thing.site.lang or c.lang or ''
default_lang = default_lang.split('-')[0]
default_lang = g.lang if len(default_lang) != 2 else default_lang
%>
${language_tool(all_langs = True, default_lang = default_lang)}
</div>
</%utils:line_field>
<%utils:line_field title="${_('type')}">
<div class="delete-field">
<table>
${utils.radio_type('type', "public", _("public"),
_("anyone can view and submit"),
(not thing.site or thing.site.type=='public'))}
${utils.radio_type('type', "restricted", _("restricted"),
_("anyone can view, but only some are approved to submit links"),
(thing.site and thing.site.type=='restricted'))}
${utils.radio_type('type', "private", _("private"),
_("only approved members can view and submit"),
(thing.site and thing.site.type=='private'))}
</table>
</div>
</%utils:line_field>
<%utils:line_field title="${_('content options')}">
<div class="delete-field">
<table>
${utils.radio_type('link_type', "any", _("any"),
_("any link type is allowed"),
(not thing.site or thing.site.link_type=='any'))}
${utils.radio_type('link_type', "link", _("links only"),
_("only links to external sites are allowed"),
(thing.site and thing.site.link_type=='link'))}
${utils.radio_type('link_type', "self", _("text posts only"),
_("only text/self posts are allowed"),
(thing.site and thing.site.link_type=='self'))}
</table>
</div>
</%utils:line_field>
<%utils:line_field title="${_('other options')}">
<div class="delete-field">
<ul>
<li>
<input class="nomargin" type="checkbox" name="over_18" id="over_18"
${thing.site and thing.site.over_18 and "checked='checked'" or ""}/>
<label for="over_18">
${_("viewers must be over eighteen years old")}
</label>
</li>
<li>
<input class="nomargin" type="checkbox"
name="allow_top" id="allow_top"
${(not thing.site or thing.site.allow_top) and "checked='checked'" or ""}/>
<label for="allow_top">
${_("allow this reddit to be shown in the default set")}
</label>
</li>
<li>
<input class="nomargin" type="checkbox"
name="show_media" id="show_media"
${thing.site and thing.site.show_media and "checked='checked'" or ""}/>
<label for="show_media">
${_("show thumbnail images of content")}
</label>
</li>
</ul>
</div>
</%utils:line_field>
<%utils:line_field title="${_('domain')}" css_class="usertext">
<div class="delete-field">
%if thing.site and c.site.domain:
<input class="nomargin" type="checkbox"
name="css_on_cname" id="css_on_cname"
${thing.site.css_on_cname and "checked='checked'" or ""}/>
<label for="css_on_cname">
${_("make custom CSS styles apply only when accessed from the cname.")}
</label>
<br/>
<input class="nomargin" type="checkbox"
name="show_cname_sidebar" id="show_cname_sidebar"
${thing.site and thing.site.show_cname_sidebar and "checked='checked'" or ""}/>
<label for="show_cname_sidebar">
${_("show sidebar when accessed from the cname.")}
</label>
%endif
</div>
<div class="usertext-edit">
%if thing.site:
<input id="domain" type="text" name="domain" class="text"
value="${getattr(thing.site, 'domain', None) or ""}"/>
%else:
<input id="domain" type="text" name="domain" class="text" />
%endif
<div class="bottom-area">
${toggle_button("help-toggle", _("what's this?"), _("hide help"),
"helpon", "helpoff")}
</div>
<div class="infobar markhelp md" style="display: none">
${_("Own a domain? Enter it here and then go to your DNS provider and add a CNAME record aliasing your domain to rhs.reddit.com. You will be able to access your reddit through your domain.")}
</div>
</div>
</%utils:line_field>
%if thing.site:
<input type="hidden" name="sr" value="${thing.site._fullname}"/>
<%utils:line_field title="${_('look and feel')}">
<ul class="upload">
<li>
${plain_link(_("edit the stylesheet"),
"/about/stylesheet",
_sr_path = True)}
 
<span class="gray">(${_("leaves this page")})</span>
</li>
<li>
<label for="header-title">header mouseover text:</label>
<input type="text" name="header-title" id="header-title"
value="${thing.site.header_title}"
/>
</li>
<li>
<%utils:image_upload post_target="/api/upload_sr_img"
current_image="${thing.site.header}"
label="${_('upload header image')}"
ask_type="${True}">
<br/>
<button id="delete-img" class="delete-img"
%if not thing.site.header:
style="display: none;"
%endif
onclick="return post_form(this.form, 'delete_sr_header');">
${_('restore default header')}
</button>
<div class="clearleft"></div>
<input type="hidden" name="uh" value="${c.modhash}" />
<input type="hidden" name="r" value="${c.site.name}" />
<input type="hidden" name="header" value="1" />
<script type="text/javascript">
function on_image_success(img) {
$("#header-img").log().attr("src", img.attr("src"));
}
</script>
</%utils:image_upload>
</li>
</ul>
</%utils:line_field>
<%utils:line_field title="${_('custom menus')}">
<ul class="upload" id="menu-links">
<script language="javascript">
function add() {
i++;
var li = document.createElement("li");
li.setAttribute("id", "link-url-"+i);
var list = document.getElementById("menu-links");
li.innerHTML = "<input type=\"text\" id=\"link-url-"+i+"\" value=\"${thing.site.link_urls_0}\" />";
list.appendChild(li);
if(i >= 1){
document.getElementById("remove-button").style.visibility = "visible";
}
}
function remove() {
var d = document.getElementById("menu-links");
var olddiv = document.getElementById("link-url-" + i);
d.removeChild(olddiv);
i--;
if(i < 1){
document.getElementById("remove-button").style.visibility = "hidden";
}
}
$(window).load(function(){
document.getElementById("remove-button").style.visibility = "hidden";
i=0;
});
</script>
<li class="left">
<input type="text" name="link-url-0" id="link-url-0"
value="${thing.site.link_urls_0}"
/>
</li>
<li class="right">
<input type="text" name="link-url-title-0" id="link-url-title-0"
value="${thing.site.link_urls_title_0}"
/>
</li>
<li class="left">
<input type="text" name="link-url-1" id="link-url-1"
value="${thing.site.link_urls_1}"
/>
</li>
<li class="right">
<input type="text" name="link-url-title-1" id="link-url-title-1"
value="${thing.site.link_urls_title_1}"
/>
</li>
<li class="left">
<input type="text" name="link-url-2" id="link-url-2"
value="${thing.site.link_urls_2}"
/>
</li>
<li class="right">
<input type="text" name="link-url-title-2" id="link-url-title-2"
value="${thing.site.link_urls_title_2}"
/>
</li>
<li class="left">
<input type="text" name="link-url-3" id="link-url-3"
value="${thing.site.link_urls_3}"
/>
</li>
<li class="right">
<input type="text" name="link-url-title-3" id="link-url-title-3"
value="${thing.site.link_urls_title_3}"
/>
</li>
<li class="left">
<input type="text" name="link-url-4" id="link-url-4"
value="${thing.site.link_urls_4}"
/>
</li>
<li class="right">
<input type="text" name="link-url-title-4" id="link-url-title-4"
value="${thing.site.link_urls_title_4}"
/>
</li>
</ul>
<div class="clear"></div>
</%utils:line_field>
%if c.user_is_admin:
<%utils:line_field title="${_('sponsorship')}">
<ul class="upload">
<li>
<input type="text" name="sponsorship-text"
value="${thing.site.sponsorship_text}"
/>
</li>
<li>
<input type="text" name="sponsorship-name"
%if thing.site.sponsorship_name:
value="${thing.site.sponsorship_name}"
%else:
placeholder="${_('name this campaign (for traffic)')}"
%endif
/>
</li>
<li>
<input type="text" name="sponsorship-url"
%if thing.site.sponsorship_url:
value="${thing.site.sponsorship_url}"
%else:
placeholder="${_('enter link url here')}"
%endif
/>
</li>
<li>
<%utils:image_upload post_target="/api/upload_sr_img"
current_image="${thing.site.sponsorship_img}"
label="${_('upload sponsorship image')}"
form_id="sponsor-upload",
ask_type="${True}">
<br/>
<button id="delete-sponsor" class="delete-img"
%if not thing.site.sponsorship_img:
style="display: none;"
%endif
onclick="return post_form(this.form, 'delete_sr_header');">
${_('delete')}
</button>
<div class="clearleft"></div>
<input type="hidden" name="uh" value="${c.modhash}" />
<input type="hidden" name="r" value="${c.site.name}" />
<input type="hidden" name="sponsor" value="1" />
</%utils:image_upload>
</li>
</ul>
</%utils:line_field>
%endif
%endif
<div class="save-button">
<%
if thing.site:
name = "edit"
text = _("save options")
else:
name = "create"
text = _("create")
%>
<button name="${name}" class="btn" type="button"
onclick="return post_pseudo_form('#sr-form', 'site_admin')">
${text}
</button>
 
<span class="status error"></span>
${error_field("RATELIMIT", "ratelimit")}
</div>
</div>
</div>