houdini 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.document +11 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +122 -0
  6. data/LICENSE +20 -0
  7. data/README.markdown +59 -0
  8. data/Rakefile +35 -0
  9. data/app/controllers/houdini/postbacks_controller.rb +12 -0
  10. data/config/routes.rb +8 -0
  11. data/houdini.gemspec +25 -0
  12. data/lib/houdini/base.rb +36 -0
  13. data/lib/houdini/engine.rb +4 -0
  14. data/lib/houdini/model.rb +58 -0
  15. data/lib/houdini/task.rb +15 -0
  16. data/lib/houdini/version.rb +3 -0
  17. data/lib/houdini.rb +23 -0
  18. data/spec/controllers/houdini/postbacks_controller_spec.rb +0 -0
  19. data/spec/dummy/Rakefile +7 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  21. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  22. data/spec/dummy/app/models/article.rb +25 -0
  23. data/spec/dummy/app/models/post.rb +24 -0
  24. data/spec/dummy/app/models/product_review.rb +23 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/spec/dummy/app/views/posts/houdini_template.html.erb +6 -0
  27. data/spec/dummy/config/application.rb +51 -0
  28. data/spec/dummy/config/boot.rb +10 -0
  29. data/spec/dummy/config/database.yml +22 -0
  30. data/spec/dummy/config/environment.rb +5 -0
  31. data/spec/dummy/config/environments/development.rb +26 -0
  32. data/spec/dummy/config/environments/production.rb +49 -0
  33. data/spec/dummy/config/environments/test.rb +35 -0
  34. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/spec/dummy/config/initializers/inflections.rb +10 -0
  36. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  37. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  38. data/spec/dummy/config/initializers/session_store.rb +8 -0
  39. data/spec/dummy/config/locales/en.yml +5 -0
  40. data/spec/dummy/config/routes.rb +58 -0
  41. data/spec/dummy/config.ru +4 -0
  42. data/spec/dummy/db/migrate/001_create_posts.rb +16 -0
  43. data/spec/dummy/db/migrate/002_create_product_reviews.rb +15 -0
  44. data/spec/dummy/db/migrate/003_create_articles.rb +15 -0
  45. data/spec/dummy/public/404.html +26 -0
  46. data/spec/dummy/public/422.html +26 -0
  47. data/spec/dummy/public/500.html +26 -0
  48. data/spec/dummy/public/favicon.ico +0 -0
  49. data/spec/dummy/public/javascripts/application.js +2 -0
  50. data/spec/dummy/public/javascripts/controls.js +965 -0
  51. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  52. data/spec/dummy/public/javascripts/effects.js +1123 -0
  53. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  54. data/spec/dummy/public/javascripts/rails.js +175 -0
  55. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  56. data/spec/dummy/script/rails +6 -0
  57. data/spec/houdini_rails_spec.rb +4 -0
  58. data/spec/requests/integration_spec.rb +35 -0
  59. data/spec/spec_helper.rb +34 -0
  60. metadata +227 -0
data/.document ADDED
@@ -0,0 +1,11 @@
1
+ # .document is used by rdoc and yard to know how to generate documentation
2
+ # for example, it can be used to control how rdoc gets built when you do `gem install foo`
3
+
4
+ README.rdoc
5
+ lib/**/*.rb
6
+ bin/*
7
+
8
+ # Files below this - are treated as 'extra files', and aren't parsed for ruby code
9
+ -
10
+ features/**/*.feature
11
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .rvmrc
2
+ .bundle/
3
+ log/*.log
4
+ pkg/
5
+ spec/dummy/db/*.sqlite3
6
+ spec/dummy/log/*.log
7
+ spec/dummy/tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,122 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ houdini (0.1.1)
5
+ rails (~> 3.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.5)
12
+ actionpack (= 3.0.5)
13
+ mail (~> 2.2.15)
14
+ actionpack (3.0.5)
15
+ activemodel (= 3.0.5)
16
+ activesupport (= 3.0.5)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.13)
22
+ rack-test (~> 0.5.7)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.5)
25
+ activesupport (= 3.0.5)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4)
28
+ activerecord (3.0.5)
29
+ activemodel (= 3.0.5)
30
+ activesupport (= 3.0.5)
31
+ arel (~> 2.0.2)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.5)
34
+ activemodel (= 3.0.5)
35
+ activesupport (= 3.0.5)
36
+ activesupport (3.0.5)
37
+ arel (2.0.9)
38
+ builder (2.1.2)
39
+ capybara (0.4.1.2)
40
+ celerity (>= 0.7.9)
41
+ culerity (>= 0.2.4)
42
+ mime-types (>= 1.16)
43
+ nokogiri (>= 1.3.3)
44
+ rack (>= 1.0.0)
45
+ rack-test (>= 0.5.4)
46
+ selenium-webdriver (>= 0.0.27)
47
+ xpath (~> 0.1.3)
48
+ celerity (0.8.8)
49
+ childprocess (0.1.8)
50
+ ffi (~> 1.0.6)
51
+ culerity (0.2.15)
52
+ diff-lcs (1.1.2)
53
+ erubis (2.6.6)
54
+ abstract (>= 1.0.0)
55
+ ffi (1.0.7)
56
+ rake (>= 0.8.7)
57
+ i18n (0.5.0)
58
+ json_pure (1.5.1)
59
+ mail (2.2.15)
60
+ activesupport (>= 2.3.6)
61
+ i18n (>= 0.4.0)
62
+ mime-types (~> 1.16)
63
+ treetop (~> 1.4.8)
64
+ mime-types (1.16)
65
+ nokogiri (1.4.4)
66
+ polyglot (0.3.1)
67
+ rack (1.2.2)
68
+ rack-mount (0.6.14)
69
+ rack (>= 1.0.0)
70
+ rack-test (0.5.7)
71
+ rack (>= 1.0)
72
+ rails (3.0.5)
73
+ actionmailer (= 3.0.5)
74
+ actionpack (= 3.0.5)
75
+ activerecord (= 3.0.5)
76
+ activeresource (= 3.0.5)
77
+ activesupport (= 3.0.5)
78
+ bundler (~> 1.0)
79
+ railties (= 3.0.5)
80
+ railties (3.0.5)
81
+ actionpack (= 3.0.5)
82
+ activesupport (= 3.0.5)
83
+ rake (>= 0.8.7)
84
+ thor (~> 0.14.4)
85
+ rake (0.8.7)
86
+ rspec (2.5.0)
87
+ rspec-core (~> 2.5.0)
88
+ rspec-expectations (~> 2.5.0)
89
+ rspec-mocks (~> 2.5.0)
90
+ rspec-core (2.5.1)
91
+ rspec-expectations (2.5.0)
92
+ diff-lcs (~> 1.1.2)
93
+ rspec-mocks (2.5.0)
94
+ rspec-rails (2.5.0)
95
+ actionpack (~> 3.0)
96
+ activesupport (~> 3.0)
97
+ railties (~> 3.0)
98
+ rspec (~> 2.5.0)
99
+ rubyzip (0.9.4)
100
+ selenium-webdriver (0.1.4)
101
+ childprocess (>= 0.1.7)
102
+ ffi (>= 1.0.7)
103
+ json_pure
104
+ rubyzip
105
+ sqlite3 (1.3.3)
106
+ sqlite3-ruby (1.3.3)
107
+ sqlite3 (>= 1.3.3)
108
+ thor (0.14.6)
109
+ treetop (1.4.9)
110
+ polyglot (>= 0.3.1)
111
+ tzinfo (0.3.25)
112
+ xpath (0.1.3)
113
+ nokogiri (~> 1.3)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ capybara (>= 0.4.1)
120
+ houdini!
121
+ rspec-rails (>= 2.5.0)
122
+ sqlite3-ruby
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Chris Conley
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,59 @@
1
+ # Overview
2
+
3
+ This ruby gem is a Rails Engine for using the Houdini Mechanical Turk API. It provides easy integration into your models and sets up the necessary controllers to receive answers posted back to your app from Houdini.
4
+
5
+ Check out the [Houdini Documentation](http://houdiniapi.com/documentation) for more info about the API.
6
+
7
+ # Installation (Rails 3.0.x)
8
+
9
+ Add the gem to your Gemfile
10
+
11
+ gem 'houdini'
12
+
13
+ Configure a few constants in config/application.rb
14
+
15
+ config.after_initialize do
16
+ Houdini.setup(:sandbox, :api_key => 'YOUR_API_KEY', :app_host => 'https://your-app-domain.com')
17
+ end
18
+
19
+ You may want to configure Houdini differently for each of you environments.
20
+
21
+ # Example Usage
22
+
23
+ Create a task design at https://admin.houdiniapi.com
24
+
25
+ Setup Houdini in your ActiveRecord model:
26
+
27
+ class Post < ActiveRecord::Base
28
+ include Houdini::Model
29
+
30
+ houdini :image_moderation, # short_name of task_design
31
+ :task_info => {
32
+ :image_url => "http://example.com/image12345.jpg"
33
+ },
34
+ :version => 1,
35
+ :after_submit => :update_houdini_attributes,
36
+ :on_task_completion => :process_image_moderation_answer
37
+
38
+ after_create :moderate_image
39
+
40
+ def moderate_image
41
+ Houdini.perform!(:image_moderation, self)
42
+ end
43
+
44
+ def update_houdini_attributes
45
+ update_attribute(:houdini_request_sent_at, Time.now)
46
+ end
47
+
48
+ def process_image_moderation_answer(params)
49
+ update_attribute(:flagged => params[:category] == 'flagged')
50
+ end
51
+ end
52
+
53
+
54
+ Post.houdini class method options:
55
+
56
+ * :task_info - Any task specific info needed to populate your template you created when you created the task design.
57
+ * :version - Version of the task design to use
58
+ * :after_submit - Method that should be called after submitting the task to Houdini.
59
+ * :on_task_completion - Method that should be called when the answer is posted back to your app.
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ Bundler::GemHelper.install_tasks
13
+
14
+ require 'rspec/core'
15
+ require 'rspec/core/rake_task'
16
+ RSpec::Core::RakeTask.new(:spec) do |spec|
17
+ spec.pattern = FileList['spec/**/*_spec.rb']
18
+ end
19
+
20
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
21
+ spec.pattern = 'spec/**/*_spec.rb'
22
+ spec.rcov = true
23
+ end
24
+
25
+ task :default => :spec
26
+
27
+ require 'rake/rdoctask'
28
+ Rake::RDocTask.new do |rdoc|
29
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
30
+
31
+ rdoc.rdoc_dir = 'rdoc'
32
+ rdoc.title = "houdini-rails3 #{version}"
33
+ rdoc.rdoc_files.include('README*')
34
+ rdoc.rdoc_files.include('lib/**/*.rb')
35
+ end
@@ -0,0 +1,12 @@
1
+ class Houdini::PostbacksController < ApplicationController
2
+ protect_from_forgery :except => [:create]
3
+ def create
4
+ object_class = params[:object_class].classify.constantize
5
+ object = object_class.find(params[:object_id])
6
+ if object.process_postback(params[:task_name], HashWithIndifferentAccess.new(ActiveSupport::JSON.decode(request.raw_post)))
7
+ render :json => {:success => true}
8
+ else
9
+ render :json => {:success => false}, :status => 422
10
+ end
11
+ end
12
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ scope "houdini/:object_class/:object_id/:task_name" do
3
+ resources :postbacks,
4
+ :as => 'houdini_postbacks',
5
+ :controller => 'houdini/postbacks',
6
+ :only => [:create]
7
+ end
8
+ end
data/houdini.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "houdini/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = %q{houdini}
6
+ s.version = Houdini::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+
9
+ s.authors = ["Chris Conley"]
10
+ s.email = %q{chris@houdiniapi.com}
11
+ s.summary = %q{Rails 3 Engine for using the Houdini Mechanical Turk API}
12
+ s.description = %q{Rails 3 Engine for using the Houdini Mechanical Turk API}
13
+ s.homepage = %q{http://github.com/chrisconley/houdini-gem}
14
+
15
+ s.add_runtime_dependency "rails", "~> 3.0.0"
16
+ s.add_development_dependency "rspec-rails", ">= 2.5.0"
17
+ s.add_development_dependency "capybara", ">= 0.4.1"
18
+ s.add_development_dependency "sqlite3-ruby"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
25
+
@@ -0,0 +1,36 @@
1
+ module Houdini
2
+ Undefined = Class.new(NameError)
3
+ RequestError = Class.new(NameError)
4
+ AuthenticationError = Class.new(NameError)
5
+ HostError = Class.new(NameError)
6
+
7
+ HOST = 'houdini2-staging.heroku.com'
8
+
9
+ class Base
10
+ def self.request(params)
11
+
12
+ puts "sending #{params.to_json} to houdini"
13
+ validate_config
14
+
15
+ url = File.join("https://", HOST, "tasks")
16
+ uri = URI.parse(url)
17
+ http = Net::HTTP.new(uri.host, uri.port)
18
+ http.use_ssl = true
19
+ response, body = http.post(uri.path, params.to_json)
20
+
21
+ if response.code != "200"
22
+ raise RequestError, "The request to houdini failed with code #{response.code}: #{body}"
23
+ end
24
+
25
+ [response, body]
26
+ end
27
+
28
+ private
29
+
30
+ def self.validate_config
31
+ raise HostError, "Houdini.app_host should not include http://" if Houdini.app_host.match(/http/)
32
+ end
33
+ end
34
+
35
+
36
+ end
@@ -0,0 +1,4 @@
1
+ module Houdini
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,58 @@
1
+ module Houdini
2
+ module Model
3
+ # def self.included(base)
4
+ # base.extend ClassMethods
5
+ # base.include Rails.application.routes.url_helpers
6
+ # end
7
+
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+ include Rails.application.routes.url_helpers
12
+ extend ClassMethods
13
+ end
14
+
15
+ module ClassMethods
16
+ def houdini(name, options)
17
+ houdini_tasks[name.to_sym] = Houdini::Task.new(name.to_sym, options)
18
+ end
19
+
20
+ def houdini_tasks
21
+ @houdini_tasks ||= {}
22
+ end
23
+
24
+ end
25
+
26
+ def send_to_houdini(task_name)
27
+ houdini_task = self.class.houdini_tasks[task_name.to_sym]
28
+ params = {
29
+ :environment => Houdini.environment,
30
+ :api_key => Houdini.api_key,
31
+ :task_design => houdini_task.short_name,
32
+ :task_design_version => houdini_task.version,
33
+ :postback_url => houdini_postbacks_url(self.class.name, self.id, houdini_task.short_name, :host => Houdini.app_host)
34
+ }
35
+
36
+ params[:task_info] = houdini_task.task_info.inject({}) do |hash, (info_name, model_attribute)|
37
+ hash[info_name] = model_attribute
38
+ hash[info_name] = model_attribute.call if model_attribute.respond_to?(:call)
39
+ hash[info_name] = self.send(model_attribute) if self.respond_to?(model_attribute)
40
+ hash
41
+ end
42
+
43
+ result = Houdini::Base.request(params)
44
+
45
+ call_after_submit(task_name)
46
+ end
47
+
48
+ def process_postback(task_name, answer)
49
+ houdini_task = self.class.houdini_tasks[task_name.to_sym]
50
+ self.send(houdini_task.on_task_completion, answer)
51
+ end
52
+
53
+ def call_after_submit(task_name)
54
+ houdini_task = self.class.houdini_tasks[task_name.to_sym]
55
+ self.send(houdini_task.after_submit) if houdini_task.after_submit
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,15 @@
1
+ module Houdini
2
+ class Task
3
+ attr_accessor :short_name, :version, :task_info, :on, :if, :after_submit, :on_task_completion
4
+
5
+ def initialize(short_name, options)
6
+ @short_name = short_name.to_s
7
+ @version = options[:version]
8
+ @task_info = options[:task_info]
9
+ @on = options[:on] || :after_create
10
+ @if = options[:if] || true
11
+ @after_submit = options[:after_submit]
12
+ @on_task_completion = options[:on_task_completion] || :update_attributes
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Houdini
2
+ VERSION = "0.1.1"
3
+ end
data/lib/houdini.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+
4
+ require 'houdini/base'
5
+ require 'houdini/model'
6
+ require 'houdini/task'
7
+
8
+ require 'houdini/engine'
9
+
10
+
11
+ module Houdini
12
+ mattr_accessor :environment, :api_key, :app_host
13
+ # Convenience methods
14
+ def self.perform!(task_name, object)
15
+ object.send_to_houdini(task_name)
16
+ end
17
+
18
+ def self.setup(environment, options)
19
+ self.environment = environment.to_s
20
+ self.api_key = options[:api_key]
21
+ self.app_host = options[:app_host]
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,25 @@
1
+ class Article < ActiveRecord::Base
2
+ include Houdini::Model
3
+
4
+ houdini :edit_for_grammar,
5
+ :version => 1,
6
+ :task_info => {
7
+ 'original_text' => :original_text,
8
+ },
9
+ :after_submit => :update_houdini_attributes,
10
+ :on_task_completion => :process_houdini_edited_text
11
+
12
+ after_create :moderate_image, :if => :original_text
13
+
14
+ def moderate_image
15
+ Houdini.perform!(:edit_for_grammar, self)
16
+ end
17
+
18
+ def update_houdini_attributes
19
+ update_attribute(:houdini_request_sent_at, Time.now)
20
+ end
21
+
22
+ def process_houdini_edited_text(params)
23
+ update_attribute(:edited_text, params[:edited_text])
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ class Post < ActiveRecord::Base
2
+ include Houdini::Model
3
+
4
+ houdini :image_moderation,
5
+ :title => 'Moderate Image',
6
+ :form_template => 'app/views/posts/houdini_template.html.erb',
7
+ :after_submit => :update_houdini_attributes,
8
+ :on_task_completion => :process_image_moderation_answer,
9
+ :price => '0.01'
10
+
11
+ after_create :moderate_image, :if => :image_url
12
+
13
+ def moderate_image
14
+ Houdini.perform!(:image_moderation, self)
15
+ end
16
+
17
+ def update_houdini_attributes
18
+ update_attribute(:houdini_request_sent_at, Time.now)
19
+ end
20
+
21
+ def process_image_moderation_answer(params)
22
+ update_attribute(:flagged, params[:flagged] == 'yes')
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ class ProductReview < ActiveRecord::Base
2
+ include Houdini::Model
3
+
4
+ houdini :text_classification,
5
+ :text => :original_text,
6
+ :api => "classification",
7
+ :after_submit => :update_houdini_attributes,
8
+ :on_task_completion => :process_image_moderation_answer
9
+
10
+ after_create :moderate_image, :if => :original_text
11
+
12
+ def moderate_image
13
+ Houdini.perform!(:text_classification, self)
14
+ end
15
+
16
+ def update_houdini_attributes
17
+ update_attribute(:houdini_request_sent_at, Time.now)
18
+ end
19
+
20
+ def process_image_moderation_answer(params)
21
+ update_attribute(:category, params[:category])
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,6 @@
1
+ <h2>Should this image be flagged?</h2>
2
+
3
+ <img src="<%= post.image_url %>">
4
+
5
+ <input type="radio" name="flagged" value="yes", class="required">Yes</input>
6
+ <input type="radio" name="flagged" value="no", class="required">No</input>
@@ -0,0 +1,51 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+
9
+ Bundler.require
10
+ require "houdini"
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # JavaScript files you want as :defaults (application.js is always included).
37
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
38
+
39
+ # Configure the default encoding used in templates for Ruby 1.9.
40
+ config.encoding = "utf-8"
41
+
42
+ # Configure sensitive parameters which will be filtered from the log file.
43
+ config.filter_parameters += [:password]
44
+
45
+ Houdini.setup(:sandbox,
46
+ :api_key => "wOVK7OFeRJVfmjqBk603",
47
+ :app_host => 'example.com'
48
+ )
49
+
50
+ end
51
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!