spina-admin-journal 0.1.0

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 (95) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +99 -0
  4. data/Rakefile +36 -0
  5. data/app/assets/config/spina_admin_journal_manifest.js +3 -0
  6. data/app/assets/javascripts/spina/admin/journal/application.es6 +72 -0
  7. data/app/assets/stylesheets/spina/admin/journal/application.css +27 -0
  8. data/app/controllers/spina/admin/journal/application_controller.rb +26 -0
  9. data/app/controllers/spina/admin/journal/articles_controller.rb +125 -0
  10. data/app/controllers/spina/admin/journal/authors_controller.rb +83 -0
  11. data/app/controllers/spina/admin/journal/institutions_controller.rb +71 -0
  12. data/app/controllers/spina/admin/journal/issues_controller.rb +129 -0
  13. data/app/controllers/spina/admin/journal/journals_controller.rb +73 -0
  14. data/app/controllers/spina/admin/journal/volumes_controller.rb +79 -0
  15. data/app/models/spina/admin/journal.rb +11 -0
  16. data/app/models/spina/admin/journal/affiliation.rb +62 -0
  17. data/app/models/spina/admin/journal/article.rb +55 -0
  18. data/app/models/spina/admin/journal/author.rb +47 -0
  19. data/app/models/spina/admin/journal/authorship.rb +19 -0
  20. data/app/models/spina/admin/journal/institution.rb +32 -0
  21. data/app/models/spina/admin/journal/issue.rb +49 -0
  22. data/app/models/spina/admin/journal/journal.rb +50 -0
  23. data/app/models/spina/admin/journal/volume.rb +37 -0
  24. data/app/validators/spina/admin/journal/uri_validator.rb +24 -0
  25. data/app/views/layouts/spina/admin/journal/articles.html.haml +10 -0
  26. data/app/views/layouts/spina/admin/journal/authors.html.haml +10 -0
  27. data/app/views/layouts/spina/admin/journal/institutions.html.haml +10 -0
  28. data/app/views/layouts/spina/admin/journal/issues.html.haml +10 -0
  29. data/app/views/layouts/spina/admin/journal/journals.html.haml +10 -0
  30. data/app/views/layouts/spina/admin/journal/volumes.html.haml +10 -0
  31. data/app/views/spina/admin/hooks/journal/_head.html.haml +2 -0
  32. data/app/views/spina/admin/hooks/journal/_primary_navigation.html.haml +27 -0
  33. data/app/views/spina/admin/hooks/journal/_website_secondary_navigation.html.haml +0 -0
  34. data/app/views/spina/admin/journal/affiliations/_affiliation.html.haml +8 -0
  35. data/app/views/spina/admin/journal/application/_empty_list.html.haml +3 -0
  36. data/app/views/spina/admin/journal/articles/_article.html.haml +10 -0
  37. data/app/views/spina/admin/journal/articles/_form.html.haml +29 -0
  38. data/app/views/spina/admin/journal/articles/_form_authors.html.haml +10 -0
  39. data/app/views/spina/admin/journal/articles/_form_details.html.haml +52 -0
  40. data/app/views/spina/admin/journal/articles/edit.html.haml +1 -0
  41. data/app/views/spina/admin/journal/articles/index.html.haml +19 -0
  42. data/app/views/spina/admin/journal/articles/new.html.haml +1 -0
  43. data/app/views/spina/admin/journal/authors/_author.html.haml +8 -0
  44. data/app/views/spina/admin/journal/authors/_form.html.haml +29 -0
  45. data/app/views/spina/admin/journal/authors/_form_affiliation.html.haml +20 -0
  46. data/app/views/spina/admin/journal/authors/_form_articles.html.haml +18 -0
  47. data/app/views/spina/admin/journal/authors/_form_details.html.haml +6 -0
  48. data/app/views/spina/admin/journal/authors/edit.html.haml +1 -0
  49. data/app/views/spina/admin/journal/authors/index.html.haml +17 -0
  50. data/app/views/spina/admin/journal/authors/new.html.haml +1 -0
  51. data/app/views/spina/admin/journal/institutions/_form.html.haml +29 -0
  52. data/app/views/spina/admin/journal/institutions/_form_details.html.haml +9 -0
  53. data/app/views/spina/admin/journal/institutions/_form_view_affiliations.html.haml +10 -0
  54. data/app/views/spina/admin/journal/institutions/_institution.html.haml +9 -0
  55. data/app/views/spina/admin/journal/institutions/edit.html.haml +1 -0
  56. data/app/views/spina/admin/journal/institutions/index.html.haml +16 -0
  57. data/app/views/spina/admin/journal/institutions/new.html.haml +1 -0
  58. data/app/views/spina/admin/journal/issues/_form.html.haml +29 -0
  59. data/app/views/spina/admin/journal/issues/_form_articles.html.haml +14 -0
  60. data/app/views/spina/admin/journal/issues/_form_details.html.haml +32 -0
  61. data/app/views/spina/admin/journal/issues/_issue.html.haml +9 -0
  62. data/app/views/spina/admin/journal/issues/edit.html.haml +1 -0
  63. data/app/views/spina/admin/journal/issues/index.html.haml +18 -0
  64. data/app/views/spina/admin/journal/issues/new.html.haml +1 -0
  65. data/app/views/spina/admin/journal/journals/_form.html.haml +35 -0
  66. data/app/views/spina/admin/journal/journals/edit.html.haml +1 -0
  67. data/app/views/spina/admin/journal/journals/index.html.haml +27 -0
  68. data/app/views/spina/admin/journal/journals/new.html.haml +1 -0
  69. data/app/views/spina/admin/journal/volumes/_form.html.haml +15 -0
  70. data/app/views/spina/admin/journal/volumes/_form_details.html.haml +10 -0
  71. data/app/views/spina/admin/journal/volumes/_form_issues.html.haml +13 -0
  72. data/app/views/spina/admin/journal/volumes/_volume.html.haml +7 -0
  73. data/app/views/spina/admin/journal/volumes/edit.html.haml +1 -0
  74. data/app/views/spina/admin/journal/volumes/index.html.haml +17 -0
  75. data/app/views/spina/admin/journal/volumes/new.html.haml +1 -0
  76. data/config/locales/en.yml +184 -0
  77. data/config/routes.rb +21 -0
  78. data/db/migrate/20201216152147_create_spina_admin_journal_journals.rb +13 -0
  79. data/db/migrate/20201216153822_create_spina_admin_journal_volumes.rb +13 -0
  80. data/db/migrate/20201216155113_create_spina_admin_journal_issues.rb +15 -0
  81. data/db/migrate/20201216161122_create_spina_admin_journal_articles.rb +16 -0
  82. data/db/migrate/20201216205633_create_spina_admin_journal_institutions.rb +11 -0
  83. data/db/migrate/20201216211224_create_spina_admin_journal_authors.rb +7 -0
  84. data/db/migrate/20201216221146_create_spina_admin_journal_affiliations.rb +15 -0
  85. data/db/migrate/20201216230816_create_spina_admin_journal_authorships.rb +14 -0
  86. data/db/migrate/20201231165231_create_spina_admin_journal_parts.rb +12 -0
  87. data/db/migrate/20210424123450_add_json_attributes_to_spina_admin_journal_journals.rb +7 -0
  88. data/db/migrate/20210424123521_add_json_attributes_to_spina_admin_journal_issues.rb +7 -0
  89. data/db/migrate/20210424123555_add_json_attributes_to_spina_admin_journal_articles.rb +7 -0
  90. data/lib/spina/admin/journal.rb +18 -0
  91. data/lib/spina/admin/journal/engine.rb +17 -0
  92. data/lib/spina/admin/journal/version.rb +9 -0
  93. data/lib/tasks/spina/admin/journal_tasks.rake +5 -0
  94. data/vendor/assets/javascripts/spina/admin/journal/html5sortable.js +1295 -0
  95. metadata +388 -0
@@ -0,0 +1,27 @@
1
+ - content_for :header_actions do
2
+ = link_to new_admin_journal_journal_path, class: %w[button button-primary], style: 'margin-right: 0' do
3
+ = icon 'plus'
4
+ = t '.new'
5
+
6
+ .well
7
+ .table-container
8
+ %table.table
9
+ %thead
10
+ %tr
11
+ %th= ::Spina::Admin::Journal::Journal.human_attribute_name :name
12
+ %th
13
+
14
+ %tbody
15
+ - if @journals.any?
16
+ - @journals.each do |journal|
17
+ %tr
18
+ %td
19
+ = journal.name
20
+ %td.nowrap.align-right
21
+ = link_to spina.edit_admin_journal_journal_path(journal), class: %w[button button-link] do
22
+ = icon 'pencil-outline'
23
+
24
+ - else
25
+ %tr
26
+ %td.align-center{colspan: 2}
27
+ %em= t '.no_journals'
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -0,0 +1,15 @@
1
+ = form_for @volume, html: { autocomplete: 'off' } do |f|
2
+ %header#header
3
+ = render partial: 'spina/admin/shared/breadcrumbs'
4
+
5
+ #header_actions
6
+ .button{ style: 'margin-right: 0' }= link_to t('spina.cancel'), admin_journal_volumes_path
7
+
8
+ %nav#secondary.tabs
9
+ %ul
10
+ - @tabs.each_with_index do |tab, i|
11
+ %li{ class: ('active' if i == 0) }
12
+ = link_to t(".#{tab}"), "##{tab}"
13
+
14
+ #details.tab-content.active= render 'form_details', f: f
15
+ #issues.tab-content= render 'form_issues', f: f
@@ -0,0 +1,10 @@
1
+ .page-form
2
+ .page-form-group
3
+ .page-form-label
4
+ = ::Spina::Admin::Journal::Volume.human_attribute_name :number
5
+ %small= t '.unchangeable'
6
+ .page-form-content
7
+ = f.number_field :number, disabled: true
8
+
9
+ - unless @volume.new_record?
10
+ .pull-right= link_to t('spina.permanently_delete'), admin_journal_volume_path(@volume), method: :delete, data: { confirm: t('.delete_confirmation', number: @volume.number) }, class: 'button button-link button-danger'
@@ -0,0 +1,13 @@
1
+ .sort-message
2
+ .well
3
+ .table-container
4
+ %table.table
5
+ %thead
6
+ %tr
7
+ %th= ::Spina::Admin::Journal::Volume.human_attribute_name :number
8
+ %th= ::Spina::Admin::Journal::Issue.human_attribute_name :number
9
+ %th= ::Spina::Admin::Journal::Issue.human_attribute_name :title
10
+ %th= ::Spina::Admin::Journal::Issue.human_attribute_name :date
11
+ %th
12
+ %tbody.html5sortable{ data: { id: @volume.id, sorted_collection: 'admin_journal_issues', sort_url: sort_admin_journal_issues_url(@volume) } }
13
+ = render @volume.issues.any? ? @volume.issues.sorted_asc : 'empty_list', message: t('.no_issues')
@@ -0,0 +1,7 @@
1
+ %tr{ data: { id: volume.id } }
2
+ %td.position-display= volume.number
3
+ %td= volume.issues.any? ? time_tag(volume.issues.first.date, format: :year) : t('.no_date')
4
+ %td.nowrap.align-right
5
+ = link_to edit_admin_journal_volume_path(volume.id), class: 'button button-link' do
6
+ = icon 'pencil-outline'
7
+ = t '.view'
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -0,0 +1,17 @@
1
+ - content_for(:header_actions) do
2
+ = link_to admin_journal_volumes_path, method: :post, class: 'button button-primary' do
3
+ = icon 'plus'
4
+ = t '.new'
5
+
6
+ .sort-message
7
+ .well
8
+ .table-container
9
+ %table.table
10
+ %thead
11
+ %tr
12
+ %th= ::Spina::Admin::Journal::Volume.human_attribute_name :number
13
+ %th= t '.date'
14
+ %th
15
+
16
+ %tbody.html5sortable{ data: { id: ::Spina::Admin::Journal::Journal.instance.id, sorted_collection: 'admin_journal_volumes', sort_url: sort_admin_journal_volumes_url(::Spina::Admin::Journal::Journal.instance.id) } }
17
+ = render @volumes.any? ? @volumes : 'empty_list', message: t('.empty')
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -0,0 +1,184 @@
1
+ en:
2
+ spina:
3
+ admin:
4
+ journal:
5
+ navigation_title: Journal settings
6
+ unnamed_journal: Unnamed journal
7
+ journals:
8
+ index:
9
+ new: New journal
10
+ no_journals: There are currently no journals saved.
11
+ update:
12
+ saved: Journal saved.
13
+ destroy:
14
+ deleted: Journal deleted.
15
+ form:
16
+ name: name
17
+ save: Save journal
18
+ delete_confirmation:
19
+ "Are you sure you want to delete the journal <strong>%{name}</strong>?
20
+ This action is irreversible, and will delete all associated volumes, issues,
21
+ and articles."
22
+ volumes:
23
+ volume_number: "Volume #%{number}"
24
+ index:
25
+ new: New volume
26
+ date: Year
27
+ view: View
28
+ empty: There are no volumes.
29
+ create:
30
+ created: Volume <strong>%{number}</strong> created.
31
+ update:
32
+ saved: Volume saved.
33
+ form_details:
34
+ unchangeable: The volume number can be changed by clicking 'Change Order' in the index view.
35
+ delete_confirmation: "Are you sure you want to delete Volume <strong>#%{number}</strong>?"
36
+ form_issues:
37
+ volume_number: "Volume #"
38
+ issue_number: "Issue #"
39
+ volume:
40
+ no_date: Unpublished
41
+ sort:
42
+ sort_success: Sorted successfully!
43
+ sort_error: There was an error when sorting. Check the server logs for more information.
44
+ issues:
45
+ issue_number: "Issue #%{number}"
46
+ index:
47
+ new: New issue
48
+ empty: There are no issues.
49
+ new:
50
+ new: New issue
51
+ create:
52
+ saved: Issue saved.
53
+ update:
54
+ saved: Issue saved.
55
+ destroy:
56
+ deleted: Issue deleted.
57
+ form:
58
+ save: Save issue
59
+ form_details:
60
+ issue_unchangeable: The issue order can be changed in the 'Volumes' tab.
61
+ delete_confirmation: "Are you sure you want to delete Issue <strong>#%{number}</strong>?"
62
+ sort:
63
+ sort_success: Sorted successfully!
64
+ sort_error: There was an error when sorting. Check the server logs for more information.
65
+ articles:
66
+ index:
67
+ new: New article
68
+ empty: There are no articles.
69
+ new:
70
+ new: New article
71
+ create:
72
+ saved: Article saved.
73
+ update:
74
+ saved: Article saved.
75
+ destroy:
76
+ deleted: Article deleted.
77
+ form:
78
+ save: Save article
79
+ form_details:
80
+ volume_issue: "Volume %{volume_number} Issue %{issue_number}"
81
+ unchangeable: Article order can be changed in the issue.
82
+ delete_confirmation: "Are you sure you want to delete '<strong>%{title}</strong>'?"
83
+ form_authors:
84
+ no_authors: There are no authors.
85
+ number_of_articles: "# Articles"
86
+ article:
87
+ view: View
88
+ sort:
89
+ sort_success: Sorted successfully!
90
+ sort_error: There was an error when sorting. Check the server logs for more information.
91
+ authors:
92
+ index:
93
+ new: New author
94
+ number_of_articles: "# Articles"
95
+ new:
96
+ new: New author
97
+ create:
98
+ saved: Author saved.
99
+ update:
100
+ saved: Author saved.
101
+ destroy:
102
+ deleted: Author deleted.
103
+ form:
104
+ save: Save author
105
+ form_details:
106
+ delete_confirmation: "Are you sure you want to delete the author %{name}?"
107
+ form_affiliation:
108
+ primary: Primary?
109
+ form_articles:
110
+ no_articles: There are no articles.
111
+ institutions:
112
+ index:
113
+ new: New institution
114
+ edit: Edit
115
+ empty: There are no institutions.
116
+ number_of_affiliations: "# affiliations"
117
+ new:
118
+ new: New institution
119
+ create:
120
+ saved: Institution saved.
121
+ update:
122
+ saved: Institution saved.
123
+ destroy:
124
+ deleted: Institution deleted.
125
+ form:
126
+ save: Save institution
127
+ form_view_affiliations:
128
+ no_affiliations: This institution has no associated affiliations.
129
+ number_of_articles: "# articles"
130
+ form_details:
131
+ delete_confirmation:
132
+ "Are you sure you want to delete the institution <strong>%{name}</strong>?
133
+ This action is irreversible, and will delete all associated affiliations. Authors will not be deleted."
134
+ activerecord:
135
+ models:
136
+ spina/admin/journal/journal:
137
+ one: Journal
138
+ other: Journals
139
+ spina/admin/journal/volume:
140
+ one: Volume
141
+ other: Volumes
142
+ spina/admin/journal/issue:
143
+ one: Issue
144
+ other: Issues
145
+ spina/admin/journal/article:
146
+ one: Article
147
+ other: Articles
148
+ spina/admin/journal/author:
149
+ one: Author
150
+ other: Authors
151
+ spina/admin/journal/author_name:
152
+ one: Author name
153
+ other: Author names
154
+ spina/admin/journal/institution:
155
+ one: Institution
156
+ other: Institutions
157
+ attributes:
158
+ spina/admin/journal/journal:
159
+ name: Name
160
+ logo: Logo
161
+ spina/admin/journal/volume:
162
+ number: "Volume #"
163
+ spina/admin/journal/issue:
164
+ number: "Issue #"
165
+ title: Title
166
+ date: Date
167
+ spina/admin/journal/article:
168
+ number: "Article #"
169
+ title: Title
170
+ url: URL
171
+ doi: DOI
172
+ spina/admin/journal/author:
173
+ spina/admin/journal/author_name:
174
+ spina/admin/journal/institution:
175
+ name: Institution Name
176
+
177
+ date:
178
+ formats:
179
+ iso8601: "%F"
180
+ year: "%Y"
181
+
182
+ errors:
183
+ messages:
184
+ invalid_uri: is invalid
data/config/routes.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ Spina::Engine.routes.draw do
4
+ namespace :admin, path: Spina.config.backend_path do
5
+ namespace :journal do
6
+ resources :journals, only: %i[edit update destroy]
7
+ resources :volumes, except: %i[show new update] do
8
+ patch 'sort/:journal_id' => 'volumes#sort', as: :sort, on: :collection
9
+ end
10
+ resources :issues, except: %i[show] do
11
+ patch 'sort/:volume_id' => 'issues#sort', as: :sort, on: :collection
12
+ end
13
+ resources :articles, except: %i[show] do
14
+ patch 'sort/:issue_id' => 'articles#sort', as: :sort, on: :collection
15
+ end
16
+
17
+ resources :institutions, except: %i[show]
18
+ resources :authors, except: %i[show]
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalJournals < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_journals do |t|
6
+ t.string :name, null: false, default: 'Unnamed Journal'
7
+ t.references :logo, null: true, foreign_key: { to_table: :spina_images }
8
+ t.integer :singleton_guard, null: false, index: { unique: true }
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalVolumes < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_volumes do |t|
6
+ t.integer :number, null: false
7
+ t.string :title, null: false, default: ''
8
+ t.references :journal, null: false, foreign_key: { to_table: :spina_admin_journal_journals }
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalIssues < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_issues do |t|
6
+ t.integer :number, null: false
7
+ t.string :title, null: false, default: ''
8
+ t.date :date, null: false
9
+ t.references :volume, null: false, foreign_key: { to_table: :spina_admin_journal_volumes }
10
+ t.references :cover_img, null: true, foreign_key: { to_table: :spina_images }
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalArticles < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_articles do |t|
6
+ t.integer :number, null: false, default: 0
7
+ t.string :title, null: false
8
+ t.string :url, null: false, default: ''
9
+ t.string :doi, null: false, default: ''
10
+ t.references :issue, null: false, foreign_key: { to_table: :spina_admin_journal_issues }
11
+ t.references :file, null: true, foreign_key: { to_table: :spina_attachments, on_delete: :nullify }
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalInstitutions < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_institutions do |t|
6
+ t.string :name, null: false
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalAuthors < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_authors, &:timestamps
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalAffiliations < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_affiliations do |t|
6
+ t.string :first_name, null: false
7
+ t.string :surname, null: false
8
+ t.integer :status, null: false, default: 0
9
+ t.references :institution, null: false, foreign_key: { to_table: :spina_admin_journal_institutions }
10
+ t.references :author, null: false, foreign_key: { to_table: :spina_admin_journal_authors }
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalAuthorships < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_authorships do |t|
6
+ t.references :article, null: false, foreign_key: { to_table: :spina_admin_journal_articles }
7
+ t.references :affiliation, null: false, foreign_key: { to_table: :spina_admin_journal_affiliations }
8
+ t.index %i[article_id affiliation_id], unique: true, name: :index_authorships_on_article_id_and_affiliation_id
9
+ t.index %i[affiliation_id article_id], unique: true, name: :index_authorships_on_affiliation_id_and_article_id
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateSpinaAdminJournalParts < ActiveRecord::Migration[6.0] # :nodoc:
4
+ def change
5
+ create_table :spina_admin_journal_parts do |t| # rubocop:disable Rails/CreateTableWithTimestamps
6
+ t.string :title
7
+ t.string :name
8
+ t.references :partable, polymorphic: true, index: false
9
+ t.references :pageable, polymorphic: true, index: false
10
+ end
11
+ end
12
+ end