open_porch 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. data/Gemfile +41 -0
  2. data/Gemfile.lock +130 -0
  3. data/README.md +170 -0
  4. data/Rakefile +19 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/admin/areas/base_controller.rb +11 -0
  7. data/app/controllers/admin/areas/issues_controller.rb +67 -0
  8. data/app/controllers/admin/areas/memberships_controller.rb +7 -0
  9. data/app/controllers/admin/areas/posts_controller.rb +44 -0
  10. data/app/controllers/admin/areas_controller.rb +89 -0
  11. data/app/controllers/admin/base_controller.rb +16 -0
  12. data/app/controllers/admin/user_activity_controller.rb +29 -0
  13. data/app/controllers/admin/users_controller.rb +57 -0
  14. data/app/controllers/application_controller.rb +15 -0
  15. data/app/controllers/areas/base_controller.rb +25 -0
  16. data/app/controllers/areas/issues_controller.rb +35 -0
  17. data/app/controllers/areas/posts_controller.rb +28 -0
  18. data/app/controllers/areas_controller.rb +30 -0
  19. data/app/controllers/passwords_controller.rb +42 -0
  20. data/app/controllers/registrations_controller.rb +42 -0
  21. data/app/controllers/sessions_controller.rb +33 -0
  22. data/app/controllers/users_controller.rb +77 -0
  23. data/app/helpers/open_porch_helper.rb +24 -0
  24. data/app/mailers/user_mailer.rb +35 -0
  25. data/app/models/address.rb +57 -0
  26. data/app/models/area.rb +171 -0
  27. data/app/models/area_activity.rb +24 -0
  28. data/app/models/email_message.rb +104 -0
  29. data/app/models/issue.rb +66 -0
  30. data/app/models/issue_number.rb +22 -0
  31. data/app/models/membership.rb +27 -0
  32. data/app/models/post.rb +64 -0
  33. data/app/models/session_user.rb +69 -0
  34. data/app/models/user.rb +140 -0
  35. data/app/models/user_activity.rb +31 -0
  36. data/app/models/user_authority_check.rb +14 -0
  37. data/app/views/admin/areas/_form.html.haml +8 -0
  38. data/app/views/admin/areas/_nav.html.haml +12 -0
  39. data/app/views/admin/areas/edit.html.haml +22 -0
  40. data/app/views/admin/areas/edit_borders.html.haml +44 -0
  41. data/app/views/admin/areas/index.html.haml +61 -0
  42. data/app/views/admin/areas/issues/_post.html.haml +15 -0
  43. data/app/views/admin/areas/issues/add_posts.js.rjs +3 -0
  44. data/app/views/admin/areas/issues/edit.html.haml +37 -0
  45. data/app/views/admin/areas/issues/index.html.haml +31 -0
  46. data/app/views/admin/areas/issues/remove_posts.js.rjs +3 -0
  47. data/app/views/admin/areas/issues/show.html.haml +13 -0
  48. data/app/views/admin/areas/memberships/index.html.haml +17 -0
  49. data/app/views/admin/areas/new.html.haml +6 -0
  50. data/app/views/admin/areas/new.js.haml +4 -0
  51. data/app/views/admin/areas/posts/_edit.html.haml +6 -0
  52. data/app/views/admin/areas/posts/_post_status.html.haml +1 -0
  53. data/app/views/admin/areas/posts/destroy.js.rjs +1 -0
  54. data/app/views/admin/areas/posts/edit.js.rjs +1 -0
  55. data/app/views/admin/areas/posts/show.js.rjs +1 -0
  56. data/app/views/admin/areas/posts/toggle_reviewed_by.js.rjs +1 -0
  57. data/app/views/admin/areas/posts/update.js.rjs +5 -0
  58. data/app/views/admin/areas/show.html.haml +5 -0
  59. data/app/views/admin/user_activity/show.html.haml +5 -0
  60. data/app/views/admin/users/_form.html.haml +21 -0
  61. data/app/views/admin/users/edit.html.haml +5 -0
  62. data/app/views/admin/users/index.html.haml +31 -0
  63. data/app/views/admin/users/new.html.haml +5 -0
  64. data/app/views/areas/issues/index.html.haml +31 -0
  65. data/app/views/areas/issues/show.html.haml +22 -0
  66. data/app/views/areas/posts/_post.html.haml +8 -0
  67. data/app/views/areas/posts/_posts_search_form.html.haml +8 -0
  68. data/app/views/areas/posts/index.html.haml +27 -0
  69. data/app/views/areas/posts/new.html.haml +10 -0
  70. data/app/views/areas/show.html.haml +47 -0
  71. data/app/views/layouts/_account_nav.html.haml +18 -0
  72. data/app/views/layouts/_flash_message.html.haml +4 -0
  73. data/app/views/layouts/_footer.html.haml +9 -0
  74. data/app/views/layouts/_head.html.haml +16 -0
  75. data/app/views/layouts/admin/_nav.html.haml +13 -0
  76. data/app/views/layouts/admin.html.haml +15 -0
  77. data/app/views/layouts/application.html.haml +14 -0
  78. data/app/views/layouts/area_editor.html.haml +11 -0
  79. data/app/views/passwords/edit.html.haml +9 -0
  80. data/app/views/passwords/new.html.haml +13 -0
  81. data/app/views/registrations/_address_form.html.haml +7 -0
  82. data/app/views/registrations/create.html.haml +49 -0
  83. data/app/views/registrations/index.html.haml +30 -0
  84. data/app/views/registrations/new.html.haml +17 -0
  85. data/app/views/sessions/new.html.haml +18 -0
  86. data/app/views/stylesheets/common.sass +239 -0
  87. data/app/views/stylesheets/content.sass +193 -0
  88. data/app/views/stylesheets/reset.sass +46 -0
  89. data/app/views/stylesheets/structure.sass +11 -0
  90. data/app/views/stylesheets/typography.sass +57 -0
  91. data/app/views/user_mailer/email_verification.html.erb +5 -0
  92. data/app/views/user_mailer/email_verification.text.erb +7 -0
  93. data/app/views/user_mailer/new_issue.html.erb +32 -0
  94. data/app/views/user_mailer/new_issue.text.erb +26 -0
  95. data/app/views/user_mailer/password_reset.html.erb +7 -0
  96. data/app/views/user_mailer/password_reset.text.erb +6 -0
  97. data/app/views/users/_form.html.haml +5 -0
  98. data/app/views/users/edit.html.haml +11 -0
  99. data/app/views/users/new.html.haml +41 -0
  100. data/app/views/users/show.html.haml +30 -0
  101. data/bin/open_porch_engine +135 -0
  102. data/config/application.rb +43 -0
  103. data/config/boot.rb +13 -0
  104. data/config/database_example.yml +59 -0
  105. data/config/environment.rb +5 -0
  106. data/config/environments/development.rb +26 -0
  107. data/config/environments/production.rb +49 -0
  108. data/config/environments/test.rb +35 -0
  109. data/config/initializers/backtrace_silencers.rb +7 -0
  110. data/config/initializers/email_regex.rb +38 -0
  111. data/config/initializers/geokit_config.rb +61 -0
  112. data/config/initializers/inflections.rb +20 -0
  113. data/config/initializers/meta_search.rb +7 -0
  114. data/config/initializers/mime_types.rb +5 -0
  115. data/config/initializers/open_porch.rb +41 -0
  116. data/config/initializers/sass.rb +1 -0
  117. data/config/initializers/secret_token.rb +7 -0
  118. data/config/initializers/session_store.rb +8 -0
  119. data/config/initializers/states_provinces.rb +2 -0
  120. data/config/initializers/will_paginate.rb +2 -0
  121. data/config/locales/en.yml +5 -0
  122. data/config/open_porch_example.yml +23 -0
  123. data/config/routes.rb +54 -0
  124. data/config/schedule.rb +9 -0
  125. data/config.ru +4 -0
  126. data/db/migrate/01_create_areas.rb +21 -0
  127. data/db/migrate/02_create_users.rb +28 -0
  128. data/db/migrate/03_create_memberships.rb +14 -0
  129. data/db/migrate/04_create_posts.rb +20 -0
  130. data/db/migrate/05_create_issue_numbers.rb +13 -0
  131. data/db/migrate/06_create_issues.rb +21 -0
  132. data/db/migrate/20110204173301_add_published_to_areas.rb +10 -0
  133. data/db/migrate/20110204194840_create_user_activities.rb +13 -0
  134. data/db/migrate/20110208163604_add_zip_to_areas.rb +11 -0
  135. data/db/migrate/20110209175723_add_counters_to_areas.rb +11 -0
  136. data/db/migrate/20110209182244_remove_subject_from_issues.rb +9 -0
  137. data/db/migrate/20110209190146_add_reviewer_info_to_posts.rb +9 -0
  138. data/db/migrate/20110215173144_add_email_validation_key_to_users.rb +13 -0
  139. data/db/migrate/20110215182716_remove_published_from_areas.rb +10 -0
  140. data/db/migrate/20110215211012_create_area_activities.rb +19 -0
  141. data/db/migrate/20110215213802_create_email_messages.rb +19 -0
  142. data/db/migrate/20110217165018_change_send_mode_to_string.rb +17 -0
  143. data/db/migrate/20110223160609_denormalize_user_info_in_posts.rb +19 -0
  144. data/db/seeds.rb +7 -0
  145. data/doc/README_FOR_APP +2 -0
  146. data/lib/generators/open_porch_generator.rb +37 -0
  147. data/lib/open_porch/engine.rb +20 -0
  148. data/lib/open_porch.rb +3 -0
  149. data/lib/tasks/.gitkeep +0 -0
  150. data/lib/tasks/open_porch.rake +10 -0
  151. data/lib/tasks/postageapp_tasks.rake +78 -0
  152. data/open_porch.gemspec +335 -0
  153. data/public/404.html +26 -0
  154. data/public/422.html +26 -0
  155. data/public/500.html +26 -0
  156. data/public/favicon.ico +0 -0
  157. data/public/images/icons/ajax-loader.gif +0 -0
  158. data/public/images/icons/calendar.png +0 -0
  159. data/public/images/icons/post_new.png +0 -0
  160. data/public/images/icons/post_reviewed.png +0 -0
  161. data/public/javascripts/application.js +3 -0
  162. data/public/javascripts/google_maps.js +153 -0
  163. data/public/javascripts/highcharts.js +162 -0
  164. data/public/javascripts/highcharts_init.js +30 -0
  165. data/public/javascripts/issue_edit.js +57 -0
  166. data/public/javascripts/jquery-ui.min.js +191 -0
  167. data/public/javascripts/jquery.js +154 -0
  168. data/public/javascripts/rails.js +137 -0
  169. data/public/javascripts/region_editor.js +616 -0
  170. data/public/javascripts/user_activity.js +29 -0
  171. data/public/robots.txt +5 -0
  172. data/public/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  173. data/public/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  174. data/public/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  175. data/public/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  176. data/public/stylesheets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  177. data/public/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  178. data/public/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  179. data/public/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  180. data/public/stylesheets/images/ui-icons_222222_256x240.png +0 -0
  181. data/public/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
  182. data/public/stylesheets/images/ui-icons_454545_256x240.png +0 -0
  183. data/public/stylesheets/images/ui-icons_888888_256x240.png +0 -0
  184. data/public/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
  185. data/public/stylesheets/jquery-ui.css +362 -0
  186. data/script/rails +6 -0
  187. data/test/dummy/area.rb +5 -0
  188. data/test/dummy/area_activity.rb +7 -0
  189. data/test/dummy/issue.rb +4 -0
  190. data/test/dummy/membership.rb +4 -0
  191. data/test/dummy/post.rb +12 -0
  192. data/test/dummy/user.rb +29 -0
  193. data/test/dummy/user_activity.rb +11 -0
  194. data/test/functional/admin/areas/issues_controller_test.rb +48 -0
  195. data/test/functional/admin/areas/memberships_controller_test.rb +45 -0
  196. data/test/functional/admin/areas/posts_controller_test.rb +54 -0
  197. data/test/functional/admin/areas_controller_test.rb +134 -0
  198. data/test/functional/admin/base_controller_test.rb +8 -0
  199. data/test/functional/admin/user_activity_controller_test.rb +28 -0
  200. data/test/functional/admin/users_controller_test.rb +144 -0
  201. data/test/functional/areas/issues_controller_test.rb +33 -0
  202. data/test/functional/areas/posts_controller_test.rb +50 -0
  203. data/test/functional/areas_controller_test.rb +12 -0
  204. data/test/functional/passwords_controller_test.rb +64 -0
  205. data/test/functional/registrations_controller_test.rb +64 -0
  206. data/test/functional/sessions_controller_test.rb +120 -0
  207. data/test/functional/users_controller_test.rb +144 -0
  208. data/test/performance/browsing_test.rb +9 -0
  209. data/test/test_helper.rb +92 -0
  210. data/test/unit/address_test.rb +25 -0
  211. data/test/unit/area_activity_test.rb +57 -0
  212. data/test/unit/area_test.rb +92 -0
  213. data/test/unit/email_message_test.rb +8 -0
  214. data/test/unit/issue_number_test.rb +25 -0
  215. data/test/unit/issue_test.rb +154 -0
  216. data/test/unit/membership_test.rb +20 -0
  217. data/test/unit/post_test.rb +69 -0
  218. data/test/unit/session_user_test.rb +65 -0
  219. data/test/unit/user_activity_test.rb +31 -0
  220. data/test/unit/user_mailer_test.rb +20 -0
  221. data/test/unit/user_test.rb +61 -0
  222. data/vendor/plugins/.gitkeep +0 -0
  223. metadata +456 -0
@@ -0,0 +1,23 @@
1
+ # Configure the mail server used to collect emails using POP3
2
+ pop3:
3
+ development:
4
+ host: pop.example.com
5
+ mailto: example.com
6
+ port: 995
7
+ username:
8
+ password:
9
+ enable_ssl: true
10
+
11
+ # OpenX zones
12
+ openx_zones:
13
+ development:
14
+ current_issue: ZONE_ID
15
+ newsletter: ZONE_ID
16
+
17
+ # PostageApp configuration
18
+ postageapp:
19
+ development:
20
+ api_key: YOUR_API_KEY
21
+ # other options here
22
+
23
+
data/config/routes.rb ADDED
@@ -0,0 +1,54 @@
1
+ Rails.application.routes.draw do
2
+
3
+ resources :passwords, :only => [:new, :create, :edit, :update]
4
+ post '/login' => 'sessions#create'
5
+ get '/login' => 'sessions#new'
6
+ get '/logout' => 'sessions#destroy'
7
+
8
+ resources :registrations
9
+ resource :user
10
+ get '/verify-email/:email_verification_key' => 'users#verify_email', :as => :verify_email
11
+ get '/resend-email-verification/:email_verification_key' => 'users#resend_email_verification', :as => :resend_email_verification
12
+
13
+ resources :areas, :only => :show do
14
+ get '/current-issue' => 'areas/issues#current', :as => :current_issue
15
+ resources :issues, :controller => 'areas/issues', :only => [:index, :show] do
16
+ collection do
17
+ get '/:year/:month', :action => :index, :as => :archive
18
+ end
19
+ end
20
+ resources :posts, :controller => 'areas/posts', :only => [:index, :new, :create]
21
+ end
22
+
23
+ namespace :admin do
24
+ get '/' => redirect('/admin/areas')
25
+ resources :areas do
26
+ resources :issues, :controller => 'areas/issues' do
27
+ member do
28
+ post :add_posts
29
+ post :remove_posts
30
+ end
31
+ end
32
+ resources :posts, :controller => 'areas/posts' do
33
+ member do
34
+ post :toggle_reviewed_by
35
+ end
36
+ collection do
37
+ put :order, :as => :order
38
+ end
39
+ end
40
+ member do
41
+ get :edit_borders
42
+ end
43
+ collection do
44
+ post :bulk_update
45
+ end
46
+ resources :memberships, :controller => 'areas/memberships'
47
+ end
48
+ resources :users
49
+ resources :user_activity
50
+ end
51
+
52
+ root :to => 'registrations#index'
53
+
54
+ end
@@ -0,0 +1,9 @@
1
+ set :output, "log/cron.log"
2
+ job_type :exec, "cd :path && RAILS_ENV=:environment :task :output"
3
+
4
+ every 5.minutes do
5
+ exec "open_porch_engine"
6
+ end
7
+
8
+ # Add the following line at the beginning of the deploy script
9
+ # require "whenever/capistrano"
data/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run OpenPorch::Application
@@ -0,0 +1,21 @@
1
+ class CreateAreas < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :areas do |t|
4
+ t.string :name
5
+ t.text :description
6
+ t.string :city
7
+ t.string :state
8
+ t.string :slug
9
+ t.integer :last_issue_number
10
+ t.integer :households
11
+ t.integer :send_mode, :default => 0
12
+ t.column :border, :polygon, :geographic => true, :srid => 4326
13
+ t.timestamps
14
+ end
15
+ add_index :areas, :border, :spatial => true
16
+ end
17
+
18
+ def self.down
19
+ drop_table :areas
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :email
5
+ t.string :password_hash, :limit => 40
6
+ t.string :password_salt, :limit => 40
7
+ t.string :perishable_token
8
+ t.string :remember_token
9
+ t.string :role
10
+ t.string :first_name
11
+ t.string :last_name
12
+ t.string :address
13
+ t.string :city
14
+ t.string :state
15
+ t.string :zip
16
+ t.string :lat
17
+ t.string :lng
18
+ t.timestamps
19
+ end
20
+ add_index :users, :email
21
+ add_index :users, :perishable_token
22
+ add_index :users, :remember_token
23
+ end
24
+
25
+ def self.down
26
+ drop_table :users
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ class CreateMemberships < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :memberships do |t|
4
+ t.integer :user_id
5
+ t.integer :area_id
6
+ t.timestamps
7
+ end
8
+ add_index :memberships, [:user_id, :area_id]
9
+ end
10
+
11
+ def self.down
12
+ drop_table :memberships
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :posts do |t|
4
+ t.integer :area_id
5
+ t.integer :user_id
6
+ t.integer :issue_id
7
+ t.integer :parent_id
8
+ t.string :title
9
+ t.text :content
10
+ t.integer :position
11
+ t.timestamps
12
+ end
13
+ add_index :posts, [:area_id, :created_at]
14
+ add_index :posts, [:area_id, :issue_id]
15
+ end
16
+
17
+ def self.down
18
+ drop_table :posts
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ class CreateIssueNumbers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :issue_numbers do |t|
4
+ t.integer :area_id
5
+ t.integer :sequence_number
6
+ end
7
+ add_index :issue_numbers, :area_id, :unique => true
8
+ end
9
+
10
+ def self.down
11
+ drop_table :issue_numbers
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ class CreateIssues < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :issues do |t|
4
+ t.string :subject
5
+ t.integer :area_id
6
+ t.datetime :scheduled_at
7
+ t.datetime :sent_at
8
+ t.integer :number
9
+ t.timestamps
10
+ end
11
+ add_index :issues, :area_id
12
+ add_index :issues, [:area_id, :scheduled_at]
13
+ add_index :issues, [:area_id, :sent_at]
14
+ add_index :issues, :number
15
+ add_index :issues, [:area_id, :number]
16
+ end
17
+
18
+ def self.down
19
+ drop_table :issues
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ class AddPublishedToAreas < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :areas, :published, :boolean, :default => false, :null => false
4
+ add_index :areas, :published
5
+ end
6
+
7
+ def self.down
8
+ remove_column :areas, :published
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUserActivities < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :user_activities do |t|
4
+ t.string :url
5
+ t.string :name
6
+ t.datetime :expires_at
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :user_activities
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ class AddZipToAreas < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :areas, :zip, :string
4
+ remove_column :areas, :last_issue_number
5
+ end
6
+
7
+ def self.down
8
+ remove_column :areas, :zip
9
+ # add_column :areas, :last_issue_number, :integer
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ class AddCountersToAreas < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :areas, :memberships_count, :integer
4
+ add_column :areas, :issues_count, :integer
5
+ end
6
+
7
+ def self.down
8
+ remove_column :areas, :memberships_count
9
+ remove_column :areas, :issues_count
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class RemoveSubjectFromIssues < ActiveRecord::Migration
2
+ def self.up
3
+ remove_column :issues, :subject
4
+ end
5
+
6
+ def self.down
7
+ add_column :issues, :subject, :string
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddReviewerInfoToPosts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :posts, :reviewed_by, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :posts, :reviewed_by
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class AddEmailValidationKeyToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :email_verification_key, :string
4
+ add_column :users, :verified_at, :datetime
5
+ add_index :users, [:email_verification_key]
6
+ add_index :users, [:verified_at]
7
+ end
8
+
9
+ def self.down
10
+ remove_column :users, :email_verification_key
11
+ remove_column :users, :verified_at
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class RemovePublishedFromAreas < ActiveRecord::Migration
2
+ def self.up
3
+ remove_column :areas, :published
4
+ end
5
+
6
+ def self.down
7
+ add_column :areas, :published, :boolean, :default => false, :null => false
8
+ add_index :areas, :published
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ class CreateAreaActivities < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :area_activities do |t|
4
+ t.integer :area_id
5
+ t.date :day
6
+ t.integer :quitters_count, :default => 0
7
+ t.integer :new_users_count, :default => 0
8
+ t.integer :new_posts_count, :default => 0
9
+ t.integer :issues_published_count, :default => 0
10
+ t.timestamps
11
+ end
12
+ add_index :area_activities, :area_id
13
+ add_index :area_activities, :day
14
+ end
15
+
16
+ def self.down
17
+ drop_table :area_activities
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ class CreateEmailMessages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :email_messages do |t|
4
+ t.integer :number
5
+ t.text :content
6
+ t.integer :size
7
+ t.boolean :parsed, :default => false, :null => false
8
+ t.timestamps
9
+ end
10
+ add_index :email_messages, [:parsed]
11
+
12
+ add_column :posts, :email_message_id, :integer
13
+ end
14
+
15
+ def self.down
16
+ drop_table :email_messages
17
+ remove_column :posts, :email_message_id
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ class ChangeSendModeToString < ActiveRecord::Migration
2
+ def self.up
3
+ rename_column :areas, :send_mode, :old_send_mode
4
+ add_column :areas, :send_mode, :string
5
+ Area.update_all({:send_mode => 'immediate'}, 'old_send_mode = 0 OR old_send_mode IS NULL')
6
+ Area.update_all({:send_mode => 'batched'}, {:old_send_mode => 1})
7
+ remove_column :areas, :old_send_mode
8
+ end
9
+
10
+ def self.down
11
+ rename_column :areas, :send_mode, :old_send_mode
12
+ add_column :areas, :send_mode, :integer
13
+ Area.update_all({:send_mode => 0}, "old_send_mode = 'immediate' OR old_send_mode IS NULL")
14
+ Area.update_all({:send_mode => 1}, {:old_send_mode => 'batched'})
15
+ remove_column :areas, :old_send_mode
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ class DenormalizeUserInfoInPosts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :posts, :user_first_name, :string
4
+ add_column :posts, :user_last_name, :string
5
+ add_column :posts, :user_email, :string
6
+ add_column :posts, :user_address, :string
7
+ add_column :posts, :user_city, :string
8
+ add_column :posts, :user_state, :string
9
+ end
10
+
11
+ def self.down
12
+ remove_column :posts, :user_first_name
13
+ remove_column :posts, :user_last_name
14
+ remove_column :posts, :user_email
15
+ remove_column :posts, :user_address
16
+ remove_column :posts, :user_city
17
+ remove_column :posts, :user_state
18
+ end
19
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Mayor.create(:name => 'Daley', :city => cities.first)
@@ -0,0 +1,2 @@
1
+ Use this README file to introduce your application and point to useful places in the API for learning more.
2
+ Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
@@ -0,0 +1,37 @@
1
+ class OpenPorchGenerator < Rails::Generators::Base
2
+ include Rails::Generators::Migration
3
+
4
+ source_root File.expand_path('../../..', __FILE__)
5
+
6
+ def generate_application_controller
7
+ copy_file 'app/controllers/application_controller.rb', 'app/controllers/application_controller.rb'
8
+ end
9
+
10
+ def generate_static_files
11
+ directory 'public/javascripts', 'public/javascripts'
12
+ directory 'public/images', 'public/images'
13
+ directory 'app/views/stylesheets', 'app/views/stylesheets'
14
+ copy_file 'public/stylesheets/jquery-ui.css', 'public/stylesheets/jquery-ui.css'
15
+ directory 'public/stylesheets/images', 'public/stylesheets/images'
16
+ end
17
+
18
+ def generate_config_example_files
19
+ copy_file 'config/open_porch_example.yml', 'config/open_porch_example.yml'
20
+ copy_file 'config/database_example.yml', 'config/database_example.yml'
21
+ end
22
+
23
+ def generate_migration
24
+ migrations = Dir.glob(File.expand_path('db/migrate/*.rb', self.class.source_root))
25
+
26
+ migrations.each do |migration|
27
+ filename = File.basename(migration).gsub(/\d+_/, '')
28
+ migration_template migration, "db/migrate/#{filename}"
29
+ end
30
+ end
31
+
32
+ def self.next_migration_number(dirname)
33
+ orm = Rails.configuration.generators.options[:rails][:orm]
34
+ require "rails/generators/#{orm}"
35
+ "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname)
36
+ end
37
+ end
@@ -0,0 +1,20 @@
1
+ require 'haml'
2
+ require "wristband"
3
+ require 'active_link_to'
4
+ require 'postageapp'
5
+ require 'spatial_adapter'
6
+ require "open_porch"
7
+ require "formatted_form"
8
+ require "will_paginate"
9
+ require "meta_search"
10
+ require 'geokit'
11
+ require "rails"
12
+
13
+ module OpenPorch
14
+ class Engine < Rails::Engine
15
+ initializer 'open_porch_helper' do |app|
16
+ require File.expand_path("../../app/helpers/open_porch_helper.rb", File.dirname(__FILE__))
17
+ ActionView::Base.send(:include, OpenPorchHelper)
18
+ end
19
+ end
20
+ end
data/lib/open_porch.rb ADDED
@@ -0,0 +1,3 @@
1
+ module OpenPorch
2
+ require 'open_porch/engine' if defined?(Rails)
3
+ end
File without changes
@@ -0,0 +1,10 @@
1
+ namespace :open_porch do
2
+
3
+ desc "Send Issues"
4
+ task :send_issues => :environment do
5
+ Issue.scheduled_before(Time.now).each do |issue|
6
+ issue.send!
7
+ end
8
+ end
9
+
10
+ end
@@ -0,0 +1,78 @@
1
+ namespace :postageapp do
2
+
3
+ desc 'Verify postageapp gem installation by requesting project info from PostageApp.com'
4
+ task :test => :environment do
5
+
6
+ puts "Attempting to contact #{PostageApp.configuration.host} ..."
7
+ response = PostageApp::Request.new(:get_project_info).send
8
+
9
+ if response.ok?
10
+ project_name = response.data['project']['name']
11
+ project_url = response.data['project']['url']
12
+ user_emails = response.data['project']['users']
13
+
14
+ puts %{
15
+ Found Project:
16
+ ----------------------------
17
+ Name: #{ project_name }
18
+ URL: #{ project_url }
19
+ Users: #{ user_emails.keys.join(', ') }
20
+ }
21
+
22
+ # Sending test email to all users in the project
23
+ # Most likely a single user if it's a new project
24
+ puts 'Sending test message to users in the project...'
25
+ r = send_test_message(user_emails)
26
+ if r.ok?
27
+ puts "Message was successfully sent!\n\n"
28
+ puts 'Your application is ready to use PostageApp!'
29
+ else
30
+ puts 'Failed to send test message. Please try again. Check logs if issue persists.'
31
+ puts 'This was the response:'
32
+ puts r.to_yaml
33
+ end
34
+
35
+ else
36
+ puts 'Failed to fetch information about your project. This was the response:'
37
+ puts response.to_yaml
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ HTML_MESSAGE = %{
44
+ <h3> Hello {{name}}, </h3>
45
+ <p> This is a html message generated by Postage plugin. </p>
46
+ <p> If you received this message it means that your application is properly configured and is ready to use PostageApp service. </p>
47
+ <p> Thank you, </p>
48
+ <p> The PostageApp Team </p>
49
+ }
50
+
51
+ TEXT_MESSAGE = %{
52
+ Hello {{name}}
53
+
54
+ This is a plain text message generated by Postage plugin.
55
+ If you received this message it means that your application is properly configured and is ready to use PostageApp service.
56
+
57
+ Thank you,
58
+ The PostageApp Team
59
+ }
60
+
61
+ def send_test_message(recipients)
62
+ recipients_with_variables = {}
63
+ recipients.each do |email, name|
64
+ recipients_with_variables[email] = { 'name' => name }
65
+ end
66
+
67
+ PostageApp::Request.new(:send_message,
68
+ :message => {
69
+ 'text/html' => HTML_MESSAGE,
70
+ 'text/plain' => TEXT_MESSAGE
71
+ },
72
+ :recipients => recipients_with_variables,
73
+ :headers => {
74
+ 'Subject' => '[PostageApp] Test Message',
75
+ 'From' => 'no-return@postageapp.com'
76
+ }
77
+ ).send
78
+ end