Commit a0d48cac899058532483642aedb62afb930b41fd

Authored by Fernando Brito
1 parent ba0c37a3
Exists in master and in 2 other branches v2, wikilibras

ActiveAdmin

Gemfile
1 1 source 'https://rubygems.org'
  2 +
2 3 ruby '2.1.1'
3 4 gem 'rails', '4.1.1'
  5 +
  6 +gem 'activeadmin', github: 'gregbell/active_admin'
  7 +
  8 +gem 'haml-rails'
4 9 gem 'sass-rails', '~> 4.0.3'
  10 +gem 'bootstrap-sass'
5 11 gem 'uglifier', '>= 1.3.0'
6 12 gem 'coffee-rails', '~> 4.0.0'
7 13 gem 'jquery-rails'
  14 +gem 'therubyracer', :platform => :ruby
8 15 gem 'turbolinks'
9   -gem 'jbuilder', '~> 2.0'
10   -gem 'sdoc', '~> 0.4.0', group: :doc
11   -gem 'spring', group: :development
12   -gem 'bootstrap-sass'
  16 +
13 17 gem 'devise'
14   -gem 'haml-rails'
15   -gem 'mysql2'
  18 +gem 'cancan'
  19 +gem 'rolify'
  20 +
16 21 gem 'simple_form'
17   -gem 'therubyracer', :platform=>:ruby
  22 +
  23 +gem 'inherited_resources'
  24 +
18 25 group :development do
19 26 gem 'better_errors'
20 27 gem 'binding_of_caller', :platforms=>[:mri_21]
21 28 gem 'guard-bundler'
22 29 gem 'guard-rails'
23 30 gem 'guard-rspec'
  31 + gem 'guard-livereload', require: false
  32 + gem 'rack-livereload'
  33 + gem 'spring'
24 34 gem 'html2haml'
25 35 gem 'quiet_assets'
26 36 gem 'rails_layout'
27 37 gem 'rb-fchange', :require=>false
28 38 gem 'rb-fsevent', :require=>false
29 39 gem 'rb-inotify', :require=>false
  40 + gem 'awesome_print'
30 41 end
  42 +
31 43 group :development, :test do
32 44 gem 'factory_girl_rails'
33 45 gem 'pry-rails'
34 46 gem 'pry-rescue'
  47 + gem 'pry-debugger'
35 48 gem 'rspec-rails', '>= 3.0.0.beta2'
  49 + gem 'sqlite3'
36 50 end
  51 +
37 52 group :production do
38 53 gem 'thin'
  54 + gem 'mysql2'
39 55 end
  56 +
40 57 group :test do
41 58 gem 'capybara'
42 59 gem 'database_cleaner'
... ...
Gemfile.lock 0 → 100644
... ... @@ -0,0 +1,373 @@
  1 +GIT
  2 + remote: git://github.com/gregbell/active_admin.git
  3 + revision: 89fe847eb3db8b60a743be10e5ba4c29048adef2
  4 + specs:
  5 + activeadmin (1.0.0.pre)
  6 + arbre (~> 1.0)
  7 + bourbon
  8 + coffee-rails
  9 + formtastic (~> 2.3.0.rc3)
  10 + inherited_resources (~> 1.3)
  11 + jquery-rails
  12 + jquery-ui-rails
  13 + kaminari (~> 0.15)
  14 + rails (>= 3.2, < 4.2)
  15 + ransack (~> 1.0)
  16 + sass-rails
  17 +
  18 +GEM
  19 + remote: https://rubygems.org/
  20 + specs:
  21 + actionmailer (4.1.1)
  22 + actionpack (= 4.1.1)
  23 + actionview (= 4.1.1)
  24 + mail (~> 2.5.4)
  25 + actionpack (4.1.1)
  26 + actionview (= 4.1.1)
  27 + activesupport (= 4.1.1)
  28 + rack (~> 1.5.2)
  29 + rack-test (~> 0.6.2)
  30 + actionview (4.1.1)
  31 + activesupport (= 4.1.1)
  32 + builder (~> 3.1)
  33 + erubis (~> 2.7.0)
  34 + activemodel (4.1.1)
  35 + activesupport (= 4.1.1)
  36 + builder (~> 3.1)
  37 + activerecord (4.1.1)
  38 + activemodel (= 4.1.1)
  39 + activesupport (= 4.1.1)
  40 + arel (~> 5.0.0)
  41 + activesupport (4.1.1)
  42 + i18n (~> 0.6, >= 0.6.9)
  43 + json (~> 1.7, >= 1.7.7)
  44 + minitest (~> 5.1)
  45 + thread_safe (~> 0.1)
  46 + tzinfo (~> 1.1)
  47 + addressable (2.3.6)
  48 + arbre (1.0.1)
  49 + activesupport (>= 3.0.0)
  50 + arel (5.0.1.20140414130214)
  51 + awesome_print (1.2.0)
  52 + bcrypt (3.1.7)
  53 + better_errors (1.1.0)
  54 + coderay (>= 1.0.0)
  55 + erubis (>= 2.6.6)
  56 + binding_of_caller (0.7.2)
  57 + debug_inspector (>= 0.0.1)
  58 + bootstrap-sass (3.1.1.1)
  59 + sass (~> 3.2)
  60 + bourbon (3.2.1)
  61 + sass (~> 3.2)
  62 + thor
  63 + builder (3.2.2)
  64 + cancan (1.6.10)
  65 + capybara (2.2.1)
  66 + mime-types (>= 1.16)
  67 + nokogiri (>= 1.3.3)
  68 + rack (>= 1.0.0)
  69 + rack-test (>= 0.5.4)
  70 + xpath (~> 2.0)
  71 + celluloid (0.15.2)
  72 + timers (~> 1.1.0)
  73 + celluloid-io (0.15.0)
  74 + celluloid (>= 0.15.0)
  75 + nio4r (>= 0.5.0)
  76 + childprocess (0.5.3)
  77 + ffi (~> 1.0, >= 1.0.11)
  78 + coderay (1.1.0)
  79 + coffee-rails (4.0.1)
  80 + coffee-script (>= 2.2.0)
  81 + railties (>= 4.0.0, < 5.0)
  82 + coffee-script (2.2.0)
  83 + coffee-script-source
  84 + execjs
  85 + coffee-script-source (1.7.0)
  86 + columnize (0.8.9)
  87 + daemons (1.1.9)
  88 + database_cleaner (1.2.0)
  89 + debug_inspector (0.0.2)
  90 + debugger (1.6.6)
  91 + columnize (>= 0.3.1)
  92 + debugger-linecache (~> 1.2.0)
  93 + debugger-ruby_core_source (~> 1.3.2)
  94 + debugger-linecache (1.2.0)
  95 + debugger-ruby_core_source (1.3.4)
  96 + devise (3.2.4)
  97 + bcrypt (~> 3.0)
  98 + orm_adapter (~> 0.1)
  99 + railties (>= 3.2.6, < 5)
  100 + thread_safe (~> 0.1)
  101 + warden (~> 1.2.3)
  102 + diff-lcs (1.2.5)
  103 + em-websocket (0.5.1)
  104 + eventmachine (>= 0.12.9)
  105 + http_parser.rb (~> 0.6.0)
  106 + erubis (2.7.0)
  107 + eventmachine (1.0.3)
  108 + execjs (2.0.2)
  109 + factory_girl (4.4.0)
  110 + activesupport (>= 3.0.0)
  111 + factory_girl_rails (4.4.1)
  112 + factory_girl (~> 4.4.0)
  113 + railties (>= 3.0.0)
  114 + faker (1.3.0)
  115 + i18n (~> 0.5)
  116 + ffi (1.9.3)
  117 + formatador (0.2.4)
  118 + formtastic (2.3.0.rc3)
  119 + actionpack (>= 3.0)
  120 + guard (2.6.1)
  121 + formatador (>= 0.2.4)
  122 + listen (~> 2.7)
  123 + lumberjack (~> 1.0)
  124 + pry (>= 0.9.12)
  125 + thor (>= 0.18.1)
  126 + guard-bundler (2.0.0)
  127 + bundler (~> 1.0)
  128 + guard (~> 2.2)
  129 + guard-livereload (2.1.2)
  130 + em-websocket (~> 0.5)
  131 + guard (~> 2.0)
  132 + multi_json (~> 1.8)
  133 + guard-rails (0.5.0)
  134 + guard (>= 2.0.0)
  135 + guard-rspec (4.2.2)
  136 + guard (~> 2.1, >= 2.1)
  137 + rspec (~> 3.0.0.beta, >= 2.14, < 4.0)
  138 + haml (4.1.0.beta.1)
  139 + tilt
  140 + haml-rails (0.5.3)
  141 + actionpack (>= 4.0.1)
  142 + activesupport (>= 4.0.1)
  143 + haml (>= 3.1, < 5.0)
  144 + railties (>= 4.0.1)
  145 + has_scope (0.6.0.rc)
  146 + actionpack (>= 3.2, < 5)
  147 + activesupport (>= 3.2, < 5)
  148 + hike (1.2.3)
  149 + hpricot (0.8.6)
  150 + html2haml (1.0.1)
  151 + erubis (~> 2.7.0)
  152 + haml (>= 4.0.0.rc.1)
  153 + hpricot (~> 0.8.6)
  154 + ruby_parser (~> 3.1.1)
  155 + http_parser.rb (0.6.0)
  156 + i18n (0.6.9)
  157 + inherited_resources (1.4.1)
  158 + has_scope (~> 0.6.0.rc)
  159 + responders (~> 1.0.0.rc)
  160 + interception (0.5)
  161 + jquery-rails (3.1.0)
  162 + railties (>= 3.0, < 5.0)
  163 + thor (>= 0.14, < 2.0)
  164 + jquery-ui-rails (4.2.1)
  165 + railties (>= 3.2.16)
  166 + json (1.8.1)
  167 + kaminari (0.15.1)
  168 + actionpack (>= 3.0.0)
  169 + activesupport (>= 3.0.0)
  170 + launchy (2.4.2)
  171 + addressable (~> 2.3)
  172 + libv8 (3.16.14.3)
  173 + listen (2.7.4)
  174 + celluloid (>= 0.15.2)
  175 + celluloid-io (>= 0.15.0)
  176 + rb-fsevent (>= 0.9.3)
  177 + rb-inotify (>= 0.9)
  178 + lumberjack (1.0.5)
  179 + mail (2.5.4)
  180 + mime-types (~> 1.16)
  181 + treetop (~> 1.4.8)
  182 + method_source (0.8.2)
  183 + mime-types (1.25.1)
  184 + mini_portile (0.5.3)
  185 + minitest (5.3.3)
  186 + multi_json (1.10.0)
  187 + mysql2 (0.3.15)
  188 + nio4r (1.0.0)
  189 + nokogiri (1.6.2)
  190 + mini_portile (~> 0.5.2)
  191 + orm_adapter (0.5.0)
  192 + polyamorous (1.0.0)
  193 + activerecord (>= 3.0)
  194 + polyglot (0.3.4)
  195 + pry (0.9.12.6)
  196 + coderay (~> 1.0)
  197 + method_source (~> 0.8)
  198 + slop (~> 3.4)
  199 + pry-debugger (0.2.2)
  200 + debugger (~> 1.3)
  201 + pry (~> 0.9.10)
  202 + pry-rails (0.3.2)
  203 + pry (>= 0.9.10)
  204 + pry-rescue (1.4.1)
  205 + interception (>= 0.5)
  206 + pry
  207 + quiet_assets (1.0.2)
  208 + railties (>= 3.1, < 5.0)
  209 + rack (1.5.2)
  210 + rack-livereload (0.3.15)
  211 + rack
  212 + rack-test (0.6.2)
  213 + rack (>= 1.0)
  214 + rails (4.1.1)
  215 + actionmailer (= 4.1.1)
  216 + actionpack (= 4.1.1)
  217 + actionview (= 4.1.1)
  218 + activemodel (= 4.1.1)
  219 + activerecord (= 4.1.1)
  220 + activesupport (= 4.1.1)
  221 + bundler (>= 1.3.0, < 2.0)
  222 + railties (= 4.1.1)
  223 + sprockets-rails (~> 2.0)
  224 + rails_layout (1.0.16)
  225 + railties (4.1.1)
  226 + actionpack (= 4.1.1)
  227 + activesupport (= 4.1.1)
  228 + rake (>= 0.8.7)
  229 + thor (>= 0.18.1, < 2.0)
  230 + rake (10.3.1)
  231 + ransack (1.2.3)
  232 + actionpack (>= 3.0)
  233 + activerecord (>= 3.0)
  234 + activesupport (>= 3.0)
  235 + i18n
  236 + polyamorous (~> 1.0.0)
  237 + rb-fchange (0.0.6)
  238 + ffi
  239 + rb-fsevent (0.9.4)
  240 + rb-inotify (0.9.4)
  241 + ffi (>= 0.5.0)
  242 + ref (1.0.5)
  243 + responders (1.0.0)
  244 + railties (>= 3.2, < 5)
  245 + rolify (3.4.0)
  246 + rspec (3.0.0.beta2)
  247 + rspec-core (= 3.0.0.beta2)
  248 + rspec-expectations (= 3.0.0.beta2)
  249 + rspec-mocks (= 3.0.0.beta2)
  250 + rspec-collection_matchers (0.0.4)
  251 + rspec-expectations (>= 2.99.0.beta1)
  252 + rspec-core (3.0.0.beta2)
  253 + rspec-support (= 3.0.0.beta2)
  254 + rspec-expectations (3.0.0.beta2)
  255 + diff-lcs (>= 1.2.0, < 2.0)
  256 + rspec-support (= 3.0.0.beta2)
  257 + rspec-mocks (3.0.0.beta2)
  258 + rspec-support (= 3.0.0.beta2)
  259 + rspec-rails (3.0.0.beta2)
  260 + actionpack (>= 3.0)
  261 + activemodel (>= 3.0)
  262 + activesupport (>= 3.0)
  263 + railties (>= 3.0)
  264 + rspec-collection_matchers
  265 + rspec-core (= 3.0.0.beta2)
  266 + rspec-expectations (= 3.0.0.beta2)
  267 + rspec-mocks (= 3.0.0.beta2)
  268 + rspec-support (= 3.0.0.beta2)
  269 + rspec-support (3.0.0.beta2)
  270 + ruby_parser (3.1.3)
  271 + sexp_processor (~> 4.1)
  272 + rubyzip (1.1.3)
  273 + sass (3.2.19)
  274 + sass-rails (4.0.3)
  275 + railties (>= 4.0.0, < 5.0)
  276 + sass (~> 3.2.0)
  277 + sprockets (~> 2.8, <= 2.11.0)
  278 + sprockets-rails (~> 2.0)
  279 + selenium-webdriver (2.41.0)
  280 + childprocess (>= 0.5.0)
  281 + multi_json (~> 1.0)
  282 + rubyzip (~> 1.0)
  283 + websocket (~> 1.0.4)
  284 + sexp_processor (4.4.3)
  285 + simple_form (3.0.2)
  286 + actionpack (~> 4.0)
  287 + activemodel (~> 4.0)
  288 + slop (3.5.0)
  289 + spring (1.1.2)
  290 + sprockets (2.11.0)
  291 + hike (~> 1.2)
  292 + multi_json (~> 1.0)
  293 + rack (~> 1.0)
  294 + tilt (~> 1.1, != 1.3.0)
  295 + sprockets-rails (2.1.3)
  296 + actionpack (>= 3.0)
  297 + activesupport (>= 3.0)
  298 + sprockets (~> 2.8)
  299 + sqlite3 (1.3.9)
  300 + therubyracer (0.12.1)
  301 + libv8 (~> 3.16.14.0)
  302 + ref
  303 + thin (1.6.2)
  304 + daemons (>= 1.0.9)
  305 + eventmachine (>= 1.0.0)
  306 + rack (>= 1.0.0)
  307 + thor (0.19.1)
  308 + thread_safe (0.3.3)
  309 + tilt (1.4.1)
  310 + timers (1.1.0)
  311 + treetop (1.4.15)
  312 + polyglot
  313 + polyglot (>= 0.3.1)
  314 + turbolinks (2.2.2)
  315 + coffee-rails
  316 + tzinfo (1.1.0)
  317 + thread_safe (~> 0.1)
  318 + uglifier (2.5.0)
  319 + execjs (>= 0.3.0)
  320 + json (>= 1.8.0)
  321 + warden (1.2.3)
  322 + rack (>= 1.0)
  323 + websocket (1.0.7)
  324 + xpath (2.0.0)
  325 + nokogiri (~> 1.3)
  326 +
  327 +PLATFORMS
  328 + ruby
  329 +
  330 +DEPENDENCIES
  331 + activeadmin!
  332 + awesome_print
  333 + better_errors
  334 + binding_of_caller
  335 + bootstrap-sass
  336 + cancan
  337 + capybara
  338 + coffee-rails (~> 4.0.0)
  339 + database_cleaner
  340 + devise
  341 + factory_girl_rails
  342 + faker
  343 + guard-bundler
  344 + guard-livereload
  345 + guard-rails
  346 + guard-rspec
  347 + haml-rails
  348 + html2haml
  349 + inherited_resources
  350 + jquery-rails
  351 + launchy
  352 + mysql2
  353 + pry-debugger
  354 + pry-rails
  355 + pry-rescue
  356 + quiet_assets
  357 + rack-livereload
  358 + rails (= 4.1.1)
  359 + rails_layout
  360 + rb-fchange
  361 + rb-fsevent
  362 + rb-inotify
  363 + rolify
  364 + rspec-rails (>= 3.0.0.beta2)
  365 + sass-rails (~> 4.0.3)
  366 + selenium-webdriver
  367 + simple_form
  368 + spring
  369 + sqlite3
  370 + therubyracer
  371 + thin
  372 + turbolinks
  373 + uglifier (>= 1.3.0)
... ...
app/admin/dashboard.rb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +ActiveAdmin.register_page "Dashboard" do
  2 +
  3 + menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
  4 +
  5 + content title: proc{ I18n.t("active_admin.dashboard") } do
  6 + div class: "blank_slate_container", id: "dashboard_default_message" do
  7 + span class: "blank_slate" do
  8 + span I18n.t("active_admin.dashboard_welcome.welcome")
  9 + small I18n.t("active_admin.dashboard_welcome.call_to_action")
  10 + end
  11 + end
  12 +
  13 + # Here is an example of a simple dashboard with columns and panels.
  14 + #
  15 + # columns do
  16 + # column do
  17 + # panel "Recent Posts" do
  18 + # ul do
  19 + # Post.recent(5).map do |post|
  20 + # li link_to(post.title, admin_post_path(post))
  21 + # end
  22 + # end
  23 + # end
  24 + # end
  25 +
  26 + # column do
  27 + # panel "Info" do
  28 + # para "Welcome to ActiveAdmin."
  29 + # end
  30 + # end
  31 + # end
  32 + end # content
  33 +end
... ...
app/admin/user.rb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +ActiveAdmin.register User do
  2 + permit_params :email, :password, :password_confirmation
  3 +
  4 + index do
  5 + selectable_column
  6 + id_column
  7 + column :email
  8 + column :current_sign_in_at
  9 + column :sign_in_count
  10 + column :created_at
  11 + actions
  12 + end
  13 +
  14 + filter :email
  15 + filter :current_sign_in_at
  16 + filter :sign_in_count
  17 + filter :created_at
  18 +
  19 + form do |f|
  20 + f.inputs "Admin Details" do
  21 + f.input :email
  22 + f.input :password
  23 + f.input :password_confirmation
  24 + end
  25 + f.actions
  26 + end
  27 +
  28 +end
... ...
app/assets/javascripts/active_admin.js.coffee 0 → 100644
... ... @@ -0,0 +1 @@
  1 +#= require active_admin/base
... ...
app/assets/stylesheets/active_admin.css.scss 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +// SASS variable overrides must be declared before loading up Active Admin's styles.
  2 +//
  3 +// To view the variables that Active Admin provides, take a look at
  4 +// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
  5 +// Active Admin source.
  6 +//
  7 +// For example, to change the sidebar width:
  8 +// $sidebar-width: 242px;
  9 +
  10 +// Active Admin's got SASS!
  11 +@import "active_admin/mixins";
  12 +@import "active_admin/base";
  13 +
  14 +// Overriding any non-variable SASS must be done after the fact.
  15 +// For example, to change the default status-tag color:
  16 +//
  17 +// .status_tag { background: #6090DB; }
... ...
app/models/user.rb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +class User < ActiveRecord::Base
  2 + # Include default devise modules. Others available are:
  3 + # :confirmable, :lockable, :timeoutable and :omniauthable
  4 + devise :database_authenticatable,
  5 + :recoverable, :rememberable, :trackable, :validatable
  6 +end
... ...
config/initializers/active_admin.rb 0 → 100644
... ... @@ -0,0 +1,245 @@
  1 +ActiveAdmin.setup do |config|
  2 +
  3 + # == Site Title
  4 + #
  5 + # Set the title that is displayed on the main layout
  6 + # for each of the active admin pages.
  7 + #
  8 + config.site_title = "VLibras"
  9 +
  10 + # Set the link url for the title. For example, to take
  11 + # users to your main site. Defaults to no link.
  12 + #
  13 + config.site_title_link = "/admin"
  14 +
  15 + # Set an optional image to be displayed for the header
  16 + # instead of a string (overrides :site_title)
  17 + #
  18 + # Note: Aim for an image that's 21px high so it fits in the header.
  19 + #
  20 + # config.site_title_image = "logo.png"
  21 +
  22 + # == Default Namespace
  23 + #
  24 + # Set the default namespace each administration resource
  25 + # will be added to.
  26 + #
  27 + # eg:
  28 + # config.default_namespace = :hello_world
  29 + #
  30 + # This will create resources in the HelloWorld module and
  31 + # will namespace routes to /hello_world/*
  32 + #
  33 + # To set no namespace by default, use:
  34 + # config.default_namespace = false
  35 + #
  36 + # Default:
  37 + config.default_namespace = :admin
  38 + #
  39 + # You can customize the settings for each namespace by using
  40 + # a namespace block. For example, to change the site title
  41 + # within a namespace:
  42 + #
  43 + # config.namespace :admin do |admin|
  44 + # admin.site_title = "Custom Admin Title"
  45 + # end
  46 + #
  47 + # This will ONLY change the title for the admin section. Other
  48 + # namespaces will continue to use the main "site_title" configuration.
  49 +
  50 + # == User Authentication
  51 + #
  52 + # Active Admin will automatically call an authentication
  53 + # method in a before filter of all controller actions to
  54 + # ensure that there is a currently logged in admin user.
  55 + #
  56 + # This setting changes the method which Active Admin calls
  57 + # within the application controller.
  58 + config.authentication_method = :authenticate_user!
  59 +
  60 + # == User Authorization
  61 + #
  62 + # Active Admin will automatically call an authorization
  63 + # method in a before filter of all controller actions to
  64 + # ensure that there is a user with proper rights. You can use
  65 + # CanCanAdapter or make your own. Please refer to documentation.
  66 + config.authorization_adapter = ActiveAdmin::CanCanAdapter
  67 +
  68 + # You can customize your CanCan Ability class name here.
  69 + config.cancan_ability_class = "Ability"
  70 +
  71 + # You can specify a method to be called on unauthorized access.
  72 + # This is necessary in order to prevent a redirect loop which happens
  73 + # because, by default, user gets redirected to Dashboard. If user
  74 + # doesn't have access to Dashboard, he'll end up in a redirect loop.
  75 + # Method provided here should be defined in application_controller.rb.
  76 + # config.on_unauthorized_access = :access_denied
  77 +
  78 + # == Current User
  79 + #
  80 + # Active Admin will associate actions with the current
  81 + # user performing them.
  82 + #
  83 + # This setting changes the method which Active Admin calls
  84 + # (within the application controller) to return the currently logged in user.
  85 + config.current_user_method = :current_user
  86 +
  87 +
  88 + # == Logging Out
  89 + #
  90 + # Active Admin displays a logout link on each screen. These
  91 + # settings configure the location and method used for the link.
  92 + #
  93 + # This setting changes the path where the link points to. If it's
  94 + # a string, the strings is used as the path. If it's a Symbol, we
  95 + # will call the method to return the path.
  96 + #
  97 + # Default:
  98 + config.logout_link_path = :destroy_user_session_path
  99 +
  100 + # This setting changes the http method used when rendering the
  101 + # link. For example :get, :delete, :put, etc..
  102 + #
  103 + # Default:
  104 + # config.logout_link_method = :get
  105 +
  106 +
  107 + # == Root
  108 + #
  109 + # Set the action to call for the root path. You can set different
  110 + # roots for each namespace.
  111 + #
  112 + # Default:
  113 + config.root_to = 'dashboard#index'
  114 +
  115 +
  116 + # == Admin Comments
  117 + #
  118 + # This allows your users to comment on any resource registered with Active Admin.
  119 + #
  120 + # You can completely disable comments:
  121 + # config.allow_comments = false
  122 + #
  123 + # You can disable the menu item for the comments index page:
  124 + # config.show_comments_in_menu = false
  125 + #
  126 + # You can change the name under which comments are registered:
  127 + # config.comments_registration_name = 'AdminComment'
  128 +
  129 +
  130 + # == Batch Actions
  131 + #
  132 + # Enable and disable Batch Actions
  133 + #
  134 + config.batch_actions = true
  135 +
  136 +
  137 + # == Controller Filters
  138 + #
  139 + # You can add before, after and around filters to all of your
  140 + # Active Admin resources and pages from here.
  141 + #
  142 + # config.before_filter :do_something_awesome
  143 +
  144 +
  145 + # == Setting a Favicon
  146 + #
  147 + # config.favicon = '/assets/favicon.ico'
  148 +
  149 +
  150 + # == Removing Breadcrumbs
  151 + #
  152 + # Breadcrumbs are enabled by default. You can customize them for individual
  153 + # resources or you can disable them globally from here.
  154 + #
  155 + # config.breadcrumb = false
  156 +
  157 +
  158 + # == Register Stylesheets & Javascripts
  159 + #
  160 + # We recommend using the built in Active Admin layout and loading
  161 + # up your own stylesheets / javascripts to customize the look
  162 + # and feel.
  163 + #
  164 + # To load a stylesheet:
  165 + # config.register_stylesheet 'my_stylesheet.css'
  166 + #
  167 + # You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
  168 + # config.register_stylesheet 'my_print_stylesheet.css', :media => :print
  169 + #
  170 + # To load a javascript file:
  171 + # config.register_javascript 'my_javascript.js'
  172 +
  173 +
  174 + # == CSV options
  175 + #
  176 + # Set the CSV builder separator
  177 + # config.csv_options = { :col_sep => ';' }
  178 + #
  179 + # Force the use of quotes
  180 + # config.csv_options = { :force_quotes => true }
  181 +
  182 +
  183 + # == Menu System
  184 + #
  185 + # You can add a navigation menu to be used in your application, or configure a provided menu
  186 + #
  187 + # To change the default utility navigation to show a link to your website & a logout btn
  188 + #
  189 + # config.namespace :admin do |admin|
  190 + # admin.build_menu :utility_navigation do |menu|
  191 + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
  192 + # admin.add_logout_button_to_menu menu
  193 + # end
  194 + # end
  195 + #
  196 + # If you wanted to add a static menu item to the default menu provided:
  197 + #
  198 + # config.namespace :admin do |admin|
  199 + # admin.build_menu :default do |menu|
  200 + # menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
  201 + # end
  202 + # end
  203 +
  204 +
  205 + # == Download Links
  206 + #
  207 + # You can disable download links on resource listing pages,
  208 + # or customize the formats shown per namespace/globally
  209 + #
  210 + # To disable/customize for the :admin namespace:
  211 + #
  212 + # config.namespace :admin do |admin|
  213 + #
  214 + # # Disable the links entirely
  215 + # admin.download_links = false
  216 + #
  217 + # # Only show XML & PDF options
  218 + # admin.download_links = [:xml, :pdf]
  219 + #
  220 + # # Enable/disable the links based on block
  221 + # # (for example, with cancan)
  222 + # admin.download_links = proc { can?(:view_download_links) }
  223 + #
  224 + # end
  225 +
  226 +
  227 + # == Pagination
  228 + #
  229 + # Pagination is enabled by default for all resources.
  230 + # You can control the default per page count for all resources here.
  231 + #
  232 + # config.default_per_page = 30
  233 +
  234 +
  235 + # == Filters
  236 + #
  237 + # By default the index screen includes a “Filters” sidebar on the right
  238 + # hand side with a filter for each attribute of the registered model.
  239 + # You can enable or disable them for all resources here.
  240 + #
  241 + # config.filters = true
  242 +
  243 + config.allow_comments = false
  244 + config.show_comments_in_menu = false
  245 +end
... ...
config/initializers/devise.rb 0 → 100644
... ... @@ -0,0 +1,256 @@
  1 +# Use this hook to configure devise mailer, warden hooks and so forth.
  2 +# Many of these configuration options can be set straight in your model.
  3 +Devise.setup do |config|
  4 + # The secret key used by Devise. Devise uses this key to generate
  5 + # random tokens. Changing this key will render invalid all existing
  6 + # confirmation, reset password and unlock tokens in the database.
  7 + # config.secret_key = '97effc2d0b60a3b7d51fffe965c758e138db46402da394622c5af00917b2bf649971b6bbc8271fecdd766d953472f53d3bb88a9120806426c03e511b5f23a88c'
  8 +
  9 + # ==> Mailer Configuration
  10 + # Configure the e-mail address which will be shown in Devise::Mailer,
  11 + # note that it will be overwritten if you use your own mailer class
  12 + # with default "from" parameter.
  13 + config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
  14 +
  15 + # Configure the class responsible to send e-mails.
  16 + # config.mailer = 'Devise::Mailer'
  17 +
  18 + # ==> ORM configuration
  19 + # Load and configure the ORM. Supports :active_record (default) and
  20 + # :mongoid (bson_ext recommended) by default. Other ORMs may be
  21 + # available as additional gems.
  22 + require 'devise/orm/active_record'
  23 +
  24 + # ==> Configuration for any authentication mechanism
  25 + # Configure which keys are used when authenticating a user. The default is
  26 + # just :email. You can configure it to use [:username, :subdomain], so for
  27 + # authenticating a user, both parameters are required. Remember that those
  28 + # parameters are used only when authenticating and not when retrieving from
  29 + # session. If you need permissions, you should implement that in a before filter.
  30 + # You can also supply a hash where the value is a boolean determining whether
  31 + # or not authentication should be aborted when the value is not present.
  32 + # config.authentication_keys = [ :email ]
  33 +
  34 + # Configure parameters from the request object used for authentication. Each entry
  35 + # given should be a request method and it will automatically be passed to the
  36 + # find_for_authentication method and considered in your model lookup. For instance,
  37 + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
  38 + # The same considerations mentioned for authentication_keys also apply to request_keys.
  39 + # config.request_keys = []
  40 +
  41 + # Configure which authentication keys should be case-insensitive.
  42 + # These keys will be downcased upon creating or modifying a user and when used
  43 + # to authenticate or find a user. Default is :email.
  44 + config.case_insensitive_keys = [ :email ]
  45 +
  46 + # Configure which authentication keys should have whitespace stripped.
  47 + # These keys will have whitespace before and after removed upon creating or
  48 + # modifying a user and when used to authenticate or find a user. Default is :email.
  49 + config.strip_whitespace_keys = [ :email ]
  50 +
  51 + # Tell if authentication through request.params is enabled. True by default.
  52 + # It can be set to an array that will enable params authentication only for the
  53 + # given strategies, for example, `config.params_authenticatable = [:database]` will
  54 + # enable it only for database (email + password) authentication.
  55 + # config.params_authenticatable = true
  56 +
  57 + # Tell if authentication through HTTP Auth is enabled. False by default.
  58 + # It can be set to an array that will enable http authentication only for the
  59 + # given strategies, for example, `config.http_authenticatable = [:database]` will
  60 + # enable it only for database authentication. The supported strategies are:
  61 + # :database = Support basic authentication with authentication key + password
  62 + # config.http_authenticatable = false
  63 +
  64 + # If http headers should be returned for AJAX requests. True by default.
  65 + # config.http_authenticatable_on_xhr = true
  66 +
  67 + # The realm used in Http Basic Authentication. 'Application' by default.
  68 + # config.http_authentication_realm = 'Application'
  69 +
  70 + # It will change confirmation, password recovery and other workflows
  71 + # to behave the same regardless if the e-mail provided was right or wrong.
  72 + # Does not affect registerable.
  73 + # config.paranoid = true
  74 +
  75 + # By default Devise will store the user in session. You can skip storage for
  76 + # particular strategies by setting this option.
  77 + # Notice that if you are skipping storage for all authentication paths, you
  78 + # may want to disable generating routes to Devise's sessions controller by
  79 + # passing skip: :sessions to `devise_for` in your config/routes.rb
  80 + config.skip_session_storage = [:http_auth]
  81 +
  82 + # By default, Devise cleans up the CSRF token on authentication to
  83 + # avoid CSRF token fixation attacks. This means that, when using AJAX
  84 + # requests for sign in and sign up, you need to get a new CSRF token
  85 + # from the server. You can disable this option at your own risk.
  86 + # config.clean_up_csrf_token_on_authentication = true
  87 +
  88 + # ==> Configuration for :database_authenticatable
  89 + # For bcrypt, this is the cost for hashing the password and defaults to 10. If
  90 + # using other encryptors, it sets how many times you want the password re-encrypted.
  91 + #
  92 + # Limiting the stretches to just one in testing will increase the performance of
  93 + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
  94 + # a value less than 10 in other environments. Note that, for bcrypt (the default
  95 + # encryptor), the cost increases exponentially with the number of stretches (e.g.
  96 + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
  97 + config.stretches = Rails.env.test? ? 1 : 10
  98 +
  99 + # Setup a pepper to generate the encrypted password.
  100 + # config.pepper = '2907dad46ee52172663da4398e3197c50517be04581626455d75df94ddc21ea16e57e553e71f0302ccb14f1078582cf7d678dc0bac4c2068da7e25fea0d1896e'
  101 +
  102 + # ==> Configuration for :confirmable
  103 + # A period that the user is allowed to access the website even without
  104 + # confirming their account. For instance, if set to 2.days, the user will be
  105 + # able to access the website for two days without confirming their account,
  106 + # access will be blocked just in the third day. Default is 0.days, meaning
  107 + # the user cannot access the website without confirming their account.
  108 + # config.allow_unconfirmed_access_for = 2.days
  109 +
  110 + # A period that the user is allowed to confirm their account before their
  111 + # token becomes invalid. For example, if set to 3.days, the user can confirm
  112 + # their account within 3 days after the mail was sent, but on the fourth day
  113 + # their account can't be confirmed with the token any more.
  114 + # Default is nil, meaning there is no restriction on how long a user can take
  115 + # before confirming their account.
  116 + # config.confirm_within = 3.days
  117 +
  118 + # If true, requires any email changes to be confirmed (exactly the same way as
  119 + # initial account confirmation) to be applied. Requires additional unconfirmed_email
  120 + # db field (see migrations). Until confirmed, new email is stored in
  121 + # unconfirmed_email column, and copied to email column on successful confirmation.
  122 + config.reconfirmable = true
  123 +
  124 + # Defines which key will be used when confirming an account
  125 + # config.confirmation_keys = [ :email ]
  126 +
  127 + # ==> Configuration for :rememberable
  128 + # The time the user will be remembered without asking for credentials again.
  129 + # config.remember_for = 2.weeks
  130 +
  131 + # If true, extends the user's remember period when remembered via cookie.
  132 + # config.extend_remember_period = false
  133 +
  134 + # Options to be passed to the created cookie. For instance, you can set
  135 + # secure: true in order to force SSL only cookies.
  136 + # config.rememberable_options = {}
  137 +
  138 + # ==> Configuration for :validatable
  139 + # Range for password length.
  140 + config.password_length = 6..128
  141 +
  142 + # Email regex used to validate email formats. It simply asserts that
  143 + # one (and only one) @ exists in the given string. This is mainly
  144 + # to give user feedback and not to assert the e-mail validity.
  145 + # config.email_regexp = /\A[^@]+@[^@]+\z/
  146 +
  147 + # ==> Configuration for :timeoutable
  148 + # The time you want to timeout the user session without activity. After this
  149 + # time the user will be asked for credentials again. Default is 30 minutes.
  150 + # config.timeout_in = 30.minutes
  151 +
  152 + # If true, expires auth token on session timeout.
  153 + # config.expire_auth_token_on_timeout = false
  154 +
  155 + # ==> Configuration for :lockable
  156 + # Defines which strategy will be used to lock an account.
  157 + # :failed_attempts = Locks an account after a number of failed attempts to sign in.
  158 + # :none = No lock strategy. You should handle locking by yourself.
  159 + # config.lock_strategy = :failed_attempts
  160 +
  161 + # Defines which key will be used when locking and unlocking an account
  162 + # config.unlock_keys = [ :email ]
  163 +
  164 + # Defines which strategy will be used to unlock an account.
  165 + # :email = Sends an unlock link to the user email
  166 + # :time = Re-enables login after a certain amount of time (see :unlock_in below)
  167 + # :both = Enables both strategies
  168 + # :none = No unlock strategy. You should handle unlocking by yourself.
  169 + # config.unlock_strategy = :both
  170 +
  171 + # Number of authentication tries before locking an account if lock_strategy
  172 + # is failed attempts.
  173 + # config.maximum_attempts = 20
  174 +
  175 + # Time interval to unlock the account if :time is enabled as unlock_strategy.
  176 + # config.unlock_in = 1.hour
  177 +
  178 + # Warn on the last attempt before the account is locked.
  179 + # config.last_attempt_warning = false
  180 +
  181 + # ==> Configuration for :recoverable
  182 + #
  183 + # Defines which key will be used when recovering the password for an account
  184 + # config.reset_password_keys = [ :email ]
  185 +
  186 + # Time interval you can reset your password with a reset password key.
  187 + # Don't put a too small interval or your users won't have the time to
  188 + # change their passwords.
  189 + config.reset_password_within = 6.hours
  190 +
  191 + # ==> Configuration for :encryptable
  192 + # Allow you to use another encryption algorithm besides bcrypt (default). You can use
  193 + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
  194 + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
  195 + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
  196 + # REST_AUTH_SITE_KEY to pepper).
  197 + #
  198 + # Require the `devise-encryptable` gem when using anything other than bcrypt
  199 + # config.encryptor = :sha512
  200 +
  201 + # ==> Scopes configuration
  202 + # Turn scoped views on. Before rendering "sessions/new", it will first check for
  203 + # "users/sessions/new". It's turned off by default because it's slower if you
  204 + # are using only default views.
  205 + # config.scoped_views = false
  206 +
  207 + # Configure the default scope given to Warden. By default it's the first
  208 + # devise role declared in your routes (usually :user).
  209 + # config.default_scope = :user
  210 +
  211 + # Set this configuration to false if you want /users/sign_out to sign out
  212 + # only the current scope. By default, Devise signs out all scopes.
  213 + # config.sign_out_all_scopes = true
  214 +
  215 + # ==> Navigation configuration
  216 + # Lists the formats that should be treated as navigational. Formats like
  217 + # :html, should redirect to the sign in page when the user does not have
  218 + # access, but formats like :xml or :json, should return 401.
  219 + #
  220 + # If you have any extra navigational formats, like :iphone or :mobile, you
  221 + # should add them to the navigational formats lists.
  222 + #
  223 + # The "*/*" below is required to match Internet Explorer requests.
  224 + # config.navigational_formats = ['*/*', :html]
  225 +
  226 + # The default HTTP method used to sign out a resource. Default is :delete.
  227 + config.sign_out_via = :delete
  228 +
  229 + # ==> OmniAuth
  230 + # Add a new OmniAuth provider. Check the wiki for more information on setting
  231 + # up on your models and hooks.
  232 + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
  233 +
  234 + # ==> Warden configuration
  235 + # If you want to use other strategies, that are not supported by Devise, or
  236 + # change the failure app, you can configure them inside the config.warden block.
  237 + #
  238 + # config.warden do |manager|
  239 + # manager.intercept_401 = false
  240 + # manager.default_strategies(scope: :user).unshift :some_external_strategy
  241 + # end
  242 +
  243 + # ==> Mountable engine configurations
  244 + # When using Devise inside an engine, let's call it `MyEngine`, and this engine
  245 + # is mountable, there are some extra configurations to be taken into account.
  246 + # The following options are available, assuming the engine is mounted as:
  247 + #
  248 + # mount MyEngine, at: '/my_engine'
  249 + #
  250 + # The router that invoked `devise_for`, in the example above, would be:
  251 + # config.router_name = :my_engine
  252 + #
  253 + # When using omniauth, Devise cannot automatically set Omniauth path,
  254 + # so you need to do it manually. For the users scope, it would be:
  255 + # config.omniauth_path_prefix = '/my_engine/users/auth'
  256 +end
... ...
config/locales/devise.en.yml 0 → 100644
... ... @@ -0,0 +1,59 @@
  1 +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
  2 +
  3 +en:
  4 + devise:
  5 + confirmations:
  6 + confirmed: "Your account was successfully confirmed."
  7 + send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
  8 + send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
  9 + failure:
  10 + already_authenticated: "You are already signed in."
  11 + inactive: "Your account is not activated yet."
  12 + invalid: "Invalid email or password."
  13 + locked: "Your account is locked."
  14 + last_attempt: "You have one more attempt before your account will be locked."
  15 + not_found_in_database: "Invalid email or password."
  16 + timeout: "Your session expired. Please sign in again to continue."
  17 + unauthenticated: "You need to sign in or sign up before continuing."
  18 + unconfirmed: "You have to confirm your account before continuing."
  19 + mailer:
  20 + confirmation_instructions:
  21 + subject: "Confirmation instructions"
  22 + reset_password_instructions:
  23 + subject: "Reset password instructions"
  24 + unlock_instructions:
  25 + subject: "Unlock Instructions"
  26 + omniauth_callbacks:
  27 + failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
  28 + success: "Successfully authenticated from %{kind} account."
  29 + passwords:
  30 + no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
  31 + send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
  32 + send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
  33 + updated: "Your password was changed successfully. You are now signed in."
  34 + updated_not_active: "Your password was changed successfully."
  35 + registrations:
  36 + destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
  37 + signed_up: "Welcome! You have signed up successfully."
  38 + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
  39 + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
  40 + signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
  41 + update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
  42 + updated: "You updated your account successfully."
  43 + sessions:
  44 + signed_in: "Signed in successfully."
  45 + signed_out: "Signed out successfully."
  46 + unlocks:
  47 + send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
  48 + send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
  49 + unlocked: "Your account has been unlocked successfully. Please sign in to continue."
  50 + errors:
  51 + messages:
  52 + already_confirmed: "was already confirmed, please try signing in"
  53 + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
  54 + expired: "has expired, please request a new one"
  55 + not_found: "not found"
  56 + not_locked: "was not locked"
  57 + not_saved:
  58 + one: "1 error prohibited this %{resource} from being saved:"
  59 + other: "%{count} errors prohibited this %{resource} from being saved:"
... ...
config/routes.rb
1 1 Rails.application.routes.draw do
  2 + devise_for :users, ActiveAdmin::Devise.config
  3 +
  4 + ActiveAdmin.routes(self)
2 5 end
... ...
db/migrate/20140513065840_devise_create_admin_users.rb 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +class DeviseCreateAdminUsers < ActiveRecord::Migration
  2 + def migrate(direction)
  3 + super
  4 + # Create a default user
  5 + # User.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up
  6 + end
  7 +
  8 + def change
  9 + create_table(:users) do |t|
  10 + t.string :name
  11 +
  12 + ## Database authenticatable
  13 + t.string :email, null: false, default: ""
  14 + t.string :encrypted_password, null: false, default: ""
  15 +
  16 + ## Recoverable
  17 + t.string :reset_password_token
  18 + t.datetime :reset_password_sent_at
  19 +
  20 + ## Rememberable
  21 + t.datetime :remember_created_at
  22 +
  23 + ## Trackable
  24 + t.integer :sign_in_count, default: 0, null: false
  25 + t.datetime :current_sign_in_at
  26 + t.datetime :last_sign_in_at
  27 + t.string :current_sign_in_ip
  28 + t.string :last_sign_in_ip
  29 +
  30 + ## Confirmable
  31 + # t.string :confirmation_token
  32 + # t.datetime :confirmed_at
  33 + # t.datetime :confirmation_sent_at
  34 + # t.string :unconfirmed_email # Only if using reconfirmable
  35 +
  36 + ## Lockable
  37 + # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
  38 + # t.string :unlock_token # Only if unlock strategy is :email or :both
  39 + # t.datetime :locked_at
  40 +
  41 +
  42 + t.timestamps
  43 + end
  44 +
  45 + add_index :users, :email, unique: true
  46 + add_index :users, :reset_password_token, unique: true
  47 + # add_index :admin_users, :confirmation_token, unique: true
  48 + # add_index :admin_users, :unlock_token, unique: true
  49 + end
  50 +end
... ...
db/schema.rb 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +# encoding: UTF-8
  2 +# This file is auto-generated from the current state of the database. Instead
  3 +# of editing this file, please use the migrations feature of Active Record to
  4 +# incrementally modify your database, and then regenerate this schema definition.
  5 +#
  6 +# Note that this schema.rb definition is the authoritative source for your
  7 +# database schema. If you need to create the application database on another
  8 +# system, you should be using db:schema:load, not running all the migrations
  9 +# from scratch. The latter is a flawed and unsustainable approach (the more migrations
  10 +# you'll amass, the slower it'll run and the greater likelihood for issues).
  11 +#
  12 +# It's strongly recommended that you check this file into your version control system.
  13 +
  14 +ActiveRecord::Schema.define(version: 20140513065840) do
  15 +
  16 + create_table "users", force: true do |t|
  17 + t.string "name"
  18 + t.string "email", default: "", null: false
  19 + t.string "encrypted_password", default: "", null: false
  20 + t.string "reset_password_token"
  21 + t.datetime "reset_password_sent_at"
  22 + t.datetime "remember_created_at"
  23 + t.integer "sign_in_count", default: 0, null: false
  24 + t.datetime "current_sign_in_at"
  25 + t.datetime "last_sign_in_at"
  26 + t.string "current_sign_in_ip"
  27 + t.string "last_sign_in_ip"
  28 + t.datetime "created_at"
  29 + t.datetime "updated_at"
  30 + end
  31 +
  32 + add_index "users", ["email"], name: "index_users_on_email", unique: true
  33 + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  34 +
  35 +end
... ...