Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/assets/javascripts/admin.js.coffee

This file was deleted.

7 changes: 4 additions & 3 deletions app/assets/javascripts/content.js.coffee
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/users.js.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/character.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion app/models/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion app/models/universe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
[
Expand Down
9 changes: 9 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions app/views/content/form/_actions_dropdown.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
<% end %>

<ul id='options-menu' class='dropdown-content'>
<%# TODO: something with these %>
<!-- Broken on content edit pages
<li><a href="#!" class="share">Share this <%= content.class.to_s.downcase %></a></li>
<li class="divider"></li>
-->
<% if content.persisted? %>
<li>
<%= link_to "Delete this #{content.class.to_s.downcase} forever", content,
:class => 'red-text',
:method => :delete,
:confirm => 'Are you sure? This action cannot be undone!' %>
:data => { :confirm => 'Are you sure? This action cannot be undone!' } %>
</li>
<% end %>
</ul>
44 changes: 38 additions & 6 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ content_jsonld = {
%>

<div class="row">
<div class="col s12 m3 l4">
<div class="col s12 m3 l2">

<div class="hoverable card">
<div class="card-image waves-effect waves-block waves-light">
Expand All @@ -45,6 +45,7 @@ content_jsonld = {
<% end %>
</div>

<% if @user.public_content_count > 0 %>
<div class="row">
<%= pie_chart({
universes: @user.universes.is_public.count,
Expand All @@ -55,6 +56,7 @@ content_jsonld = {
colors: [Universe.color, Character.color, Location.color, "yellow"],
) %>
</div>
<% end %>

</div>
<div class="card-reveal">
Expand All @@ -70,19 +72,49 @@ content_jsonld = {
</div>
</div>

<div class="card col s12 m9 l8">
<div class="card col s12 m9 l10">
<div>
<ul class="tabs">
<% tabs.each do |tab| %>
<li class="tab col s3 <%= "disabled" if tab_content_list[tab].empty? %>"><%= link_to pluralize(tab_content_list[tab].length, tab.singularize), "\##{tab}" %></li>
<li class="tab col s3" id="js-<%= tab %>-tab"><%= link_to pluralize(tab_content_list[tab].length, tab.singularize), "\##{tab}" %></li>
<% end %>
</ul>
</div>

<% tabs.each do |tab| %>
<div id="<%= tab %>" class="col s12">
<%= render partial: 'content/list/list', locals: { content_list: tab_content_list[tab], title: '', clean: true } %>
</div>
<% if tab_content_list[tab].any? %>
<div id="<%= tab %>" class="col s12">
<%= render partial: 'content/list/list', locals: { content_list: tab_content_list[tab], title: '', clean: true } %>
</div>
<% elsif tab_content_list[tab].empty? %>
<% tab_class = tab.singularize.titleize.constantize %>
<div id="<%= tab %>" class="col s12">
<div class="center <%= tab_class.color %>-text" style="margin-top: 40px;">
<i class="material-icons" style="font-size: 500%"><%= tab_class.icon %></i>
</div>
<p class="center">
It looks like <%= @user.name %> isn't sharing any public <%= tab %> yet.
</p>
</div>
<% end %>
<% end %>
</div>
</div>

<%
# Default to showing the first tab with content in it (left-first)
tabs.each do |tab|
if tab_content_list[tab].any?
%>

<script type="text/javascript">
$(document).ready(function () {
$('#js-<%= tab %>-tab').find('a')[0].click();
})
</script>

<%
break # Only do this for the first tab with content we see
end
end
%>