GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of al3x/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/zmalltalker/git-wiki.git
hella better style, move page and extensions out to their own files, doc 
additions
Alex Payne (author)
Thu Feb 21 23:08:55 -0800 2008
commit  fbe2a733eda74a83559435ab0be0b43935fcdbcf
tree    46b16e976d8984e1cc1b185301e085683cfe1b9a
parent  66bacb826219bc5bb913cb29d94e20da7c3fb23c
...
1
 
2
...
1
2
3
0
@@ -1 +1,2 @@
0
 *.log
0
+.DS_Store
0
\ No newline at end of file
...
2
3
4
5
6
 
 
7
...
2
3
4
 
5
6
7
8
0
@@ -2,4 +2,5 @@ Originally by Simon Rozet (http://atonie.org/2008/02/git-wiki)
0
 
0
 Modified by:
0
  - Alex Payne (http://www.al3x.net)
0
- - Jesse Andrews (http://www.overstimulate.com)
0
\ No newline at end of file
0
+ - Jesse Andrews (http://www.overstimulate.com)
0
+ - Timoni Grone (http://www.timoni.org) - stylesheet and design aid
0
\ No newline at end of file
...
 
 
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
40
41
42
43
44
45
46
 
 
 
 
 
 
47
48
49
50
51
52
53
 
 
 
 
54
55
56
57
 
 
 
...
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
40
41
42
43
44
45
 
46
47
48
49
50
 
 
 
51
52
53
54
55
56
57
58
 
59
60
61
62
63
 
 
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
 
96
97
 
 
 
 
 
 
 
98
99
100
101
102
103
104
105
 
 
 
 
 
106
107
108
109
110
 
 
111
112
113
114
0
@@ -1,56 +1,113 @@
0
+/* elements */
0
+
0
 body {
0
- font-family: Verdana, Arial, "Bitstream Vera Sans", Helvetica, sans-serif;
0
- font-size: 14px;
0
- color: black;
0
- line-height: 160%;
0
- background-color: white;
0
+ background-color: #fff;
0
+ color: #333;
0
+ font-family: Helvetica, Arial, "Deja Vu Sans", "Bitstream Vera Sans", sans-serif;
0
+ font-size: .95em;
0
+ line-height: 1.6em;
0
   margin: 2em;
0
 }
0
 
0
-#navigation {
0
+a {
0
+ color: #6d7fa3;
0
+ text-decoration: none;
0
+}
0
+a:visited { color: #7b69b0; }
0
+a:hover { text-decoration: underline; }
0
+
0
+code, pre, .delta {
0
+ font-family: "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Inconsolata", "Consolas", monospace;
0
+}
0
+
0
+h1 {
0
+ color: #333;
0
+ font-size: 3.5em;
0
+ margin: 24px 0 8px 0;
0
+}
0
+
0
+textarea {
0
+ border: 1px solid #ccc;
0
+ font-family: "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Inconsolata", "Consolas", monospace;
0
+ font-size: .9em;
0
   padding: 5px;
0
- border-bottom: 1px black solid;
0
 }
0
 
0
-#navigation a {
0
- background-color: #e0e0e0;
0
- color: black;
0
+ul {
0
+ list-style-type: square;
0
+ padding: 0;
0
+}
0
+
0
+/* classes */
0
+
0
+.cancel {
0
+ font-weight: normal;
0
   text-decoration: none;
0
- padding: 2px;
0
+ font-size: 14px;
0
 }
0
+.cancel:before { content: "("; }
0
+.cancel:after { content: ")" }
0
 
0
-h1 {
0
- display: block;
0
- padding-bottom: 5px;
0
+.clearer { clear: both; }
0
+
0
+.content {
0
+ margin-left: 35%;
0
+ margin-top: -.55em;
0
+ padding: 0 10px 2px 10px;
0
 }
0
 
0
-a { color: black }
0
+.delta {
0
+ font-size: 1.1em;
0
+ padding: 0;
0
+}
0
 
0
-em {
0
- font-size: 0.8em;
0
+.nav_link, .nav_link:visited {
0
+ display: inline;
0
+ padding: 3px;
0
+ color: #666;
0
 }
0
 
0
+.nav_link:hover {
0
+ background-color: #d1ccdb;
0
+ color: #333;
0
+ text-decoration: none;
0
+}
0
+
0
+.nav_list, #footer {
0
+ border-top: 1px solid #ccc;
0
+ border-bottom: 1px solid #ccc;
0
+ list-style-type: none;
0
+ padding: 4px;
0
+ text-align: right;
0
+}
0
+
0
+.nav_list li {
0
+ display: inline;
0
+ padding-right: 10px;
0
+}
0
+
0
+.right { text-align: right; }
0
+
0
 .submit {
0
   font-size: large;
0
   font-weight: bold;
0
 }
0
 
0
-.page_title { font-size: xx-large; }
0
+.sub_nav { float: left; }
0
 
0
-.edit_link {
0
- color: black;
0
- font-size: 14px;
0
- font-weight: bold;
0
- background-color: #e0e0e0;
0
- font-variant: small-caps;
0
- text-decoration: none;
0
+/* ids */
0
+
0
+#container {
0
+ clear: both;
0
+ margin: auto;
0
+ width: 70%;
0
 }
0
 
0
-.cancel {
0
- background-color: #e0e0e0;
0
- font-weight: normal;
0
- text-decoration: none;
0
- font-size: 14px;
0
+#edit_textarea {
0
+ height: 35em;
0
+ margin-top: 1.5em;
0
+ width: 100%;
0
 }
0
-.cancel:before { content: "("; }
0
-.cancel:after { content: ")" }
0
\ No newline at end of file
0
+
0
+#footer a, #footer a:visited { color: #666; }
0
+
...
8
9
10
 
 
 
11
12
13
14
 
15
16
17
...
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
81
82
83
...
8
9
10
11
12
13
14
15
16
 
17
18
19
20
...
24
25
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
28
29
30
 
31
32
33
34
0
@@ -8,10 +8,13 @@
0
   end
0
 end
0
 
0
+require 'page'
0
+require 'extensions'
0
+
0
 GIT_REPO = ARGV[1] || ENV['HOME'] + '/wiki'
0
 GIT_DIR = File.join(GIT_REPO, '.git')
0
 HOMEPAGE = 'Home'
0
-UV_THEME = 'twilight'
0
+UV_THEME = 'idle'
0
 
0
 unless File.exists?(GIT_DIR) && File.directory?(GIT_DIR)
0
   FileUtils.mkdir_p(GIT_DIR)
0
@@ -21,63 +24,11 @@ end
0
 
0
 $repo = Grit::Repo.new(GIT_REPO)
0
 
0
-class String
0
- def wiki_linked
0
- self.gsub!(/\b((?:[A-Z]\w+){2,})/) { |m| "<a href=\"/e/#{m}\">#{m}</a>" }
0
- self
0
- end
0
-end
0
-
0
-class Page
0
- attr_reader :name
0
-
0
- def initialize(name)
0
- @name = name
0
- @filename = File.join(GIT_REPO, @name)
0
- end
0
-
0
- def body
0
- @body ||= RedCloth.new(RubyPants.new(raw_body).to_html).to_html.wiki_linked
0
- end
0
-
0
- def raw_body
0
- @raw_body ||= File.exists?(@filename) ? File.read(@filename) : ''
0
- end
0
-
0
- def body=(content)
0
- File.open(@filename, 'w') { |f| f << content }
0
- message = tracked? ? "Edited #{@name}" : "Created #{@name}"
0
- `cd #{GIT_REPO} && git add #{@name} && git commit -m "#{message}"`
0
- end
0
-
0
- def tracked?
0
- return false if $repo.commits.empty?
0
- $repo.commits.first.tree.contents.map { |b| b.name }.include?(@name)
0
- end
0
-
0
- def history
0
- return nil unless tracked?
0
- $repo.log('master', @name)
0
- end
0
-
0
- def delta(rev)
0
- $repo.diff($repo.commit(rev).parents.first, rev, @name)
0
- end
0
-
0
- def version(rev)
0
- ($repo.tree(rev)/@name).data
0
- end
0
-
0
- def to_s
0
- "<li><strong><a href='/#{@name}'>#{@name}</a></strong> — <a href='/e/#{@name}'>edit</a></li>"
0
- end
0
-end
0
-
0
 layout { File.read('views/layout.erb') }
0
 
0
 def show(template, title)
0
   @title = title
0
- erb template
0
+ erb(template)
0
 end
0
 
0
 get('/') { redirect '/' + HOMEPAGE }
...
1
2
3
4
5
 
 
 
 
 
 
 
 
 
 
 
...
1
 
 
 
 
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,5 +1,12 @@
0
 <h1>Diff of <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
0
-<%=
0
- diff = @page.delta(params[:rev])
0
- Uv.parse(diff, "xhtml", "diff", true, UV_THEME)
0
-%>
0
+
0
+<div class="sub_nav">
0
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a> &bull;
0
+ <a href="/e/<%= @page.name %>" class="nav_link">edit</a>
0
+</div>
0
+
0
+<div class="content">
0
+ <div class="delta">
0
+ <%= Uv.parse(@page.delta(params[:rev]), "xhtml", "diff", true, UV_THEME) %>
0
+ </div>
0
+</div>
...
1
2
3
4
5
6
7
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
@@ -1,8 +1,15 @@
0
-<h1>Editing <%= @page.name %></h1>
0
-<a href="javascript:history.back();" class="cancel">Cancel</a>
0
-<form method="post" action="/e/<%= params[:page] %>">
0
- <p>
0
- <textarea name="body" rows="25" cols="130"><%= @page.raw_body %></textarea>
0
- </p>
0
- <p><input type="submit" value="Save as the newest version" class="submit" /></p>
0
-</form>
0
+<h1>Editing <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
0
+
0
+<div class="sub_nav">
0
+ <a href="/<%= @page.name %>" class="nav_link">back</a> &bull;
0
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a>
0
+</div>
0
+
0
+<div class="content">
0
+ <form method="post" action="/e/<%= params[:page] %>">
0
+ <textarea name="body" id="edit_textarea"><%= @page.raw_body %></textarea>
0
+ <p class="right"><input type="submit" value="Save" class="submit" /></p>
0
+ </form>
0
+</div>
0
+
0
+<div class="clearer"></div>
...
1
2
3
4
5
6
7
8
9
10
11
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -1,12 +1,20 @@
0
-<h1>History of <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
0
-<ul>
0
- <% @page.history.each do |c| %>
0
- <li>
0
- <em><%= c.committed_date %></em>
0
- <a href="/h/<%= @page.name %>/<%= c.id %>"><%= c.message %></a>
0
- <% unless c.parents.empty? %>
0
- <a href="/d/<%= @page.name %>/<%= c.id %>">diff</a>
0
- <% end %>
0
- </li>
0
- <% end %>
0
-</ul>
0
+<h1>History / <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
0
+
0
+<div class="sub_nav">
0
+ <a href="/<%= @page.name %>" class="nav_link">back</a> &bull;
0
+ <a href="/e/<%= @page.name %>" class="nav_link">edit</a>
0
+</div>
0
+
0
+<div class="content">
0
+ <ul>
0
+ <% @page.history.each do |c| %>
0
+ <li>
0
+ <%= c.committed_date %> &mdash;
0
+ <a href="/h/<%= @page.name %>/<%= c.id %>"><%= c.message %></a>
0
+ <% unless c.parents.empty? %>
0
+ &bull; <a href="/d/<%= @page.name %>/<%= c.id %>">diff</a>
0
+ <% end %>
0
+ </li>
0
+ <% end %>
0
+ </ul>
0
+</div>
...
6
7
8
9
10
11
 
 
 
 
 
 
 
 
 
12
13
14
15
...
6
7
8
 
 
 
9
10
11
12
13
14
15
16
17
18
 
19
20
0
@@ -6,10 +6,15 @@
0
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
0
   </head>
0
   <body>
0
- <div id="navigation">
0
- <a href="/">Home</a>
0
- <a href="/_list">List</a>
0
+ <div id="container">
0
+ <ul class="nav_list" id="top_nav">
0
+ <li><a href="/" class="nav_link">home</a></li>
0
+ <li><a href="/_list" class="nav_link">pages</a></li>
0
+ </ul>
0
+ <%= yield %>
0
+ <div id="footer">
0
+ powered by <a href="http://github.com/sr/git-wiki/network">git-wiki</a>
0
+ </div>
0
     </div>
0
- <%= yield %>
0
   </body>
0
 </html>
...
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
0
@@ -1,10 +1,17 @@
0
 <% if @pages.empty? %>
0
- <p>No pages found.</p>
0
+ <h1>No pages yet</h1>
0
 <% else %>
0
   <h1>All pages</h1>
0
- <ul>
0
- <% @pages.each do |page| %>
0
- <%= page.to_s %>
0
- <% end %>
0
- </ul>
0
+
0
+ <div class="content">
0
+ <ul>
0
+ <% @pages.each do |page| %>
0
+ <li>
0
+ <strong><a href="/<%= page.name %>"><%= page.name %></a></strong> &mdash;
0
+ <a href="/e/<%= page.name %>">edit</a> &bull;
0
+ <a href="/h/<%= page.name %>">history</a>
0
+ </li>
0
+ <% end %>
0
+ </ul>
0
+ </div>
0
 <% end %>
...
1
2
3
4
 
 
 
 
 
 
 
 
 
 
...
 
 
 
 
1
2
3
4
5
6
7
8
9
10
0
@@ -1,4 +1,10 @@
0
-<a href="/e/<%= @page.name %>" class="edit_link">edit this page</a>
0
-<a href="/h/<%= @page.name %>" class="edit_link">history of this page</a>
0
-<h1 class="page_title"><%= @page.name %></h1>
0
-<div id="page_content"><%= @page.body %></div>
0
+<h1><%= @page.name %></h1>
0
+
0
+<div class="sub_nav">
0
+ <a href="/e/<%= @page.name %>" class="nav_link">edit</a> &bull;
0
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a>
0
+</div>
0
+
0
+<div class="content">
0
+ <%= @page.body %>
0
+</div>
...
1
2
3
4
 
 
 
 
 
 
 
 
 
...
 
 
1
 
2
3
4
5
6
7
8
9
10
0
@@ -1,4 +1,10 @@
0
-<a href="/e/<%= @page.name %>" class="edit_link">edit this page</a>
0
-<a href="/h/<%= @page.name %>" class="edit_link">history of page</a>
0
 <h1 class="page_title"><%= @page.name %></h1>
0
-<div id="page_content"><%= @page.version(params[:rev]) %></div>
0
+
0
+<div class="sub_nav">
0
+ <a href="/<%= @page.name %>" class="nav_link">current</a> &bull;
0
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a>
0
+</div>
0
+
0
+<div class="content">
0
+ <%= @page.version(params[:rev]) %>
0
+</div>

Comments

    No one has commented yet.