Permalink
Browse files

merged with origin/master

  • Loading branch information...
oemera committed Apr 2, 2012
2 parents 6f7f512 + 1a24b96 commit d15893cefec9aabebc24f900b293e8ab766c6644
Showing with 851 additions and 23 deletions.
  1. +1 −0 .rspec
  2. +25 −3 Gemfile
  3. +73 −0 Gemfile.lock
  4. +37 −0 Guardfile
  5. BIN app/assets/images/hackful.png
  6. BIN app/assets/images/rails.png
  7. BIN app/assets/images/rss.png
  8. +3 −0 app/assets/javascripts/admin.js.coffee
  9. +3 −0 app/assets/stylesheets/admin.css.scss
  10. +10 −0 app/assets/stylesheets/layout.css.scss
  11. +21 −0 app/controllers/admin_controller.rb
  12. +1 −0 app/controllers/filter_controller.rb
  13. +1 −1 app/controllers/posts_controller.rb
  14. +2 −0 app/helpers/admin_helper.rb
  15. +36 −0 app/mailers/user_mailer.rb
  16. +3 −0 app/models/ability.rb
  17. +3 −0 app/models/admin_auth.rb
  18. +1 −1 app/models/comment.rb
  19. +7 −0 app/models/data_set.rb
  20. +5 −1 app/models/user.rb
  21. +8 −0 app/views/admin/mail.html.erb
  22. +8 −0 app/views/content/stats.html.erb
  23. +5 −0 app/views/devise/registrations/edit.html.erb
  24. +1 −0 app/views/layouts/application.html.erb
  25. +7 −0 app/views/user_mailer/newsletter.html.erb
  26. +7 −0 app/views/user_mailer/newsletter.text.erb
  27. +3 −0 app/views/user_mailer/notify.text.erb
  28. +3 −0 app/views/user_mailer/receive.text.erb
  29. +3 −3 config/cucumber.yml
  30. +11 −0 config/database.yml
  31. +1 −1 config/initializers/devise.rb
  32. +6 −1 config/routes.rb
  33. +11 −0 db/migrate/20120224135606_create_admin_auths.rb
  34. +22 −0 db/migrate/20120226193229_create_delayed_jobs.rb
  35. +16 −0 db/migrate/20120307155241_create_data_sets.rb
  36. +39 −1 db/schema.rb
  37. +11 −0 db/seeds.rb
  38. +30 −0 features/devise.feature
  39. +31 −0 features/posts.feature
  40. +19 −0 features/step_definitions/devise_steps.rb
  41. +3 −0 features/step_definitions/posts_steps.rb
  42. +40 −0 features/step_definitions/shared_steps.rb
  43. +65 −0 features/support/env.rb
  44. +193 −0 spec/controllers/posts_controller_spec.rb
  45. +7 −0 spec/factories/posts.rb
  46. +11 −0 spec/factories/users.rb
  47. +49 −0 spec/spec_helper.rb
  48. +9 −0 spec/support/controller_macros.rb
  49. +0 −11 test/integration/posts_controller_test.rb
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
28 Gemfile
@@ -7,16 +7,36 @@ gem 'sqlite3'
gem 'json'
group :assets do
- gem 'sass-rails', '~> 3.1.5'
+ gem 'sass-rails', '~> 3.1.5'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
-group :test do
+group :test, :development do
gem 'cucumber-rails'
+ gem 'database_cleaner'
+ gem 'rspec-rails'
+ gem 'cucumber-rails', require: false
+ gem "factory_girl_rails"
gem 'capybara'
+ gem "capybara-webkit"
+ gem 'fakeweb'
+ gem "launchy"
gem 'database_cleaner', :group => :test
+ gem 'faker'
+ gem 'pry'
gem 'rest-client'
+
+ if RUBY_PLATFORM.downcase.include?("darwin")
+ gem "guard"
+ gem "guard-rspec"
+ gem "guard-cucumber"
+ gem "guard-bundler"
+ gem "guard-spork"
+ gem 'spork'
+ gem 'rb-fsevent'
+ gem 'growl' # also install growlnotify from the Extras/growlnotify/growlnotify.pkg in Growl disk image
+ end
end
gem 'execjs'
@@ -28,4 +48,6 @@ gem 'cancan'
gem 'make_voteable'
gem 'mysql2'
gem 'rails_autolink'
-gem 'rdiscount'
+gem 'rdiscount'
+gem 'delayed_job'
+gem 'delayed_job_active_record'
View
@@ -36,6 +36,7 @@ GEM
activesupport (= 3.1.3)
activesupport (3.1.3)
multi_json (~> 1.0)
+ addressable (2.2.7)
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
@@ -47,8 +48,12 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
+ capybara-webkit (0.10.1)
+ capybara (>= 1.0.0, < 1.2)
+ json
childprocess (0.3.0)
ffi (~> 1.0.6)
+ coderay (1.0.5)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
@@ -67,6 +72,11 @@ GEM
cucumber (>= 1.1.3)
nokogiri (>= 1.5.0)
database_cleaner (0.7.1)
+ delayed_job (3.0.0)
+ activesupport (~> 3.0)
+ delayed_job_active_record (0.3.1)
+ activerecord (> 2.1.0)
+ delayed_job (~> 3.0.0)
devise (2.0.0)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
@@ -76,28 +86,58 @@ GEM
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
+ factory_girl (2.6.3)
+ activesupport (>= 2.3.9)
+ factory_girl_rails (1.7.0)
+ factory_girl (~> 2.6.0)
+ railties (>= 3.0.0)
+ faker (1.0.1)
+ i18n (~> 0.4)
+ fakeweb (1.3.0)
ffi (1.0.11)
gherkin (2.7.6)
json (>= 1.4.6)
+ growl (1.0.3)
+ guard (1.0.1)
+ ffi (>= 0.5.0)
+ thor (~> 0.14.6)
+ guard-bundler (0.1.3)
+ bundler (>= 1.0.0)
+ guard (>= 0.2.2)
+ guard-cucumber (0.7.5)
+ cucumber (>= 0.10)
+ guard (>= 0.8.3)
+ guard-rspec (0.6.0)
+ guard (>= 0.10.0)
+ guard-spork (0.5.2)
+ guard (>= 0.10.0)
+ spork (>= 0.8.4)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.5)
+ launchy (2.0.5)
+ addressable (~> 2.2.6)
libv8 (3.3.10.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
make_voteable (0.1.1)
activerecord (~> 3.0)
+ method_source (0.7.1)
mime-types (1.17.2)
multi_json (1.0.4)
mysql2 (0.3.11)
nokogiri (1.5.0)
orm_adapter (0.0.6)
polyglot (0.3.3)
+ pry (0.9.8.4)
+ coderay (~> 1.0.5)
+ method_source (~> 0.7.1)
+ slop (>= 2.4.4, < 3)
rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
@@ -125,11 +165,25 @@ GEM
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
+ rb-fsevent (0.9.0)
rdiscount (1.6.8)
rdoc (3.12)
json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ rspec-rails (2.8.1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ railties (>= 3.0)
+ rspec (~> 2.8.0)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.1.5)
@@ -142,6 +196,8 @@ GEM
ffi (~> 1.0.9)
multi_json (~> 1.0.4)
rubyzip
+ slop (2.4.4)
+ spork (0.9.0)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
@@ -170,21 +226,38 @@ PLATFORMS
DEPENDENCIES
cancan
capybara
+ capybara-webkit
coffee-rails (~> 3.1.1)
cucumber-rails
database_cleaner
+ delayed_job
+ delayed_job_active_record
devise
execjs
+ factory_girl_rails
+ faker
+ fakeweb
+ growl
+ guard
+ guard-bundler
+ guard-cucumber
+ guard-rspec
+ guard-spork
jquery-rails
json
+ launchy
make_voteable
mysql2
nested_form!
+ pry
rails (= 3.1.3)
rails_autolink
+ rb-fsevent
rdiscount
rest-client
+ rspec-rails
sass-rails (~> 3.1.5)
+ spork
sqlite3
therubyracer
uglifier (>= 1.0.3)
View
@@ -0,0 +1,37 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
+ watch('config/application.rb')
+ watch('config/environment.rb')
+ watch(%r{^config/environments/.+\.rb$})
+ watch(%r{^config/initializers/.+\.rb$})
+ watch('Gemfile')
+ watch('Gemfile.lock')
+ watch('spec/spec_helper.rb') { :rspec }
+ watch('test/test_helper.rb') { :test_unit }
+ watch(%r{features/support/}) { :cucumber }
+end
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+end
+
+
+guard 'cucumber' do
+ watch(%r{^features/.+\.feature$})
+ watch(%r{^features/support/.+$}) { 'features' }
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
+end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,3 @@
+// Place all the styles related to the Admin controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -25,6 +25,16 @@ a:visited {
text-decoration: none;
}
+.notice {
+ font-size: 10pt;
+ padding: {
+ left: 13%;
+ right: 10%;
+ }
+ line-height: 20px;
+ color: #797979;
+}
+
.header {
background: {
color: #EBEBEB;
@@ -0,0 +1,21 @@
+class AdminController < ApplicationController
+ authorize_resource :class => false
+
+ def mail
+
+ end
+
+ def send_newsletter
+ if user_signed_in?
+ unless params[:test]
+ User.all.each do |user|
+ UserMailer.delay.newsletter(user, params[:subject], params[:text])
+ end
+ else
+ UserMailer.delay.newsletter(current_user, params[:subject], params[:text])
+ end
+ redirect_to "/admin/mail", notice: "Mail sent"
+ end
+ end
+
+end
@@ -4,6 +4,7 @@ class FilterController < ApplicationController
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = exception.message
+ session[:user_return_to] = request.url
redirect_to new_user_session_path
end
end
@@ -22,7 +22,7 @@ def show
# GET /posts/new
# GET /posts/new.json
def new
- @post = Post.new
+ @post = Post.new(:link => params[:link], :title => params[:title])
respond_to do |format|
format.html # new.html.erb
@@ -0,0 +1,2 @@
+module AdminHelper
+end
View
@@ -0,0 +1,36 @@
+class UserMailer < ActionMailer::Base
+ helper :application
+
+ default from: "mail@hackful.com"
+
+ def receive(email)
+ commentable_string = email.subject.scan(/\(\w{1,} #\d*\)/mi)[0]
+ commentable_type = commentable_string.scan(/[a-zA-Z]+/mi)[0]
+ commentable_id = commentable_string.scan(/[0-9]{1,}/)[0].to_i
+ text = email.body.decoded.gsub(/(^>.*)|((\w*\s*)[0-9]{1,}.*:$)/mi, "")
+ Comment.new(commentable_type: commentable_type, commentable_id: commentable_id, text: text, user_id: User.find_by_email(email.from.first).id).save! unless User.find_by_email(email.from.first).nil?
+ end
+
+ # Subject can be set in your I18n file at config/locales/en.yml
+ # with the following lookup:
+ #
+ # en.user_mailer.newsletter.subject
+ #
+ def newsletter(user, subject, text)
+ @user = user
+ @text = text
+
+ mail(to: user.email, subject: subject)
+ end
+
+ # Subject can be set in your I18n file at config/locales/en.yml
+ # with the following lookup:
+ #
+ # en.user_mailer.notify.subject
+ #
+ def notify
+ @greeting = "Hi"
+
+ mail to: "to@example.org"
+ end
+end
View
@@ -6,6 +6,9 @@ def initialize(user)
unless user.id.nil?
can [:read, :create, :vote_up, :vote_down], [Post, Comment]
can [:update, :destroy], [Post, Comment], :user_id => user.id
+ user.admin_auths.each do |auth|
+ (defined?(auth.resource.upcase) == "constant") ? (can auth.action.to_sym, auth.resource.constantize) : (can auth.action.to_sym, auth.resource.to_sym)
+ end
end
can [:read], :all
can :create, User
View
@@ -0,0 +1,3 @@
+class AdminAuth < ActiveRecord::Base
+ belongs_to :user
+end
View
@@ -6,7 +6,7 @@ class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
belongs_to :user
- attr_accessible :commentable_type, :commentable_id, :text
+ attr_accessible :commentable_type, :commentable_id, :text, :user_id
has_many :comments, :as => :commentable
View
@@ -0,0 +1,7 @@
+class DataSet < ActiveRecord::Base
+ #Initial table structure, could be changed in favor of more dynamic structure
+
+ attr_accessible :contact_me, :user_id
+
+ belongs_to :user
+end
Oops, something went wrong.

0 comments on commit d15893c

Please sign in to comment.