Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rails Compatibility Page #103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

@import "partials/basics";
@import "partials/compat-table";
@import "partials/compat-cell";
@import "partials/email-notification";

@import "pages/gemmies-index";
Expand Down
24 changes: 24 additions & 0 deletions app/assets/stylesheets/partials/_compat-cell.scss
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/partials/_compat-table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ table.compat-table {
color: $green;
}
}
}
}
6 changes: 6 additions & 0 deletions app/controllers/rails_releases_controller.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions app/controllers/sitemaps_controller.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions app/helpers/lockfiles_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module LockfilesHelper
def head_title
if @lockfile
"Compatibility for Gemfile.lock##{@lockfile.slug}"
else
super
end
end
end
16 changes: 16 additions & 0 deletions app/helpers/rails_releases_helper.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/models/rails_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 4 additions & 11 deletions app/views/gemmies/compat_table.html.haml
Original file line number Diff line number Diff line change
@@ -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 } }
Expand All @@ -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
Expand All @@ -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}"})"
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%html
%head
%title
RailsBump
= head_title

= csrf_meta_tags
= csp_meta_tag
Expand Down
63 changes: 63 additions & 0 deletions app/views/rails_releases/show.html.haml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions app/views/shared/_compat_cell.html.haml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
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"

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
Expand Down
6 changes: 6 additions & 0 deletions config/sitemap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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