Skip to content

Commit

Permalink
Add version to user-agent, footer and about page
Browse files Browse the repository at this point in the history
  • Loading branch information
renatolond committed Nov 12, 2024
1 parent d7b6019 commit b8012b3
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/objects/retro_meet_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def login(login:, password:)
def retromeet_core_host = @retromeet_core_host ||= Async::HTTP::Endpoint.parse("http://localhost:3000")

# @return [Hash] Base headers to be used for requests
def base_headers = @base_headers ||= { "Content-Type" => "application/json" }.freeze
def base_headers = @base_headers ||= { "Content-Type" => "application/json", "User-Agent": RetroMeet::Version.user_agent }.freeze

# @return [Async::HTTP::Client]
def client = Async::HTTP::Client.new(retromeet_core_host)
Expand Down
65 changes: 65 additions & 0 deletions app/objects/retromeet/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# frozen_string_literal: true

module RetroMeet
# This module contains functions to build the retromeet web version to be used around programatically
# Should be modified when releasing to indicate the proper versions
module Version
class << self
# The major part of the version
# @return [Integer]
def major
0
end

# The minor part of the version
# @return [Integer]
def minor
1
end

# The patch part of the version
# @return [Integer]
def patch
0
end

# The default prerelease name
# @return [String]
def default_prerelease
"alpha.1"
end

# The prerelease name, takes the +RETROMEET_VERSION_PRERELEASE+ environment variable into consideration
# @return [String]
def prerelease
ENV["RETROMEET_VERSION_PRERELEASE"].presence || default_prerelease
end

# The build metadata, should be used to indicate a fork or other special build condition
# Takes the +RETROMEET_VERSION_METADATA+ environment variable into consideration
# @return [String,nil]
def build_metadata
ENV.fetch("RETROMEET_VERSION_METADATA", nil)
end

# @return [Array<String>]
def to_a
[major, minor, patch].compact
end

# @return [String]
def to_s
components = [to_a.join(".")]
components << "-#{prerelease}" if prerelease.present?
components << "+#{build_metadata}" if build_metadata.present?
components.join
end

# @return [String]
def user_agent
# TODO: (renatolond, 2024-10-31): properly build the address of the server
@user_agent ||= "RetroMeet-web/#{Version} (async-http #{Async::HTTP::VERSION}; +http#{false ? "s" : ""}://localhost:3000/)"
end
end
end
end
5 changes: 2 additions & 3 deletions app/views/application/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
%img.image{:alt => "", :src => "https://bulma.io/images/bulma-logo.png", :width => "96px"}/
%div
%ul.is-flex.is-flex-wrap-wrap.is-align-items-center.is-justify-content-center
%li.mr-4
%a{:href => "#"} About
%li.mr-4= link_to t("about"), about_path
%li.mr-4= link_to t("terms"), terms_path
%li.mr-4= link_to t("privacy_policy"), privacy_path
%hr
Expand All @@ -17,7 +16,7 @@
%p
Powered by
%a{href: "https://join.retromeet.social", target: "_blank"}
RetroMeet
RetroMeet #{RetroMeet::Version}
&#169; 2024, RetroMeet contributors.
.py-2.is-hidden-tablet
.ml-auto
Expand Down
5 changes: 5 additions & 0 deletions app/views/home/about.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.container
%h1.title.has-text-centered About us
%p
%strong> Version
\: #{RetroMeet::Version}
7 changes: 7 additions & 0 deletions config/initializers/zeitwerk.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

Rails.autoloaders.each do |autoloader|
autoloader.inflector.inflect(
"retromeet" => "RetroMeet"
)
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

get "terms" => "home#terms"
get "privacy" => "home#privacy"
get "about" => "home#about"

# Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb)
# get "manifest" => "rails/pwa#manifest", as: :pwa_manifest
Expand Down

0 comments on commit b8012b3

Please sign in to comment.