Posted By

pdxmph on 04/21/11


Tagged


Versions (?)

Reclasser


 / Published in: Ruby
 

  1. #!/usr/bin/env ruby
  2.  
  3. require 'rubygems'
  4. require 'sinatra'
  5. require 'active_record'
  6. require 'active_support'
  7. require '/Users/mike/lib/ruby/CDEV'
  8.  
  9.  
  10. ActiveRecord::Base.establish_connection(
  11. :adapter => "sqlite3",
  12. :database => File.dirname(__FILE__) + '/enp_reclass.sqlite3'
  13. )
  14.  
  15. Use Rack::Auth::Basic, "Restricted Area" do |username, password|
  16. [username, password] == ['user', 'password']
  17. end
  18.  
  19.  
  20. class Article < ActiveRecord::Base
  21.  
  22. scope :unclassed_tutorials, :conditions => ["container_directory = ? AND reclass_to IS NULL","Tutorials"]
  23.  
  24. end
  25.  
  26. set :public, File.dirname(__FILE__) + '/pub'
  27.  
  28. layout 'default.rhtml'
  29.  
  30. get '/' do
  31. article = Article.unclassed_tutorials.first
  32. @remaining = Article.unclassed_tutorials.count
  33. @total = Article.count
  34. @first = "/article/#{article.id}"
  35. "Hello world"
  36. erb :home
  37.  
  38. end
  39.  
  40. get '/article/:id' do
  41. @article = Article.find(params[:id])
  42. @remaining = Article.unclassed_tutorials.count
  43. erb :show
  44. end
  45.  
  46. get '/summary/:id' do
  47. @article = Article.find(params[:id])
  48. # @web = CDEV.new(@article.url).summarized
  49. erb :summary
  50. end
  51.  
  52.  
  53. post '/article/:id/update' do
  54. id = params[:id].to_i
  55. @article = Article.find(params[:id])
  56. @article.update_attribute(:reclass_to, params[:reclass_to])
  57. @article.save
  58. @art = Article.unclassed_tutorials.first
  59.  
  60. redirect "/article/#{@art.id}"
  61.  
  62. end
  63.  

Report this snippet  

You need to login to post a comment.