Skip to content

Commit

Permalink
Use Concern version of Serendipitous
Browse files Browse the repository at this point in the history
  • Loading branch information
Cantido committed Sep 24, 2016
1 parent 8e75458 commit 98bd3c0
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ gem 'rails-jquery-autocomplete'
gem 'meta-tags'

# Smarts
# gem 'serendipitous', :path => "~/Code/indent/serendipitous-gem"
gem 'serendipitous', git: 'git://github.com/indentlabs/serendipitous-gem.git'
# gem 'serendipitous', :path => "~/git/serendipitous-gem"
gem 'serendipitous', git: 'git://github.com/indentlabs/serendipitous-gem.git', branch: 'use-yml-files'

# Editor
gem 'medium-editor-rails'
Expand Down
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GIT
remote: git://github.com/indentlabs/serendipitous-gem.git
revision: 3e1808e873e00e1d59a918a5ac4306b22de3c5df
revision: 153eac3c12e5b4b009d497792add7f1afa00f39f
branch: use-yml-files
specs:
serendipitous (0.0.2)

Expand Down
16 changes: 3 additions & 13 deletions app/controllers/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ def index

@content = @content.where(universe: @universe_scope) if @universe_scope.present? && @content.build.respond_to?(:universe)
@content ||= []

begin
@questioned_content = @content.sample
questionable_params = content_param_list.reject { |x| x.is_a?(Hash) || x.to_s.end_with?('_id') }
@question = QuestionService.question(Content.new @questioned_content.slice(*questionable_params))
rescue
end
@questioned_content = @content.sample
@question = @questioned_content.question unless @questioned_content.nil?

respond_to do |format|
format.html # index.html.erb
Expand All @@ -29,13 +24,8 @@ def index
def show
# TODO: Secure this with content class whitelist lel
@content = content_type_from_controller(self.class).find(params[:id])
@question = @content.question

# question = QuestionService.question(Content.new @content.slice(*content_param_list.flat_map { |v| v.is_a?(Symbol) ? v : v.keys.map { |k| k.to_s.chomp('_attributes').to_sym } }))
begin
questionable_params = content_param_list.reject { |x| x.is_a?(Hash) || x.to_s.end_with?('_id') }
@question = QuestionService.question(Content.new @content.slice(*questionable_params))
rescue
end

respond_to do |format|
format.html # show.html.erb
Expand Down
1 change: 1 addition & 0 deletions app/models/character.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Character < ActiveRecord::Base

include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern

# Characters
relates :fathers, with: :fatherships
Expand Down
1 change: 1 addition & 0 deletions app/models/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Item < ActiveRecord::Base

include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern

# Characters
relates :original_owners, with: :original_ownerships
Expand Down
1 change: 1 addition & 0 deletions app/models/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Location < ActiveRecord::Base

include HasPrivacy
include HasContentGroupers
include Serendipitous::Concern

# Characters
relates :leaders, with: :location_leaderships
Expand Down
1 change: 1 addition & 0 deletions app/models/universe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# contains all canonically-related content created by Users
class Universe < ActiveRecord::Base
include HasPrivacy
include Serendipitous::Concern

validates :name, presence: true

Expand Down
94 changes: 94 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# UTF-8

# Localization file for English.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale
# for starting points.
Expand Down Expand Up @@ -33,8 +35,100 @@ en:
universe: Universe
user: User
attributes:
character:
eyecolor: eye color
facialhair: facial hair
fave_animal: favorite animal
fave_color: favorite color
fave_food: favorite food
fave_possession: favorite possession
fave_weapon: favorite weapon
haircolor: hair color
identmarks: identifying marks

location:
map: Map
serendipitous_questions:
attributes:
character:
age: How old is %{name}?
background: What is %{name}’s background?
birthday: When is %{name}’s birthday?
birthplace: Where was %{name} born?
bodytype: What is %{name}’s body type?
description: Describe %{name}.
education: What is %{name}’s level of education?
eyecolor: What is %{name}’s eye color?
facialhair: What facial hair does %{name} have?
fave_animal: What is %{name}’s favorite animal?
fave_color: What is %{name}’s favorite color?
fave_food: What is %{name}’s favorite food?
fave_possession: What is %{name}’s favorite possession?
fave_weapon: What is %{name}’s favorite weapon?
gender: What is %{name}’s gender?
haircolor: What color is %{name}’s hair?
hairstyle: How does %{name} style their hair?
height: How tall is %{name}?
identmarks: What identifying marks does %{name} have?
mannerisms: What mannerisms does %{name} have?
name: What is %{name}’s full name?
notes: Do you have any miscellaneous public notes for %{name}?
occupation: What is %{name}’s occupation?
pets: What pets does %{name} have?
politics: What politices does %{name} have?
prejudices: What prejudices does %{name} have?
private_notes: Do you have any private notes for %{name}?
race: What is %{name}’s race?
religion: What religion does %{name} practice?
role: What is %{name}’s role in your story?
skintone: What skin tone does %{name} name?
weight: How much does %{name} weigh?

item:
current_owner: Who currently owns %{name}?
description: Describe %{name}.
item_type: What type of item is %{name}?
made_by: Who made %{name}?
magic: What kind of magic does %{name} possess?
materials: What is %{name} made out of?
name: What is %{name}’s full name?
notes: Do you have any miscellaneous public notes for %{name}?
original_owner: Who originally owned %{name}?
private_notes: Do you have any private notes for %{name}?
weight: How much does %{name} weigh?
year_made: When was %{name} made?

location:
area: What kind of area is %{name} in?
capital: What is %{name}’s capital?
crops: What cropes does %{name} produce?
currency: What currencies are used in %{name}?
established_year: When was %{name} established?
language: What languages are spoken in %{name}?
largest_city: What is %{name}’s largest city?
located_at: Where is %{name} located?
motto: What is %{name}’s motto?
notable_cities: What notable cities are located in %{name}?
notable_wars: What notable wars has %{name} been involved in?
population: What is %{name}’s population?
type_of: What type of location is %{name}?

description: Describe %{name}.
name: What is %{name}’s full name?
notes: Do you have any miscellaneous public notes for %{name}?
private_notes: Do you have any private notes for %{name}?
universe:
history: What is %{name}’s history?
blacklist:
_:
- id
- user_id
- privacy
location:
- map_content_type
- map_file_name
- map_file_size
- map_updated_at

create_success: "%{model_name} was successfully created."
update_success: "%{model_name} was successfully updated."
Expand Down

0 comments on commit 98bd3c0

Please sign in to comment.