Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Unified Diff: src/site/_plugins/articles_tag.rb

Issue 10788006: new site (Closed) Base URL: https://code.google.com/p/dartlang-site/@master
Patch Set: final patch Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/site/_layouts/homepage.html ('k') | src/site/_plugins/asset_bundler.rb » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/site/_plugins/articles_tag.rb
diff --git a/src/site/_plugins/articles_tag.rb b/src/site/_plugins/articles_tag.rb
new file mode 100644
index 0000000000000000000000000000000000000000..150a5f5643e8cb0af171ff549a6ef6ae4820878d
--- /dev/null
+++ b/src/site/_plugins/articles_tag.rb
@@ -0,0 +1,40 @@
+require 'yaml'
+
+module Jekyll
+
+ class ArticlesTag < Liquid::Tag
+ def initialize(tag_name, section_name, tokens)
+ super
+ @section_name = section_name.strip
+ end
+
+ def render(context)
+ @data_file = File.join(context.registers[:site].source, 'articles', 'articles.yaml')
+ @articles = YAML.load_file(@data_file)
+
+ section = @articles[@section_name]
+
+ <<-END
+ <section id="#{@section_name}">
+ <h2>#{section['title']}</h2>
+ #{section['articles'].map{|article| render_article(article)}.join("\n")}
+ </section>
+ END
+
+ end
+
+ def render_article(article)
+ <<-END
+ <section class="article">
+ <h4><a href="#{article['url']}">#{article['title']}</a></h4>
+ <div class="author-and-date">#{article['authors'].join(' and ')}, #{article['date']}</div>
+ <p>#{article['desc']}</p>
+ </section>
+ END
+ end
+
+ end
+
+end
+
+Liquid::Template.register_tag('articles', Jekyll::ArticlesTag)
« no previous file with comments | « src/site/_layouts/homepage.html ('k') | src/site/_plugins/asset_bundler.rb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698