From 0db551db625d8f2cfe5e7efaef99f1770d6a1adf Mon Sep 17 00:00:00 2001 From: Cinder Date: Sun, 26 Jan 2025 06:26:23 -0800 Subject: [PATCH] [Misc] Add a subscribestar static page (#856) --- app/controllers/static_controller.rb | 4 ++++ app/helpers/application_helper.rb | 19 +++++++++++++++++- .../src/styles/common/navigation.scss | 20 +++++++++++++------ app/views/layouts/_nav.html.erb | 3 ++- app/views/static/subscribestar.html.erb | 12 +++++++++++ config/routes.rb | 1 + 6 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 app/views/static/subscribestar.html.erb diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 6028ac8e1..a63bd197e 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -21,6 +21,10 @@ class StaticController < ApplicationController @page = format_wiki_page("e621:avoid_posting_notice") end + def subscribestar + @page = format_wiki_page("e621:subscribestar") + end + def not_found render "static/404", formats: [:html], status: 404 end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 928838e57..8b37699a7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,6 @@ module ApplicationHelper cookies[:nmm].present? end - def diff_list_html(new, old, latest) diff = SetDiff.new(new, old, latest) render "diff_list", diff: diff @@ -32,6 +31,24 @@ module ApplicationHelper end end + def custom_image_nav_link_to(text, image, url, **options) + klass = options.delete(:class) + + if nav_link_match(params[:controller], url) + klass = "#{klass} current" + end + + id = "nav-#{text.downcase.gsub(/[^a-z ]/, '').parameterize}" + + tag.li(id: id, class: klass) do + link_to(url, id: "#{id}-link", **options) do + concat image_pack_tag(image) + concat " " + concat tag.span(text) + end + end + end + def nav_link_to(text, url, **options) klass = options.delete(:class) diff --git a/app/javascript/src/styles/common/navigation.scss b/app/javascript/src/styles/common/navigation.scss index ed3969aaa..4c9acdfde 100644 --- a/app/javascript/src/styles/common/navigation.scss +++ b/app/javascript/src/styles/common/navigation.scss @@ -172,19 +172,28 @@ nav.navigation { li { padding: 0; - &.nav-help-discord { grid-column: 1 / -1; } + &.nav-help-discord, + &.nav-help-subscribestar { + grid-column: 1 / -1; + } & > a { - display: block; + display: flex; background: themed("color-section-darken-5"); border-radius: 6px; font-size: 125%; padding: 0.5rem 1rem; - text-align: center; - i { color: themed("color-link-active"); } + justify-content: center; + align-items: center; + gap: 0.25em; + + img { + height: 1.25em; + margin: -0.5em 0; + } } } } @@ -351,11 +360,10 @@ nav.navigation, body.nav-toggled nav.navigation { } } .nav-help { - overflow: hidden; + li a img { display: none; } li.current a { background-color: themed("color-foreground"); - i { display: none; } } } diff --git a/app/views/layouts/_nav.html.erb b/app/views/layouts/_nav.html.erb index 731a4099a..7db448f12 100644 --- a/app/views/layouts/_nav.html.erb +++ b/app/views/layouts/_nav.html.erb @@ -42,8 +42,9 @@ "> <% if !CurrentUser.is_anonymous? %> - <%= nav_link_to("Discord", discord_get_path, class: "nav-help-discord") %> + <%= custom_image_nav_link_to("Discord", "discord.com.png", discord_get_path, class: "nav-help-discord") %> <% end %> + <%= custom_image_nav_link_to("Subscribestar", "subscribestar.adult.png", subscribestar_path, class: "nav-help-subscribestar") %> <%= nav_link_to("Wiki", wiki_pages_path(title: "help:home"), class: "nav-help-wiki") %> <%= nav_link_to("Help", help_pages_path, class: "nav-help-help") %> <%= nav_link_to("More", site_map_path, class: "nav-help-map") %> diff --git a/app/views/static/subscribestar.html.erb b/app/views/static/subscribestar.html.erb new file mode 100644 index 000000000..40975b8c7 --- /dev/null +++ b/app/views/static/subscribestar.html.erb @@ -0,0 +1,12 @@ +
+
+ +
+ <%= format_text(@page.body, allow_color: true) %> +
+
+
+ +<% content_for(:page_title) do %> + Subscribestar +<% end %> diff --git a/config/routes.rb b/config/routes.rb index da6084b9f..b1080fad0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -476,6 +476,7 @@ Rails.application.routes.draw do get "/static/toggle_mobile_mode" => "static#disable_mobile_mode", as: "disable_mobile_mode" get "/static/theme" => "static#theme", as: "theme" get "/static/avoid_posting" => "static#avoid_posting", as: "avoid_posting_static" + get "/static/subscribestar" => "static#subscribestar", as: "subscribestar" get "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags" root :to => "static#home"