Skip to content
Browse files

hella better style, move page and extensions out to their own files, …

…doc additions
  • Loading branch information...
1 parent 66bacb8 commit fbe2a733eda74a83559435ab0be0b43935fcdbcf Alex Payne committed Feb 21, 2008
Showing with 231 additions and 128 deletions.
  1. +1 −0 .gitignore
  2. +2 −1 AUTHORS
  3. +89 −32 css/style.css
  4. +6 −0 extensions.rb
  5. +5 −54 git-wiki.rb
  6. +41 −0 page.rb
  7. +11 −4 views/delta.erb
  8. +15 −8 views/edit.erb
  9. +20 −12 views/history.erb
  10. +9 −4 views/layout.erb
  11. +13 −6 views/list.erb
  12. +10 −4 views/show.erb
  13. +9 −3 views/version.erb
View
1 .gitignore
@@ -1 +1,2 @@
*.log
+.DS_Store
View
3 AUTHORS
@@ -2,4 +2,5 @@ Originally by Simon Rozet (http://atonie.org/2008/02/git-wiki)
Modified by:
- Alex Payne (http://www.al3x.net)
- - Jesse Andrews (http://www.overstimulate.com)
+ - Jesse Andrews (http://www.overstimulate.com)
+ - Timoni Grone (http://www.timoni.org) - stylesheet and design aid
View
121 css/style.css
@@ -1,56 +1,113 @@
+/* elements */
+
body {
- font-family: Verdana, Arial, "Bitstream Vera Sans", Helvetica, sans-serif;
- font-size: 14px;
- color: black;
- line-height: 160%;
- background-color: white;
+ background-color: #fff;
+ color: #333;
+ font-family: Helvetica, Arial, "Deja Vu Sans", "Bitstream Vera Sans", sans-serif;
+ font-size: .95em;
+ line-height: 1.6em;
margin: 2em;
}
-#navigation {
+a {
+ color: #6d7fa3;
+ text-decoration: none;
+}
+a:visited { color: #7b69b0; }
+a:hover { text-decoration: underline; }
+
+code, pre, .delta {
+ font-family: "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Inconsolata", "Consolas", monospace;
+}
+
+h1 {
+ color: #333;
+ font-size: 3.5em;
+ margin: 24px 0 8px 0;
+}
+
+textarea {
+ border: 1px solid #ccc;
+ font-family: "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", "Inconsolata", "Consolas", monospace;
+ font-size: .9em;
padding: 5px;
- border-bottom: 1px black solid;
}
-#navigation a {
- background-color: #e0e0e0;
- color: black;
+ul {
+ list-style-type: square;
+ padding: 0;
+}
+
+/* classes */
+
+.cancel {
+ font-weight: normal;
text-decoration: none;
- padding: 2px;
+ font-size: 14px;
}
+.cancel:before { content: "("; }
+.cancel:after { content: ")" }
-h1 {
- display: block;
- padding-bottom: 5px;
+.clearer { clear: both; }
+
+.content {
+ margin-left: 35%;
+ margin-top: -.55em;
+ padding: 0 10px 2px 10px;
}
-a { color: black }
+.delta {
+ font-size: 1.1em;
+ padding: 0;
+}
-em {
- font-size: 0.8em;
+.nav_link, .nav_link:visited {
+ display: inline;
+ padding: 3px;
+ color: #666;
}
+.nav_link:hover {
+ background-color: #d1ccdb;
+ color: #333;
+ text-decoration: none;
+}
+
+.nav_list, #footer {
+ border-top: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+ list-style-type: none;
+ padding: 4px;
+ text-align: right;
+}
+
+.nav_list li {
+ display: inline;
+ padding-right: 10px;
+}
+
+.right { text-align: right; }
+
.submit {
font-size: large;
font-weight: bold;
}
-.page_title { font-size: xx-large; }
+.sub_nav { float: left; }
-.edit_link {
- color: black;
- font-size: 14px;
- font-weight: bold;
- background-color: #e0e0e0;
- font-variant: small-caps;
- text-decoration: none;
+/* ids */
+
+#container {
+ clear: both;
+ margin: auto;
+ width: 70%;
}
-.cancel {
- background-color: #e0e0e0;
- font-weight: normal;
- text-decoration: none;
- font-size: 14px;
+#edit_textarea {
+ height: 35em;
+ margin-top: 1.5em;
+ width: 100%;
}
-.cancel:before { content: "("; }
-.cancel:after { content: ")" }
+
+#footer a, #footer a:visited { color: #666; }
+
View
6 extensions.rb
@@ -0,0 +1,6 @@
+class String
+ def wiki_linked
+ self.gsub!(/\b((?:[A-Z]\w+){2,})/) { |m| "<a href=\"/e/#{m}\">#{m}</a>" }
+ self
+ end
+end
View
59 git-wiki.rb
@@ -8,10 +8,13 @@
end
end
+require 'page'
+require 'extensions'
+
GIT_REPO = ARGV[1] || ENV['HOME'] + '/wiki'
GIT_DIR = File.join(GIT_REPO, '.git')
HOMEPAGE = 'Home'
-UV_THEME = 'twilight'
+UV_THEME = 'idle'
unless File.exists?(GIT_DIR) && File.directory?(GIT_DIR)
FileUtils.mkdir_p(GIT_DIR)
@@ -21,63 +24,11 @@
$repo = Grit::Repo.new(GIT_REPO)
-class String
- def wiki_linked
- self.gsub!(/\b((?:[A-Z]\w+){2,})/) { |m| "<a href=\"/e/#{m}\">#{m}</a>" }
- self
- end
-end
-
-class Page
- attr_reader :name
-
- def initialize(name)
- @name = name
- @filename = File.join(GIT_REPO, @name)
- end
-
- def body
- @body ||= RedCloth.new(RubyPants.new(raw_body).to_html).to_html.wiki_linked
- end
-
- def raw_body
- @raw_body ||= File.exists?(@filename) ? File.read(@filename) : ''
- end
-
- def body=(content)
- File.open(@filename, 'w') { |f| f << content }
- message = tracked? ? "Edited #{@name}" : "Created #{@name}"
- `cd #{GIT_REPO} && git add #{@name} && git commit -m "#{message}"`
- end
-
- def tracked?
- return false if $repo.commits.empty?
- $repo.commits.first.tree.contents.map { |b| b.name }.include?(@name)
- end
-
- def history
- return nil unless tracked?
- $repo.log('master', @name)
- end
-
- def delta(rev)
- $repo.diff($repo.commit(rev).parents.first, rev, @name)
- end
-
- def version(rev)
- ($repo.tree(rev)/@name).data
- end
-
- def to_s
- "<li><strong><a href='/#{@name}'>#{@name}</a></strong> — <a href='/e/#{@name}'>edit</a></li>"
- end
-end
-
layout { File.read('views/layout.erb') }
def show(template, title)
@title = title
- erb template
+ erb(template)
end
get('/') { redirect '/' + HOMEPAGE }
View
41 page.rb
@@ -0,0 +1,41 @@
+class Page
+ attr_reader :name
+
+ def initialize(name)
+ @name = name
+ @filename = File.join(GIT_REPO, @name)
+ end
+
+ def body
+ @body ||= RedCloth.new(RubyPants.new(raw_body).to_html).to_html.wiki_linked
+ end
+
+ def raw_body
+ @raw_body ||= File.exists?(@filename) ? File.read(@filename) : ''
+ end
+
+ def body=(content)
+ File.open(@filename, 'w') { |f| f << content }
+ message = tracked? ? "edited #{@name}" : "created #{@name}"
+ `cd #{GIT_REPO} && git add #{@name} && git commit -m "#{message}"`
+ end
+
+ def tracked?
+ return false if $repo.commits.empty?
+ $repo.commits.first.tree.contents.map { |b| b.name }.include?(@name)
+ end
+
+ def history
+ return nil unless tracked?
+ $repo.log('master', @name)
+ end
+
+ def delta(rev)
+ $repo.diff($repo.commit(rev).parents.first, rev, @name)
+ end
+
+ def version(rev)
+ data = ($repo.tree(rev)/@name).data
+ RedCloth.new(RubyPants.new(data).to_html).to_html.wiki_linked
+ end
+end
View
15 views/delta.erb
@@ -1,5 +1,12 @@
<h1>Diff of <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
-<%=
- diff = @page.delta(params[:rev])
- Uv.parse(diff, "xhtml", "diff", true, UV_THEME)
-%>
+
+<div class="sub_nav">
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a> &bull;
+ <a href="/e/<%= @page.name %>" class="nav_link">edit</a>
+</div>
+
+<div class="content">
+ <div class="delta">
+ <%= Uv.parse(@page.delta(params[:rev]), "xhtml", "diff", true, UV_THEME) %>
+ </div>
+</div>
View
23 views/edit.erb
@@ -1,8 +1,15 @@
-<h1>Editing <%= @page.name %></h1>
-<a href="javascript:history.back();" class="cancel">Cancel</a>
-<form method="post" action="/e/<%= params[:page] %>">
- <p>
- <textarea name="body" rows="25" cols="130"><%= @page.raw_body %></textarea>
- </p>
- <p><input type="submit" value="Save as the newest version" class="submit" /></p>
-</form>
+<h1>Editing <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
+
+<div class="sub_nav">
+ <a href="/<%= @page.name %>" class="nav_link">back</a> &bull;
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a>
+</div>
+
+<div class="content">
+ <form method="post" action="/e/<%= params[:page] %>">
+ <textarea name="body" id="edit_textarea"><%= @page.raw_body %></textarea>
+ <p class="right"><input type="submit" value="Save" class="submit" /></p>
+ </form>
+</div>
+
+<div class="clearer"></div>
View
32 views/history.erb
@@ -1,12 +1,20 @@
-<h1>History of <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
-<ul>
- <% @page.history.each do |c| %>
- <li>
- <em><%= c.committed_date %></em>
- <a href="/h/<%= @page.name %>/<%= c.id %>"><%= c.message %></a>
- <% unless c.parents.empty? %>
- <a href="/d/<%= @page.name %>/<%= c.id %>">diff</a>
- <% end %>
- </li>
- <% end %>
-</ul>
+<h1>History / <a href="/<%= @page.name %>"><%= @page.name %></a></h1>
+
+<div class="sub_nav">
+ <a href="/<%= @page.name %>" class="nav_link">back</a> &bull;
+ <a href="/e/<%= @page.name %>" class="nav_link">edit</a>
+</div>
+
+<div class="content">
+ <ul>
+ <% @page.history.each do |c| %>
+ <li>
+ <%= c.committed_date %> &mdash;
+ <a href="/h/<%= @page.name %>/<%= c.id %>"><%= c.message %></a>
+ <% unless c.parents.empty? %>
+ &bull; <a href="/d/<%= @page.name %>/<%= c.id %>">diff</a>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+</div>
View
13 views/layout.erb
@@ -6,10 +6,15 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
- <div id="navigation">
- <a href="/">Home</a>
- <a href="/_list">List</a>
+ <div id="container">
+ <ul class="nav_list" id="top_nav">
+ <li><a href="/" class="nav_link">home</a></li>
+ <li><a href="/_list" class="nav_link">pages</a></li>
+ </ul>
+ <%= yield %>
+ <div id="footer">
+ powered by <a href="http://github.com/sr/git-wiki/network">git-wiki</a>
+ </div>
</div>
- <%= yield %>
</body>
</html>
View
19 views/list.erb
@@ -1,10 +1,17 @@
<% if @pages.empty? %>
- <p>No pages found.</p>
+ <h1>No pages yet</h1>
<% else %>
<h1>All pages</h1>
- <ul>
- <% @pages.each do |page| %>
- <%= page.to_s %>
- <% end %>
- </ul>
+
+ <div class="content">
+ <ul>
+ <% @pages.each do |page| %>
+ <li>
+ <strong><a href="/<%= page.name %>"><%= page.name %></a></strong> &mdash;
+ <a href="/e/<%= page.name %>">edit</a> &bull;
+ <a href="/h/<%= page.name %>">history</a>
+ </li>
+ <% end %>
+ </ul>
+ </div>
<% end %>
View
14 views/show.erb
@@ -1,4 +1,10 @@
-<a href="/e/<%= @page.name %>" class="edit_link">edit this page</a>
-<a href="/h/<%= @page.name %>" class="edit_link">history of this page</a>
-<h1 class="page_title"><%= @page.name %></h1>
-<div id="page_content"><%= @page.body %></div>
+<h1><%= @page.name %></h1>
+
+<div class="sub_nav">
+ <a href="/e/<%= @page.name %>" class="nav_link">edit</a> &bull;
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a>
+</div>
+
+<div class="content">
+ <%= @page.body %>
+</div>
View
12 views/version.erb
@@ -1,4 +1,10 @@
-<a href="/e/<%= @page.name %>" class="edit_link">edit this page</a>
-<a href="/h/<%= @page.name %>" class="edit_link">history of page</a>
<h1 class="page_title"><%= @page.name %></h1>
-<div id="page_content"><%= @page.version(params[:rev]) %></div>
+
+<div class="sub_nav">
+ <a href="/<%= @page.name %>" class="nav_link">current</a> &bull;
+ <a href="/h/<%= @page.name %>" class="nav_link">history</a>
+</div>
+
+<div class="content">
+ <%= @page.version(params[:rev]) %>
+</div>

0 comments on commit fbe2a73

Please sign in to comment.
Something went wrong with that request. Please try again.