Last active
August 29, 2015 14:09
-
-
Save jarib/6e4ad221c7467d375ab3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'yaml' | |
h = Rails.application.routes.url_helpers | |
Issue.published.order(:title).each do |issue| | |
File.open("/hdo/hdo-blog/_issues/#{issue.slug}.md", "w") do |io| | |
io.puts YAML.dump( | |
'layout' => 'issue', | |
'title' => issue.title, | |
'tags' => issue.tag_list.to_a, | |
'slug' => issue.slug, | |
'issue_id' => issue.id, | |
'redirect_from' => h.issue_path(issue) | |
) | |
io.puts "---" | |
io.puts | |
io.puts issue.description | |
io.puts | |
io.puts "TODO: widget løfter" | |
io.puts | |
io.puts "TODO: widget forslag/avstemninger" | |
io.puts | |
io.puts "TODO: widget posisjoner?" | |
io.puts | |
if issue.party_comments.any? | |
io.puts "### Partikommentarer" | |
io.puts | |
issue.party_comments.group_by(&:parliament_period).each do |period, comments| | |
io.puts "#### #{period.name}" | |
io.puts | |
comments.each do |comment| | |
io.puts | |
io.puts comment.body.split("\n").map { |e| "> #{e}" } | |
io.puts "> <cite>#{comment.party.name}</cite>" | |
io.puts | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment