Distinguish between present and absent page links.
This commit is contained in:
@@ -40,7 +40,11 @@ p {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
/***********************/
|
||||
a.absent {
|
||||
color: #a00;
|
||||
}
|
||||
|
||||
/* Images */
|
||||
|
||||
.frame {
|
||||
margin: 1em 0;
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user