public
Description: A pure-Nu wiki based on Nunja, Git, and NuMarkdown
Homepage: http://importantshock.wordpress.com
Clone URL: git://github.com/patrickt/nuki.git
Many changes, the most significant of which is the support for editing a 
page starting at a given revision. Check the History pages to see it in 
action.

Improved the CSS a little bit. Removed the HTML escapes, as they weren't 
working right. (Thanks to Grayson Hansard for pointing that out.)

Changed the edit pages to use (page contents) rather than (page 
filesystemContents).
patrickt (author)
Tue Apr 01 19:48:40 -0700 2008
commit  f6d5bed22bae4a5c53d5c42cbf2c1739694c0c0d
tree    9c4fde20ec8e2a58ec8295fb441795c4b4f5b087
parent  566e02472a5e2358221ba9ac36bb830aeef7c1f5
...
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
...
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
0
@@ -1,37 +1,37 @@
0
 (class NSFileManager
0
-
0
- (- (id) directoryContentsAtPath:(id)path withPattern:(id)pattern is
0
+
0
+ ;; Filters directory contents based on a provided regular expression.
0
+ (- (id) directoryContentsAtPath:(id)path withPattern:(id)pattern is
0
         ((self directoryContentsAtPath: path) select:
0
- (do (directory)
0
- (pattern findInString: directory))))
0
-
0
+ (do (directory)
0
+ (pattern findInString: directory))))
0
+
0
      ;; Forwards unknown methods to the singleton instance of NSFileManager.
0
      (+ handleUnknownMessage:(id)message withContext:(id)ctx is
0
         ((NSFileManager defaultManager) sendMessage:message withContext:ctx)))
0
 
0
 (class NSString
0
      
0
- ;; Whitespace removal. Self-explanaory.
0
+ ;; Whitespace removal. Self-explanatory.
0
      (- (id) stripWhitespace is
0
- (self stringByTrimmingCharactersInSet:(NSCharacterSet whitespaceCharacterSet)))
0
+ (self stringByTrimmingCharactersInSet:(NSCharacterSet whitespaceCharacterSet)))
0
      
0
      ;; Grabs the nth path component. There is no error checking on this. Be careful.
0
      (- (id) pathComponent:(int)index is
0
- ((self pathComponents) index))
0
+ ((self pathComponents) index))
0
      
0
      ;; This makes string substitution much more concise and Rubyesque.
0
      ;; Merely an alias for replaceWithString:inString:
0
      (- (id) sub:(id)re with:(id)string is
0
- (re replaceWithString:string inString:self))
0
+ (re replaceWithString:string inString:self))
0
      
0
      ;; This escapes all HTML characters. Perhaps this should be included in NuTemplate?
0
      (- (id) escapeHTML is
0
- ((((self sub: /&/ with: "&")
0
- sub: /\"/ with: """)
0
- sub: />/ with: ">")
0
- sub: /</ with: "&lt;")))
0
+ ((((self sub: /\"/ with: "&quot;")
0
+ sub: />/ with: "&gt;")
0
+ sub: /</ with: "&lt;"))))
0
 
0
 (class NSNull
0
      ;; Overriding stringValue prevents parentheses from appearing everywhere in my templates.
0
      ;; Kids, don't try this at home. I feel very dirty writing this.
0
- (- (id) stringValue is ""))
0
\ No newline at end of file
0
+ (- (id) stringValue is ""))
0
\ No newline at end of file
...
10
11
12
13
14
 
 
 
 
 
 
 
 
15
...
10
11
12
 
13
14
15
16
17
18
19
20
21
22
0
@@ -10,4 +10,11 @@
0
         
0
 (global link-to-page
0
     (do (page)
0
- "<a href=\"#{(page path)}\">#{(page path)}</a>"))
0
\ No newline at end of file
0
+ "<a href=\"#{(page path)}\">#{(page path)}</a>"))
0
+
0
+(global display-page
0
+ (do (page)
0
+ (if page
0
+ (NuMarkdown convert: (page contents))
0
+ (else
0
+ "This page doesn't exist yet. Click on the 'Edit' link above to create it."))))
0
\ No newline at end of file
...
6
7
8
9
10
11
12
 
13
14
15
...
6
7
8
 
 
 
 
9
10
11
12
0
@@ -6,10 +6,7 @@
0
 Welcome to Nuki!
0
 
0
 Nuki is a simple Wiki engine powered by the Nunja web server, the Git version control system, and NuMarkdown.
0
-As you can _see_, Markdown works - however, <em>regular</em> HTML is escaped.
0
-Links are created with Markdown syntax: [About Nuki](/AboutNuki).
0
-
0
-The logo above was drawn by the lovely and talented [Victoria Wang](http://violasong.com)
0
+As you can _see_, Markdown works.
0
 END)
0
         ($session commit))
0
           (unless ($session fileExists: "About")
0
...
11
12
13
 
14
15
16
...
11
12
13
14
15
16
17
0
@@ -11,6 +11,7 @@
0
 
0
 (load "Nunja")
0
 (load "NuMarkdown")
0
+(load "SmartyPants")
0
 
0
 (load "Nuki")
0
 (load "Nuki:git")
...
13
14
15
16
 
17
18
19
...
13
14
15
 
16
17
18
19
0
@@ -13,7 +13,7 @@
0
   <div id="content">
0
     <form action=<%= "/#{@path}/edit" %> method="post">
0
       <label for="contents">Page contents: </label>
0
- <textarea name="contents" rows=35 cols=75><%= (@page filesystemContents) %></textarea> <br/>
0
+ <textarea name="contents" rows=35 cols=75><%= (@page contents) %></textarea> <br/>
0
       <input type="submit" value="Commit"/> <br/> <input type="reset"/>
0
     </form>
0
   </div>
...
13
14
15
16
 
 
17
18
19
...
13
14
15
 
16
17
18
19
20
0
@@ -13,7 +13,8 @@
0
   <div id="content">  
0
     <% (if @allRevisions %>  
0
      <% (@allRevisions each: (do (hash) %>
0
- Revision: <a href="/<%= @path %>/history/<%= hash %>"><%= hash %></a> <br> <% )) %>
0
+ Rev <a href="/<%= @path %>/history/<%= hash %>"><%= hash %></a>
0
+ (<a href="/<%= @path %>/history/<%= hash %>/edit">Edit</a>)<br> <% )) %>
0
     <% (else %>
0
       Since the page <%= @path %> doesn't exist yet, it has no history.
0
     <% )) %>
...
28
29
30
31
32
33
34
...
28
29
30
 
31
32
33
0
@@ -28,7 +28,6 @@ background:#FFF;
0
 width: 750px;
0
 padding: 0;
0
 margin: 0;
0
-height: 100%;
0
 float: left;
0
 background:#FFF;
0
 }
...
15
16
17
18
19
20
21
22
 
23
24
25
...
15
16
17
 
 
 
 
 
18
19
20
21
0
@@ -15,11 +15,7 @@
0
     </div>
0
   </div>
0
   <div id="content">
0
- <% (if @page %>
0
- <%= (NuMarkdown convert: ((@page contents) escapeHTML)) %>
0
- <% (else %>
0
- The page '<%= @path %>' doesn't exist yet. Click on the 'Edit' link above to create it.
0
- <% )) %>
0
+ <%= (display-page @page) %>
0
   </div>
0
   <div id="footer">
0
     <p>&copy; 2007 <a href="http://importantshock.wordpress.com">Patrick Thomson</a>. A <a href="http://programming.nu">Nu&#8482;</a> thing.</p>
...
17
18
19
20
21
22
23
...
52
53
54
55
56
 
 
 
 
 
 
 
 
 
57
...
17
18
19
 
20
21
22
...
51
52
53
 
54
55
56
57
58
59
60
61
62
63
64
0
@@ -17,7 +17,6 @@
0
 (get "/pages"
0
      (default-headers)
0
      (set @pages ($session allBlobs))
0
- (p @pages)
0
      (eval (template-named "listpages")))
0
 
0
 (get /\/(\w*)/
0
@@ -52,4 +51,12 @@
0
      (set @revision (TITLE pathComponent: 3))
0
      (set @page ($session fetchBlob: @path))
0
      (@page setContents: (@page contentsForRevisionHash: @revision))
0
- (eval (template-named "page")))
0
\ No newline at end of file
0
+ (eval (template-named "page")))
0
+
0
+(get /\/(\w*)\/history\/(\w*)\/edit/
0
+ (default-headers)
0
+ (set @path (TITLE pathComponent: 1))
0
+ (set @revision (TITLE pathComponent: 3))
0
+ (set @page ($session fetchBlob: @path))
0
+ (@page setContents: (@page contentsForRevisionHash: @revision))
0
+ (eval (template-named "edit")))
0
\ No newline at end of file

Comments

    No one has commented yet.