File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 7
7
8
8
module GitWiki
9
9
class << self
10
- attr_accessor :root_page , :extension , :link_pattern
10
+ attr_accessor :wiki_path , : root_page, :extension , :link_pattern
11
11
attr_reader :wiki_name , :repository
12
+ def wiki_path = ( path )
13
+ @wiki_name = File . basename ( path )
14
+ @repository = Grit ::Repo . new ( path )
15
+ end
16
+ def all_page_blobs
17
+ @repository . tree . contents . select do |obj |
18
+ obj . kind_of? ( Grit ::Blob ) && obj . name . end_with? ( @extension )
19
+ end
20
+ end
12
21
end
13
- @wiki_name = File . basename ( File . expand_path ( ARGV [ 0 ] || '~/wiki' ) )
14
- @repository = Grit ::Repo . new ( File . expand_path ( ARGV [ 0 ] || '~/wiki' ) )
15
- @extension = ARGV [ 1 ] || '.markdown'
16
- @root_page = ARGV [ 2 ] || 'index'
17
- @link_pattern = /\[ \[ (.*?)\] \] /
18
22
end
19
23
20
24
class Page
21
25
def self . find_all
22
- GitWiki . repository . tree . contents . collect { |blob | new ( blob ) }
26
+ GitWiki . all_page_blobs . map { |blob | new ( blob ) }
23
27
end
24
28
25
29
def self . find_or_create ( name )
@@ -101,3 +105,10 @@ def save!(data)
101
105
@page . save! ( params [ :body ] )
102
106
redirect @page . url
103
107
end
108
+
109
+ configure do
110
+ GitWiki . wiki_path = Dir . pwd
111
+ GitWiki . root_page = 'index'
112
+ GitWiki . extension = '.md'
113
+ GitWiki . link_pattern = /\[ \[ (.*?)\] \] /
114
+ end
You can’t perform that action at this time.
0 commit comments