aboutsummaryrefslogblamecommitdiffstats
path: root/script/year-review.rb
blob: 566c4891bdbbd9a5ac21d0cfbd765d98ca2f5721 (plain) (tree)
1
2
3
4
                   

                                                                            
 












                                                                          















                                                                                                                    
#!/usr/bin/env ruby
# This file is part of hmnoweb, a RefineryCMS based Webapp for heavymetal.no
# Copyright (C) 2018  Harald Eilertsen <haraldei@anduin.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License version 3
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.


# Run with reils runner like this:
#
#     RAILS_ENV=production rails runner script/year-review.rb
#
# Thie ensures it runs in the context of the application.

def normalize(t)
  t.gsub("'", '"')
end

cat = Refinery::Blog::Category.where(:title => "Omtaler").first
start_date = Date.new(Date.today.year, 01, 01)
posts = cat.posts.where("published_at > :date", { :date => start_date })
posts.each do |p|
  puts "'#{normalize(p.title)}', #{p.published_at}, #{p.author.username}, http://heavymetal.no/blog/posts/#{p.slug}"
end