Skip to content

Instantly share code, notes, and snippets.

@jarib
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarib/6e4ad221c7467d375ab3 to your computer and use it in GitHub Desktop.
Save jarib/6e4ad221c7467d375ab3 to your computer and use it in GitHub Desktop.
# -*- 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