]> gitweb.factorcode.org Git - factor.git/commitdiff
Minor Wiki improvements
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 8 Jul 2008 21:15:51 +0000 (16:15 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Tue, 8 Jul 2008 21:15:51 +0000 (16:15 -0500)
extra/webapps/planet/mini-planet.xml [deleted file]
extra/webapps/wiki/initial-content/Farkup.txt [new file with mode: 0644]
extra/webapps/wiki/initial-content/Front Page.txt [new file with mode: 0644]
extra/webapps/wiki/wiki-common.xml
extra/webapps/wiki/wiki.factor
extra/websites/concatenative/concatenative.factor

diff --git a/extra/webapps/planet/mini-planet.xml b/extra/webapps/planet/mini-planet.xml
deleted file mode 100644 (file)
index 661c2dc..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version='1.0' ?>
-
-<t:chloe xmlns:t="http://factorcode.org/chloe/1.0">
-
-       <t:bind-each t:name="postings">
-
-               <p class="news">
-                       <strong><t:label t:name="title" /></strong> <br/>
-                       <t:a value="link" class="more">Read More...</t:a>
-               </p>
-
-       </t:bind-each>
-
-</t:chloe>
diff --git a/extra/webapps/wiki/initial-content/Farkup.txt b/extra/webapps/wiki/initial-content/Farkup.txt
new file mode 100644 (file)
index 0000000..8814af6
--- /dev/null
@@ -0,0 +1,63 @@
+Look at the source to this page by clicking *Edit* to compare the farkup language with resulting output.
+
+= level 1 heading =
+
+== level 2 heading ==
+
+=== level 3 heading ===
+
+==== level 4 heading ====
+
+Here is a paragraph of text, with _emphasized_ and *strong* text, together with an inline %code snippet%. Did you know that E=mc^2^, and L~2~ spaces are cool? Of course, if you want to include \_ special \* characters \^ you \~ can \% do that, too.
+
+You can make [[Wiki Links]] just like that, as well as links to external sites: [[http://sbcl.sourceforge.net]]. [[Factor|Custom link text]] can be used [[http://www.apple.com|with both types of links]].
+
+Images can be embedded in the text:
+
+[[image:http://factorcode.org/graphics/logo.png]]
+
+- a list
+- with three
+- items
+
+|a table|with|four|columns|
+|and|two|rows|...|
+
+Here is some code:
+
+[{HAI
+CAN HAS STDIO?
+VISIBLE "HAI WORLD!"
+KTHXBYE}]
+
+There is syntax highlighting various languages, too:
+
+[factor{PEG: parse-request-line ( string -- triple )
+    #! Triple is { method url version }
+    [ 
+        'space' ,
+        'http-method' ,
+        'space' ,
+        'url' ,
+        'space' ,
+        'http-version' ,
+        'space' ,
+    ] seq* just ;}]
+
+Some Java:
+
+[java{/**
+ * Returns the extension of the specified filename, or an empty
+ * string if there is none.
+ * @param path The path
+ */
+public static String getFileExtension(String path)
+{
+    int fsIndex = getLastSeparatorIndex(path);
+    int index = path.lastIndexOf('.');
+    // there could be a dot in the path and no file extension
+    if(index == -1 || index < fsIndex )
+        return "";
+    else
+        return path.substring(index);
+}}]
diff --git a/extra/webapps/wiki/initial-content/Front Page.txt b/extra/webapps/wiki/initial-content/Front Page.txt
new file mode 100644 (file)
index 0000000..37351ee
--- /dev/null
@@ -0,0 +1,5 @@
+Congratulations, you are now running your very own Wiki.
+
+You can now click *Edit* below and begin editing the content of the [[Front Page]]. This Wiki uses [[Farkup]] to mark up text.
+
+Two special article names are recognized by the Wiki: [[Sidebar]] and [[Footer]]. They do not exist by default, but if you create them, they will be visible on every page.
index 0abd36a7cd936d2965a5efdd90f9095170f2af32..5cddcee628294a9fe8bcd69a84e3f15111097041 100644 (file)
@@ -13,6 +13,7 @@
                <t:a t:href="$wiki">Front Page</t:a>
                | <t:a t:href="$wiki/articles">All Articles</t:a>
                | <t:a t:href="$wiki/changes">Recent Changes</t:a>
+               | <t:a t:href="$wiki/random">Random Article</t:a>
 
                <t:if t:code="furnace.auth:logged-in?">
 
                                </td>
                        </t:if>
                </tr>
+
+               <tr>
+                       <td>
+                               <t:bind t:name="footer">
+                                       <small>
+                                               <t:farkup t:name="content" />
+                                       </small>
+                               </t:bind>
+                       </td>
+               </tr>
        </table>
 
 </t:chloe>
index 77ee24266884eda5a3ea5b8d552b9ea84f659d18..3c87f3cd4926105c486cceee6183907e01420fc4 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel hashtables calendar
+USING: accessors kernel hashtables calendar random assocs
 namespaces splitting sequences sorting math.order present
+io.files io.encodings.ascii
 syndication
 html.components html.forms
 http.server
@@ -115,6 +116,14 @@ M: revision feed-entry-url id>> revision-url ;
 
         { wiki "view" } >>template ;
 
+: <random-article-action> ( -- action )
+    <action>
+        [
+            article new select-tuples random
+            [ title>> ] [ "Front Page" ] if*
+            view-url <redirect>
+        ] >>display ;
+
 : amend-article ( revision article -- )
     swap id>> >>revision update-tuple ;
 
@@ -286,15 +295,15 @@ M: revision feed-entry-url id>> revision-url ;
         { wiki "page-common" } >>template ;
 
 : init-sidebar ( -- )
-    "Sidebar" latest-revision [
-        "sidebar" [ from-object ] nest-form
-    ] when* ;
+    "Sidebar" latest-revision [ "sidebar" [ from-object ] nest-form ] when*
+    "Footer" latest-revision [ "footer" [ from-object ] nest-form ] when* ;
 
 : <wiki> ( -- dispatcher )
     wiki new-dispatcher
         <main-article-action> <article-boilerplate> "" add-responder
         <view-article-action> <article-boilerplate> "view" add-responder
         <view-revision-action> <article-boilerplate> "revision" add-responder
+        <random-article-action> "random" add-responder
         <list-revisions-action> <article-boilerplate> "revisions" add-responder
         <list-revisions-feed-action> "revisions.atom" add-responder
         <diff-action> <article-boilerplate> "diff" add-responder
@@ -309,3 +318,15 @@ M: revision feed-entry-url id>> revision-url ;
     <boilerplate>
         [ init-sidebar ] >>init
         { wiki "wiki-common" } >>template ;
+
+: init-wiki ( -- )
+    "resource:extra/webapps/wiki/initial-content" directory* keys
+    [
+        [ ascii file-contents ] [ file-name "." split1 drop ] bi
+        f <revision>
+            swap >>title
+            swap >>content
+            "slava" >>author
+            now >>date
+        add-revision
+    ] each ;
index 211dcb3c11b3e81a8bf4a3d2a081725b607090b2..1ae7f63a27f9e4b71b132ae50b2964589ea7ac0f 100644 (file)
@@ -25,7 +25,7 @@ webapps.wee-url
 webapps.user-admin ;
 IN: websites.concatenative
 
-: test-db ( -- db params ) "resource:test.db" sqlite-db ;
+: test-db ( -- params db ) "resource:test.db" sqlite-db ;
 
 : init-factor-db ( -- )
     test-db [