From 98bd3c0356eece5ff85acc56ebd6ec79c315a841 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sat, 24 Sep 2016 18:40:29 -0500 Subject: [PATCH 1/5] Use Concern version of Serendipitous --- Gemfile | 4 +- Gemfile.lock | 3 +- app/controllers/content_controller.rb | 16 +---- app/models/character.rb | 1 + app/models/item.rb | 1 + app/models/location.rb | 1 + app/models/universe.rb | 1 + config/locales/en.yml | 94 +++++++++++++++++++++++++++ 8 files changed, 105 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index ebd700ce..be32335a 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 83886477..8ade4fa3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 0928fcba..56f0ef5b 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -12,13 +12,8 @@ class ContentController < ApplicationController @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 @@ -29,13 +24,8 @@ class ContentController < ApplicationController 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 diff --git a/app/models/character.rb b/app/models/character.rb index b30dfc97..135a3740 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -16,6 +16,7 @@ class Character < ActiveRecord::Base include HasPrivacy include HasContentGroupers + include Serendipitous::Concern # Characters relates :fathers, with: :fatherships diff --git a/app/models/item.rb b/app/models/item.rb index f194b02a..0f93960e 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -14,6 +14,7 @@ class Item < ActiveRecord::Base include HasPrivacy include HasContentGroupers + include Serendipitous::Concern # Characters relates :original_owners, with: :original_ownerships diff --git a/app/models/location.rb b/app/models/location.rb index 518e7e80..e3908c5f 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -17,6 +17,7 @@ class Location < ActiveRecord::Base include HasPrivacy include HasContentGroupers + include Serendipitous::Concern # Characters relates :leaders, with: :location_leaderships diff --git a/app/models/universe.rb b/app/models/universe.rb index 009c6305..7968b4ec 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 1301a362..1cb4ef23 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,3 +1,5 @@ +# UTF-8 + # Localization file for English. # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale # for starting points. @@ -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." From d82b0a228270d2b11990809ec4905e0c33ba5bfa Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Sun, 25 Sep 2016 19:40:05 -0500 Subject: [PATCH 2/5] Update git version of Serendipitous --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ade4fa3..5ee98dd8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/indentlabs/serendipitous-gem.git - revision: 153eac3c12e5b4b009d497792add7f1afa00f39f + revision: 462bc7538bf7201cf69e3f508772fe55a80b9873 branch: use-yml-files specs: serendipitous (0.0.2) From 4ee0d5f008159c8b043f58307d8e354bf65104a3 Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Thu, 29 Sep 2016 20:06:41 -0500 Subject: [PATCH 3/5] Merge master --- Gemfile | 4 ++ Gemfile.lock | 9 +++- app/assets/javascripts/admin.js.coffee | 3 ++ app/assets/javascripts/application.js | 2 + app/assets/stylesheets/admin.css.scss | 13 +++++ app/controllers/admin_controller.rb | 18 +++++++ app/controllers/content_controller.rb | 2 +- app/controllers/main_controller.rb | 2 +- app/helpers/admin_helper.rb | 2 + app/models/user.rb | 6 --- app/views/admin/characters.html.erb | 52 +++++++++++++++++++ app/views/admin/dashboard.html.erb | 25 +++++++++ app/views/admin/items.html.erb | 48 +++++++++++++++++ app/views/admin/locations.html.erb | 48 +++++++++++++++++ app/views/admin/universes.html.erb | 32 ++++++++++++ .../serendipitous/_content_question.html.erb | 4 +- .../cards/_in_universe_content_list.html.erb | 4 -- app/views/layouts/admin.html.erb | 32 ++++++++++++ app/views/main/dashboard.html.erb | 16 ------ config/routes.rb | 8 +++ test/controllers/admin_controller_test.rb | 29 +++++++++++ 21 files changed, 328 insertions(+), 31 deletions(-) create mode 100644 app/assets/javascripts/admin.js.coffee create mode 100644 app/assets/stylesheets/admin.css.scss create mode 100644 app/controllers/admin_controller.rb create mode 100644 app/helpers/admin_helper.rb create mode 100644 app/views/admin/characters.html.erb create mode 100644 app/views/admin/dashboard.html.erb create mode 100644 app/views/admin/items.html.erb create mode 100644 app/views/admin/locations.html.erb create mode 100644 app/views/admin/universes.html.erb create mode 100644 app/views/layouts/admin.html.erb create mode 100644 test/controllers/admin_controller_test.rb diff --git a/Gemfile b/Gemfile index be32335a..587b032d 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem 'material_icons' # Quality of Life gem 'cocoon' +gem 'dateslices' # Javascript gem 'coffee-rails' @@ -36,6 +37,9 @@ gem 'serendipitous', git: 'git://github.com/indentlabs/serendipitous-gem.git', b # Editor gem 'medium-editor-rails' +# Graphs & Charts +gem 'chartkick' + group :production do # gem 'less-rails' # gem 'less-rails-fontawesome' diff --git a/Gemfile.lock b/Gemfile.lock index 5ee98dd8..5c080cdd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/indentlabs/serendipitous-gem.git - revision: 462bc7538bf7201cf69e3f508772fe55a80b9873 + revision: d650852664d1bf021d6c9dc97e338624f59abc53 branch: use-yml-files specs: serendipitous (0.0.2) @@ -66,6 +66,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + chartkick (2.1.1) childprocess (0.5.9) ffi (~> 1.0, >= 1.0.11) climate_control (0.0.3) @@ -105,6 +106,8 @@ GEM railties (>= 3, < 5) cucumber-wire (0.0.1) database_cleaner (1.5.3) + dateslices (0.0.4) + rails (> 4) debug_inspector (0.0.2) devise (3.5.6) bcrypt (~> 3.0) @@ -306,11 +309,13 @@ DEPENDENCIES better_errors binding_of_caller capybara + chartkick cocoon coffee-rails coveralls cucumber-rails database_cleaner + dateslices devise factory_girl_rails guard @@ -341,4 +346,4 @@ DEPENDENCIES uglifier (>= 1.3.0) BUNDLED WITH - 1.12.5 + 1.13.1 diff --git a/app/assets/javascripts/admin.js.coffee b/app/assets/javascripts/admin.js.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/admin.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/javascripts/application.js b/app/assets/javascripts/application.js index 7445094a..67375cc4 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,4 +17,6 @@ //= require autocomplete-rails //= require cocoon //= require medium-editor +//= require Chart.bundle +//= require chartkick //= require_tree . diff --git a/app/assets/stylesheets/admin.css.scss b/app/assets/stylesheets/admin.css.scss new file mode 100644 index 00000000..33acc8e0 --- /dev/null +++ b/app/assets/stylesheets/admin.css.scss @@ -0,0 +1,13 @@ +h1, h2, h3 { text-align: center; } + +.admin-nav { + margin-left: 10px; + + li { + display: inline; + a { + border: 1px solid #222; + padding: 10px; + } + } +} \ No newline at end of file diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb new file mode 100644 index 00000000..feb7ebb1 --- /dev/null +++ b/app/controllers/admin_controller.rb @@ -0,0 +1,18 @@ +class AdminController < ApplicationController + layout 'admin' + + def dashboard + end + + def universes + end + + def characters + end + + def locations + end + + def items + end +end diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 56f0ef5b..56188dc3 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -24,8 +24,8 @@ class ContentController < ApplicationController def show # TODO: Secure this with content class whitelist lel @content = content_type_from_controller(self.class).find(params[:id]) - @question = @content.question + @question = @content.question if current_user.present? and current_user == @content.user respond_to do |format| format.html # show.html.erb diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 367d0d9f..aa7f846c 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,7 +1,7 @@ # Controller for top-level pages of the site that do not have # an associated model class MainController < ApplicationController - layout "landing", only: [:index, :about_notebook] + layout 'landing', only: [:index, :about_notebook] def index redirect_to :dashboard if user_signed_in? diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb new file mode 100644 index 00000000..d5c6d355 --- /dev/null +++ b/app/helpers/admin_helper.rb @@ -0,0 +1,2 @@ +module AdminHelper +end diff --git a/app/models/user.rb b/app/models/user.rb index 7d68759c..f6902184 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -13,9 +13,7 @@ class User < ActiveRecord::Base has_many :characters has_many :items - has_many :languages has_many :locations - has_many :magics has_many :universes # as_json creates a hash structure, which you then pass to ActiveSupport::json.encode to actually encode the object as a JSON string. @@ -45,9 +43,7 @@ class User < ActiveRecord::Base { characters: characters, items: items, - languages: languages, locations: locations, - magics: magics, universes: universes } end @@ -56,9 +52,7 @@ class User < ActiveRecord::Base [ characters.length, items.length, - languages.length, locations.length, - magics.length, universes.length ].sum end diff --git a/app/views/admin/characters.html.erb b/app/views/admin/characters.html.erb new file mode 100644 index 00000000..2be1d05a --- /dev/null +++ b/app/views/admin/characters.html.erb @@ -0,0 +1,52 @@ +
+
+

Character creations

+ <%= line_chart Character.group_by_day(:created_at) %> +
+
+ +
+
+

Characters per user

+ <%= column_chart User.joins(:characters).group(:user_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Characters per universe

+ <%= column_chart Universe.joins(:characters).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Character privacy

+ <%= pie_chart Character.where.not(privacy: "").group(:privacy).count() %> +
+
+ +

Character usage data

+
+
+

Most common names

+ <%= bar_chart Character.where.not(name: "").group(:name).order('count_all desc').limit(5).count() %> +
+
+

Most common age

+ <%= bar_chart Character.where.not(age: "").group(:age).order('count_all desc').limit(5).count() %> +
+
+

Most common gender

+ <%= pie_chart Character.where.not(gender: "").group(:gender).order('count_all desc').limit(5).count() %> +
+
+ +
+
+

Most common occupation

+ <%= bar_chart Character.where.not(occupation: "").group(:occupation).order('count_all desc').limit(5).count() %> +
+
+

Most-favorite weapons

+ <%= bar_chart Character.where.not(fave_weapon: "").group(:fave_weapon).order('count_all desc').limit(5).count() %> +
+
+

Most common eye color

+ <%= pie_chart Character.where.not(eyecolor: "").group(:eyecolor).order('count_all desc').limit(5).count() %> +
+
\ No newline at end of file diff --git a/app/views/admin/dashboard.html.erb b/app/views/admin/dashboard.html.erb new file mode 100644 index 00000000..2d8a035f --- /dev/null +++ b/app/views/admin/dashboard.html.erb @@ -0,0 +1,25 @@ +

User signups

+<%= area_chart User.group_by_day(:created_at) %> + +
+
+

Universes per user

+ <%= column_chart User.joins(:universes).group(:user_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Characters per user

+ <%= column_chart User.joins(:characters).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+ +
+ +
+
+

Locations per user

+ <%= column_chart User.joins(:locations).group(:user_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Items per universe

+ <%= column_chart Universe.joins(:items).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
\ No newline at end of file diff --git a/app/views/admin/items.html.erb b/app/views/admin/items.html.erb new file mode 100644 index 00000000..681193b3 --- /dev/null +++ b/app/views/admin/items.html.erb @@ -0,0 +1,48 @@ +
+
+

Item creations

+ <%= line_chart Item.group_by_day(:created_at) %> +
+
+ +
+
+

Characters per user

+ <%= column_chart User.joins(:items).group(:user_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Items per universe

+ <%= column_chart Universe.joins(:items).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Item privacy

+ <%= pie_chart Item.where.not(privacy: "").group(:privacy).count() %> +
+
+ +

Item usage data

+
+
+

Most common names

+ <%= bar_chart Item.where.not(name: "").group(:name).order('count_all desc').limit(5).count() %> +
+
+

Most common types

+ <%= bar_chart Item.where.not(item_type: "").group(:item_type).order('count_all desc').limit(5).count() %> +
+
+ +
+
+

Common made years

+ <%= bar_chart Item.where.not(year_made: "").group(:year_made).order('count_all desc').limit(5).count() %> +
+
+

Common makers

+ <%= bar_chart Item.where.not(made_by: "").group(:made_by).order('count_all desc').limit(5).count() %> +
+
+

Most common weights

+ <%= bar_chart Item.where.not(weight: "").group(:weight).order('count_all desc').limit(5).count() %> +
+
\ No newline at end of file diff --git a/app/views/admin/locations.html.erb b/app/views/admin/locations.html.erb new file mode 100644 index 00000000..ad40ed18 --- /dev/null +++ b/app/views/admin/locations.html.erb @@ -0,0 +1,48 @@ +
+
+

Location creations

+ <%= line_chart Location.group_by_day(:created_at) %> +
+
+ +
+
+

Locations per user

+ <%= column_chart User.joins(:locations).group(:user_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Locations per universe

+ <%= column_chart Universe.joins(:locations).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Location privacy

+ <%= pie_chart Location.where.not(privacy: "").group(:privacy).count() %> +
+
+ +

Location usage data

+
+
+

Most common names

+ <%= bar_chart Location.where.not(name: "").group(:name).order('count_all desc').limit(5).count() %> +
+
+

Most common types

+ <%= bar_chart Location.where.not(type_of: "").group(:type_of).order('count_all desc').limit(5).count() %> +
+
+ +
+
+

Common estab. years

+ <%= bar_chart Location.where.not(established_year: "").group(:established_year).order('count_all desc').limit(5).count() %> +
+
+

Most common currencies

+ <%= pie_chart Location.where.not(currency: "").group(:currency).order('count_all desc').limit(5).count() %> +
+
+

Most common languages

+ <%= pie_chart Location.where.not(language: "").where.not(language: nil).group(:language).order('count_all desc').limit(5).count() %> +
+
\ No newline at end of file diff --git a/app/views/admin/universes.html.erb b/app/views/admin/universes.html.erb new file mode 100644 index 00000000..cd64c324 --- /dev/null +++ b/app/views/admin/universes.html.erb @@ -0,0 +1,32 @@ +
+
+

Universe creations

+ <%= line_chart Universe.group_by_day(:created_at) %> +
+
+ +
+
+

Universes per user

+ <%= column_chart User.joins(:universes).group(:user_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Privacy per universe

+ <%= pie_chart Universe.where.not(privacy: "").group(:privacy).count() %> +
+
+ +
+
+

Characters per universe

+ <%= column_chart Universe.joins(:characters).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Locations per universe

+ <%= column_chart Universe.joins(:locations).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
+

Items per universe

+ <%= column_chart Universe.joins(:items).group(:universe_id).count().group_by { |n| n.last }.each_with_object({}) { |(content_count, ids), h| h[content_count] = ids.count } %> +
+
diff --git a/app/views/cards/serendipitous/_content_question.html.erb b/app/views/cards/serendipitous/_content_question.html.erb index 84cea5ae..2bbbc480 100644 --- a/app/views/cards/serendipitous/_content_question.html.erb +++ b/app/views/cards/serendipitous/_content_question.html.erb @@ -15,7 +15,7 @@ %>
<%= f.text_field question[:field], class: 'content-question-input' %> - <%= f.label question[:field], question[:field].humanize %> + <%= f.label content.class.human_attribute_name(question[:field]) %>
<% end @@ -28,4 +28,6 @@ <% end %> <% end %> +<% else %> + <% end %> diff --git a/app/views/content/cards/_in_universe_content_list.html.erb b/app/views/content/cards/_in_universe_content_list.html.erb index 3181ad53..43688c66 100644 --- a/app/views/content/cards/_in_universe_content_list.html.erb +++ b/app/views/content/cards/_in_universe_content_list.html.erb @@ -20,16 +20,12 @@ Name Description - Created at - Last modified <% content_list.each do |content| %> <%= link_to content.name, content %> <%= content.description %> - <%= content.created_at.strftime("%m/%d/%Y") %> - <%= content.updated_at.strftime("%m/%d/%Y") %>
<%= link_to edit_polymorphic_path(content) do %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb new file mode 100644 index 00000000..3bd82d7c --- /dev/null +++ b/app/views/layouts/admin.html.erb @@ -0,0 +1,32 @@ + + + + <%= content_for?(:title) ? yield(:title) : 'Notebook' %> + <%= stylesheet_link_tag 'application' %> + <%= javascript_include_tag 'application' %> + <%= csrf_meta_tags %> + + + + + + + + + <%= render 'layouts/navbar' %> + +
+
    +
  • <%= link_to "Dashboard stats", admin_dashboard_path %>
  • +
  • <%= link_to "Universe stats", admin_universes_path %>
  • +
  • <%= link_to "Character stats", admin_characters_path %>
  • +
  • <%= link_to "Location stats", admin_locations_path %>
  • +
  • <%= link_to "Item stats", admin_items_path %>
  • +
+ + <%= yield %> + +
+ + + diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 26223218..b14ee13d 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -29,16 +29,12 @@ Name Description - Created at - Last modified <% current_user.universes.sort_by { |x| x.name.downcase }.each do |universe| %> <%= link_to universe.name, universe %> <%= truncate(universe.description, length: 140) %> - <%= universe.created_at.strftime("%m/%d/%Y") %> - <%= universe.updated_at.strftime("%m/%d/%Y") %>
<%= link_to edit_universe_path(universe) do %> @@ -80,16 +76,12 @@ Name Role - Created at - Last modified <% current_user.characters.sort_by { |x| x.name.downcase }.each do |character| %> <%= 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 %> @@ -132,8 +124,6 @@ Name Description Type - Created at - Last modified <% current_user.locations.sort_by { |x| x.name.downcase }.each do |location| %> @@ -141,8 +131,6 @@ <%= link_to location.name, location %> <%= truncate(location.description, length: 140) %> <%= location.type_of %> - <%= location.created_at.strftime("%m/%d/%Y") %> - <%= location.updated_at.strftime("%m/%d/%Y") %>
<%= link_to edit_location_path(location) do %> @@ -185,8 +173,6 @@ Name Description Type - Created at - Last modified <% current_user.items.sort_by { |x| x.name.downcase }.each do |item| %> @@ -194,8 +180,6 @@ <%= link_to item.name, item %> <%= truncate(item.description, length: 140) %> <%= item.item_type %> - <%= item.created_at.strftime("%m/%d/%Y") %> - <%= item.updated_at.strftime("%m/%d/%Y") %>
<%= link_to edit_item_path(item) do %> diff --git a/config/routes.rb b/config/routes.rb index 8a7a0ff8..d1923497 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,6 +43,14 @@ Rails.application.routes.draw do get 'editor', to: 'write#editor' end + scope 'admin' do + get '/', to: 'admin#dashboard', as: :admin_dashboard + get '/universes', to: 'admin#universes', as: :admin_universes + get '/characters', to: 'admin#characters', as: :admin_characters + get '/locations', to: 'admin#locations', as: :admin_locations + get '/items', to: 'admin#items', as: :admin_items + end + # API Endpoints scope '/generate' do # General information diff --git a/test/controllers/admin_controller_test.rb b/test/controllers/admin_controller_test.rb new file mode 100644 index 00000000..b8e0acfa --- /dev/null +++ b/test/controllers/admin_controller_test.rb @@ -0,0 +1,29 @@ +require 'test_helper' + +class AdminControllerTest < ActionController::TestCase + test "should get dashboard" do + get :dashboard + assert_response :success + end + + test "should get universes" do + get :universes + assert_response :success + end + + test "should get characters" do + get :characters + assert_response :success + end + + test "should get locations" do + get :locations + assert_response :success + end + + test "should get items" do + get :items + assert_response :success + end + +end From 3bf3f8412b50872311b7555aacfd41aaa65e903b Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Thu, 29 Sep 2016 20:08:24 -0500 Subject: [PATCH 4/5] Fix merge conflict --- app/controllers/content_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 56188dc3..5994c2f7 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -24,7 +24,7 @@ class ContentController < ApplicationController def show # TODO: Secure this with content class whitelist lel @content = content_type_from_controller(self.class).find(params[:id]) - + @question = @content.question if current_user.present? and current_user == @content.user respond_to do |format| From 794c38d6568fa1c1db57c1dd90c8189027ea424d Mon Sep 17 00:00:00 2001 From: Robert Richter Date: Thu, 29 Sep 2016 20:42:09 -0500 Subject: [PATCH 5/5] Serendipitous PR was merged, use master --- Gemfile | 2 +- Gemfile.lock | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 587b032d..3578dd8b 100644 --- a/Gemfile +++ b/Gemfile @@ -32,7 +32,7 @@ gem 'meta-tags' # Smarts # gem 'serendipitous', :path => "~/git/serendipitous-gem" -gem 'serendipitous', git: 'git://github.com/indentlabs/serendipitous-gem.git', branch: 'use-yml-files' +gem 'serendipitous', git: 'https://github.com/indentlabs/serendipitous-gem.git' # Editor gem 'medium-editor-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 5c080cdd..19c563d3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,6 @@ GIT - remote: git://github.com/indentlabs/serendipitous-gem.git - revision: d650852664d1bf021d6c9dc97e338624f59abc53 - branch: use-yml-files + remote: https://github.com/indentlabs/serendipitous-gem.git + revision: 393c9b664e0cbfacfc06d44dfd43898413b539a5 specs: serendipitous (0.0.2)