spina-conferences-primer_theme-fork 0.8.1 → 0.9.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5eeeecc259280f962b1f0e54454b87884adbbcf02d7bccd976096489e48b7d6a
4
- data.tar.gz: 0e9baa272b17486a1888d7103da11c22563c90208b62e625a245d7be90ef94bc
3
+ metadata.gz: 7638db04dabeb5edc3de27c831870439c78710521acbd1c46a99b2b5f2061d16
4
+ data.tar.gz: c759d3795b8bb2358d310e997198203a4ffda6f1a8f5bb9711df8b1f986b0dac
5
5
  SHA512:
6
- metadata.gz: 5916e3b6065d2f4c5d4bef963ce35915c6666e99363001de02585536a8b8133860f7899f7bdf9851fa318d7f2aea9597f41e9b072b7cd3ca21c56f1998d38abd
7
- data.tar.gz: 8473988d364a83fdba70e3a10d4c476f12df2fbd0b58c666bee88fec6e4686112f9dd67443102b48b4afc3d483ad1d9b89bce43e8f67e687ad8482b5e62414ce
6
+ metadata.gz: 83268c1e40a1e9094ab995e472b5e49316c9b19a9a54bd48071dee0a7a6e86441c8a294fd5776e1d36c8527f73072109002850516f80d5ea2bc73acf59d6b852
7
+ data.tar.gz: f26deb07ceda524347c30b38b9de2d895ca7e22b5cbf6cf7c9b590dbde7743ae2a1e18d051858cb69ce3ef50cd228c30d3fb8c3050ef29ed644e7db94262a489
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Conferences
5
+ module PrimerTheme
6
+ module Blog
7
+ class ApplicationController < ::Spina::ApplicationController
8
+ include ::Spina::Frontend
9
+ def cookies_info
10
+ render partial: 'cookies'
11
+ end
12
+
13
+ protected
14
+
15
+ def theme_layout
16
+ 'layouts/spina/conferences/primer_theme/blog/blog'
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Conferences
5
+ module PrimerTheme
6
+ module Blog
7
+ # Spina::Blog::CategoriesController
8
+ class CategoriesController < ApplicationController
9
+ include ::Spina::Frontend
10
+
11
+ before_action :page
12
+ before_action :category
13
+ before_action :posts
14
+ before_action :set_breadcrumb, only: :show
15
+
16
+ def show
17
+ add_breadcrumb t('.category', name: @category.name)
18
+ render layout: theme_layout
19
+ end
20
+
21
+ private
22
+
23
+ def category
24
+ @category = Spina::Admin::Conferences::Blog::Category.friendly.find params[:id]
25
+ end
26
+
27
+ def posts
28
+ @posts = @category.posts.available.live.order(published_at: :desc)
29
+ .page(params[:page])
30
+ end
31
+
32
+ def page
33
+ @page = Spina::Page.find_or_create_by name: 'blog' do |page|
34
+ page.link_url = '/blog'
35
+ page.deletable = false
36
+ end
37
+ end
38
+
39
+ def set_breadcrumb
40
+ add_breadcrumb 'Blog', frontend_blog_root_path
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Conferences
5
+ module PrimerTheme
6
+ module Blog
7
+ # Spina::Blog::PostsController
8
+ class PostsController < ApplicationController
9
+ include ::Spina::Frontend
10
+
11
+ before_action :find_posts, only: [:index]
12
+ before_action :current_spina_user_can_view_page?
13
+ before_action :set_breadcrumb, only: :show
14
+
15
+ decorates_assigned :posts, :post
16
+
17
+ def index
18
+ @posts = @posts.unscope(where: :draft) if current_spina_user&.admin?
19
+
20
+ respond_to do |format|
21
+ format.atom
22
+ format.html { render layout: theme_layout }
23
+ end
24
+ end
25
+
26
+ def show
27
+ @post = Spina::Admin::Conferences::Blog::Post.friendly.find params[:id]
28
+ set_metadata
29
+ add_breadcrumb @post.title
30
+ render layout: theme_layout
31
+ rescue ActiveRecord::RecordNotFound
32
+ try_redirect
33
+ end
34
+
35
+ def archive
36
+ @posts = Spina::Admin::Conferences::Blog::Post.live
37
+ .where(published_at: start_date..end_date)
38
+ .order(published_at: :desc)
39
+ .page(params[:page])
40
+
41
+ render layout: theme_layout
42
+ end
43
+
44
+ private
45
+
46
+ def start_date
47
+ Time.zone.local(params[:year].to_i, (params[:month] || 1).to_i)
48
+ end
49
+
50
+ def end_date
51
+ start_date.end_of_year
52
+ end
53
+
54
+ def page
55
+ @page ||= Spina::Page.find_or_create_by name: 'blog' do |page|
56
+ page.title = 'Blog'
57
+ page.link_url = '/blog'
58
+ page.deletable = false
59
+ end
60
+ end
61
+
62
+ def find_posts
63
+ @posts = Spina::Admin::Conferences::Blog::Post.available.live.order(published_at: :desc)
64
+ .page(params[:page])
65
+ end
66
+
67
+ def try_redirect
68
+ rule = RewriteRule.find_by!(old_path: "/blog/posts/#{params[:id]}")
69
+ redirect_to rule.new_path, status: :moved_permanently
70
+ end
71
+
72
+ def current_spina_user_can_view_page?
73
+ raise ActiveRecord::RecordNotFound unless current_spina_user.present? || page.live?
74
+ end
75
+
76
+ def set_breadcrumb
77
+ add_breadcrumb 'Blog', frontend_blog_root_path
78
+ end
79
+
80
+ def set_metadata
81
+ @title = @post.seo_title || @post.title
82
+ @description = @post.description
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -58,7 +58,7 @@ module Spina
58
58
  end
59
59
 
60
60
  def set_breadcrumb
61
- add_breadcrumb Admin::Conferences::Conference.model_name.human.pluralize, frontend_conferences_path
61
+ add_breadcrumb 'Blog', frontend_conferences_path
62
62
  end
63
63
 
64
64
  def set_metadata
@@ -0,0 +1,5 @@
1
+ - content_for :breadcrumbs do
2
+ = render_breadcrumbs(builder: Spina::Conferences::PrimerTheme::Breadcrumbs::Builder)
3
+
4
+ = render template: 'layouts/spina/conferences/primer_theme/application',
5
+ locals: { author: current_account.name, description: @description, title: @title, seo_title: @title }
@@ -1,4 +1,5 @@
1
1
  %nav.d-flex.flex-column.flex-self-stretch
2
2
  = render partial: 'mobile_navigation_item', collection: main_navigation_items, as: :navigation_item, cache: -> navigation_item { [navigation_item, navigation_item.children] }
3
+ .Header-item.mr-0.border-top.border-white-fade-15= link_to 'Blog', frontend_blog_root_path, class: %w[Header-link py-2 py-lg-0]
3
4
  .Header-item.mr-0.border-top.border-white-fade-15= link_to 'Journal', frontend_issues_path, class: %w[Header-link py-2 py-lg-0]
4
5
  .Header-item.mr-0.border-top.border-white-fade-15= link_to 'Conferences', frontend_conferences_path, class: %w[Header-link py-2 py-lg-0]
@@ -7,5 +7,6 @@
7
7
  .Header-item.Header-item--full.flex-column.width-full.flex-order-1.mr-0.mt-3
8
8
  = render partial: 'mobile_navigation_items'
9
9
  = render partial: 'navigation_item', collection: main_navigation_items, cache: -> navigation_item { [navigation_item, navigation_item.children] }
10
+ .Header-item.d-none.d-lg-flex= link_to 'Blog', frontend_blog_root_path, class: %w[Header-link]
10
11
  .Header-item.d-none.d-lg-flex= link_to 'Journal', frontend_issues_path, class: %w[Header-link]
11
12
  .Header-item.d-none.d-lg-flex= link_to 'Conferences', frontend_conferences_path, class: %w[Header-link]
@@ -0,0 +1,12 @@
1
+ = render(Primer::HeadingComponent.new) do
2
+ Blog
3
+ = render(Primer::HeadingComponent.new(tag: :h2)) do
4
+ = t '.category', name: @category.name
5
+
6
+ = render(Primer::FlexComponent.new(flex: :auto, direction: [:column, nil, :row, nil])) do
7
+ = render(Primer::FlexItemComponent.new(flex_auto: true)) do
8
+ - if @posts.any?
9
+ %ul= render collection: @posts, partial: 'spina/conferences/primer_theme/blog/posts/post', layout: 'list_item', cached: true
10
+ - else
11
+ = render Primer::BlankslateComponent.new(title: t(:'.no_posts'), icon: 'mortar-board')
12
+ = render 'spina/conferences/primer_theme/blog/shared/sidebar'
@@ -0,0 +1,10 @@
1
+ -#%li{class: dom_class(post), id: dom_id(post)}
2
+
3
+ = render(Primer::HeadingComponent.new(tag: :h3, mb: 1)) do
4
+ = link_to post.title, frontend_blog_post_path(post)
5
+ = render(Primer::HeadingComponent.new(tag: :h4)) do
6
+ = time_tag post.published_at, format: :ordinal_datetime_with_year
7
+ = render(Primer::MarkdownComponent.new(color: :text_secondary)) do
8
+ = post.excerpt.html_safe
9
+ = render(Primer::TextComponent.new(tag: :div, color: :text_secondary)) do
10
+ = t '.category_html', name: link_to(post.category.name, frontend_blog_category_path(post.category))
@@ -0,0 +1,5 @@
1
+ %h1
2
+ Blog Archive
3
+ %small= formatted_date(params[:year], params[:month])
4
+
5
+ %ul.posts= render @posts
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ atom_feed language: 'en-GB', url: spina.frontend_blog_root_url do |feed|
4
+ feed.title('Blog')
5
+ feed.updated(@posts[0].created_at) unless @posts.empty?
6
+
7
+ @posts.each do |post|
8
+ feed.entry(post, published: post.published_at, url: spina.frontend_blog_post_url(post)) do |entry|
9
+ entry.title(post.title)
10
+ entry.content(post.content, type: 'html')
11
+
12
+ if post.user
13
+ entry.author do |author|
14
+ author.name(post.user.name)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ = render(Primer::HeadingComponent.new) do
2
+ Blog
3
+
4
+ = render(Primer::FlexComponent.new(flex: :auto, direction: [:column, nil, :row, nil])) do
5
+ = render(Primer::FlexItemComponent.new(flex_auto: true)) do
6
+ - if @posts.any?
7
+ %ul= render collection: @posts, partial: 'post', layout: 'list_item', cached: true
8
+ - else
9
+ = render Primer::BlankslateComponent.new(title: t(:'.no_posts'), icon: 'mortar-board')
10
+ = render 'spina/conferences/primer_theme/blog/shared/sidebar'
11
+
@@ -0,0 +1,17 @@
1
+ = render(Primer::HeadingComponent.new) do
2
+ = @post.title
3
+
4
+ %ul.list-style-none.d-flex.flex-column.flex-sm-row.my-2
5
+ = render(Primer::FlexComponent.new(tag: :li, mr: 4, align_items: :center)) do
6
+ = render(Primer::FlexItemComponent.new(mr: 2)) do
7
+ = render(Primer::OcticonComponent.new('person'))
8
+ = render(Primer::FlexComponent.new(tag: :address, direction: :column)) do
9
+ = render(Primer::TextComponent.new(tag: :div, font_weight: :bold)) { @post.user.name }
10
+
11
+ - if @post.image
12
+ = image_tag main_app.url_for(@post.image.file)
13
+
14
+ = render(Primer::FlexComponent.new(flex: :auto, direction: [:column, nil, :row, nil])) do
15
+ = render(Primer::FlexItemComponent.new(flex_auto: true)) do
16
+ = render(Primer::MarkdownComponent.new(tag: :article)) do
17
+ = @post.content.html_safe
@@ -0,0 +1,10 @@
1
+ = render(Primer::BorderBoxComponent.new(ml: [nil, nil, 4, nil], style: 'min-width: 15vw;')) do |sidebar|
2
+ - sidebar.header do
3
+ = render(Primer::HeadingComponent.new(tag: :h3)) do
4
+ = t '.categories'
5
+ - sidebar.row do
6
+ = render(Primer::MarkdownComponent.new(tag: :div, font_weight: :bold)) do
7
+ %ul
8
+ - Spina::Admin::Conferences::Blog::Category.all.each do |cat|
9
+ %li= link_to cat.name, frontend_blog_category_path(cat)
10
+
@@ -288,5 +288,5 @@
288
288
  label: 'Footer'
289
289
  }]
290
290
 
291
- theme.plugins = %w[conferences journal]
291
+ theme.plugins = %w[conferences journal conferences-blog]
292
292
  end
@@ -190,6 +190,18 @@ en:
190
190
  issue: Issue
191
191
  draft: THIS ARTICLE IS A DRAFT
192
192
  licence_logo: Licence logo
193
+ blog:
194
+ posts:
195
+ post:
196
+ category_html: "Category: %{name}"
197
+ categories:
198
+ show:
199
+ category: "Category: %{name}"
200
+ shared:
201
+ siebar:
202
+ categories: Categories
203
+
204
+
193
205
 
194
206
  languages:
195
207
  en-GB: British English
data/config/routes.rb CHANGED
@@ -14,4 +14,18 @@ Spina::Engine.routes.draw do
14
14
  resources :articles, only: %i[show]
15
15
  end
16
16
  end
17
+
18
+ namespace :frontend, as: 'frontend_blog', path: 'blog', module: 'conferences/primer_theme/blog' do
19
+ root to: 'posts#index'
20
+
21
+ get ':id', to: 'posts#show', as: :post
22
+
23
+ # Redirects for old sites that used the old blog path
24
+ get 'posts/', to: redirect('/blog'), as: :old_index
25
+ get 'posts/:id', to: redirect('/blog/%{id}'), as: :old_post
26
+
27
+ get 'feed.atom', to: 'posts#index', as: :rss_feed, defaults: { format: :atom }
28
+ get 'categories/:id', to: 'categories#show', as: :category
29
+ get 'archive/:year(/:month)', to: 'posts#archive', as: :archive_posts
30
+ end
17
31
  end
@@ -3,7 +3,7 @@
3
3
  module Spina
4
4
  module Conferences
5
5
  module PrimerTheme
6
- VERSION = '0.8.1'
6
+ VERSION = '0.9.0'
7
7
  end
8
8
  end
9
9
  end
@@ -5,6 +5,7 @@ require 'spina/conferences/primer_theme/engine'
5
5
  require 'spina/conferences/primer_theme/breadcrumbs/builder'
6
6
  require 'spina/admin/conferences'
7
7
  require 'spina/admin/journal'
8
+ require 'spina/admin/conferences/blog'
8
9
  require 'octicons_helper'
9
10
  require 'view_component'
10
11
  require 'primer/view_components'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spina-conferences-primer_theme-fork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Malčić
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-11-06 00:00:00.000000000 Z
12
+ date: 2021-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: babel-transpiler
@@ -96,7 +96,7 @@ dependencies:
96
96
  - !ruby/object:Gem::Version
97
97
  version: 2.0.0
98
98
  - !ruby/object:Gem::Dependency
99
- name: spina-admin-conferences
99
+ name: spina-admin-conferences-fork
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
@@ -123,6 +123,20 @@ dependencies:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: 0.6.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: spina-admin-conferences-blog
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: 0.1.4
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: 0.1.4
126
140
  - !ruby/object:Gem::Dependency
127
141
  name: capybara
128
142
  requirement: !ruby/object:Gem::Requirement
@@ -294,6 +308,9 @@ files:
294
308
  - app/assets/stylesheets/spina/conferences/primer_theme/_custom.sass
295
309
  - app/assets/stylesheets/spina/conferences/primer_theme/_custom_variables.sass
296
310
  - app/assets/stylesheets/spina/conferences/primer_theme/application.sass
311
+ - app/controllers/spina/conferences/primer_theme/blog/application_controller.rb
312
+ - app/controllers/spina/conferences/primer_theme/blog/categories_controller.rb
313
+ - app/controllers/spina/conferences/primer_theme/blog/posts_controller.rb
297
314
  - app/controllers/spina/conferences/primer_theme/conferences/application_controller.rb
298
315
  - app/controllers/spina/conferences/primer_theme/conferences/conferences_controller.rb
299
316
  - app/controllers/spina/conferences/primer_theme/conferences/presentations_controller.rb
@@ -317,6 +334,7 @@ files:
317
334
  - app/views/conferences_primer_theme/partials/_homepage_item.html.haml
318
335
  - app/views/layouts/conferences_primer_theme/application.html.haml
319
336
  - app/views/layouts/spina/conferences/primer_theme/application.html.haml
337
+ - app/views/layouts/spina/conferences/primer_theme/blog/blog.html.haml
320
338
  - app/views/layouts/spina/conferences/primer_theme/conferences/conferences.html.haml
321
339
  - app/views/layouts/spina/conferences/primer_theme/conferences/presentations.html.haml
322
340
  - app/views/layouts/spina/conferences/primer_theme/journal/articles.html.haml
@@ -334,6 +352,13 @@ files:
334
352
  - app/views/spina/application/_navigation.html.haml
335
353
  - app/views/spina/application/_navigation_item.html.haml
336
354
  - app/views/spina/application/_text.html.haml
355
+ - app/views/spina/conferences/primer_theme/blog/categories/show.html.haml
356
+ - app/views/spina/conferences/primer_theme/blog/posts/_post.html.haml
357
+ - app/views/spina/conferences/primer_theme/blog/posts/archive.html.haml
358
+ - app/views/spina/conferences/primer_theme/blog/posts/index.atom.builder
359
+ - app/views/spina/conferences/primer_theme/blog/posts/index.html.haml
360
+ - app/views/spina/conferences/primer_theme/blog/posts/show.html.haml
361
+ - app/views/spina/conferences/primer_theme/blog/shared/_sidebar.html.haml
337
362
  - app/views/spina/conferences/primer_theme/conferences/conferences/_conference.html.haml
338
363
  - app/views/spina/conferences/primer_theme/conferences/conferences/_event.html.haml
339
364
  - app/views/spina/conferences/primer_theme/conferences/conferences/_events.html.haml