public
Fork of sr/git-wiki
Description: A wiki engine that uses a Git repository as its data store.
Homepage: http://atonie.org/2008/02/git-wiki
Clone URL: git://github.com/al3x/git-wiki.git
Search Repo:
half-working 'older' links on page, a better don't-repeat-yourself way to 
view older revisions, sundry fixes
Alex Payne (author)
Fri Feb 22 12:05:04 -0800 2008
commit  95f6d9ce83ba0cc6eaf570154eb1c02c1735d1d9
tree    7b43780e5eb29cd9aaecd9e3c561de65cf0c225c
parent  b651c58e742115262a015b3b2f6fb0048099c35d
0
...
1
2
3
 
 
4
5
6
7
 
8
 
9
10
11
 
...
1
 
 
2
3
4
5
6
7
8
9
10
11
12
 
13
0
@@ -1,11 +1,13 @@
0
 = SOON
0
- * working launchd plist (al3x)
0
- * backlinks (trivial syntax, ideally) - requested by lattice
0
+ * next/previous version links on pages (partially complete)
0
+ * working launchd plist
0
   * deleting pages
0
   * pushing repo
0
 
0
 = LATER/MAYBE
0
+ * backlinks (trivial syntax, ideally)
0
   * outliner functionality
0
+ * repo stats/info/maintenance page
0
   
0
 = DONE
0
- * Pretty stylesheet (al3x and timoni)
0
+ * Pretty stylesheet
...
67
68
69
70
71
 
 
72
73
74
...
67
68
69
 
 
70
71
72
73
74
0
@@ -67,8 +67,8 @@ get '/h/:page' do
0
 end
0
 
0
 get '/h/:page/:rev' do
0
- @page = Page.new(params[:page])
0
- show :version, "Version of #{@page.name}"
0
+ @page = Page.new(params[:page], params[:rev])
0
+ show :show, "#{@page.name} / version #{params[:rev]})"
0
 end
0
 
0
 get '/d/:page/:rev' do
...
1
2
3
4
 
5
 
6
7
8
...
11
12
13
14
 
 
 
 
 
15
16
17
...
33
34
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
37
38
...
1
2
3
 
4
5
6
7
8
9
...
12
13
14
 
15
16
17
18
19
20
21
22
...
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
0
@@ -1,8 +1,9 @@
0
 class Page
0
   attr_reader :name
0
 
0
- def initialize(name)
0
+ def initialize(name, rev=nil)
0
     @name = name
0
+ @rev = rev
0
     @filename = File.join(GIT_REPO, @name)
0
   end
0
 
0
@@ -11,7 +12,11 @@ class Page
0
   end
0
 
0
   def raw_body
0
- @raw_body ||= File.exists?(@filename) ? File.read(@filename) : ''
0
+ if @rev
0
+ @raw_body ||= ($repo.tree(@rev)/@name).data
0
+ else
0
+ @raw_body ||= File.exists?(@filename) ? File.read(@filename) : ''
0
+ end
0
   end
0
 
0
   def body=(content)
0
@@ -33,6 +38,23 @@ class Page
0
   def delta(rev)
0
     $repo.diff($repo.commit(rev).parents.first, rev, @name)
0
   end
0
+
0
+ def previous_commit
0
+ # FIXME this is going through all commits, not just those containing
0
+ # this page
0
+ rev = @rev || $repo.commits.first
0
+ commit = $repo.commit(rev).parents.first
0
+
0
+ if ($repo.tree(commit.to_s)/@name)
0
+ commit
0
+ else
0
+ nil
0
+ end
0
+ end
0
+
0
+ def next_commit
0
+ # TODO implement
0
+ end
0
 
0
   def version(rev)
0
     data = ($repo.tree(rev)/@name).data
...
1
2
3
4
 
 
 
 
 
 
 
5
 
 
 
 
6
7
8
9
10
 
...
1
2
 
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -1,10 +1,20 @@
0
 <h1><%= @page.name %></h1>
0
 
0
-<div class="sub_nav">
0
- <a href="/e/<%= @page.name %>" class="nav_link">edit</a> &bull;
0
+<div class="sub_nav">
0
+ <% if params[:rev] %>
0
+ <a href="/<%= @page.name %>" class="nav_link">current</a> &bull;
0
+ <% else %>
0
+ <a href="/e/<%= @page.name %>" class="nav_link">edit</a> &bull;
0
+ <% end %>
0
+
0
   <a href="/h/<%= @page.name %>" class="nav_link">history</a>
0
+
0
+ <% if @page.previous_commit %>
0
+ &bull; <a href="/h/<%= @page.name %>/<%= @page.previous_commit%>" class="nav_link">older</a>
0
+ <% end %>
0
 </div>
0
 
0
 <div class="content">
0
   <%= @page.body %>
0
 </div>
0
+

Comments

    No one has commented yet.