26 | <%= f.label :current_password %> (we need your current password to confirm your changes)
27 | <%= f.password_field :current_password, autocomplete: "off" %>
28 |
29 |
30 |
31 | <%= f.submit "Update" %>
32 |
33 | <% end %>
34 |
35 |
Cancel my account
36 |
37 |
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
14 | <% end %>
15 |
16 | <%= render "users/shared/links" %>
17 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path('../../config/application', __FILE__)
3 | require_relative '../config/boot'
4 | require 'rails/commands'
5 |
--------------------------------------------------------------------------------
/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative '../config/boot'
3 | require 'rake'
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/bin/setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 |
4 | # path to your application root.
5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6 |
7 | Dir.chdir APP_ROOT do
8 | # This script is a starting point to setup your application.
9 | # Add necessary setup steps to this file:
10 |
11 | puts "== Installing dependencies =="
12 | system "gem install bundler --conservative"
13 | system "bundle check || bundle install"
14 |
15 | # puts "\n== Copying sample files =="
16 | # unless File.exist?("config/database.yml")
17 | # system "cp config/database.yml.sample config/database.yml"
18 | # end
19 |
20 | puts "\n== Preparing database =="
21 | system "bin/rake db:setup"
22 |
23 | puts "\n== Removing old logs and tempfiles =="
24 | system "rm -f log/*"
25 | system "rm -rf tmp/cache"
26 |
27 | puts "\n== Restarting application server =="
28 | system "touch tmp/restart.txt"
29 | end
30 |
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
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 OmniAuthDevise
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 |
15 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17 | # config.time_zone = 'Central Time (US & Canada)'
18 |
19 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21 | # config.i18n.default_locale = :de
22 |
23 | # Do not swallow errors in after_commit/after_rollback callbacks.
24 | config.active_record.raise_in_transactional_callbacks = true
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2 |
3 | require 'bundler/setup' # Set up gems listed in the Gemfile.
4 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | # SQLite version 3.x
2 | # gem install sqlite3
3 | #
4 | # Ensure the SQLite 3 gem is defined in your Gemfile
5 | # gem 'sqlite3'
6 | #
7 | default: &default
8 | adapter: sqlite3
9 | pool: 5
10 | timeout: 5000
11 |
12 | development:
13 | <<: *default
14 | database: db/development.sqlite3
15 |
16 | # Warning: The database defined as "test" will be erased and
17 | # re-generated from your development database when you run "rake".
18 | # Do not set this db to the same as development or production.
19 | test:
20 | <<: *default
21 | database: db/test.sqlite3
22 |
23 | production:
24 | adapter: postgresql
25 | encoding: unicode
26 | database: postgres://inhgkzrprynkig:bQfprOWJiWwlPIZC5zS9OkKpte@ec2-107-20-244-39.compute-1.amazonaws.com:5432/dbkr96crvalmbq
27 | pool: 5
28 | timeout: 5000
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Rails.application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
5 |
6 | # In the development environment your application's code is reloaded on
7 | # every request. This slows down response time but is perfect for development
8 | # since you don't have to restart the web server when you make code changes.
9 | config.cache_classes = false
10 |
11 | # Do not eager load code on boot.
12 | config.eager_load = false
13 |
14 | # Show full error reports and disable caching.
15 | config.consider_all_requests_local = true
16 | config.action_controller.perform_caching = false
17 |
18 | # Don't care if the mailer can't send.
19 | config.action_mailer.raise_delivery_errors = false
20 |
21 | # Print deprecation notices to the Rails logger.
22 | config.active_support.deprecation = :log
23 |
24 | # Raise an error on page load if there are pending migrations.
25 | config.active_record.migration_error = :page_load
26 |
27 | # Debug mode disables concatenation and preprocessing of assets.
28 | # This option may cause significant delays in view rendering with a large
29 | # number of complex assets.
30 | config.assets.debug = true
31 |
32 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
33 | # yet still be able to expire them through the digest params.
34 | config.assets.digest = true
35 |
36 | # Adds additional error checking when serving assets at runtime.
37 | # Checks for improperly declared sprockets dependencies.
38 | # Raises helpful error messages.
39 | config.assets.raise_runtime_errors = true
40 |
41 | # Raises error for missing translations
42 | # config.action_view.raise_on_missing_translations = true
43 |
44 | config.action_mailer.delivery_method = :smtp
45 | config.action_mailer.raise_delivery_errors = true
46 | config.action_mailer.perform_deliveries = true
47 | config.action_mailer.default :charset => "utf-8"
48 | config.action_mailer.smtp_settings = {
49 | address: "smtp.163.com",
50 | port: 25,
51 | domain: "163.com",
52 | authentication: :login,
53 | user_name: "***",
54 | password: "***"
55 | }
56 |
57 | end
58 |
--------------------------------------------------------------------------------
/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 | # Enable Rack::Cache to put a simple HTTP cache in front of your application
18 | # Add `rack-cache` to your Gemfile before enabling this.
19 | # For large-scale production use, consider using a caching reverse proxy like
20 | # NGINX, varnish or squid.
21 | # config.action_dispatch.rack_cache = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26 |
27 | # Compress JavaScripts and CSS.
28 | config.assets.js_compressor = :uglifier
29 | # config.assets.css_compressor = :sass
30 |
31 | # Do not fallback to assets pipeline if a precompiled asset is missed.
32 | config.assets.compile = false
33 |
34 | # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35 | # yet still be able to expire them through the digest params.
36 | config.assets.digest = true
37 |
38 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39 |
40 | # Specifies the header that your server uses for sending files.
41 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43 |
44 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45 | # config.force_ssl = true
46 |
47 | # Use the lowest log level to ensure availability of diagnostic information
48 | # when problems arise.
49 | config.log_level = :debug
50 |
51 | # Prepend all log lines with the following tags.
52 | # config.log_tags = [ :subdomain, :uuid ]
53 |
54 | # Use a different logger for distributed setups.
55 | # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56 |
57 | # Use a different cache store in production.
58 | # config.cache_store = :mem_cache_store
59 |
60 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61 | # config.action_controller.asset_host = 'http://assets.example.com'
62 |
63 | # Ignore bad email addresses and do not raise email delivery errors.
64 | # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65 | # config.action_mailer.raise_delivery_errors = false
66 |
67 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68 | # the I18n.default_locale when a translation cannot be found).
69 | config.i18n.fallbacks = true
70 |
71 | # Send deprecation notices to registered listeners.
72 | config.active_support.deprecation = :notify
73 |
74 | # Use default logging formatter so that PID and timestamp are not suppressed.
75 | config.log_formatter = ::Logger::Formatter.new
76 |
77 | # Do not dump schema after migrations.
78 | config.active_record.dump_schema_after_migration = false
79 |
80 | config.action_mailer.delivery_method = :smtp
81 | config.action_mailer.raise_delivery_errors = true
82 | config.action_mailer.perform_deliveries = true
83 | config.action_mailer.default :charset => "utf-8"
84 | config.action_mailer.smtp_settings = {
85 | address: "smtp.163.com",
86 | port: 25,
87 | domain: "163.com",
88 | authentication: :login,
89 | user_name: "***",
90 | password: "***"
91 | }
92 | end
93 |
--------------------------------------------------------------------------------
/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 static file server for tests with Cache-Control for performance.
16 | config.serve_static_files = true
17 | config.static_cache_control = 'public, max-age=3600'
18 |
19 | # Show full error reports and disable caching.
20 | config.consider_all_requests_local = true
21 | config.action_controller.perform_caching = false
22 |
23 | # Raise exceptions instead of rendering exception templates.
24 | config.action_dispatch.show_exceptions = false
25 |
26 | # Disable request forgery protection in test environment.
27 | config.action_controller.allow_forgery_protection = false
28 |
29 | # Tell Action Mailer not to deliver emails to the real world.
30 | # The :test delivery method accumulates sent emails in the
31 | # ActionMailer::Base.deliveries array.
32 | config.action_mailer.delivery_method = :test
33 |
34 | # Randomize the order test cases are executed.
35 | config.active_support.test_order = :random
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 |
--------------------------------------------------------------------------------
/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 |
9 | # Precompile additional assets.
10 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11 | # Rails.application.config.assets.precompile += %w( search.js )
12 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/cookies_serializer.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.action_dispatch.cookies_serializer = :json
4 |
--------------------------------------------------------------------------------
/config/initializers/default_settings.rb:
--------------------------------------------------------------------------------
1 | Settings.defaults[:page_size] = '5'
2 | Settings.defaults[:hot_comments_size] = '5'
3 | Settings.defaults[:hot_articles_size] = '5'
--------------------------------------------------------------------------------
/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 | # config.secret_key = '48dabe309d4f9d736ef024ca671919786b74f16af2e781065ebec71d88d4f3908f74ff7feb8ba5c6805093f0d449d3cfdefe171bad412f2f17ee808f6daae3c0'
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 = 'caiwenhn2008@163.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 401 status code 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 = 'c8001c788cbc503f9d11453875ff1470f6fe3d817f0e536e9bdb0b76edf2589d67b8524fc9efc64dfd0a535fab8a096c400d35a8d71be7e6eff702221e6fe61a'
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 | # Invalidates all the remember me tokens when the user signs out.
132 | config.expire_all_remember_me_on_sign_out = true
133 |
134 | # If true, extends the user's remember period when remembered via cookie.
135 | # config.extend_remember_period = false
136 |
137 | # Options to be passed to the created cookie. For instance, you can set
138 | # secure: true in order to force SSL only cookies.
139 | # config.rememberable_options = {}
140 |
141 | # ==> Configuration for :validatable
142 | # Range for password length.
143 | config.password_length = 8..128
144 |
145 | # Email regex used to validate email formats. It simply asserts that
146 | # one (and only one) @ exists in the given string. This is mainly
147 | # to give user feedback and not to assert the e-mail validity.
148 | # config.email_regexp = /\A[^@]+@[^@]+\z/
149 |
150 | # ==> Configuration for :timeoutable
151 | # The time you want to timeout the user session without activity. After this
152 | # time the user will be asked for credentials again. Default is 30 minutes.
153 | # config.timeout_in = 30.minutes
154 |
155 | # If true, expires auth token on session timeout.
156 | # config.expire_auth_token_on_timeout = false
157 |
158 | # ==> Configuration for :lockable
159 | # Defines which strategy will be used to lock an account.
160 | # :failed_attempts = Locks an account after a number of failed attempts to sign in.
161 | # :none = No lock strategy. You should handle locking by yourself.
162 | # config.lock_strategy = :failed_attempts
163 |
164 | # Defines which key will be used when locking and unlocking an account
165 | # config.unlock_keys = [ :email ]
166 |
167 | # Defines which strategy will be used to unlock an account.
168 | # :email = Sends an unlock link to the user email
169 | # :time = Re-enables login after a certain amount of time (see :unlock_in below)
170 | # :both = Enables both strategies
171 | # :none = No unlock strategy. You should handle unlocking by yourself.
172 | # config.unlock_strategy = :both
173 |
174 | # Number of authentication tries before locking an account if lock_strategy
175 | # is failed attempts.
176 | # config.maximum_attempts = 20
177 |
178 | # Time interval to unlock the account if :time is enabled as unlock_strategy.
179 | # config.unlock_in = 1.hour
180 |
181 | # Warn on the last attempt before the account is locked.
182 | # config.last_attempt_warning = true
183 |
184 | # ==> Configuration for :recoverable
185 | #
186 | # Defines which key will be used when recovering the password for an account
187 | # config.reset_password_keys = [ :email ]
188 |
189 | # Time interval you can reset your password with a reset password key.
190 | # Don't put a too small interval or your users won't have the time to
191 | # change their passwords.
192 | config.reset_password_within = 6.hours
193 |
194 | # ==> Configuration for :encryptable
195 | # Allow you to use another encryption algorithm besides bcrypt (default). You can use
196 | # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
197 | # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
198 | # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
199 | # REST_AUTH_SITE_KEY to pepper).
200 | #
201 | # Require the `devise-encryptable` gem when using anything other than bcrypt
202 | # config.encryptor = :sha512
203 |
204 | # ==> Scopes configuration
205 | # Turn scoped views on. Before rendering "sessions/new", it will first check for
206 | # "users/sessions/new". It's turned off by default because it's slower if you
207 | # are using only default views.
208 | config.scoped_views = true
209 |
210 | # Configure the default scope given to Warden. By default it's the first
211 | # devise role declared in your routes (usually :user).
212 | # config.default_scope = :user
213 |
214 | # Set this configuration to false if you want /users/sign_out to sign out
215 | # only the current scope. By default, Devise signs out all scopes.
216 | # config.sign_out_all_scopes = true
217 |
218 | # ==> Navigation configuration
219 | # Lists the formats that should be treated as navigational. Formats like
220 | # :html, should redirect to the sign in page when the user does not have
221 | # access, but formats like :xml or :json, should return 401.
222 | #
223 | # If you have any extra navigational formats, like :iphone or :mobile, you
224 | # should add them to the navigational formats lists.
225 | #
226 | # The "*/*" below is required to match Internet Explorer requests.
227 | # config.navigational_formats = ['*/*', :html]
228 |
229 | # The default HTTP method used to sign out a resource. Default is :delete.
230 | config.sign_out_via = :delete
231 |
232 | # ==> OmniAuth
233 | # Add a new OmniAuth provider. Check the wiki for more information on setting
234 | # up on your models and hooks.
235 | #config.omniauth :github, '4cbcf714c51af5909f23', '760e664aa1cb3050f459d261987e6985aaf48f55', scope: 'user,public_repo'
236 | config.omniauth :github, '35afc7183620bc9675d9', '34839b4a56705fb17ec7905205e71296857c494e', scope: 'user,public_repo'
237 | config.omniauth :qq_connect, '101200256', '36967d36cf508d3b1fcc24bf9f9aec6d', scope: 'user,public_repo'
238 | config.omniauth :weibo, '1053744505', '63262590e669fd65e7b309d0e94d53b3', scope: 'user,public_repo'
239 |
240 |
241 | # ==> Warden configuration
242 | # If you want to use other strategies, that are not supported by Devise, or
243 | # change the failure app, you can configure them inside the config.warden block.
244 | #
245 | # config.warden do |manager|
246 | # manager.intercept_401 = false
247 | # manager.default_strategies(scope: :user).unshift :some_external_strategy
248 | # end
249 |
250 | # ==> Mountable engine configurations
251 | # When using Devise inside an engine, let's call it `MyEngine`, and this engine
252 | # is mountable, there are some extra configurations to be taken into account.
253 | # The following options are available, assuming the engine is mounted as:
254 | #
255 | # mount MyEngine, at: '/my_engine'
256 | #
257 | # The router that invoked `devise_for`, in the example above, would be:
258 | # config.router_name = :my_engine
259 | #
260 | # When using omniauth, Devise cannot automatically set Omniauth path,
261 | # so you need to do it manually. For the users scope, it would be:
262 | # config.omniauth_path_prefix = '/my_engine/users/auth'
263 | end
264 |
--------------------------------------------------------------------------------
/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 |
--------------------------------------------------------------------------------
/config/initializers/rails_admin.rb:
--------------------------------------------------------------------------------
1 | RailsAdmin.config do |config|
2 |
3 | ### Popular gems integration
4 |
5 | ## == Devise ==
6 | config.authenticate_with do
7 | warden.authenticate! scope: :user
8 | end
9 | config.current_user_method(&:current_user)
10 |
11 | ## == Cancan ==
12 | config.authorize_with :cancan
13 |
14 | ## == PaperTrail ==
15 | # config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0
16 |
17 | ### More at https://github.com/sferik/rails_admin/wiki/Base-configuration
18 |
19 | config.actions do
20 | dashboard # mandatory
21 | index # mandatory
22 | new
23 | export
24 | bulk_delete
25 | show
26 | edit
27 | delete
28 | show_in_app
29 |
30 | ## With an audit adapter, you can add:
31 | # history_index
32 | # history_show
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/config/initializers/rails_settings_ui.rb:
--------------------------------------------------------------------------------
1 | require 'rails-settings-ui'
2 |
3 | #= Application-specific
4 | #
5 | # # You can specify a controller for RailsSettingsUi::ApplicationController to inherit from:
6 | # RailsSettingsUi.parent_controller = 'Admin::ApplicationController' # default: '::ApplicationController'
7 | #
8 | # # Render RailsSettingsUi inside a custom layout (set to 'application' to use app layout, default is RailsSettingsUi's own layout)
9 | # RailsSettingsUi::ApplicationController.layout 'admin'
10 |
11 | Rails.application.config.to_prepare do
12 | # If you use a *custom layout*, make route helpers available to RailsSettingsUi:
13 | # RailsSettingsUi.inline_main_app_routes!
14 | end
15 |
--------------------------------------------------------------------------------
/config/initializers/rolify.rb:
--------------------------------------------------------------------------------
1 | Rolify.configure do |config|
2 | # By default ORM adapter is ActiveRecord. uncomment to use mongoid
3 | # config.use_mongoid
4 |
5 | # Dynamic shortcuts for User class (user.is_admin? like methods). Default is: false
6 | # config.use_dynamic_shortcuts
7 | end
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Rails.application.config.session_store :cookie_store, key: '_OmniAuthDevise_session'
4 |
--------------------------------------------------------------------------------
/config/initializers/simple_form.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | # Wrappers are used by the form builder to generate a
4 | # complete input. You can remove any component from the
5 | # wrapper, change the order or even add your own to the
6 | # stack. The options given below are used to wrap the
7 | # whole input.
8 | config.wrappers :default, class: :input,
9 | hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10 | ## Extensions enabled by default
11 | # Any of these extensions can be disabled for a
12 | # given input by passing: `f.input EXTENSION_NAME => false`.
13 | # You can make any of these extensions optional by
14 | # renaming `b.use` to `b.optional`.
15 |
16 | # Determines whether to use HTML5 (:email, :url, ...)
17 | # and required attributes
18 | b.use :html5
19 |
20 | # Calculates placeholders automatically from I18n
21 | # You can also pass a string as f.input placeholder: "Placeholder"
22 | b.use :placeholder
23 |
24 | ## Optional extensions
25 | # They are disabled unless you pass `f.input EXTENSION_NAME => true`
26 | # to the input. If so, they will retrieve the values from the model
27 | # if any exists. If you want to enable any of those
28 | # extensions by default, you can change `b.optional` to `b.use`.
29 |
30 | # Calculates maxlength from length validations for string inputs
31 | b.optional :maxlength
32 |
33 | # Calculates pattern from format validations for string inputs
34 | b.optional :pattern
35 |
36 | # Calculates min and max from length validations for numeric inputs
37 | b.optional :min_max
38 |
39 | # Calculates readonly automatically from readonly attributes
40 | b.optional :readonly
41 |
42 | ## Inputs
43 | b.use :label_input
44 | b.use :hint, wrap_with: { tag: :span, class: :hint }
45 | b.use :error, wrap_with: { tag: :span, class: :error }
46 |
47 | ## full_messages_for
48 | # If you want to display the full error message for the attribute, you can
49 | # use the component :full_error, like:
50 | #
51 | # b.use :full_error, wrap_with: { tag: :span, class: :error }
52 | end
53 |
54 | # The default wrapper to be used by the FormBuilder.
55 | config.default_wrapper = :default
56 |
57 | # Define the way to render check boxes / radio buttons with labels.
58 | # Defaults to :nested for bootstrap config.
59 | # inline: input + label
60 | # nested: label > input
61 | config.boolean_style = :nested
62 |
63 | # Default class for buttons
64 | config.button_class = 'btn'
65 |
66 | # Method used to tidy up errors. Specify any Rails Array method.
67 | # :first lists the first message for each field.
68 | # Use :to_sentence to list all errors for each field.
69 | # config.error_method = :first
70 |
71 | # Default tag used for error notification helper.
72 | config.error_notification_tag = :div
73 |
74 | # CSS class to add for error notification helper.
75 | config.error_notification_class = 'error_notification'
76 |
77 | # ID to add for error notification helper.
78 | # config.error_notification_id = nil
79 |
80 | # Series of attempts to detect a default label method for collection.
81 | # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
82 |
83 | # Series of attempts to detect a default value method for collection.
84 | # config.collection_value_methods = [ :id, :to_s ]
85 |
86 | # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
87 | # config.collection_wrapper_tag = nil
88 |
89 | # You can define the class to use on all collection wrappers. Defaulting to none.
90 | # config.collection_wrapper_class = nil
91 |
92 | # You can wrap each item in a collection of radio/check boxes with a tag,
93 | # defaulting to :span. Please note that when using :boolean_style = :nested,
94 | # SimpleForm will force this option to be a label.
95 | # config.item_wrapper_tag = :span
96 |
97 | # You can define a class to use in all item wrappers. Defaulting to none.
98 | # config.item_wrapper_class = nil
99 |
100 | # How the label text should be generated altogether with the required text.
101 | # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
102 |
103 | # You can define the class to use on all labels. Default is nil.
104 | # config.label_class = nil
105 |
106 | # You can define the default class to be used on forms. Can be overriden
107 | # with `html: { :class }`. Defaulting to none.
108 | # config.default_form_class = nil
109 |
110 | # You can define which elements should obtain additional classes
111 | # config.generate_additional_classes_for = [:wrapper, :label, :input]
112 |
113 | # Whether attributes are required by default (or not). Default is true.
114 | # config.required_by_default = true
115 |
116 | # Tell browsers whether to use the native HTML5 validations (novalidate form option).
117 | # These validations are enabled in SimpleForm's internal config but disabled by default
118 | # in this configuration, which is recommended due to some quirks from different browsers.
119 | # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
120 | # change this configuration to true.
121 | config.browser_validations = false
122 |
123 | # Collection of methods to detect if a file type was given.
124 | # config.file_methods = [ :mounted_as, :file?, :public_filename ]
125 |
126 | # Custom mappings for input types. This should be a hash containing a regexp
127 | # to match as key, and the input type that will be used when the field name
128 | # matches the regexp as value.
129 | # config.input_mappings = { /count/ => :integer }
130 |
131 | # Custom wrappers for input types. This should be a hash containing an input
132 | # type as key and the wrapper that will be used for all inputs with specified type.
133 | # config.wrapper_mappings = { string: :prepend }
134 |
135 | # Namespaces where SimpleForm should look for custom input classes that
136 | # override default inputs.
137 | # config.custom_inputs_namespaces << "CustomInputs"
138 |
139 | # Default priority for time_zone inputs.
140 | # config.time_zone_priority = nil
141 |
142 | # Default priority for country inputs.
143 | # config.country_priority = nil
144 |
145 | # When false, do not use translations for labels.
146 | # config.translate_labels = true
147 |
148 | # Automatically discover new inputs in Rails' autoload path.
149 | # config.inputs_discovery = true
150 |
151 | # Cache SimpleForm inputs discovery
152 | # config.cache_discovery = !Rails.env.development?
153 |
154 | # Default class for inputs
155 | # config.input_class = nil
156 |
157 | # Define the default class of the input wrapper of the boolean input.
158 | config.boolean_label_class = 'checkbox'
159 |
160 | # Defines if the default input wrapper class should be included in radio
161 | # collection wrappers.
162 | # config.include_default_input_wrapper_class = true
163 |
164 | # Defines which i18n scope will be used in Simple Form.
165 | # config.i18n_scope = 'simple_form'
166 | end
167 |
--------------------------------------------------------------------------------
/config/initializers/simple_form_bootstrap.rb:
--------------------------------------------------------------------------------
1 | # Use this setup block to configure all options available in SimpleForm.
2 | SimpleForm.setup do |config|
3 | config.error_notification_class = 'alert alert-danger'
4 | config.button_class = 'btn btn-default'
5 | config.boolean_label_class = nil
6 |
7 | config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
8 | b.use :html5
9 | b.use :placeholder
10 | b.optional :maxlength
11 | b.optional :pattern
12 | b.optional :min_max
13 | b.optional :readonly
14 | b.use :label, class: 'control-label'
15 |
16 | b.use :input, class: 'form-control'
17 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
18 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
19 | end
20 |
21 | config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
22 | b.use :html5
23 | b.use :placeholder
24 | b.optional :maxlength
25 | b.optional :readonly
26 | b.use :label, class: 'control-label'
27 |
28 | b.use :input
29 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
30 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
31 | end
32 |
33 | config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
34 | b.use :html5
35 | b.optional :readonly
36 |
37 | b.wrapper tag: 'div', class: 'checkbox' do |ba|
38 | ba.use :label_input
39 | end
40 |
41 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
42 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
43 | end
44 |
45 | config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
46 | b.use :html5
47 | b.optional :readonly
48 | b.use :label, class: 'control-label'
49 | b.use :input
50 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
51 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
52 | end
53 |
54 | config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
55 | b.use :html5
56 | b.use :placeholder
57 | b.optional :maxlength
58 | b.optional :pattern
59 | b.optional :min_max
60 | b.optional :readonly
61 | b.use :label, class: 'col-sm-3 control-label'
62 |
63 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
64 | ba.use :input, class: 'form-control'
65 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
66 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
67 | end
68 | end
69 |
70 | config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
71 | b.use :html5
72 | b.use :placeholder
73 | b.optional :maxlength
74 | b.optional :readonly
75 | b.use :label, class: 'col-sm-3 control-label'
76 |
77 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
78 | ba.use :input
79 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
80 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
81 | end
82 | end
83 |
84 | config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
85 | b.use :html5
86 | b.optional :readonly
87 |
88 | b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr|
89 | wr.wrapper tag: 'div', class: 'checkbox' do |ba|
90 | ba.use :label_input, class: 'col-sm-9'
91 | end
92 |
93 | wr.use :error, wrap_with: { tag: 'span', class: 'help-block' }
94 | wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
95 | end
96 | end
97 |
98 | config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
99 | b.use :html5
100 | b.optional :readonly
101 |
102 | b.use :label, class: 'col-sm-3 control-label'
103 |
104 | b.wrapper tag: 'div', class: 'col-sm-9' do |ba|
105 | ba.use :input
106 | ba.use :error, wrap_with: { tag: 'span', class: 'help-block' }
107 | ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
108 | end
109 | end
110 |
111 | config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
112 | b.use :html5
113 | b.use :placeholder
114 | b.optional :maxlength
115 | b.optional :pattern
116 | b.optional :min_max
117 | b.optional :readonly
118 | b.use :label, class: 'sr-only'
119 |
120 | b.use :input, class: 'form-control'
121 | b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
122 | b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
123 | end
124 |
125 | # Wrappers for forms and inputs using the Bootstrap toolkit.
126 | # Check the Bootstrap docs (http://getbootstrap.com)
127 | # to learn about the different styles for forms and inputs,
128 | # buttons and other elements.
129 | config.default_wrapper = :vertical_form
130 | config.wrapper_mappings = {
131 | check_boxes: :vertical_radio_and_checkboxes,
132 | radio_buttons: :vertical_radio_and_checkboxes,
133 | file: :vertical_file_input,
134 | boolean: :vertical_boolean,
135 | }
136 | end
137 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/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 | 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 has been changed successfully. You are now signed in."
34 | updated_not_active: "Your password has been changed successfully."
35 | registrations:
36 | destroyed: "Bye! Your account has been 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 follow 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 follow the confirm link to confirm your new email address."
42 | updated: "Your account has been updated successfully."
43 | sessions:
44 | signed_in: "Signed in successfully."
45 | signed_out: "Signed out successfully."
46 | already_signed_out: "Signed out successfully."
47 | unlocks:
48 | send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
49 | send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
50 | unlocked: "Your account has been unlocked successfully. Please sign in to continue."
51 | errors:
52 | messages:
53 | already_confirmed: "was already confirmed, please try signing in"
54 | confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
55 | expired: "has expired, please request a new one"
56 | not_found: "not found"
57 | not_locked: "was not locked"
58 | not_saved:
59 | one: "1 error prohibited this %{resource} from being saved:"
60 | other: "%{count} errors prohibited this %{resource} from being saved:"
61 |
--------------------------------------------------------------------------------
/config/locales/en.bootstrap.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | breadcrumbs:
6 | application:
7 | root: "Index"
8 | pages:
9 | pages: "Pages"
10 | helpers:
11 | actions: "Actions"
12 | links:
13 | back: "Back"
14 | cancel: "Cancel"
15 | confirm: "Are you sure?"
16 | destroy: "Delete"
17 | new: "New"
18 | edit: "Edit"
19 | titles:
20 | edit: "Edit %{model}"
21 | save: "Save %{model}"
22 | new: "New %{model}"
23 | delete: "Delete %{model}"
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 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 | settings:
25 | attributes:
26 | page_size: # setting name
27 | name: '分页【每页文章数】'
28 | hot_comments_size:
29 | name: '热门评论数量'
30 | hot_articles_size:
31 | name: '热门文章数量'
--------------------------------------------------------------------------------
/config/locales/pagination.yml:
--------------------------------------------------------------------------------
1 | en:
2 | views:
3 | pagination:
4 | first: "首页"
5 | last: "末页"
6 | previous: "‹ 前一页"
7 | next: "后一页 ›"
8 | truncate: "…"
9 | helpers:
10 | page_entries_info:
11 | one_page:
12 | display_entries:
13 | zero: "No %{entry_name} found"
14 | one: "Displaying 1 %{entry_name}"
15 | other: "Displaying all %{count} %{entry_name}"
16 | more_pages:
17 | display_entries: "Displaying %{entry_name} %{first} - %{last} of %{total} in total"
--------------------------------------------------------------------------------
/config/locales/simple_form.en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | simple_form:
3 | "yes": 'Yes'
4 | "no": 'No'
5 | required:
6 | text: 'required'
7 | mark: '*'
8 | # You can uncomment the line below if you need to overwrite the whole required html.
9 | # When using html, text and mark won't be used.
10 | # html: '*'
11 | error_notification:
12 | default_message: "问题来啦,请重新输入!"
13 | labels:
14 | defaults:
15 | password: '密码'
16 | password_confirmation: '确认密码'
17 |
18 | user:
19 | new:
20 | email: '邮件地址'
21 | avatar: '头像'
22 | edit:
23 | email: 'E-mail.'
24 | hints:
25 | defaults:
26 | username: 'User name to sign in.'
27 | password: '*请不要输入特殊字符'
28 | include_blanks:
29 | defaults:
30 | age: 'Rather not say'
31 | prompts:
32 | defaults:
33 | age: 'Select your age'
34 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env puma
2 |
3 | environment 'development'
4 | threads 2, 32 # minimum 2 threads, maximum 64 threads
5 | workers 2
6 |
7 | app_name = 'rails4blog'
8 |
9 | application_path = "#{ENV["rails_app_home"]}/#{app_name}"
10 |
11 | directory "#{application_path}"
12 |
13 | pidfile "#{application_path}/shared/tmp/pids/puma.pid"
14 | state_path "#{application_path}/shared/tmp/sockets/puma.state"
15 | stdout_redirect "#{application_path}/shared/log/puma.stdout.log", "#{application_path}/shared/log/puma.stderr.log"
16 |
17 |
18 | # bind "unix://#{application_path}/shared/tmp/sockets/puma.sock" #绑定sock
19 | bind 'tcp://127.0.0.1:3000' #绑定端口801
20 | worker_timeout 60
21 |
22 | #daemonize true
23 |
24 | preload_app!
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | Rails.application.routes.draw do
2 | mount RailsSettingsUi::Engine, at: 'settings'
3 | mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
4 | devise_for :users, :controllers => { :omniauth_callbacks => "callbacks" }
5 |
6 | resources :articles
7 | resources :articles do
8 | resources :comments
9 | end
10 |
11 | root 'articles#index'
12 |
13 |
14 | # The priority is based upon order of creation: first created -> highest priority.
15 | # See how all your routes lay out with "rake routes".
16 |
17 | # You can have the root of your site routed with "root"
18 | # root 'welcome#index'
19 |
20 | # Example of regular route:
21 | # get 'products/:id' => 'catalog#view'
22 |
23 | # Example of named route that can be invoked with purchase_url(id: product.id)
24 | # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
25 |
26 | # Example resource route (maps HTTP verbs to controller actions automatically):
27 | # resources :products
28 |
29 | # Example resource route with options:
30 | # resources :products do
31 | # member do
32 | # get 'short'
33 | # post 'toggle'
34 | # end
35 | #
36 | # collection do
37 | # get 'sold'
38 | # end
39 | # end
40 |
41 | # Example resource route with sub-resources:
42 | # resources :products do
43 | # resources :comments, :sales
44 | # resource :seller
45 | # end
46 |
47 | # Example resource route with more complex sub-resources:
48 | # resources :products do
49 | # resources :comments
50 | # resources :sales do
51 | # get 'recent', on: :collection
52 | # end
53 | # end
54 |
55 | # Example resource route with concerns:
56 | # concern :toggleable do
57 | # post 'toggle'
58 | # end
59 | # resources :posts, concerns: :toggleable
60 | # resources :photos, concerns: :toggleable
61 |
62 | # Example resource route within a namespace:
63 | # namespace :admin do
64 | # # Directs /admin/products/* to Admin::ProductsController
65 | # # (app/controllers/admin/products_controller.rb)
66 | # resources :products
67 | # end
68 | end
69 |
--------------------------------------------------------------------------------
/config/secrets.yml:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rake secret` to generate a secure secret key.
9 |
10 | # Make sure the secrets in this file are kept private
11 | # if you're sharing your code publicly.
12 |
13 | development:
14 | secret_key_base: 4c0e6da17cdae2cac243ac22a982eae491cc34f22fea7b0e67288b467008257960e92c53a91b40a3439280d154b7cb5169cae79a76c0c7e0782dbe5397a704d6
15 |
16 | test:
17 | secret_key_base: 76227fbc24de7df49093a580fd2802ad4998daec1fac059bca725fbf7242686b693e36b16723f8da775fc6a704fd2582a370c852d849252c228da52b5ec93f29
18 |
19 | # Do not keep production secrets in the repository,
20 | # instead read values from the environment.
21 | production:
22 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
23 |
--------------------------------------------------------------------------------
/db/migrate/20150303150726_devise_create_users.rb:
--------------------------------------------------------------------------------
1 | class DeviseCreateUsers < ActiveRecord::Migration
2 | def change
3 | create_table(:users) do |t|
4 | ## Database authenticatable
5 | t.string :email, null: false, default: ""
6 | t.string :encrypted_password, null: false, default: ""
7 |
8 | ## Recoverable
9 | t.string :reset_password_token
10 | t.datetime :reset_password_sent_at
11 |
12 | ## Rememberable
13 | t.datetime :remember_created_at
14 |
15 | ## Trackable
16 | t.integer :sign_in_count, default: 0, null: false
17 | t.datetime :current_sign_in_at
18 | t.datetime :last_sign_in_at
19 | t.string :current_sign_in_ip
20 | t.string :last_sign_in_ip
21 |
22 | ## Confirmable
23 | # t.string :confirmation_token
24 | # t.datetime :confirmed_at
25 | # t.datetime :confirmation_sent_at
26 | # t.string :unconfirmed_email # Only if using reconfirmable
27 |
28 | ## Lockable
29 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
30 | # t.string :unlock_token # Only if unlock strategy is :email or :both
31 | # t.datetime :locked_at
32 |
33 |
34 | t.timestamps
35 | end
36 |
37 | add_index :users, :email, unique: true
38 | add_index :users, :reset_password_token, unique: true
39 | # add_index :users, :confirmation_token, unique: true
40 | # add_index :users, :unlock_token, unique: true
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/db/migrate/20150303150952_add_columns_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddColumnsToUsers < ActiveRecord::Migration
2 | def change
3 | add_column :users, :provider, :string
4 | add_column :users, :uid, :string
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20150307065926_create_articles.rb:
--------------------------------------------------------------------------------
1 | class CreateArticles < ActiveRecord::Migration
2 | def change
3 | create_table :articles do |t|
4 | t.string :title
5 | t.text :text
6 |
7 | t.timestamps null: false
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20150307074427_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration
2 | def change
3 | create_table :comments do |t|
4 | t.string :commenter
5 | t.text :body
6 | t.references :article, index: true
7 |
8 | t.timestamps null: false
9 | end
10 | add_foreign_key :comments, :articles
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20150315103101_add_view_count_to_articles.rb:
--------------------------------------------------------------------------------
1 | class AddViewCountToArticles < ActiveRecord::Migration
2 | def change
3 | add_column :articles, :view_count, :integer
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20150315112806_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 1)
2 | class ActsAsTaggableOnMigration < ActiveRecord::Migration
3 | def self.up
4 | create_table :tags do |t|
5 | t.string :name
6 | end
7 |
8 | create_table :taggings do |t|
9 | t.references :tag
10 |
11 | # You should make sure that the column created is
12 | # long enough to store the required class names.
13 | t.references :taggable, polymorphic: true
14 | t.references :tagger, polymorphic: true
15 |
16 | # Limit is created to prevent MySQL error on index
17 | # length for MyISAM table type: http://bit.ly/vgW2Ql
18 | t.string :context, limit: 128
19 |
20 | t.datetime :created_at
21 | end
22 |
23 | add_index :taggings, :tag_id
24 | add_index :taggings, [:taggable_id, :taggable_type, :context]
25 | end
26 |
27 | def self.down
28 | drop_table :taggings
29 | drop_table :tags
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/db/migrate/20150315112807_add_missing_unique_indices.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 2)
2 | class AddMissingUniqueIndices < ActiveRecord::Migration
3 | def self.up
4 | add_index :tags, :name, unique: true
5 |
6 | remove_index :taggings, :tag_id
7 | remove_index :taggings, [:taggable_id, :taggable_type, :context]
8 | add_index :taggings,
9 | [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
10 | unique: true, name: 'taggings_idx'
11 | end
12 |
13 | def self.down
14 | remove_index :tags, :name
15 |
16 | remove_index :taggings, name: 'taggings_idx'
17 | add_index :taggings, :tag_id
18 | add_index :taggings, [:taggable_id, :taggable_type, :context]
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/db/migrate/20150315112808_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 3)
2 | class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
3 | def self.up
4 | add_column :tags, :taggings_count, :integer, default: 0
5 |
6 | ActsAsTaggableOn::Tag.reset_column_information
7 | ActsAsTaggableOn::Tag.find_each do |tag|
8 | ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
9 | end
10 | end
11 |
12 | def self.down
13 | remove_column :tags, :taggings_count
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/db/migrate/20150315112809_add_missing_taggable_index.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 4)
2 | class AddMissingTaggableIndex < ActiveRecord::Migration
3 | def self.up
4 | add_index :taggings, [:taggable_id, :taggable_type, :context]
5 | end
6 |
7 | def self.down
8 | remove_index :taggings, [:taggable_id, :taggable_type, :context]
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20150315112810_change_collation_for_tag_names.acts_as_taggable_on_engine.rb:
--------------------------------------------------------------------------------
1 | # This migration comes from acts_as_taggable_on_engine (originally 5)
2 | # This migration is added to circumvent issue #623 and have special characters
3 | # work properly
4 | class ChangeCollationForTagNames < ActiveRecord::Migration
5 | def up
6 | if ActsAsTaggableOn::Utils.using_mysql?
7 | execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20150315142442_rolify_create_roles.rb:
--------------------------------------------------------------------------------
1 | class RolifyCreateRoles < ActiveRecord::Migration
2 | def change
3 | create_table(:roles) do |t|
4 | t.string :name
5 | t.references :resource, :polymorphic => true
6 |
7 | t.timestamps
8 | end
9 |
10 | create_table(:users_roles, :id => false) do |t|
11 | t.references :user
12 | t.references :role
13 | end
14 |
15 | add_index(:roles, :name)
16 | add_index(:roles, [ :name, :resource_type, :resource_id ])
17 | add_index(:users_roles, [ :user_id, :role_id ])
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/db/migrate/20150318150436_add_avatar_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddAvatarToUsers < ActiveRecord::Migration
2 | def change
3 | add_column :users, :avatar, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20150321020003_create_settings.rb:
--------------------------------------------------------------------------------
1 | class CreateSettings < ActiveRecord::Migration
2 | def self.up
3 | create_table :settings do |t|
4 | t.string :var, :null => false
5 | t.text :value, :null => true
6 | t.integer :thing_id, :null => true
7 | t.string :thing_type, :limit => 30, :null => true
8 | t.timestamps
9 | end
10 |
11 | add_index :settings, [ :thing_type, :thing_id, :var ], :unique => true
12 | end
13 |
14 | def self.down
15 | drop_table :settings
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
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: 20150321020003) do
15 |
16 | create_table "articles", force: :cascade do |t|
17 | t.string "title"
18 | t.text "text"
19 | t.datetime "created_at", null: false
20 | t.datetime "updated_at", null: false
21 | t.integer "view_count"
22 | end
23 |
24 | create_table "comments", force: :cascade do |t|
25 | t.string "commenter"
26 | t.text "body"
27 | t.integer "article_id"
28 | t.datetime "created_at", null: false
29 | t.datetime "updated_at", null: false
30 | end
31 |
32 | add_index "comments", ["article_id"], name: "index_comments_on_article_id"
33 |
34 | create_table "roles", force: :cascade do |t|
35 | t.string "name"
36 | t.integer "resource_id"
37 | t.string "resource_type"
38 | t.datetime "created_at"
39 | t.datetime "updated_at"
40 | end
41 |
42 | add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
43 | add_index "roles", ["name"], name: "index_roles_on_name"
44 |
45 | create_table "settings", force: :cascade do |t|
46 | t.string "var", null: false
47 | t.text "value"
48 | t.integer "thing_id"
49 | t.string "thing_type", limit: 30
50 | t.datetime "created_at"
51 | t.datetime "updated_at"
52 | end
53 |
54 | add_index "settings", ["thing_type", "thing_id", "var"], name: "index_settings_on_thing_type_and_thing_id_and_var", unique: true
55 |
56 | create_table "taggings", force: :cascade do |t|
57 | t.integer "tag_id"
58 | t.integer "taggable_id"
59 | t.string "taggable_type"
60 | t.integer "tagger_id"
61 | t.string "tagger_type"
62 | t.string "context", limit: 128
63 | t.datetime "created_at"
64 | end
65 |
66 | add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
67 | add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
68 |
69 | create_table "tags", force: :cascade do |t|
70 | t.string "name"
71 | t.integer "taggings_count", default: 0
72 | end
73 |
74 | add_index "tags", ["name"], name: "index_tags_on_name", unique: true
75 |
76 | create_table "users", force: :cascade do |t|
77 | t.string "email", default: "", null: false
78 | t.string "encrypted_password", default: "", null: false
79 | t.string "reset_password_token"
80 | t.datetime "reset_password_sent_at"
81 | t.datetime "remember_created_at"
82 | t.integer "sign_in_count", default: 0, null: false
83 | t.datetime "current_sign_in_at"
84 | t.datetime "last_sign_in_at"
85 | t.string "current_sign_in_ip"
86 | t.string "last_sign_in_ip"
87 | t.datetime "created_at"
88 | t.datetime "updated_at"
89 | t.string "provider"
90 | t.string "uid"
91 | t.string "avatar"
92 | end
93 |
94 | add_index "users", ["email"], name: "index_users_on_email", unique: true
95 | add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
96 |
97 | create_table "users_roles", id: false, force: :cascade do |t|
98 | t.integer "user_id"
99 | t.integer "role_id"
100 | end
101 |
102 | add_index "users_roles", ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id"
103 |
104 | end
105 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 | # Mayor.create(name: 'Emanuel', city: cities.first)
8 |
--------------------------------------------------------------------------------
/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caiwenhn2008/rails4blog/8950ad421418895570653fc9c7b8712e4d815fea/lib/assets/.keep
--------------------------------------------------------------------------------
/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caiwenhn2008/rails4blog/8950ad421418895570653fc9c7b8712e4d815fea/lib/tasks/.keep
--------------------------------------------------------------------------------
/lib/templates/haml/scaffold/_form.html.haml:
--------------------------------------------------------------------------------
1 | = simple_form_for(@<%= singular_table_name %>) do |f|
2 | = f.error_notification
3 |
4 | .form-inputs
5 | <%- attributes.each do |attribute| -%>
6 | = f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
7 | <%- end -%>
8 |
9 | .form-actions
10 | = f.button :submit
11 |
--------------------------------------------------------------------------------
/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caiwenhn2008/rails4blog/8950ad421418895570653fc9c7b8712e4d815fea/log/.keep
--------------------------------------------------------------------------------
/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.
<%= comment.body %>
30 |