diff --git a/app/assets/javascripts/admin.js.coffee b/app/assets/javascripts/admin.js.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/admin.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/content.js.coffee b/app/assets/javascripts/content.js.coffee index a9b3ed352..c0356a4bb 100644 --- a/app/assets/javascripts/content.js.coffee +++ b/app/assets/javascripts/content.js.coffee @@ -1,8 +1,9 @@ $(document).ready -> $('.tab').click -> - btn_href = $('.card-action a').attr('href').split('#')[0]; - tab_anchor = $(this).find('a').attr('href') - $('.card-action a').attr('href', btn_href + tab_anchor); + if $('.card-action a').attr('href') + btn_href = $('.card-action a').attr('href').split('#')[0]; + tab_anchor = $(this).find('a').attr('href') + $('.card-action a').attr('href', btn_href + tab_anchor); if location.hash? setTimeout ( -> window.scrollTo(0, 0); diff --git a/app/assets/javascripts/users.js.coffee b/app/assets/javascripts/users.js.coffee deleted file mode 100644 index 24f83d18b..000000000 --- a/app/assets/javascripts/users.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# 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/models/character.rb b/app/models/character.rb index 652d0e60b..7d5a28dc7 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -33,7 +33,7 @@ class Character < ActiveRecord::Base # Items relates :favorite_items, with: :ownerships, where: { favorite: true } - scope :is_public, -> { joins(:universe).where('universes.privacy = ? OR characters.privacy = ?', 'public', 'public') } + scope :is_public, -> { eager_load(:universe).where('characters.privacy = ? OR universes.privacy = ?', 'public', 'public') } def description role diff --git a/app/models/item.rb b/app/models/item.rb index 9e467afbf..280a2a513 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -21,7 +21,7 @@ class Item < ActiveRecord::Base relates :current_owners, with: :current_ownerships relates :makers, with: :maker_relationships - scope :is_public, -> { joins(:universe).where('universes.privacy = ? OR items.privacy = ?', 'public', 'public') } + scope :is_public, -> { eager_load(:universe).where('universes.privacy = ? OR items.privacy = ?', 'public', 'public') } def self.color 'amber' diff --git a/app/models/location.rb b/app/models/location.rb index 2773b41b9..4974185e4 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -27,7 +27,7 @@ class Location < ActiveRecord::Base relates :largest_cities, with: :largest_cities_relationships relates :notable_cities, with: :notable_cities_relationships - scope :is_public, -> { joins(:universe).where('universes.privacy = ? OR locations.privacy = ?', 'public', 'public') } + scope :is_public, -> { eager_load(:universe).where('universes.privacy = ? OR locations.privacy = ?', 'public', 'public') } def self.icon 'terrain' diff --git a/app/models/universe.rb b/app/models/universe.rb index f4aff1086..b83305216 100644 --- a/app/models/universe.rb +++ b/app/models/universe.rb @@ -16,7 +16,7 @@ class Universe < ActiveRecord::Base has_many :items has_many :locations - scope :is_public, -> { where(privacy: "public") } + scope :is_public, -> { where(privacy: 'public') } def content_count [ diff --git a/app/models/user.rb b/app/models/user.rb index f6902184a..f4278db2d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -57,6 +57,15 @@ def content_count ].sum end + def public_content_count + [ + characters.is_public.length, + items.is_public.length, + locations.is_public.length, + universes.is_public.length + ].sum + end + def image_url(size=80) email_md5 = Digest::MD5.hexdigest(email.downcase) # 80px is Gravatar's default size diff --git a/app/views/content/form/_actions_dropdown.html.erb b/app/views/content/form/_actions_dropdown.html.erb index f03a90c1e..7cf76d1bd 100644 --- a/app/views/content/form/_actions_dropdown.html.erb +++ b/app/views/content/form/_actions_dropdown.html.erb @@ -5,15 +5,16 @@ <% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 0e8ad31dc..937e1c38d 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -25,7 +25,7 @@ content_jsonld = { %>
-
+
@@ -45,6 +45,7 @@ content_jsonld = { <% end %>
+ <% if @user.public_content_count > 0 %>
<%= pie_chart({ universes: @user.universes.is_public.count, @@ -55,6 +56,7 @@ content_jsonld = { colors: [Universe.color, Character.color, Location.color, "yellow"], ) %>
+ <% end %>
@@ -70,19 +72,49 @@ content_jsonld = {
-
+
    <% tabs.each do |tab| %> -
  • "><%= link_to pluralize(tab_content_list[tab].length, tab.singularize), "\##{tab}" %>
  • +
  • <%= link_to pluralize(tab_content_list[tab].length, tab.singularize), "\##{tab}" %>
  • <% end %>
<% tabs.each do |tab| %> -
- <%= render partial: 'content/list/list', locals: { content_list: tab_content_list[tab], title: '', clean: true } %> -
+ <% if tab_content_list[tab].any? %> +
+ <%= render partial: 'content/list/list', locals: { content_list: tab_content_list[tab], title: '', clean: true } %> +
+ <% elsif tab_content_list[tab].empty? %> + <% tab_class = tab.singularize.titleize.constantize %> +
+
+ <%= tab_class.icon %> +
+

+ It looks like <%= @user.name %> isn't sharing any public <%= tab %> yet. +

+
+ <% end %> <% end %>
+ +<% + # Default to showing the first tab with content in it (left-first) + tabs.each do |tab| + if tab_content_list[tab].any? +%> + + + +<% + break # Only do this for the first tab with content we see + end + end +%> \ No newline at end of file