Distinguish between present and absent page links.

This commit is contained in:
Tom Preston-Werner
2010-07-07 13:49:55 -07:00
parent 2e49f2c9e7
commit 0485c67b3d
3 changed files with 20 additions and 4 deletions
+5 -1
View File
@@ -40,7 +40,11 @@ p {
color: #666;
}
/***********************/
a.absent {
color: #a00;
}
/* Images */
.frame {
margin: 1em 0;
+6 -2
View File
@@ -41,7 +41,7 @@ module Gollum
#
# Returns the placeholder'd String data.
def extract_tags(data)
data.gsub(/\[\[(.+?)\]\]/) do
data.gsub(/\[\[(.+?)\]\]/m) do
id = Digest::SHA1.hexdigest($1)
@tagmap[id] = $1
id
@@ -192,7 +192,11 @@ module Gollum
parts = tag.split('|')
name = parts[0].strip
cname = Page.cname((parts[1] || parts[0]).strip)
%{<a href="#{cname}">#{name}</a>}
if @wiki.page(cname)
%{<a class="internal present" href="#{cname}">#{name}</a>}
else
%{<a class="internal absent" href="#{cname}">#{name}</a>}
end
end
# Find the given file in the repo.
+9 -1
View File
@@ -21,7 +21,15 @@ context "Markup" do
page = @wiki.page("Bilbo Baggins")
output = Gollum::Markup.new(page).render
assert_equal %{<p>a <a href="Bilbo-Baggins">Bilbo Baggins</a> b</p>\n}, output
assert_equal %{<p>a <a class="internal present" href="Bilbo-Baggins">Bilbo Baggins</a> b</p>\n}, output
end
test "absent page link" do
@wiki.write_page("Tolkien", :markdown, "a [[J. R. R. Tolkien]]'s b", @commit)
page = @wiki.page("Tolkien")
output = Gollum::Markup.new(page).render
assert_equal %{<p>a <a class="internal absent" href="J.-R.-R.-Tolkien">J. R. R. Tolkien</a>'s b</p>\n}, output
end
test "image with absolute path" do