panda_cms 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd7ca583180961d77d05634c9159ab828e8412bb393189a17673e205678e2c2c
4
- data.tar.gz: 27f77b7dea245a10c9e3f67404ce599009f46545c446d11102d4fbca6f4ba948
3
+ metadata.gz: c8d2e30561848d6e53c6717861b56681eff580b74b81dbe14fdd26d72dd964a1
4
+ data.tar.gz: 60c6219ab70bda2f649b6354277dcb730d500135a6d1d399f15cc3ee0c34942c
5
5
  SHA512:
6
- metadata.gz: f9af8638df72dc9f4f444ad05cb3458fd1f04e499fe7f9246854973b0f713df7e360f9d6ce4f7aa7ccdff4e66826ed712de24b768eeec6d12ecbca47a41c863d
7
- data.tar.gz: 6a28ab4cd9dd1e7ccf9f48d1dec7c21c2902313dc0ce11da4809862625953a38ae9f76e9eb91980aeed4dfe5d4a9f58ffc1b290b445466822196f465a0d2bb58
6
+ metadata.gz: 8f25a5a0b0bbe6a616caff5e7d57ec4c2d3471b03c2ea031e15a9c94b8b62531e8f6115f94555bae102e6561b499c38d9bf7051bbf52fdd2f1dc30de84bbf9e5
7
+ data.tar.gz: 2fbca70b88f2c37ae46f512e6c2c1ed228f1ab8ac45b34ec2ede63f9aaf0c44fe724a543e80020301a8e3c3b07292e34b17d2c06e54e2a198450b186e8339405
@@ -68,7 +68,7 @@ module PandaCms
68
68
  # @return PandaCms::post
69
69
  def post
70
70
  @post ||= if params[:id]
71
- PandaCms::Post.find_by_slug(params[:id])
71
+ PandaCms::Post.find_by_slug("/" + params[:id])
72
72
  else
73
73
  PandaCms::Post.new
74
74
  end
@@ -1,18 +1,11 @@
1
1
  module PandaCms
2
2
  class PostsController < ApplicationController
3
- def index
4
- end
5
-
6
3
  def show
7
- post = PandaCms::Post.find_by(slug: params[:slug])
8
-
9
- # TODO: Make this much nicer in future
10
- globals = {
11
- post: post,
12
- title: post.title
13
- }
4
+ @posts_index_page = PandaCms::Page.find_by(path: "/#{PandaCms.posts[:prefix]}")
5
+ @post = PandaCms::Post.find_by(slug: "/#{params[:slug]}")
6
+ @title = @post.title
14
7
 
15
- render inline: "", assigns: globals, status: :ok, layout: "layouts/post"
8
+ render inline: "", status: :ok, layout: "layouts/post"
16
9
  end
17
10
  end
18
11
  end
@@ -38,6 +38,9 @@ module PandaCms
38
38
  @pages[:about] = PandaCms::Page.find_or_create_by!({path: "/about", title: "About", template: @templates[:page], parent: @pages[:home]})
39
39
  @pages[:terms] = PandaCms::Page.find_or_create_by!({path: "/terms-and-conditions", title: "Terms & Conditions", template: @templates[:page], parent: @pages[:home]})
40
40
 
41
+ PandaCms::Page.reset_column_information
42
+ PandaCms::Page.rebuild!
43
+
41
44
  @pages
42
45
  end
43
46
 
@@ -52,7 +55,7 @@ module PandaCms
52
55
 
53
56
  # Automatically create main menu from homepage
54
57
  unless @pages[:home].nil?
55
- @menus[:main].update(kind: :auto, start_page: @pages[:home])
58
+ @menus[:main].update(kind: :auto, start_page: @pages[:home], depth: 1)
56
59
  @menus[:main].generate_auto_menu_items
57
60
  end
58
61
 
@@ -11,7 +11,13 @@ module PandaCms
11
11
  belongs_to :user, class_name: "PandaCms::User"
12
12
 
13
13
  validates :title, presence: true
14
- validates :slug, presence: true, uniqueness: true, format: {with: /\A[a-z0-9-]+\z/}
14
+ validates :slug,
15
+ presence: true,
16
+ uniqueness: true,
17
+ format: {
18
+ with: /\A\/[a-z0-9-]+\z/,
19
+ message: "must start with a forward slash and contain only lowercase letters, numbers, and hyphens"
20
+ }
15
21
 
16
22
  scope :ordered, -> { order(published_at: :desc) }
17
23
  scope :with_user, -> { includes(:user) }
@@ -28,7 +34,7 @@ module PandaCms
28
34
  }
29
35
 
30
36
  def to_param
31
- slug.to_s
37
+ formatted_slug.to_s
32
38
  end
33
39
 
34
40
  def excerpt(length = 100, squish: true)
@@ -42,10 +48,10 @@ module PandaCms
42
48
  end
43
49
 
44
50
  def formatted_slug
45
- if params[:slug][0] != "/"
46
- "/#{params[:slug]}"
51
+ if slug[0] == "/"
52
+ slug[1, slug.length].to_s
47
53
  else
48
- params[:slug]
54
+ slug
49
55
  end
50
56
  end
51
57
  end
@@ -10,7 +10,6 @@
10
10
  <%= f.button %>
11
11
  </div>
12
12
  <% end %>
13
-
14
13
  <% content_for :head do %>
15
14
  <link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.0.8/dist/trix.css">
16
15
  <script type="text/javascript" src="https://unpkg.com/trix@2.0.8/dist/trix.umd.min.js"></script>
data/config/routes.rb CHANGED
@@ -37,7 +37,8 @@ PandaCms::Engine.routes.draw do
37
37
 
38
38
  if PandaCms.posts
39
39
  # TODO: Allow multiple types of post in future
40
- get PandaCms.posts[:prefix], to: "posts#index", as: :posts
40
+ # TODO: This now requires a page to be created, make it explicit (with a rendering posts helper?)
41
+ # get PandaCms.posts[:prefix], to: "posts#index", as: :posts
41
42
  get "#{PandaCms.posts[:prefix]}/:slug", to: "posts#show", as: :post
42
43
  end
43
44
 
@@ -1,3 +1,3 @@
1
1
  module PandaCms
2
- VERSION = "0.5.8"
2
+ VERSION = "0.5.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Panda Software Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-30 00:00:00.000000000 Z
11
+ date: 2024-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-office-previewer
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: amazing_print
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: awesome_nested_set
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -388,20 +402,6 @@ dependencies:
388
402
  - - "~>"
389
403
  - !ruby/object:Gem::Version
390
404
  version: '2.0'
391
- - !ruby/object:Gem::Dependency
392
- name: amazing_print
393
- requirement: !ruby/object:Gem::Requirement
394
- requirements:
395
- - - "~>"
396
- - !ruby/object:Gem::Version
397
- version: '1.6'
398
- type: :development
399
- prerelease: false
400
- version_requirements: !ruby/object:Gem::Requirement
401
- requirements:
402
- - - "~>"
403
- - !ruby/object:Gem::Version
404
- version: '1.6'
405
405
  - !ruby/object:Gem::Dependency
406
406
  name: annotate
407
407
  requirement: !ruby/object:Gem::Requirement