Implement Page#footer and display footer in frontend.
This commit is contained in:
@@ -339,6 +339,11 @@ html {overflow-y: scroll;}
|
||||
|
||||
/* Special markup considerations */
|
||||
|
||||
.wikistyle.gollum.footer {
|
||||
border-top: 4px solid #f0f0f0;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.wikistyle.gollum > h1:first-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,14 @@
|
||||
<a href="/">Home</a> | <a href="/edit/{{name}}">Edit</a>
|
||||
</div>
|
||||
<h1>{{human_name}}</h1>
|
||||
<div class="wikistyle gollum {{format}}">
|
||||
<div class="content wikistyle gollum {{format}}">
|
||||
{{{content}}}
|
||||
</div>
|
||||
{{#has_footer}}
|
||||
<div class="footer wikistyle gollum {{footer_format}}">
|
||||
{{{footer_content}}}
|
||||
</div>
|
||||
{{/has_footer}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module Precious
|
||||
module Views
|
||||
class Page < Layout
|
||||
attr_reader :content, :page
|
||||
attr_reader :content, :page, :footer
|
||||
|
||||
def human_name
|
||||
@page.title
|
||||
@@ -23,6 +23,21 @@ module Precious
|
||||
@page.version.authored_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
end
|
||||
|
||||
def has_footer
|
||||
@footer ||= @page.footer
|
||||
!@footer.nil?
|
||||
end
|
||||
|
||||
def footer_content
|
||||
@footer ||= @page.footer
|
||||
@footer.formatted_data
|
||||
end
|
||||
|
||||
def footer_format
|
||||
@footer ||= @page.footer
|
||||
@footer.format.to_s
|
||||
end
|
||||
|
||||
def versions
|
||||
i = @page.versions.size + 1
|
||||
@page.versions.map do |v|
|
||||
|
||||
@@ -148,6 +148,28 @@ module Gollum
|
||||
@wiki.repo.log('master', @path, log_pagination_options(options))
|
||||
end
|
||||
|
||||
# Public: The footer Page.
|
||||
#
|
||||
# Returns the footer Page or nil if none exists.
|
||||
def footer
|
||||
dirs = self.path.split('/')
|
||||
dirs.pop
|
||||
while !dirs.empty?
|
||||
tree = self.version.tree / dirs.join('/')
|
||||
if page = find_page_in_this_tree(tree, dirs.join('/'), '_Footer')
|
||||
return page
|
||||
end
|
||||
dirs.pop
|
||||
end
|
||||
|
||||
tree = self.version.tree
|
||||
if page = find_page_in_this_tree(tree, '', '_Footer')
|
||||
return page
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
# Class Methods
|
||||
@@ -245,6 +267,28 @@ module Gollum
|
||||
return nil # nothing was found
|
||||
end
|
||||
|
||||
# Find a page in a given tree without recursing into subtrees.
|
||||
#
|
||||
# tree - The Grit::Tree in which to look.
|
||||
# dir - The String path of the given Grit::Tree.
|
||||
# name - The canonical String page name.
|
||||
#
|
||||
# Returns a Gollum::Page or nil if the page could not be found.
|
||||
def find_page_in_this_tree(tree, dir, name)
|
||||
treemap = {}
|
||||
tree.contents.each do |item|
|
||||
case item
|
||||
when Grit::Blob
|
||||
if page_match(name, item.name)
|
||||
path = dir == '' ? '' : ::File.join('/', dir)
|
||||
return populate(item, path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil # nothing was found
|
||||
end
|
||||
|
||||
# Populate the Page with information from the Blob.
|
||||
#
|
||||
# blob - The Grit::Blob that contains the info.
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
x�ŽAj1E³ö)t� ’ÆÛBs€@…®=#
|
||||
MÀ£â¸÷¯Ï�íã¿ÏÛ¬ÖGžó©7UÀ…fò =Q$Ü2—Ä»²�Æ%ϼEÜue
|
||||
î·4=:dx–XÔ§¢k 1`Î"Ä™Ï(iôÄ•¿þc
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
94523d7ae48aeba575099dd12926420d8fd0425d
|
||||
0ed8cbe0a25235bd867e65193c7d837c66b328ef
|
||||
|
||||
@@ -80,4 +80,16 @@ context "Page" do
|
||||
page = @wiki.page('Eye Of Sauron')
|
||||
assert_equal "Eye Of Sauron", page.title
|
||||
end
|
||||
|
||||
test "top level footer" do
|
||||
footer = @wiki.page('Home').footer
|
||||
assert_equal 'Lord of the Rings wiki', footer.raw_data
|
||||
assert_equal '_Footer.md', footer.path
|
||||
end
|
||||
|
||||
test "nested footer" do
|
||||
footer = @wiki.page('Eye Of Sauron').footer
|
||||
assert_equal "Ones does not simply **walk** into Mordor!\n", footer.raw_data
|
||||
assert_equal "Mordor/_Footer.md", footer.path
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user