Skip to content

Commit

Permalink
Merge pull request #1399 from codidact/cellio/make-tag-rss-link-more-…
Browse files Browse the repository at this point in the history
…visible

make tag rss link more visible
  • Loading branch information
Oaphi authored Sep 22, 2024
2 parents a0922b3 + 95539c9 commit 712ec5d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 28 deletions.
6 changes: 6 additions & 0 deletions app/assets/stylesheets/categories.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
align-items: center;
justify-content: space-between;
}

& .category-meta--start {
display: flex;
align-items: center;
gap: 0.5em;
}
}

.category-header--nav {
Expand Down
17 changes: 5 additions & 12 deletions app/views/categories/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@
<% post_count = @posts.count %>
<div class="has-color-tertiary-500 category-meta">
<span>
<span class=category-meta--start>
<span title="<%= post_count %> posts">
<%= short_number_to_human post_count, precision: 1, significant: false %>
<%= 'post'.pluralize(post_count) %> &nbsp;
<%= 'post'.pluralize(post_count) %>
</span>

<%= link_to category_feed_path(@category, format: 'rss') do %>
<i class="fas fa-rss"></i> RSS
<% end %>

<%= render 'shared/rss_link', url: category_feed_path(@category, format: 'rss') %>
<span class="has-margin-4">
<% if current_user&.is_admin %>
<%= link_to 'Edit Category', edit_category_path(@category) %> &nbsp;
<%= link_to 'Edit Category', edit_category_path(@category) %>
<% end %>
</span>

</span>

<div class="button-list is-gutterless has-margin-2">
Expand Down Expand Up @@ -83,7 +78,5 @@
</div>

<div class="has-padding-top-4">
<%= link_to category_feed_path(@category, format: 'rss') do %>
<i class="fas fa-rss"></i> Category RSS feed
<% end %>
<%= render 'shared/rss_link', url: category_feed_path(@category, format: 'rss'), text: 'Category RSS feed' %>
</div>
20 changes: 20 additions & 0 deletions app/views/shared/_rss_link.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%#
'Adds an RSS link.
Variables:
url : [String] URL to the feed
text : [String, Nil] text to visibly show
tooltip : [String, Nil] text to show in the tooltip
'
%>
<%
# Defaults
text = defined?(text) ? text : 'RSS'
tooltip = defined?(tooltip) ? tooltip : 'RSS Feed'
%>

<span title="<%= tooltip %>">
<%= link_to url, class: 'has-display-inline-block' do %>
<i class="fas fa-rss"></i> RSS
<% end %>
</span>
36 changes: 20 additions & 16 deletions app/views/tags/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<p class="has-color-tertiary-900 has-font-weight-normal has-margin-0 has-font-family-brand">
<% if @tag.parent_id.present? %>
Subtag of <%= link_to @tag.parent.name, tag_path(id: @category.id, tag_id: @tag.parent_id),
Subtag of <%= link_to @tag.parent.name, tag_path(id: @category.id, tag_id: @tag.parent_id),
class: tag_classes(@tag.parent, @category) %>
<% end %>
<% child_count = @tag.children.count %>
Expand Down Expand Up @@ -62,12 +62,12 @@
<div class="widget--body">
<% if @tag.wiki.present? %>
<% if @tag.wiki.length < 600 %>
<%= raw(sanitize(@tag.wiki, scrubber: scrubber)) %>
<% else %>
<details>
<summary>Tag Wiki</summary>
<%= raw(sanitize(@tag.wiki, scrubber: scrubber)) %>
</details>
<% else %>
<details>
<summary>Tag Wiki</summary>
<%= raw(sanitize(@tag.wiki, scrubber: scrubber)) %>
</details>
<% end %>
<% end %>
<% unless @tag.wiki.present? %>
Expand All @@ -91,18 +91,24 @@
<% post_count = @posts.count %>
<div class="has-color-tertiary-500 category-meta" title="<%= post_count %>">
<div>
<%= short_number_to_human post_count, precision: 1, significant: false %>
<%= 'post'.pluralize(post_count) %>
<div class="category-meta--start">
<span title="<%= post_count %> posts with this tag">
<%= short_number_to_human post_count, precision: 1, significant: false %>
<%= 'post'.pluralize(post_count) %>
</span>
<%= render 'shared/rss_link', url: tag_path(id: @category.id, tag_id: @tag.id, format: 'rss'), tooltip: 'RSS feed for this tag' %>
<% if user_signed_in? && current_user&.subscriptions.where(type: 'tag', qualifier: @tag.name).exists? %>
<%= link_to 'Subscribed', subscriptions_path(current_user),
<span class="has-margin-4" title="Subscribed: manage email subscriptions">
<%= link_to 'Subscribed', subscriptions_path(current_user),
class: 'button is-outlined', 'aria-label': "Subscribed to tag #{@tag.name}" %>
</span>
<% else %>
<%= link_to 'Subscribe',
<span title="Create email subscription">
<%= link_to 'Subscribe',
new_subscription_path(type: 'tag', qualifier: @tag.name, return_to: request.path),
class: 'button is-outlined', 'aria-label': "Subscribe to tag #{@tag.name}" %>
<% end %>
</span>
<% end %>
</div>

<div class="button-list is-gutterless has-margin-2">
Expand All @@ -126,7 +132,5 @@
</div>

<div class="has-padding-top-4">
<%= link_to tag_path(id: @category.id, tag_id: @tag.id, format: 'rss') do %>
<i class="fas fa-rss"></i> Tag RSS feed
<% end %>
<%= render 'shared/rss_link', url: tag_path(id: @category.id, tag_id: @tag.id, format: 'rss'), text: 'Tag RSS feed' %>
</div>

0 comments on commit 712ec5d

Please sign in to comment.