diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 00000000..91600595 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +service_name: travis-ci diff --git a/.gitignore b/.gitignore index 88b29665..dc99db11 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ /log/*.log /tmp +# Ignore generated coverage folder +/coverage + # Ignore assets /public/assets diff --git a/.travis.yml b/.travis.yml index 4b3f0652..5d8bfaf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,6 @@ language: ruby -rvm: 2.0.0 -services: mongodb - -matrix: - include: - - rvm: 2.1.0 - gemfile: gemfiles/Gemfile.ruby-2.1.0 - allow_failures: - - rvm: 2.1.0 - gemfile: gemfiles/Gemfile.ruby-2.1.0 - +rvm: 2.1.1 +before_script: + - cp config/database.yml.travis config/database.yml + - psql -c 'create database travis_ci_test;' -U postgres \ No newline at end of file diff --git a/Gemfile b/Gemfile index afa2f701..d919e11f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,53 +1,21 @@ source 'https://rubygems.org' -ruby '2.0.0' -gem 'rails', '3.2.13' - -# Mongo stuff -gem 'bson_ext', '1.6.0' -gem 'mongo', '1.6.0' -gem 'mongoid' - -# File uploads -gem 'mongoid-paperclip', :require => "mongoid_paperclip" -gem 'aws-sdk', '~> 1.3.4' +gem 'rails', '4.1.0' +gem 'sqlite3' +gem 'paperclip', '~> 4.2.0' gem 'rmagick' +gem 'aws-sdk', '~> 1.50' +gem 'pg' -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'less-rails' - #gem 'less-rails-fontawesome' - gem 'coffee-rails', '~> 3.2.1' - - #gem 'bootplus-rails' - #gem 'twitter-bootstrap-rails' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', '~> 0.12.1', :platform => :ruby - - gem 'uglifier', '>= 1.0.3' -end - -group :test do - gem 'factory_girl_rails' - gem 'database_cleaner' -end - +gem 'sass-rails', '~> 4.0.3' +gem 'less-rails' +gem 'less-rails-fontawesome' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'therubyracer', platforms: :ruby +gem 'bootplus-rails' gem 'jquery-rails' -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# To use Jbuilder templates for JSON -# gem 'jbuilder' - -# Use unicorn as the app server -# gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' +gem 'capybara' +gem 'selenium-webdriver' +gem 'coveralls', require: false diff --git a/Gemfile.lock b/Gemfile.lock index cecf9b7f..374fee39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,70 +1,71 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.13) - actionpack (= 3.2.13) - mail (~> 2.5.3) - actionpack (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - builder (~> 3.0.0) + actionmailer (4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + mail (~> 2.5.4) + actionpack (4.1.0) + actionview (= 4.1.0) + activesupport (= 4.1.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + actionview (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.5) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.13) - activesupport (= 3.2.13) - builder (~> 3.0.0) - activerecord (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.13) - activemodel (= 3.2.13) - activesupport (= 3.2.13) - activesupport (3.2.13) - i18n (= 0.6.1) - multi_json (~> 1.0) - arel (3.0.3) - aws-sdk (1.3.9) - httparty (~> 0.7) + activemodel (4.1.0) + activesupport (= 4.1.0) + builder (~> 3.1) + activerecord (4.1.0) + activemodel (= 4.1.0) + activesupport (= 4.1.0) + arel (~> 5.0.0) + activesupport (4.1.0) + i18n (~> 0.6, >= 0.6.9) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) + thread_safe (~> 0.1) + tzinfo (~> 1.1) + arel (5.0.1.20140414130214) + aws-sdk (1.50.0) json (~> 1.4) nokogiri (>= 1.4.4) - uuidtools (~> 2.1) - bson (1.6.0) - bson_ext (1.6.0) - bson (= 1.6.0) - builder (3.0.4) + bootplus-rails (1.0.0) + builder (3.2.2) + capybara (2.4.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + childprocess (0.5.3) + ffi (~> 1.0, >= 1.0.11) climate_control (0.0.3) activesupport (>= 3.0) - cocaine (0.5.3) + cocaine (0.5.4) climate_control (>= 0.0.3, < 1.0) - coffee-rails (3.2.2) + coffee-rails (4.0.1) coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) + railties (>= 4.0.0, < 5.0) + coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.6.3) + coffee-script-source (1.7.1) commonjs (0.2.7) - database_cleaner (1.2.0) + coveralls (0.7.1) + multi_json (~> 1.3) + rest-client + simplecov (>= 0.7) + term-ansicolor + thor + docile (1.1.5) erubis (2.7.0) - execjs (2.0.2) - factory_girl (4.4.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.4.1) - factory_girl (~> 4.4.0) - railties (>= 3.0.0) + execjs (2.2.1) + ffi (1.9.3) hike (1.2.3) - httparty (0.13.0) - json (~> 1.8) - multi_xml (>= 0.5.2) - i18n (0.6.1) - journey (1.0.4) - jquery-rails (3.1.0) + i18n (0.6.11) + jquery-rails (3.1.1) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.8.1) @@ -73,103 +74,116 @@ GEM less-rails (2.4.2) actionpack (>= 3.1) less (~> 2.4.0) + less-rails-fontawesome (0.8.0) + less-rails (~> 2.4.2) libv8 (3.16.14.3) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) - mini_portile (0.5.2) - mongo (1.6.0) - bson (= 1.6.0) - mongoid (3.1.6) - activemodel (~> 3.2) - moped (~> 1.4) - origin (~> 1.0) - tzinfo (~> 0.3.29) - mongoid-paperclip (0.0.9) - paperclip (>= 2.3.6) - moped (1.5.2) - multi_json (1.9.0) - multi_xml (0.5.5) - nokogiri (1.6.1) - mini_portile (~> 0.5.0) - nokogiri (1.6.1-x86-mingw32) - mini_portile (~> 0.5.0) - origin (1.1.0) - paperclip (4.1.1) + mini_portile (0.6.0) + minitest (5.4.0) + multi_json (1.10.1) + netrc (0.8.0) + nokogiri (1.6.3.1) + mini_portile (= 0.6.0) + paperclip (4.2.0) activemodel (>= 3.0.0) activesupport (>= 3.0.0) cocaine (~> 0.5.3) mime-types - polyglot (0.3.4) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.3) - rack + pg (0.17.1) + polyglot (0.3.5) + rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (3.2.13) - actionmailer (= 3.2.13) - actionpack (= 3.2.13) - activerecord (= 3.2.13) - activeresource (= 3.2.13) - activesupport (= 3.2.13) - bundler (~> 1.0) - railties (= 3.2.13) - railties (3.2.13) - actionpack (= 3.2.13) - activesupport (= 3.2.13) - rack-ssl (~> 1.3.2) + rails (4.1.0) + actionmailer (= 4.1.0) + actionpack (= 4.1.0) + actionview (= 4.1.0) + activemodel (= 4.1.0) + activerecord (= 4.1.0) + activesupport (= 4.1.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.1.0) + sprockets-rails (~> 2.0) + railties (4.1.0) + actionpack (= 4.1.0) + activesupport (= 4.1.0) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.1.1) - rdoc (3.12.2) - json (~> 1.4) + thor (>= 0.18.1, < 2.0) + rake (10.3.2) ref (1.0.5) + rest-client (1.7.2) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) rmagick (2.13.2) - sass (3.3.3) - sass-rails (3.2.6) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - sprockets (2.2.2) + rubyzip (1.1.6) + sass (3.2.19) + sass-rails (4.0.3) + railties (>= 4.0.0, < 5.0) + sass (~> 3.2.0) + sprockets (~> 2.8, <= 2.11.0) + sprockets-rails (~> 2.0) + selenium-webdriver (2.42.0) + childprocess (>= 0.5.0) + multi_json (~> 1.0) + rubyzip (~> 1.0) + websocket (~> 1.0.4) + simplecov (0.9.1) + docile (~> 1.1.0) + multi_json (~> 1.0) + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + sprockets (2.11.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) + sprockets-rails (2.1.3) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + sqlite3 (1.3.9) + term-ansicolor (1.3.0) + tins (~> 1.0) therubyracer (0.12.1) libv8 (~> 3.16.14.0) ref - thor (0.18.1) + thor (0.19.1) + thread_safe (0.3.4) tilt (1.4.1) + tins (1.3.3) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.39) - uglifier (2.5.0) + tzinfo (1.2.1) + thread_safe (~> 0.1) + uglifier (2.5.1) execjs (>= 0.3.0) json (>= 1.8.0) - uuidtools (2.1.4) + websocket (1.0.7) + xpath (2.0.0) + nokogiri (~> 1.3) PLATFORMS ruby - x86-mingw32 DEPENDENCIES - aws-sdk (~> 1.3.4) - bson_ext (= 1.6.0) - coffee-rails (~> 3.2.1) - database_cleaner - factory_girl_rails + aws-sdk (~> 1.50) + bootplus-rails + capybara + coffee-rails (~> 4.0.0) + coveralls jquery-rails less-rails - mongo (= 1.6.0) - mongoid - mongoid-paperclip - rails (= 3.2.13) + less-rails-fontawesome + paperclip (~> 4.2.0) + pg + rails (= 4.1.0) rmagick - sass-rails (~> 3.2.3) - therubyracer (~> 0.12.1) - uglifier (>= 1.0.3) + sass-rails (~> 4.0.3) + selenium-webdriver + sqlite3 + therubyracer + uglifier (>= 1.3.0) diff --git a/README.rdoc b/README.rdoc index cf3a5d6e..5a5834b4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -41,26 +41,16 @@ Install rvm source ~/.rvm/scripts/rvm -Install ruby 2.0.0 +Install ruby 2.1.2 - rvm install ruby 2.0.0 + rvm install ruby 2.1.2 - rvm use 2.0.0 + rvm use 2.1.2 Install rails 4.0.1 gem install rails -v 4.0.1 -Install mongodb - - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 - - echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list - - sudo apt-get update - - sudo apt-get install mongodb-10gen - Install necessary libraries sudo apt-get install imagemagick libmagickwand-dev diff --git a/Rakefile b/Rakefile index 659f1981..ba6b733d 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,6 @@ -#!/usr/bin/env rake # 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__) -PlanCharacters::Application.load_tasks +Rails.application.load_tasks diff --git a/app/models/.gitkeep b/app/assets/images/.keep similarity index 100% rename from app/models/.gitkeep rename to app/assets/images/.keep diff --git a/app/assets/javascripts/languages.js.coffee b/app/assets/javascripts/languages.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/languages.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/languages.css.scss b/app/assets/stylesheets/languages.css.scss new file mode 100644 index 00000000..32d25fab --- /dev/null +++ b/app/assets/stylesheets/languages.css.scss @@ -0,0 +1,3 @@ +// 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/controllers/characters_controller.rb b/app/controllers/characters_controller.rb index 256c70a5..9504d547 100644 --- a/app/controllers/characters_controller.rb +++ b/app/controllers/characters_controller.rb @@ -56,7 +56,7 @@ class CharactersController < ApplicationController # POST /characters # POST /characters.json def create - @character = Character.new(params[:character]) + @character = Character.create(character_params) @character.user_id = session[:user] @character.universe = Universe.where(user_id: session[:user]).where(name: params[:character][:universe].strip).first @@ -83,7 +83,7 @@ class CharactersController < ApplicationController end respond_to do |format| - if @character.update_attributes(params[:character]) + if @character.update_attributes(character_params) format.html { redirect_to @character, notice: 'Character was successfully updated.' } format.json { head :no_content } else @@ -96,12 +96,25 @@ class CharactersController < ApplicationController # DELETE /characters/1 # DELETE /characters/1.json def destroy - @character = Character.find(params[:id]) - @character.destroy + Character.find(params[:id]).delete respond_to do |format| format.html { redirect_to character_list_url } format.json { head :no_content } end end + + private + def character_params + params.require(:character).permit( + :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) + end end diff --git a/lib/assets/.gitkeep b/app/controllers/concerns/.keep similarity index 100% rename from lib/assets/.gitkeep rename to app/controllers/concerns/.keep diff --git a/app/controllers/equipment_controller.rb b/app/controllers/equipment_controller.rb index 05b9028e..4aa300d6 100644 --- a/app/controllers/equipment_controller.rb +++ b/app/controllers/equipment_controller.rb @@ -41,7 +41,7 @@ class EquipmentController < ApplicationController end def create - @equipment = Equipment.new(params[:equipment]) + @equipment = Equipment.create(equipment_params) @equipment.user_id = session[:user] @equipment.universe = Universe.where(user_id: session[:user]).where(name: params[:equipment][:universe].strip).first @@ -66,7 +66,7 @@ class EquipmentController < ApplicationController end respond_to do |format| - if @equipment.update_attributes(params[:equipment]) + if @equipment.update_attributes(equipment_params) format.html { redirect_to @equipment, notice: 'Equipment was successfully updated.' } format.json { head :no_content } else @@ -85,4 +85,15 @@ class EquipmentController < ApplicationController format.json { head :no_content } end end + + private + def equipment_params + params.require(:equipment).permit( + :universe_id, :user_id, + :name, :equip_type, + :description, :weight, + :original_owner, :current_owner, :made_by, :materials, :year_made, + :magic, + :notes, :private_notes) + end end diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index 92bc1e6f..01a1df51 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -41,7 +41,7 @@ class LanguagesController < ApplicationController end def create - @language = Language.new(params[:language]) + @language = Language.new(language_params) @language.user_id = session[:user] @language.universe = Universe.where(user_id: session[:user]).where(name: params[:language][:universe].strip).first @@ -65,7 +65,7 @@ class LanguagesController < ApplicationController end respond_to do |format| - if @language.update_attributes(params[:language]) + if @language.update_attributes(language_params) format.html { redirect_to @language, notice: 'Language was successfully updated.' } format.json { head :no_content } else @@ -84,4 +84,16 @@ class LanguagesController < ApplicationController format.json { head :no_content } end end + + private + def language_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 5a3896bc..1ccfdae3 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -41,7 +41,7 @@ class LocationsController < ApplicationController end def create - @location = Location.new(params[:location]) + @location = Location.new(location_params) @location.user_id = session[:user] @location.universe = Universe.where(user_id: session[:user]).where(name: params[:location][:universe].strip).first @@ -80,7 +80,7 @@ class LocationsController < ApplicationController respond_to do |format| begin - if @location.update_attributes(params[:location]) + if @location.update_attributes(location_params) format.html { redirect_to @location, notice: 'Location was successfully updated.' } format.json { head :no_content } else @@ -105,4 +105,17 @@ class LocationsController < ApplicationController format.json { head :no_content } end end + + private + def location_params + params.require(:location).permit( + :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) + end end diff --git a/app/controllers/magic_controller.rb b/app/controllers/magic_controller.rb index e7b862b4..c0c22f6b 100644 --- a/app/controllers/magic_controller.rb +++ b/app/controllers/magic_controller.rb @@ -41,7 +41,7 @@ class MagicController < ApplicationController end def create - @magic = Magic.new(params[:magic]) + @magic = Magic.new(magic_params) @magic.user_id = session[:user] @magic.universe = Universe.where(user_id: session[:user]).where(name: params[:magic][:universe].strip).first @@ -66,7 +66,7 @@ class MagicController < ApplicationController end respond_to do |format| - if @magic.update_attributes(params[:magic]) + if @magic.update_attributes(magic_params) format.html { redirect_to @magic, notice: 'Magic was successfully updated.' } format.json { head :no_content } else @@ -85,4 +85,16 @@ class MagicController < ApplicationController format.json { head :no_content } end end + + private + def magic_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/sessions_controller.rb b/app/controllers/sessions_controller.rb index 329657ec..ceaa05fb 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -14,8 +14,7 @@ class SessionsController < ApplicationController # POST /sessions.json def create require 'digest' - login = Session.new(params[:session]) - + login = Session.new(session_params) hash = Digest::MD5.hexdigest(login.username + "'s password IS... " + login.password + " (lol!)") user = User.where(name: login.username, password: hash) if user.length < 1 @@ -36,10 +35,16 @@ class SessionsController < ApplicationController # GET /logout def destroy session.delete(:user) + session.delete(:anon_user) respond_to do |format| format.html { redirect_to homepage_path, notice: 'Logged out!' } format.json { head :no_content } end end + + private + 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 da3b6226..8e6b4934 100644 --- a/app/controllers/universes_controller.rb +++ b/app/controllers/universes_controller.rb @@ -41,7 +41,7 @@ class UniversesController < ApplicationController end def create - @universe = Universe.new(params[:universe]) + @universe = Universe.new(universe_params) @universe.user_id = session[:user] respond_to do |format| @@ -59,7 +59,7 @@ class UniversesController < ApplicationController @universe = Universe.find(params[:id]) respond_to do |format| - if @universe.update_attributes(params[:universe]) + if @universe.update_attributes(universe_params) format.html { redirect_to @universe, notice: 'Universe was successfully updated.' } format.json { head :no_content } else @@ -78,4 +78,14 @@ class UniversesController < ApplicationController format.json { head :no_content } end end + + private + def universe_params + params.require(:universe).permit( + :user_id, + :name, :description, + :history, + :privacy, + :notes, :private_notes) + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 987f5ec2..1824d5dd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -20,10 +20,10 @@ class UsersController < ApplicationController # POST /users # POST /users.json def create - @user = User.new(params[:user]) + @user = User.new(user_params) respond_to do |format| if @user.save - session[:user] = @user.id + session[:user] = @user.id format.html { redirect_to homepage_path, notice: 'User was successfully created.' } format.json { render json: @user, status: :created } else @@ -57,7 +57,7 @@ class UsersController < ApplicationController @user = User.find(session[:user]) respond_to do |format| - if @user.update_attributes(params[:user]) + if @user.update_attributes(user_params) session[:anon_user] = false format.html { redirect_to homepage_path, notice: 'Successfully updated.' } format.json { head :no_content } @@ -70,4 +70,9 @@ class UsersController < ApplicationController def anonymous end + + private + def user_params + params.require(:user).permit(:name, :password, :email) + end end diff --git a/app/helpers/equipment_helper.rb b/app/helpers/equipment_helper.rb new file mode 100644 index 00000000..b3ce05f9 --- /dev/null +++ b/app/helpers/equipment_helper.rb @@ -0,0 +1,2 @@ +module EquipmentHelper +end diff --git a/app/helpers/languages_helper.rb b/app/helpers/languages_helper.rb new file mode 100644 index 00000000..24686681 --- /dev/null +++ b/app/helpers/languages_helper.rb @@ -0,0 +1,2 @@ +module LanguagesHelper +end diff --git a/log/.gitkeep b/app/mailers/.keep similarity index 100% rename from log/.gitkeep rename to app/mailers/.keep diff --git a/test/functional/.gitkeep b/app/models/.keep similarity index 100% rename from test/functional/.gitkeep rename to app/models/.keep diff --git a/app/models/character.rb b/app/models/character.rb index 69ed96aa..6c8b52ea 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -1,71 +1,6 @@ -class Character - include Mongoid::Document - - # General - field :name, :type => String - field :role, :type => String - field :gender, :type => String - field :age, :type => String - - # Appearance - field :height, :type => String - field :weight, :type => String - field :haircolor, :type => String - field :hairstyle, :type => String - field :facialhair, :type => String - field :eyecolor, :type => String - field :race, :type => String - field :skintone, :type => String - field :bodytype, :type => String - field :identmarks, :type => String # Identifying marks - - # Social - field :bestfriend, :type => String - field :religion, :type => String - field :politics, :type => String - field :prejudices, :type => String - field :occupation, :type => String - field :pets, :type => String - #How might others describe him? - #What would others change about him? +class Character < ActiveRecord::Base + #validates_presence_of :name - # Behavior - field :mannerisms, :type => String - #What drives this character? - #What is standing in his way? - #What is he most afraid of? - #What does he need most? - #What makes him vulnerable? - #What kind of trouble does he get in? - - # History - field :birthday, :type => String - field :birthplace, :type => String - field :education, :type => String - field :background, :type => String - #What is his deepest secret? - #Does he have a history of criminal activity? - - # Favorites - field :fave_color, :type => String - field :fave_food, :type => String - field :fave_possession, :type => String - field :fave_weapon, :type => String - field :fave_animal, :type => String - #favorite leisure activities - - # Relationships - field :father, :type => String - field :mother, :type => String - field :spouse, :type => String - field :siblings, :type => String - field :archenemy, :type => String - - # Notes - field :notes, :type => String - field :private_notes, :type => String - #additional fields - belongs_to :user belongs_to :universe end diff --git a/test/integration/.gitkeep b/app/models/concerns/.keep similarity index 100% rename from test/integration/.gitkeep rename to app/models/concerns/.keep diff --git a/app/models/equipment.rb b/app/models/equipment.rb index f503869c..6edf1509 100644 --- a/app/models/equipment.rb +++ b/app/models/equipment.rb @@ -1,28 +1,6 @@ -class Equipment - include Mongoid::Document +class Equipment < ActiveRecord::Base + #validates_presence_of :name - # General - field :name, :type => String - field :equip_type, :type => String - - # Appearance - field :description, :type => String - field :weight, :type => String - - # History - field :original_owner, :type => String - field :current_owner, :type => String - field :made_by, :type => String - field :materials, :type => String - field :year_made, :type => String - - # Abilities - field :magic, :type => String # Magical Properties - - # Notes - field :notes, :type => String - field :private_notes, :type => String - belongs_to :user belongs_to :universe end diff --git a/app/models/language.rb b/app/models/language.rb index 447df506..e95dbcf4 100644 --- a/app/models/language.rb +++ b/app/models/language.rb @@ -1,23 +1,6 @@ -class Language - include Mongoid::Document +class Language < ActiveRecord::Base + #validates_presence_of :name - # General - field :name, :type => String - - # Vocabulary - field :words, :type => String - - # History - field :established_year, :type => String - field :established_location, :type => String - - # Speakers - field :characters, :type => String - field :locations, :type => String - - # More - field :notes, :type => String - belongs_to :user belongs_to :universe end diff --git a/app/models/location.rb b/app/models/location.rb index 34ab75da..1506f04c 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,50 +1,8 @@ -class Location - include Mongoid::Document - include Mongoid::Paperclip +class Location < ActiveRecord::Base + has_attached_file :map, :styles => { :original => "1920x1080>", :thumb => "200x200>" } + validates_attachment_content_type :map, :content_type => /\Aimage\/.*\Z/ + validates_presence_of :name - # General - field :name, :type => String - field :type_of, :type => String - field :description, :type => String - - # Map - has_mongoid_attached_file :map, - styles: { -# original: '1920x1680>', -# thumb: '200x200>', -# todo -# make banner for cards -# resize full-size for large-cards -# make thumbnail for small-cards - }, - default_url: '/assets/placeholders/map.png' - - # Culture - field :population, :type => String - field :language, :type => String - field :currency, :type => String - field :motto, :type => String - #field :flag, :type => Image - #field :seal, :type => Image - - # Cities - field :capital, :type => String - field :largest_city, :type => String - field :notable_cities, :type => String - - # Geography - field :area, :type => String - field :crops, :type => String - field :located_at, :type => String - - # History - field :established_year, :type => String - field :notable_wars, :type => String - - # Notes - field :notes, :type => String - field :private_notes, :type => String - belongs_to :user belongs_to :universe end diff --git a/app/models/magic.rb b/app/models/magic.rb index e7ae7a56..f15d59b8 100644 --- a/app/models/magic.rb +++ b/app/models/magic.rb @@ -1,32 +1,6 @@ -class Magic - include Mongoid::Document +class Magic < ActiveRecord::Base + #validates_presence_of :name - # General - field :name, :type => String - field :type_of, :type => String # "Type of": Spell, Ability, Enchantment, etc - - # Appearance - field :manifestation, :type => String - field :symptoms, :type => String - - # Alignment - field :element, :type => String - field :diety, :type => String - - # Effects - field :harmfulness, :type => String # Harmful effects - field :helpfulness, :type => String # Helpful effects - field :neutralness, :type => String # Neutral effects - - # Requirements - field :resource, :type => String # Resource required - field :skill_level, :type => String # Skill required - field :limitations, :type => String - - # Notes - field :notes, :type => String - field :private_notes, :type => String - belongs_to :user belongs_to :universe end diff --git a/app/models/session.rb b/app/models/session.rb index 2cf4aaf2..619022a7 100644 --- a/app/models/session.rb +++ b/app/models/session.rb @@ -1,7 +1,3 @@ -class Session - include Mongoid::Document - field :username, :type => String - field :password, :type => String - +class Session < ActiveRecord::Base validates_presence_of :username, :password end diff --git a/app/models/universe.rb b/app/models/universe.rb index 7c914e20..ce1459ca 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -1,22 +1,13 @@ -class Universe - include Mongoid::Document - - # General - field :name, :type => String - field :description, :type => String +class Universe < ActiveRecord::Base + #validates_presence_of :name - # History - field :history, :type => String - - # More... - field :notes, :type => String - field :private_notes, :type => String - - # Settings - field :privacy, :type => String # Whether or not this universe is public, options are 'private' or 'public' - belongs_to :user - + has_many :characters + has_many :equipment + has_many :languages + has_many :locations + has_many :magics + def content_count [ characters.length, @@ -26,30 +17,4 @@ class Universe magics.length, ].sum end - - def characters - Character.where(universe_id: id) - end - - def equipment - Equipment.where(universe_id: id) - end - - def languages - Language.where(universe_id: id) - end - - def locations - Location.where(universe_id: id) - end - - def magics - Magic.where(universe_id: id) - end - - - def to_s - self.name - end - end diff --git a/app/models/user.rb b/app/models/user.rb index 57842360..edb31440 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,18 +1,20 @@ -class User - include Mongoid::Document - field :name, :type => String - field :email, :type => String - field :password, :type => String - - validates_presence_of :name, :email, :password - validates_uniqueness_of :name, :email +class User < ActiveRecord::Base + validates_presence_of :name, :password, :email before_save :hash_password + + has_many :characters + has_many :equipment + has_many :languages + has_many :locations + has_many :magics + has_many :universes + def hash_password require 'digest' self.password = Digest::MD5.hexdigest(self.name + "'s password IS... " + self.password + " (lol!)") end - + def content { :characters => characters, @@ -23,7 +25,7 @@ class User :universes => universes } end - + def content_count [ characters.length, @@ -34,29 +36,4 @@ class User universes.length ].sum end - - def characters - Character.where(user_id: id) - end - - def equipment - Equipment.where(user_id: id) - end - - def languages - Language.where(user_id: id) - end - - def locations - Location.where(user_id: id) - end - - def magics - Magic.where(user_id: id) - end - - def universes - Universe.where(user_id: id) - end - end diff --git a/app/views/characters/_list.html.erb b/app/views/characters/_list.html.erb index e859adca..7a3e27b8 100644 --- a/app/views/characters/_list.html.erb +++ b/app/views/characters/_list.html.erb @@ -7,7 +7,7 @@
- <% if character.role.length > 0 %> + <% if character.role.present? %> <%= character.role %><% if character.age.length > 0 %>, <%= character.age %><% end %> <% end %> diff --git a/app/views/layouts/_session_protection.html.erb b/app/views/layouts/_session_protection.html.erb index d962cd88..c06a1175 100644 --- a/app/views/layouts/_session_protection.html.erb +++ b/app/views/layouts/_session_protection.html.erb @@ -2,7 +2,7 @@ # Destroy old sessions if a user has been deleted begin User.find(session[:user]) if session[:user] - rescue Mongoid::Errors::DocumentNotFound + rescue ActiveRecord::RecordNotFound session = {} %>