diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index b799c4cd5531195ff95a46b0b93270f9d8f16403..a1900da4356dad2a31e6c2c3374110a83ecc6a9d 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -35,7 +35,7 @@ class Communication::Website::Page < ApplicationRecord include WithSlug - include Communication::Website::WithGithub + include WithGithub belongs_to :university belongs_to :website, diff --git a/app/models/communication/website/post.rb b/app/models/communication/website/post.rb index 31e70ca1c3f82a8a43867ae0714556e13c23095b..88e15c76fd928f91cd4a6da6975002621289daa1 100644 --- a/app/models/communication/website/post.rb +++ b/app/models/communication/website/post.rb @@ -28,7 +28,7 @@ # class Communication::Website::Post < ApplicationRecord include WithSlug - include Communication::Website::WithGithub + include WithGithub has_rich_text :text has_one_attached_deletable :featured_image diff --git a/app/models/communication/website/with_github.rb b/app/models/concerns/with_github.rb similarity index 90% rename from app/models/communication/website/with_github.rb rename to app/models/concerns/with_github.rb index f7d243914cfd64e68dcd8e6fb0170689fd77a512..e19f825e4c0dc492c5ff51e92e63fe5193c8dae0 100644 --- a/app/models/communication/website/with_github.rb +++ b/app/models/concerns/with_github.rb @@ -1,4 +1,4 @@ -module Communication::Website::WithGithub +module WithGithub extend ActiveSupport::Concern included do @@ -34,5 +34,5 @@ module Communication::Website::WithGithub data: to_jekyll update_column :github_path, github_path_generated end - handle_asynchronously :publish_to_github + # handle_asynchronously :publish_to_github end diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb index 20a415c655deaf08befa1c4a77cf15c2faa94b1f..896c54bcc1d38402822b94a04aa308c973139484 100644 --- a/app/models/research/journal/article.rb +++ b/app/models/research/journal/article.rb @@ -4,6 +4,7 @@ # # id :uuid not null, primary key # abstract :text +# github_path :text # keywords :text # published_at :date # references :text @@ -47,6 +48,10 @@ class Research::Journal::Article < ApplicationRecord "/assets/articles/#{id}/#{pdf.filename}" end + def website + journal.website + end + def to_s "#{ title }" end diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb index 86e614af0bd4b353689968fb0b3a9ffe9c159fe1..ce5f8aa08374f17b00bab6835efc58528d66a12b 100644 --- a/app/models/research/journal/volume.rb +++ b/app/models/research/journal/volume.rb @@ -4,6 +4,7 @@ # # id :uuid not null, primary key # description :text +# github_path :text # keywords :text # number :integer # published_at :date @@ -24,12 +25,12 @@ # fk_rails_... (university_id => universities.id) # class Research::Journal::Volume < ApplicationRecord + include WithGithub + belongs_to :university belongs_to :journal, foreign_key: :research_journal_id has_many :articles, foreign_key: :research_journal_volume_id - after_commit :publish_to_github - has_one_attached :cover scope :ordered, -> { order(number: :desc, published_at: :desc) } @@ -38,25 +39,25 @@ class Research::Journal::Volume < ApplicationRecord "/assets/img/volumes/#{id}#{cover.filename.extension_with_delimiter}" end + def website + journal.website + end + def to_s "##{ number } #{ title }" end protected - def publish_to_github - github.publish kind: :volumes, - file: "#{id}.md", - title: title, - data: ApplicationController.render( - template: 'admin/research/journal/volumes/jekyll', - layout: false, - assigns: { volume: self } - ) - github.send_file cover, cover_path if cover.attached? + def github_path_generated + "_volumes/#{id}.html" end - def github - @github ||= Github.with_site(journal.website) + def to_jekyll + ApplicationController.render( + template: 'admin/research/journal/volumes/jekyll', + layout: false, + assigns: { volume: self } + ) end end diff --git a/app/models/research/researcher.rb b/app/models/research/researcher.rb index 8504f16ae1c86961be821ca8cd2e5b3e05e3b6da..6b85efede27a16e94b22e46452cd9e03b07e7c62 100644 --- a/app/models/research/researcher.rb +++ b/app/models/research/researcher.rb @@ -2,13 +2,14 @@ # # Table name: research_researchers # -# id :uuid not null, primary key -# biography :text -# first_name :string -# last_name :string -# created_at :datetime not null -# updated_at :datetime not null -# user_id :uuid +# id :uuid not null, primary key +# biography :text +# first_name :string +# github_path :text +# last_name :string +# created_at :datetime not null +# updated_at :datetime not null +# user_id :uuid # # Indexes # diff --git a/app/services/github.rb b/app/services/github.rb index 15962abe47c96b4919129a7c77e9e40ebd9c5ae1..5f029c5d9b5c0db061680b7e867e1fe21103a445 100644 --- a/app/services/github.rb +++ b/app/services/github.rb @@ -2,7 +2,7 @@ class Github attr_reader :access_token, :repository def self.with_site(site) - new site.access_token, site.repository + new site&.access_token, site&.repository end def initialize(access_token, repository) diff --git a/db/migrate/20211023153416_add_github_path_to_volumes_and_articles_and_researchers.rb b/db/migrate/20211023153416_add_github_path_to_volumes_and_articles_and_researchers.rb new file mode 100644 index 0000000000000000000000000000000000000000..9708358994a1317c59278439c59e6a79c201dd89 --- /dev/null +++ b/db/migrate/20211023153416_add_github_path_to_volumes_and_articles_and_researchers.rb @@ -0,0 +1,7 @@ +class AddGithubPathToVolumesAndArticlesAndResearchers < ActiveRecord::Migration[6.1] + def change + add_column :research_journal_articles, :github_path, :text + add_column :research_journal_volumes, :github_path, :text + add_column :research_researchers, :github_path, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index a4a75857998a9eb096dd2752b68d93fcd027ffba..3449b82fb60eba5f9e7a8bb8ecb61da08a20bc48 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_10_23_063050) do +ActiveRecord::Schema.define(version: 2021_10_23_153416) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -272,6 +272,7 @@ ActiveRecord::Schema.define(version: 2021_10_23_063050) do t.text "abstract" t.text "references" t.text "keywords" + t.text "github_path" t.index ["research_journal_id"], name: "index_research_journal_articles_on_research_journal_id" t.index ["research_journal_volume_id"], name: "index_research_journal_articles_on_research_journal_volume_id" t.index ["university_id"], name: "index_research_journal_articles_on_university_id" @@ -295,6 +296,7 @@ ActiveRecord::Schema.define(version: 2021_10_23_063050) do t.datetime "updated_at", precision: 6, null: false t.text "description" t.text "keywords" + t.text "github_path" t.index ["research_journal_id"], name: "index_research_journal_volumes_on_research_journal_id" t.index ["university_id"], name: "index_research_journal_volumes_on_university_id" end @@ -318,6 +320,7 @@ ActiveRecord::Schema.define(version: 2021_10_23_063050) do t.uuid "user_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.text "github_path" t.index ["user_id"], name: "index_research_researchers_on_user_id" end