From 3595ef72912738df747715c01c134292ae690ba2 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 27 Feb 2017 17:54:57 +0000 Subject: [PATCH 1/5] Show custom tabs on public content even if user isn't logged in --- app/views/content/show.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index ac5d428e..2761674e 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -11,8 +11,7 @@ <%= render partial: 'cards/serendipitous/content_question', locals: { question: @question, content: @content } %> <% end %> -<% categories = content.class.attribute_categories(current_user) %> - +<% categories = @content.class.attribute_categories(@content.user) %>
From 93e3edde919a5c8d86e8979f3777a75b5ab68805 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 27 Feb 2017 17:58:23 +0000 Subject: [PATCH 2/5] Show all fields on user content, even if they're blank --- app/views/content/show.html.erb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index 2761674e..197ad66f 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -55,7 +55,7 @@ <% end %> <% category.attribute_fields.each do |attribute| %> - <% next if attribute.name.start_with?("private") && @content.user != current_user %> + <% next if attribute.name.start_with?("private") && (current_user.nil? || @content.user != current_user) %> <% value = nil if content.respond_to?(attribute.name.to_sym) @@ -64,7 +64,7 @@ value = Attribute.where(user: current_user, attribute_field: attribute, entity: content).first end %> - <% next if value.blank? %> + <%# next if value.blank? %>
<%= attribute.label %>
@@ -90,9 +90,11 @@
<% else %> <%# TODO: if text is > 240, truncate and add "Read more" link that opens modal %> -
140 %> markdownable"> - <%= Rails.application.config.markdown.render(value.is_a?(Attribute) ? value.value : value).html_safe %>  -
+ <% unless value.blank? %> +
140 %> markdownable"> + <%= Rails.application.config.markdown.render(value.is_a?(Attribute) ? value.value : value).html_safe %>  +
+ <% end %> <% end %>
<% end %> From 3333415b1de382ac834a7709da7fdec8708f9574 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 27 Feb 2017 19:08:24 +0000 Subject: [PATCH 3/5] Show attribute values for logged-out users --- app/views/content/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index 197ad66f..cfa881d6 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -61,7 +61,7 @@ if content.respond_to?(attribute.name.to_sym) value = content.send(attribute.name.to_sym) else - value = Attribute.where(user: current_user, attribute_field: attribute, entity: content).first + value = Attribute.where(user: @content.user, attribute_field: attribute, entity: content).first end %> <%# next if value.blank? %> From a6316559d7414b693aeed653a3ee2c3c0d4043e3 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 27 Feb 2017 19:35:04 +0000 Subject: [PATCH 4/5] Also check if user is signed in for edit actions --- app/views/content/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/content/show.html.erb b/app/views/content/show.html.erb index cfa881d6..5556cbbf 100644 --- a/app/views/content/show.html.erb +++ b/app/views/content/show.html.erb @@ -105,7 +105,7 @@
<%= yield :content_show_footer %> - <% if current_user == content.user %> + <% if user_signed_in? && current_user == content.user %> <%= link_to "Edit this #{content.class.to_s.downcase}", edit_polymorphic_path(@content), class: "btn #{content.class.color}" %> <% elsif content.user.name.present? %> <%= content.user.name %> created and maintains this universe on Notebook.ai.
From d2c310fe0f19c404c91784351e24524de52c0d60 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 27 Feb 2017 19:41:41 +0000 Subject: [PATCH 5/5] Differentiate between redirecting to content and looking at content --- app/controllers/content_controller.rb | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 471f8d23..dceddedf 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -27,11 +27,22 @@ class ContentController < ApplicationController if (current_user || User.new).can_read? @content @question = @content.question if current_user.present? and current_user == @content.user - Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed content', { - 'content_type': content_type.name, - 'content_owner': current_user.present? && current_user.id == @content.user_id, - 'logged_in_user': current_user.present? - }) if current_user + if current_user + if @content.updated_at > 30.minutes.ago + Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed content', { + 'content_type': content_type.name, + 'content_owner': current_user.present? && current_user.id == @content.user_id, + 'logged_in_user': current_user.present? + }) + else + Mixpanel::Tracker.new(Rails.application.config.mixpanel_token).track(current_user.id, 'viewed recently-modified content', { + 'content_type': content_type.name, + 'content_owner': current_user.present? && current_user.id == @content.user_id, + 'logged_in_user': current_user.present? + }) + end + end + respond_to do |format| format.html { render 'content/show', locals: { content: @content } }