spina-conferences-primer_theme-fork 0.9.1 → 1.0.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -4
  3. data/Rakefile +6 -0
  4. data/app/assets/builds/spina/conferences/primer_theme/application.css +25964 -0
  5. data/app/assets/config/spina_conferences_primer_theme_manifest.js +7 -4
  6. data/app/assets/javascripts/spina/conferences/primer_theme/application.js +6 -7
  7. data/app/assets/javascripts/spina/conferences/primer_theme/controllers/application.js +10 -0
  8. data/app/assets/javascripts/spina/conferences/primer_theme/controllers/index.js +5 -0
  9. data/app/assets/javascripts/spina/conferences/primer_theme/controllers/{slideshow_controller.es6 → slideshow_controller.js} +4 -3
  10. data/app/assets/stylesheets/spina/conferences/primer_theme/application.sass +1 -1
  11. data/app/controllers/spina/conferences/primer_theme/blog/application_controller.rb +2 -0
  12. data/app/controllers/spina/conferences/primer_theme/blog/categories_controller.rb +0 -2
  13. data/app/controllers/spina/conferences/primer_theme/blog/posts_controller.rb +5 -7
  14. data/app/controllers/spina/conferences/primer_theme/conferences/application_controller.rb +17 -0
  15. data/app/controllers/spina/conferences/primer_theme/conferences/conferences_controller.rb +14 -13
  16. data/app/controllers/spina/conferences/primer_theme/conferences/presentations_controller.rb +2 -1
  17. data/app/controllers/spina/conferences/primer_theme/journal/application_controller.rb +16 -0
  18. data/app/controllers/spina/conferences/primer_theme/journal/articles_controller.rb +15 -7
  19. data/app/controllers/spina/conferences/primer_theme/journal/authors_controller.rb +48 -0
  20. data/app/controllers/spina/conferences/primer_theme/journal/issues_controller.rb +12 -5
  21. data/app/helpers/spina/conferences/primer_theme/application_helper.rb +33 -14
  22. data/app/helpers/spina/conferences/primer_theme/asset_helper.rb +10 -2
  23. data/app/helpers/spina/conferences/primer_theme/navigations_helper.rb +11 -1
  24. data/app/models/spina/parts/conferences/primer_theme/checkbox.rb +6 -2
  25. data/app/models/spina/parts/conferences/primer_theme.rb +9 -3
  26. data/app/views/conferences_primer_theme/pages/about.html.haml +14 -14
  27. data/app/views/conferences_primer_theme/pages/committee.html.haml +13 -12
  28. data/app/views/conferences_primer_theme/pages/embedded_form.html.haml +2 -2
  29. data/app/views/conferences_primer_theme/pages/events.html.haml +3 -3
  30. data/app/views/conferences_primer_theme/pages/homepage.html.haml +2 -2
  31. data/app/views/conferences_primer_theme/pages/information.html.haml +2 -2
  32. data/app/views/conferences_primer_theme/pages/journal_information.html.haml +10 -0
  33. data/app/views/conferences_primer_theme/pages/periodical.html.haml +10 -10
  34. data/app/views/conferences_primer_theme/pages/show.html.haml +1 -1
  35. data/app/views/conferences_primer_theme/partials/_event.html.haml +2 -2
  36. data/app/views/conferences_primer_theme/partials/_homepage_item.html.haml +2 -2
  37. data/app/views/layouts/conferences_primer_theme/application.html.haml +1 -1
  38. data/app/views/layouts/spina/conferences/primer_theme/application.html.haml +7 -14
  39. data/app/views/layouts/spina/conferences/primer_theme/journal/articles.html.haml +3 -0
  40. data/app/views/layouts/spina/conferences/primer_theme/journal/authors.html.haml +5 -0
  41. data/app/views/layouts/spina/conferences/primer_theme/journal/issues.html.haml +3 -0
  42. data/app/views/spina/application/_admin_bar.html.haml +7 -0
  43. data/app/views/spina/application/_alert.html.haml +4 -0
  44. data/app/views/spina/application/_analytics.html.erb +10 -0
  45. data/app/views/spina/application/{_footer_content.html.haml → _cookies_footer.html.haml} +1 -1
  46. data/app/views/spina/application/_footer.html.haml +20 -12
  47. data/app/views/spina/application/_google_site_verification.html.haml +1 -0
  48. data/app/views/spina/application/_journal_navigation.html.haml +17 -0
  49. data/app/views/spina/application/_mobile_navigation_items.html.haml +0 -3
  50. data/app/views/spina/application/_navigation.html.haml +0 -3
  51. data/app/views/spina/application/_text.html.haml +1 -1
  52. data/app/views/spina/conferences/primer_theme/blog/categories/show.html.haml +3 -3
  53. data/app/views/spina/conferences/primer_theme/blog/posts/_post.html.haml +4 -3
  54. data/app/views/spina/conferences/primer_theme/blog/posts/index.html.haml +3 -3
  55. data/app/views/spina/conferences/primer_theme/blog/posts/show.html.haml +8 -8
  56. data/app/views/spina/conferences/primer_theme/blog/shared/_sidebar.html.haml +1 -1
  57. data/app/views/spina/conferences/primer_theme/conferences/conferences/_conference.html.haml +2 -2
  58. data/app/views/spina/conferences/primer_theme/conferences/conferences/_event.html.haml +6 -6
  59. data/app/views/spina/conferences/primer_theme/conferences/conferences/_events.html.haml +1 -1
  60. data/app/views/spina/conferences/primer_theme/conferences/conferences/_header.html.haml +4 -4
  61. data/app/views/spina/conferences/primer_theme/conferences/conferences/_presentation.html.haml +4 -4
  62. data/app/views/spina/conferences/primer_theme/conferences/conferences/_presentations.html.haml +4 -4
  63. data/app/views/spina/conferences/primer_theme/conferences/conferences/_submission_flash.html.haml +3 -3
  64. data/app/views/spina/conferences/primer_theme/conferences/conferences/index.html.haml +3 -3
  65. data/app/views/spina/conferences/primer_theme/conferences/conferences/show.html.haml +5 -5
  66. data/app/views/spina/conferences/primer_theme/conferences/presentations/_abstract.html.haml +1 -1
  67. data/app/views/spina/conferences/primer_theme/conferences/presentations/_attachments.html.haml +1 -1
  68. data/app/views/spina/conferences/primer_theme/conferences/presentations/show.html.haml +3 -3
  69. data/app/views/spina/conferences/primer_theme/journal/articles/_authorship.html.haml +8 -6
  70. data/app/views/spina/conferences/primer_theme/journal/articles/_metadata.html.haml +7 -7
  71. data/app/views/spina/conferences/primer_theme/journal/articles/show.html.haml +24 -26
  72. data/app/views/spina/conferences/primer_theme/journal/authors/_author.html.haml +9 -0
  73. data/app/views/spina/conferences/primer_theme/journal/authors/index.html.haml +10 -0
  74. data/app/views/spina/conferences/primer_theme/journal/authors/show.html.haml +20 -0
  75. data/app/views/spina/conferences/primer_theme/journal/issues/_article.html.haml +6 -6
  76. data/app/views/spina/conferences/primer_theme/journal/issues/_issue.html.haml +10 -9
  77. data/app/views/spina/conferences/primer_theme/journal/issues/index.html.haml +27 -23
  78. data/app/views/spina/conferences/primer_theme/journal/issues/show.html.haml +31 -21
  79. data/config/initializers/importmap.rb +21 -0
  80. data/config/initializers/mime_types.rb +3 -1
  81. data/config/initializers/primer.rb +1 -1
  82. data/config/initializers/themes/conferences_primer_theme.rb +14 -2
  83. data/config/locales/en.yml +23 -33
  84. data/config/routes.rb +7 -3
  85. data/db/migrate/20210206170704_change_current_conference_alert_to_text.rb +1 -1
  86. data/lib/spina/conferences/primer_theme/breadcrumbs/builder.rb +4 -17
  87. data/lib/spina/conferences/primer_theme/engine.rb +7 -3
  88. data/lib/spina/conferences/primer_theme/version.rb +1 -1
  89. data/lib/spina/conferences/primer_theme.rb +10 -3
  90. metadata +62 -33
  91. data/app/views/spina/application/_current_conference_alert.html.haml +0 -4
@@ -1,9 +1,12 @@
1
- //= link_directory ../stylesheets/spina/conferences/primer_theme .css
2
- //= link_directory ../javascripts/spina/conferences/primer_theme .js
3
- //= link spina_admin_conferences_manifest.js
4
- //= link spina_admin_journal_manifest.js
1
+ //= link spina/conferences/primer_theme/application.css
2
+
3
+ //= link_directory ../javascripts/spina/conferences/primer_theme/controllers .js
4
+ //= link spina/conferences/primer_theme/application.js
5
5
 
6
6
  //= link @github/details-dialog-element/dist/index.js
7
7
  //= link @github/include-fragment-element/dist/index.js
8
8
  //= link @github/filter-input-element/dist/index.js
9
9
  //= link @github/details-menu-element/dist/index.js
10
+
11
+ //= link spina_admin_conferences_manifest.js
12
+ //= link spina_admin_journal_manifest.js
@@ -1,7 +1,6 @@
1
- //= require stimulus
2
- //= require_directory ./controllers
3
-
4
- // eslint-disable-next-line no-undef
5
- const application = Stimulus.Application.start()
6
- // eslint-disable-next-line no-undef
7
- application.register('slideshow', SlideshowController)
1
+ import '@hotwired/turbo-rails'
2
+ import '@github/details-dialog-element'
3
+ import '@github/include-fragment-element'
4
+ import '@github/filter-input-element'
5
+ import '@github/details-menu-element'
6
+ import 'controllers'
@@ -0,0 +1,10 @@
1
+ import { Application } from '@hotwired/stimulus'
2
+
3
+ const application = Application.start()
4
+
5
+ // Configure Stimulus
6
+ application.warnings = true
7
+ application.debug = false
8
+ window.Stimulus = application
9
+
10
+ export { application }
@@ -0,0 +1,5 @@
1
+ import { application } from 'controllers/application'
2
+
3
+ // Eager load all Stimulus controllers
4
+ import { eagerLoadControllersFrom } from '@hotwired/stimulus-loading'
5
+ eagerLoadControllersFrom('controllers', application)
@@ -1,5 +1,6 @@
1
- // eslint-disable-next-line no-unused-vars,no-undef
2
- class SlideshowController extends Stimulus.Controller {
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class SlideshowController extends Controller {
3
4
  static get targets() {
4
5
  return [
5
6
  /**
@@ -35,7 +36,7 @@ class SlideshowController extends Stimulus.Controller {
35
36
  * @return {Number} The value for the delay.
36
37
  */
37
38
  get delay() {
38
- return this.data.has('delay')
39
+ return this.data.has('delay')
39
40
  ? Number.parseInt(this.data.get('delay'))
40
41
  : 10000
41
42
  }
@@ -28,7 +28,7 @@
28
28
  font-display: swap
29
29
 
30
30
  .admin
31
- @import "spina/admin_editing"
31
+ //@import "spina/admin_editing"
32
32
  #admin_bar
33
33
  font-family: 'Metropolis', sans-serif
34
34
 
@@ -4,8 +4,10 @@ module Spina
4
4
  module Conferences
5
5
  module PrimerTheme
6
6
  module Blog
7
+ # Base class from which controllers related to the blog plugin inherit
7
8
  class ApplicationController < ::Spina::ApplicationController
8
9
  include ::Spina::Frontend
10
+
9
11
  def cookies_info
10
12
  render partial: 'cookies'
11
13
  end
@@ -6,8 +6,6 @@ module Spina
6
6
  module Blog
7
7
  # Spina::Blog::CategoriesController
8
8
  class CategoriesController < ApplicationController
9
- include ::Spina::Frontend
10
-
11
9
  before_action :page
12
10
  before_action :category
13
11
  before_action :posts
@@ -6,8 +6,6 @@ module Spina
6
6
  module Blog
7
7
  # Spina::Blog::PostsController
8
8
  class PostsController < ApplicationController
9
- include ::Spina::Frontend
10
-
11
9
  before_action :find_posts, only: [:index]
12
10
  before_action :current_spina_user_can_view_page?
13
11
  before_action :set_breadcrumb, only: :show
@@ -36,9 +34,9 @@ module Spina
36
34
 
37
35
  def archive
38
36
  @posts = Spina::Admin::Conferences::Blog::Post.live
39
- .where(published_at: start_date..end_date)
40
- .order(published_at: :desc)
41
- .page(params[:page])
37
+ .where(published_at: start_date..end_date)
38
+ .order(published_at: :desc)
39
+ .page(params[:page])
42
40
 
43
41
  render layout: theme_layout
44
42
  end
@@ -63,7 +61,7 @@ module Spina
63
61
 
64
62
  def find_posts
65
63
  @posts = Spina::Admin::Conferences::Blog::Post.available.live.order(published_at: :desc)
66
- .page(params[:page])
64
+ .page(params[:page])
67
65
  end
68
66
 
69
67
  def try_redirect
@@ -80,7 +78,7 @@ module Spina
80
78
  end
81
79
 
82
80
  def set_metadata
83
- @title = @post.seo_title.blank? ? @post.title : @post.seo_title
81
+ @title = @post.seo_title.presence || @post.title
84
82
  @description = @post.description
85
83
  end
86
84
  end
@@ -6,9 +6,26 @@ module Spina
6
6
  module Conferences
7
7
  # Base class from which controllers inherit
8
8
  class ApplicationController < Spina::ApplicationController
9
+ before_action :journal_accessible?
10
+
9
11
  def cookies_info
10
12
  render partial: 'cookies'
11
13
  end
14
+
15
+ private
16
+
17
+ def page
18
+ @page ||= Spina::Page.find_or_create_by name: 'conferences' do |page|
19
+ page.title = 'Conferences'
20
+ page.link_url = '/conferences/conferences'
21
+ page.deletable = false
22
+ page.view_template = 'blank'
23
+ end
24
+ end
25
+
26
+ def journal_accessible?
27
+ raise ActiveRecord::RecordNotFound unless current_spina_user.present? || page.live?
28
+ end
12
29
  end
13
30
  end
14
31
  end
@@ -6,7 +6,8 @@ module Spina
6
6
  module Conferences
7
7
  # User-facing controller for conferences, serving both html and ics
8
8
  class ConferencesController < ApplicationController
9
- before_action :set_conference, :set_tab, :set_presentation_type, :set_presentations, :set_breadcrumb, only: :show
9
+ before_action :set_conference, :set_tab, :set_presentation_type, :set_presentations, :set_breadcrumb,
10
+ only: :show
10
11
  before_action :set_metadata
11
12
 
12
13
  def index
@@ -30,7 +31,7 @@ module Spina
30
31
  def set_conference
31
32
  @conference = Admin::Conferences::Conference.includes(:events, :institutions,
32
33
  presentation_types: [:translations],
33
- presentations: [session: [:room], presenters: [:institution]])
34
+ presentations: [session: [:room], presenters: [:institution]]) # rubocop:disable Layout/LineLength
34
35
  .find(params[:id])
35
36
  @conference.view_context = view_context
36
37
  rescue ActiveRecord::RecordNotFound
@@ -42,28 +43,28 @@ module Spina
42
43
  end
43
44
 
44
45
  def set_presentation_type
45
- if params[:presentation_type].present?
46
- @presentation_type = @conference.presentation_types
47
- .includes(presentations: [session: [:room], presenters: [:institution]])
48
- .find(params[:presentation_type])
49
- end
46
+ return if params[:presentation_type].blank?
47
+
48
+ @presentation_type = @conference.presentation_types
49
+ .includes(presentations: [session: [:room], presenters: [:institution]])
50
+ .find(params[:presentation_type])
50
51
  end
51
52
 
52
53
  def set_presentations
53
54
  @presentations = if @presentation_type.present?
54
- @presentation_type.presentations.page(params[:page]).per(15)
55
- else
56
- @conference.presentations.page(params[:page]).per(15)
57
- end
55
+ @presentation_type.presentations.page(params[:page]).per(15)
56
+ else
57
+ @conference.presentations.page(params[:page]).per(15)
58
+ end
58
59
  end
59
60
 
60
61
  def set_breadcrumb
61
- add_breadcrumb 'Blog', frontend_conferences_path
62
+ add_breadcrumb Admin::Conferences::Conference.model_name.human.pluralize, frontend_conferences_path
62
63
  end
63
64
 
64
65
  def set_metadata
65
66
  @title = @conference.present? ? @conference.name : Admin::Conferences::Conference.model_name.human(count: 0)
66
- @description = @conference.present? && @conference.has_content?(:text) ? helpers.strip_tags(@conference.content(:text)) : ''
67
+ @description = @conference.present? && @conference.has_content?(:text) ? helpers.strip_tags(@conference.content(:text)) : '' # rubocop:disable Layout/LineLength
67
68
  end
68
69
  end
69
70
  end
@@ -19,7 +19,8 @@ module Spina
19
19
  private
20
20
 
21
21
  def set_presentation
22
- @presentation = Admin::Conferences::Presentation.includes(:presenters, attachments: [attachment_type: [:translations]])
22
+ @presentation = Admin::Conferences::Presentation.includes(:presenters,
23
+ attachments: [attachment_type: [:translations]])
23
24
  .find(params[:id])
24
25
  rescue ActiveRecord::RecordNotFound
25
26
  send_file Rails.root.join('public/404.html'), type: 'text/html; charset=utf-8', status: 404
@@ -6,6 +6,22 @@ module Spina
6
6
  module Journal
7
7
  # Base class from which controllers related to the journal plugin inherit
8
8
  class ApplicationController < Spina::ApplicationController
9
+ before_action :journal_accessible?
10
+
11
+ private
12
+
13
+ def page
14
+ @page ||= Spina::Page.find_or_create_by name: 'journal' do |page|
15
+ page.title = 'Journal'
16
+ page.link_url = '/journal/issues'
17
+ page.deletable = false
18
+ page.view_template = 'blank'
19
+ end
20
+ end
21
+
22
+ def journal_accessible?
23
+ raise ActiveRecord::RecordNotFound unless current_spina_user.present? || page.live?
24
+ end
9
25
  end
10
26
  end
11
27
  end
@@ -6,7 +6,8 @@ module Spina
6
6
  module Journal
7
7
  # User-facing controller for journal articles
8
8
  class ArticlesController < ApplicationController
9
- before_action :set_article, :set_issue, :set_journal, :set_licence, :set_breadcrumb, :set_metadata, :require_admin_for_invisible_article
9
+ before_action :set_volume, :set_issue, :set_article, :set_journal, :set_licence,
10
+ :set_breadcrumb, :set_metadata, :require_admin_for_invisible_article
10
11
 
11
12
  def show
12
13
  respond_to do |format|
@@ -24,13 +25,19 @@ module Spina
24
25
  private
25
26
 
26
27
  def set_article
27
- @article = Admin::Journal::Article.includes(affiliations: [:institution]).find(params[:id])
28
+ @article = @issue.articles.includes(affiliations: [:institution]).find_by!(number: params[:number])
28
29
  rescue ActiveRecord::RecordNotFound
29
30
  send_file Rails.root.join('public/404.html'), type: 'text/html; charset=utf-8', status: 404
30
31
  end
31
32
 
32
33
  def set_issue
33
- @issue = Admin::Journal::Issue.includes(:volume, :articles).find(params[:issue_id])
34
+ @issue = @volume.issues.includes(:volume, :articles).find_by!(number: params[:issue_number])
35
+ rescue ActiveRecord::RecordNotFound
36
+ send_file Rails.root.join('public/404.html'), type: 'text/html; charset=utf-8', status: 404
37
+ end
38
+
39
+ def set_volume
40
+ @volume = Admin::Journal::Volume.includes(:issues).find_by!(number: params[:volume_number])
34
41
  rescue ActiveRecord::RecordNotFound
35
42
  send_file Rails.root.join('public/404.html'), type: 'text/html; charset=utf-8', status: 404
36
43
  end
@@ -46,10 +53,11 @@ module Spina
46
53
  def set_breadcrumb
47
54
  return if @issue.blank?
48
55
 
49
- add_breadcrumb @journal.name, frontend_issues_path
50
- add_breadcrumb Admin::Journal::Issue.model_name.human.pluralize, frontend_issues_path
51
- add_breadcrumb t('spina.conferences.primer_theme.journal.volume_issue', volume_number: @issue.volume.number, issue_number: @issue.number),
52
- frontend_issue_path(@issue.id)
56
+ add_breadcrumb helpers.journal_abbreviation_or_name(@journal), frontend_issues_path
57
+ # add_breadcrumb Admin::Journal::Issue.model_name.human.pluralize, frontend_issues_path
58
+ add_breadcrumb t('spina.conferences.primer_theme.journal.volume_issue', volume_number: @issue.volume.number,
59
+ issue_number: @issue.number),
60
+ frontend_volume_issue_path(@issue.volume.number, @issue.number)
53
61
  end
54
62
 
55
63
  def set_metadata
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Conferences
5
+ module PrimerTheme
6
+ module Journal
7
+ # User-facing controller for authors
8
+ class AuthorsController < ApplicationController
9
+ before_action :set_journal, :set_breadcrumb
10
+ before_action :set_author, only: :show
11
+ before_action :set_metadata
12
+
13
+ def index
14
+ @authors = Admin::Journal::Author.all.sort do |a, b|
15
+ a.primary_affiliation.name <=> b.primary_affiliation.name
16
+ end
17
+ end
18
+
19
+ def show
20
+ add_breadcrumb @author.primary_affiliation.name
21
+ end
22
+
23
+ private
24
+
25
+ def set_journal
26
+ @journal = Admin::Journal::Journal.instance
27
+ end
28
+
29
+ def set_author
30
+ @author = Admin::Journal::Author.includes(:affiliations, :articles).find(params[:id])
31
+ rescue ActiveRecord::RecordNotFound
32
+ send_file Rails.root.join('public/404.html'), type: 'text/html; charset=utf-8', status: 404
33
+ end
34
+
35
+ def set_metadata
36
+ @title = @journal.name
37
+ @description = ActionView::Base.full_sanitizer.sanitize(@journal.content(:description))
38
+ end
39
+
40
+ def set_breadcrumb
41
+ add_breadcrumb helpers.journal_abbreviation_or_name(@journal), frontend_issues_path
42
+ add_breadcrumb Admin::Journal::Author.model_name.human(count: :many), frontend_authors_path
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -7,7 +7,7 @@ module Spina
7
7
  # User-facing controller for journal issues
8
8
  class IssuesController < ApplicationController
9
9
  before_action :set_journal
10
- before_action :set_issue, :set_breadcrumb, only: :show
10
+ before_action :set_volume, :set_issue, only: :show
11
11
  before_action :set_metadata
12
12
 
13
13
  def index
@@ -22,7 +22,8 @@ module Spina
22
22
 
23
23
  def show
24
24
  @articles = current_spina_user.present? ? @issue.articles : @issue.articles.visible
25
- add_breadcrumb t('spina.conferences.primer_theme.journal.volume_issue', volume_number: @issue.volume.number, issue_number: @issue.number)
25
+ add_breadcrumb t('spina.conferences.primer_theme.journal.volume_issue',
26
+ volume_number: @issue.volume.number, issue_number: @issue.number)
26
27
  end
27
28
 
28
29
  private
@@ -32,14 +33,20 @@ module Spina
32
33
  end
33
34
 
34
35
  def set_issue
35
- @issue = Admin::Journal::Issue.includes(:volume, :articles).find(params[:id])
36
+ @issue = @volume.issues.includes(:volume, :articles).find_by!(number: params[:number])
37
+ rescue ActiveRecord::RecordNotFound
38
+ send_file Rails.root.join('public/404.html'), type: 'text/html; charset=utf-8', status: 404
39
+ end
40
+
41
+ def set_volume
42
+ @volume = Admin::Journal::Volume.includes(:issues).find_by!(number: params[:volume_number])
36
43
  rescue ActiveRecord::RecordNotFound
37
44
  send_file Rails.root.join('public/404.html'), type: 'text/html; charset=utf-8', status: 404
38
45
  end
39
46
 
40
47
  def set_breadcrumb
41
- add_breadcrumb @journal.name, frontend_issues_path
42
- add_breadcrumb Admin::Journal::Issue.model_name.human.pluralize, frontend_issues_path
48
+ add_breadcrumb helpers.journal_abbreviation_or_name(@journal), frontend_issues_path
49
+ # add_breadcrumb Admin::Journal::Issue.model_name.human.pluralize, frontend_issues_path
43
50
  end
44
51
 
45
52
  def set_metadata
@@ -9,34 +9,53 @@ module Spina
9
9
 
10
10
  # Because the upper bound is exclusive a conference is current the day after it ends
11
11
  def current_conference
12
- Spina::Admin::Conferences::Conference.order(dates: :asc).find_by('upper(dates) >= ?', Date.today)
12
+ Spina::Admin::Conferences::Conference.order(dates: :asc).find_by('upper(dates) >= ?', Time.zone.today)
13
13
  end
14
14
 
15
- def ancestors
15
+ def journal_abbreviation_or_name(journal)
16
+ journal.content(:journal_abbreviation) && journal.content(:journal_abbreviation).empty? ? journal.name : journal.content(:journal_abbreviation) # rubocop:disable Layout/LineLength
17
+ end
18
+
19
+ def ancestors # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
16
20
  return [] if current_page.blank?
17
21
 
18
- render Primer::BreadcrumbComponent.new(mb: 4) do |component|
22
+ render Primer::Beta::Breadcrumbs.new(mb: 4) do |component|
23
+ if current_page.resource&.name = 'journal'
24
+ component.item(href: frontend_issues_path) do
25
+ journal_abbreviation_or_name(Spina::Admin::Journal::Journal.instance)
26
+ end
27
+ end
19
28
  current_page.ancestors.each do |ancestor|
20
29
  component.item(href: ancestor.materialized_path) { ancestor.menu_title }
21
30
  end
22
- component.item(selected: true) { current_page.menu_title }
31
+ component.item(href: current_page.materialized_path) { current_page.menu_title }
23
32
  end
24
33
  end
25
34
 
26
- def calendar(name:)
35
+ def calendar(name:, &block)
27
36
  Icalendar::Calendar.new
28
- .tap { |calendar| calendar.x_wr_calname = name }
29
- .tap { |calendar| yield(calendar) }
30
- .tap(&:publish)
31
- .then(&:to_ical)
37
+ .tap { |calendar| calendar.x_wr_calname = name }
38
+ .tap(&block)
39
+ .tap(&:publish)
40
+ .then(&:to_ical)
32
41
  end
33
42
 
34
43
  def generate_datetime(date, time)
35
- Time.new(date.year,
36
- date.month,
37
- date.day,
38
- time.hour,
39
- time.min)
44
+ Time.zone.local(date.year,
45
+ date.month,
46
+ date.day,
47
+ time.hour,
48
+ time.min)
49
+ end
50
+
51
+ def primer_theme_importmap_tags(entry_point = 'application', shim: true)
52
+ safe_join [
53
+ javascript_inline_importmap_tag(Spina::Conferences::PrimerTheme.config.importmap.to_json(resolver: self)),
54
+ javascript_importmap_module_preload_tags(Spina::Conferences::PrimerTheme.config.importmap),
55
+ (javascript_importmap_shim_nonce_configuration_tag if shim),
56
+ (javascript_importmap_shim_tag if shim),
57
+ javascript_import_module_tag(entry_point)
58
+ ], "\n"
40
59
  end
41
60
  end
42
61
  end
@@ -27,7 +27,9 @@ module Spina
27
27
  DEFAULT_FACTORS = [1, 2, 3, 4].freeze
28
28
 
29
29
  def variants_for(image, variant_options:, factors:)
30
- factors.inject({}) { |srcset, factor| srcset.update(variant_url(image, variant_options, factor) => "#{factor}x") }
30
+ factors.inject({}) do |srcset, factor|
31
+ srcset.update(variant_url(image, variant_options, factor) => "#{factor}x")
32
+ end
31
33
  end
32
34
 
33
35
  def variant_url(image, variant_options, factor)
@@ -39,7 +41,13 @@ module Spina
39
41
  end
40
42
 
41
43
  def resize_dimensions_for_key(key, factor, dimensions)
42
- METHODS_TO_RESIZE.include?(key) ? dimensions.collect { |dimension| resize_dimension(dimension, factor) } : dimensions
44
+ if METHODS_TO_RESIZE.include?(key)
45
+ dimensions.collect do |dimension|
46
+ resize_dimension(dimension, factor)
47
+ end
48
+ else
49
+ dimensions
50
+ end
43
51
  end
44
52
 
45
53
  def resize_dimension(dimension = 0, factor = 0)
@@ -13,10 +13,20 @@ module Spina
13
13
  @footer_navigation_items ||= live_navigation_items('footer')
14
14
  end
15
15
 
16
+ def journal_navigation_items
17
+ @journal_navigation_items ||= live_resource_navigation_items('journal')
18
+ end
19
+
16
20
  private
17
21
 
18
22
  def live_navigation_items(name)
19
- ::Spina::NavigationItem.joins(:navigation).where(spina_navigations: { name: name }).roots.regular_pages.in_menu.live.sorted
23
+ ::Spina::NavigationItem.joins(:navigation)
24
+ .where(spina_navigations: { name: name })
25
+ .roots.regular_pages.in_menu.live.sorted
26
+ end
27
+
28
+ def live_resource_navigation_items(name)
29
+ ::Spina::Resource.find_by(name: name)&.pages&.roots&.in_menu&.live&.sorted || []
20
30
  end
21
31
  end
22
32
  end
@@ -1,11 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spina
2
4
  module Parts
3
5
  module Conferences
4
6
  module PrimerTheme
7
+ # A simplistic checkbox part, e.g. to indicate whether an item should
8
+ # show or not.
5
9
  class Checkbox < Spina::Parts::Base
6
10
  # Booleans don't work nicely with Spina page parts, so we have this mess
7
- CHECKED_VALUE = "1"
8
- UNCHECKED_VALUE = "0"
11
+ CHECKED_VALUE = '1'
12
+ UNCHECKED_VALUE = '0'
9
13
 
10
14
  attr_json :content, :string, default: UNCHECKED_VALUE
11
15
  end
@@ -1,7 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spina
2
- module Parts::Conferences::PrimerTheme
3
- def self.table_name_prefix
4
- 'spina_parts_conferences_primer_theme_'
4
+ module Parts
5
+ module Conferences
6
+ module PrimerTheme # rubocop:disable Style/Documentation
7
+ def self.table_name_prefix
8
+ 'spina_parts_conferences_primer_theme_'
9
+ end
10
+ end
5
11
  end
6
12
  end
7
13
  end
@@ -1,20 +1,20 @@
1
1
  - cache current_page do
2
- = render(Primer::HeadingComponent.new) { current_page.title }
2
+ = render(Primer::HeadingComponent.new(tag: :h1)) { current_page.title }
3
3
 
4
4
  - if content(:text).present?
5
- = render(Primer::MarkdownComponent.new(mt: 4)) { content.html(:text) }
5
+ = render(Primer::Markdown.new(mt: 4)) { content.html(:text).to_s }
6
6
  - if content(:contact).present?
7
7
  = render Primer::SubheadComponent.new(mt: 4) do |component|
8
8
  = component.heading { t :'.contact.title' }
9
- = render(Primer::MarkdownComponent.new) { content.html(:contact) }
9
+ = render(Primer::Markdown.new) { content.html(:contact).to_s }
10
10
 
11
11
  .clearfix.gutter
12
12
  = render Primer::BoxComponent.new(mt: 4, col: [12, nil, 6, nil], float: [nil, nil, :left, nil]) do
13
13
  = render Primer::SubheadComponent.new do |component|
14
14
  = component.heading { t :'.constitution.title' }
15
15
  - if content(:constitution).present?
16
- = render Primer::FlexComponent.new(align_items: :center, py: 1) do
17
- = render Primer::FlexItemComponent.new(flex_auto: true, pr: 1) do
16
+ = render Primer::BoxComponent.new(display: :flex, align_items: :center, py: 1) do
17
+ = render Primer::BoxComponent.new(flex: :auto, pr: 1) do
18
18
  = t :'.constitution.uploaded',
19
19
  date: l(Spina::Attachment.find(content(:constitution).attachment_id).created_at.to_date, format: :long)
20
20
  = render Primer::ButtonComponent.new(tag: :a, href: content.attachment_url(:constitution), ml: 2, download: '') do
@@ -30,7 +30,7 @@
30
30
  %ul
31
31
  - repeater :minutes do |minutes_entry|
32
32
  %li.list-style-none.py-1.d-flex.flex-items-center
33
- = render Primer::FlexItemComponent.new(flex_auto: true) do
33
+ = render Primer::BoxComponent.new(flex: :auto) do
34
34
  - if minutes_entry.content(:date).present?
35
35
  = t(:'.minutes.minutes_for_html', date: time_tag(minutes_entry.content(:date)))
36
36
  - else
@@ -41,7 +41,7 @@
41
41
  = render Primer::OcticonComponent.new('desktop-download')
42
42
  = t(:'.minutes.download')
43
43
  - else
44
- = render(Primer::TextComponent.new(color: :text_secondary, font_size: 6)) { t :'.minutes.no_file' }
44
+ = render(Primer::Beta::Text.new(color: :muted, font_size: 6)) { t :'.minutes.no_file' }
45
45
  - else
46
46
  = render Primer::BlankslateComponent.new(title: t(:'.minutes.no_minutes'), icon: 'file')
47
47
 
@@ -52,13 +52,13 @@
52
52
  %ul
53
53
  - repeater :documents do |document|
54
54
  %li.list-style-none.py-1.d-flex.flex-items-center
55
- = render(Primer::TextComponent.new(tag: :div, flex: :auto)) { document.content(:name).presence || t(:'.documents.no_name') }
55
+ = render(Primer::Beta::Text.new(tag: :div, flex: :auto)) { document.content(:name).presence || t(:'.documents.no_name') }
56
56
  - if document.content(:attachment).present?
57
57
  = render Primer::ButtonComponent.new(tag: :a, ml: 2, href: document.content.attachment_url(:attachment), download: '') do
58
58
  = render Primer::OcticonComponent.new('desktop-download')
59
59
  = t :'.documents.download'
60
60
  - else
61
- = render(Primer::TextComponent.new(tag: :div, font_size: 6, color: :text_secondary)) { t :'.documents.no_file' }
61
+ = render(Primer::Beta::Text.new(tag: :div, font_size: 6, color: :muted)) { t :'.documents.no_file' }
62
62
 
63
63
  = render Primer::SubheadComponent.new(mt: 4) do |component|
64
64
  = component.heading { t :'.partner_societies.title' }
@@ -66,13 +66,13 @@
66
66
  %ul
67
67
  - repeater :partner_societies do |partner_society|
68
68
  %li.list-style-none.py-4.border-bottom
69
- = render Primer::FlexComponent.new(direction: [:column, nil, :row_reverse, nil], align_items: :start) do
69
+ = render Primer::BoxComponent.new(display: :flex, direction: [:column, nil, :row_reverse, nil], align_items: :flex_start) do
70
70
  = render Primer::BaseComponent.new(tag: :div, flex: :auto) do
71
71
  = render Primer::HeadingComponent.new(tag: :h3, mb: 1) do
72
- = render Primer::FlexComponent.new(flex_wrap: true, justify_content: :space_between) do
72
+ = render Primer::BoxComponent.new(display: :flex, flex_wrap: :wrap, justify_content: :space_between) do
73
73
  - if partner_society.content(:name).present?
74
- = render(Primer::TextComponent.new(tag: :div)) { partner_society.content(:name) }
75
- = render Primer::ButtonGroupComponent.new(aria: { label: t(:'.partner_societies.contact_buttons') }) do |component|
74
+ = render(Primer::Beta::Text.new(tag: :div)) { partner_society.content(:name) }
75
+ = render Primer::ButtonGroup.new(aria: { label: t(:'.partner_societies.contact_buttons') }) do |component|
76
76
  - if partner_society.content(:website).present?
77
77
  = component.button(tag: :a, href: partner_society.content(:website)) do
78
78
  = render Primer::OcticonComponent.new('browser')
@@ -82,7 +82,7 @@
82
82
  = render Primer::OcticonComponent.new('mail')
83
83
  = t(:'.partner_societies.email')
84
84
  - if partner_society.content(:description).present?
85
- = render Primer::MarkdownComponent.new(color: :text_secondary) do
85
+ = render Primer::Markdown.new(color: :muted) do
86
86
  = partner_society.content(:description).try(:html_safe)
87
87
  - if partner_society.content(:logo).present?
88
88
  = partner_society.content.image_tag(:logo, { resize_to_limit: [200, 150] }, size: nil, draggable: false,