flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmetz...@apache.org
Subject git commit: add gh_link jekyll plugin to docs
Date Tue, 01 Jul 2014 11:48:16 GMT
Repository: incubator-flink
Updated Branches:
  refs/heads/master 504228011 -> cebb1f635


add gh_link jekyll plugin to docs


Project: http://git-wip-us.apache.org/repos/asf/incubator-flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-flink/commit/cebb1f63
Tree: http://git-wip-us.apache.org/repos/asf/incubator-flink/tree/cebb1f63
Diff: http://git-wip-us.apache.org/repos/asf/incubator-flink/diff/cebb1f63

Branch: refs/heads/master
Commit: cebb1f63508cc2adbd9fa69e25245e8ff0e8cd44
Parents: 5042280
Author: Robert Metzger <rmetzger@apache.org>
Authored: Tue Jul 1 13:46:38 2014 +0200
Committer: Robert Metzger <rmetzger@apache.org>
Committed: Tue Jul 1 13:46:38 2014 +0200

----------------------------------------------------------------------
 docs/_plugins/gh_link.rb | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-flink/blob/cebb1f63/docs/_plugins/gh_link.rb
----------------------------------------------------------------------
diff --git a/docs/_plugins/gh_link.rb b/docs/_plugins/gh_link.rb
new file mode 100644
index 0000000..b7dda3e
--- /dev/null
+++ b/docs/_plugins/gh_link.rb
@@ -0,0 +1,29 @@
+module Jekyll
+  class GitHubLinkTag < Liquid::Tag
+
+    def initialize(tag_name, input, tokens)
+      super
+      @input = input
+    end
+
+    def render(context)
+      input = @input.split
+      config = context.registers[:site].config
+
+      path = input[0]
+      file = path.split('/').last
+
+      page_gh_tag = context["page"]["gh_link_tag"]
+      # tag precendence:
+      # 1. input[1],
+      # 2. 'gh_link_tag' of page frontmatter
+      # 3. "master" (default)
+      gh_tag = input[1].nil? ? (page_gh_tag.nil? ? "master" : page_gh_tag) : input[1]
+      
+
+      "<a href=#{config["FLINK_GITHUB_URL"]}/blob/#{gh_tag}/#{path}>#{file}</a>"
+    end
+  end
+end
+
+Liquid::Template.register_tag('gh_link', Jekyll::GitHubLinkTag)
\ No newline at end of file


Mime
View raw message