diff --git a/assets/stylesheets/components/_page.scss b/assets/stylesheets/components/_page.scss index 30935d85..d9d96e46 100644 --- a/assets/stylesheets/components/_page.scss +++ b/assets/stylesheets/components/_page.scss @@ -22,6 +22,23 @@ } } +// +// 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 // diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index 6388c568..6ea7ed01 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -4,7 +4,7 @@ module Docs DB_FILENAME = 'db.json' class << self - attr_accessor :name, :slug, :type, :version, :abstract + attr_accessor :name, :slug, :type, :version, :abstract, :home_url def inherited(subclass) subclass.type = type diff --git a/lib/docs/core/filter.rb b/lib/docs/core/filter.rb index de176544..21c88d0a 100644 --- a/lib/docs/core/filter.rb +++ b/lib/docs/core/filter.rb @@ -20,6 +20,10 @@ module Docs context[:base_url] end + def home_url + context[:home_url] + end + def current_url context[:url] end diff --git a/lib/docs/core/scraper.rb b/lib/docs/core/scraper.rb index 634ee857..d6d45b7c 100644 --- a/lib/docs/core/scraper.rb +++ b/lib/docs/core/scraper.rb @@ -34,7 +34,7 @@ module Docs self.text_filters = FilterStack.new html_filters.push 'container', 'clean_html', 'normalize_urls', 'internal_urls', 'normalize_paths' - text_filters.push 'inner_html', 'clean_text', 'attribution' + text_filters.push 'inner_html', 'clean_text', 'home_url', 'attribution' def build_page(path) response = request_one url_for(path) @@ -65,6 +65,10 @@ module Docs @root_url ||= root_path? ? URL.parse(File.join(base_url.to_s, root_path)) : base_url.normalize end + def home_url + @home_url ||= self.class.home_url + end + def root_path self.class.root_path end @@ -89,7 +93,7 @@ module Docs def options @options ||= self.class.options.deep_dup.tap do |options| - options.merge! base_url: base_url, root_url: root_url, + options.merge! base_url: base_url, root_url: root_url, home_url: home_url, root_path: root_path, initial_paths: initial_paths if root_path? diff --git a/lib/docs/filters/core/home_url.rb b/lib/docs/filters/core/home_url.rb new file mode 100644 index 00000000..0892f3fd --- /dev/null +++ b/lib/docs/filters/core/home_url.rb @@ -0,0 +1,16 @@ +module Docs + class HomeUrlFilter < Filter + def call + html.prepend(home_url_html) if home_url + html + end + + def home_url_html + <<-HTML.strip_heredoc +
+ Official Documentation: #{home_url} +
+ HTML + end + end +end diff --git a/test/lib/docs/core/doc_test.rb b/test/lib/docs/core/doc_test.rb index dfad3731..d3d783d3 100644 --- a/test/lib/docs/core/doc_test.rb +++ b/test/lib/docs/core/doc_test.rb @@ -60,6 +60,19 @@ class DocsDocTest < MiniTest::Spec end end + describe ".home_url" do + it "returns nil" do + assert_nil doc.home_url + 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 it "returns nil" do assert_nil doc.abstract