diff --git a/Gemfile b/Gemfile index 6b1563f4..d1953626 100644 --- a/Gemfile +++ b/Gemfile @@ -1,21 +1,27 @@ source 'https://rubygems.org' -ruby "2.2.3" +ruby '2.2.3' -gem 'rails', '4.2.0' +gem 'rails' gem 'jquery-rails' -gem 'sass-rails', '~> 4.0.3', require: 'sass' -gem 'coffee-rails', '~> 4.0.0' +gem 'sass-rails' +gem 'coffee-rails' gem 'paperclip', '~> 4.2.0' gem 'rmagick', '2.13.4' gem 'aws-sdk', '~> 1.50' -gem 'bcrypt', '~> 3.1.10', platforms: [:ruby, :mingw, :x64_mingw] +gem 'devise' +gem 'material_icons' + +# Libraries +#gem 'serendipitous', :path => "~/Code/indent/serendipitous-gem" +gem 'serendipitous', :git => 'git://github.com/indentlabs/serendipitous-gem.git' group :production do gem 'less-rails' gem 'less-rails-fontawesome' gem 'uglifier', '>= 1.3.0' gem 'bootplus-rails' + #gem 'rails_12factor' end group :test, :production do diff --git a/Gemfile.lock b/Gemfile.lock index 904c0215..c96e21c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,8 @@ +PATH + remote: ~/Code/indent/serendipitous-gem + specs: + serendipitous (0.0.2) + GEM remote: https://rubygems.org/ specs: @@ -45,7 +50,6 @@ GEM json (~> 1.4) nokogiri (>= 1.4.4) bcrypt (3.1.11) - bcrypt (3.1.11-x86-mingw32) better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) @@ -83,11 +87,17 @@ GEM thor (~> 0.19.1) tins (~> 1.6.0) debug_inspector (0.0.2) + devise (3.5.6) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 3.2.6, < 5) + responders + thread_safe (~> 0.1) + warden (~> 1.2.3) docile (1.1.5) erubis (2.7.0) execjs (2.6.0) ffi (1.9.10) - ffi (1.9.10-x86-mingw32) formatador (0.2.5) globalid (0.3.6) activesupport (>= 4.1.0) @@ -130,6 +140,8 @@ GEM lumberjack (1.0.10) mail (2.6.4) mime-types (>= 1.16, < 4) + material_icons (2.2.0) + railties (>= 3.2) method_source (0.8.2) mime-types (3.0) mime-types-data (~> 3.2015) @@ -140,11 +152,10 @@ GEM nenv (0.3.0) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) - nokogiri (1.6.7.2-x86-mingw32) - mini_portile2 (~> 2.0.0.rc2) notiffany (0.0.8) nenv (~> 0.1) shellany (~> 0.0) + orm_adapter (0.5.0) paperclip (4.2.4) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -153,7 +164,6 @@ GEM parser (2.3.0.7) ast (~> 2.2) pg (0.18.4) - pg (0.18.4-x86-mingw32) powerpack (0.1.1) pry (0.10.3) coderay (~> 1.1.0) @@ -192,6 +202,8 @@ GEM rb-inotify (0.9.7) ffi (>= 0.5.0) ref (2.0.0) + responders (2.1.2) + railties (>= 4.2.0, < 5.1) rmagick (2.13.4) rubocop (0.39.0) parser (>= 2.3.0.7, < 3.0) @@ -228,7 +240,6 @@ GEM activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) sqlite3 (1.3.11) - sqlite3 (1.3.11-x86-mingw32) term-ansicolor (1.3.2) tins (~> 1.0) therubyracer (0.12.2) @@ -245,37 +256,40 @@ GEM uglifier (3.0.0) execjs (>= 0.3.0, < 3) unicode-display_width (1.0.3) - websocket (1.2.2) + warden (1.2.6) + rack (>= 1.0) + websocket (1.2.3) xpath (2.0.0) nokogiri (~> 1.3) PLATFORMS ruby - x86-mingw32 DEPENDENCIES aws-sdk (~> 1.50) - bcrypt (~> 3.1.10) better_errors binding_of_caller bootplus-rails capybara - coffee-rails (~> 4.0.0) + coffee-rails coveralls + devise guard guard-minitest guard-rubocop jquery-rails less-rails less-rails-fontawesome + material_icons paperclip (~> 4.2.0) pg pry - rails (= 4.2.0) + rails rmagick (= 2.13.4) rubocop - sass-rails (~> 4.0.3) + sass-rails selenium-webdriver + serendipitous! simplecov sqlite3 therubyracer diff --git a/Rakefile b/Rakefile index c1d941e9..ff6f1149 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,2 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically -# be available to Rake. - require File.expand_path('../config/application', __FILE__) -require 'rubocop/rake_task' - -RuboCop::RakeTask.new -task default: 'rubocop' - Rails.application.load_tasks diff --git a/app/assets/images/card-headers/characters.jpg b/app/assets/images/card-headers/characters.jpg index d8170332..c9d1d1ef 100644 Binary files a/app/assets/images/card-headers/characters.jpg and b/app/assets/images/card-headers/characters.jpg differ diff --git a/app/assets/images/card-headers/items.jpg b/app/assets/images/card-headers/items.jpg new file mode 100644 index 00000000..15786687 Binary files /dev/null and b/app/assets/images/card-headers/items.jpg differ diff --git a/app/assets/images/card-headers/locations.jpg b/app/assets/images/card-headers/locations.jpg index 42885a30..6d726b12 100644 Binary files a/app/assets/images/card-headers/locations.jpg and b/app/assets/images/card-headers/locations.jpg differ diff --git a/app/assets/images/card-headers/universes.jpg b/app/assets/images/card-headers/universes.jpg index be037947..d110c17c 100644 Binary files a/app/assets/images/card-headers/universes.jpg and b/app/assets/images/card-headers/universes.jpg differ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 3b5cc664..625943f9 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -9,5 +9,6 @@ * compiled file, but it's generally better to create a new file per style scope. * *= require_self + *= require material_icons *= require_tree . */ diff --git a/app/assets/stylesheets/cards.css.scss b/app/assets/stylesheets/cards.css.scss deleted file mode 100644 index fcdf8f4b..00000000 --- a/app/assets/stylesheets/cards.css.scss +++ /dev/null @@ -1,53 +0,0 @@ -.card { - margin: 10px 0; - padding-top: 15px; - border: 1px solid #d8d8d8; - border-bottom-width: 2px; - border-top-width: 0; - background-color: #ffffff; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -box-sizing: border-box; - - .card-heading { - text-transform: capitalize; - border-bottom: 1px solid #e5e5e5; - color: #777; - font-size: 20px; - font-weight: 300; - margin: 0 -15px; - padding: 0px 35px 10px 35px; - } - - .card-image { - - } - - .card-body { - padding: 10px 20px; - font-family: Roboto, arial, sans-serif; - font-size: 13px; - line-height: 20px; - color: #444444; - - h2 { - font-size: 29px; - small { - font-size: 16px; - } - } - } - - .card-comments { - padding: 20px; - margin: 0; - background-color: #f8f8f8; - } - -} diff --git a/app/assets/stylesheets/content.css b/app/assets/stylesheets/content.css deleted file mode 100644 index afad32db..00000000 --- a/app/assets/stylesheets/content.css +++ /dev/null @@ -1,4 +0,0 @@ -/* - Place all the styles related to the matching controller here. - They will automatically be included in application.css. -*/ diff --git a/app/assets/stylesheets/footer.css b/app/assets/stylesheets/footer.css new file mode 100644 index 00000000..4676cac6 --- /dev/null +++ b/app/assets/stylesheets/footer.css @@ -0,0 +1,9 @@ + body { + display: flex; + min-height: 100vh; + flex-direction: column; + } + + main { + flex: 1 0 auto; + } \ No newline at end of file diff --git a/app/assets/stylesheets/forms.css.scss b/app/assets/stylesheets/forms.css.scss deleted file mode 100644 index af6fb1e6..00000000 --- a/app/assets/stylesheets/forms.css.scss +++ /dev/null @@ -1,21 +0,0 @@ -form { - .text_field { - padding: 0 8px; - border-top: 1px solid #c0c0c0; - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - min-height: 29px; - background-color: #ffffff; - border: 1px solid #d9d9d9; - -webkit-transition: border linear .2s, box-shadow linear .2s; - -moz-transition: border linear .2s, box-shadow linear .2s; - -o-transition: border linear .2s, box-shadow linear .2s; - transition: border linear .2s, box-shadow linear .2s; - } -} - -#placeholder_map_input { - width: 100%; - display: block; -} \ No newline at end of file diff --git a/app/assets/stylesheets/landing.css.scss b/app/assets/stylesheets/landing.css.scss deleted file mode 100644 index 850cadf7..00000000 --- a/app/assets/stylesheets/landing.css.scss +++ /dev/null @@ -1,12 +0,0 @@ -#landing-page-1 { - - #content-types { - .card { - img { - height: 200px; - width: 100%; - } - min-height: 400px; - } - } -} diff --git a/app/assets/stylesheets/languages.css.scss b/app/assets/stylesheets/languages.css.scss deleted file mode 100644 index 32d25fab..00000000 --- a/app/assets/stylesheets/languages.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the languages controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/navbar.css.scss b/app/assets/stylesheets/navbar.css.scss deleted file mode 100644 index d7740ac4..00000000 --- a/app/assets/stylesheets/navbar.css.scss +++ /dev/null @@ -1,21 +0,0 @@ -.navbar-fixed-top { - border-bottom: 1px solid #d8d8d8 !important; - background-color: #ffffff; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - -box-sizing: border-box; - - & a { - color: #777777; - &:hover { - color: #000000; - } - } -} - diff --git a/app/assets/stylesheets/structure.css.scss b/app/assets/stylesheets/structure.css.scss deleted file mode 100644 index 5bf25761..00000000 --- a/app/assets/stylesheets/structure.css.scss +++ /dev/null @@ -1,7 +0,0 @@ -.footer { - margin-top: 120px; - - & p { - text-align: center; - } -} diff --git a/app/assets/stylesheets/tabs.css.scss b/app/assets/stylesheets/tabs.css.scss deleted file mode 100644 index b7ff677b..00000000 --- a/app/assets/stylesheets/tabs.css.scss +++ /dev/null @@ -1,5 +0,0 @@ -.nav-stacked { - .active { - border-left: 3px solid #777; - } -} \ No newline at end of file diff --git a/app/assets/stylesheets/theme.css.scss b/app/assets/stylesheets/theme.css.scss deleted file mode 100644 index a67b2074..00000000 --- a/app/assets/stylesheets/theme.css.scss +++ /dev/null @@ -1,8 +0,0 @@ -body { - margin-top: 60px !important; - background: #e5e5e5 !important; -} - -.section { - margin: 30px 0; -} \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 57240319..272eb65f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,71 +2,6 @@ class ApplicationController < ActionController::Base protect_from_forgery - helper :html - helper :my_content - - helper_method :nl2br - helper_method :universe_filter - - # Rails changed cookie format in rails 4, so log out all old users so that - # they get the new version - rescue_from JSON::ParserError, with: :force_user_logout - def force_user_logout - reset_session - redirect_to login_path - end - - # View Helpers - def nl2br(string) - # simple_format string - string.gsub("\n\r", '
').gsub("\r", '').gsub("\n", '
').html_safe - end - - def universe_filter - return if User.find_by(id: session[:user]).universes.empty? - @selected_universe_filter ||= t(:all_universes) - end - - # Authentication - # replace with devise - def log_in(user) - session[:user] = user.id - end - - def logged_in? - session && session[:user] - end - - def redirect_if_not_logged_in - return if logged_in? - redirect_to signup_path, notice: t(:must_be_logged_in) - end - - def create_anonymous_account_if_not_logged_in - return if logged_in? - - # layman's collision detection - 10.times do - @user = create_anonymous_user - break if @user.save - end - - return if @user.nil? - - session[:user] = @user.id - session[:anon_user] = true - end - - def create_anonymous_user - # TODO: guarantee anonymous id is random (or just let db assign it?) - id = rand(10_000_000).to_s + rand(10_000_000).to_s # lol - - User.new( - name: 'Anonymous-' + id.to_s, - email: id.to_s + '@localhost', - password: id.to_s) - end - def content_type_from_controller(content_controller_name) content_controller_name.to_s.chomp('Controller').singularize.constantize end diff --git a/app/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index a5354c21..2c1bce27 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -1,15 +1,21 @@ # Controller for the Character model class CharactersController < ContentController + private def content_params - params.require(:character).permit( + params.require(:character).permit(content_param_list) + end + + def content_param_list + [ :universe_id, :user_id, :name, :age, :role, :gender, :age, :height, :weight, :haircolor, :facialhair, :eyecolor, :race, :skintone, :bodytype, :identmarks, :bestfriend, :religion, :politics, :prejudices, :occupation, :pets, :mannerisms, :birthday, :birthplace, :education, :background, :fave_color, :fave_food, :fave_possession, :fave_weapon, :fave_animal, - :father, :mother, :spouse, :siblings, :archenemy, :notes, :private_notes) + :father, :mother, :spouse, :siblings, :archenemy, :notes, :private_notes + ] end end diff --git a/app/controllers/concerns/has_ownership.rb b/app/controllers/concerns/has_ownership.rb index 13eb2b27..d86e67d9 100644 --- a/app/controllers/concerns/has_ownership.rb +++ b/app/controllers/concerns/has_ownership.rb @@ -42,7 +42,7 @@ module HasOwnership end def owned_by_current_user?(object) - session[:user] && session[:user] == object.user.id + current_user == object.user end def visible?(object) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index f0511c5e..6d84d639 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -1,11 +1,13 @@ class ContentController < ApplicationController include HasOwnership - before_action :create_anonymous_account_if_not_logged_in, only: [:edit, :create, :update] + before_action :authenticate_user! + + # TODO: put a lot of this in ContentManagementService def index @content = content_type_from_controller(self.class) - .where(user_id: session[:user]) + .where(user_id: current_user.id) .order(:name) .presence || [] @@ -16,8 +18,9 @@ class ContentController < ApplicationController end def show - @content = content_type_from_controller(self.class) - .find(params[:id]) + # TODO: Secure this with content class whitelist lel + @content = content_type_from_controller(self.class).find(params[:id]) + @question = QuestionService.question(Content.new @content.slice(*content_param_list)) respond_to do |format| format.html # show.html.erb @@ -77,7 +80,7 @@ class ContentController < ApplicationController @content = content_type .new(content_params) .tap do |c| - c.user_id = session[:user] + c.user_id = current_user.id c.universe = universe_from_params if c.respond_to? :universe #todo this doesn't actually work? end end @@ -89,7 +92,7 @@ class ContentController < ApplicationController def universe_from_params return unless params[content_symbol].include? :universe - Universe.where(user_id: session[:user], name: params[content_symbol][:universe].strip).first + Universe.where(user_id: current_user.id, name: params[content_symbol][:universe].strip).first end def content_symbol diff --git a/app/controllers/equipment_controller.rb b/app/controllers/items_controller.rb similarity index 53% rename from app/controllers/equipment_controller.rb rename to app/controllers/items_controller.rb index 9d5c3c32..88524368 100644 --- a/app/controllers/equipment_controller.rb +++ b/app/controllers/items_controller.rb @@ -1,14 +1,19 @@ # Controller for the Equipment model -class EquipmentController < ContentController +class ItemsController < ContentController private def content_params - params.require(:equipment).permit( + params.require(:item).permit(content_param_list) + end + + def content_param_list + [ :universe_id, :user_id, - :name, :equip_type, + :name, :item_type, :description, :weight, :original_owner, :current_owner, :made_by, :materials, :year_made, :magic, - :notes, :private_notes) + :notes, :private_notes + ] end end diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb deleted file mode 100644 index 7e2af52e..00000000 --- a/app/controllers/languages_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Controller for the Language model -class LanguagesController < ContentController - private - - def content_params - params.require(:language).permit( - :user_id, :universe_id, - :name, - :words, - :established_year, :established_location, - :characters, :locations, - :notes) - end -end diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 1064fbb1..74bb55be 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -3,10 +3,15 @@ class LocationsController < ContentController private def content_params - params.require(:location).permit( - :universe_id, :user_id, :name, :type_of, :description, :map, + params.require(:location).permit(content_param_list) + end + + def content_param_list + [ + :universe_id, :user_id, :name, :type_of, :description, #:map, :population, :currency, :motto, :capital, :largest_city, :notable_cities, - :area, :crops, :located_at, :stablishment_year, :notable_wars, - :notes, :private_notes) + :area, :crops, :located_at, :established_year, :notable_wars, + :notes, :private_notes + ] end end diff --git a/app/controllers/magic_controller.rb b/app/controllers/magic_controller.rb deleted file mode 100644 index c6a39b27..00000000 --- a/app/controllers/magic_controller.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Controller for the Magic model -class MagicController < ContentController - private - - def content_params - params.require(:magic).permit( - :universe_id, :user_id, - :name, :type_of, - :manifestation, :symptoms, - :element, :diety, - :harmfulness, :helpfulness, :neutralness, - :resource, :skill_level, :limitations, - :notes, :private_notes) - end -end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index ab6bf557..b8e4c057 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,10 +1,8 @@ # Controller for top-level pages of the site that do not have # an associated model class MainController < ApplicationController - before_action :redirect_if_not_logged_in, only: [:dashboard] - def index - redirect_to :dashboard if session && session[:user] + redirect_to :dashboard if user_signed_in? end def comingsoon @@ -17,15 +15,5 @@ class MainController < ApplicationController end def dashboard - user = User.where(id: session[:user]).first - - @characters = user.characters - @equipment = user.equipment - @languages = user.languages - @locations = user.locations - @magics = user.magics - @universes = user.universes - - @things = user.content_count end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb deleted file mode 100644 index 4d3a651c..00000000 --- a/app/controllers/sessions_controller.rb +++ /dev/null @@ -1,76 +0,0 @@ -# Controller for user Sessions -class SessionsController < ApplicationController - # GET /sessions/new - # GET /sessions/new.json - def new - @session = Session.new - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @session } - end - end - - # POST /sessions - # POST /sessions.json - def create - user = user_from_params - - if user.nil? - redirect_to login_path, notice: t(:username_password_incorrect) - return - end - - build_session_for user - - respond_to do |format| - format.html { redirect_to dashboard_path, notice: t(:login_successful) } - format.json { render json: true, status: :created } - end - end - - # GET /logout - def destroy - session.delete(:user) - session.delete(:anon_user) - - respond_to do |format| - format.html { redirect_to homepage_path, notice: t(:logged_out) } - format.json { head :no_content } - end - end - - def self.create_password_digest(username, password) - require 'digest' - Digest::MD5.hexdigest( - username + "'s password IS... " + password + ' (lol!)') - end - - private - - def user_from_params - login = Session.new(session_params) - user = User.find_by(name: login.username) - migrate_to_bcrypt(user, login.password) if user.old_password.present? - user.try(:authenticate, login.password) - end - - def migrate_to_bcrypt(user, password) - hash = SessionsController.create_password_digest user.name, password - - return unless user.old_password == hash - - user.old_password = nil - user.password = password - user.save - end - - def build_session_for(user) - session[:user] = user.id - session.delete(:anon_user) - end - - def session_params - params.require(:session).permit(:username, :password) - end -end diff --git a/app/controllers/universes_controller.rb b/app/controllers/universes_controller.rb index cd49d199..d18f0c6f 100644 --- a/app/controllers/universes_controller.rb +++ b/app/controllers/universes_controller.rb @@ -3,11 +3,16 @@ class UniversesController < ContentController private def content_params - params.require(:universe).permit( + params.require(:universe).permit(content_param_list) + end + + def content_param_list + [ :user_id, :name, :description, :history, :privacy, - :notes, :private_notes) + :notes, :private_notes + ] end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a0cea86e..3f5a2915 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,6 @@ # Controller for the User model +#todo not sure this is even needed with devise class UsersController < ApplicationController - before_action :redirect_if_not_logged_in, only: [:edit, :update] - # GET /users/new # GET /users/new.json def new @@ -15,7 +14,7 @@ class UsersController < ApplicationController # GET /users/1/edit def edit - @user = User.find(session[:user]) + @user = current_user #todo just use current_user in view end # POST /users @@ -27,23 +26,7 @@ class UsersController < ApplicationController if @user.save log_in @user notice = t(:create_success, model_name: User.model_name.human) - format.html { redirect_to homepage_path, notice: notice } - format.json { render json: @user, status: :created } - else - format.html { render action: 'new' } - format.json { render json: @user.errors, status: :unprocessable_entity } - end - end - end - - def anonymous_login - @user = create_anonymous_user - - respond_to do |format| - if @user.save - session[:user] = @user.id - session[:anon_user] = true - format.html { redirect_to dashboard_path } + format.html { redirect_to root_url, notice: notice } format.json { render json: @user, status: :created } else format.html { render action: 'new' } @@ -55,12 +38,11 @@ class UsersController < ApplicationController # PUT /users/1 # PUT /users/1.json def update - @user = User.find(session[:user]) + @user = current_user respond_to do |format| if @user.update_attributes(user_params) - session[:anon_user] = false - format.html { redirect_to homepage_path, notice: 'Successfully updated.' } + format.html { redirect_to root_url, notice: 'Successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } @@ -69,13 +51,9 @@ class UsersController < ApplicationController end end - def anonymous - end - private def user_params - params.require(:user).permit(:name, :email, - :password, :password_confirmation) + params.require(:user).permit(:name, :email, :password, :password_confirmation) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 929f067e..ba85167a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,8 +4,7 @@ module ApplicationHelper # current logged-in user. Otherwise will just print a text title def link_if_present(name, type) return name unless session[:user] - userid = User.where(id: session[:user]).first.id - result = find_by_name_and_type name, type.downcase, userid + result = find_by_name_and_type name, type.downcase, current_user.id result.nil? ? name : link_to(name, result) end diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb deleted file mode 100644 index 31996048..00000000 --- a/app/helpers/content_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ContentHelper -end diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb deleted file mode 100644 index 7e8d36f7..00000000 --- a/app/helpers/form_helper.rb +++ /dev/null @@ -1,32 +0,0 @@ -# Helps to generate forms and buttons -module FormHelper - def generate_form_row_for(form_handler, field, label_override = nil, toolbox = {}) - label = (label_override.nil? ? field : label_override.titleize) - [ - '
', - '
', - form_handler.label(label, class: 'control-label'), - '
', - '
', - form_handler.text_field(field, class: 'form-control'), - '
', - '
', - toolbox.map { |config| toolbox_button_for(config) }, - '
', - '
' - ].join("\n").html_safe - end - - def toolbox_button_for(config = {}) - if config[:action].ends_with? '_picker' - picker_type = config[:action].split('_picker').first - picker_for picker_type - else - [ - "' - ].join("\n").html_safe - end - end -end diff --git a/app/helpers/html_helper.rb b/app/helpers/html_helper.rb deleted file mode 100644 index c3dbf099..00000000 --- a/app/helpers/html_helper.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Helps generate small HTML constructs -module HtmlHelper - PICKER_ICONS = { - 'character' => 'user', - 'universe' => 'globe', - 'equipment' => 'gift', - 'language' => 'comment', - 'location' => 'road' - } - - def picker_for(content_type) - content_array = send "my_#{content_type.pluralize}" - generate_picker_code_for(content_array, PICKER_ICONS[content_type]) - rescue - end - - def generate_picker_code_for(content_array, glyphicon_id) - return if content_array.length == 0 - [ - '', - '', - '', - '' - ].join("\n").html_safe - end -end diff --git a/app/helpers/my_content_helper.rb b/app/helpers/my_content_helper.rb deleted file mode 100644 index a03db8ef..00000000 --- a/app/helpers/my_content_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -# Helps to get content owned by the current user -module MyContentHelper - %w(characters universes equipment languages locations).each do |content_type| - define_method "my_#{content_type}" do - content_type.singularize.titleize.constantize.where(user_id: session[:user]) - end - end -end diff --git a/app/models/character.rb b/app/models/character.rb index 33f573f1..78b05c70 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -7,26 +7,57 @@ # # exists within a Universe. class Character < ActiveRecord::Base - include Comparable - include NilsBlankUniverse - validates :name, presence: true belongs_to :user belongs_to :universe - def <=>(other) - name.downcase <=> other.name.downcase + def description + role end - def card_title - name + def self.color + 'red' end - def card_subtitle - [ - role, - age - ].compact.join ', ' + def self.icon + 'group' + end + + def self.attribute_categories + { + general_information: { + icon: 'info', + attributes: %w(name role gender age universe_id), + }, + appearance: { + icon: 'face', + attributes: %w(weight height haircolor hairstyle facialhair eyecolor race skintone bodytype identmarks) + }, + social: { + icon: 'groups', + attributes: %w(bestfriend religion politics prejudices occupation) + }, + mannerisms: { + icon: 'groups', + attributes: %w(mannerisms) + }, + history: { + icon: 'info', + attributes: %w(birthday birthplace education background) + }, + favorites: { + icon: 'star', + attributes: %w(fave_color fave_food fave_possession fave_weapon fave_animal) + }, + relationships: { + icon: 'face', + attributes: %w(mother father spouse siblings archenemy) + }, + notes: { + icon: 'edit', + attributes: %w(notes private_notes) + } + } end end diff --git a/app/models/concerns/nils_blank_universe.rb b/app/models/concerns/nils_blank_universe.rb deleted file mode 100644 index bbb64ff3..00000000 --- a/app/models/concerns/nils_blank_universe.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'active_support/concern' - -# Model will set its Universe attribute to nil if the string is blank -module NilsBlankUniverse - extend ActiveSupport::Concern - - included do - before_save :nil_blank_universe - end - - def nil_blank_universe - self.universe = nil if universe.blank? - end -end diff --git a/app/models/equipment.rb b/app/models/equipment.rb deleted file mode 100644 index 193f316a..00000000 --- a/app/models/equipment.rb +++ /dev/null @@ -1,29 +0,0 @@ -## -# = e-quip-ment -# == /e'kwipment/ -# _noun_ -# -# 1. the necessary items for a particular purpose. -# -# exists within a Universe. -class Equipment < ActiveRecord::Base - include Comparable - include NilsBlankUniverse - - validates :name, presence: true - - belongs_to :user - belongs_to :universe - - def <=>(other) - name.downcase <=> other.name.downcase - end - - def table_columns - { - 'Name' => -> { link_to name, self }, - 'Type' => equip_type, - 'Description' => description - } - end -end diff --git a/app/models/item.rb b/app/models/item.rb new file mode 100644 index 00000000..008fd382 --- /dev/null +++ b/app/models/item.rb @@ -0,0 +1,47 @@ +## +# = e-quip-ment +# == /e'kwipment/ +# _noun_ +# +# 1. the necessary items for a particular purpose. +# +# exists within a Universe. +class Item < ActiveRecord::Base + validates :name, presence: true + + belongs_to :user + belongs_to :universe + + def self.color + 'amber' + end + + def self.icon + 'beach_access' + end + + def self.attribute_categories + { + general_information: { + icon: 'info', + attributes: %w(name item_type description universe), + }, + appearance: { + icon: 'face', + attributes: %w(weight) + }, + history: { + icon: 'face', + attributes: %w(original_owner current_owner made_by materials year_made) + }, + abilities: { + icon: 'face', + attributes: %w(magic) + }, + notes: { + icon: 'edit', + attributes: %w(notes private_notes) + } + } + end +end diff --git a/app/models/language.rb b/app/models/language.rb deleted file mode 100644 index 96953ece..00000000 --- a/app/models/language.rb +++ /dev/null @@ -1,17 +0,0 @@ -## -# = lang-guage -# == /'laNGgqwij/ -# _noun_ -# -# 1. the method of communication, either spoken or written, consisting of the -# use of words in a structured and conventional way. -# -# spoken within a Universe -class Language < ActiveRecord::Base - include NilsBlankUniverse - - validates :name, presence: true - - belongs_to :user - belongs_to :universe -end diff --git a/app/models/location.rb b/app/models/location.rb index 22bd077d..0629c16e 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -7,8 +7,6 @@ # # exists within a Universe class Location < ActiveRecord::Base - include NilsBlankUniverse - has_attached_file :map, styles: { original: '1920x1080>', thumb: '200x200>' } validates_attachment_content_type :map, content_type: %r{\Aimage\/.*\Z} @@ -16,4 +14,42 @@ class Location < ActiveRecord::Base belongs_to :user belongs_to :universe + + def self.icon + 'terrain' + end + + def self.color + 'green' + end + + def self.attribute_categories + { + general_information: { + icon: 'info', + attributes: %w(name type_of description universe), + }, + #todo map + culture: { + icon: 'face', + attributes: %w(population language currency motto) + }, + cities: { + icon: 'face', + attributes: %w(capital largest_city notable_cities) + }, + geography: { + icon: 'edit', + attributes: %w(area crops located_at) + }, + history: { + icon: 'edit', + attributes: %w(established_year notable_wars) + }, + notes: { + icon: 'edit', + attributes: %w(notes private_notes) + } + } + end end diff --git a/app/models/magic.rb b/app/models/magic.rb deleted file mode 100644 index 3ff30f4d..00000000 --- a/app/models/magic.rb +++ /dev/null @@ -1,19 +0,0 @@ -## -# = mag-ic -# == /'majik/ -# _noun_ -# -# 1. the power of apparently influencing the course of events by using -# mysterious or supernatural forces. -# -# used within a universe -# -# "do you believe in magic?" -class Magic < ActiveRecord::Base - include NilsBlankUniverse - - validates :name, presence: true - - belongs_to :user - belongs_to :universe -end diff --git a/app/models/session.rb b/app/models/session.rb deleted file mode 100644 index ed10cfd7..00000000 --- a/app/models/session.rb +++ /dev/null @@ -1,6 +0,0 @@ -## -# A currently-logged-in User -class Session < ActiveRecord::Base - validates :username, presence: true - validates :password, presence: true -end diff --git a/app/models/universe.rb b/app/models/universe.rb index bf5b57c3..67a01186 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -10,7 +10,7 @@ class Universe < ActiveRecord::Base belongs_to :user has_many :characters - has_many :equipment + has_many :items has_many :languages has_many :locations has_many :magics @@ -18,10 +18,39 @@ class Universe < ActiveRecord::Base def content_count [ characters.length, - equipment.length, + items.length, languages.length, locations.length, magics.length ].sum end + + def self.color + 'purple' + end + + def self.icon + 'vpn_lock' + end + + def self.attribute_categories + { + general_information: { + icon: 'info', + attributes: %w(name description), + }, + history: { + icon: 'face', + attributes: %w(history) + }, + settings: { + icon: 'face', + attributes: %w(privacy) + }, + notes: { + icon: 'edit', + attributes: %w(notes private_notes) + } + } + end end diff --git a/app/models/user.rb b/app/models/user.rb index 21fd5851..618104df 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,32 +1,25 @@ ## # a person using the Indent web application. Owns all other content. class User < ActiveRecord::Base - validates :name, presence: true + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable + + #validates :name, presence: true validates :email, presence: true - has_secure_password - before_save :hash_old_password - has_many :characters - has_many :equipment + has_many :items has_many :languages has_many :locations has_many :magics has_many :universes - def hash_old_password - require 'digest' - - return if old_password.blank? - - self.old_password = Digest::MD5.hexdigest( - name + "'s password IS... " + old_password + ' (lol!)') - end - def content { characters: characters, - equipment: equipment, + items: items, languages: languages, locations: locations, magics: magics, @@ -37,7 +30,7 @@ class User < ActiveRecord::Base def content_count [ characters.length, - equipment.length, + items.length, languages.length, locations.length, magics.length, diff --git a/app/views/cards/_character_intro.html.erb b/app/views/cards/_character_intro.html.erb new file mode 100644 index 00000000..b194ec5f --- /dev/null +++ b/app/views/cards/_character_intro.html.erb @@ -0,0 +1,11 @@ +
+
+ <%= image_tag 'card-headers/characters.jpg' %> + Create characters +
+
+

+ Plan physical appearance, behaviorisms, social roles, family – even a favorite color! +

+
+
\ No newline at end of file diff --git a/app/views/cards/_item_intro.html.erb b/app/views/cards/_item_intro.html.erb new file mode 100644 index 00000000..5046dd79 --- /dev/null +++ b/app/views/cards/_item_intro.html.erb @@ -0,0 +1,11 @@ +
+
+ <%= image_tag 'card-headers/items.jpg' %> + Track items +
+
+

+ Every weapon was made by someone, and every book has an owner. Keep track of every aspect of your items. +

+
+
\ No newline at end of file diff --git a/app/views/cards/_location_intro.html.erb b/app/views/cards/_location_intro.html.erb new file mode 100644 index 00000000..f74f75d7 --- /dev/null +++ b/app/views/cards/_location_intro.html.erb @@ -0,0 +1,11 @@ +
+
+ <%= image_tag 'card-headers/locations.jpg' %> + Construct locations +
+
+

+ Upload maps, link areas, track demographics, and keep track of history. +

+
+
\ No newline at end of file diff --git a/app/views/cards/_universe_intro.html.erb b/app/views/cards/_universe_intro.html.erb new file mode 100644 index 00000000..4bad3b26 --- /dev/null +++ b/app/views/cards/_universe_intro.html.erb @@ -0,0 +1,11 @@ +
+
+ <%= image_tag 'card-headers/universes.jpg' %> + Build universes +
+
+

+ You know you've always wanted to create an entire universe. Now's your chance! +

+
+
diff --git a/app/views/cards/serendipitous/_content_question.html.erb b/app/views/cards/serendipitous/_content_question.html.erb new file mode 100644 index 00000000..4ef631e7 --- /dev/null +++ b/app/views/cards/serendipitous/_content_question.html.erb @@ -0,0 +1,17 @@ +<% if question %> +
+ <%= content.class.icon %>` + <%= question[:question] %> + +
+ <%# TODO: Support dropdown, picker, etc for relations %> +
+ + +
+
+ save +
+
+
+<% end %> diff --git a/app/views/cards/ui/_alert.html.erb b/app/views/cards/ui/_alert.html.erb new file mode 100644 index 00000000..d9256470 --- /dev/null +++ b/app/views/cards/ui/_alert.html.erb @@ -0,0 +1,7 @@ +<% if alert %> +
+ + <%= alert %> + +
+<% end %> diff --git a/app/views/cards/ui/_notice.html.erb b/app/views/cards/ui/_notice.html.erb new file mode 100644 index 00000000..961f4893 --- /dev/null +++ b/app/views/cards/ui/_notice.html.erb @@ -0,0 +1,7 @@ +<% if notice %> +
+ + <%= notice %> + +
+<% end %> \ No newline at end of file diff --git a/app/views/cards/user/_recent_activity.html.erb b/app/views/cards/user/_recent_activity.html.erb new file mode 100644 index 00000000..ae2b775d --- /dev/null +++ b/app/views/cards/user/_recent_activity.html.erb @@ -0,0 +1,4 @@ +<% all_content = %i(universes characters locations items).map { |c| current_user.send(c) }.flatten.sort_by(&:created_at).reverse.first(10) %> +<% if all_content.count > 0 %> + <%= render partial: 'content/list/list', locals: { content_list: all_content, title: 'Recent creations' } %> +<% end %> diff --git a/app/views/characters/_form.html.erb b/app/views/characters/_form.html.erb deleted file mode 100644 index 8aeac484..00000000 --- a/app/views/characters/_form.html.erb +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/views/characters/_list.html.erb b/app/views/characters/_list.html.erb deleted file mode 100644 index 36f96fe1..00000000 --- a/app/views/characters/_list.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<% @content.each do |character| %> -
-
-

- <%= simple_format link_to character.name, character_path(character) %> -

-
-

- - <% if character.role.present? %> - <%= character.role %><% if character.age.length > 0 %>, <%= character.age %><% end %> - <% end %> - -

-

-

-
-
-

- <% if session[:user] and session[:user] == character.user.id %> - <%= link_to t('.view', :default => t("helpers.links.view")), - character_path(character), :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - character_edit_path(character), :class => 'btn' %> - <% end %> - -

-
-
-
-<% end %> diff --git a/app/views/characters/_tabs.html.erb b/app/views/characters/_tabs.html.erb deleted file mode 100644 index 8d442efb..00000000 --- a/app/views/characters/_tabs.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/app/views/characters/edit.html.erb b/app/views/characters/edit.html.erb index f3e836b4..4b89dde9 100644 --- a/app/views/characters/edit.html.erb +++ b/app/views/characters/edit.html.erb @@ -1,37 +1,9 @@ -<%- model_class = @content.class -%> - -
-
-
-

Facets

- <%= render :partial => 'tabs' %> -
- -
-

Danger-zone

-
- <%= link_to 'Delete character forever', character_path, - :class => 'btn btn-danger', +

Editing a character

+<%= form_for @content, :url => character_edit_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> + <%= link_to "Delete #{@content.class.to_s} forever", @content, + :class => 'red btn right', :method => :delete, :confirm => 'Are you sure? This action cannot be undone!' %> -
-
-
- -
-
-

Editing <%= @content.name %>

- <%= form_for @content, - :url => character_edit_process_path, - :html => { :class => 'form-horizontal' } do |form| %> -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', character_list_path, :class => 'btn' %> -
- <% end %> -
-
-
+<% end %> \ No newline at end of file diff --git a/app/views/characters/index.html.erb b/app/views/characters/index.html.erb index c3039696..3664c7ae 100644 --- a/app/views/characters/index.html.erb +++ b/app/views/characters/index.html.erb @@ -1,30 +1,4 @@ -
+

You've created <%= @content.count %> characters

+<%= render partial: 'content/list/list', locals: { content_list: @content } %> -
-
-

- Your characters - <% if Universe.where(user_id: session[:user]).length > 0 %> - from <%= render 'universes/picker' %> - <% end %> -

-
-
- - <%= render 'content/list/cards', content: @content %> - -
-
-

Planning characters

-
-

- Consistency is sometimes hard to keep, and having a reference of everything about your character for yourself can help you down the line, especially if you're writing a series. -

-
-
- <%= link_to 'New character', character_create_path, :class => 'btn btn-primary' %> -
-
-
- -
+<%= link_to 'Create another character', character_create_path, :class => 'btn' %> diff --git a/app/views/characters/new.html.erb b/app/views/characters/new.html.erb index 05dc401a..891c0331 100644 --- a/app/views/characters/new.html.erb +++ b/app/views/characters/new.html.erb @@ -1,29 +1,5 @@ -
-
- -
-

New character

- <%= render :partial => 'tabs' %> -
-
-
-
- - <%= form_for @content, - :url => character_create_process_path, - :html => { :class => 'form-horizontal' } do |form| %> - -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', character_list_path, :class => 'btn' %> -
- - <% end %> -
- -
- -
\ No newline at end of file +

Create a new character

+<%= form_for @content, :url => character_create_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> +<% end %> \ No newline at end of file diff --git a/app/views/characters/show.html.erb b/app/views/characters/show.html.erb index 4e15aac4..3fb323be 100644 --- a/app/views/characters/show.html.erb +++ b/app/views/characters/show.html.erb @@ -1,100 +1,3 @@ -<% @character = @content %> -<%- model_class = @character.class -%> +<%= render partial: 'content/show', locals: { content: @content } %> -
-
-
- <%= render :partial => 'tabs' %> -
-
- -
-
-

- <%= @character.name %> -

- -
- - - - - - - - - - - - - - - - - -
- -
- - <% if session[:user] and session[:user] == @character.user.id %> -
- <%= link_to t('.back', :default => t("helpers.links.back")), - character_list_path, :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - character_edit_path(@character), :class => 'btn' %> -
- <% end %> - -
- -
-
-
\ No newline at end of file +<%= link_to 'Edit this character', edit_character_path(@content), class: 'btn' %> \ No newline at end of file diff --git a/app/views/content/_form.html.erb b/app/views/content/_form.html.erb new file mode 100644 index 00000000..388a4049 --- /dev/null +++ b/app/views/content/_form.html.erb @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/app/views/content/_show.html.erb b/app/views/content/_show.html.erb new file mode 100644 index 00000000..96b4886b --- /dev/null +++ b/app/views/content/_show.html.erb @@ -0,0 +1,26 @@ +<% content_for :sidebar_top do %> + <%= render partial: 'cards/serendipitous/content_question', locals: { question: @question, content: @content } %> +<% end %> + +

<%= content.name %>

+ \ No newline at end of file diff --git a/app/views/content/list/_cards.html.erb b/app/views/content/list/_cards.html.erb deleted file mode 100644 index 778ea8e5..00000000 --- a/app/views/content/list/_cards.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<% content.each do |content| %> -
-
-

- <%= simple_format link_to content.card_title, content %> -

-
-

- - <%= content.card_subtitle %> - -

-

-

-
-
-

- <% if session[:user] and session[:user] == content.user.id %> - <%= link_to t('.view', :default => t("helpers.links.view")), content, :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), content, :class => 'btn' %> - <% end %> -

-
-
-
-<% end %> diff --git a/app/views/content/list/_list.html.erb b/app/views/content/list/_list.html.erb new file mode 100644 index 00000000..161ef856 --- /dev/null +++ b/app/views/content/list/_list.html.erb @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/app/views/content/list/_table.html.erb b/app/views/content/list/_table.html.erb deleted file mode 100644 index 1a680023..00000000 --- a/app/views/content/list/_table.html.erb +++ /dev/null @@ -1,28 +0,0 @@ - - - - <% @content.first.table_columns.keys.each do |column_header| %> - - <% end %> - <% if session[:user] %> - - <% end %> - - - - <% @content.each do |row_item| %> - - <% row_item.table_columns.values.each do |cell| %> - - <% end %> - - - <% end %> - -
<%= column_header %><%=t '.actions', :default => t("helpers.actions") %>
<%= cell.is_a? Proc ? cell.call : cell %> - <% if session[:user] and session[:user] == row_item.user.id %> - <%= link_to t('.view', :default => t("helpers.links.view")), equipment_path(row_item), :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), equipment_edit_path(row_item), :class => 'btn' %> - <% end %> -
- diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 00000000..826672f7 --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,16 @@ +

Resend confirmation instructions

+ +<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> +
+ +
+ <%= f.submit "Resend confirmation instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 00000000..dc55f64f --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @email %>!

+ +

You can confirm your account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>

diff --git a/app/views/devise/mailer/password_change.html.erb b/app/views/devise/mailer/password_change.html.erb new file mode 100644 index 00000000..b41daf47 --- /dev/null +++ b/app/views/devise/mailer/password_change.html.erb @@ -0,0 +1,3 @@ +

Hello <%= @resource.email %>!

+ +

We're contacting you to notify you that your password has been changed.

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 00000000..f667dc12 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password. You can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 00000000..41e148bf --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @resource.email %>!

+ +

Your account has been locked due to an excessive number of unsuccessful sign in attempts.

+ +

Click the link below to unlock your account:

+ +

<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>

diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 00000000..6a796b05 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,25 @@ +

Change your password

+ +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> + <%= devise_error_messages! %> + <%= f.hidden_field :reset_password_token %> + +
+ <%= f.label :password, "New password" %>
+ <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum)
+ <% end %> + <%= f.password_field :password, autofocus: true, autocomplete: "off" %> +
+ +
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
+ +
+ <%= f.submit "Change my password" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 00000000..3d6d11aa --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,16 @@ +

Forgot your password?

+ +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.submit "Send me reset password instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 00000000..05f521ba --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,35 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %> + +
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, autocomplete: "off" %> +
+ +
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
+ +
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password, autocomplete: "off" %> +
+ +
+ <%= f.submit "Update", class: 'btn' %> +
+<% end %> + +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 00000000..fab6dda6 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,29 @@ +

Sign up

+ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.label :password %> + <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum) + <% end %>
+ <%= f.password_field :password, autocomplete: "off" %> +
+ +
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
+ +
+ <%= f.submit "Sign up", class: 'btn' %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 00000000..c7c6f226 --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,26 @@ +

Log in

+ +<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.label :password %>
+ <%= f.password_field :password, autocomplete: "off" %> +
+ + <% if devise_mapping.rememberable? -%> +
+ <%= f.check_box :remember_me %> + <%= f.label :remember_me %> +
+ <% end -%> + +
+ <%= f.submit "Log in", class: 'btn' %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb new file mode 100644 index 00000000..e6a3e419 --- /dev/null +++ b/app/views/devise/shared/_links.html.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Log in", new_session_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 00000000..16586bc7 --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,16 @@ +

Resend unlock instructions

+ +<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ +
+ <%= f.submit "Resend unlock instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/equipment/_form.html.erb b/app/views/equipment/_form.html.erb deleted file mode 100644 index 8f926571..00000000 --- a/app/views/equipment/_form.html.erb +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - diff --git a/app/views/equipment/_tabs.html.erb b/app/views/equipment/_tabs.html.erb deleted file mode 100644 index 6f9f520c..00000000 --- a/app/views/equipment/_tabs.html.erb +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/app/views/equipment/edit.html.erb b/app/views/equipment/edit.html.erb deleted file mode 100644 index 4101f9b6..00000000 --- a/app/views/equipment/edit.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -<%- model_class = @content.class -%> - -
-
-
-

Facets

- <%= render :partial => 'tabs' %> -
- -
-

Danger-zone

-
- <%= link_to 'Delete this equipment forever', equipment_path, - :class => 'btn btn-danger', - :method => :delete, - :confirm => 'Are you sure? This action cannot be undone!' %> -
-
-
- -
-
-

Editing <%= @content.name %>

- <%= form_for @content, - :url => equipment_edit_process_path, - :html => { :class => 'form-horizontal' } do |form| %> -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', equipment_list_path, :class => 'btn' %> -
- <% end %> -
-
-
diff --git a/app/views/equipment/index.html.erb b/app/views/equipment/index.html.erb deleted file mode 100644 index 87f61bf5..00000000 --- a/app/views/equipment/index.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -<% if @content.length > 0 %> -
-

- Your equipment - <% if false and Universe.where(user_id: session[:user]).length > 0 %> - from <%= render 'universes/picker' %> - <% end %> -

- - <%= render 'content/list/table', content: @content %> -
-<% end %> - -
-

Planning equipment

-
-

- A legendary sword or decrepit family shield are capable of telling a story all on their own. Before including them in your literary masterpiece, you should flesh their history out and keep their stories straight. -

- <%= link_to 'New Equipment', equipment_create_path, :class => 'btn btn-primary' %> - <%= link_to 'New Weapon', equipment_create_type_path(:weapon), :class => 'btn' %> - <%= link_to 'New Armor', equipment_create_type_path(:armor), :class => 'btn' %> -
-
-
diff --git a/app/views/equipment/new.html.erb b/app/views/equipment/new.html.erb deleted file mode 100644 index 3e6b68b0..00000000 --- a/app/views/equipment/new.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -<%- model_class = @content.class -%> - -
-
- -
-

New equipment

- <%= render :partial => 'tabs' %> -
-
-
-
- - <%= form_for @content, - :url => equipment_create_process_path, - :html => { :class => 'form-horizontal' } do |form| %> - -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', equipment_list_path, :class => 'btn' %> -
- - <% end %> -
- -
- -
\ No newline at end of file diff --git a/app/views/equipment/show.html.erb b/app/views/equipment/show.html.erb deleted file mode 100644 index fbff2c60..00000000 --- a/app/views/equipment/show.html.erb +++ /dev/null @@ -1,64 +0,0 @@ -<% @equipment = @content %> -<%- model_class = @equipment.class -%> - -
-
-
- <%= render :partial => 'tabs' %> -
-
- -
-
-

- <%= @equipment.name %> -

- -
- - - - - - - - - - - -
- -
- <% if session[:user] and session[:user] == @equipment.user.id %> -
- <%= link_to t('.back', :default => t("helpers.links.back")), - equipment_list_path, :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - equipment_edit_path(@equipment), :class => 'btn' %> -
- <% end %> -
- -
-
-
diff --git a/app/views/equipment/_list.html.erb b/app/views/items/_list.html.erb similarity index 94% rename from app/views/equipment/_list.html.erb rename to app/views/items/_list.html.erb index 4f8a9497..6d2646a4 100644 --- a/app/views/equipment/_list.html.erb +++ b/app/views/items/_list.html.erb @@ -13,7 +13,7 @@ <% @content.each do |equipment| %> <%= simple_format link_to equipment.name, equipment_path(equipment) %> - <%= simple_format equipment.equip_type %> + <%= simple_format equipment.item_type %> <%= simple_format equipment.description %> <% if session[:user] and session[:user] == equipment.user.id %> diff --git a/app/views/items/edit.html.erb b/app/views/items/edit.html.erb new file mode 100644 index 00000000..9f2056a9 --- /dev/null +++ b/app/views/items/edit.html.erb @@ -0,0 +1,9 @@ +

Editing an item

+<%= form_for @content, :url => item_edit_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> + <%= link_to "Delete #{@content.class.to_s} forever", @content, + :class => 'red btn right', + :method => :delete, + :confirm => 'Are you sure? This action cannot be undone!' %> +<% end %> \ No newline at end of file diff --git a/app/views/items/index.html.erb b/app/views/items/index.html.erb new file mode 100644 index 00000000..484974fc --- /dev/null +++ b/app/views/items/index.html.erb @@ -0,0 +1,4 @@ +

You've created <%= @content.count %> items

+<%= render partial: 'content/list/list', locals: { content_list: @content } %> + +<%= link_to 'Create another item', item_create_path, :class => 'btn' %> diff --git a/app/views/items/new.html.erb b/app/views/items/new.html.erb new file mode 100644 index 00000000..2f300929 --- /dev/null +++ b/app/views/items/new.html.erb @@ -0,0 +1,5 @@ +

Create a new item

+<%= form_for @content, :url => item_create_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> +<% end %> \ No newline at end of file diff --git a/app/views/items/show.html.erb b/app/views/items/show.html.erb new file mode 100644 index 00000000..dc052f22 --- /dev/null +++ b/app/views/items/show.html.erb @@ -0,0 +1,3 @@ +<%= render partial: 'content/show', locals: { content: @content } %> + +<%= link_to 'Edit this item', edit_item_path(@content), class: 'btn' %> \ No newline at end of file diff --git a/app/views/languages/_form.html.erb b/app/views/languages/_form.html.erb deleted file mode 100644 index a9fd1df2..00000000 --- a/app/views/languages/_form.html.erb +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - diff --git a/app/views/languages/_list.html.erb b/app/views/languages/_list.html.erb deleted file mode 100644 index d63a9e13..00000000 --- a/app/views/languages/_list.html.erb +++ /dev/null @@ -1,26 +0,0 @@ - - - - - <% if session[:user] %> - - <% end %> - - - - <% @content.each do |language| %> - - - - - <% end %> - -
Name<%=t '.actions', :default => t("helpers.actions") %>
<%= simple_format link_to language.name, language_path(language) %> - <% if session[:user] and session[:user] == language.user.id %> - <%= link_to t('.view', :default => t("helpers.links.view")), - language_path(language), :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - language_edit_path(language), :class => 'btn' %> - <% end %> -
- diff --git a/app/views/languages/_tabs.html.erb b/app/views/languages/_tabs.html.erb deleted file mode 100644 index f4c24957..00000000 --- a/app/views/languages/_tabs.html.erb +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/app/views/languages/edit.html.erb b/app/views/languages/edit.html.erb deleted file mode 100644 index 6ca8e279..00000000 --- a/app/views/languages/edit.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -<%- model_class = @content.class -%> - -
-
-
-

Facets

- <%= render :partial => 'tabs' %> -
- -
-

Danger-zone

-
- <%= link_to 'Delete this language forever', language_path, - :class => 'btn btn-danger', - :method => :delete, - :confirm => 'Are you sure? This action cannot be undone!' %> -
-
-
- -
-
-

Editing <%= @content.name %>

- <%= form_for @content, - :url => language_edit_process_path, - :html => { :class => 'form-horizontal' } do |form| %> -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', language_list_path, :class => 'btn' %> -
- <% end %> -
-
-
diff --git a/app/views/languages/index.html.erb b/app/views/languages/index.html.erb deleted file mode 100644 index 1d07706b..00000000 --- a/app/views/languages/index.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -<%- model_class = @content.class -%> -<% if @content.length > 0 %> -
-

- Languages - <% if false and Universe.where(user_id: session[:user]).length > 0 %> - spoken in <%= render 'universes/picker' %> - <% end %> -

- - <%= render 'list' %> -
-<% end %> - -
-

Planning languages

-
-

- English doesn't have to be the only language in your story. Whether you're planning differing dialects or completely new languages, you want to keep track of what defines them. -

- <%= link_to 'New language', language_create_path, :class => 'btn btn-primary' %> -
-
-
diff --git a/app/views/languages/new.html.erb b/app/views/languages/new.html.erb deleted file mode 100644 index 13ea4a4b..00000000 --- a/app/views/languages/new.html.erb +++ /dev/null @@ -1,30 +0,0 @@ - -
-
- -
-

New language

- <%= render :partial => 'tabs' %> -
-
-
-
- - <%= form_for @content, - :url => language_create_process_path, - :html => { :class => 'form-horizontal' } do |form| %> - -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', language_list_path, :class => 'btn' %> -
- - <% end %> -
- -
- -
\ No newline at end of file diff --git a/app/views/languages/show.html.erb b/app/views/languages/show.html.erb deleted file mode 100644 index b72a5fea..00000000 --- a/app/views/languages/show.html.erb +++ /dev/null @@ -1,59 +0,0 @@ -<% @language = @content %> -<%- model_class = @language.class -%> - -
-
-
- <%= render :partial => 'tabs' %> -
-
- -
-
-

- <%= @language.name %> -

- -
- - - - - - - - - - - -
- -
- - <% if session[:user] and session[:user] == @language.user.id %> -
- <%= link_to t('.back', :default => t("helpers.links.back")), - language_list_path, :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - language_edit_path(@language), :class => 'btn' %> -
- <% end %> - -
- -
-
-
\ No newline at end of file diff --git a/app/views/layouts/_bootstrap_includes.html.erb b/app/views/layouts/_bootstrap_includes.html.erb deleted file mode 100644 index eb60ee1d..00000000 --- a/app/views/layouts/_bootstrap_includes.html.erb +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb new file mode 100644 index 00000000..2bcea83a --- /dev/null +++ b/app/views/layouts/_footer.html.erb @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/app/views/layouts/_login_box.html.erb b/app/views/layouts/_login_box.html.erb index 46cefeb0..52af76ae 100644 --- a/app/views/layouts/_login_box.html.erb +++ b/app/views/layouts/_login_box.html.erb @@ -1,12 +1,12 @@ diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index 31aaf30e..bd29ca01 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -1,29 +1,61 @@ - + \ No newline at end of file diff --git a/app/views/layouts/_noscript_notice.html.erb b/app/views/layouts/_noscript_notice.html.erb deleted file mode 100644 index 0a1afc39..00000000 --- a/app/views/layouts/_noscript_notice.html.erb +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/app/views/layouts/_session_protection.html.erb b/app/views/layouts/_session_protection.html.erb deleted file mode 100644 index c06a1175..00000000 --- a/app/views/layouts/_session_protection.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<% - # Destroy old sessions if a user has been deleted - begin - User.find(session[:user]) if session[:user] - rescue ActiveRecord::RecordNotFound - session = {} - %> - - <% - end -%> \ No newline at end of file diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index b6df5d89..61b7aa0f 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -1,61 +1,17 @@ -<% if flash[:notice] %> -
-
-
- <%= flash[:notice] %> -
-
-
-<% end %> +<%= render 'cards/ui/alert' %> +<%= render 'cards/ui/notice' %> -<% if flash[:alert] %> -
-
-
- <%= flash[:alert] %> -
-
-
-<% end %> +<% if user_signed_in? %> -<% if session[:anon_user] and session[:user] and User.find(session[:user]).content_count > 0 && !current_page?(account_path) %> -
-
Anonymous accounts
-
- You are currently using an anonymous account. In order to save the brilliant things you have created with it, please click here to give yourself a username and password. -
-
-
-<% end %> + <%= yield :sidebar_top %> + <%= render 'cards/user/recent_activity' %> + <%= yield :sidebar_bottom %> + +<% else %> + + <%= render 'cards/universe_intro' %> + <%= render 'cards/character_intro' %> + <%= render 'cards/location_intro' %> + <%= render 'cards/item_intro' %> -<% unless session[:user] %> -
-

Get started instantly

-
- Nobody likes creating accounts just to try things out. You can get started making things immediately and create your account later if you want. -
-
- -
-

- If you jump right in to creating things, an account will be created for you. As you flesh out characters and worlds, your ideas will be safe and sound under this account, which does not ever expire unless you delete it yourself. -

-

- At any time, you can change the account's login information, so if you make some good progress you can just create an account and tada! all of your ideas are private to your new account, always there for you. -

-

- - Collapse card - -

-
-
-
<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 56481aee..64116a2c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,44 +1,36 @@ - Indent - <%= stylesheet_link_tag "application", :media => "all" %> - <%= javascript_include_tag "application" %> + Notebook + <%= stylesheet_link_tag 'application' %> + <%= javascript_include_tag 'application' %> <%= csrf_meta_tags %> - <%= render 'layouts/session_protection' %> - <%= render 'layouts/bootstrap_includes' %> + + + + + <%= render 'layouts/navbar' %> -<%= render 'layouts/noscript_notice' %> -
-
-
- <%= yield %> -
-
- <%= render 'layouts/sidebar' %> +
+
+
+
<%= yield %>
+
+ <%= render 'layouts/sidebar' %> +
-
- + <%= render 'layouts/ganalytics' %> -<%= render 'layouts/ganalytics' %> + + + +<%= render 'layouts/footer' %> - diff --git a/app/views/locations/_form.html.erb b/app/views/locations/_form.html.erb deleted file mode 100644 index a5490c31..00000000 --- a/app/views/locations/_form.html.erb +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/views/locations/_list.html.erb b/app/views/locations/_list.html.erb index 97cef6f9..f0c9e99c 100644 --- a/app/views/locations/_list.html.erb +++ b/app/views/locations/_list.html.erb @@ -20,7 +20,7 @@ <%= link_to t('.view', :default => t("helpers.links.view")), location_path(location), :class => 'btn' %> <%= link_to t('.edit', :default => t("helpers.links.edit")), - location_edit_path(location), :class => 'btn' %> + edit_location_path(location), :class => 'btn' %> <% end %>
diff --git a/app/views/locations/_tabs.html.erb b/app/views/locations/_tabs.html.erb deleted file mode 100644 index 63ec8db0..00000000 --- a/app/views/locations/_tabs.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/app/views/locations/edit.html.erb b/app/views/locations/edit.html.erb index 7571a822..025abcfb 100644 --- a/app/views/locations/edit.html.erb +++ b/app/views/locations/edit.html.erb @@ -1,37 +1,9 @@ -<%- model_class = @content.class -%> - -
-
-
-

Facets

- <%= render :partial => 'tabs' %> -
- -
-

Danger-zone

-
- <%= link_to 'Delete location forever', location_path, - :class => 'btn btn-danger', +

Editing a location

+<%= form_for @content, :url => location_edit_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> + <%= link_to "Delete #{@content.class.to_s} forever", @content, + :class => 'red btn right', :method => :delete, :confirm => 'Are you sure? This action cannot be undone!' %> -
-
-
- -
-
-

Editing <%= @content.name %>

- <%= form_for @content, - :url => location_edit_process_path, - :html => { :class => 'form-horizontal' } do |form| %> -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', location_list_path, :class => 'btn' %> -
- <% end %> -
-
-
+<% end %> \ No newline at end of file diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index b7b23c9b..edff6a87 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -1,36 +1,4 @@ -<%- model_class = @content.class -%> +

You've created <%= @content.count %> locations

+<%= render partial: 'content/list/list', locals: { content_list: @content } %> -
- -<% if @content.length > 0 %> -
-
-

- Your locations - <% if false and Universe.where(user_id: session[:user]).length > 0 %> - from <%= render 'universes/picker' %> - <% end %> -

-
-
- -<%= render 'list' %> -<% end %> - -
-
-

Planning locations

-
-

- Worldbuilding should never be neglected; keep track of where your characters are, where they have been, and where they are going. -

-
-
- <%= link_to 'New location', location_create_path, :class => 'btn btn-primary' %> - <%= link_to 'New country', location_create_type_path(:country), :class => 'btn' %> - <%= link_to 'New city', location_create_type_path(:city), :class => 'btn' %> -
-
-
- -
+<%= link_to 'Create another location', location_create_path, :class => 'btn' %> diff --git a/app/views/locations/new.html.erb b/app/views/locations/new.html.erb index 8a2ee3f7..2abb3000 100644 --- a/app/views/locations/new.html.erb +++ b/app/views/locations/new.html.erb @@ -1,30 +1,5 @@ -<%- model_class = @content.class -%> -
-
- -
-

New location

- <%= render :partial => 'tabs' %> -
-
-
-
- - <%= form_for @content, - :url => location_create_process_path, - :html => { :class => 'form-horizontal' } do |form| %> - -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', location_list_path, :class => 'btn' %> -
- - <% end %> -
- -
- -
\ No newline at end of file +

Create a new location

+<%= form_for @content, :url => location_create_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> +<% end %> \ No newline at end of file diff --git a/app/views/locations/show.html.erb b/app/views/locations/show.html.erb index bace461b..ed58f3d5 100644 --- a/app/views/locations/show.html.erb +++ b/app/views/locations/show.html.erb @@ -1,86 +1,3 @@ -<% @location = @content %> -<%- model_class = @location.class -%> +<%= render partial: 'content/show', locals: { content: @content } %> -
-
-
- <%= render :partial => 'tabs' %> -
-
- -
-
-

- <%= @location.name %> -

- -
- - - - - - - - - - - - - - - -
-
- - <% if session[:user] and session[:user] == @location.user.id %> -
- <%= link_to t('.back', :default => t("helpers.links.back")), - location_list_path, :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - location_edit_path(@location), :class => 'btn' %> -
- <% end %> - -
- - -
-
-
\ No newline at end of file +<%= link_to 'Edit this location', edit_location_path(@content), class: 'btn' %> \ No newline at end of file diff --git a/app/views/magic/_edit_form.html.erb b/app/views/magic/_edit_form.html.erb deleted file mode 100644 index 2c6dba18..00000000 --- a/app/views/magic/_edit_form.html.erb +++ /dev/null @@ -1,119 +0,0 @@ -<%= form_for @magic, :url => magic_edit_process_path, :html => { :class => 'form-horizontal' } do |f| %> - - - - - - - - - - - - -
- <%= f.submit nil, :class => 'btn btn-primary' %> - <%= link_to t('.cancel', :default => t("helpers.links.cancel")), - magic_list_path, :class => 'btn' %> -
-<% end %> diff --git a/app/views/magic/_form.html.erb b/app/views/magic/_form.html.erb deleted file mode 100644 index 56125e0c..00000000 --- a/app/views/magic/_form.html.erb +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - diff --git a/app/views/magic/_list.html.erb b/app/views/magic/_list.html.erb deleted file mode 100644 index d5c13fdf..00000000 --- a/app/views/magic/_list.html.erb +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - <% if session[:user] %> - - <% end %> - - - - <% @content.each do |magic| %> - - - - - - <% end %> - -
NameType<%=t '.actions', :default => t("helpers.actions") %>
<%= simple_format link_to magic.name, magic %><%= simple_format magic.type_of %> - <% if session[:user] and session[:user] == magic.user.id %> - <%= link_to t('.view', :default => t("helpers.links.view")), - magic_path(magic), :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - magic_edit_path(magic), :class => 'btn' %> - <% end %> -
- diff --git a/app/views/magic/_tabs.html.erb b/app/views/magic/_tabs.html.erb deleted file mode 100644 index 6f1bc165..00000000 --- a/app/views/magic/_tabs.html.erb +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/app/views/magic/edit.html.erb b/app/views/magic/edit.html.erb deleted file mode 100644 index caec2e25..00000000 --- a/app/views/magic/edit.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -<%- model_class = @content.class -%> - -
-
-
-

Facets

- <%= render :partial => 'tabs' %> -
- -
-

Danger-zone

-
- <%= link_to 'Delete magic forever', magic_path, - :class => 'btn btn-danger', - :method => :delete, - :confirm => 'Are you sure? This action cannot be undone!' %> -
-
-
- -
-
-

Editing <%= @content.name %>

- <%= form_for @content, - :url => magic_edit_process_path, - :html => { :class => 'form-horizontal' } do |form| %> -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', magic_list_path, :class => 'btn' %> -
- <% end %> -
-
-
diff --git a/app/views/magic/index.html.erb b/app/views/magic/index.html.erb deleted file mode 100644 index 120be60b..00000000 --- a/app/views/magic/index.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<%- model_class = @content.class -%> -<% if @content.length > 0 %> -
-

- Magic - <% if false and Universe.where(user_id: session[:user]).length > 0 %> - from <%= render 'universes/picker' %> - <% end %> -

- - <%= render 'list', locals: { content: @content } %> -
-<% end %> - -
-

Planning magic

-
-

- Magic, the most wonderous thing! How does it work? -

- <%= link_to 'New magic', magic_create_path, :class => 'btn btn-primary' %> - <%= link_to 'New spell', magic_create_type_path(:spell), :class => 'btn' %> - <%= link_to 'New enchantment', magic_create_type_path(:enchantment), :class => 'btn' %> - <%= link_to 'New curse', magic_create_type_path(:curse), :class => 'btn' %> - <%= link_to 'New potion', magic_create_type_path(:potion), :class => 'btn' %> -
-
-
diff --git a/app/views/magic/new.html.erb b/app/views/magic/new.html.erb deleted file mode 100644 index ff384f75..00000000 --- a/app/views/magic/new.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -
-
- -
-

New magic

- <%= render :partial => 'tabs' %> -
-
-
-
- - <%= form_for @content, - :url => magic_create_process_path, - :html => { :class => 'form-horizontal' } do |form| %> - -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', magic_list_path, :class => 'btn' %> -
- - <% end %> -
-
-
\ No newline at end of file diff --git a/app/views/magic/show.html.erb b/app/views/magic/show.html.erb deleted file mode 100644 index 0759fa8e..00000000 --- a/app/views/magic/show.html.erb +++ /dev/null @@ -1,69 +0,0 @@ -<%- model_class = @content.class -%> -<% @magic = @content %> - -
-
-
- <%= render :partial => 'tabs' %> -
-
- -
-
-

- <%= @magic.name %> -

- -
- - - - - - - - - - - -
- -
- - <% if session[:user] and session[:user] == @magic.user.id %> -
- <%= link_to t('.back', :default => t("helpers.links.back")), - magic_list_path, :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - magic_edit_path(@magic), :class => 'btn' %> -
- <% end %> - -
- -
-
-
diff --git a/app/views/main/_dashboard_intro.html.erb b/app/views/main/_dashboard_intro.html.erb deleted file mode 100644 index 2a2846d4..00000000 --- a/app/views/main/_dashboard_intro.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -
-
-
-

This is is your dashboard

-
-

- As you plan your stories, you can always return back here to get a view of everything - you've created at a glance. To get back here from anywhere, simply click the - Indent logo up top, or the icon next to it. -

-

- Good luck and have fun! -

-
-
-
-
- -
-
-

Ready to get started?

-
-

- Welcome to Indent. Before you get started, it's recommended that you - <%= link_to "create a universe", :universe_create %>. -

-

- This universe will contain - everything you create about your world, and is a handy way to keep multiple worlds - cleanly separated during the planning process. -

-
-
- <%= link_to "Create a universe!", :universe_create %> -
-
-
-
- diff --git a/app/views/main/_quote_card.html.erb b/app/views/main/_quote_card.html.erb deleted file mode 100644 index f1bae6ff..00000000 --- a/app/views/main/_quote_card.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - -<% quote = t(:quotes).sample %> - -
-
-

<%= quote["text"] %>

- - <%= quote["author"] %>, - "> - <%= quote["source"] %> - - -
-
diff --git a/app/views/main/anoninfo.html.erb b/app/views/main/anoninfo.html.erb deleted file mode 100644 index bd4ba0ed..00000000 --- a/app/views/main/anoninfo.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -
-

What are "Anonymous" accounts?

-
-

- Nobody likes having to create an account before being able to check out something cool. -

- -

- So you don't need an account. If you're just browsing or deciding whether or not it's worth creating an account, you can simply log in with the big, blue Be Anonymous button. -

- -

- Clicking the button will generate a random account and automatically log you in, letting you jump right in to planning your stories. Everything acts exactly as it would if you were logged in to a "real" account, except with one caveat: -

- -

- If you log out or close your browser without setting a username and password for yourself, your account will be deleted. To keep all of your content, all you have to do is visit this page and type in the login information you want to use – it's that easy. All of your content will be saved and you can log in to your account with that username in the future. -

-
-
-
- -
- <%= render 'quote_card' %> -
diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 6ef46cdf..01d94ade 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -1,35 +1,194 @@ -<% if @things > 0 %> -
-
-

- You've created a total of <%= @things %> <%= "thing".pluralize(@things) %>! -

- -
-

- Keep it up! -

+
+
+
+
+ <%= image_tag 'card-headers/universes.jpg', class: 'activator', style: 'height: 390px' %> +
+
+ + You've created <%= current_user.universes.count %> universes + <%= link_to universe_list_path, class: 'black-text' do %> + zoom_out_map + <% end %> + arrow_upward + +

Create another

+
+
+ + Universes + close + + + + + + + + + + <% current_user.universes.each do |universe| %> + + + + + + + + <% end %> +
NameDescriptionCreated atLast modified
<%= link_to universe.name, universe %><%= universe.description %><%= universe.created_at.strftime("%m/%d/%Y") %><%= universe.updated_at.strftime("%m/%d/%Y") %> + <%= link_to edit_universe_path(universe) do %> + edit + <% end %> +
+ <%= link_to 'Create another', universe_create_path, class: 'btn' %>
-
-
-
-
-

-

<%= @characters.length %> <%= link_to "character".pluralize(@characters.length), character_list_path %>

-

<%= @equipment.length %> <%= link_to "piece".pluralize(@equipment.length) + " of equipment", equipment_list_path %>

-

<%= @languages.length %> <%= link_to "language".pluralize(@languages.length), language_list_path %>

-

<%= @locations.length %> <%= link_to "location".pluralize(@locations.length), location_list_path %>

-

<%= @magics.length %> <%= link_to "manifestation".pluralize(@magics.length) + " of magic", magic_list_path %>

-

<%= @universes.length %> <%= link_to "universe".pluralize(@universes.length), universe_list_path %>

-

+
+
+
+ <%= image_tag 'card-headers/characters.jpg', class: 'activator', style: 'height: 390px' %> +
+
+ + You've created <%= current_user.characters.count %> characters + <%= link_to character_list_path, class: 'black-text' do %> + zoom_out_map + <% end %> + arrow_upward + +

Create another

+
+
+ + Characters + close + + + + + + + + + + <% current_user.characters.each do |character| %> + + + + + + + + <% end %> +
NameRoleCreated atLast modified
<%= link_to character.name, character %><%= character.role %><%= character.created_at.strftime("%m/%d/%Y") %><%= character.updated_at.strftime("%m/%d/%Y") %> + <%= link_to edit_character_path(character) do %> + edit + <% end %> +
+ <%= link_to 'Create another', character_create_path, class: 'btn' %>
-
-<% else %> - <%= render 'dashboard_intro' %> -<% end %> +
+
+
+ <%= image_tag 'card-headers/locations.jpg', class: 'activator', style: 'height: 390px' %> +
+
+ + You've created <%= current_user.locations.count %> locations + <%= link_to location_list_path, class: 'black-text' do %> + zoom_out_map + <% end %> + arrow_upward + +

<%= link_to 'Create another', location_create_path %>

+
+
+ + Locations + close + + + + + + + + + + + <% current_user.locations.each do |location| %> + + + + + + + + + <% end %> +
NameDescriptionTypeCreated atLast modified
<%= link_to location.name, location %><%= location.description %><%= location.type_of %><%= location.created_at.strftime("%m/%d/%Y") %><%= location.updated_at.strftime("%m/%d/%Y") %> + <%= link_to edit_location_path(location) do %> + edit + <% end %> +
+ <%= link_to 'Create another', location_create_path, class: 'btn' %> +
+
+
+ +
+
+
+ <%= image_tag 'card-headers/items.jpg', class: 'activator', style: 'height: 390px' %> +
+
+ + You've created <%= current_user.items.count %> items + <%= link_to item_list_path, class: 'black-text' do %> + zoom_out_map + <% end %> + arrow_upward + +

<%= link_to 'Create another', item_create_path %>

+
+
+ + Items + close + + + + + + + + + + + <% current_user.items.each do |item| %> + + + + + + + + + <% end %> +
NameDescriptionTypeCreated atLast modified
<%= link_to item.name, item %><%= item.description %><%= item.item_type %><%= item.created_at.strftime("%m/%d/%Y") %><%= item.updated_at.strftime("%m/%d/%Y") %> + <%= link_to edit_item_path(item) do %> + edit + <% end %> +
+ <%= link_to 'Create another', item_create_path, class: 'btn' %> +
+
+
+ +
\ No newline at end of file diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb index e13d530f..51181999 100644 --- a/app/views/main/index.html.erb +++ b/app/views/main/index.html.erb @@ -1,129 +1,22 @@ -
- -
+
-
-

- Indent before you write -

-

- Indent is a set of tools for writers, game designers, and roleplayers to create magnificent universes – and everything within them. -

+
+ <%= image_tag 'card-headers/hero.jpg', width: '100%' %> + Your digital notebook is here. +
+
+

+ Notebook is a set of tools for writers, game designers, and roleplayers to create magnificent universes – and everything within them. +

From a simple interface in your browser, on your phone, or on your tablet, you can do everything you'd ever want to do while creating your own little (or big!) world.

-

- Ready? -

-
- -
-
-
-
- <%= image_tag "card-headers/hero.jpg", :style => "width: 100%;" %> -
-
- -
- -
-
-
-

Characters

- <%= image_tag "card-headers/characters.jpg" %> -
-

- Plan physical appearance, behaviorisms, social roles, family – even a favorite color! -

-
- -
-
- -
-
-

Equipment

- <%= image_tag "card-headers/equipment.jpg" %> -
-

- Every weapon was made by someone. Keep track of every aspect of your equipment. -

-
- -
-
- -
-
-

Locations

- <%= image_tag "card-headers/locations.jpg" %> -
-

- Upload maps, link areas, track demographics, and keep track of history. -

-
- -
-
- -
-
-

Magic

- <%= image_tag "card-headers/magic.jpg" %> -
-

- Whether it's fireballs or potions or nature or voodoo, craft every facet to how it works. -

-
- -
-
- -
-
-

Languages

- <%= image_tag "card-headers/languages.jpg" %> -
-

- English doesn't have to be the only language in your world. Everything is fair game. -

-
- -
-
- -
-
-

Universes

- <%= image_tag "card-headers/universes.jpg" %> -
-

- You know you've always wanted to create an entire universe. Now's your chance! -

-
-
- Plan your own +
+ <%= link_to 'Get started', new_user_registration_path %>
-
diff --git a/app/views/sessions/_form.html.erb b/app/views/sessions/_form.html.erb index e2027006..a573afe5 100644 --- a/app/views/sessions/_form.html.erb +++ b/app/views/sessions/_form.html.erb @@ -17,7 +17,7 @@
<%= f.submit 'Log in', :class => 'btn btn-primary' %> - <%= link_to t('.cancel', :default => t("helpers.links.cancel")), homepage_path, :class => 'btn' %> + <%= link_to t('.cancel', :default => t("helpers.links.cancel")), root_url, :class => 'btn' %>
<% end %> diff --git a/app/views/universes/_form.html.erb b/app/views/universes/_form.html.erb deleted file mode 100644 index ff81addd..00000000 --- a/app/views/universes/_form.html.erb +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - diff --git a/app/views/universes/_tabs.html.erb b/app/views/universes/_tabs.html.erb deleted file mode 100644 index 97cbb90d..00000000 --- a/app/views/universes/_tabs.html.erb +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/app/views/universes/edit.html.erb b/app/views/universes/edit.html.erb index fb575366..27bceb05 100644 --- a/app/views/universes/edit.html.erb +++ b/app/views/universes/edit.html.erb @@ -1,37 +1,9 @@ -<%- model_class = @content.class -%> - -
-
-
-

Facets

- <%= render :partial => 'tabs' %> -
- -
-

Danger-zone

-
- <%= link_to 'Delete universe forever', universe_path, - :class => 'btn btn-danger', +

Editing a universe

+<%= form_for @content, :url => universe_edit_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> + <%= link_to "Delete #{@content.class.to_s} forever", @content, + :class => 'red btn right', :method => :delete, :confirm => 'Are you sure? This action cannot be undone!' %> -
-
-
- -
-
-

Editing <%= @content.name %>

- <%= form_for @content, - :url => universe_edit_process_path, - :html => { :class => 'form-horizontal' } do |form| %> -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', universe_list_path, :class => 'btn' %> -
- <% end %> -
-
-
+<% end %> \ No newline at end of file diff --git a/app/views/universes/index.html.erb b/app/views/universes/index.html.erb index a9231b54..74955f61 100644 --- a/app/views/universes/index.html.erb +++ b/app/views/universes/index.html.erb @@ -1,41 +1,4 @@ -<%- model_class = @content.class -%> - -
- - <% if @content.length > 0 %> - <% @content.each do |universe| %> -
-
-

- <% if universe.privacy and universe.privacy.downcase == "public" %> - - <% end %> - <%= universe.name %> -

-
-

<%= simple_format truncate(universe.description, length: 256) %> -

-
- <%= link_to t('.view', :default => t("helpers.links.view")), universe_path(universe), :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), universe_edit_path(universe), :class => 'btn' %> -
-
-
- <% end %> - <% end %> - -
-
-

What is a universe?

-
-

- Literally, a universe. The universe your character exists in. The universe their friends, family, and foes exist in. The universe that contains their hometown, their country, their planet – everything that exists in their world. Sticking it all in a universe keeps it separate from other universes that other stories might be happening in. -

-
-
- <%= link_to 'New universe', universe_create_path, :class => 'btn btn-primary' %> -
-
-
-
+

You've created <%= @content.count %> universes

+<%= render partial: 'content/list/list', locals: { content_list: @content } %> +<%= link_to 'Create another universe', universe_create_path, :class => 'btn' %> \ No newline at end of file diff --git a/app/views/universes/new.html.erb b/app/views/universes/new.html.erb index 79c60b66..849cc04e 100644 --- a/app/views/universes/new.html.erb +++ b/app/views/universes/new.html.erb @@ -1,29 +1,5 @@ -
-
- -
-

New universe

- <%= render :partial => 'tabs' %> -
-
-
-
- - <%= form_for @content, - :url => universe_create_process_path, - :html => { :class => 'form-horizontal' } do |form| %> - -
- <%= render :partial => 'form', :locals => { :f => form } %> -
-
- <%= form.submit nil, :class => 'btn btn-primary' %> - <%= link_to 'Cancel', universe_list_path, :class => 'btn' %> -
- - <% end %> -
- -
- -
\ No newline at end of file +

Create a new universe

+<%= form_for @content, :url => universe_create_process_path do |form| %> + <%= render partial: 'content/form', locals: { f: form, content: @content } %> + <%= form.submit nil, :class => 'btn btn-primary' %> +<% end %> \ No newline at end of file diff --git a/app/views/universes/show.html.erb b/app/views/universes/show.html.erb index 172148da..cd652d1c 100644 --- a/app/views/universes/show.html.erb +++ b/app/views/universes/show.html.erb @@ -1,140 +1,3 @@ -<% @universe = @content %> -<%- model_class = @universe.class -%> +<%= render partial: 'content/show', locals: { content: @content } %> -
-
-
- <%= render :partial => 'tabs' %> -
-
- -
-
-

- <% if @universe.privacy and @universe.privacy.downcase == "public" %> - - <% end %> - <%= @universe.name %> by <%= @universe.user.name %> -

- -
- - - - - - - - - -
- -
- - <% if session[:user] and session[:user] == @universe.user.id %> -
- <%= link_to t('.back', :default => t("helpers.links.back")), - universe_list_path, :class => 'btn' %> - <%= link_to t('.edit', :default => t("helpers.links.edit")), - universe_edit_path(@universe), :class => 'btn' %> -
- <% end %> - -
- -
-
-
- -<% if @universe.content_count > 0 %> - -
-

- In this universe... -

- -
- - -
-
-
-
- - - - - - - -
- -
- -
- -<% end %> - -<% u = User.find(session[:user]) if session[:user] %> -<% if session[:user] and u.content_count == 1 and u.universes.length == 1 %> -
-

Congratulations, you created your first universe! So... what next?

-
-

- Now that you know the basics of how to create, edit, and view your content, you're free to create anything you want! Personally I typically start with characters, but I know some people enjoy starting with a good map full of locations. Or if magic is more your thing, all power to you! -

-

- Your universe is empty but ready to be filled with stuff now. You'll find everything you could think to fill it with within the Plan menu at the top of the page! -

-

- Good luck! -

-
-
-<% end %> \ No newline at end of file +<%= link_to 'Edit this universe', edit_universe_path(@content), class: 'btn' %> \ No newline at end of file diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 239ba3a0..975b64a7 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -43,7 +43,7 @@
<%= f.submit nil, :class => 'btn btn-primary' %> - <%= link_to t('.cancel', :default => t("helpers.links.cancel")), homepage_path, :class => 'btn' %> + <%= link_to t('.cancel', :default => t("helpers.links.cancel")), root_url, :class => 'btn' %>
<% end %> diff --git a/config/database.yml b/config/database.yml index 1c1a37ca..34cd6a6c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -21,5 +21,4 @@ test: database: db/test.sqlite3 production: - <<: *default - database: db/production.sqlite3 + url: <%= ENV['DATABASE_URL'] %> diff --git a/config/environments/development.rb b/config/environments/development.rb index cb6a141c..362f7c58 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -26,6 +26,9 @@ PlanCharacters::Application.configure do # Do not compress assets config.assets.compress = false + # Devise default url options + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + # DEVELOPMENT S3 settings for Paperclip uploads ON DEVELOPMENT config.paperclip_defaults = { storage: :s3, diff --git a/config/environments/production.rb b/config/environments/production.rb index c6316329..67f55c6f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -10,7 +10,7 @@ Rails.application.configure do config.eager_load = true # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = false + config.serve_static_files = false # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -62,6 +62,9 @@ Rails.application.configure do # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true + # Devise default url options + config.action_mailer.default_url_options = { host: 'notebook.indentlabs.com', port: 80 } + # Send deprecation notices to registered listeners config.active_support.deprecation = :notify diff --git a/config/environments/test.rb b/config/environments/test.rb index aa5e9f37..f14c6e11 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,7 +8,7 @@ Rails.application.configure do config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_files = true config.static_cache_control = 'public, max-age=3600' config.eager_load = false diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb new file mode 100644 index 00000000..19252e65 --- /dev/null +++ b/config/initializers/devise.rb @@ -0,0 +1,265 @@ +# Use this hook to configure devise mailer, warden hooks and so forth. +# Many of these configuration options can be set straight in your model. +Devise.setup do |config| + # The secret key used by Devise. Devise uses this key to generate + # random tokens. Changing this key will render invalid all existing + # confirmation, reset password and unlock tokens in the database. + # Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key` + # by default. You can change it below and use your own secret key. + config.secret_key = '81af3b7e066c6e98abdc277d2f97b72c179d4b4332c4cf0434f99681d1f81693713e41b58d076e0493c003d12451b2c5953d42ab3f66e9c31d6fa760db0aad0c' + + # ==> Mailer Configuration + # Configure the e-mail address which will be shown in Devise::Mailer, + # note that it will be overwritten if you use your own mailer class + # with default "from" parameter. + config.mailer_sender = 'notebook@indentlabs.com' + + # Configure the class responsible to send e-mails. + # config.mailer = 'Devise::Mailer' + + # ==> ORM configuration + # Load and configure the ORM. Supports :active_record (default) and + # :mongoid (bson_ext recommended) by default. Other ORMs may be + # available as additional gems. + require 'devise/orm/active_record' + + # ==> Configuration for any authentication mechanism + # Configure which keys are used when authenticating a user. The default is + # just :email. You can configure it to use [:username, :subdomain], so for + # authenticating a user, both parameters are required. Remember that those + # parameters are used only when authenticating and not when retrieving from + # session. If you need permissions, you should implement that in a before filter. + # You can also supply a hash where the value is a boolean determining whether + # or not authentication should be aborted when the value is not present. + # config.authentication_keys = [:email] + + # Configure parameters from the request object used for authentication. Each entry + # given should be a request method and it will automatically be passed to the + # find_for_authentication method and considered in your model lookup. For instance, + # if you set :request_keys to [:subdomain], :subdomain will be used on authentication. + # The same considerations mentioned for authentication_keys also apply to request_keys. + # config.request_keys = [] + + # Configure which authentication keys should be case-insensitive. + # These keys will be downcased upon creating or modifying a user and when used + # to authenticate or find a user. Default is :email. + config.case_insensitive_keys = [:email] + + # Configure which authentication keys should have whitespace stripped. + # These keys will have whitespace before and after removed upon creating or + # modifying a user and when used to authenticate or find a user. Default is :email. + config.strip_whitespace_keys = [:email] + + # Tell if authentication through request.params is enabled. True by default. + # It can be set to an array that will enable params authentication only for the + # given strategies, for example, `config.params_authenticatable = [:database]` will + # enable it only for database (email + password) authentication. + # config.params_authenticatable = true + + # Tell if authentication through HTTP Auth is enabled. False by default. + # It can be set to an array that will enable http authentication only for the + # given strategies, for example, `config.http_authenticatable = [:database]` will + # enable it only for database authentication. The supported strategies are: + # :database = Support basic authentication with authentication key + password + # config.http_authenticatable = false + + # If 401 status code should be returned for AJAX requests. True by default. + # config.http_authenticatable_on_xhr = true + + # The realm used in Http Basic Authentication. 'Application' by default. + # config.http_authentication_realm = 'Application' + + # It will change confirmation, password recovery and other workflows + # to behave the same regardless if the e-mail provided was right or wrong. + # Does not affect registerable. + # config.paranoid = true + + # By default Devise will store the user in session. You can skip storage for + # particular strategies by setting this option. + # Notice that if you are skipping storage for all authentication paths, you + # may want to disable generating routes to Devise's sessions controller by + # passing skip: :sessions to `devise_for` in your config/routes.rb + config.skip_session_storage = [:http_auth] + + # By default, Devise cleans up the CSRF token on authentication to + # avoid CSRF token fixation attacks. This means that, when using AJAX + # requests for sign in and sign up, you need to get a new CSRF token + # from the server. You can disable this option at your own risk. + # config.clean_up_csrf_token_on_authentication = true + + # ==> Configuration for :database_authenticatable + # For bcrypt, this is the cost for hashing the password and defaults to 10. If + # using other encryptors, it sets how many times you want the password re-encrypted. + # + # Limiting the stretches to just one in testing will increase the performance of + # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use + # a value less than 10 in other environments. Note that, for bcrypt (the default + # encryptor), the cost increases exponentially with the number of stretches (e.g. + # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation). + config.stretches = Rails.env.test? ? 1 : 10 + + # Setup a pepper to generate the encrypted password. + # config.pepper = '663d2a93a1c348ef0c540729701ce6767ea5b3f6f68543ddd16549d8dd2f63022af9c7f54c429e5b247566b1b099c1c0d05ac64fdc1c6898dd7495c52b10862d' + + # Send a notification email when the user's password is changed + # config.send_password_change_notification = false + + # ==> Configuration for :confirmable + # A period that the user is allowed to access the website even without + # confirming their account. For instance, if set to 2.days, the user will be + # able to access the website for two days without confirming their account, + # access will be blocked just in the third day. Default is 0.days, meaning + # the user cannot access the website without confirming their account. + # config.allow_unconfirmed_access_for = 2.days + + # A period that the user is allowed to confirm their account before their + # token becomes invalid. For example, if set to 3.days, the user can confirm + # their account within 3 days after the mail was sent, but on the fourth day + # their account can't be confirmed with the token any more. + # Default is nil, meaning there is no restriction on how long a user can take + # before confirming their account. + # config.confirm_within = 3.days + + # If true, requires any email changes to be confirmed (exactly the same way as + # initial account confirmation) to be applied. Requires additional unconfirmed_email + # db field (see migrations). Until confirmed, new email is stored in + # unconfirmed_email column, and copied to email column on successful confirmation. + config.reconfirmable = true + + # Defines which key will be used when confirming an account + # config.confirmation_keys = [:email] + + # ==> Configuration for :rememberable + # The time the user will be remembered without asking for credentials again. + # config.remember_for = 2.weeks + + # Invalidates all the remember me tokens when the user signs out. + config.expire_all_remember_me_on_sign_out = true + + # If true, extends the user's remember period when remembered via cookie. + # config.extend_remember_period = false + + # Options to be passed to the created cookie. For instance, you can set + # secure: true in order to force SSL only cookies. + # config.rememberable_options = {} + + # ==> Configuration for :validatable + # Range for password length. + config.password_length = 8..72 + + # Email regex used to validate email formats. It simply asserts that + # one (and only one) @ exists in the given string. This is mainly + # to give user feedback and not to assert the e-mail validity. + # config.email_regexp = /\A[^@]+@[^@]+\z/ + + # ==> Configuration for :timeoutable + # The time you want to timeout the user session without activity. After this + # time the user will be asked for credentials again. Default is 30 minutes. + # config.timeout_in = 30.minutes + + # ==> Configuration for :lockable + # Defines which strategy will be used to lock an account. + # :failed_attempts = Locks an account after a number of failed attempts to sign in. + # :none = No lock strategy. You should handle locking by yourself. + # config.lock_strategy = :failed_attempts + + # Defines which key will be used when locking and unlocking an account + # config.unlock_keys = [:email] + + # Defines which strategy will be used to unlock an account. + # :email = Sends an unlock link to the user email + # :time = Re-enables login after a certain amount of time (see :unlock_in below) + # :both = Enables both strategies + # :none = No unlock strategy. You should handle unlocking by yourself. + # config.unlock_strategy = :both + + # Number of authentication tries before locking an account if lock_strategy + # is failed attempts. + # config.maximum_attempts = 20 + + # Time interval to unlock the account if :time is enabled as unlock_strategy. + # config.unlock_in = 1.hour + + # Warn on the last attempt before the account is locked. + # config.last_attempt_warning = true + + # ==> Configuration for :recoverable + # + # Defines which key will be used when recovering the password for an account + # config.reset_password_keys = [:email] + + # Time interval you can reset your password with a reset password key. + # Don't put a too small interval or your users won't have the time to + # change their passwords. + config.reset_password_within = 6.hours + + # When set to false, does not sign a user in automatically after their password is + # reset. Defaults to true, so a user is signed in automatically after a reset. + # config.sign_in_after_reset_password = true + + # ==> Configuration for :encryptable + # Allow you to use another encryption algorithm besides bcrypt (default). You can use + # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1, + # :authlogic_sha512 (then you should set stretches above to 20 for default behavior) + # and :restful_authentication_sha1 (then you should set stretches to 10, and copy + # REST_AUTH_SITE_KEY to pepper). + # + # Require the `devise-encryptable` gem when using anything other than bcrypt + # config.encryptor = :sha512 + + # ==> Scopes configuration + # Turn scoped views on. Before rendering "sessions/new", it will first check for + # "users/sessions/new". It's turned off by default because it's slower if you + # are using only default views. + # config.scoped_views = false + + # Configure the default scope given to Warden. By default it's the first + # devise role declared in your routes (usually :user). + # config.default_scope = :user + + # Set this configuration to false if you want /users/sign_out to sign out + # only the current scope. By default, Devise signs out all scopes. + # config.sign_out_all_scopes = true + + # ==> Navigation configuration + # Lists the formats that should be treated as navigational. Formats like + # :html, should redirect to the sign in page when the user does not have + # access, but formats like :xml or :json, should return 401. + # + # If you have any extra navigational formats, like :iphone or :mobile, you + # should add them to the navigational formats lists. + # + # The "*/*" below is required to match Internet Explorer requests. + # config.navigational_formats = ['*/*', :html] + + # The default HTTP method used to sign out a resource. Default is :delete. + config.sign_out_via = :delete + + # ==> OmniAuth + # Add a new OmniAuth provider. Check the wiki for more information on setting + # up on your models and hooks. + # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo' + + # ==> Warden configuration + # If you want to use other strategies, that are not supported by Devise, or + # change the failure app, you can configure them inside the config.warden block. + # + # config.warden do |manager| + # manager.intercept_401 = false + # manager.default_strategies(scope: :user).unshift :some_external_strategy + # end + + # ==> Mountable engine configurations + # When using Devise inside an engine, let's call it `MyEngine`, and this engine + # is mountable, there are some extra configurations to be taken into account. + # The following options are available, assuming the engine is mounted as: + # + # mount MyEngine, at: '/my_engine' + # + # The router that invoked `devise_for`, in the example above, would be: + # config.router_name = :my_engine + # + # When using OmniAuth, Devise cannot automatically set OmniAuth path, + # so you need to do it manually. For the users scope, it would be: + # config.omniauth_path_prefix = '/my_engine/users/auth' +end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml new file mode 100644 index 00000000..bd4c3ebc --- /dev/null +++ b/config/locales/devise.en.yml @@ -0,0 +1,62 @@ +# Additional translations at https://github.com/plataformatec/devise/wiki/I18n + +en: + devise: + confirmations: + confirmed: "Your email address has been successfully confirmed." + send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." + 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." + failure: + already_authenticated: "You are already signed in." + inactive: "Your account is not activated yet." + invalid: "Invalid %{authentication_keys} or password." + locked: "Your account is locked." + last_attempt: "You have one more attempt before your account is locked." + not_found_in_database: "Invalid %{authentication_keys} or password." + timeout: "Your session expired. Please sign in again to continue." + unauthenticated: "You need to sign in or sign up before continuing." + unconfirmed: "You have to confirm your email address before continuing." + mailer: + confirmation_instructions: + subject: "Confirmation instructions" + reset_password_instructions: + subject: "Reset password instructions" + unlock_instructions: + subject: "Unlock instructions" + password_change: + subject: "Password Changed" + omniauth_callbacks: + failure: "Could not authenticate you from %{kind} because \"%{reason}\"." + success: "Successfully authenticated from %{kind} account." + passwords: + 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." + send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." + 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." + updated: "Your password has been changed successfully. You are now signed in." + updated_not_active: "Your password has been changed successfully." + registrations: + destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." + signed_up: "Welcome! You have signed up successfully." + signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." + signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + 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." + 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." + updated: "Your account has been updated successfully." + sessions: + signed_in: "Signed in successfully." + signed_out: "Signed out successfully." + already_signed_out: "Signed out successfully." + unlocks: + send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." + send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." + unlocked: "Your account has been unlocked successfully. Please sign in to continue." + errors: + messages: + already_confirmed: "was already confirmed, please try signing in" + confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" + expired: "has expired, please request a new one" + not_found: "not found" + not_locked: "was not locked" + not_saved: + one: "1 error prohibited this %{resource} from being saved:" + other: "%{count} errors prohibited this %{resource} from being saved:" diff --git a/config/routes.rb b/config/routes.rb index 01cc6c08..cb0e620b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,8 +1,9 @@ PlanCharacters::Application.routes.draw do + devise_for :users # rubocop:disable LineLength # Main pages - root to: 'main#index', as: :homepage + root to: 'main#index' # Info pages scope '/about' do @@ -22,14 +23,6 @@ PlanCharacters::Application.routes.draw do post '/login', to: 'sessions#create', as: :login_process get '/logout', to: 'sessions#destroy', as: :logout - # Users - get '/register', to: 'users#new', as: :signup - post '/register', to: 'users#create', as: :signup_process - get '/account', to: 'users#edit', as: :account - patch '/register', to: 'users#update', as: :account_process - get '/be-anonymous', to: 'users#anonymous', as: :anonymous - get '/anon-login', to: 'users#anonymous_login', as: :anonymous_login - # Planning scope '/plan' do # Characters @@ -38,30 +31,20 @@ PlanCharacters::Application.routes.draw do get '/character/new', to: 'characters#new', as: :character_create post '/character/new', to: 'characters#create', as: :character_create_process get '/character/:id', to: 'characters#show', as: :character - get '/character/:id/edit', to: 'characters#edit', as: :character_edit + get '/character/:id/edit', to: 'characters#edit', as: :edit_character patch '/character/:id', to: 'characters#update', as: :character_edit_process delete '/character/:id', to: 'characters#destroy', as: :character_destroy - # Equipment - get '/equipment', to: 'equipment#index', as: :equipment_list - get '/equipment/from/:universe', to: 'equipment#index', as: :equipment_by_universe - get '/equipment/new', to: 'equipment#new', as: :equipment_create - get '/equipment/new/:type_of', to: 'equipment#new', as: :equipment_create_type - post '/equipment/new', to: 'equipment#create', as: :equipment_create_process - get '/equipment/:id', to: 'equipment#show', as: :equipment - get '/equipment/:id/edit', to: 'equipment#edit', as: :equipment_edit - patch '/equipment/:id', to: 'equipment#update', as: :equipment_edit_process - delete '/equipment/:id', to: 'equipment#destroy', as: :equipment_destroy - - # Languages - get '/languages', to: 'languages#index', as: :language_list - get '/languages/from/:universe', to: 'languages#index', as: :languages_by_universe - get '/language/new', to: 'languages#new', as: :language_create - post '/language/new', to: 'languages#create', as: :language_create_process - get '/language/:id', to: 'languages#show', as: :language - get '/language/:id/edit', to: 'languages#edit', as: :language_edit - patch '/language/:id', to: 'languages#update', as: :language_edit_process - delete '/language/:id', to: 'languages#destroy', as: :language_destroy + # Items + get '/items', to: 'items#index', as: :item_list + get '/items/from/:universe', to: 'items#index', as: :item_by_universe + get '/item/new', to: 'items#new', as: :item_create + get '/item/new/:type_of', to: 'items#new', as: :item_create_type + post '/item/new', to: 'items#create', as: :item_create_process + get '/item/:id', to: 'items#show', as: :item + get '/item/:id/edit', to: 'items#edit', as: :edit_item + patch '/item/:id', to: 'items#update', as: :item_edit_process + delete '/item/:id', to: 'items#destroy', as: :item_destroy # Locations get '/locations', to: 'locations#index', as: :location_list @@ -70,27 +53,16 @@ PlanCharacters::Application.routes.draw do post '/location/new', to: 'locations#create', as: :location_create_process get '/location/new/:type_of', to: 'locations#new', as: :location_create_type get '/location/:id', to: 'locations#show', as: :location - get '/location/:id/edit', to: 'locations#edit', as: :location_edit + get '/location/:id/edit', to: 'locations#edit', as: :edit_location patch '/location/:id', to: 'locations#update', as: :location_edit_process delete '/location/:id', to: 'locations#destroy', as: :location_destroy - # Magic - get '/magic', to: 'magic#index', as: :magic_list - get '/magic/from/:universe', to: 'magic#index', as: :magic_by_universe - get '/magic/new', to: 'magic#new', as: :magic_create - post '/magic/new', to: 'magic#create', as: :magic_create_process - get '/magic/new/:type_of', to: 'magic#new', as: :magic_create_type - get '/magic/:id', to: 'magic#show', as: :magic - get '/magic/:id/edit', to: 'magic#edit', as: :magic_edit - patch '/magic/:id', to: 'magic#update', as: :magic_edit_process - delete '/magic/:id', to: 'magic#destroy', as: :magic_destroy - # Universes get '/universes', to: 'universes#index', as: :universe_list get '/universe/new', to: 'universes#new', as: :universe_create post '/universe/new', to: 'universes#create', as: :universe_create_process get '/universe/:id', to: 'universes#show', as: :universe - get '/universe/:id/edit', to: 'universes#edit', as: :universe_edit + get '/universe/:id/edit', to: 'universes#edit', as: :edit_universe patch '/universe/:id', to: 'universes#update', as: :universe_edit_process delete '/universe/:id', to: 'universes#destroy', as: :universe_destroy diff --git a/config/secrets.yml b/config/secrets.yml index c2f2dfba..e07acc87 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -19,4 +19,5 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. production: + secret_token: <%= ENV['SECRET_TOKEN'] %> secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/db/migrate/20140713043535_create_models.rb b/db/migrate/20140713043535_create_models.rb index dcb26156..60f3a3a8 100644 --- a/db/migrate/20140713043535_create_models.rb +++ b/db/migrate/20140713043535_create_models.rb @@ -70,10 +70,10 @@ class CreateModels < ActiveRecord::Migration t.timestamps end - create_table :equipment do |t| + create_table :items do |t| # General t.string :name, null: false - t.string :equip_type + t.string :item_type # Appearance t.text :description @@ -225,7 +225,7 @@ class CreateModels < ActiveRecord::Migration end create_table :users do |t| - t.string :name, unique: true, null: false + t.string :name, null: true t.string :email, unique: true, null: false t.string :password, null: false diff --git a/db/migrate/20160405035806_add_devise_to_users.rb b/db/migrate/20160405035806_add_devise_to_users.rb new file mode 100644 index 00000000..8c1cba49 --- /dev/null +++ b/db/migrate/20160405035806_add_devise_to_users.rb @@ -0,0 +1,48 @@ +class AddDeviseToUsers < ActiveRecord::Migration + def self.up + change_table(:users) do |t| + ## Database authenticatable + t.string :encrypted_password, null: false, default: "" + + ## Recoverable + t.string :reset_password_token + t.datetime :reset_password_sent_at + + ## Rememberable + t.datetime :remember_created_at + + ## Trackable + t.integer :sign_in_count, default: 0, null: false + t.datetime :current_sign_in_at + t.datetime :last_sign_in_at + t.string :current_sign_in_ip + t.string :last_sign_in_ip + + ## Confirmable + # t.string :confirmation_token + # t.datetime :confirmed_at + # t.datetime :confirmation_sent_at + # t.string :unconfirmed_email # Only if using reconfirmable + + ## Lockable + # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts + # t.string :unlock_token # Only if unlock strategy is :email or :both + # t.datetime :locked_at + + + # Uncomment below if timestamps were not included in your original model. + # t.timestamps null: false + end + + add_index :users, :email, unique: true + add_index :users, :reset_password_token, unique: true + # add_index :users, :confirmation_token, unique: true + # add_index :users, :unlock_token, unique: true + end + + def self.down + # By default, we don't want to make any assumption about how to roll back a migration when your + # model already existed. Please edit below which fields you would like to remove in this migration. + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/schema.rb b/db/schema.rb index dd669321..fd9e1491 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,9 +11,9 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150419134141) do +ActiveRecord::Schema.define(version: 20160405035806) do - create_table "characters", force: true do |t| + create_table "characters", force: :cascade do |t| t.string "name", null: false t.string "role" t.string "gender" @@ -57,9 +57,9 @@ ActiveRecord::Schema.define(version: 20150419134141) do t.datetime "updated_at" end - create_table "equipment", force: true do |t| + create_table "items", force: :cascade do |t| t.string "name", null: false - t.string "equip_type" + t.string "item_type" t.text "description" t.string "weight" t.string "original_owner" @@ -76,7 +76,7 @@ ActiveRecord::Schema.define(version: 20150419134141) do t.datetime "updated_at" end - create_table "languages", force: true do |t| + create_table "languages", force: :cascade do |t| t.string "name", null: false t.text "words" t.string "established_year" @@ -90,7 +90,7 @@ ActiveRecord::Schema.define(version: 20150419134141) do t.datetime "updated_at" end - create_table "locations", force: true do |t| + create_table "locations", force: :cascade do |t| t.string "name", null: false t.string "type_of" t.text "description" @@ -118,7 +118,7 @@ ActiveRecord::Schema.define(version: 20150419134141) do t.datetime "updated_at" end - create_table "magics", force: true do |t| + create_table "magics", force: :cascade do |t| t.string "name", null: false t.string "type_of" t.text "manifestation" @@ -139,14 +139,14 @@ ActiveRecord::Schema.define(version: 20150419134141) do t.datetime "updated_at" end - create_table "sessions", force: true do |t| + create_table "sessions", force: :cascade do |t| t.string "username", null: false t.string "password", null: false t.datetime "created_at" t.datetime "updated_at" end - create_table "universes", force: true do |t| + create_table "universes", force: :cascade do |t| t.string "name", null: false t.text "description" t.text "history" @@ -158,13 +158,25 @@ ActiveRecord::Schema.define(version: 20150419134141) do t.datetime "updated_at" end - create_table "users", force: true do |t| - t.string "name", null: false - t.string "email", null: false + create_table "users", force: :cascade do |t| + t.string "name" + t.string "email", null: false t.string "old_password" t.datetime "created_at" t.datetime "updated_at" t.string "password_digest" + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.integer "sign_in_count", default: 0, null: false + t.datetime "current_sign_in_at" + t.datetime "last_sign_in_at" + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" end + add_index "users", ["email"], name: "index_users_on_email", unique: true + add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true + end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index d2995625..b5f056de 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -27,7 +27,7 @@ class UsersControllerTest < ActionController::TestCase email: 'tolkienjr@example.com' } end - assert_redirected_to homepage_path + assert_redirected_to root_url end test 'can create an anonymous account' do @@ -42,7 +42,7 @@ class UsersControllerTest < ActionController::TestCase password: 'Mellon', email: 'jrr@localhost' } - assert_redirected_to homepage_path + assert_redirected_to root_url assert_not_nil assigns(:user) assert_equal assigns(:user).email, 'jrr@localhost' end diff --git a/test/integration/character_stories_test.rb b/test/integration/character_stories_test.rb index 35afbbe6..d79ac729 100644 --- a/test/integration/character_stories_test.rb +++ b/test/integration/character_stories_test.rb @@ -15,7 +15,7 @@ class CharacterStoriesTest < ActionDispatch::IntegrationTest log_in_as_user visit character_list_path click_on 'Edit' - assert_equal character_edit_path(characters(:frodo)), current_path + assert_equal edit_character_path(characters(:frodo)), current_path end test 'view button shows character list' do @@ -29,6 +29,6 @@ class CharacterStoriesTest < ActionDispatch::IntegrationTest log_in_as_user visit character_path(characters(:frodo)) click_on 'Edit' - assert_equal character_edit_path(characters(:frodo)), current_path + assert_equal edit_character_path(characters(:frodo)), current_path end end diff --git a/test/test_helper.rb b/test/test_helper.rb index d3b9b276..0a00b361 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -39,7 +39,7 @@ module ActionDispatch include Capybara::DSL def register_as(name, email, password) - visit homepage_path + visit root_url click_on 'Register' fill_in 'user_name', with: name fill_in 'user_email', with: email @@ -48,7 +48,7 @@ module ActionDispatch end def log_in_as(user, password) - visit homepage_path + visit root_url click_on 'Login' within('#new_session') do fill_in 'session[username]', with: user @@ -64,7 +64,7 @@ module ActionDispatch end def log_in_as_anon - visit homepage_path + visit root_url click_on 'Login' click_on 'Be Anonymous' click_on 'I understand, create an account for me'