This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
usertext.html
168 lines (157 loc) · 5.96 KB
/
usertext.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
## 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 reddit Inc.
##
## All portions of the code written by reddit are Copyright (c) 2006-2013
## reddit Inc. All Rights Reserved.
###############################################################################
<%!
from r2.lib.filters import unsafe, safemarkdown, keep_space
from r2.lib.strings import strings
from r2.lib.utils import randstr
%>
<%namespace file="printablebuttons.html" import="toggle_button" />
<%namespace file="utils.html" import="error_field, md"/>
<%def name="action_button(name, btn_type, onclick, display)">
<button type="${btn_type}" onclick="${onclick}" class="${name}"
${"style='display:none'" if not display else ""}>
${name}
</button>
</%def>
%if thing.have_form:
<form action="#" class="${thing.css_class}"
onsubmit="return post_form(this, '${thing.post_form}')"
${"style='display:none'" if not thing.display else ""}
id="form-${thing.fullname + randstr(3)}">
%else:
<div class="${thing.css_class}">
%endif
##this is set for both editting selftext and creating new comments
<input type="hidden" name="thing_id" value="${thing.fullname or ''}"/>
%if not thing.creating:
<div class="usertext-body">
% if not thing.expunged:
${unsafe(safemarkdown(thing.text, nofollow = thing.nofollow,
target = '_blank' if c.user.pref_newwindow else thing.target))}
% else:
<em>${_("[removed]")}</em> 
% endif
</div>
%endif
%if thing.editable or thing.creating:
##keep this on one line so we don't add extra spaces
<div class="usertext-edit"
style="${"" if thing.creating else 'display: none'}">
##this div prevents IE7 from adding extra margin to the textarea.
<div>
<textarea rows="1" cols="1"
name="${thing.name}"
>${keep_space(thing.text)}</textarea>
</div>
<div class="bottom-area">
${toggle_button("help-toggle", _("formatting help"), _("hide help"),
"helpon", "helpoff",
style = "" if thing.creating else "display: none")}
${error_field("TOO_LONG", thing.name, "span")}
${error_field("RATELIMIT", "ratelimit", "span")}
${error_field("NO_TEXT", thing.name, "span")}
${error_field("TOO_OLD", "parent", "span")}
${error_field("DELETED_COMMENT", "parent", "span")}
${error_field("DELETED_LINK", "parent", "span")}
${error_field("USER_BLOCKED", "parent", "span")}
<div class="usertext-buttons">
${action_button("save", "submit", "",
thing.creating and thing.have_form)}
${action_button("cancel", "button", "cancel_usertext(this)", False)}
%if thing.have_form:
<span class="status"></span>
%endif
</div>
</div>
<div class="markhelp" style="display:none">
<p>${md(strings.formatting_help_info)}</p>
<table class="md">
<tr style="background-color: #ffff99; text-align: center">
<td><em>${_( "you type:")}</em></td>
<td><em>${_( "you see:")}</em></td>
</tr>
<tr>
<td>*${_( "italics")}*</td>
<td><em>${_( "italics")}</em></td>
</tr>
<tr>
<td>**${_( "bold")}**</td>
<td><b>${_( "bold")}</b></td>
</tr>
<tr>
<td>[reddit!](http://reddit.com)</td>
<td><a href="http://reddit.com">reddit!</a></td>
</tr>
<tr>
<td>
* ${_( "item")} 1<br/>
* ${_( "item")} 2<br/>
* ${_( "item")} 3
</td>
<td>
<ul>
<li>${_( "item")} 1</li>
<li>${_( "item")} 2</li>
<li>${_( "item")} 3</li>
</ul>
</td>
</tr>
<tr>
<td>> ${_( "quoted text")}</td>
<td><blockquote>${_( "quoted text" )}</blockquote></td>
</tr>
<tr>
<td>
Lines starting with four spaces <br/>
are treated like code:<br/><br/>
<span class="spaces">
</span>
if 1 * 2 < 3:<br/>
<span class="spaces">
</span>
print "hello, world!"<br/>
</td>
<td>Lines starting with four spaces <br/>
are treated like code:<br/>
<pre>if 1 * 2 < 3:<br/> print "hello,
world!"</pre>
</td>
</tr>
<tr>
<td>~~strikethrough~~</td>
<td><strike>strikethrough</strike></td>
</tr>
<tr>
<td>super^script</td>
<td>super<sup>script</sup></td>
</tr>
</table>
</div>
</div>
%endif
%if thing.have_form:
</form>
%else:
</div>
%endif