24 |
25 |
26 |
27 | <%= link_to 'New Photo', new_photo_path %>
28 |
--------------------------------------------------------------------------------
/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Version of your assets, change this if you want to expire all your assets.
4 | Rails.application.config.assets.version = '1.0'
5 |
6 | # Add additional assets to the asset load path.
7 | # Rails.application.config.assets.paths << Emoji.images_path
8 | # Add Yarn node_modules folder to the asset load path.
9 | Rails.application.config.assets.paths << Rails.root.join('node_modules')
10 |
11 | # Precompile additional assets.
12 | # application.js, application.css, and all non-JS/CSS in the app/assets
13 | # folder are already added.
14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css )
15 |
--------------------------------------------------------------------------------
/app/controllers/admin/announcements_controller.rb:
--------------------------------------------------------------------------------
1 | module Admin
2 | class AnnouncementsController < Admin::ApplicationController
3 | # To customize the behavior of this controller,
4 | # you can overwrite any of the RESTful actions. For example:
5 | #
6 | # def index
7 | # super
8 | # @resources = Announcement.
9 | # page(params[:page]).
10 | # per(10)
11 | # end
12 |
13 | # Define a custom finder by overriding the `find_resource` method:
14 | # def find_resource(param)
15 | # Announcement.find_by!(slug: param)
16 | # end
17 |
18 | # See https://administrate-prototype.herokuapp.com/customizing_controller_actions
19 | # for more information
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require_relative 'boot'
2 |
3 | require 'rails/all'
4 |
5 | # Require the gems listed in Gemfile, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(*Rails.groups)
8 |
9 | module TrixExample
10 | class Application < Rails::Application
11 | config.active_job.queue_adapter = :sidekiq
12 | # Initialize configuration defaults for originally generated Rails version.
13 | config.load_defaults 5.1
14 |
15 | # Settings in config/environments/* take precedence over those specified here.
16 | # Application configuration should go into files in config/initializers
17 | # -- all .rb files in that directory are automatically loaded.
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/app/views/posts/index.html.erb:
--------------------------------------------------------------------------------
1 |
24 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # The following keys must be escaped otherwise they will not be retrieved by
20 | # the default I18n backend:
21 | #
22 | # true, false, on, off, yes, no
23 | #
24 | # Instead, surround them with single quotes.
25 | #
26 | # en:
27 | # 'true': 'foo'
28 | #
29 | # To learn more, please read the Rails Internationalization guide
30 | # available at http://guides.rubyonrails.org/i18n.html.
31 |
32 | en:
33 | hello: "Hello world"
34 |
--------------------------------------------------------------------------------
/app/controllers/admin/application_controller.rb:
--------------------------------------------------------------------------------
1 | # All Administrate controllers inherit from this `Admin::ApplicationController`,
2 | # making it the ideal place to put authentication logic or other
3 | # before_actions.
4 | #
5 | # If you want to add pagination or other controller-level concerns,
6 | # you're free to overwrite the RESTful controller actions.
7 | module Admin
8 | class ApplicationController < Administrate::ApplicationController
9 | before_action :authenticate_admin
10 | before_action :default_params
11 |
12 | def authenticate_admin
13 | redirect_to '/', alert: 'Not authorized.' unless user_signed_in? && current_user.admin?
14 | end
15 |
16 | def default_params
17 | params[:order] ||= "created_at"
18 | params[:direction] ||= "desc"
19 | end
20 |
21 | # Override this value to specify the number of elements to display at a time
22 | # on index pages. Defaults to 20.
23 | # def records_per_page
24 | # params[:per_page] || 20
25 | # end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/app/views/announcements/index.html.erb:
--------------------------------------------------------------------------------
1 |
What's New
2 |
3 |
4 |
5 | <% @announcements.each_with_index do |announcement, index| %>
6 | <% if index != 0 %>
7 |
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Do not eager load code on boot. This avoids loading your whole application
11 | # just for the purpose of running a single test. If you are using a tool that
12 | # preloads Rails for running tests, you may have to set it to true.
13 | config.eager_load = false
14 |
15 | # Configure public file server for tests with Cache-Control for performance.
16 | config.public_file_server.enabled = true
17 | config.public_file_server.headers = {
18 | 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}"
19 | }
20 |
21 | # Show full error reports and disable caching.
22 | config.consider_all_requests_local = true
23 | config.action_controller.perform_caching = false
24 |
25 | # Raise exceptions instead of rendering exception templates.
26 | config.action_dispatch.show_exceptions = false
27 |
28 | # Disable request forgery protection in test environment.
29 | config.action_controller.allow_forgery_protection = false
30 | config.action_mailer.perform_caching = false
31 |
32 | # Tell Action Mailer not to deliver emails to the real world.
33 | # The :test delivery method accumulates sent emails in the
34 | # ActionMailer::Base.deliveries array.
35 | config.action_mailer.delivery_method = :test
36 |
37 | # Print deprecation notices to the stderr.
38 | config.active_support.deprecation = :stderr
39 |
40 | # Raises error for missing translations
41 | # config.action_view.raise_on_missing_translations = true
42 | end
43 |
--------------------------------------------------------------------------------
/app/dashboards/announcement_dashboard.rb:
--------------------------------------------------------------------------------
1 | require "administrate/base_dashboard"
2 |
3 | class AnnouncementDashboard < Administrate::BaseDashboard
4 | # ATTRIBUTE_TYPES
5 | # a hash that describes the type of each of the model's fields.
6 | #
7 | # Each different type represents an Administrate::Field object,
8 | # which determines how the attribute is displayed
9 | # on pages throughout the dashboard.
10 | ATTRIBUTE_TYPES = {
11 | id: Field::Number,
12 | published_at: Field::DateTime,
13 | announcement_type: Field::Select.with_options(collection: Announcement::TYPES),
14 | name: Field::String,
15 | description: Field::Text,
16 | created_at: Field::DateTime,
17 | updated_at: Field::DateTime,
18 | }.freeze
19 |
20 | # COLLECTION_ATTRIBUTES
21 | # an array of attributes that will be displayed on the model's index page.
22 | #
23 | # By default, it's limited to four items to reduce clutter on index pages.
24 | # Feel free to add, remove, or rearrange items.
25 | COLLECTION_ATTRIBUTES = [
26 | :id,
27 | :published_at,
28 | :announcement_type,
29 | :name,
30 | ].freeze
31 |
32 | # SHOW_PAGE_ATTRIBUTES
33 | # an array of attributes that will be displayed on the model's show page.
34 | SHOW_PAGE_ATTRIBUTES = [
35 | :id,
36 | :published_at,
37 | :announcement_type,
38 | :name,
39 | :description,
40 | :created_at,
41 | :updated_at,
42 | ].freeze
43 |
44 | # FORM_ATTRIBUTES
45 | # an array of attributes that will be displayed
46 | # on the model's form (`new` and `edit`) pages.
47 | FORM_ATTRIBUTES = [
48 | :published_at,
49 | :announcement_type,
50 | :name,
51 | :description,
52 | ].freeze
53 |
54 | # Overwrite this method to customize how announcements are displayed
55 | # across all pages of the admin dashboard.
56 | #
57 | # def display_resource(announcement)
58 | # "Announcement ##{announcement.id}"
59 | # end
60 | end
61 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/controllers/posts_controller.rb:
--------------------------------------------------------------------------------
1 | class PostsController < ApplicationController
2 | before_action :set_post, only: [:show, :edit, :update, :destroy]
3 |
4 | # GET /posts
5 | # GET /posts.json
6 | def index
7 | @posts = Post.all
8 | end
9 |
10 | # GET /posts/1
11 | # GET /posts/1.json
12 | def show
13 | end
14 |
15 | # GET /posts/new
16 | def new
17 | @post = Post.new
18 | end
19 |
20 | # GET /posts/1/edit
21 | def edit
22 | end
23 |
24 | # POST /posts
25 | # POST /posts.json
26 | def create
27 | @post = Post.new(post_params)
28 |
29 | respond_to do |format|
30 | if @post.save
31 | format.html { redirect_to @post, notice: 'Post was successfully created.' }
32 | format.json { render :show, status: :created, location: @post }
33 | else
34 | format.html { render :new }
35 | format.json { render json: @post.errors, status: :unprocessable_entity }
36 | end
37 | end
38 | end
39 |
40 | # PATCH/PUT /posts/1
41 | # PATCH/PUT /posts/1.json
42 | def update
43 | respond_to do |format|
44 | if @post.update(post_params)
45 | format.html { redirect_to @post, notice: 'Post was successfully updated.' }
46 | format.json { render :show, status: :ok, location: @post }
47 | else
48 | format.html { render :edit }
49 | format.json { render json: @post.errors, status: :unprocessable_entity }
50 | end
51 | end
52 | end
53 |
54 | # DELETE /posts/1
55 | # DELETE /posts/1.json
56 | def destroy
57 | @post.destroy
58 | respond_to do |format|
59 | format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
60 | format.json { head :no_content }
61 | end
62 | end
63 |
64 | private
65 | # Use callbacks to share common setup or constraints between actions.
66 | def set_post
67 | @post = Post.find(params[:id])
68 | end
69 |
70 | # Never trust parameters from the scary internet, only allow the white list through.
71 | def post_params
72 | params.require(:post).permit(:title, :body)
73 | end
74 | end
75 |
--------------------------------------------------------------------------------
/app/controllers/photos_controller.rb:
--------------------------------------------------------------------------------
1 | class PhotosController < ApplicationController
2 | before_action :set_photo, only: [:show, :edit, :update, :destroy]
3 |
4 | # GET /photos
5 | # GET /photos.json
6 | def index
7 | @photos = Photo.all
8 | end
9 |
10 | # GET /photos/1
11 | # GET /photos/1.json
12 | def show
13 | end
14 |
15 | # GET /photos/new
16 | def new
17 | @photo = Photo.new
18 | end
19 |
20 | # GET /photos/1/edit
21 | def edit
22 | end
23 |
24 | # POST /photos
25 | # POST /photos.json
26 | def create
27 | @photo = Photo.new(photo_params)
28 |
29 | respond_to do |format|
30 | if @photo.save
31 | format.html { redirect_to @photo, notice: 'Photo was successfully created.' }
32 | format.json { render :show, status: :created, location: @photo }
33 | else
34 | format.html { render :new }
35 | format.json { render json: @photo.errors, status: :unprocessable_entity }
36 | end
37 | end
38 | end
39 |
40 | # PATCH/PUT /photos/1
41 | # PATCH/PUT /photos/1.json
42 | def update
43 | respond_to do |format|
44 | if @photo.update(photo_params)
45 | format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }
46 | format.json { render :show, status: :ok, location: @photo }
47 | else
48 | format.html { render :edit }
49 | format.json { render json: @photo.errors, status: :unprocessable_entity }
50 | end
51 | end
52 | end
53 |
54 | # DELETE /photos/1
55 | # DELETE /photos/1.json
56 | def destroy
57 | @photo.destroy
58 | respond_to do |format|
59 | format.html { redirect_to photos_url, notice: 'Photo was successfully destroyed.' }
60 | format.json { head :no_content }
61 | end
62 | end
63 |
64 | private
65 | # Use callbacks to share common setup or constraints between actions.
66 | def set_photo
67 | @photo = Photo.find(params[:id])
68 | end
69 |
70 | # Never trust parameters from the scary internet, only allow the white list through.
71 | def photo_params
72 | params.require(:photo).permit(:image)
73 | end
74 | end
75 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/edit.html.erb:
--------------------------------------------------------------------------------
1 |
<%= link_to "Deactivate my account", registration_path(resource_name), data: { confirm: "Are you sure? You cannot undo this." }, method: :delete %>
45 |
46 |
47 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
3 | # Settings specified here will take precedence over those in config/application.rb.
4 |
5 | # In the development environment your application's code is reloaded on
6 | # every request. This slows down response time but is perfect for development
7 | # since you don't have to restart the web server when you make code changes.
8 | config.cache_classes = false
9 |
10 | # Do not eager load code on boot.
11 | config.eager_load = false
12 |
13 | # Show full error reports.
14 | config.consider_all_requests_local = true
15 |
16 | # Enable/disable caching. By default caching is disabled.
17 | if Rails.root.join('tmp/caching-dev.txt').exist?
18 | config.action_controller.perform_caching = true
19 |
20 | config.cache_store = :memory_store
21 | config.public_file_server.headers = {
22 | 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
23 | }
24 | else
25 | config.action_controller.perform_caching = false
26 |
27 | config.cache_store = :null_store
28 | end
29 |
30 | # Don't care if the mailer can't send.
31 | config.action_mailer.raise_delivery_errors = false
32 |
33 | config.action_mailer.perform_caching = false
34 |
35 | # Print deprecation notices to the Rails logger.
36 | config.active_support.deprecation = :log
37 |
38 | # Raise an error on page load if there are pending migrations.
39 | config.active_record.migration_error = :page_load
40 |
41 | # Debug mode disables concatenation and preprocessing of assets.
42 | # This option may cause significant delays in view rendering with a large
43 | # number of complex assets.
44 | config.assets.debug = true
45 |
46 | # Suppress logger output for asset requests.
47 | config.assets.quiet = true
48 |
49 | # Raises error for missing translations
50 | # config.action_view.raise_on_missing_translations = true
51 |
52 | # Use an evented file watcher to asynchronously detect changes in source code,
53 | # routes, locales, etc. This feature depends on the listen gem.
54 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker
55 | end
56 |
--------------------------------------------------------------------------------
/bin/webpack-dev-server:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | $stdout.sync = true
3 |
4 | require "shellwords"
5 | require "yaml"
6 | require "socket"
7 |
8 | ENV["RAILS_ENV"] ||= "development"
9 | RAILS_ENV = ENV["RAILS_ENV"]
10 |
11 | ENV["NODE_ENV"] ||= RAILS_ENV
12 | NODE_ENV = ENV["NODE_ENV"]
13 |
14 | APP_PATH = File.expand_path("../", __dir__)
15 | CONFIG_FILE = File.join(APP_PATH, "config/webpacker.yml")
16 | NODE_MODULES_PATH = File.join(APP_PATH, "node_modules")
17 | WEBPACK_CONFIG = File.join(APP_PATH, "config/webpack/#{NODE_ENV}.js")
18 |
19 | DEFAULT_LISTEN_HOST_ADDR = NODE_ENV == 'development' ? 'localhost' : '0.0.0.0'
20 |
21 | def args(key)
22 | index = ARGV.index(key)
23 | index ? ARGV[index + 1] : nil
24 | end
25 |
26 | begin
27 | dev_server = YAML.load_file(CONFIG_FILE)[RAILS_ENV]["dev_server"]
28 |
29 | HOSTNAME = args('--host') || dev_server["host"]
30 | PORT = args('--port') || dev_server["port"]
31 | HTTPS = ARGV.include?('--https') || dev_server["https"]
32 | DEV_SERVER_ADDR = "http#{"s" if HTTPS}://#{HOSTNAME}:#{PORT}"
33 | LISTEN_HOST_ADDR = args('--listen-host') || DEFAULT_LISTEN_HOST_ADDR
34 |
35 | rescue Errno::ENOENT, NoMethodError
36 | $stdout.puts "Webpack dev_server configuration not found in #{CONFIG_FILE}."
37 | $stdout.puts "Please run bundle exec rails webpacker:install to install webpacker"
38 | exit!
39 | end
40 |
41 | begin
42 | server = TCPServer.new(LISTEN_HOST_ADDR, PORT)
43 | server.close
44 |
45 | rescue Errno::EADDRINUSE
46 | $stdout.puts "Another program is running on port #{PORT}. Set a new port in #{CONFIG_FILE} for dev_server"
47 | exit!
48 | end
49 |
50 | # Delete supplied host, port and listen-host CLI arguments
51 | ["--host", "--port", "--listen-host"].each do |arg|
52 | ARGV.delete(args(arg))
53 | ARGV.delete(arg)
54 | end
55 |
56 | env = { "NODE_PATH" => NODE_MODULES_PATH.shellescape }
57 |
58 | cmd = [
59 | "#{NODE_MODULES_PATH}/.bin/webpack-dev-server", "--progress", "--color",
60 | "--config", WEBPACK_CONFIG,
61 | "--host", LISTEN_HOST_ADDR,
62 | "--public", "#{HOSTNAME}:#{PORT}",
63 | "--port", PORT.to_s
64 | ] + ARGV
65 |
66 | Dir.chdir(APP_PATH) do
67 | exec env, *cmd
68 | end
69 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | threads threads_count, threads_count
9 |
10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11 | #
12 | port ENV.fetch("PORT") { 3000 }
13 |
14 | # Specifies the `environment` that Puma will run in.
15 | #
16 | environment ENV.fetch("RAILS_ENV") { "development" }
17 |
18 | # Specifies the number of `workers` to boot in clustered mode.
19 | # Workers are forked webserver processes. If using threads and workers together
20 | # the concurrency of the application would be max `threads` * `workers`.
21 | # Workers do not work on JRuby or Windows (both of which do not support
22 | # processes).
23 | #
24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25 |
26 | # Use the `preload_app!` method when specifying a `workers` number.
27 | # This directive tells Puma to first boot the application and load code
28 | # before forking the application. This takes advantage of Copy On Write
29 | # process behavior so workers use less memory. If you use this option
30 | # you need to make sure to reconnect any threads in the `on_worker_boot`
31 | # block.
32 | #
33 | # preload_app!
34 |
35 | # If you are preloading your application and using Active Record, it's
36 | # recommended that you close any connections to the database before workers
37 | # are forked to prevent connection leakage.
38 | #
39 | # before_fork do
40 | # ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
41 | # end
42 |
43 | # The code in the `on_worker_boot` will be called if you are using
44 | # clustered mode by specifying a number of `workers`. After each worker
45 | # process is booted, this block will be run. If you are using the `preload_app!`
46 | # option, you will want to use this block to reconnect to any threads
47 | # or connections that may have been created at application boot, as Ruby
48 | # cannot share connections between processes.
49 | #
50 | # on_worker_boot do
51 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
52 | # end
53 | #
54 |
55 | # Allow puma to be restarted by `rails restart` command.
56 | plugin :tmp_restart
57 |
--------------------------------------------------------------------------------
/app/views/shared/_navbar.html.erb:
--------------------------------------------------------------------------------
1 | <% if user_masquerade? %>
2 |
3 | You're logged in as <%= current_user.name %> (<%= current_user.email %>)
4 | <%= link_to back_masquerade_path(current_user) do %><%= icon("times") %> Logout <% end %>
5 |
6 | <% end %>
7 |
8 |
48 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended that you check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(version: 20171003150750) do
14 |
15 | # These are extensions that must be enabled in order to support this database
16 | enable_extension "plpgsql"
17 |
18 | create_table "announcements", force: :cascade do |t|
19 | t.datetime "published_at"
20 | t.string "announcement_type"
21 | t.string "name"
22 | t.text "description"
23 | t.datetime "created_at", null: false
24 | t.datetime "updated_at", null: false
25 | end
26 |
27 | create_table "photos", force: :cascade do |t|
28 | t.text "image_data"
29 | t.datetime "created_at", null: false
30 | t.datetime "updated_at", null: false
31 | end
32 |
33 | create_table "posts", force: :cascade do |t|
34 | t.string "title"
35 | t.text "body"
36 | t.datetime "created_at", null: false
37 | t.datetime "updated_at", null: false
38 | end
39 |
40 | create_table "users", force: :cascade do |t|
41 | t.string "email", default: "", null: false
42 | t.string "encrypted_password", default: "", null: false
43 | t.string "reset_password_token"
44 | t.datetime "reset_password_sent_at"
45 | t.datetime "remember_created_at"
46 | t.integer "sign_in_count", default: 0, null: false
47 | t.datetime "current_sign_in_at"
48 | t.datetime "last_sign_in_at"
49 | t.inet "current_sign_in_ip"
50 | t.inet "last_sign_in_ip"
51 | t.string "first_name"
52 | t.string "last_name"
53 | t.datetime "announcements_last_read_at"
54 | t.boolean "admin", default: false
55 | t.datetime "created_at", null: false
56 | t.datetime "updated_at", null: false
57 | t.index ["email"], name: "index_users_on_email", unique: true
58 | t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
59 | end
60 |
61 | end
62 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | git_source(:github) do |repo_name|
4 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5 | "https://github.com/#{repo_name}.git"
6 | end
7 |
8 |
9 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
10 | gem 'rails', '~> 5.1.4'
11 | # Use postgresql as the database for Active Record
12 | gem 'pg', '~> 0.18'
13 | # Use Puma as the app server
14 | gem 'puma', '~> 3.7'
15 | # Use SCSS for stylesheets
16 | gem 'sass-rails', '~> 5.0'
17 | # Use Uglifier as compressor for JavaScript assets
18 | gem 'uglifier', '>= 1.3.0'
19 | # See https://github.com/rails/execjs#readme for more supported runtimes
20 | # gem 'therubyracer', platforms: :ruby
21 |
22 | # Use CoffeeScript for .coffee assets and views
23 | gem 'coffee-rails', '~> 4.2'
24 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
25 | gem 'turbolinks', '~> 5'
26 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
27 | gem 'jbuilder', '~> 2.5'
28 | # Use Redis adapter to run Action Cable in production
29 | # gem 'redis', '~> 3.0'
30 | # Use ActiveModel has_secure_password
31 | # gem 'bcrypt', '~> 3.1.7'
32 |
33 | # Use Capistrano for deployment
34 | # gem 'capistrano-rails', group: :development
35 |
36 | group :development, :test do
37 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console
38 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
39 | # Adds support for Capybara system testing and selenium driver
40 | gem 'capybara', '~> 2.13'
41 | gem 'selenium-webdriver'
42 | end
43 |
44 | group :development do
45 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
46 | gem 'web-console', '>= 3.3.0'
47 | gem 'listen', '>= 3.0.5', '< 3.2'
48 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
49 | gem 'spring'
50 | gem 'spring-watcher-listen', '~> 2.0.0'
51 | end
52 |
53 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
54 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
55 |
56 | gem 'administrate', '~> 0.8.1'
57 | gem 'devise', '~> 4.3.0'
58 | gem 'devise-bootstrapped', github: 'excid3/devise-bootstrapped', branch: 'bootstrap4'
59 | gem 'devise_masquerade', '~> 0.6.0'
60 | gem 'font-awesome-sass', '~> 4.7'
61 | gem 'gravatar_image_tag', github: 'mdeering/gravatar_image_tag'
62 | gem 'jquery-rails', '~> 4.3.1'
63 | gem 'bootstrap', '~> 4.0.0.beta'
64 | gem 'webpacker', '~> 3.0'
65 | gem 'sidekiq', '~> 5.0'
66 | gem 'foreman', '~> 0.84.0'
67 |
68 | gem 'trix'
69 | gem 'shrine'
70 |
--------------------------------------------------------------------------------
/app/dashboards/user_dashboard.rb:
--------------------------------------------------------------------------------
1 | require "administrate/base_dashboard"
2 |
3 | class UserDashboard < Administrate::BaseDashboard
4 | # ATTRIBUTE_TYPES
5 | # a hash that describes the type of each of the model's fields.
6 | #
7 | # Each different type represents an Administrate::Field object,
8 | # which determines how the attribute is displayed
9 | # on pages throughout the dashboard.
10 | ATTRIBUTE_TYPES = {
11 | id: Field::Number,
12 | email: Field::String,
13 | encrypted_password: Field::String,
14 | reset_password_token: Field::String,
15 | reset_password_sent_at: Field::DateTime,
16 | remember_created_at: Field::DateTime,
17 | sign_in_count: Field::Number,
18 | current_sign_in_at: Field::DateTime,
19 | last_sign_in_at: Field::DateTime,
20 | current_sign_in_ip: Field::String.with_options(searchable: false),
21 | last_sign_in_ip: Field::String.with_options(searchable: false),
22 | first_name: Field::String,
23 | last_name: Field::String,
24 | announcements_last_read_at: Field::DateTime,
25 | admin: Field::Boolean,
26 | created_at: Field::DateTime,
27 | updated_at: Field::DateTime,
28 | }.freeze
29 |
30 | # COLLECTION_ATTRIBUTES
31 | # an array of attributes that will be displayed on the model's index page.
32 | #
33 | # By default, it's limited to four items to reduce clutter on index pages.
34 | # Feel free to add, remove, or rearrange items.
35 | COLLECTION_ATTRIBUTES = [
36 | :id,
37 | :email,
38 | :encrypted_password,
39 | :reset_password_token,
40 | ].freeze
41 |
42 | # SHOW_PAGE_ATTRIBUTES
43 | # an array of attributes that will be displayed on the model's show page.
44 | SHOW_PAGE_ATTRIBUTES = [
45 | :id,
46 | :email,
47 | :encrypted_password,
48 | :reset_password_token,
49 | :reset_password_sent_at,
50 | :remember_created_at,
51 | :sign_in_count,
52 | :current_sign_in_at,
53 | :last_sign_in_at,
54 | :current_sign_in_ip,
55 | :last_sign_in_ip,
56 | :first_name,
57 | :last_name,
58 | :announcements_last_read_at,
59 | :admin,
60 | :created_at,
61 | :updated_at,
62 | ].freeze
63 |
64 | # FORM_ATTRIBUTES
65 | # an array of attributes that will be displayed
66 | # on the model's form (`new` and `edit`) pages.
67 | FORM_ATTRIBUTES = [
68 | :email,
69 | :encrypted_password,
70 | :reset_password_token,
71 | :reset_password_sent_at,
72 | :remember_created_at,
73 | :sign_in_count,
74 | :current_sign_in_at,
75 | :last_sign_in_at,
76 | :current_sign_in_ip,
77 | :last_sign_in_ip,
78 | :first_name,
79 | :last_name,
80 | :announcements_last_read_at,
81 | :admin,
82 | ].freeze
83 |
84 | # Overwrite this method to customize how users are displayed
85 | # across all pages of the admin dashboard.
86 | #
87 | # def display_resource(user)
88 | # "User ##{user.id}"
89 | # end
90 | end
91 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # PostgreSQL. Versions 9.1 and up are supported.
2 | #
3 | # Install the pg driver:
4 | # gem install pg
5 | # On OS X with Homebrew:
6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7 | # On OS X with MacPorts:
8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9 | # On Windows:
10 | # gem install pg
11 | # Choose the win32 build.
12 | # Install PostgreSQL and put its /bin directory on your path.
13 | #
14 | # Configure Using Gemfile
15 | # gem 'pg'
16 | #
17 | default: &default
18 | adapter: postgresql
19 | encoding: unicode
20 | # For details on connection pooling, see Rails configuration guide
21 | # http://guides.rubyonrails.org/configuring.html#database-pooling
22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
23 |
24 | development:
25 | <<: *default
26 | database: trix_example_development
27 |
28 | # The specified database role being used to connect to postgres.
29 | # To create additional roles in postgres see `$ createuser --help`.
30 | # When left blank, postgres will use the default role. This is
31 | # the same name as the operating system user that initialized the database.
32 | #username: trix_example
33 |
34 | # The password associated with the postgres role (username).
35 | #password:
36 |
37 | # Connect on a TCP socket. Omitted by default since the client uses a
38 | # domain socket that doesn't need configuration. Windows does not have
39 | # domain sockets, so uncomment these lines.
40 | #host: localhost
41 |
42 | # The TCP port the server listens on. Defaults to 5432.
43 | # If your server runs on a different port number, change accordingly.
44 | #port: 5432
45 |
46 | # Schema search path. The server defaults to $user,public
47 | #schema_search_path: myapp,sharedapp,public
48 |
49 | # Minimum log levels, in increasing order:
50 | # debug5, debug4, debug3, debug2, debug1,
51 | # log, notice, warning, error, fatal, and panic
52 | # Defaults to warning.
53 | #min_messages: notice
54 |
55 | # Warning: The database defined as "test" will be erased and
56 | # re-generated from your development database when you run "rake".
57 | # Do not set this db to the same as development or production.
58 | test:
59 | <<: *default
60 | database: trix_example_test
61 |
62 | # As with config/secrets.yml, you never want to store sensitive information,
63 | # like your database password, in your source code. If your source code is
64 | # ever seen by anyone, they now have access to your database.
65 | #
66 | # Instead, provide the password as a unix environment variable when you boot
67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
68 | # for a full rundown on how to provide these environment variables in a
69 | # production deployment.
70 | #
71 | # On Heroku and other platform providers, you may have a full connection URL
72 | # available as an environment variable. For example:
73 | #
74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
75 | #
76 | # You can use this database configuration with:
77 | #
78 | # production:
79 | # url: <%= ENV['DATABASE_URL'] %>
80 | #
81 | production:
82 | <<: *default
83 | database: trix_example_production
84 | username: trix_example
85 | password: <%= ENV['TRIX_EXAMPLE_DATABASE_PASSWORD'] %>
86 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # Code is not reloaded between requests.
5 | config.cache_classes = true
6 |
7 | # Eager load code on boot. This eager loads most of Rails and
8 | # your application in memory, allowing both threaded web servers
9 | # and those relying on copy on write to perform better.
10 | # Rake tasks automatically ignore this option for performance.
11 | config.eager_load = true
12 |
13 | # Full error reports are disabled and caching is turned on.
14 | config.consider_all_requests_local = false
15 | config.action_controller.perform_caching = true
16 |
17 | # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
18 | # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
19 | # `config/secrets.yml.key`.
20 | config.read_encrypted_secrets = true
21 |
22 | # Disable serving static files from the `/public` folder by default since
23 | # Apache or NGINX already handles this.
24 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
25 |
26 | # Compress JavaScripts and CSS.
27 | config.assets.js_compressor = :uglifier
28 | # config.assets.css_compressor = :sass
29 |
30 | # Do not fallback to assets pipeline if a precompiled asset is missed.
31 | config.assets.compile = false
32 |
33 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
34 |
35 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
36 | # config.action_controller.asset_host = 'http://assets.example.com'
37 |
38 | # Specifies the header that your server uses for sending files.
39 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
41 |
42 | # Mount Action Cable outside main process or domain
43 | # config.action_cable.mount_path = nil
44 | # config.action_cable.url = 'wss://example.com/cable'
45 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
46 |
47 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
48 | # config.force_ssl = true
49 |
50 | # Use the lowest log level to ensure availability of diagnostic information
51 | # when problems arise.
52 | config.log_level = :debug
53 |
54 | # Prepend all log lines with the following tags.
55 | config.log_tags = [ :request_id ]
56 |
57 | # Use a different cache store in production.
58 | # config.cache_store = :mem_cache_store
59 |
60 | # Use a real queuing backend for Active Job (and separate queues per environment)
61 | # config.active_job.queue_adapter = :resque
62 | # config.active_job.queue_name_prefix = "trix_example_#{Rails.env}"
63 | config.action_mailer.perform_caching = false
64 |
65 | # Ignore bad email addresses and do not raise email delivery errors.
66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
67 | # config.action_mailer.raise_delivery_errors = false
68 |
69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
70 | # the I18n.default_locale when a translation cannot be found).
71 | config.i18n.fallbacks = true
72 |
73 | # Send deprecation notices to registered listeners.
74 | config.active_support.deprecation = :notify
75 |
76 | # Use default logging formatter so that PID and timestamp are not suppressed.
77 | config.log_formatter = ::Logger::Formatter.new
78 |
79 | # Use a different logger for distributed setups.
80 | # require 'syslog/logger'
81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
82 |
83 | if ENV["RAILS_LOG_TO_STDOUT"].present?
84 | logger = ActiveSupport::Logger.new(STDOUT)
85 | logger.formatter = config.log_formatter
86 | config.logger = ActiveSupport::TaggedLogging.new(logger)
87 | end
88 |
89 | # Do not dump schema after migrations.
90 | config.active_record.dump_schema_after_migration = false
91 | end
92 |
--------------------------------------------------------------------------------
/config/locales/devise.en.yml:
--------------------------------------------------------------------------------
1 | # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2 |
3 | en:
4 | devise:
5 | confirmations:
6 | confirmed: "Your email address has been successfully confirmed."
7 | send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
8 | send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address 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 %{authentication_keys} or password."
13 | locked: "Your account is locked."
14 | last_attempt: "You have one more attempt before your account is locked."
15 | not_found_in_database: "Invalid %{authentication_keys} 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 email address 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 | email_changed:
27 | subject: "Email Changed"
28 | password_change:
29 | subject: "Password Changed"
30 | omniauth_callbacks:
31 | failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
32 | success: "Successfully authenticated from %{kind} account."
33 | passwords:
34 | 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."
35 | send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
36 | 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."
37 | updated: "Your password has been changed successfully. You are now signed in."
38 | updated_not_active: "Your password has been changed successfully."
39 | registrations:
40 | destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
41 | signed_up: "Welcome! You have signed up successfully."
42 | signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
43 | signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
44 | signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
45 | update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
46 | updated: "Your account has been updated successfully."
47 | sessions:
48 | signed_in: "Signed in successfully."
49 | signed_out: "Signed out successfully."
50 | already_signed_out: "Signed out successfully."
51 | unlocks:
52 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
53 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
54 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
55 | errors:
56 | messages:
57 | already_confirmed: "was already confirmed, please try signing in"
58 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
59 | expired: "has expired, please request a new one"
60 | not_found: "not found"
61 | not_locked: "was not locked"
62 | not_saved:
63 | one: "1 error prohibited this %{resource} from being saved:"
64 | other: "%{count} errors prohibited this %{resource} from being saved:"
65 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GIT
2 | remote: https://github.com/excid3/devise-bootstrapped.git
3 | revision: a963d93052ce0069d050e4615fb06e95dc30ac2b
4 | branch: bootstrap4
5 | specs:
6 | devise-bootstrapped (0.2.0)
7 |
8 | GIT
9 | remote: https://github.com/mdeering/gravatar_image_tag.git
10 | revision: 61ba79bd92d23a1edd5126d903d76b0c94f09641
11 | specs:
12 | gravatar_image_tag (1.2.0)
13 |
14 | GEM
15 | remote: https://rubygems.org/
16 | specs:
17 | actioncable (5.1.4)
18 | actionpack (= 5.1.4)
19 | nio4r (~> 2.0)
20 | websocket-driver (~> 0.6.1)
21 | actionmailer (5.1.4)
22 | actionpack (= 5.1.4)
23 | actionview (= 5.1.4)
24 | activejob (= 5.1.4)
25 | mail (~> 2.5, >= 2.5.4)
26 | rails-dom-testing (~> 2.0)
27 | actionpack (5.1.4)
28 | actionview (= 5.1.4)
29 | activesupport (= 5.1.4)
30 | rack (~> 2.0)
31 | rack-test (>= 0.6.3)
32 | rails-dom-testing (~> 2.0)
33 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
34 | actionview (5.1.4)
35 | activesupport (= 5.1.4)
36 | builder (~> 3.1)
37 | erubi (~> 1.4)
38 | rails-dom-testing (~> 2.0)
39 | rails-html-sanitizer (~> 1.0, >= 1.0.3)
40 | activejob (5.1.4)
41 | activesupport (= 5.1.4)
42 | globalid (>= 0.3.6)
43 | activemodel (5.1.4)
44 | activesupport (= 5.1.4)
45 | activerecord (5.1.4)
46 | activemodel (= 5.1.4)
47 | activesupport (= 5.1.4)
48 | arel (~> 8.0)
49 | activesupport (5.1.4)
50 | concurrent-ruby (~> 1.0, >= 1.0.2)
51 | i18n (~> 0.7)
52 | minitest (~> 5.1)
53 | tzinfo (~> 1.1)
54 | addressable (2.5.2)
55 | public_suffix (>= 2.0.2, < 4.0)
56 | administrate (0.8.1)
57 | actionpack (>= 4.2, < 5.2)
58 | actionview (>= 4.2, < 5.2)
59 | activerecord (>= 4.2, < 5.2)
60 | autoprefixer-rails (>= 6.0)
61 | datetime_picker_rails (~> 0.0.7)
62 | jquery-rails (>= 4.0)
63 | kaminari (>= 1.0)
64 | momentjs-rails (~> 2.8)
65 | sass-rails (~> 5.0)
66 | selectize-rails (~> 0.6)
67 | arel (8.0.0)
68 | autoprefixer-rails (7.1.4.1)
69 | execjs
70 | bcrypt (3.1.11)
71 | bindex (0.5.0)
72 | bootstrap (4.0.0.beta)
73 | autoprefixer-rails (>= 6.0.3)
74 | popper_js (~> 1.11.1)
75 | sass (>= 3.4.19)
76 | builder (3.2.3)
77 | byebug (9.1.0)
78 | capybara (2.15.2)
79 | addressable
80 | mini_mime (>= 0.1.3)
81 | nokogiri (>= 1.3.3)
82 | rack (>= 1.0.0)
83 | rack-test (>= 0.5.4)
84 | xpath (~> 2.0)
85 | childprocess (0.8.0)
86 | ffi (~> 1.0, >= 1.0.11)
87 | coffee-rails (4.2.2)
88 | coffee-script (>= 2.2.0)
89 | railties (>= 4.0.0)
90 | coffee-script (2.4.1)
91 | coffee-script-source
92 | execjs
93 | coffee-script-source (1.12.2)
94 | concurrent-ruby (1.0.5)
95 | connection_pool (2.2.1)
96 | crass (1.0.2)
97 | datetime_picker_rails (0.0.7)
98 | momentjs-rails (>= 2.8.1)
99 | devise (4.3.0)
100 | bcrypt (~> 3.0)
101 | orm_adapter (~> 0.1)
102 | railties (>= 4.1.0, < 5.2)
103 | responders
104 | warden (~> 1.2.3)
105 | devise_masquerade (0.6.1)
106 | devise (>= 2.1.0)
107 | railties (>= 3.0)
108 | down (4.0.1)
109 | erubi (1.6.1)
110 | execjs (2.7.0)
111 | ffi (1.9.18)
112 | font-awesome-sass (4.7.0)
113 | sass (>= 3.2)
114 | foreman (0.84.0)
115 | thor (~> 0.19.1)
116 | globalid (0.4.0)
117 | activesupport (>= 4.2.0)
118 | i18n (0.8.6)
119 | jbuilder (2.7.0)
120 | activesupport (>= 4.2.0)
121 | multi_json (>= 1.2)
122 | jquery-rails (4.3.1)
123 | rails-dom-testing (>= 1, < 3)
124 | railties (>= 4.2.0)
125 | thor (>= 0.14, < 2.0)
126 | kaminari (1.0.1)
127 | activesupport (>= 4.1.0)
128 | kaminari-actionview (= 1.0.1)
129 | kaminari-activerecord (= 1.0.1)
130 | kaminari-core (= 1.0.1)
131 | kaminari-actionview (1.0.1)
132 | actionview
133 | kaminari-core (= 1.0.1)
134 | kaminari-activerecord (1.0.1)
135 | activerecord
136 | kaminari-core (= 1.0.1)
137 | kaminari-core (1.0.1)
138 | listen (3.1.5)
139 | rb-fsevent (~> 0.9, >= 0.9.4)
140 | rb-inotify (~> 0.9, >= 0.9.7)
141 | ruby_dep (~> 1.2)
142 | loofah (2.1.1)
143 | crass (~> 1.0.2)
144 | nokogiri (>= 1.5.9)
145 | mail (2.6.6)
146 | mime-types (>= 1.16, < 4)
147 | method_source (0.9.0)
148 | mime-types (3.1)
149 | mime-types-data (~> 3.2015)
150 | mime-types-data (3.2016.0521)
151 | mini_mime (0.1.4)
152 | mini_portile2 (2.3.0)
153 | minitest (5.10.3)
154 | momentjs-rails (2.17.1)
155 | railties (>= 3.1)
156 | multi_json (1.12.2)
157 | nio4r (2.1.0)
158 | nokogiri (1.8.1)
159 | mini_portile2 (~> 2.3.0)
160 | orm_adapter (0.5.0)
161 | pg (0.21.0)
162 | popper_js (1.11.1)
163 | public_suffix (3.0.0)
164 | puma (3.10.0)
165 | rack (2.0.3)
166 | rack-protection (2.0.0)
167 | rack
168 | rack-proxy (0.6.2)
169 | rack
170 | rack-test (0.7.0)
171 | rack (>= 1.0, < 3)
172 | rails (5.1.4)
173 | actioncable (= 5.1.4)
174 | actionmailer (= 5.1.4)
175 | actionpack (= 5.1.4)
176 | actionview (= 5.1.4)
177 | activejob (= 5.1.4)
178 | activemodel (= 5.1.4)
179 | activerecord (= 5.1.4)
180 | activesupport (= 5.1.4)
181 | bundler (>= 1.3.0)
182 | railties (= 5.1.4)
183 | sprockets-rails (>= 2.0.0)
184 | rails-dom-testing (2.0.3)
185 | activesupport (>= 4.2.0)
186 | nokogiri (>= 1.6)
187 | rails-html-sanitizer (1.0.3)
188 | loofah (~> 2.0)
189 | railties (5.1.4)
190 | actionpack (= 5.1.4)
191 | activesupport (= 5.1.4)
192 | method_source
193 | rake (>= 0.8.7)
194 | thor (>= 0.18.1, < 2.0)
195 | rake (12.1.0)
196 | rb-fsevent (0.10.2)
197 | rb-inotify (0.9.10)
198 | ffi (>= 0.5.0, < 2)
199 | redis (4.0.1)
200 | responders (2.4.0)
201 | actionpack (>= 4.2.0, < 5.3)
202 | railties (>= 4.2.0, < 5.3)
203 | ruby_dep (1.5.0)
204 | rubyzip (1.2.1)
205 | sass (3.5.1)
206 | sass-listen (~> 4.0.0)
207 | sass-listen (4.0.0)
208 | rb-fsevent (~> 0.9, >= 0.9.4)
209 | rb-inotify (~> 0.9, >= 0.9.7)
210 | sass-rails (5.0.6)
211 | railties (>= 4.0.0, < 6)
212 | sass (~> 3.1)
213 | sprockets (>= 2.8, < 4.0)
214 | sprockets-rails (>= 2.0, < 4.0)
215 | tilt (>= 1.1, < 3)
216 | selectize-rails (0.12.4)
217 | selenium-webdriver (3.6.0)
218 | childprocess (~> 0.5)
219 | rubyzip (~> 1.0)
220 | shrine (2.6.1)
221 | down (>= 2.3.6)
222 | sidekiq (5.0.5)
223 | concurrent-ruby (~> 1.0)
224 | connection_pool (~> 2.2, >= 2.2.0)
225 | rack-protection (>= 1.5.0)
226 | redis (>= 3.3.4, < 5)
227 | spring (2.0.2)
228 | activesupport (>= 4.2)
229 | spring-watcher-listen (2.0.1)
230 | listen (>= 2.7, < 4.0)
231 | spring (>= 1.2, < 3.0)
232 | sprockets (3.7.1)
233 | concurrent-ruby (~> 1.0)
234 | rack (> 1, < 3)
235 | sprockets-rails (3.2.1)
236 | actionpack (>= 4.0)
237 | activesupport (>= 4.0)
238 | sprockets (>= 3.0.0)
239 | thor (0.19.4)
240 | thread_safe (0.3.6)
241 | tilt (2.0.8)
242 | trix (0.11.0)
243 | rails (> 4.1, < 5.2)
244 | turbolinks (5.0.1)
245 | turbolinks-source (~> 5)
246 | turbolinks-source (5.0.3)
247 | tzinfo (1.2.3)
248 | thread_safe (~> 0.1)
249 | uglifier (3.2.0)
250 | execjs (>= 0.3.0, < 3)
251 | warden (1.2.7)
252 | rack (>= 1.0)
253 | web-console (3.5.1)
254 | actionview (>= 5.0)
255 | activemodel (>= 5.0)
256 | bindex (>= 0.4.0)
257 | railties (>= 5.0)
258 | webpacker (3.0.1)
259 | activesupport (>= 4.2)
260 | rack-proxy (>= 0.6.1)
261 | railties (>= 4.2)
262 | websocket-driver (0.6.5)
263 | websocket-extensions (>= 0.1.0)
264 | websocket-extensions (0.1.2)
265 | xpath (2.1.0)
266 | nokogiri (~> 1.3)
267 |
268 | PLATFORMS
269 | ruby
270 |
271 | DEPENDENCIES
272 | administrate (~> 0.8.1)
273 | bootstrap (~> 4.0.0.beta)
274 | byebug
275 | capybara (~> 2.13)
276 | coffee-rails (~> 4.2)
277 | devise (~> 4.3.0)
278 | devise-bootstrapped!
279 | devise_masquerade (~> 0.6.0)
280 | font-awesome-sass (~> 4.7)
281 | foreman (~> 0.84.0)
282 | gravatar_image_tag!
283 | jbuilder (~> 2.5)
284 | jquery-rails (~> 4.3.1)
285 | listen (>= 3.0.5, < 3.2)
286 | pg (~> 0.18)
287 | puma (~> 3.7)
288 | rails (~> 5.1.4)
289 | sass-rails (~> 5.0)
290 | selenium-webdriver
291 | shrine
292 | sidekiq (~> 5.0)
293 | spring
294 | spring-watcher-listen (~> 2.0.0)
295 | trix
296 | turbolinks (~> 5)
297 | tzinfo-data
298 | uglifier (>= 1.3.0)
299 | web-console (>= 3.3.0)
300 | webpacker (~> 3.0)
301 |
302 | BUNDLED WITH
303 | 1.15.3
304 |
--------------------------------------------------------------------------------
/config/initializers/devise.rb:
--------------------------------------------------------------------------------
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 | # Devise will use the `secret_key_base` as its `secret_key`
8 | # by default. You can change it below and use your own secret key.
9 | # config.secret_key = 'dd441f5b4ec4862ac9bdd2ddfbb24ed390e9ec935d06f6169bd22e00076e545a50c6832e85fe07d31aebcd380d60b11a21dd919ca09ab8841cb8133779d294a1'
10 |
11 | # ==> Mailer Configuration
12 | # Configure the e-mail address which will be shown in Devise::Mailer,
13 | # note that it will be overwritten if you use your own mailer class
14 | # with default "from" parameter.
15 | config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
16 |
17 | # Configure the class responsible to send e-mails.
18 | # config.mailer = 'Devise::Mailer'
19 |
20 | # Configure the parent class responsible to send e-mails.
21 | # config.parent_mailer = 'ActionMailer::Base'
22 |
23 | # ==> ORM configuration
24 | # Load and configure the ORM. Supports :active_record (default) and
25 | # :mongoid (bson_ext recommended) by default. Other ORMs may be
26 | # available as additional gems.
27 | require 'devise/orm/active_record'
28 |
29 | # ==> Configuration for any authentication mechanism
30 | # Configure which keys are used when authenticating a user. The default is
31 | # just :email. You can configure it to use [:username, :subdomain], so for
32 | # authenticating a user, both parameters are required. Remember that those
33 | # parameters are used only when authenticating and not when retrieving from
34 | # session. If you need permissions, you should implement that in a before filter.
35 | # You can also supply a hash where the value is a boolean determining whether
36 | # or not authentication should be aborted when the value is not present.
37 | # config.authentication_keys = [:email]
38 |
39 | # Configure parameters from the request object used for authentication. Each entry
40 | # given should be a request method and it will automatically be passed to the
41 | # find_for_authentication method and considered in your model lookup. For instance,
42 | # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
43 | # The same considerations mentioned for authentication_keys also apply to request_keys.
44 | # config.request_keys = []
45 |
46 | # Configure which authentication keys should be case-insensitive.
47 | # These keys will be downcased upon creating or modifying a user and when used
48 | # to authenticate or find a user. Default is :email.
49 | config.case_insensitive_keys = [:email]
50 |
51 | # Configure which authentication keys should have whitespace stripped.
52 | # These keys will have whitespace before and after removed upon creating or
53 | # modifying a user and when used to authenticate or find a user. Default is :email.
54 | config.strip_whitespace_keys = [:email]
55 |
56 | # Tell if authentication through request.params is enabled. True by default.
57 | # It can be set to an array that will enable params authentication only for the
58 | # given strategies, for example, `config.params_authenticatable = [:database]` will
59 | # enable it only for database (email + password) authentication.
60 | # config.params_authenticatable = true
61 |
62 | # Tell if authentication through HTTP Auth is enabled. False by default.
63 | # It can be set to an array that will enable http authentication only for the
64 | # given strategies, for example, `config.http_authenticatable = [:database]` will
65 | # enable it only for database authentication. The supported strategies are:
66 | # :database = Support basic authentication with authentication key + password
67 | # config.http_authenticatable = false
68 |
69 | # If 401 status code should be returned for AJAX requests. True by default.
70 | # config.http_authenticatable_on_xhr = true
71 |
72 | # The realm used in Http Basic Authentication. 'Application' by default.
73 | # config.http_authentication_realm = 'Application'
74 |
75 | # It will change confirmation, password recovery and other workflows
76 | # to behave the same regardless if the e-mail provided was right or wrong.
77 | # Does not affect registerable.
78 | # config.paranoid = true
79 |
80 | # By default Devise will store the user in session. You can skip storage for
81 | # particular strategies by setting this option.
82 | # Notice that if you are skipping storage for all authentication paths, you
83 | # may want to disable generating routes to Devise's sessions controller by
84 | # passing skip: :sessions to `devise_for` in your config/routes.rb
85 | config.skip_session_storage = [:http_auth]
86 |
87 | # By default, Devise cleans up the CSRF token on authentication to
88 | # avoid CSRF token fixation attacks. This means that, when using AJAX
89 | # requests for sign in and sign up, you need to get a new CSRF token
90 | # from the server. You can disable this option at your own risk.
91 | # config.clean_up_csrf_token_on_authentication = true
92 |
93 | # When false, Devise will not attempt to reload routes on eager load.
94 | # This can reduce the time taken to boot the app but if your application
95 | # requires the Devise mappings to be loaded during boot time the application
96 | # won't boot properly.
97 | # config.reload_routes = true
98 |
99 | # ==> Configuration for :database_authenticatable
100 | # For bcrypt, this is the cost for hashing the password and defaults to 11. If
101 | # using other algorithms, it sets how many times you want the password to be hashed.
102 | #
103 | # Limiting the stretches to just one in testing will increase the performance of
104 | # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
105 | # a value less than 10 in other environments. Note that, for bcrypt (the default
106 | # algorithm), the cost increases exponentially with the number of stretches (e.g.
107 | # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
108 | config.stretches = Rails.env.test? ? 1 : 11
109 |
110 | # Set up a pepper to generate the hashed password.
111 | # config.pepper = '4446d9a5de0a2b7e6c20a724984d49b924ef4f7c47aef6ea63ef51a2da25d0ae06851b5e4c5dba1d5c34321fe89145cbd29d1b4c9d346e3fcb57f987f248cc26'
112 |
113 | # Send a notification to the original email when the user's email is changed.
114 | # config.send_email_changed_notification = false
115 |
116 | # Send a notification email when the user's password is changed.
117 | # config.send_password_change_notification = false
118 |
119 | # ==> Configuration for :confirmable
120 | # A period that the user is allowed to access the website even without
121 | # confirming their account. For instance, if set to 2.days, the user will be
122 | # able to access the website for two days without confirming their account,
123 | # access will be blocked just in the third day. Default is 0.days, meaning
124 | # the user cannot access the website without confirming their account.
125 | # config.allow_unconfirmed_access_for = 2.days
126 |
127 | # A period that the user is allowed to confirm their account before their
128 | # token becomes invalid. For example, if set to 3.days, the user can confirm
129 | # their account within 3 days after the mail was sent, but on the fourth day
130 | # their account can't be confirmed with the token any more.
131 | # Default is nil, meaning there is no restriction on how long a user can take
132 | # before confirming their account.
133 | # config.confirm_within = 3.days
134 |
135 | # If true, requires any email changes to be confirmed (exactly the same way as
136 | # initial account confirmation) to be applied. Requires additional unconfirmed_email
137 | # db field (see migrations). Until confirmed, new email is stored in
138 | # unconfirmed_email column, and copied to email column on successful confirmation.
139 | config.reconfirmable = true
140 |
141 | # Defines which key will be used when confirming an account
142 | # config.confirmation_keys = [:email]
143 |
144 | # ==> Configuration for :rememberable
145 | # The time the user will be remembered without asking for credentials again.
146 | # config.remember_for = 2.weeks
147 |
148 | # Invalidates all the remember me tokens when the user signs out.
149 | config.expire_all_remember_me_on_sign_out = true
150 |
151 | # If true, extends the user's remember period when remembered via cookie.
152 | # config.extend_remember_period = false
153 |
154 | # Options to be passed to the created cookie. For instance, you can set
155 | # secure: true in order to force SSL only cookies.
156 | # config.rememberable_options = {}
157 |
158 | # ==> Configuration for :validatable
159 | # Range for password length.
160 | config.password_length = 6..128
161 |
162 | # Email regex used to validate email formats. It simply asserts that
163 | # one (and only one) @ exists in the given string. This is mainly
164 | # to give user feedback and not to assert the e-mail validity.
165 | config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
166 |
167 | # ==> Configuration for :timeoutable
168 | # The time you want to timeout the user session without activity. After this
169 | # time the user will be asked for credentials again. Default is 30 minutes.
170 | # config.timeout_in = 30.minutes
171 |
172 | # ==> Configuration for :lockable
173 | # Defines which strategy will be used to lock an account.
174 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
175 | # :none = No lock strategy. You should handle locking by yourself.
176 | # config.lock_strategy = :failed_attempts
177 |
178 | # Defines which key will be used when locking and unlocking an account
179 | # config.unlock_keys = [:email]
180 |
181 | # Defines which strategy will be used to unlock an account.
182 | # :email = Sends an unlock link to the user email
183 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
184 | # :both = Enables both strategies
185 | # :none = No unlock strategy. You should handle unlocking by yourself.
186 | # config.unlock_strategy = :both
187 |
188 | # Number of authentication tries before locking an account if lock_strategy
189 | # is failed attempts.
190 | # config.maximum_attempts = 20
191 |
192 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
193 | # config.unlock_in = 1.hour
194 |
195 | # Warn on the last attempt before the account is locked.
196 | # config.last_attempt_warning = true
197 |
198 | # ==> Configuration for :recoverable
199 | #
200 | # Defines which key will be used when recovering the password for an account
201 | # config.reset_password_keys = [:email]
202 |
203 | # Time interval you can reset your password with a reset password key.
204 | # Don't put a too small interval or your users won't have the time to
205 | # change their passwords.
206 | config.reset_password_within = 6.hours
207 |
208 | # When set to false, does not sign a user in automatically after their password is
209 | # reset. Defaults to true, so a user is signed in automatically after a reset.
210 | # config.sign_in_after_reset_password = true
211 |
212 | # ==> Configuration for :encryptable
213 | # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
214 | # You can use :sha1, :sha512 or algorithms from others authentication tools as
215 | # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
216 | # for default behavior) and :restful_authentication_sha1 (then you should set
217 | # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
218 | #
219 | # Require the `devise-encryptable` gem when using anything other than bcrypt
220 | # config.encryptor = :sha512
221 |
222 | # ==> Scopes configuration
223 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
224 | # "users/sessions/new". It's turned off by default because it's slower if you
225 | # are using only default views.
226 | # config.scoped_views = false
227 |
228 | # Configure the default scope given to Warden. By default it's the first
229 | # devise role declared in your routes (usually :user).
230 | # config.default_scope = :user
231 |
232 | # Set this configuration to false if you want /users/sign_out to sign out
233 | # only the current scope. By default, Devise signs out all scopes.
234 | # config.sign_out_all_scopes = true
235 |
236 | # ==> Navigation configuration
237 | # Lists the formats that should be treated as navigational. Formats like
238 | # :html, should redirect to the sign in page when the user does not have
239 | # access, but formats like :xml or :json, should return 401.
240 | #
241 | # If you have any extra navigational formats, like :iphone or :mobile, you
242 | # should add them to the navigational formats lists.
243 | #
244 | # The "*/*" below is required to match Internet Explorer requests.
245 | # config.navigational_formats = ['*/*', :html]
246 |
247 | # The default HTTP method used to sign out a resource. Default is :delete.
248 | config.sign_out_via = :delete
249 |
250 | # ==> OmniAuth
251 | # Add a new OmniAuth provider. Check the wiki for more information on setting
252 | # up on your models and hooks.
253 | # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
254 |
255 | # ==> Warden configuration
256 | # If you want to use other strategies, that are not supported by Devise, or
257 | # change the failure app, you can configure them inside the config.warden block.
258 | #
259 | # config.warden do |manager|
260 | # manager.intercept_401 = false
261 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
262 | # end
263 |
264 | # ==> Mountable engine configurations
265 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
266 | # is mountable, there are some extra configurations to be taken into account.
267 | # The following options are available, assuming the engine is mounted as:
268 | #
269 | # mount MyEngine, at: '/my_engine'
270 | #
271 | # The router that invoked `devise_for`, in the example above, would be:
272 | # config.router_name = :my_engine
273 | #
274 | # When using OmniAuth, Devise cannot automatically set OmniAuth path,
275 | # so you need to do it manually. For the users scope, it would be:
276 | # config.omniauth_path_prefix = '/my_engine/users/auth'
277 | end
278 |
--------------------------------------------------------------------------------