Adding syntax highlighting support to the pastebin

release
Slava Pestov 2007-12-06 00:22:35 -05:00
parent 54b52e7b01
commit 0e60982aca
6 changed files with 17 additions and 16 deletions

2
extra/webapps/pastebin/annotate-paste.furnace Normal file → Executable file
View File

@ -24,7 +24,7 @@
</tr>
<tr>
<th valign="top">Contents:</th>
<th valign="top">Content:</th>
<td><textarea rows="24" cols="60" name="contents"></textarea></td>
</tr>
</table>

2
extra/webapps/pastebin/annotation.furnace Normal file → Executable file
View File

@ -8,4 +8,4 @@
<tr><th>Created:</th><td><% "date" get write %></td></tr>
</table>
<pre><% "contents" get write %></pre>
<% "syntax" render-template %

2
extra/webapps/pastebin/new-paste.furnace Normal file → Executable file
View File

@ -25,7 +25,7 @@
</tr>
<tr>
<th valign="top">Contents:</th>
<th valign="top">Content:</th>
<td><textarea rows="24" cols="60" name="contents"></textarea></td>
</tr>
</table>

14
extra/webapps/pastebin/pastebin.factor Normal file → Executable file
View File

@ -1,5 +1,5 @@
USING: calendar furnace furnace.validator io.files kernel
namespaces sequences store ;
namespaces sequences store http.server.responders html ;
IN: webapps.pastebin
TUPLE: pastebin pastes ;
@ -28,21 +28,25 @@ SYMBOL: store
pastebin get pastebin-pastes nth ;
: show-paste ( n -- )
get-paste "show-paste" render-component ;
serving-html
get-paste
[ "show-paste" render-component ] with-html-stream ;
\ show-paste { { "n" v-number } } define-action
: new-paste ( -- )
"new-paste" render-template ;
serving-html
[ "new-paste" render-template ] with-html-stream ;
\ new-paste { } define-action
: paste-list ( -- )
serving-html
[
[ show-paste ] "show-paste-quot" set
[ new-paste ] "new-paste-quot" set
pastebin get "paste-list" render-component
] with-scope ;
] with-html-stream ;
\ paste-list { } define-action
@ -68,7 +72,7 @@ SYMBOL: store
\ submit-paste [ paste-list ] define-redirect
: annotate-paste ( n summary author contents -- )
: annotate-paste ( n summary author mode contents -- )
<annotation> swap get-paste
paste-annotations push
save-pastebin-store ;

5
extra/webapps/pastebin/show-paste.furnace Normal file → Executable file
View File

@ -1,4 +1,4 @@
<% USING: namespaces io furnace sequences ; %>
<% USING: namespaces io furnace sequences xmode.code2html ; %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@ -9,6 +9,7 @@
<title>Paste: <% "summary" get write %></title>
<link rel="stylesheet" href="/responder/file/css/pastebin.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<% default-stylesheet %>
</head>
<h1 class="pastebin-title">[ <% "summary" get write %> ]</h1>
@ -20,7 +21,7 @@
<tr><th>File type:</th><td><% "mode" get write %></td></tr>
</table>
<pre><% "contents" get write %></pre>
<% "syntax" render-template %>
<% "annotations" get [ "annotation" render-component ] each %>

8
extra/webapps/pastebin/syntax.furnace Normal file → Executable file
View File

@ -1,7 +1,3 @@
<% USING: xmode.catalog sequences kernel html.elements assocs io ; %>
<% USING: xmode.code2html splitting namespaces ; %>
<select name="mode">
<% modes keys [
<option dup "factor" = [ "true" =selected ] when option> write </option>
] each %>
</select>
<pre><% "contents" get string-lines "mode" get htmlize-lines %></pre>