forked from yegor256/netbout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bout.xsl
270 lines (270 loc) · 11.9 KB
/
bout.xsl
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
<?xml version="1.0"?>
<!--
* Copyright (c) 2009-2016, netbout.com
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are PROHIBITED without prior written permission from
* the author. This product may NOT be used anywhere and on any computer
* except the server platform of netbout Inc. located at www.netbout.com.
* Federal copyright law prohibits unauthorized reproduction by any means
* and imposes fines up to $25,000 for violation. If you received
* this code accidentally and without intent to use it, please report this
* incident to the author by email.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @author Yegor Bugayenko ([email protected])
* @version $Id$
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output method="html" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes" />
<xsl:param name="TEXTS"
select="document(concat('/lang/', /page/alias/locale, '.xml?', /page/version/name))/texts"/>
<xsl:include href="/xsl/layout.xsl"/>
<xsl:include href="/xsl/friends.xsl"/>
<xsl:template match="page" mode="head">
<title>
<xsl:text>#</xsl:text>
<xsl:value-of select="bout/number"/>
<xsl:text>: </xsl:text>
<xsl:value-of select="bout/title"/>
</title>
<script src="/js/thridparty/jquery.textcomplete.min.js?{version/name}">
<xsl:text> </xsl:text>
</script>
<script src="/js/friends.js?{version/name}">
<xsl:text> </xsl:text>
<!-- this is for W3C compliance -->
</script>
<script src="/js/bout.js?{version/name}">
<xsl:text> </xsl:text>
<!-- this is for W3C compliance -->
</script>
</xsl:template>
<xsl:template match="page" mode="body">
<xsl:apply-templates select="bout"/>
</xsl:template>
<xsl:template match="bout">
<h1 class="bout">
<a href="{/page/links/link[@rel='self']/@href}">
<span class="num">
<xsl:text>#</xsl:text>
<xsl:value-of select="number"/>
</span>
</a>
<span class="title">
<xsl:if test="/page/links/link[@rel='rename']">
<xsl:attribute name="contenteditable">
<xsl:text>true</xsl:text>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="crop">
<xsl:with-param name="text" select="title"/>
<xsl:with-param name="length" select="50"/>
</xsl:call-template>
</span>
<a href="{/page/links/link[@rel='subscribe']/@href}">
<xsl:choose>
<xsl:when test="subscription='true'">
<i class="fa fa-bell-o"></i>
</xsl:when>
<xsl:otherwise>
<i class="fa fa-bell-slash-o"></i>
</xsl:otherwise>
</xsl:choose>
</a>
</h1>
<div class="top2">
<xsl:apply-templates select="friends"/>
<xsl:if test="not(/page/links/link[@rel='re-login'])">
<xsl:call-template name="invite"/>
<xsl:call-template name="rename"/>
</xsl:if>
</div>
<xsl:apply-templates select="attachments"/>
<xsl:apply-templates select="attachments/attachment[html]" mode="page"/>
<div id="tabs" class="tabs previewable-content">
<div class="tabnav">
<nav class="tabnav-tabs">
<a id="write-link" href="#tab-post" class="active">Write</a>
<a id="preview-link" data-preview="{/page/links/link[@rel='preview']/@href}" href="#preview">Preview</a>
</nav>
</div>
<form id="post-message" method="post" action="{/page/links/link[@rel='post']/@href}">
<div id="tab-post" class="tab-panel active post">
<fieldset>
<label for="text">
<xsl:text> </xsl:text>
</label>
<textarea name="text" cols="80" rows="5" id="text" onkeydown="if ((event.keyCode == 10 || event.keyCode == 13) && event.ctrlKey) submit.click();">
<xsl:text> </xsl:text>
</textarea>
</fieldset>
</div>
<div id="tab-preview" class="tab-panel preview">
<div class="content">
</div>
</div>
<fieldset class="form-submit">
<label for="submit">
<xsl:text> </xsl:text>
</label>
<input type="submit" id="submit" value="{$TEXTS/Post.new.message}"/>
</fieldset>
</form>
</div>
<div id="messages" data-more="{messages/message[position()=last()]/links/link[@rel='more']/@href}">
<xsl:apply-templates select="messages/message"/>
<div id="tail"/>
</div>
</xsl:template>
<xsl:template match="messages/message">
<xsl:variable name="msg" select="."/>
<div class="message" id="msg{$msg/number}">
<div class="left">
<img class="photo" src="{links/link[@rel='photo']/@href}"/>
</div>
<div class="right">
<div class="meta">
<xsl:if test="position() <= /page/bout/unread">
<xsl:attribute name="class">
<xsl:text>red</xsl:text>
</xsl:attribute>
</xsl:if>
<strong>
<xsl:choose>
<xsl:when test="$msg/author = /page/alias/name">
<xsl:value-of select="$TEXTS/you"/>
</xsl:when>
<xsl:when test="/page/bout/friends/friend[$msg/author=alias]">
<xsl:value-of select="/page/bout/friends/friend[$msg/author=alias]/alias"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$TEXTS/someone"/>
</xsl:otherwise>
</xsl:choose>
</strong>
<xsl:text> </xsl:text>
<xsl:value-of select="$TEXTS/said"/>
<xsl:text> </xsl:text>
<a href="{/page/links/link[@rel='self']/@href}#msg{$msg/number}">
<span title="{date}">
<xsl:value-of select="timeago"/>
</span>
</a>
</div>
<div class="text">
<xsl:value-of select="html" disable-output-escaping="yes"/>
</div>
</div>
</div>
</xsl:template>
<xsl:template name="invite">
<div class="invite">
<form method="post" id="invite" action="{/page/links/link[@rel='invite']/@href}">
<fieldset>
<input name="name" autocomplete="off" placeholder="{$TEXTS/Invite}"/>
</fieldset>
</form>
</div>
</xsl:template>
<xsl:template name="rename">
<xsl:if test="/page/links/link[@rel='rename']">
<form id="rename" method="post" style="display: none;" action="{/page/links/link[@rel='rename']/@href}">
<input name="title" size="50" autocomplete="off" value="{/page/bout/title}"/>
</form>
</xsl:if>
</xsl:template>
<xsl:template match="attachments">
<nav class="attachments">
<xsl:variable name="files" select="attachment[not(links/link[@rel='open'])]"/>
<ul>
<xsl:apply-templates select="attachment[links/link[@rel='open']]"/>
<li onclick="$('#files').toggle();" class="toggle">
<xsl:variable name="count" select="count($files)"/>
<xsl:text>+</xsl:text>
<xsl:value-of select="$count"/>
<xsl:text> file</xsl:text>
<xsl:if test="$count != 1">
<xsl:text>s</xsl:text>
</xsl:if>
</li>
<xsl:text> </xsl:text>
</ul>
<div id="files" style="display:none">
<ul>
<xsl:for-each select="$files">
<li>
<a href="{links/link[@rel='download']/@href}">
<xsl:value-of select="name"/>
</a>
<xsl:text> (</xsl:text>
<xsl:value-of select="ctype"/>
<xsl:text>)</xsl:text>
</li>
</xsl:for-each>
</ul>
<form method="post" id="upload" action="{/page/links/link[@rel='attach']/@href}"
enctype="multipart/form-data">
<fieldset>
<input id="file-name" name="name" autocomplete="off" placeholder="attachment name..." size="30" maxlength="50"/>
<input id="file-binary" name="file" type="file"/>
<label for="file-submit"/>
<input id="file-submit" type="submit" value="Upload"/>
</fieldset>
</form>
</div>
</nav>
</xsl:template>
<xsl:template match="attachment">
<li>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="html">
<xsl:text>active</xsl:text>
</xsl:when>
<xsl:when test="unseen = 'true'">
<xsl:text>unseen</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:choose>
<xsl:when test="links/link[@rel='open']">
<a href="{links/link[@rel='open']/@href}">
<xsl:value-of select="name"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name"/>
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:template>
<xsl:template match="attachment" mode="page">
<div class="page">
<div class="controls">
<xsl:if test="links/link[@rel='download']">
<a title="download {name} ({ctype})" href="{links/link[@rel='download']/@href}">
<i class="ico ico-download">
<xsl:comment>download</xsl:comment>
</i>
</a>
</xsl:if>
</div>
<xsl:value-of select="html" disable-output-escaping="yes"/>
</div>
</xsl:template>
</xsl:stylesheet>