Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1c5bcc0
Link to forum preferences page from user preferences page
drusepth Jan 27, 2018
0fac1b2
onChange tweak on customization page
drusepth Jan 27, 2018
a0fda99
partial cleanup
drusepth Jan 27, 2018
d7c791b
remove redundant controller methods
drusepth Jan 27, 2018
32a062e
prep page create script
drusepth Jan 27, 2018
12e20d7
Clean up export and frame planet page type
drusepth Jan 27, 2018
ac38502
refactor exports
drusepth Jan 27, 2018
81c5544
Add Planet pre-configuring
drusepth Jan 27, 2018
07e586d
Add technology and deity
drusepth Jan 27, 2018
55e7b9b
Add government preconf
drusepth Jan 27, 2018
9060f37
Sort sidebar premium pages alphabetically
drusepth Jan 27, 2018
db02341
fix attributes creation
drusepth Jan 29, 2018
4f8d857
page type icons/colors
drusepth Jan 29, 2018
7ee02b2
deity categories + rename universe technologies field to technology
drusepth Jan 29, 2018
9ce169f
new page type categories
drusepth Jan 29, 2018
3b0d81a
fix a bug preventing some users from accessing the forums
drusepth Jan 29, 2018
b4a56ca
Page type copy
drusepth Jan 30, 2018
162e7c5
add planet relations
drusepth Jan 30, 2018
a174f2d
add technology relation models
drusepth Jan 30, 2018
f80df7f
add deity relation models
drusepth Jan 30, 2018
346f283
move content groupers
drusepth Jan 30, 2018
9f000bb
relates definitions
drusepth Jan 31, 2018
6969397
finalize planet relations
drusepth Jan 31, 2018
3b2c39f
verbiage change to clarify content linking
drusepth Jan 31, 2018
fdca8ba
hook up deity, gov, and technologies relations
drusepth Jan 31, 2018
963c942
new character relations
drusepth Jan 31, 2018
a4ec437
new relations on locations
drusepth Jan 31, 2018
b0035ff
add magic link to items
drusepth Jan 31, 2018
3ac5686
add requested relations
drusepth Jan 31, 2018
9befdaa
add classification to creatures
drusepth Jan 31, 2018
7865693
add material uses to flora
drusepth Jan 31, 2018
2c016ca
scope content dropdowns to the same universe, if present
drusepth Jan 31, 2018
a25d67a
context cards for everyone
drusepth Jan 31, 2018
c871095
add missing universe_id fields to new pages
drusepth Jan 31, 2018
8032835
cleanup
drusepth Feb 1, 2018
1b55a04
smart relations for planets/technology
drusepth Feb 1, 2018
e9ab0fe
update landing page for new types
drusepth Feb 2, 2018
cd2fc56
Merge branch 'master' into jan-release-1
drusepth Feb 2, 2018
f25db5b
order dashboard in the same way the sidenav is ordered
drusepth Feb 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added app/assets/images/card-headers/.DS_Store
Binary file not shown.
Binary file added app/assets/images/card-headers/deities.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/card-headers/governments.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/card-headers/planets.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/card-headers/technologies.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion app/controllers/characters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ def content_param_list
birthings_attributes: [:id, :birthplace_id, :_destroy],
childrenships_attributes: [:id, :child_id, :_destroy],
lingualisms_attributes: [:id, :spoken_language_id, :_destroy],
raceships_attributes: [:id, :race_id, :_destroy]
raceships_attributes: [:id, :race_id, :_destroy],
character_items_attributes: [:id, :item_id, :_destroy],
character_technologies_attributes: [:id, :technology_id, :_destroy],
character_floras_attributes: [:id, :flora_id, :_destroy],
character_friends_attributes: [:id, :friend_id, :_destroy],
character_companions_attributes: [:id, :companion_id, :_destroy],
character_birthtowns_attributes: [:id, :birthtown_id, :_destroy],
character_magics_attributes: [:id, :magic_id, :_destroy],
character_enemies_attributes: [:id, :enemy_id, :_destroy]
]
end
end
3 changes: 2 additions & 1 deletion app/controllers/countries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def content_param_list
country_religions_attributes: [:id, :religion_id, :_destroy],
country_landmarks_attributes: [:id, :landmark_id, :_destroy],
country_creatures_attributes: [:id, :creature_id, :_destroy],
country_floras_attributes: [:id, :flora_id, :_destroy]
country_floras_attributes: [:id, :flora_id, :_destroy],
country_governments_attributes: [:id, :government_id, :_destroy]
]
end
end
5 changes: 1 addition & 4 deletions app/controllers/creatures_controller.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
class CreaturesController < ContentController
private

def content_params
params.require(:creature).permit(content_param_list)
end

def content_param_list
%i(
name description type_of other_names universe_id color shape size notable_features
materials preferred_habitat sounds strengths weaknesses spoils aggressiveness
attack_method defense_method maximum_speed food_sources
migratory_patterns reproduction herd_patterns
similar_animals symbolisms privacy notes private_notes
phylum class_string order family genus species
) + [
custom_attribute_values: [:name, :value],
wildlifeships_attributes: [:id, :habitat_id, :_destroy],
Expand Down
27 changes: 27 additions & 0 deletions app/controllers/deities_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

class DeitiesController < ContentController
private

def content_param_list
[
:name, :description, :other_names, :physical_description, :height,
:weight, :symbols, :elements, :strengths, :weaknesses, :prayers, :rituals,
:human_interaction, :notable_events, :family_history, :life_story, :notes,
:private_notes, :privacy, :universe_id
] + [
deity_character_parents_attributes: [:id, :character_parent_id, :_destroy],
deity_character_partners_attributes: [:id, :character_partner_id, :_destroy],
deity_character_children_attributes: [:id, :character_child_id, :_destroy],
deity_deity_parents_attributes: [:id, :deity_parent_id, :_destroy],
deity_deity_partners_attributes: [:id, :deity_partner_id, :_destroy],
deity_deity_children_attributes: [:id, :deity_child_id, :_destroy],
deity_creatures_attributes: [:id, :creature_id, :_destroy],
deity_floras_attributes: [:id, :flora_id, :_destroy],
deity_religions_attributes: [:id, :religion_id, :_destroy],
deity_relics_attributes: [:id, :relic_id, :_destroy],
deity_abilities_attributes: [:id, :ability_id, :_destroy],
deity_related_towns_attributes: [:id, :related_town_id, :_destroy],
deity_related_landmarks_attributes: [:id, :related_landmark_id, :_destroy]
]
end
end
89 changes: 14 additions & 75 deletions app/controllers/export_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class ExportController < ApplicationController
before_action :authenticate_user!
before_action :whitelist_pluralized_model, only: [:csv]

def index
Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed export page', {
Expand All @@ -14,81 +15,9 @@ def report_to_mixpanel format, scope
}) if Rails.env.production?
end

# Formats

def universes_csv
report_to_mixpanel 'csv', 'universes'
send_data to_csv(current_user.universes), filename: "universes-#{Date.today}.csv"
end

def characters_csv
report_to_mixpanel 'csv', 'characters'
send_data to_csv(current_user.characters), filename: "characters-#{Date.today}.csv"
end

def locations_csv
report_to_mixpanel 'csv', 'locations'
send_data to_csv(current_user.locations), filename: "locations-#{Date.today}.csv"
end

def items_csv
report_to_mixpanel 'csv', 'items'
send_data to_csv(current_user.items), filename: "items-#{Date.today}.csv"
end

def creatures_csv
report_to_mixpanel 'csv', 'creatures'
send_data to_csv(current_user.creatures), filename: "creatures-#{Date.today}.csv"
end

def races_csv
report_to_mixpanel 'csv', 'races'
send_data to_csv(current_user.races), filename: "races-#{Date.today}.csv"
end

def floras_csv
report_to_mixpanel 'csv', 'flora'
send_data to_csv(current_user.floras), filename: "floras-#{Date.today}.csv"
end

def religions_csv
report_to_mixpanel 'csv', 'religions'
send_data to_csv(current_user.religions), filename: "religions-#{Date.today}.csv"
end

def magics_csv
report_to_mixpanel 'csv', 'magics'
send_data to_csv(current_user.magics), filename: "magics-#{Date.today}.csv"
end

def languages_csv
report_to_mixpanel 'csv', 'languages'
send_data to_csv(current_user.languages), filename: "languages-#{Date.today}.csv"
end

def groups_csv
report_to_mixpanel 'csv', 'groups'
send_data to_csv(current_user.groups), filename: "groups-#{Date.today}.csv"
end

def towns_csv
report_to_mixpanel 'csv', 'towns'
send_data to_csv(current_user.towns), filename: "towns-#{Date.today}.csv"
end

def landmarks_csv
report_to_mixpanel 'csv', 'landmarks'
send_data to_csv(current_user.landmarks), filename: "landmarks-#{Date.today}.csv"
end

def countries_csv
report_to_mixpanel 'csv', 'countries'
send_data to_csv(current_user.countries), filename: "countries-#{Date.today}.csv"
end

def scenes_csv
report_to_mixpanel 'csv', 'scenes'
send_data to_csv(current_user.scenes), filename: "scenes-#{Date.today}.csv"
def csv # params[:model] needed
report_to_mixpanel 'csv', @pluralized_model
send_data to_csv(current_user.send(@pluralized_model)), filename: "#{@pluralized_model}-#{Date.today}.csv"
end

def outline
Expand Down Expand Up @@ -119,6 +48,16 @@ def scrivener

private

def whitelist_pluralized_model
@pluralized_model = params[:model]
valid_models_to_export = Rails.application.config.content_types[:all].map { |p| p.name.downcase.pluralize }

unless valid_models_to_export.include?(@pluralized_model)
redirect_to root_path, notice: "You don't have permission to do that!"
return false
end
end

def to_csv ar_relation
ar_class = ar_relation.build.class
attribute_categories = ar_class.attribute_categories(current_user)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/floras_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def content_param_list
name description aliases universe_id
order family genus
colorings size smell taste
fruits seeds nuts berries medicinal_purposes
fruits seeds nuts berries medicinal_purposes material_uses
reproduction seasonality
privacy
notes private_notes
Expand Down
23 changes: 23 additions & 0 deletions app/controllers/governments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

class GovernmentsController < ContentController
private

def content_param_list
[
:name, :description, :type_of_government, :power_structure, :power_source,
:checks_and_balances, :sociopolitical, :socioeconomical, :geocultural,
:laws, :immigration, :privacy_ideologies, :electoral_process,
:term_lengths, :criminal_system, :approval_ratings, :military, :navy,
:airforce, :space_program, :international_relations, :civilian_life,
:founding_story, :flag_design_story, :notable_wars, :notes,
:private_notes, :privacy, :universe_id
] + [ #<relations>
government_leaders_attributes: [:id, :leader_id, :_destroy],
government_groups_attributes: [:id, :group_id, :_destroy],
government_political_figures_attributes: [:id, :political_figure_id, :_destroy],
government_items_attributes: [:id, :item_id, :_destroy],
government_technologies_attributes: [:id, :technology_id, :_destroy],
government_creatures_attributes: [:id, :creature_id, :_destroy]
]
end
end
1 change: 1 addition & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def content_param_list
officeships_attributes: [:id, :office_id, :_destroy],
group_equipmentships_attributes: [:id, :equipment_id, :_destroy],
key_itemships_attributes: [:id, :key_item_id, :_destroy],
group_creatures_attributes: [:id, :creature_id, :_destroy]
]
end
end
1 change: 1 addition & 0 deletions app/controllers/items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def content_param_list
current_ownerships_attributes: [:id, :current_owner_id, :_destroy],
past_ownerships_attributes: [:id, :past_owner_id, :_destroy],
maker_relationships_attributes: [:id, :maker_id, :_destroy],
item_magics_attributes: [:id, :magic_id, :_destroy],
]
end
end
6 changes: 5 additions & 1 deletion app/controllers/locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def content_param_list
capital_cities_relationships_attributes: [:id, :capital_city_id, :_destroy],
largest_cities_relationships_attributes: [:id, :largest_city_id, :_destroy],
notable_cities_relationships_attributes: [:id, :notable_city_id, :_destroy],
location_languageships_attributes: [:id, :language_id, :_destroy]
location_languageships_attributes: [:id, :language_id, :_destroy],
location_capital_towns_attributes: [:id, :capital_town_id, :_destroy],
location_largest_towns_attributes: [:id, :largest_town_id, :_destroy],
location_notable_towns_attributes: [:id, :notable_town_id, :_destroy],
location_landmarks_attributes: [:id, :landmark_id, :_destroy]
]
end
end
4 changes: 0 additions & 4 deletions app/controllers/magics_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
class MagicsController < ContentController
private

def content_params
params.require(:magic).permit(content_param_list)
end

def content_param_list
%i(
name description type_of universe_id visuals effects positive_effects
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/main_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def comingsoon
def dashboard
return redirect_to new_user_session_path unless user_signed_in?

@content_types = current_user.user_content_type_activators.pluck(:content_type)
@content_types = (
Rails.application.config.content_types[:all].map(&:name) & # Use config to dictate order
current_user.user_content_type_activators.pluck(:content_type)
)

ask_question
end
Expand Down
31 changes: 31 additions & 0 deletions app/controllers/planets_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

class PlanetsController < ContentController
private

def content_param_list
[
:name, :description, :size, :surface, :landmarks, :climate, :weather,
:water_content, :natural_resources, :length_of_day, :length_of_night,
:calendar_system, :population, :moons, :orbit, :visible_constellations,
:first_inhabitants_story, :world_history, :public_notes, :private_notes,
:privacy, :universe_id
] + [
#todo refactor all models to use:
# self.class.relates.map do |relation|
# #{with_relation}_attributes: [:id, :#{relates_relation.singularize}_id, :_destroy]
# end
planet_countries_attributes: [:id, :country_id, :_destroy],
planet_locations_attributes: [:id, :location_id, :_destroy],
planet_landmarks_attributes: [:id, :landmark_id, :_destroy],
planet_races_attributes: [:id, :race_id, :_destroy],
planet_floras_attributes: [:id, :flora_id, :_destroy],
planet_creatures_attributes: [:id, :creature_id, :_destroy],
planet_religions_attributes: [:id, :religion_id, :_destroy],
planet_deities_attributes: [:id, :deity_id, :_destroy],
planet_groups_attributes: [:id, :group_id, :_destroy],
planet_languages_attributes: [:id, :language_id, :_destroy],
planet_towns_attributes: [:id, :town_id, :_destroy],
planet_nearby_planets_attributes: [:id, :nearby_planet_id, :_destroy]
]
end
end
4 changes: 0 additions & 4 deletions app/controllers/races_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
class RacesController < ContentController
private

def content_params
params.require(:race).permit(content_param_list)
end

def content_param_list
%i(
name description other_names universe_id
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/religions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
class ReligionsController < ContentController
private

def content_params
params.require(:religion).permit(content_param_list)
end

def content_param_list
%i(
name description other_names universe_id
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/scenes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
class ScenesController < ContentController
private

def content_params
params.require(:scene).permit(content_param_list)
end

def content_param_list
%i(
name summary universe_id
Expand Down
24 changes: 24 additions & 0 deletions app/controllers/technologies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

class TechnologiesController < ContentController
private

def content_param_list
[
:name, :description, :other_names, :materials, :manufacturing_process,
:sales_process, :cost, :rarity, :purpose, :how_it_works, :resources_used,
:physical_description, :size, :weight, :colors, :notes, :private_notes,
:privacy, :universe_id
] + [ #<relations>
technology_characters_attributes: [:id, :character_id, :_destroy],
technology_towns_attributes: [:id, :town_id, :_destroy],
technology_countries_attributes: [:id, :country_id, :_destroy],
technology_groups_attributes: [:id, :group_id, :_destroy],
technology_creatures_attributes: [:id, :creature_id, :_destroy],
technology_planets_attributes: [:id, :planet_id, :_destroy],
technology_magics_attributes: [:id, :magic_id, :_destroy],
technology_parent_technologies_attributes: [:id, :parent_technology_id, :_destroy],
technology_child_technologies_attributes: [:id, :child_technology_id, :_destroy],
technology_related_technologies_attributes: [:id, :related_technology_id, :_destroy]
]
end
end
16 changes: 11 additions & 5 deletions app/controllers/universes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
class UniversesController < ContentController

# TODO: pull list of content types out from some centralized list somewhere
[
:characters, :locations, :items, :creatures, :races, :religions, :groups, :magics, :languages, :floras, :scenes
].each do |content_type_name|
Rails.application.config.content_types[:all_non_universe].each do |content_type|
content_type_name = content_type.name.downcase.pluralize.to_sym
define_method content_type_name do
@content_type = content_type_name.to_s.singularize.capitalize.constantize

@universe = Universe.find(params[:id])
@content_list = @universe.send(content_type_name).is_public.order(:name)
@content_list = @universe.send(content_type_name)

# todo just use current_user.can_view?(@universe) and/or individual filtering
unless user_signed_in? && (current_user == @universe.user || Contributor.exists?(user_id: current_user.id, universe_id: @universe.id))
@content_list = @content_list.is_public
end

@content_list = @content_list.order(:name)

render :content_list
end
Expand All @@ -24,7 +30,7 @@ def content_param_list
[
:user_id,
:name, :description, :genre,
:laws_of_physics, :magic_system, :technologies,
:laws_of_physics, :magic_system, :technology,
:history,
:privacy,
:notes, :private_notes,
Expand Down
Loading