Skip to content

Commit

Permalink
Add /stories/qpe action to quickly export the most important stories
Browse files Browse the repository at this point in the history
  • Loading branch information
bloopletech committed Feb 6, 2013
1 parent a7676f5 commit 263b064
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/controllers/stories_controller.rb
Expand Up @@ -108,6 +108,21 @@ def export_done
render :action => 'export_done', :layout => 'secondary'
end

QPE_LENGTH = 150
def qpe
stories = (Story.order("opens DESC").limit(QPE_LENGTH) | Story.order("last_opened_at DESC").limit(QPE_LENGTH) | Story.order("word_count DESC").limit(QPE_LENGTH))
stories.each do |s|
e = s.export("html")
File.open("#{Stories.export_dir}/#{e.filename}", "w") do |f|
f << e.content
f.flush
end
end
flash[:success] = "Stories exported successfully."
redirect_to "/"
end





Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -11,6 +11,7 @@
get :quit
get :export
get :export_done
get :qpe
end
end

Expand Down

0 comments on commit 263b064

Please sign in to comment.