@@ -16,8 +16,7 @@ class << self
16
16
17
17
class Page
18
18
def self . find_all
19
- return [ ] if repository . tree . contents . empty?
20
- GitWiki . repository . tree . contents . collect { |blob | new ( blob ) }
19
+ GitWiki . repository . tree . contents . collect { |blob | new ( blob ) }
21
20
end
22
21
23
22
def self . find_or_create ( name )
@@ -26,18 +25,6 @@ def self.find_or_create(name)
26
25
new ( blob || Grit ::Blob . create ( GitWiki . repository , :name => path ) )
27
26
end
28
27
29
- def self . css_class_for ( name )
30
- find_blob ( name ) ? "exists" : "unknown"
31
- end
32
-
33
- def self . repository
34
- GitWiki . repository || raise
35
- end
36
-
37
- def self . extension
38
- GitWiki . extension || raise
39
- end
40
-
41
28
def initialize ( blob )
42
29
@blob = blob
43
30
end
@@ -50,8 +37,8 @@ def to_s
50
37
name
51
38
end
52
39
53
- def new?
54
- @blob . id . nil?
40
+ def css_class
41
+ @blob . id ? 'existing' : 'new'
55
42
end
56
43
57
44
def name
@@ -70,18 +57,14 @@ def update_content(new_content)
70
57
71
58
private
72
59
def add_to_index_and_commit!
73
- Dir . chdir ( self . class . repository . working_dir ) {
74
- self . class . repository . add ( @blob . name )
60
+ Dir . chdir ( GitWiki . repository . working_dir ) {
61
+ GitWiki . repository . add ( @blob . name )
75
62
}
76
- self . class . repository . commit_index ( commit_message )
63
+ GitWiki . repository . commit_index ( "web commit: #{ self } " )
77
64
end
78
65
79
66
def file_name
80
- File . join ( self . class . repository . working_dir , name + self . class . extension )
81
- end
82
-
83
- def commit_message
84
- new? ? "Created #{ name } " : "Updated #{ name } "
67
+ File . join ( GitWiki . repository . working_dir , name + GitWiki . extension )
85
68
end
86
69
87
70
def wiki_link ( str )
@@ -95,21 +78,6 @@ def wiki_link(str)
95
78
set :haml , :format => :html5 , :attr_wrapper => '"'
96
79
enable :inline_templates
97
80
98
- before do
99
- content_type "text/html" , :charset => "utf-8"
100
- end
101
-
102
- helpers do
103
- def title ( title = nil )
104
- @title = title . to_s unless title . nil?
105
- @title
106
- end
107
-
108
- def list_item ( page )
109
- %Q{<a class="page_name" href="/#{ page } ">#{ page . name } </a>}
110
- end
111
- end
112
-
113
81
get "/" do
114
82
redirect "/" + GitWiki . homepage
115
83
end
0 commit comments