Skip to content

Commit 299ff8d

Browse files
committed
Makeover views; add a stylesheet
1 parent ec2ac92 commit 299ff8d

File tree

6 files changed

+69
-36
lines changed

6 files changed

+69
-36
lines changed

git-wiki.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
module GitWiki
99
class << self
10-
attr_accessor :root_page, :extension, :repository, :link_pattern
10+
attr_accessor :root_page, :extension, :link_pattern
11+
attr_reader :wiki_name, :repository
1112
end
12-
@repository = Grit::Repo.new(ARGV[0] || File.expand_path('~/wiki'))
13+
@wiki_name = File.basename(File.expand_path(ARGV[0] || '~/wiki'))
14+
@repository = Grit::Repo.new(File.expand_path(ARGV[0] || '~/wiki'))
1315
@extension = ARGV[1] || '.markdown'
1416
@root_page = ARGV[2] || 'index'
1517
@link_pattern = /\[\[(.*?)\]\]/
@@ -39,12 +41,8 @@ def initialize(blob)
3941
@blob = blob
4042
end
4143

42-
def to_html
43-
Page.wikify(RDiscount.new(content).to_html)
44-
end
45-
4644
def to_s
47-
name
45+
@blob.name.sub(/#{GitWiki.extension}$/, '')
4846
end
4947

5048
def url
@@ -59,14 +57,14 @@ def css_class
5957
@blob.id ? 'existing' : 'new'
6058
end
6159

62-
def name
63-
@blob.name.gsub(/#{File.extname(@blob.name)}$/, '')
64-
end
65-
6660
def content
6761
@blob.data
6862
end
6963

64+
def to_html
65+
Page.wikify(RDiscount.new(content).to_html)
66+
end
67+
7068
def save!(data)
7169
Dir.chdir(GitWiki.repository.working_dir) do
7270
File.open(@blob.name, 'w') {|f| f.puts(data.gsub("\r\n", "\n")) }

public/wiki.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
body {
2+
margin: 0;
3+
padding: 0;
4+
color: #000000;
5+
background: #ffffff;
6+
font: serif;
7+
}
8+
#title {
9+
margin: 0;
10+
padding: 0.2em 0.4em;
11+
background: #ecedf8;
12+
border: 1px solid #d6d7e1;
13+
font: normal 200% sans-serif;
14+
}
15+
#content {
16+
margin: 1em;
17+
}
18+
#actions {
19+
float: right;
20+
margin: -1.75em 0.4em 0 0;
21+
font: normal 140% sans-serif;
22+
}
23+
#actions li {
24+
display: inline;
25+
padding: 0.2em;
26+
}
27+
dt {
28+
font-weight: bold;
29+
}
30+
a:link {
31+
color: #0a0ac2;
32+
}
33+
a:visited {
34+
color: #572b80;
35+
}
36+
a.new:link {
37+
color: #0ac20a;
38+
}
39+
a.new:visited {
40+
color: #57802b;
41+
}

views/edit.haml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
- title "Editing #{@page.name}"
2-
%h1= title
31
%form{:method => 'POST', :action => @page.edit_url}
42
%p
5-
%textarea{:name => 'body', :rows => 30, :style => "width: 100%"}= @page.content
3+
%textarea{:name => 'body', :rows => 25, :cols => 80}~ @page.content
64
%p
7-
%input.submit{:type => :submit, :value => "Save as the newest version"}
8-
or
9-
%a.cancel{:href=>@page.url} cancel
5+
%input{:type => :submit, :value => "Save Changes"}

views/layout.haml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
!!!
22
%html
33
%head
4-
%title= title
4+
%title= @page || GitWiki::wiki_name
5+
%link{:rel => 'stylesheet', :type => 'text/css', :href => '/wiki.css'}
56
%body
6-
%ul
7+
%h1#title<
8+
%a.home{:href => '/'}>= GitWiki::wiki_name
9+
- if @page and @page.url != '/'
10+
\:
11+
%a{:href => @page.url}= @page
12+
%ul#actions
13+
- if @page
14+
%li
15+
%a.edit{:href => @page.edit_url}> edit
716
%li
8-
%a{ :href => "/" } Home
9-
%li
10-
%a{ :href => "/pages/" } All pages
17+
%a.list{:href => '/pages/'}> list
1118
#content= yield

views/list.haml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
- title "Listing pages"
2-
%h1 All pages
3-
- if @pages.empty?
4-
%p No pages found.
5-
- else
6-
%ul#list
7-
- @pages.each do |page|
8-
%li= list_item(page)
1+
%ul#list
2+
- @pages.each do |p|
3+
%li
4+
%a.page.existing{:href => p.url}= p

views/show.haml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
- title @page.name
2-
#edit
3-
%a{:href => @page.edit_url} Edit this page
4-
%h1= title
5-
#content
6-
~"#{@page.to_html}"
1+
~ @page.to_html

0 commit comments

Comments
 (0)