From 8e813ec0fabace233ab4f5c02e418cb79cafc813 Mon Sep 17 00:00:00 2001 From: Louis Van Steene Date: Wed, 2 Feb 2022 13:49:42 +0000 Subject: [PATCH 1/4] Bump version --- Gemfile.lock | 2 +- lib/spina/admin/journal/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index deeec81..0e6d1aa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - spina-admin-journal (1.0.0.rc2) + spina-admin-journal (1.0.0.rc3) haml-rails (~> 2.0) rails (>= 6.0, < 8) rails-i18n (>= 6.0, < 8) diff --git a/lib/spina/admin/journal/version.rb b/lib/spina/admin/journal/version.rb index 0f005e8..59b5a98 100644 --- a/lib/spina/admin/journal/version.rb +++ b/lib/spina/admin/journal/version.rb @@ -3,7 +3,7 @@ module Spina module Admin module Journal - VERSION = '1.0.0.rc2' + VERSION = '1.0.0.rc3' end end end From 643f3cabbd27e2cd15a6cd8693a16ec207b7fcb6 Mon Sep 17 00:00:00 2001 From: Louis Van Steene Date: Wed, 2 Feb 2022 14:59:44 +0000 Subject: [PATCH 2/4] Use turbo frames to lazy load tabs in editor --- .../admin/journal/articles_controller.rb | 6 ++++- .../spina/admin/journal/authors_controller.rb | 6 ++++- .../admin/journal/institutions_controller.rb | 6 ++++- .../spina/admin/journal/issues_controller.rb | 8 +++++-- .../spina/admin/journal/volumes_controller.rb | 6 ++++- .../journal/articles/_form_authors.html.haml | 5 +++-- .../journal/articles/view_authors.html.haml | 2 ++ .../journal/authors/_form_articles.html.haml | 5 +++-- .../journal/authors/view_articles.html.haml | 2 ++ .../_form_view_affiliations.html.haml | 5 +++-- .../institutions/view_affiliations.html.haml | 2 ++ .../journal/issues/_form_articles.html.haml | 5 +++-- .../journal/issues/view_articles.html.haml | 3 +++ .../journal/volumes/_form_issues.html.haml | 2 +- .../journal/volumes/view_issues.html.haml | 2 ++ config/routes.rb | 22 ++++++++++++++++++- .../spina/admin/journal/articles_test.rb | 4 +++- .../spina/admin/journal/authors_test.rb | 4 +++- .../spina/admin/journal/institutions_test.rb | 4 +++- .../system/spina/admin/journal/issues_test.rb | 4 +++- 20 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 app/views/spina/admin/journal/articles/view_authors.html.haml create mode 100644 app/views/spina/admin/journal/authors/view_articles.html.haml create mode 100644 app/views/spina/admin/journal/institutions/view_affiliations.html.haml create mode 100644 app/views/spina/admin/journal/issues/view_articles.html.haml create mode 100644 app/views/spina/admin/journal/volumes/view_issues.html.haml diff --git a/app/controllers/spina/admin/journal/articles_controller.rb b/app/controllers/spina/admin/journal/articles_controller.rb index c6d8400..030f41f 100644 --- a/app/controllers/spina/admin/journal/articles_controller.rb +++ b/app/controllers/spina/admin/journal/articles_controller.rb @@ -25,7 +25,7 @@ class ArticlesController < ApplicationController before_action :set_breadcrumb before_action :set_tabs, except: %i[index destroy sort] - before_action :set_article, only: %i[edit update destroy] + before_action :set_article, only: %i[edit view_authors update destroy] before_action :set_parts_attributes, only: %i[new edit] before_action :build_parts, only: %i[edit] @@ -43,6 +43,10 @@ def new def edit; end + def view_authors + render layout: false + end + def create # rubocop:disable Metrics/AbcSize @article = Article.new(article_params) sister_articles = Article.where(issue: @article.issue_id) diff --git a/app/controllers/spina/admin/journal/authors_controller.rb b/app/controllers/spina/admin/journal/authors_controller.rb index e04fc79..fe422b6 100644 --- a/app/controllers/spina/admin/journal/authors_controller.rb +++ b/app/controllers/spina/admin/journal/authors_controller.rb @@ -7,7 +7,7 @@ module Journal class AuthorsController < ApplicationController before_action :set_breadcrumb before_action :set_tabs, except: %i[index destroy] - before_action :set_author, only: %i[edit update destroy] + before_action :set_author, only: %i[edit view_articles update destroy] admin_section :journal_settings @@ -23,6 +23,10 @@ def new def edit; end + def view_articles + render layout: false + end + def create @author = Author.new(modified_params) if @author.save diff --git a/app/controllers/spina/admin/journal/institutions_controller.rb b/app/controllers/spina/admin/journal/institutions_controller.rb index 2c4f89e..11e3a23 100644 --- a/app/controllers/spina/admin/journal/institutions_controller.rb +++ b/app/controllers/spina/admin/journal/institutions_controller.rb @@ -7,7 +7,7 @@ module Journal class InstitutionsController < ApplicationController before_action :set_breadcrumb before_action :set_tabs, except: %i[index destroy] - before_action :set_institution, only: %i[edit update destroy] + before_action :set_institution, only: %i[edit view_affiliations update destroy] admin_section :journal_settings @@ -22,6 +22,10 @@ def new def edit; end + def view_affiliations + render layout: false + end + def create @institution = Institution.new(institution_params) diff --git a/app/controllers/spina/admin/journal/issues_controller.rb b/app/controllers/spina/admin/journal/issues_controller.rb index 20cc97e..8e699c6 100644 --- a/app/controllers/spina/admin/journal/issues_controller.rb +++ b/app/controllers/spina/admin/journal/issues_controller.rb @@ -25,8 +25,8 @@ class IssuesController < ApplicationController before_action :set_breadcrumb before_action :set_tabs, except: %i[index destroy sort] - before_action :set_issue, only: %i[edit update destroy] - before_action :set_articles, only: %i[edit update] + before_action :set_issue, only: %i[edit view_articles update destroy] + before_action :set_articles, only: %i[edit view_articles update] before_action :set_parts_attributes, only: %i[new edit] before_action :build_parts, only: %i[edit] @@ -48,6 +48,10 @@ def edit add_breadcrumb t('spina.admin.journal.issues.issue_number', number: @issue.number) end + def view_articles + render layout: false + end + def create # rubocop:disable Metrics/AbcSize @issue = Issue.new(issue_params) sister_issues = Issue.where(volume: @issue.volume_id) diff --git a/app/controllers/spina/admin/journal/volumes_controller.rb b/app/controllers/spina/admin/journal/volumes_controller.rb index bb91491..ef1d29d 100644 --- a/app/controllers/spina/admin/journal/volumes_controller.rb +++ b/app/controllers/spina/admin/journal/volumes_controller.rb @@ -7,7 +7,7 @@ module Journal class VolumesController < ApplicationController before_action :set_breadcrumb before_action :set_tabs, except: %i[index destroy] - before_action :set_volume, only: %i[edit destroy] + before_action :set_volume, only: %i[edit view_issues destroy] admin_section :journal @@ -17,6 +17,10 @@ def index def edit; end + def view_issues + render layout: false + end + def new create end diff --git a/app/views/spina/admin/journal/articles/_form_authors.html.haml b/app/views/spina/admin/journal/articles/_form_authors.html.haml index 4738dfe..d320c98 100644 --- a/app/views/spina/admin/journal/articles/_form_authors.html.haml +++ b/app/views/spina/admin/journal/articles/_form_authors.html.haml @@ -1,2 +1,3 @@ -.-mt-4.md:-mt-8 -= render Spina::Admin::Journal::AuthorshipsListComponent.new(authorships: @article.authorships.sorted_within_article, sortable: true) +- if @article.persisted? + .-mt-4.md:-mt-8 + %turbo-frame#article_authors{ src: spina.view_authors_admin_journal_article_path(@article), loading: 'lazy' } diff --git a/app/views/spina/admin/journal/articles/view_authors.html.haml b/app/views/spina/admin/journal/articles/view_authors.html.haml new file mode 100644 index 0000000..3f91a88 --- /dev/null +++ b/app/views/spina/admin/journal/articles/view_authors.html.haml @@ -0,0 +1,2 @@ +%turbo-frame#article_authors + = render Spina::Admin::Journal::AuthorshipsListComponent.new(authorships: @article.authorships.sorted_within_article, sortable: true) diff --git a/app/views/spina/admin/journal/authors/_form_articles.html.haml b/app/views/spina/admin/journal/authors/_form_articles.html.haml index b2fbc9d..5f2d7f4 100644 --- a/app/views/spina/admin/journal/authors/_form_articles.html.haml +++ b/app/views/spina/admin/journal/authors/_form_articles.html.haml @@ -1,2 +1,3 @@ -.-mt-4.md:-mt-8 -= render Spina::Admin::Journal::ArticlesListComponent.new(articles: @author.affiliations.reduce([]) { |memo, affiliation| memo << affiliation.articles.to_a }.flatten ) +- if @author.persisted? + .-mt-4.md:-mt-8 + %turbo-frame#author_articles{ src: spina.view_articles_admin_journal_author_path(@author), loading: 'lazy' } diff --git a/app/views/spina/admin/journal/authors/view_articles.html.haml b/app/views/spina/admin/journal/authors/view_articles.html.haml new file mode 100644 index 0000000..73f43cf --- /dev/null +++ b/app/views/spina/admin/journal/authors/view_articles.html.haml @@ -0,0 +1,2 @@ +%turbo-frame#author_articles + = render Spina::Admin::Journal::ArticlesListComponent.new(articles: @author.affiliations.reduce([]) { |memo, affiliation| memo << affiliation.articles.to_a }.flatten ) diff --git a/app/views/spina/admin/journal/institutions/_form_view_affiliations.html.haml b/app/views/spina/admin/journal/institutions/_form_view_affiliations.html.haml index 2ef7139..a637990 100644 --- a/app/views/spina/admin/journal/institutions/_form_view_affiliations.html.haml +++ b/app/views/spina/admin/journal/institutions/_form_view_affiliations.html.haml @@ -1,2 +1,3 @@ -.-mt-4.md:-mt-8 -= render Spina::Admin::Journal::AffiliationsListComponent.new(affiliations: @institution.affiliations.sorted) +- if @institution.persisted? + .-mt-4.md:-mt-8 + %turbo-frame#institution_affiliations{ src: spina.view_affiliations_admin_journal_institution_path(@institution), loading: 'lazy' } diff --git a/app/views/spina/admin/journal/institutions/view_affiliations.html.haml b/app/views/spina/admin/journal/institutions/view_affiliations.html.haml new file mode 100644 index 0000000..fe09e2e --- /dev/null +++ b/app/views/spina/admin/journal/institutions/view_affiliations.html.haml @@ -0,0 +1,2 @@ +%turbo-frame#institution_affiliations + = render Spina::Admin::Journal::AffiliationsListComponent.new(affiliations: @institution.affiliations.sorted) diff --git a/app/views/spina/admin/journal/issues/_form_articles.html.haml b/app/views/spina/admin/journal/issues/_form_articles.html.haml index 9822d5a..f9a58e9 100644 --- a/app/views/spina/admin/journal/issues/_form_articles.html.haml +++ b/app/views/spina/admin/journal/issues/_form_articles.html.haml @@ -1,2 +1,3 @@ -.-mt-4.md:-mt-8 -= render Spina::Admin::Journal::ArticlesListComponent.new(articles: @issue.articles, sortable: true) +- if @issue.persisted? + .-mt-4.md:-mt-8 + %turbo-frame#issue_articles{ src: spina.view_articles_admin_journal_issue_path(@issue), loading: 'lazy' } diff --git a/app/views/spina/admin/journal/issues/view_articles.html.haml b/app/views/spina/admin/journal/issues/view_articles.html.haml new file mode 100644 index 0000000..a774e24 --- /dev/null +++ b/app/views/spina/admin/journal/issues/view_articles.html.haml @@ -0,0 +1,3 @@ +%turbo-frame#issue_articles + = render Spina::Admin::Journal::ArticlesListComponent.new(articles: @issue.articles, sortable: true) + diff --git a/app/views/spina/admin/journal/volumes/_form_issues.html.haml b/app/views/spina/admin/journal/volumes/_form_issues.html.haml index c059087..eabf743 100644 --- a/app/views/spina/admin/journal/volumes/_form_issues.html.haml +++ b/app/views/spina/admin/journal/volumes/_form_issues.html.haml @@ -1,2 +1,2 @@ .-mt-4.md:-mt-8 -= render Spina::Admin::Journal::IssuesListComponent.new(issues: @volume.issues, sortable: true) +%turbo-frame#volume_issues{ src: spina.view_issues_admin_journal_volume_path(@volume), loading: 'lazy' } diff --git a/app/views/spina/admin/journal/volumes/view_issues.html.haml b/app/views/spina/admin/journal/volumes/view_issues.html.haml new file mode 100644 index 0000000..3e6743d --- /dev/null +++ b/app/views/spina/admin/journal/volumes/view_issues.html.haml @@ -0,0 +1,2 @@ +%turbo-frame#volume_issues + = render Spina::Admin::Journal::IssuesListComponent.new(issues: @volume.issues, sortable: true) diff --git a/config/routes.rb b/config/routes.rb index 469ad66..ebd3764 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,18 +6,38 @@ resources :journals, only: %i[edit update destroy] resources :volumes, except: %i[show update] do post 'sort/:journal_id' => 'volumes#sort', as: :sort, on: :collection + + member do + get :view_issues + end end resources :issues, except: %i[show] do post 'sort/:volume_id' => 'issues#sort', as: :sort, on: :collection + + member do + get :view_articles + end end resources :articles, except: %i[show] do post 'sort/:issue_id' => 'articles#sort', as: :sort, on: :collection + + member do + get :view_authors + end end resources :authors, except: %i[show] do post 'sort/:article_id' => 'authors#sort', as: :sort, on: :collection + + member do + get :view_articles + end end - resources :institutions, except: %i[show] + resources :institutions, except: %i[show] do + member do + get :view_affiliations + end + end resources :licences, except: %i[show] end end diff --git a/test/system/spina/admin/journal/articles_test.rb b/test/system/spina/admin/journal/articles_test.rb index e6c6ad5..5940474 100644 --- a/test/system/spina/admin/journal/articles_test.rb +++ b/test/system/spina/admin/journal/articles_test.rb @@ -29,7 +29,9 @@ class ArticlesTest < ApplicationSystemTestCase # check that authors list is empty click_on 'Authors' - assert_text 'There are no items' + within '#authors' do + assert_no_text + end click_on 'Save article' assert_text 'Article saved' diff --git a/test/system/spina/admin/journal/authors_test.rb b/test/system/spina/admin/journal/authors_test.rb index b35e231..4596381 100644 --- a/test/system/spina/admin/journal/authors_test.rb +++ b/test/system/spina/admin/journal/authors_test.rb @@ -26,7 +26,9 @@ class AuthorsTest < ApplicationSystemTestCase # check that articles list is empty click_on 'Articles' - assert_text 'There are no items.' + within '#articles' do + assert_no_text + end click_on 'Save author' assert_text 'Author saved.' diff --git a/test/system/spina/admin/journal/institutions_test.rb b/test/system/spina/admin/journal/institutions_test.rb index 23a10d6..9edba46 100644 --- a/test/system/spina/admin/journal/institutions_test.rb +++ b/test/system/spina/admin/journal/institutions_test.rb @@ -24,7 +24,9 @@ class InstitutionsTest < ApplicationSystemTestCase # check that affiliations list is empty click_button 'Affiliations', class: 'bg-transparent' - assert_text 'There are no items.' + within '#view_affiliations' do + assert_no_text + end click_on 'Save institution' assert_text 'Institution saved.' diff --git a/test/system/spina/admin/journal/issues_test.rb b/test/system/spina/admin/journal/issues_test.rb index 3481bc4..b5419a9 100644 --- a/test/system/spina/admin/journal/issues_test.rb +++ b/test/system/spina/admin/journal/issues_test.rb @@ -26,7 +26,9 @@ class IssuesTest < ApplicationSystemTestCase # check that articles list is empty click_button 'Articles', class: 'bg-transparent' - assert_text 'There are no items.' + within '#articles' do + assert_no_text + end click_on 'Save issue' assert_text 'Issue saved' From 0161b4c5e249792814edc54144e96112cfbd0e2d Mon Sep 17 00:00:00 2001 From: Louis Van Steene Date: Wed, 2 Feb 2022 15:02:33 +0000 Subject: [PATCH 3/4] Silence linter warnings --- .rubocop.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index be996e8..75c906b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,3 +16,8 @@ AllCops: Lint/MissingSuper: Exclude: - app/components/**/* + +Metrics/BlockLength: + Exclude: + - config/routes.rb + - spina-admin-journal.gemspec From f068314d31470c2da16c8262af3929db52e7f772 Mon Sep 17 00:00:00 2001 From: Louis Van Steene Date: Wed, 2 Feb 2022 15:36:08 +0000 Subject: [PATCH 4/4] Update README --- README.md | 84 ++++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 282bb47..c8d1bb3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Spina::Admin::Journal +*Journal* is a plugin for [Spina](https://www.spinacms.com/) that provides a fully-fledged journal management package, intended to provide a more streamlined, easy-to-use, modern alternative to [OJS](https://pkp.sfu.ca/ojs/). + +Spina is a content management system built in [Ruby on Rails](http://rubyonrails.org/). *Journal* augments Spina by providing an admin interface for managing an academic journal. + ![Rails tests](https://github.com/louis-vs/spina-admin-journal/workflows/Verify/badge.svg?branch=master&event=push) [![codecov](https://codecov.io/gh/louis-vs/spina-admin-journal/branch/master/graph/badge.svg?token=9TZ9QGGLAH)](https://codecov.io/gh/louis-vs/spina-admin-journal) [![CodeFactor](https://www.codefactor.io/repository/github/louis-vs/spina-admin-journal/badge)](https://www.codefactor.io/repository/github/louis-vs/spina-admin-journal) @@ -7,69 +11,48 @@ [![Code quality: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/louis-vs/spina-admin-journal.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/louis-vs/spina-admin-journal/context:javascript) [![Inline docs](http://inch-ci.org/github/louis-vs/spina-admin-journal.svg?branch=master)](http://inch-ci.org/github/louis-vs/spina-admin-journal) -*Journal* is a plugin for [Spina](https://www.spinacms.com/), a content management system built in [Ruby on Rails](http://rubyonrails.org/). *Journal* augments Spina by providing an admin interface for managing an academic journal. - -## Usage - -The plugin adds two menus to Spina's primary navigation: - -* **Journal settings** provides access to global properties of the journal. It is divided into 3 submenus: - * **Journal** allows you to change the name of the journal. - * **Institutions** allows you to add institutions, to which authors can be affiliated. - * **Authors** allows you to add authors, who can then be added to articles. -* The **journal content** menu will be named after the journal as specified in Journal Settings. It provides a means of editing the content of the journal and is divided into three submenus: - * **Volumes** allows you to add and remove volumes of the journal, and edit their respective issues. - * **Issues** allows you to add, edit and remove issues of particular volumes of the journal, and edit their respective articles. - * **Articles** allows you to add, edit and remove articles belonging to particular issues. +## Features -The plugin does not provide any public-facing frontend. However, an example implementation can be found at **[TBC]**. +The journal plugin covers many of the needs of a professional online journal publication, including: -**NB this plugin is currently a work in progress**: please wait until an official release to use this plugin in production. +- Simple, responsive, intuitive interface that builds upon Spina's own. +- Seamlessly integrate published content with other information about the journal. +- Manage volumes, issues, articles and authors in a highly structured and organised manner. +- Keep track of individual authors with multiple affiliations, e.g. if they change name or institution, connecting with [ORCID](https://orcid.org/). -## Installation - -### From scratch - -Make sure you have a working installation of Ruby on Rails 6.1. You can find a setup guide [here](https://guides.rubyonrails.org/getting_started.html). - -Then run: - -```bash -$ rails new your-app --database=postgresql -$ cd your-app -$ bin/rails db:create -$ bin/rails active_storage:install -``` +Currently, a submissions management system is not included, but this is planned for a future release. This will allow you to manage the submissions process for the journal in a streamlined manner in parallel to publication. -Add this line to your new application's Gemfile: +## Usage -```ruby -gem 'spina', '~> 2.0' -``` +The plugin adds two menus to Spina's primary navigation: -And then execute: +- **Journal settings** provides access to global properties of the journal. It is divided into 3 submenus: + - **Journal** allows you to change metadata such as the name of the journal, as well as content that will appear on the journal homepage. + - **Institutions** allows you to add institutions, to which authors can be affiliated. + - **Authors** allows you to add authors and their affiliations, which can then be added to articles. + - **Licences** allows you to add licences and association information, which can be associated with individual articles, representing the licence under which the content is released. +- The **journal content** menu will be named after the journal as specified in Journal Settings. It provides a means of editing the content of the journal and is divided into three submenus: + - **Volumes** allows you to add and remove volumes of the journal, and edit their respective issues. + - **Issues** allows you to add, edit and remove issues of particular volumes of the journal, and edit their respective articles. + - **Articles** allows you to add, edit and remove articles belonging to particular issues. -```bash -$ bundle install -``` +**NB:** This release of the plugin does not provide any public-facing frontend or Spina theme. An example implementation can be found within the [Conferences Primer Theme](https://github.com/louis-vs/spina-conferences-primer_theme-fork). Note that this theme also contains frontends for two other Spina plugins, [Spina Conferences Blog](https://github.com/louis-vs/spina-admin-conferences-blog) and [Spina Admin Conferences](https://github.com/louis-vs/spina-admin-conferences-fork/). You can use the theme in your project as is, or copy whichever parts of the code you need. -Run the Spina install generator: +A dedicated journal theme, coupled with an automatic installer, is being planned. A system to manage submissions is also on the roadmap. -```bash -$ bin/rails g spina:install -``` +## Installation -And follow the prompts. Once this is complete, follow the instructions below. +Make sure you have a working installation of Ruby on Rails 7. You can find a setup guide [here](https://guides.rubyonrails.org/getting_started.html). -### For existing Spina installations +You then need to install Spina, following the guide [on the Spina website](https://spinacms.com/docs). -Add this line to your application's Gemfile: +To install the plugin, add this line to your application's Gemfile: ```ruby -gem 'spina-admin-journal', '~> 0.1' +gem 'spina-admin-journal', '~> 1.0' ``` -And then execute: +Then execute: ```bash $ bundle install @@ -78,7 +61,7 @@ $ bundle install You'll then need to install and run the migrations for the journal: ```bash -$ bin/rails spina_admin_journal_engine:install:migrations +$ bin/rails spina_admin_journal:install:migrations $ bin/rails db:migrate ``` @@ -94,6 +77,11 @@ You can manually populate the database from within the app, or alternatively you Bug reports and feature requests are welcome in the [Issues](https://github.com/louis-vs/spina-admin-journal/issues) section. Translations are also very welcome! +### Planned features + +- [ ] Submissions management +- [ ] Translations + ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).