Overhaul pastebin

release
Slava Pestov 2007-12-06 01:02:58 -05:00
parent a969934061
commit e82ff27e98
12 changed files with 156 additions and 69 deletions

View File

@ -9,22 +9,22 @@
<input type="hidden" name="n" value="<% "n" get number>string write %>" /> <input type="hidden" name="n" value="<% "n" get number>string write %>" />
<tr> <tr>
<th>Your name:</th> <th align="right">Summary:</th>
<td><input type="TEXT" name="author" value="" /></td>
</tr>
<tr>
<th>Summary:</th>
<td><input type="TEXT" name="summary" value="" /></td> <td><input type="TEXT" name="summary" value="" /></td>
</tr> </tr>
<tr> <tr>
<th>File type:</th> <th align="right">Your name:</th>
<td><input type="TEXT" name="author" value="" /></td>
</tr>
<tr>
<th align="right">File type:</th>
<td><% "modes" render-template %></td> <td><% "modes" render-template %></td>
</tr> </tr>
<tr> <tr>
<th valign="top">Content:</th> <th align="right" valign="top">Content:</th>
<td><textarea rows="24" cols="60" name="contents"></textarea></td> <td><textarea rows="24" cols="60" name="contents"></textarea></td>
</tr> </tr>
</table> </table>

View File

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

View File

@ -0,0 +1,3 @@
</body>
</html>

View File

@ -0,0 +1,23 @@
<% USING: namespaces io furnace sequences xmode.code2html webapps.pastebin ; %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><% "title" get write %></title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<% default-stylesheet %>
<link rel="alternate" type="application/atom+xml" title="Pastebin - Atom" href="feed.xml" />
</head>
<body id="index">
<div class="navbar">
<% [ paste-list ] "Paste list" render-link %> |
<% [ new-paste ] "New paste" render-link %> |
<% [ feed.xml ] "Syndicate" render-link %>
</div>
<h1 class="pastebin-title"><% "title" get write %></h1>

View File

@ -1,7 +1,7 @@
<% USING: xmode.catalog sequences kernel html.elements assocs io ; %> <% USING: xmode.catalog sequences kernel html.elements assocs io sorting ; %>
<select name="mode"> <select name="mode">
<% modes keys [ <% modes keys natural-sort [
<option dup "factor" = [ "true" =selected ] when option> write </option> <option dup "factor" = [ "true" =selected ] when option> write </option>
] each %> ] each %>
</select> </select>

View File

@ -1,34 +1,41 @@
<% USING: furnace ; %> <% USING: furnace namespaces ; %>
<%
"new paste" "title" set
"header" render-template
%>
<form method="POST" action="/responder/pastebin/submit-paste"> <form method="POST" action="/responder/pastebin/submit-paste">
<table> <table>
<tr> <tr>
<th>Your name:</th> <th align="right">Summary:</th>
<td><input type="TEXT" name="author" value="" /></td>
</tr>
<tr>
<th>Summary:</th>
<td><input type="TEXT" name="summary" value="" /></td> <td><input type="TEXT" name="summary" value="" /></td>
</tr> </tr>
<tr> <tr>
<th>File type:</th> <th align="right">Your name:</th>
<td><input type="TEXT" name="author" value="" /></td>
</tr>
<tr>
<th align="right">File type:</th>
<td><% "modes" render-template %></td> <td><% "modes" render-template %></td>
</tr> </tr>
<tr> <tr>
<th>Channel:</th> <th align="right">Channel:</th>
<td><input type="TEXT" name="channel" value="#concatenative" /></td> <td><input type="TEXT" name="channel" value="#concatenative" /></td>
</tr> </tr>
<tr> <tr>
<th valign="top">Content:</th> <th align="right" valign="top">Content:</th>
<td><textarea rows="24" cols="60" name="contents"></textarea></td> <td><textarea rows="24" cols="60" name="contents"></textarea></td>
</tr> </tr>
</table> </table>
<input type="SUBMIT" value="Submit paste" /> <input type="SUBMIT" value="Submit paste" />
</form> </form>
<% "footer" render-template %>

View File

@ -1,29 +1,29 @@
<% USING: namespaces furnace sequences ; %> <% USING: namespaces furnace sequences ; %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <%
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "Pastebin" "title" set
"header" render-template
%>
<html xmlns="http://www.w3.org/1999/xhtml"> <table width="100%" cellspacing="10">
<head> <tr>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <td valign="top">
<table width="100%">
<tr align="left" class="pastebin-headings">
<th width="50%">Summary:</th>
<th width="100">Paste by:</th>
<th width="200">Date:</th>
</tr>
<% "pastes" get <reversed> [ "paste-summary" render-component ] each %>
</table>
</td>
<td valign="top" width="25%" class="infobox">
<p>This pastebin is written in <a href="http://factorcode.org/">Factor</a>. It can be used for collaborative development over IRC. You can post code for review, and annotate other people's code. Syntax highlighting for over a hundred file types is supported.
</p>
<p>
<% "webapps.pastebin" browse-webapp-source %></p>
</td>
</tr>
</table>
<title>Pastebin</title> <% "footer" render-template %>
<link rel="stylesheet" href="/responder/file/css/pastebin.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<link rel="alternate" type="application/atom+xml" title="Pastebin - Atom" href="feed.xml" />
</head>
<body id="index">
<h1 class="pastebin-title">[ "paste" bin ]</h1>
<table width="100%">
<% "new-paste-quot" get "New paste" render-link %>
<tr align="left" class="pastebin-headings">
<th>&nbsp;</th>
<th>Summary:</th>
<th>Paste by:</th>
<th>Date:</th>
</tr>
<% "pastes" get <reversed> [ "paste-summary" render-component ] each %>
</table>
</body>
</html>

View File

@ -1,13 +1,11 @@
<% USING: continuations namespaces io kernel math math.parser furnace ; %> <% USING: continuations namespaces io kernel math math.parser furnace webapps.pastebin ; %>
<tr> <tr>
<td><% "n" get number>string write %></td> <td>
<td><% <a href="<% model get paste-link write %>">
"n" get number>string <% "summary" get write %>
"show-paste-quot" get curry </a>
"summary" get </td>
render-link
%></td>
<td><% "author" get write %></td> <td><% "author" get write %></td>
<td><% "date" get print %></td> <td><% "date" get print %></td>
</tr> </tr>

View File

@ -1,5 +1,6 @@
USING: calendar furnace furnace.validator io.files kernel USING: calendar furnace furnace.validator io.files kernel
namespaces sequences store http.server.responders html ; namespaces sequences store http.server.responders html
math.parser rss xml.writer ;
IN: webapps.pastebin IN: webapps.pastebin
TUPLE: pastebin pastes ; TUPLE: pastebin pastes ;
@ -50,6 +51,26 @@ SYMBOL: store
\ paste-list { } define-action \ paste-list { } define-action
: paste-link ( paste -- link )
paste-n number>string [ show-paste ] curry quot-link ;
: paste-feed ( -- entries )
pastebin get pastebin-pastes [
{
paste-summary
paste-link
paste-date
} get-slots "" swap <entry>
] map ;
: feed.xml ( -- )
"text/xml" serving-content
"pastebin"
"http://pastebin.factorcode.org"
paste-feed <feed> feed>xml write-xml ;
\ feed.xml { } define-action
: save-pastebin-store ( -- ) : save-pastebin-store ( -- )
store get-global save-store ; store get-global save-store ;
@ -87,4 +108,10 @@ SYMBOL: store
\ annotate-paste [ "n" show-paste ] define-redirect \ annotate-paste [ "n" show-paste ] define-redirect
: style.css ( -- )
"text/css" serving-content
"style.css" send-resource ;
\ style.css { } define-action
"pastebin" "paste-list" "extra/webapps/pastebin" web-app "pastebin" "paste-list" "extra/webapps/pastebin" web-app

View File

@ -1,18 +1,9 @@
<% USING: namespaces io furnace sequences xmode.code2html ; %> <% 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"> "Paste: " "summary" get append "title" set
"header" render-template
<html xmlns="http://www.w3.org/1999/xhtml"> %>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<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>
<table> <table>
<tr><th>Paste by:</th><td><% "author" get write %></td></tr> <tr><th>Paste by:</th><td><% "author" get write %></td></tr>
@ -26,3 +17,5 @@
<% "annotations" get [ "annotation" render-component ] each %> <% "annotations" get [ "annotation" render-component ] each %>
<% model get "annotate-paste" render-component %> <% model get "annotate-paste" render-component %>
<% "footer" render-template %>

View File

@ -0,0 +1,36 @@
body {
font:75%/1.6em "Lucida Grande", "Lucida Sans Unicode", verdana, geneva, sans-serif;
color:#888;
}
h1.pastebin-title {
font-size:300%;
}
a {
color:#222;
border-bottom:1px dotted #ccc;
text-decoration:none;
}
a:hover {
border-bottom:1px solid #ccc;
}
pre.code {
border:1px dashed #ccc;
background-color:#f5f5f5;
padding:5px;
font-size:150%;
}
.navbar {
background-color:#eeeeee;
padding:5px;
border:1px solid #ccc;
}
.infobox {
border: 1px solid #C1DAD7;
padding: 10px;
}

View File

@ -1,3 +1,3 @@
<% USING: xmode.code2html splitting namespaces ; %> <% USING: xmode.code2html splitting namespaces ; %>
<pre><% "contents" get string-lines "mode" get htmlize-lines %></pre> <pre class="code"><% "contents" get string-lines "mode" get htmlize-lines %></pre>