|
14 | 14 |
|
15 | 15 |
|
16 | 16 | <% unless @community.is_fake %> |
17 | | - <% if Rails.env.development? || @hot_questions.to_a.size > 0 || @pinned_links.to_a.size > 0 %> |
18 | | - <div class="widget has-margin-4 is-tertiary"> |
19 | | - <% if Rails.env.development? || @pinned_links.to_a.size > 0 %> |
20 | | - <div class="widget--header">Featured</div> |
21 | | - <% @pinned_links.each do |pl| %> |
22 | | - <div class="widget--body"> |
23 | | - <% pl_link = pl.post.nil? ? pl.link : generic_share_link(pl.post) %> |
24 | | - <% pl_label = pl.post.nil? ? pl.label : (pl.post.parent.nil? ? pl.post.title : pl.post.parent.title) %> |
25 | | - <%= link_to pl_link, class: 'h-fw-bold' do %> |
26 | | - <%= pl_label %> |
27 | | - <% end %> |
28 | | - <% unless pl.shown_before.nil? %> |
29 | | - <div> |
30 | | - — |
31 | | - <% if !pl.shown_after.nil? %> |
32 | | - <% if pl.shown_after < DateTime.now %> |
33 | | - ends in <%= time_ago_in_words(pl.shown_before) %> |
| 17 | + <%# Featured widget %> |
| 18 | + <% if Rails.env.development? || @pinned_links.to_a.size > 0 %> |
| 19 | + <% cache @pinned_links do %> |
| 20 | + <div class="widget has-margin-4 is-teal"> |
| 21 | + <% if Rails.env.development? || @pinned_links.to_a.size > 0 %> |
| 22 | + <div class="widget--header">Featured</div> |
| 23 | + <% @pinned_links.each do |pl| %> |
| 24 | + <div class="widget--body"> |
| 25 | + <% pl_link = pl.post.nil? ? pl.link : generic_share_link(pl.post) %> |
| 26 | + <% pl_label = pl.post.nil? ? pl.label : (pl.post.parent.nil? ? pl.post.title : pl.post.parent.title) %> |
| 27 | + <%= link_to pl_link, class: 'h-fw-bold' do %> |
| 28 | + <%= pl_label %> |
| 29 | + <% end %> |
| 30 | + <% unless pl.shown_before.nil? %> |
| 31 | + <div> |
| 32 | + — |
| 33 | + <% if !pl.shown_after.nil? %> |
| 34 | + <% if pl.shown_after < DateTime.now %> |
| 35 | + ends in <%= time_ago_in_words(pl.shown_before) %> |
| 36 | + <% else %> |
| 37 | + starts in <%= time_ago_in_words(pl.shown_after) %> |
| 38 | + <% end %> |
34 | 39 | <% else %> |
35 | | - starts in <%= time_ago_in_words(pl.shown_after) %> |
| 40 | + in <%= time_ago_in_words(pl.shown_before) %> |
36 | 41 | <% end %> |
37 | | - <% else %> |
38 | | - in <%= time_ago_in_words(pl.shown_before) %> |
39 | | - <% end %> |
40 | | - </div> |
| 42 | + </div> |
| 43 | + <% end %> |
| 44 | + </div> |
| 45 | + <% end %> |
| 46 | + <% end %> |
| 47 | + </div> |
| 48 | + <% end %> |
| 49 | + <% end %> |
| 50 | + |
| 51 | + <%# Related Posts widget %> |
| 52 | + <% if defined?(@post) && @post.inbound_duplicates.any? %> |
| 53 | + <% collapse_related = user_preference('collapse_related_posts') == 'true' %> |
| 54 | + <% cache [@post, @post.inbound_duplicates] do %> |
| 55 | + <div class="widget has-margin-4 is-green" data-collapsed="<%= user_preference('collapse_related_posts') %>"> |
| 56 | + <div class="widget--header"> |
| 57 | + Related Posts |
| 58 | + <button type="button" class="widget--header-link button is-icon-only-button js-widget-hide" |
| 59 | + aria-label="Collapse Related Posts"> |
| 60 | + <i class="fas <%= collapse_related ? 'fa-chevron-down' : 'fa-chevron-up' %>"></i> |
| 61 | + </button> |
| 62 | + </div> |
| 63 | + <% @post.inbound_duplicates.each do |dp| %> |
| 64 | + <div class="widget--body <%= 'hidden' if collapse_related %>"> |
| 65 | + <% unless dp.category.nil? %> |
| 66 | + <%= dp.category.name %> |
| 67 | + — |
| 68 | + <% end %> |
| 69 | + <%= link_to generic_share_link(dp) do %> |
| 70 | + <%= dp.title %> |
41 | 71 | <% end %> |
42 | 72 | </div> |
43 | 73 | <% end %> |
44 | | - <% end %> |
45 | | - <% if Rails.env.development? || @hot_questions.to_a.size > 0 %> |
46 | | - <div class="widget--header">Hot Posts</div> |
| 74 | + </div> |
| 75 | + <% end %> |
| 76 | + <% end %> |
| 77 | + |
| 78 | + <%# Hot Posts widget %> |
| 79 | + <% if Rails.env.development? || @hot_questions.to_a.size > 0 %> |
| 80 | + <% collapse_hot = user_preference('collapse_hot_posts') == 'true' %> |
| 81 | + <% cache @hot_questions do %> |
| 82 | + <div class="widget has-margin-4 is-tertiary" data-collapsed="<%= user_preference('collapse_hot_posts') %>"> |
| 83 | + <div class="widget--header"> |
| 84 | + Hot Posts |
| 85 | + <button type="button" class="widget--header-link button is-icon-only-button js-widget-hide" |
| 86 | + aria-label="Collapse Hot Posts"> |
| 87 | + <i class="fas <%= collapse_hot ? 'fa-chevron-down' : 'fa-chevron-up' %>"></i> |
| 88 | + </button> |
| 89 | + </div> |
47 | 90 | <% @hot_questions.each do |hq| %> |
48 | | - <div class="widget--body"> |
| 91 | + <div class="widget--body <%= 'hidden' if collapse_hot %>"> |
49 | 92 | <% unless hq.category.nil? %> |
50 | 93 | <%= hq.category.name %> |
51 | 94 | — |
|
55 | 98 | <% end %> |
56 | 99 | </div> |
57 | 100 | <% end %> |
58 | | - <% end %> |
59 | | - </div> |
| 101 | + </div> |
| 102 | + <% end %> |
60 | 103 | <% end %> |
61 | 104 | <% end %> |
62 | 105 |
|
|
0 commit comments