raddar 0.0.1.pre

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 (111) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +3 -0
  4. data/Rakefile +27 -0
  5. data/app/assets/images/raddar/fallback/avatar/medium.png +0 -0
  6. data/app/assets/images/raddar/fallback/avatar/thumb.png +0 -0
  7. data/app/assets/javascripts/raddar/admin/dashboard.js.coffee +3 -0
  8. data/app/assets/javascripts/raddar/application.js +16 -0
  9. data/app/assets/javascripts/raddar/followerships.js.coffee +3 -0
  10. data/app/assets/javascripts/raddar/home.js.coffee +3 -0
  11. data/app/assets/javascripts/raddar/notifications.js.coffee +16 -0
  12. data/app/assets/javascripts/raddar/users.js.coffee +3 -0
  13. data/app/assets/javascripts/raddar/users/privacies.js.coffee +3 -0
  14. data/app/assets/stylesheets/raddar/admin/dashboard.css.scss +3 -0
  15. data/app/assets/stylesheets/raddar/application.css +14 -0
  16. data/app/assets/stylesheets/raddar/followerships.css.scss +3 -0
  17. data/app/assets/stylesheets/raddar/home.css.scss +3 -0
  18. data/app/assets/stylesheets/raddar/notifications.css.scss +6 -0
  19. data/app/assets/stylesheets/raddar/users.css.scss +3 -0
  20. data/app/assets/stylesheets/raddar/users/privacies.css.scss +3 -0
  21. data/app/controllers/raddar/admin/dashboard_controller.rb +11 -0
  22. data/app/controllers/raddar/admin/users_controller.rb +34 -0
  23. data/app/controllers/raddar/application_controller.rb +17 -0
  24. data/app/controllers/raddar/followerships_controller.rb +60 -0
  25. data/app/controllers/raddar/home_controller.rb +8 -0
  26. data/app/controllers/raddar/notifications_controller.rb +31 -0
  27. data/app/controllers/raddar/users/email_preferences_controller.rb +24 -0
  28. data/app/controllers/raddar/users/external_accounts_controller.rb +18 -0
  29. data/app/controllers/raddar/users/omniauth_callbacks_controller.rb +30 -0
  30. data/app/controllers/raddar/users/passwords_controller.rb +22 -0
  31. data/app/controllers/raddar/users/privacies_controller.rb +25 -0
  32. data/app/controllers/raddar/users/registrations_controller.rb +51 -0
  33. data/app/controllers/raddar/users/sessions_controller.rb +11 -0
  34. data/app/controllers/raddar/users_controller.rb +8 -0
  35. data/app/helpers/raddar/admin/dashboard_helper.rb +4 -0
  36. data/app/helpers/raddar/application_helper.rb +4 -0
  37. data/app/helpers/raddar/notifications_helper.rb +19 -0
  38. data/app/helpers/raddar/users/privacies_helper.rb +4 -0
  39. data/app/mailers/raddar/notification_mailer.rb +16 -0
  40. data/app/models/raddar/external_account.rb +12 -0
  41. data/app/models/raddar/followership.rb +20 -0
  42. data/app/models/raddar/followership_completion.rb +37 -0
  43. data/app/models/raddar/notification.rb +10 -0
  44. data/app/models/raddar/omniauth_completion.rb +83 -0
  45. data/app/models/raddar/role.rb +7 -0
  46. data/app/models/raddar/user.rb +70 -0
  47. data/app/policies/raddar/admin/dashboard_policy.rb +7 -0
  48. data/app/policies/raddar/admin/user_policy.rb +15 -0
  49. data/app/policies/raddar/application_policy.rb +42 -0
  50. data/app/policies/raddar/followership_policy.rb +25 -0
  51. data/app/policies/raddar/notification_policy.rb +21 -0
  52. data/app/policies/raddar/user_policy.rb +17 -0
  53. data/app/uploaders/raddar/avatar_uploader.rb +56 -0
  54. data/app/views/layouts/raddar/_alerts.html.erb +3 -0
  55. data/app/views/layouts/raddar/_navbar.html.erb +22 -0
  56. data/app/views/layouts/raddar/_notifications.html.erb +20 -0
  57. data/app/views/layouts/raddar/_user_menu.html.erb +21 -0
  58. data/app/views/layouts/raddar/application.html.erb +21 -0
  59. data/app/views/layouts/raddar/notification_mailer.html.erb +12 -0
  60. data/app/views/raddar/admin/dashboard/index.html.erb +6 -0
  61. data/app/views/raddar/admin/users/index.html.erb +11 -0
  62. data/app/views/raddar/admin/users/show.html.erb +12 -0
  63. data/app/views/raddar/followerships/followers.html.erb +9 -0
  64. data/app/views/raddar/followerships/following.html.erb +9 -0
  65. data/app/views/raddar/home/index.html.erb +1 -0
  66. data/app/views/raddar/notification_mailer/new_follower.html.erb +11 -0
  67. data/app/views/raddar/notifications/index.html.erb +12 -0
  68. data/app/views/raddar/notifications/index.json.jbuilder +4 -0
  69. data/app/views/raddar/users/confirmations/new.html.erb +16 -0
  70. data/app/views/raddar/users/email_preferences/edit.html.erb +11 -0
  71. data/app/views/raddar/users/external_accounts/index.html.erb +14 -0
  72. data/app/views/raddar/users/mailer/confirmation_instructions.html.erb +5 -0
  73. data/app/views/raddar/users/mailer/reset_password_instructions.html.erb +8 -0
  74. data/app/views/raddar/users/mailer/unlock_instructions.html.erb +7 -0
  75. data/app/views/raddar/users/passwords/change.html.erb +13 -0
  76. data/app/views/raddar/users/passwords/edit.html.erb +19 -0
  77. data/app/views/raddar/users/passwords/new.html.erb +15 -0
  78. data/app/views/raddar/users/privacies/edit.html.erb +12 -0
  79. data/app/views/raddar/users/registrations/destroy.html.erb +13 -0
  80. data/app/views/raddar/users/registrations/edit.html.erb +30 -0
  81. data/app/views/raddar/users/registrations/new.html.erb +16 -0
  82. data/app/views/raddar/users/sessions/new.html.erb +13 -0
  83. data/app/views/raddar/users/shared/_links.erb +25 -0
  84. data/app/views/raddar/users/show.html.erb +52 -0
  85. data/app/views/raddar/users/unlocks/new.html.erb +16 -0
  86. data/config/cucumber.yml +8 -0
  87. data/config/initializers/carrierwave.rb +10 -0
  88. data/config/initializers/devise.rb +262 -0
  89. data/config/initializers/kaminari_config.rb +10 -0
  90. data/config/initializers/simple_form.rb +142 -0
  91. data/config/initializers/simple_form_bootstrap.rb +17 -0
  92. data/config/locales/devise.en.yml +59 -0
  93. data/config/locales/en.yml +49 -0
  94. data/config/locales/flash.en.yml +20 -0
  95. data/config/locales/mailers.en.yml +5 -0
  96. data/config/locales/simple_form.en.yml +35 -0
  97. data/config/locales/views.en.yml +36 -0
  98. data/config/routes.rb +43 -0
  99. data/db/migrate/20130824222728_devise_create_raddar_users.rb +66 -0
  100. data/db/migrate/20131013222926_create_raddar_followerships.rb +14 -0
  101. data/db/migrate/20131020174318_create_raddar_roles.rb +11 -0
  102. data/db/migrate/20131020175354_create_join_table_raddar_role_user.rb +8 -0
  103. data/db/migrate/20131021134623_create_raddar_notifications.rb +13 -0
  104. data/db/migrate/20131026133924_create_raddar_external_accounts.rb +23 -0
  105. data/lib/raddar.rb +15 -0
  106. data/lib/raddar/engine.rb +5 -0
  107. data/lib/raddar/hstore_serializer.rb +22 -0
  108. data/lib/raddar/version.rb +3 -0
  109. data/lib/tasks/cucumber.rake +65 -0
  110. data/lib/tasks/raddar_tasks.rake +4 -0
  111. metadata +390 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 68a2b365881f79ecfd79cf93253aa9dd5a044875
4
+ data.tar.gz: a049425a1472992d4de95e6b38c9114da6744300
5
+ SHA512:
6
+ metadata.gz: e483d8def5907469294e91a13be2738b6739b91f294cc4c40fd1dbce7054fd8d4ff1290550a26c69f046194b8864d45139730f5aef95cc29bc732274ad25f82b
7
+ data.tar.gz: 233f770f419e3816953ff8b52e0714449efbbd85db09a863b9fe70102b48061ff8600013daabccb035a6930db1d071d1b325af52d0b5d5b5746c7780dfed8784
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Volmer Soares
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.md ADDED
@@ -0,0 +1,3 @@
1
+ = Raddar
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Raddar'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ Bundler::GemHelper.install_tasks
22
+
23
+ Raddar::Engine.load_tasks
24
+
25
+ task default: [:spec, :cucumber]
26
+
27
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require bootstrap
16
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,16 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
4
+
5
+ markNotificationsAsRead = ->
6
+ if $('.notification.unread:visible').length > 0
7
+ $.ajax
8
+ url: '/notifications/read_all'
9
+ type: 'PATCH'
10
+
11
+ $ ->
12
+ markNotificationsAsRead()
13
+
14
+ $('#notifications-menu').parent('.dropdown').on 'shown.bs.dropdown', ->
15
+ markNotificationsAsRead()
16
+
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the admin/dashboard controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,14 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require bootstrap
12
+ *= require_self
13
+ *= require_tree .
14
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the Followerships controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the home controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,6 @@
1
+ // Place all the styles related to the Notifications controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
4
+ .notification.unread {
5
+ font-weight: bold;
6
+ }
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the users controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the users/privacies controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,11 @@
1
+ module Raddar
2
+ class Admin::DashboardController < Raddar::ApplicationController
3
+ def index
4
+ authorize(self)
5
+ end
6
+
7
+ def self.policy_class
8
+ Admin::DashboardPolicy
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+ module Raddar
2
+ class Admin::UsersController < Raddar::ApplicationController
3
+ def index
4
+ authorize(self)
5
+ @users = User.order('name ASC').page(params[:page])
6
+ end
7
+
8
+ def show
9
+ @user = User.find(params[:id])
10
+ authorize(self)
11
+ end
12
+
13
+ def update
14
+ @user = User.find(params[:id])
15
+ authorize(self)
16
+
17
+ if @user.update_attributes(user_params)
18
+ redirect_to [:admin, @user], notice: t('flash.admin.users.update', user: @user.name)
19
+ else
20
+ render 'show'
21
+ end
22
+ end
23
+
24
+ def self.policy_class
25
+ Admin::UserPolicy
26
+ end
27
+
28
+ private
29
+
30
+ def user_params
31
+ params.require(:user).permit(:state, role_ids: [])
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ module Raddar
2
+ class ApplicationController < ActionController::Base
3
+ include Pundit
4
+
5
+ after_action :verify_authorized, unless: :devise_controller?
6
+
7
+ rescue_from Pundit::NotAuthorizedError do |exception|
8
+ if user_signed_in?
9
+ self.response_body = nil
10
+
11
+ redirect_to root_path, alert: t('flash.unauthorized')
12
+ else
13
+ authenticate_user!
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,60 @@
1
+ module Raddar
2
+ class FollowershipsController < Raddar::ApplicationController
3
+
4
+ def followers
5
+ @followable = find_followable
6
+ authorize(Followership.new)
7
+ end
8
+
9
+
10
+ def following
11
+ @user = User.find(params[:user_id])
12
+ authorize(Followership.new)
13
+ end
14
+
15
+ # POST /followerships
16
+ # POST /followerships.json
17
+ def create
18
+ @followable = find_followable
19
+ @followership = Followership.new
20
+ @followership.user = current_user
21
+ @followership.followable = @followable
22
+ authorize(@followership)
23
+
24
+ respond_to do |format|
25
+ if FollowershipCompletion.new(@followership).create
26
+ format.html { redirect_to @followable, notice: t('flash.followerships.create', followable: @followable.name) }
27
+ format.json { render action: 'show', status: :created, location: @followership }
28
+ else
29
+ format.html { redirect_to @followable, alert: 'Error.' }
30
+ format.json { render json: @followership.errors, status: :unprocessable_entity }
31
+ end
32
+ end
33
+ end
34
+
35
+ # DELETE /followerships/1
36
+ # DELETE /followerships/1.json
37
+ def destroy
38
+ @followership = Followership.find(params[:id])
39
+ @followable = @followership.followable
40
+ authorize(@followership)
41
+
42
+ @followership.destroy
43
+ respond_to do |format|
44
+ format.html { redirect_to @followable, notice: t('flash.followerships.destroy', followable: @followable.name) }
45
+ format.json { head :no_content }
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ def find_followable
52
+ params.each do |name, value|
53
+ if name =~ /(.+)_id$/
54
+ return "Raddar::#{ $1.classify }".constantize.find(value)
55
+ end
56
+ end
57
+ nil
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,8 @@
1
+ module Raddar
2
+ class HomeController < Raddar::ApplicationController
3
+ skip_after_action :verify_authorized, only: [:index]
4
+
5
+ def index
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ module Raddar
2
+ class NotificationsController < Raddar::ApplicationController
3
+ # GET /notifications
4
+ # GET /notifications.json
5
+ def index
6
+ authorize(Notification.new)
7
+
8
+ @notifications = current_user.notifications.order('created_at DESC').page(params[:page])
9
+ end
10
+
11
+ # GET /notifications/1
12
+ # GET /notifications/1.json
13
+ def show
14
+ @notification = Notification.find(params[:id])
15
+
16
+ authorize(@notification)
17
+
18
+ @notification.update_attribute(:unread, false)
19
+
20
+ redirect_to @notification.item_path.presence || @notification.notifiable
21
+ end
22
+
23
+ def read_all
24
+ authorize(Notification.new)
25
+
26
+ current_user.notifications.update_all(unread: false)
27
+
28
+ head :no_content
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ module Raddar
2
+ class Users::EmailPreferencesController < Raddar::ApplicationController
3
+ skip_after_action :verify_authorized
4
+
5
+ def edit
6
+ @user = current_user
7
+ @user.email_preferences ||= {}
8
+ end
9
+
10
+ def update
11
+ @user = current_user
12
+
13
+ @user.update_attributes(email_preferences_params)
14
+
15
+ redirect_to edit_user_email_preferences_path, notice: t('flash.users.email_preferences.update')
16
+ end
17
+
18
+ private
19
+
20
+ def email_preferences_params
21
+ params.require(:user).permit(email_preferences: User.email_preferences_keys)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ module Raddar
2
+ class Users::ExternalAccountsController < Raddar::ApplicationController
3
+ skip_after_action :verify_authorized
4
+
5
+ def index
6
+ @user = current_user
7
+ @accounts = @user.external_accounts
8
+ end
9
+
10
+ def destroy
11
+ @account = ExternalAccount.find(params[:id])
12
+ @account.destroy
13
+
14
+ redirect_to user_external_accounts_path,
15
+ notice: t('flash.users.external_accounts.destroy', provider: @account.provider.titleize)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ module Raddar
2
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
3
+ def facebook
4
+ complete('facebook')
5
+ end
6
+
7
+ def twitter
8
+ complete('twitter')
9
+ end
10
+
11
+ private
12
+
13
+ def complete(provider)
14
+ @user = OmniauthCompletion.complete(request.env['omniauth.auth'], current_user)
15
+
16
+ if @user.persisted?
17
+ if user_signed_in?
18
+ redirect_to user_external_accounts_path
19
+ else
20
+ sign_in_and_redirect @user, event: :authentication
21
+ end
22
+
23
+ set_flash_message(:notice, :success, kind: provider.titleize) if is_navigational_format?
24
+ else
25
+ session["devise.#{provider}_data"] = request.env['omniauth.auth']
26
+ redirect_to new_user_registration_url
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ module Raddar
2
+ class Users::PasswordsController < Devise::PasswordsController
3
+ prepend_before_filter :require_no_authentication, except: [:change, :do_change]
4
+
5
+ def change
6
+ @user = current_user
7
+ end
8
+
9
+ def do_change
10
+ @user = current_user
11
+
12
+ user_params = params.required(:user).permit(:password, :current_password, :password_confirmation)
13
+
14
+ if @user.update_with_password(user_params)
15
+ sign_in @user, bypass: true
16
+ redirect_to root_path, notice: t('flash.users.passwords.do_change')
17
+ else
18
+ render 'change'
19
+ end
20
+ end
21
+ end
22
+ end