Change home_url to a list of links

pull/185/head
Thibaut 10 years ago
parent 4b9256a731
commit cf7f446738

@ -205,15 +205,16 @@
float: right; float: right;
max-width: 15em; max-width: 15em;
margin: .25rem 0 1.5rem 1.5rem; margin: .25rem 0 1.5rem 1.5rem;
padding: .75rem 1rem; padding: .625rem 1rem;
@extend %box; @extend %box;
+ ._lined-heading { margin-top: 0; } + ._lined-heading { margin-top: 0; }
} }
._toc-title { ._toc-title {
margin: 0 0 .75em; margin: 0 0 .5rem;
font-size: inherit; font-size: inherit;
font-weight: bold;
} }
._toc-list { ._toc-list {
@ -222,6 +223,8 @@
list-style: none; list-style: none;
} }
._toc-link { @extend %internal-link; }
// //
// Static page // Static page
// //

@ -22,23 +22,6 @@
} }
} }
//
// Official Website box
//
._official {
clear: both;
margin: 2rem 0 1.5rem;
font-size: .75rem;
color: $textColorLight;
text-align: center;
-webkit-font-smoothing: subpixel-antialiased;
& + & { margin-top: 1.5rem; }
}
._official-link { @extend %external-link; }
// //
// Attribution box // Attribution box
// //

@ -4,7 +4,7 @@ module Docs
DB_FILENAME = 'db.json' DB_FILENAME = 'db.json'
class << self class << self
attr_accessor :name, :slug, :type, :version, :abstract, :home_url attr_accessor :name, :slug, :type, :version, :abstract, :links
def inherited(subclass) def inherited(subclass)
subclass.type = type subclass.type = type

@ -20,8 +20,8 @@ module Docs
context[:base_url] context[:base_url]
end end
def home_url def links
context[:home_url] context[:links]
end end
def current_url def current_url

@ -34,7 +34,7 @@ module Docs
self.text_filters = FilterStack.new self.text_filters = FilterStack.new
html_filters.push 'container', 'clean_html', 'normalize_urls', 'internal_urls', 'normalize_paths' html_filters.push 'container', 'clean_html', 'normalize_urls', 'internal_urls', 'normalize_paths'
text_filters.push 'inner_html', 'clean_text', 'home_url', 'attribution' text_filters.push 'inner_html', 'clean_text', 'links', 'attribution'
def build_page(path) def build_page(path)
response = request_one url_for(path) response = request_one url_for(path)
@ -65,8 +65,8 @@ module Docs
@root_url ||= root_path? ? URL.parse(File.join(base_url.to_s, root_path)) : base_url.normalize @root_url ||= root_path? ? URL.parse(File.join(base_url.to_s, root_path)) : base_url.normalize
end end
def home_url def links
@home_url ||= self.class.home_url self.class.links
end end
def root_path def root_path
@ -93,7 +93,7 @@ module Docs
def options def options
@options ||= self.class.options.deep_dup.tap do |options| @options ||= self.class.options.deep_dup.tap do |options|
options.merge! base_url: base_url, root_url: root_url, home_url: home_url, options.merge! base_url: base_url, root_url: root_url, links: links,
root_path: root_path, initial_paths: initial_paths root_path: root_path, initial_paths: initial_paths
if root_path? if root_path?

@ -1,16 +0,0 @@
module Docs
class HomeUrlFilter < Filter
def call
html.prepend(home_url_html) if home_url
html
end
def home_url_html
<<-HTML.strip_heredoc
<div class="_official">
Official Documentation: <a href="#{home_url}" class="_official-link">#{home_url}</a>
</div>
HTML
end
end
end

@ -0,0 +1,26 @@
module Docs
class LinksFilter < Filter
def call
html.prepend(links_html) if links
html
end
NAMES = {
home: 'Homepage',
code: 'Source code'
}
def links_html
links = self.links.map do |name, link|
%(<li><a href="#{link}" class="_toc-link">#{NAMES[name]}</a></li>)
end
<<-HTML.strip_heredoc
<div class="_toc">
<div class="_toc-title">Resources</div>
<ul class="_toc-list">#{links.join}</ul>
</div>
HTML
end
end
end

@ -60,19 +60,13 @@ class DocsDocTest < MiniTest::Spec
end end
end end
describe ".home_url" do describe ".links=" do
it "returns nil" do it "stores .links" do
assert_nil doc.home_url doc.links = { test: true }
assert_equal({ test: true }, doc.links)
end end
end end
describe ".home_url=" do
it "stores .home_url" do
doc.home_url = 'http://www.url.com/doc'
assert_equal 'http://www.url.com/doc', doc.home_url
end
end
describe ".abstract" do describe ".abstract" do
it "returns nil" do it "returns nil" do
assert_nil doc.abstract assert_nil doc.abstract

Loading…
Cancel
Save