[UI] Add version indicator in footer (#860)

This commit is contained in:
clragon 2025-02-03 17:36:06 +01:00 committed by GitHub
parent 9cca923ced
commit 07c5ba8700
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 118 additions and 77 deletions

View File

@ -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;
}
}
}
}
}

View File

@ -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

View File

@ -1,20 +1,29 @@
<footer id="page-footer">
<span class="footer-left">
<%= link_to "Rules", terms_of_service_path %>
<%= link_to "Takedowns", takedown_static_path %>
<%= link_to "Privacy", privacy_policy_path %>
<%= link_to "Contact", contact_path %>
<%= link_to "Advertising", help_page_path(id: "advertising") %>
</span>
<span class="footer-logo">
<a href="/"><%= image_pack_tag("main-logo.svg", class: "footer-logo") %></a>
</span>
<span class="footer-right">
<span class="footer-running">Running e621ng</span>
<%= link_to "Themes / Gestures", theme_path %>
<% if CurrentUser.user.enable_keyboard_navigation %>
<%= link_to "Keyboard Shortcuts", keyboard_shortcuts_path %>
<% end %>
<%= link_to disable_mobile_mode? ? "Mobile mode: OFF": "Mobile mode: ON", disable_mobile_mode_path, :rel => "nofollow" %>
</span>
<footer class="footer-wrapper">
<div class="footer-grid">
<span class="footer-logo">
<a href="/"><%= image_pack_tag("main-logo.svg") %></a>
</span>
<span class="footer-left">
<%= link_to "Rules", terms_of_service_path %>
<%= link_to "Takedowns", takedown_static_path %>
<%= link_to "Privacy", privacy_policy_path %>
<%= link_to "Contact", contact_path %>
<%= link_to "Advertising", help_page_path(id: "advertising") %>
</span>
<span class="footer-right">
<span class="footer-running">Running e621ng</span>
<span class="footer-version">
<% if GitHelper.version.empty? %>
v. unknown
<% else %>
v. <%= link_to GitHelper.version, GitHelper.version_url %>
<% end %>
</span>
<%= link_to "Themes / Gestures", theme_path %>
<% if CurrentUser.user.enable_keyboard_navigation %>
<%= link_to "Keyboard Shortcuts", keyboard_shortcuts_path %>
<% end %>
<%= link_to disable_mobile_mode? ? "Mobile mode: OFF": "Mobile mode: ON", disable_mobile_mode_path, :rel => "nofollow" %>
</span>
</div>
</footer>