spina-conferences-primer_theme-fork 0.9.2 → 1.0.0.rc3

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} +14 -4
  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 +12 -0
  12. data/app/controllers/spina/conferences/primer_theme/blog/categories_controller.rb +0 -10
  13. data/app/controllers/spina/conferences/primer_theme/blog/posts_controller.rb +5 -20
  14. data/app/controllers/spina/conferences/primer_theme/conferences/application_controller.rb +12 -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 +11 -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 +1 -1
  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
  }
@@ -55,8 +56,15 @@ class SlideshowController extends Stimulus.Controller {
55
56
  */
56
57
  connect() {
57
58
  this.showSlide()
59
+ this.resetInterval()
60
+ }
61
+
62
+ resetInterval() {
58
63
  if (this.data.has('advance')) {
59
- setInterval(() => this.next(), this.delay)
64
+ if (this.intervalId) {
65
+ clearInterval(this.intervalId)
66
+ }
67
+ this.intervalId = setInterval(() => this.next(), this.delay)
60
68
  }
61
69
  }
62
70
 
@@ -73,6 +81,7 @@ class SlideshowController extends Stimulus.Controller {
73
81
  * @private
74
82
  */
75
83
  next() {
84
+ this.resetInterval()
76
85
  const incrementer = this.incrementer
77
86
  this.incrementer = incrementer === this.slideTargets.length - 1 ? 0 : incrementer + 1
78
87
  }
@@ -82,6 +91,7 @@ class SlideshowController extends Stimulus.Controller {
82
91
  * @private
83
92
  */
84
93
  previous() {
94
+ this.resetInterval()
85
95
  const incrementer = this.incrementer
86
96
  this.incrementer = incrementer === 0 ? this.slideTargets.length - 1 : incrementer - 1
87
97
  }
@@ -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,12 @@ 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
+
11
+ before_action :page
12
+
9
13
  def cookies_info
10
14
  render partial: 'cookies'
11
15
  end
@@ -15,6 +19,14 @@ module Spina
15
19
  def theme_layout
16
20
  'layouts/spina/conferences/primer_theme/blog/blog'
17
21
  end
22
+
23
+ def page
24
+ @page = Spina::Page.find_or_create_by name: 'blog' do |page|
25
+ page.title = 'Blog'
26
+ page.link_url = '/blog'
27
+ page.deletable = false
28
+ end
29
+ end
18
30
  end
19
31
  end
20
32
  end
@@ -6,9 +6,6 @@ module Spina
6
6
  module Blog
7
7
  # Spina::Blog::CategoriesController
8
8
  class CategoriesController < ApplicationController
9
- include ::Spina::Frontend
10
-
11
- before_action :page
12
9
  before_action :category
13
10
  before_action :posts
14
11
  before_action :set_breadcrumb, only: :show
@@ -30,13 +27,6 @@ module Spina
30
27
  .page(params[:page])
31
28
  end
32
29
 
33
- def page
34
- @page = Spina::Page.find_or_create_by name: 'blog' do |page|
35
- page.link_url = '/blog'
36
- page.deletable = false
37
- end
38
- end
39
-
40
30
  def set_breadcrumb
41
31
  add_breadcrumb 'Blog', frontend_blog_root_path
42
32
  end
@@ -6,10 +6,7 @@ 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
- before_action :current_spina_user_can_view_page?
13
10
  before_action :set_breadcrumb, only: :show
14
11
 
15
12
  decorates_assigned :posts, :post
@@ -36,9 +33,9 @@ module Spina
36
33
 
37
34
  def archive
38
35
  @posts = Spina::Admin::Conferences::Blog::Post.live
39
- .where(published_at: start_date..end_date)
40
- .order(published_at: :desc)
41
- .page(params[:page])
36
+ .where(published_at: start_date..end_date)
37
+ .order(published_at: :desc)
38
+ .page(params[:page])
42
39
 
43
40
  render layout: theme_layout
44
41
  end
@@ -53,17 +50,9 @@ module Spina
53
50
  start_date.end_of_year
54
51
  end
55
52
 
56
- def page
57
- @page ||= Spina::Page.find_or_create_by name: 'blog' do |page|
58
- page.title = 'Blog'
59
- page.link_url = '/blog'
60
- page.deletable = false
61
- end
62
- end
63
-
64
53
  def find_posts
65
54
  @posts = Spina::Admin::Conferences::Blog::Post.available.live.order(published_at: :desc)
66
- .page(params[:page])
55
+ .page(params[:page])
67
56
  end
68
57
 
69
58
  def try_redirect
@@ -71,16 +60,12 @@ module Spina
71
60
  redirect_to rule.new_path, status: :moved_permanently
72
61
  end
73
62
 
74
- def current_spina_user_can_view_page?
75
- raise ActiveRecord::RecordNotFound unless current_spina_user.present? || page.live?
76
- end
77
-
78
63
  def set_breadcrumb
79
64
  add_breadcrumb 'Blog', frontend_blog_root_path
80
65
  end
81
66
 
82
67
  def set_metadata
83
- @title = @post.seo_title.blank? ? @post.title : @post.seo_title
68
+ @title = @post.seo_title.presence || @post.title
84
69
  @description = @post.description
85
70
  end
86
71
  end
@@ -6,9 +6,21 @@ module Spina
6
6
  module Conferences
7
7
  # Base class from which controllers inherit
8
8
  class ApplicationController < Spina::ApplicationController
9
+ before_action :page
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
+ end
23
+ end
12
24
  end
13
25
  end
14
26
  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,17 @@ 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 :page
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
+ end
19
+ end
9
20
  end
10
21
  end
11
22
  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