浏览代码

Renamed official_url to home_url

Thu Trang Pham 10 年之前
父节点
当前提交
610e49119f
共有 3 个文件被更改,包括 17 次插入16 次删除
  1. 1 1
      lib/docs/core/scraper.rb
  2. 16 0
      lib/docs/filters/core/home_url.rb
  3. 0 15
      lib/docs/filters/core/official_url.rb

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

+ 16 - 0
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
+      <div class="_official">
+        Official Documentation: <a href="#{home_url}" class="_official-link">#{home_url}</a>
+      </div>
+      HTML
+    end
+  end
+end

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

@@ -1,15 +0,0 @@
-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