diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index d2b21d7..dc8e00b 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -16,6 +16,7 @@ @import "partials/basics"; @import "partials/compat-table"; +@import "partials/compat-cell"; @import "partials/email-notification"; @import "pages/gemmies-index"; diff --git a/app/assets/stylesheets/partials/_compat-cell.scss b/app/assets/stylesheets/partials/_compat-cell.scss new file mode 100644 index 0000000..61a09e1 --- /dev/null +++ b/app/assets/stylesheets/partials/_compat-cell.scss @@ -0,0 +1,24 @@ +body.rails_releases { + h2 { + font-size: 1em; + } + section.checking { + color: $yellow; + } + + section.incompatible { + color: $red; + } + + section.compatible { + color: $green; + } + + section.more { + margin-top: 8px; + } + + section.details { + margin-top: 2em; + } +} diff --git a/app/assets/stylesheets/partials/_compat-table.scss b/app/assets/stylesheets/partials/_compat-table.scss index 718624e..472ad40 100644 --- a/app/assets/stylesheets/partials/_compat-table.scss +++ b/app/assets/stylesheets/partials/_compat-table.scss @@ -22,4 +22,4 @@ table.compat-table { color: $green; } } -} +} \ No newline at end of file diff --git a/app/controllers/rails_releases_controller.rb b/app/controllers/rails_releases_controller.rb new file mode 100644 index 0000000..12e7deb --- /dev/null +++ b/app/controllers/rails_releases_controller.rb @@ -0,0 +1,6 @@ +class RailsReleasesController < ApplicationController + def show + @gemmy = Gemmy.find_by!(name: params[:gemmy_id]) + @rails_release = RailsRelease.find_by!(version: params[:id].gsub("rails-", "").gsub("-", ".")) + end +end \ No newline at end of file diff --git a/app/controllers/sitemaps_controller.rb b/app/controllers/sitemaps_controller.rb new file mode 100644 index 0000000..cd6aab1 --- /dev/null +++ b/app/controllers/sitemaps_controller.rb @@ -0,0 +1,14 @@ +# app/controllers/sitemaps_controller.rb +class SitemapsController < ApplicationController + require "open-uri" + + def show + sitemap_url = ENV["FOG_URL"] + if sitemap_url.present? + sitemap_content = URI.open("#{sitemap_url}/sitemap.xml").read + send_data sitemap_content, type: "application/xml", disposition: "inline" + else + head :not_found + end + end +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ad7e3a0..3290528 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -73,4 +73,8 @@ def compats_label_and_text(compats, gemmy, rails_release) "#{text}." ] end + + def head_title + "RailsBump.org: Rails Compatibility Checker Tool" + end end diff --git a/app/helpers/lockfiles_helper.rb b/app/helpers/lockfiles_helper.rb new file mode 100644 index 0000000..88b2831 --- /dev/null +++ b/app/helpers/lockfiles_helper.rb @@ -0,0 +1,9 @@ +module LockfilesHelper + def head_title + if @lockfile + "Compatibility for Gemfile.lock##{@lockfile.slug}" + else + super + end + end +end diff --git a/app/helpers/rails_releases_helper.rb b/app/helpers/rails_releases_helper.rb new file mode 100644 index 0000000..c65ce97 --- /dev/null +++ b/app/helpers/rails_releases_helper.rb @@ -0,0 +1,16 @@ +module RailsReleasesHelper + def head_title + if @gemmy + if @rails_release + "#{@gemmy} gem: Compatibility with #{@rails_release}" + else + rails_releases = RailsRelease.order(:version) + first_version = rails_releases.first.version + last_version = rails_releases.last.version + "#{@gemmy} gem: Compatibility with Rails #{first_version} to #{last_version}" + end + else + super + end + end +end diff --git a/app/models/rails_release.rb b/app/models/rails_release.rb index 2267519..384914f 100644 --- a/app/models/rails_release.rb +++ b/app/models/rails_release.rb @@ -76,6 +76,10 @@ def github_actions_sanity_check! client.workflow_dispatch(GITHUB_REPO, GITHUB_WORKFLOW, GITHUB_REF, inputs: github_action_inputs) end + def to_param + "rails-#{version.to_s.gsub(".", "-")}" + end + private # Define the github_action_inputs for the workflow diff --git a/app/views/gemmies/compat_table.html.haml b/app/views/gemmies/compat_table.html.haml index f8b8169..57bd299 100644 --- a/app/views/gemmies/compat_table.html.haml +++ b/app/views/gemmies/compat_table.html.haml @@ -1,6 +1,6 @@ - hide_gem_name = local_assigns.fetch(:hide_gem_name) { false } - stimulus_controller = "compat-table" -- rails_releases = RailsRelease.order(:version) +- rails_releases = local_assigns.key?(:rails_release) ? RailsRelease.where(id: local_assigns.fetch(:rails_release).id) : RailsRelease.order(:version) = async_turbo_frame :compat_table, src: [:compat_table, :gemmies, { gemmy_ids: gemmies.pluck(:id).join(","), hide_gem_name: hide_gem_name }.compact_blank], target: "_top" do %table.compat-table.table.table-striped{ data: { controller: stimulus_controller } } @@ -10,7 +10,7 @@ - unless hide_gem_name %th{ rowspan: 2 } Gem - %th{ colspan: RailsRelease.count } + %th{ colspan: rails_releases.count } = link_to "Show earlier Rails versions", "#", class: "float-end", data: { action: "#{stimulus_controller}#toggleEarlierRailsVersions" } Compatible with... %tr @@ -37,12 +37,5 @@ - label, text = compats_label_and_text(rails_release_compats, gemmy, rails_release) %td{ **cell_params } - %span{ data: { bs_toggle: "tooltip", bs_placement: "bottom", bs_title: text } } - - case status - - when :checking - %i.fas.fa-spinner.fa-pulse - - when :compatible - %i.far.fa-thumbs-up - - else - %i.far.fa-thumbs-down - = label + = render "shared/compat_cell", status: status, label: label, text: text + = "(#{link_to "more", gemmy_rails_release_path(gemmy, rails_release), title: "#{gemmy} gem: Compatibility with Rails #{rails_release.version}"})" diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f53e632..cc2c2ee 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -3,7 +3,7 @@ %html %head %title - RailsBump + = head_title = csrf_meta_tags = csp_meta_tag diff --git a/app/views/rails_releases/show.html.haml b/app/views/rails_releases/show.html.haml new file mode 100644 index 0000000..637e326 --- /dev/null +++ b/app/views/rails_releases/show.html.haml @@ -0,0 +1,63 @@ +%section + + %h1 + Gem + = @gemmy.name + + %p + Indexed versions: + = @gemmy.versions.size + - if @gemmy.versions.any? + = surround "(", ")" do + = [@gemmy.versions.first, (@gemmy.versions.last if @gemmy.versions.many?)].compact.join(" ... ") + • + = link_to "Show on RubyGems.org", "https://rubygems.org/gems/#{@gemmy.name}", target: "_blank" + + %h2 + = "Compatibility with Rails: #{@rails_release.version}:" + + - compats = @gemmy.compats + - rails_release_compats = compats.merge(@rails_release.compats) + - status = compats_status(rails_release_compats) + - label, text = compats_label_and_text(rails_release_compats, @gemmy, @rails_release) + + %section{ class: status } + = render "shared/compat_cell", status: status, label: label, text: text + + %section.more + = link_to "Show compatibility with other Rails versions", gemmy_path(@gemmy) + +%section.details + %h3 + Gem Details + %p= "This section describes the dependencies associated with each version of the #{@gemmy} gem. ❤️" + %table.compat-table.table.table-striped + %thead + %tr + %th= "#{@gemmy} version" + %th Dependencies + %tbody + - @gemmy.dependencies_and_versions.sort_by { |k, v| v }.each do |dependencies, version| + %tr + %td= version + %td= dependencies + + %section.details + %h3 + Compatibility Details + %p + This section is meant to be used for debugging compatibility issues. If you see anything that is unexpected, please share this page with the maintainers. ❤️ + %table.compat-table.table.table-striped + %thead + %tr + %th Status Determined By + %th Status + %th Checked At + %th Dependencies + %tbody + - compats.each do |compat| + %tr + %td= compat.status_determined_by + %td= compat.status + %td= compat.checked_at + %td= compat.dependencies \ No newline at end of file diff --git a/app/views/shared/_compat_cell.html.haml b/app/views/shared/_compat_cell.html.haml new file mode 100644 index 0000000..44a29e8 --- /dev/null +++ b/app/views/shared/_compat_cell.html.haml @@ -0,0 +1,9 @@ +%span{ data: { bs_toggle: "tooltip", bs_placement: "bottom", bs_title: text } } + - case status + - when :checking + %i.fas.fa-spinner.fa-pulse + - when :compatible + %i.far.fa-thumbs-up + - else + %i.far.fa-thumbs-down + = label \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9fcfe26..23f4909 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,7 @@ Rails.application.routes.draw do mount Sidekiq::Web => "sidekiq" - get '/sitemap.xml', to: redirect(ENV["FOG_URL"]) + get '/sitemap.xml', to: 'sitemaps#show' get "/robots.txt" => "static#robots" root "gemmies#index" @@ -22,6 +22,8 @@ get "up" => "rails/health#show", as: :rails_health_check resources :gemmies, path: "gems", only: %i(show new create) do + resources :rails_releases, path: "compatibility", only: %i(show) + collection do get :compat_table end diff --git a/config/sitemap.rb b/config/sitemap.rb index a3e32dc..147d450 100644 --- a/config/sitemap.rb +++ b/config/sitemap.rb @@ -21,6 +21,8 @@ sitemaps_path: "" } +rails_releases = RailsRelease.order(:version).to_a + SitemapGenerator::Sitemap.create opts do # Add static paths add root_path, changefreq: "daily", priority: 1.0 @@ -30,5 +32,9 @@ # Add dynamic paths for all gemmies Gemmy.find_each do |gemmy| add gemmy_path(gemmy), lastmod: gemmy.last_checked_at, changefreq: "weekly", priority: 0.8 + + rails_releases.each do |rails_release| + add gemmy_rails_release_path(gemmy, rails_release) + end end end \ No newline at end of file