Wiki: cache Farkup HTML output

db4
Slava Pestov 2008-09-08 01:11:27 -05:00
parent 7a9806495f
commit 977febf1fa
3 changed files with 12 additions and 6 deletions

View File

@ -5,7 +5,7 @@
<t:title><t:label t:name="title" /></t:title> <t:title><t:label t:name="title" /></t:title>
<div class="description"> <div class="description">
<t:farkup t:name="content" /> <t:html t:name="html" />
</div> </div>
<p> <p>

View File

@ -41,7 +41,7 @@
</t:a> </t:a>
</h2> </h2>
<t:farkup t:name="content" /> <t:html t:name="html" />
</t:bind> </t:bind>
</td> </td>
</t:if> </t:if>
@ -52,7 +52,7 @@
<td> <td>
<t:bind t:name="footer"> <t:bind t:name="footer">
<small> <small>
<t:farkup t:name="content" /> <t:html t:name="html" />
</small> </small>
</t:bind> </t:bind>
</td> </td>

View File

@ -3,7 +3,7 @@
USING: accessors kernel hashtables calendar random assocs USING: accessors kernel hashtables calendar random assocs
namespaces splitting sequences sorting math.order present namespaces splitting sequences sorting math.order present
io.files io.encodings.ascii io.files io.encodings.ascii
syndication syndication farkup
html.components html.forms html.components html.forms
http.server http.server
http.server.dispatchers http.server.dispatchers
@ -47,7 +47,7 @@ article "ARTICLES" {
: <article> ( title -- article ) article new swap >>title ; : <article> ( title -- article ) article new swap >>title ;
TUPLE: revision id title author date content description ; TUPLE: revision id title author date content html description ;
revision "REVISIONS" { revision "REVISIONS" {
{ "id" "ID" INTEGER +db-assigned-id+ } { "id" "ID" INTEGER +db-assigned-id+ }
@ -55,6 +55,7 @@ revision "REVISIONS" {
{ "author" "AUTHOR" { VARCHAR 256 } +not-null+ } ! uid { "author" "AUTHOR" { VARCHAR 256 } +not-null+ } ! uid
{ "date" "DATE" TIMESTAMP +not-null+ } { "date" "DATE" TIMESTAMP +not-null+ }
{ "content" "CONTENT" TEXT +not-null+ } { "content" "CONTENT" TEXT +not-null+ }
{ "html" "HTML" TEXT +not-null+ } ! Farkup converted to HTML
{ "description" "DESCRIPTION" TEXT } { "description" "DESCRIPTION" TEXT }
} define-persistent } define-persistent
@ -71,6 +72,9 @@ M: revision feed-entry-url id>> revision-url ;
: <revision> ( id -- revision ) : <revision> ( id -- revision )
revision new swap >>id ; revision new swap >>id ;
: compute-html ( revision -- )
dup content>> convert-farkup >>html drop ;
: validate-title ( -- ) : validate-title ( -- )
{ { "title" [ v-one-line ] } } validate-params ; { { "title" [ v-one-line ] } } validate-params ;
@ -144,11 +148,13 @@ M: revision feed-entry-url id>> revision-url ;
[ title>> ] [ id>> ] bi article boa insert-tuple ; [ title>> ] [ id>> ] bi article boa insert-tuple ;
: add-revision ( revision -- ) : add-revision ( revision -- )
[ compute-html ]
[ insert-tuple ] [ insert-tuple ]
[ [
dup title>> <article> select-tuple dup title>> <article> select-tuple
[ amend-article ] [ add-article ] if* [ amend-article ] [ add-article ] if*
] bi ; ]
tri ;
: <edit-article-action> ( -- action ) : <edit-article-action> ( -- action )
<page-action> <page-action>