Fix inline stylesheet issue (#248)

* Remove current article id from potential queried articles

* Fix inline stylesheet issue

* Modify sticky_articles source to be more similar to post

* Move assign sticky nav around

* Modify sticky articles

* Attempt to fix sticky

* Fix article show to call 404

* Fix

* Conditional
This commit is contained in:
Ben Halpern 2018-04-25 22:15:22 -04:00 committed by GitHub
parent 3903a3a5e4
commit e2a35693b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 30 deletions

View file

@ -218,6 +218,7 @@ class StoriesController < ApplicationController
@article_show = true
@comment = Comment.new
assign_article_and_user_and_organization
assign_sticky_nav
handle_possible_redirect; return if performed?
not_found unless @article
@comments_to_show_count = @article.cached_tag_list_array.include?("discuss") ? 75 : 25
@ -273,4 +274,31 @@ class StoriesController < ApplicationController
decorate
end
def assign_sticky_nav
return unless @article
reaction_count_num = Rails.env.production? ? 20 : -1
comment_count_num = Rails.env.production? ? 8 : -2
tag_articles = []
more_articles = []
tag_articles = Article.tagged_with(@article.cached_tag_list_array, any: true).
includes(:user).
where("positive_reactions_count > ? OR comments_count > ?", reaction_count_num, comment_count_num).
where(published: true).
where.not(id: @article.id).
where("featured_number > ?", 5.days.ago.to_i).
order("RANDOM()").
limit(12)
if tag_articles.size < 11
more_articles = Article.tagged_with((["career","productivity","discuss"]), any: true).
includes(:user).
where("positive_reactions_count > ? OR comments_count > ?", reaction_count_num, comment_count_num).
where(published: true).
where.not(id: @article.id).
where("featured_number > ?", 5.days.ago.to_i).
order("RANDOM()").
limit(10 - tag_articles.size)
end
@sticky_articles = (tag_articles + more_articles).sample(8)
end
end

View file

@ -34,33 +34,27 @@
<%= follow_button(@actor) %>
</div>
</div>
<div class="primary-sticky-nav-title">
Trending on dev.to
</div>
<% Article.tagged_with((@article.cached_tag_list_array + ["career","productivity","discuss"]), any: true).
includes(:user).
where("positive_reactions_count > ? OR comments_count > ?", (Rails.env.production? ? 20 : -1 ), (Rails.env.production? ? 8 : -1 )).
where(published: true).
where.not(id: @article.id).
where("featured_number > ?", 5.days.ago.to_i).
order("RANDOM()").
limit(8).
each do |article| %>
<a class="primary-sticky-nav-element" href="<%= article.path %>">
<img src="<%= ProfileImage.new(article.user).get(90) %>" class="primary-sticky-nav-profile-image" />
<%= article.title %>
<div class="primary-sticky-nav-element-details">
<% article.decorate.cached_tag_list_array.each do |tag| %>
<span>#<%= tag %></span>
<% end %>
</div>
</a>
<% end %>
<% if 1==2 %>
<a class="primary-sticky-nav-element sticky-join-cta" href="/enter">
<img src="https://emojipedia-us.s3.amazonaws.com/thumbs/240/apple/129/waving-hand-sign_1f44b.png" /> Join the DEV Community
</a>
<% if sticky_articles %>
<div class="primary-sticky-nav-title">
Trending on dev.to
</div>
<% sticky_articles.each do |article| %>
<a class="primary-sticky-nav-element" href="<%= article.path %>">
<img src="<%= ProfileImage.new(article.user).get(90) %>" class="primary-sticky-nav-profile-image" />
<%= article.title %>
<div class="primary-sticky-nav-element-details">
<% article.decorate.cached_tag_list_array.each do |tag| %>
<span>#<%= tag %></span>
<% end %>
</div>
</a>
<% end %>
<% if 1==2 %>
<a class="primary-sticky-nav-element sticky-join-cta" href="/enter">
<img src="https://emojipedia-us.s3.amazonaws.com/thumbs/240/apple/129/waving-hand-sign_1f44b.png" /> Join the DEV Community
</a>
<% end %>
<% end %>
</div>
<% end %>

View file

@ -202,7 +202,7 @@
</div>
</div>
<%= render "articles/sticky_nav" %>
<%= render "articles/sticky_nav", sticky_articles: @sticky_articles %>
<% if hasVid(@article) %>
<%= render 'articles/fitvids' %>

View file

@ -1,4 +1,4 @@
<% cache "base_inline_styles_#{@story_show.to_s}_#{@article_index.to_s}_#{@home_page.to_s}_#{@article_show.to_s}_#{view_class.to_s}_#{@notifications_index}_#{core_pages?.to_s}_#{@tags_index}_#{ENV["DEPLOYMENT_SIGNATURE"].to_s}x_xs", :expires_in => 6.hours do %>
<% cache "base_inline_styles_#{@story_show.to_s}_#{@article_index.to_s}_#{@home_page.to_s}_#{@article_show.to_s}_#{view_class.to_s}_#{@notifications_index}_#{core_pages?.to_s}_#{@tags_index}_#{ENV["DEPLOYMENT_SIGNATURE"].to_s}x_xs__", :expires_in => 6.hours do %>
<% if @story_show %>
<style>
<% Rails.application.config.assets.compile = true %>
@ -10,7 +10,7 @@
<%= Rails.application.assets['more-articles.css'].to_s.html_safe %>
<%= Rails.application.assets["ltags/LiquidTags.scss"].to_s.html_safe %>
<%= Rails.application.assets["syntax.css"].to_s.html_safe %>
<%= Rails.application.assets["primary-sticky-nav.css"].to_s.html_safe %>
<%= Rails.application.assets["sticky-nav.css"].to_s.html_safe %>
<% else %>
<%= Rails.application.assets['article-show.css'].to_s.html_safe %>
<%= Rails.application.assets['podcast-episodes-show.css'].to_s.html_safe %>