From cf7d9b21ef3411e984a25af0bfb0a4865816362f Mon Sep 17 00:00:00 2001 From: Olivier Lacan Date: Mon, 9 Nov 2015 02:57:56 +0100 Subject: [PATCH 1/2] Add change log links to gem page This adds a new changelog column to the linksets table and displays that change log alongside the existing linkset links. I originally wrote this with @jaymcgavren but had to recommit because of really bad rebase clusterpoop. I hope you forgive me, Jay. --- app/models/linkset.rb | 2 +- app/models/rubygem.rb | 1 + config/locales/en.yml | 2 ++ db/migrate/20151109014752_add_changelog_to_linksets.rb | 5 +++++ db/schema.rb | 3 ++- test/factories.rb | 1 + test/unit/rubygem_test.rb | 2 ++ 7 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20151109014752_add_changelog_to_linksets.rb diff --git a/app/models/linkset.rb b/app/models/linkset.rb index e1f042f194e..1baec6fee28 100644 --- a/app/models/linkset.rb +++ b/app/models/linkset.rb @@ -1,7 +1,7 @@ class Linkset < ActiveRecord::Base belongs_to :rubygem - LINKS = %w(home code docs wiki mail bugs).freeze + LINKS = %w(home wiki docs mail code bugs changelog).freeze LINKS.each do |url| validates_formatting_of url.to_sym, diff --git a/app/models/rubygem.rb b/app/models/rubygem.rb index f2fb55a211a..58a30e9cbf6 100644 --- a/app/models/rubygem.rb +++ b/app/models/rubygem.rb @@ -156,6 +156,7 @@ def payload(version = versions.most_recent, protocol = Gemcutter::PROTOCOL, host 'mailing_list_uri' => linkset.try(:mail), 'source_code_uri' => linkset.try(:code), 'bug_tracker_uri' => linkset.try(:bugs), + 'changelog_uri' => linkset.try(:changelog), 'dependencies' => { 'development' => deps.select { |r| r.rubygem && 'development' == r.scope }, 'runtime' => deps.select { |r| r.rubygem && 'runtime' == r.scope } diff --git a/config/locales/en.yml b/config/locales/en.yml index ab6ecb08b92..906820fdfc4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -133,6 +133,7 @@ en: report_abuse: Report Abuse badge: Badge rss: RSS + changelog: Change Log versions_header: Versions bundler_header: Gemfile show_all_versions: "Show all versions (%{count} total)" @@ -185,6 +186,7 @@ en: docs: Documentation URL mail: Mailing List URL wiki: Wiki URL + changelog: Changelog URL session: who: Email or Handle password: Password diff --git a/db/migrate/20151109014752_add_changelog_to_linksets.rb b/db/migrate/20151109014752_add_changelog_to_linksets.rb new file mode 100644 index 00000000000..147fbc0aeb3 --- /dev/null +++ b/db/migrate/20151109014752_add_changelog_to_linksets.rb @@ -0,0 +1,5 @@ +class AddChangelogToLinksets < ActiveRecord::Migration + def change + add_column :linksets, :changelog, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 2711384e14b..598901a5349 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150709170542) do +ActiveRecord::Schema.define(version: 20151109014752) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -72,6 +72,7 @@ t.string "bugs" t.datetime "created_at" t.datetime "updated_at" + t.string "changelog" end add_index "linksets", ["rubygem_id"], name: "index_linksets_on_rubygem_id", using: :btree diff --git a/test/factories.rb b/test/factories.rb index 074ce5291f8..55b57550374 100644 --- a/test/factories.rb +++ b/test/factories.rb @@ -38,6 +38,7 @@ mail 'http://example.com' code 'http://example.com' bugs 'http://example.com' + changelog 'http://example.com' end factory :ownership do diff --git a/test/unit/rubygem_test.rb b/test/unit/rubygem_test.rb index f27d6ca3c07..bdec9391ec2 100644 --- a/test/unit/rubygem_test.rb +++ b/test/unit/rubygem_test.rb @@ -464,6 +464,7 @@ class RubygemTest < ActiveSupport::TestCase assert_equal @rubygem.linkset.mail, hash["mailing_list_uri"] assert_equal @rubygem.linkset.code, hash["source_code_uri"] assert_equal @rubygem.linkset.bugs, hash["bug_tracker_uri"] + assert_equal @rubygem.linkset.bugs, hash["changelog_uri"] end should "return version documentation url if linkset docs is empty" do @@ -483,6 +484,7 @@ class RubygemTest < ActiveSupport::TestCase assert_equal @rubygem.linkset.mail, doc.at_css("mailing-list-uri").content assert_equal @rubygem.linkset.code, doc.at_css("source-code-uri").content assert_equal @rubygem.linkset.bugs, doc.at_css("bug-tracker-uri").content + assert_equal @rubygem.linkset.changelog, doc.at_css("changelog-uri").content end end end From c849d1ba8de3147cc7f77e7ea39c851f94be36c9 Mon Sep 17 00:00:00 2001 From: Olivier Lacan Date: Thu, 26 Jan 2017 08:23:22 +0100 Subject: [PATCH 2/2] Reorganize links to place changelog second My justification for this is that the changelog link is more news-worthy perhaps. Feel free to discuss. --- app/models/linkset.rb | 2 +- db/schema.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/linkset.rb b/app/models/linkset.rb index 1baec6fee28..8670f2d68ec 100644 --- a/app/models/linkset.rb +++ b/app/models/linkset.rb @@ -1,7 +1,7 @@ class Linkset < ActiveRecord::Base belongs_to :rubygem - LINKS = %w(home wiki docs mail code bugs changelog).freeze + LINKS = %w(home changelog code docs wiki mail bugs).freeze LINKS.each do |url| validates_formatting_of url.to_sym, diff --git a/db/schema.rb b/db/schema.rb index a693e33d738..82ddb952f36 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,6 +12,7 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20161231080902) do + # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" enable_extension "hstore"