Browse Source

Adding Official Url for url scrapped documentations

Thu Trang Pham 10 years ago
parent
commit
0dc8cfd5d3

+ 18 - 0
assets/stylesheets/components/_page.scss

@@ -22,6 +22,24 @@
   }
 }
 
+//
+// 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; }
+  & + & > ._attribution-link { display: none; }
+}
+
+._official-link { @extend %external-link; }
+
 //
 // Attribution box
 //

+ 1 - 1
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 'official_url', 'inner_html', 'clean_text', 'attribution'
 
     def build_page(path)
       response = request_one url_for(path)

+ 15 - 0
lib/docs/filters/core/official_url.rb

@@ -0,0 +1,15 @@
+module Docs
+  class OfficialUrlFilter < Filter
+    def call
+      official_url_html << html if base_url
+    end
+
+    def official_url_html
+      <<-HTML.strip_heredoc
+      <div class="_official">
+        Official Documentation: <a href="#{base_url}" class="_official-link">#{base_url}</a>
+      </div>
+      HTML
+    end
+  end
+end