From 0333f3e258026696af265f777f862e612bab1bd7 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 13 Oct 2023 11:51:47 -0400 Subject: Tag links --- app/assets/images/tag.png | Bin 0 -> 389 bytes app/assets/stylesheets/main/entries.scss | 24 ++++++++++++++++++++++++ app/controllers/tags_controller.rb | 5 +++++ app/views/blogs/_blog.html.haml | 3 +++ config/routes.rb | 2 +- 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 app/assets/images/tag.png diff --git a/app/assets/images/tag.png b/app/assets/images/tag.png new file mode 100755 index 0000000..e093032 Binary files /dev/null and b/app/assets/images/tag.png differ diff --git a/app/assets/stylesheets/main/entries.scss b/app/assets/stylesheets/main/entries.scss index 5fbd4ef..1a42d85 100644 --- a/app/assets/stylesheets/main/entries.scss +++ b/app/assets/stylesheets/main/entries.scss @@ -88,6 +88,30 @@ font: 75%/150% sans-serif; color: #999; } + + .post-tag-3 { + background: image-url("tag.png") no-repeat; + padding-left: 20px; + margin: 0 0 0 3em; + float: left; + font-size: 95%; + color: #999999; + font: 75%/150% sans-serif; + display: block; + + li { + display: inline-block; + margin-right: 0.5em; + + a { + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } + } + } } } diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 7115d28..cf5d50b 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,5 +1,10 @@ class TagsController < ApplicationController + def show + @blogs = Blog.tagged_with(params[:name]).where(published: true).order(published_at: :desc).paginate(page: params[:page], per_page: 10) + render "blogs/summary" + end + def suggest @tags = ActsAsTaggableOn::Tag.pluck(:name).select do |tag| tag.starts_with? params[:term] diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index 8972c2e..c607e63 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml @@ -6,6 +6,9 @@ .blog-title %h2= link_to_unless_current blog.title, blog .post-author Hatkirby + %ul.post-tag-3 + - blog.tags.each do |tag| + %li= link_to tag, tag_url(tag.name) %blockquote#blog-content.entry-content.bubble.rounded.bottom - if short and blog.has_read_more = markdown(blog.short_body) diff --git a/config/routes.rb b/config/routes.rb index dcfe673..a3448f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,7 +36,7 @@ Rails.application.routes.draw do get 'plays', to: 'games#index' - resources :tags, only: [], param: :name do + resources :tags, only: [:show], param: :name do collection do get 'suggest' end -- cgit 1.4.1