panda_cms 0.5.2 → 0.5.3

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: 66117a36fa0ee06ce08670baa4b54eae990054f9bc0c80091ca6e97a67b6ce28
4
- data.tar.gz: a7d7c50fd4a0c65f157bde152fef22c6a632c8878f67de9c73fbeb91fa02acf5
3
+ metadata.gz: a11f50a60d457d8a5b4eba37c270535516599a39d78c242f9711990d8f810799
4
+ data.tar.gz: 4f33c57dcb79a3b2eeaafbf58584221a1000e05b05e0058abd401a80eb530c6a
5
5
  SHA512:
6
- metadata.gz: d7f66d163bbde65c92bf600bbd21432f7083b0ff302adef3284b99ea7e233b8309f7e8a022d4b06f5dc513d0e38b795a37aac47691d97fc50ad603f8f8efb9b5
7
- data.tar.gz: b9cbbcc92f2774f780f50e7faf0b03950a3d87b1f643b783c33bc2514e445be240a090f9b985a7600ec31253b25a79942f4a8c72cf4e7a23703fdbe765f7968a
6
+ metadata.gz: 4203b15127f62ef99db77ddd54f1f6c5b5c0c47d3754957be010474aeaa11918e3efbe9d293946dd35cdbbb0fa83515c5797c3e1286c900a1a46a1a5fc159cc3
7
+ data.tar.gz: efdccb2f2ab99172a1b30e73dfa85ca59bed4f616bb67d1fe613bb50f1fe8d63c4333029eb8834b126f2ed68c41436edef535451f99ee27d4cb00e2fa6d332c3
data/README.md CHANGED
@@ -16,7 +16,9 @@ Better websites, on Rails.
16
16
 
17
17
  ## Usage
18
18
 
19
- To create a new Rails app[^1], run the command below, replacing `demo` with the name of the application you want to create:
19
+ ### New applications
20
+
21
+ To create a new Rails app, run the command below, replacing `demo` with the name of the application you want to create:
20
22
 
21
23
  ```
22
24
  rails new demo $(curl -fsSL https://raw.githubusercontent.com/pandacms/generator/main/.railsrc) -m https://raw.githubusercontent.com/pandacms/generator/main/template.rb
@@ -26,6 +28,8 @@ rails new demo $(curl -fsSL https://raw.githubusercontent.com/pandacms/generator
26
28
 
27
29
  The easiest way for you to get started is to visit http://localhost:3000/admin and login with your GitHub credentials. As the first user, you'll automatically have an administrator account created.
28
30
 
31
+ When you're ready to configure further, you can set your own configuration in `config/initializers/panda_cms.rb`. Make sure to turn off the default `github` account creation options!
32
+
29
33
  ### Existing applications
30
34
 
31
35
  Add the following to `Gemfile`:
@@ -45,7 +49,7 @@ rails db:seed
45
49
 
46
50
  You may want to check this does not re-run any of your existing seeds!
47
51
 
48
- If you don't want to use GitHub to login, you'll need to configure a user provider (in `config/initializers/panda_cms.rb`), and then set your user's `admin` attribute to `true` once you've first tried to login. (And yes, there should be a better first-time setup experience than this. We're working on it!)
52
+ If you don't want to use GitHub to login (or are at a URL other than http://localhost:3000/), you'll need to configure a user provider (in `config/initializers/panda_cms.rb`), and then set your user's `admin` attribute to `true` once you've first tried to login.
49
53
 
50
54
  ## Gotchas
51
55
 
@@ -53,7 +57,6 @@ This is a non-exhuastive list (there will be many more):
53
57
 
54
58
  * To date, this has only been tested with Rails 7.1 and 7.2.
55
59
  * There may be conflicts if you're not using Tailwind CSS on the frontend. Please report this.
56
- * If you change your login path from `/admin` the GitHub application we supply won't work on first login, so probably don't do that until you're setup!
57
60
 
58
61
  ## Contributing
59
62
 
@@ -68,5 +71,3 @@ See [Credits](https://github.com/pandacms/panda_cms/blob/main/CREDITS.md) for th
68
71
  The gem is available as open source under the terms of the [BSD-3-Clause License](https://opensource.org/licenses/bsd-3-clause).
69
72
 
70
73
  Copyright © 2024, Panda Software Limited.
71
-
72
- [^1]: You can of course use an existing Rails app, but on your head be it – we haven't tested this at all yet!
@@ -11,7 +11,7 @@ module PandaCms
11
11
  #
12
12
  # Creates initial templates and empty blocks
13
13
  #
14
- # @return [Hash] A hash containing the created templates
14
+ # @return void
15
15
  def create_templates
16
16
  # Templates
17
17
  initial_templates = [
@@ -20,10 +20,13 @@ module PandaCms
20
20
  ]
21
21
 
22
22
  initial_templates.each do |template|
23
- PandaCms::Template.find_or_create_by!(template)
23
+ key = template[:name].downcase.to_sym
24
+ @templates[key] = PandaCms::Template.find_or_create_by!(template)
24
25
  end
25
26
 
26
27
  PandaCms::Template.generate_missing_blocks
28
+
29
+ @templates
27
30
  end
28
31
 
29
32
  #
@@ -34,21 +37,26 @@ module PandaCms
34
37
  @pages[:home] = PandaCms::Page.find_or_create_by!({path: "/", title: "Home", template: @templates[:homepage]})
35
38
  @pages[:about] = PandaCms::Page.find_or_create_by!({path: "/about", title: "About", template: @templates[:page], parent: @pages[:home]})
36
39
  @pages[:terms] = PandaCms::Page.find_or_create_by!({path: "/terms-and-conditions", title: "Terms & Conditions", template: @templates[:page], parent: @pages[:home]})
40
+
41
+ @pages
37
42
  end
38
43
 
39
44
  #
40
45
  # Creates initial menus
41
46
  #
42
47
  # @return [Hash] A hash containing the created menus
43
- #
44
48
  def create_menus
45
49
  @menus = {}
46
50
  @menus[:main] = PandaCms::Menu.find_or_create_by!(name: "Main Menu")
47
51
  @menus[:footer] = PandaCms::Menu.find_or_create_by!(name: "Footer Menu")
48
52
 
49
53
  # Automatically create main menu from homepage
50
- @menus[:main].update(kind: :auto, start_page: @pages[:home])
51
- @menus[:main].generate_auto_menu_items
54
+ unless @pages[:home].nil?
55
+ @menus[:main].update(kind: :auto, start_page: @pages[:home])
56
+ @menus[:main].generate_auto_menu_items
57
+ end
58
+
59
+ @menus
52
60
  end
53
61
  end
54
62
  end
@@ -39,7 +39,6 @@ module PandaCms
39
39
  # PandaCms::RichTextComponent.new(key: :value)
40
40
  # PandaCms::RichTextComponent.new key: :value, key: value
41
41
  line.match(/PandaCms::([a-zA-Z]+)Component\.new[ \(]+([^\)]+)[\)]*/) do |match|
42
- puts "- #{match[0]}"
43
42
  # Extract the hash values
44
43
  template_path = file.gsub("app/views/", "").gsub(".html.erb", "")
45
44
  template_name = template_path.gsub("layouts/", "").titleize
@@ -49,6 +48,9 @@ module PandaCms
49
48
  template.name = template_name
50
49
  end
51
50
 
51
+ next if match[1] == "PageMenu" # Skip PageMenu blocks
52
+ next if match[1] == "Menu" # Skip Menu blocks
53
+
52
54
  # Previously used match[1].underscore but this supports more complex database
53
55
  # operations, and is more secure as it'll force the usage of a class
54
56
  block_kind = "PandaCms::#{match[1]}Component".constantize::KIND
@@ -1,5 +1,3 @@
1
- # Base URL
2
- PandaCms.url = "http://localhost:3000"
3
1
  # The main title of your website
4
2
  # The default is "Demo Site"
5
3
  PandaCms.title = "Demo Site"
@@ -41,7 +39,11 @@ PandaCms.authentication = {
41
39
  github: {
42
40
  enabled: true,
43
41
  create_account_on_first_login: true,
44
- create_admin_account_on_first_login: false,
42
+ create_admin_account_on_first_login: true,
43
+ # client_id: Rails.application.credentials.dig(:github, :client_id),
44
+ # client_secret: Rails.application.credentials.dig(:github, :client_secret),
45
+ client_id: "Ov23li9k0LpMXtq8FShb", # Will only work on localhost
46
+ client_secret: "07233b63472b7f287ac11854e627670ddc096a22", # Will only work on localhost
45
47
  redirect_uri: Rails.application.credentials.dig(:github, :redirect_uri)
46
48
  }
47
49
  }
@@ -1,3 +1,3 @@
1
1
  module PandaCms
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
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.2
4
+ version: 0.5.3
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-02 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-office-previewer