From 07c5ba870023db3ecdd037813db8e679fc27ef72 Mon Sep 17 00:00:00 2001 From: clragon Date: Mon, 3 Feb 2025 17:36:06 +0100 Subject: [PATCH] [UI] Add version indicator in footer (#860) --- app/javascript/src/styles/common/_footer.scss | 122 ++++++++++-------- app/logical/git_helper.rb | 26 +++- app/views/static/_footer.html.erb | 47 ++++--- 3 files changed, 118 insertions(+), 77 deletions(-) diff --git a/app/javascript/src/styles/common/_footer.scss b/app/javascript/src/styles/common/_footer.scss index 79047aa3a..53fe677e4 100644 --- a/app/javascript/src/styles/common/_footer.scss +++ b/app/javascript/src/styles/common/_footer.scss @@ -1,73 +1,83 @@ -footer#page-footer { - display: grid; - grid-template-columns: 1fr 2fr; - gap: 0.5rem 0; - - padding: 0.5rem 0 1rem; - margin: 1rem 0 0; - +footer.footer-wrapper { background: var(--color-foreground); + margin-top: 1rem; + + .footer-grid { + display: grid; + grid-template-columns: min-content min-content; + grid-template-areas: + "logo . " + "left right"; + justify-items: center; + gap: 0.5rem 0; + + width: min-content; + margin: 0 auto; + padding: 1rem; + } + + .footer-logo { + grid-area: logo; + width: 100%; + text-align: right; + + img { + width: 5rem; + height: auto; + + // Aligning the logo with the line below + margin-right: -3.25rem; + + background: themed("color-background") themed("image-background"); + border-radius: 50%; + padding: 0.5rem; + } + } .footer-left, .footer-right { display: flex; flex-flow: column; - gap: 0.25em; - padding: 0 0.5rem; - - font-size: 1.25em; - - a, span { - line-height: 1.25em; - } + box-sizing: border-box; + width: 100%; + gap: 0.25rem; + + font-size: 1rem; + + a, span { white-space: nowrap; } + span { line-height: 1.25em; } } + .footer-left { - align-items: end; - border-right: 1px solid var(--color-section); + grid-area: left; + padding-right: 1rem; + + text-align: right; + border-right: 1px solid var(--color-section-lighten-5); } - - .footer-logo { - grid-column: 1 / -1; - grid-row: 1; - text-align: center; - - img { - width: 5rem; - height: 5rem; - } + .footer-right { + grid-area: right; + padding-left: 1rem; } } -// Desktop -footer#page-footer { - @include window-larger-than(800px) { - grid-template-columns: 1fr min-content 1fr; - - .footer-left, .footer-right { - font-size: unset; - flex-flow: row; - align-items: center; - border: 0; - gap: 0; - - a:not(:last-child)::after { - content: ""; - width: 4px; - height: 4px; - background: white; - display: inline-block; - border-radius: 2px; - margin: 0.125rem 0.5rem; - } - - span.footer-running { display: none; } +// Desktop-ish +footer.footer-wrapper { + @include window-larger-than(450px) { + .footer-grid { + grid-template-areas: "logo left right"; } - .footer-left { justify-content: right; } - .footer-logo { - grid-column: unset; - grid-row: unset; + display: flex; + align-items: center; + padding-right: 2rem; + box-sizing: border-box; + + img { + width: 6rem; + margin-right: unset; + } } } -} \ No newline at end of file +} diff --git a/app/logical/git_helper.rb b/app/logical/git_helper.rb index c59e496b9..fe4db750e 100644 --- a/app/logical/git_helper.rb +++ b/app/logical/git_helper.rb @@ -3,14 +3,27 @@ module GitHelper def self.init if Rails.root.join("REVISION").exist? - @hash = Rails.root.join("REVISION").read.strip + @hash = @tag = Rails.root.join("REVISION").read.strip elsif system("type git > /dev/null && git rev-parse --show-toplevel > /dev/null") @hash = `git rev-parse HEAD`.strip + @tag = `git describe --abbrev=0` else - @hash = "" + @hash = @tag = "" end end + def self.tag + @tag + end + + def self.hash + @hash + end + + def self.version + @tag.presence || short_hash + end + def self.short_hash @hash[0..8] end @@ -18,4 +31,13 @@ module GitHelper def self.commit_url(commit_hash) "#{Danbooru.config.source_code_url}/commit/#{commit_hash}" end + + def self.release_url(tag_name) + "#{Danbooru.config.source_code_url}/releases/tag/#{tag_name}" + end + + def self.version_url + return release_url(@tag) if @tag.present? + commit_url(@hash) + end end diff --git a/app/views/static/_footer.html.erb b/app/views/static/_footer.html.erb index 0654485b4..ff5fbe016 100644 --- a/app/views/static/_footer.html.erb +++ b/app/views/static/_footer.html.erb @@ -1,20 +1,29 @@ -