Class: Gollum::Markup
- Inherits:
-
Object
- Object
- Gollum::Markup
- Defined in:
- lib/smeagol/gollum/page.rb
Instance Method Summary collapse
-
#process_page_link_tag(tag) ⇒ Object
Attempt to process the tag as a page link tag.
Instance Method Details
#process_page_link_tag(tag) ⇒ Object
Attempt to process the tag as a page link tag.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/smeagol/gollum/page.rb', line 18 def process_page_link_tag(tag) parts = tag.split('|') parts.reverse! if @format == :mediawiki name, page_name = *parts.compact.map(&:strip) cname = @wiki.page_class.cname(page_name || name) if name =~ %r{^https?://} && page_name.nil? %{<a href="#{name}">#{name}</a>} else presence = "absent" link_name = cname page, extra = find_page_from_name(cname) if page link_name = @wiki.page_class.cname(page.name) presence = "present" end link = ::File.join(@wiki.base_path, CGI.escape(link_name)) # TODO: This is a temporary hack for posts until actual subdirs are supported. # Also, this needs to be improved so /\d-/ does match if part of actual title. link = link.gsub(/(\d)-/, '\1/') %{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>} end end |