mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
author page polish
This commit is contained in:
parent
58992ae0a3
commit
8ab97e7ea6
@ -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/
|
||||
@ -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);
|
||||
|
||||
@ -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/
|
||||
@ -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
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -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'
|
||||
|
||||
@ -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
|
||||
[
|
||||
|
||||
@ -57,6 +57,15 @@ class User < ActiveRecord::Base
|
||||
].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
|
||||
|
||||
@ -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">
|
||||
@ -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,
|
||||
@ -55,6 +56,7 @@ content_jsonld = {
|
||||
colors: [Universe.color, Character.color, Location.color, "yellow"],
|
||||
) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<div class="card-reveal">
|
||||
@ -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
|
||||
%>
|
||||
Loading…
Reference in New Issue
Block a user