File tree Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Expand file tree Collapse file tree 2 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,13 @@ def file_path(name)
25
25
def url ( page = nil , params = nil )
26
26
'/' + ( page && page . name != @root_page ? page . name : '' ) + ( params ? "?#{ Rack ::Utils . build_query ( params ) } " : '' )
27
27
end
28
+ def expand_links ( html )
29
+ html . gsub ( @link_pattern ) do
30
+ link_text = $1
31
+ page = Page . find_or_create ( link_text . gsub ( /[^\w \s ]/ , '' ) . split . join ( '-' ) . downcase )
32
+ "<a class='page #{ 'new' unless page . exists? } ' href='#{ url ( page ) } '>#{ link_text } </a>"
33
+ end
34
+ end
28
35
end
29
36
end
30
37
@@ -40,16 +47,6 @@ def self.find_or_create(name, rev=nil)
40
47
new ( blob || Grit ::Blob . create ( GitWiki . repository , :name => path ) )
41
48
end
42
49
43
- def self . wikify ( content )
44
- content . gsub ( GitWiki . link_pattern ) { |match | link ( $1) }
45
- end
46
-
47
- def self . link ( text )
48
- page = find_or_create ( text . gsub ( /[^\w \s ]/ , '' ) . split . join ( '-' ) . downcase )
49
- page_class = page . exists? ? 'existing' : 'new'
50
- "<a class='page #{ page_class } ' href='#{ GitWiki . url ( page ) } '>#{ text } </a>"
51
- end
52
-
53
50
def initialize ( blob )
54
51
@blob = blob
55
52
end
@@ -67,7 +64,7 @@ def content
67
64
end
68
65
69
66
def to_html
70
- Page . wikify ( RDiscount . new ( content ) . to_html )
67
+ GitWiki . expand_links ( RDiscount . new ( content ) . to_html )
71
68
end
72
69
73
70
def log
Original file line number Diff line number Diff line change 1
1
%ul #list
2
2
- @pages.each do |p|
3
3
%li
4
- %a .page.existing {:href => GitWiki.url(p)}= p.name
4
+ %a .page {:href => GitWiki.url(p)}= p.name
You can’t perform that action at this time.
0 commit comments