spina 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spina might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eddb2bbef87fd0d66a6ca49f2234bf75a659a67ddf1ccbf95b5ccb0fc385332
4
- data.tar.gz: 283ae2a27280cd16c66927ce8aa82210112372a8bc873d25519ee7cf3e3b8b1b
3
+ metadata.gz: f8e6360561b1bb460394fb3d5032f1927d97a50b8de91742da13cb17d1b8e4b0
4
+ data.tar.gz: d10a26f6215d2b2f4788cc5a97851d802f84b701376a5f7ab4a7dd37f0939453
5
5
  SHA512:
6
- metadata.gz: 41ba06425dd468e816f32031eef4eaa6bafef3defb437274c980d96d9e9dcc130dcb975942dfc0171bcd0883b07efb3a4037610c9c843f9b7ad936c3afb88e57
7
- data.tar.gz: b973bea94d9d22268c076b7023de7dc617876a0064ac6cb47c2513499b5e082c0556a7f991573088c3a228d53c4ee4453f0f1c44756dbe4580c0d48c3be37617
6
+ metadata.gz: 3adb1591ca4cef306680e456e00081042662d8d9b224c5a88aa0cc2845c0ace2d08db511474e7f1981581e967947143b225895d4360303ddbb8aafcd9f477eda
7
+ data.tar.gz: 863d27360647fd54c8ac5475da675cae966873e12c8d63264e3c370980333fbea0c92eea252499125bd685a4421c81f2698e94bb41f4962494080f5302842dfe
data/README.md CHANGED
@@ -18,9 +18,9 @@ gem 'spina'
18
18
 
19
19
  Run the installer to start the setup process:
20
20
 
21
- rails g spina:install
21
+ rails g spina:install [--silent] [--first-deploy]
22
22
 
23
- The installer will help you create your first user.
23
+ The installer will help you create your first user interactively, unless you choose the optional `--silent` flag : in this case, defaults will apply.
24
24
 
25
25
  Then start `rails s` and access Spina at `/admin`.
26
26
 
@@ -53,7 +53,7 @@ module Spina
53
53
  end
54
54
 
55
55
  def spina_request_path
56
- segments = ['/', params[:locale], params[:id]].compact
56
+ segments = [Spina.mounted_at, params[:locale], params[:id]].compact
57
57
  File.join(*segments)
58
58
  end
59
59
 
@@ -122,11 +122,12 @@ module Spina
122
122
  end
123
123
 
124
124
  def localized_materialized_path
125
- if Mobility.locale == I18n.default_locale
126
- generate_materialized_path.prepend('/')
125
+ segments = if Mobility.locale == I18n.default_locale
126
+ [Spina.mounted_at, generate_materialized_path]
127
127
  else
128
- generate_materialized_path.prepend("/#{Mobility.locale}/").gsub(/\/\z/, "")
128
+ [Spina.mounted_at, Mobility.locale, generate_materialized_path]
129
129
  end
130
+ File.join(*segments.map(&:to_s).compact)
130
131
  end
131
132
 
132
133
  def generate_materialized_path
data/config/routes.rb CHANGED
@@ -94,8 +94,9 @@ Spina::Engine.routes.draw do
94
94
  # Pages
95
95
  get '/:locale/*id' => 'pages#show', constraints: {locale: /#{Spina.config.locales.join('|')}/ }
96
96
  get '/:locale/' => 'pages#homepage', constraints: {locale: /#{Spina.config.locales.join('|')}/ }
97
- get '/*id' => 'pages#show', as: "page", controller: 'pages', constraints: lambda { |request|
98
- (!(Rails.env.development? && request.env['PATH_INFO'].starts_with?('/rails/') || request.env['PATH_INFO'].starts_with?("/#{Spina.config.backend_path}") || request.env['PATH_INFO'].starts_with?('/attachments/'))) && request.path.exclude?("rails/active_storage")
97
+ get '/*id' => 'pages#show', as: "page", controller: 'pages', constraints: -> (request) {
98
+ request.path.exclude?(ActiveStorage.routes_prefix) &&
99
+ !(Rails.env.development? && request.path.starts_with?('/rails/'))
99
100
  }
100
101
  end
101
102
 
@@ -0,0 +1,18 @@
1
+ module Spina
2
+ class EmbedGenerator < Rails::Generators::NamedBase
3
+ source_root File.expand_path("../templates", __FILE__)
4
+
5
+ argument :attributes, type: :array, default: [], banner: "field field"
6
+
7
+ def create_embed_object
8
+ template "app/models/spina/embeds/embed.rb.tt", "app/models/spina/embeds/#{file_name}.rb"
9
+ end
10
+
11
+ def create_views
12
+ template "app/views/spina/embeds/_fields.html.erb", "app/views/spina/embeds/#{plural_file_name}/_#{file_name}_fields.html.erb"
13
+
14
+ template "app/views/spina/embeds/_partial.html.erb", "app/views/spina/embeds/#{plural_file_name}/_#{file_name}.html.erb"
15
+ end
16
+
17
+ end
18
+ end
@@ -1,52 +1,61 @@
1
1
  module Spina
2
2
  class InstallGenerator < Rails::Generators::Base
3
3
  source_root File.expand_path("../templates", __FILE__)
4
+
5
+ class_option :first_deploy, type: :boolean, default: false
6
+ class_option :silent, type: :boolean, default: false
4
7
 
5
8
  def create_initializer_file
6
- return if Rails.env.production?
9
+ return if first_deploy?
7
10
  template 'config/initializers/spina.rb'
8
11
  end
9
12
 
10
13
  def create_mobility_initializer_file
11
- return if Rails.env.production?
14
+ return if first_deploy?
12
15
  template 'config/initializers/mobility.rb'
13
16
  end
14
17
 
15
18
  def add_route
16
- return if Rails.env.production?
19
+ return if first_deploy?
17
20
  return if Rails.application.routes.routes.detect { |route| route.app.app == Spina::Engine }
18
21
  route "mount Spina::Engine => '/'"
19
22
  end
20
23
 
21
24
  def copy_migrations
22
- return if Rails.env.production?
25
+ return if first_deploy?
23
26
  rake 'spina:install:migrations'
24
27
  end
25
28
 
26
29
  def run_migrations
30
+ return if first_deploy?
27
31
  rake 'db:migrate'
28
32
  end
29
33
 
30
34
  def create_account
31
35
  return if ::Spina::Account.exists? && !no?('An account already exists. Skip? [Yn]')
32
36
  name = ::Spina::Account.first.try(:name) || 'MySite'
33
- name = ask("What would you like to name your website? [#{name}]").presence || name
34
- account = ::Spina::Account.first_or_create.update_attribute(:name, name)
37
+ if talkative_install?
38
+ name = ask("What would you like to name your website? [#{name}]").presence || name
39
+ end
40
+ account = ::Spina::Account.first_or_create.update(name: name)
35
41
  end
36
42
 
37
43
  def set_theme
38
44
  account = ::Spina::Account.first
39
- return if account.theme.present? && !no?("Theme '#{account.theme} is set. Skip? [Yn]")
45
+ return if account.theme.present? && !no?("Theme '#{account.theme}' is set. Skip? [Yn]")
40
46
 
41
- theme = begin
42
- theme = account.theme || themes.first
43
- theme = ask("What theme do you want to use? (#{themes.join('/')}) [#{theme}]").presence || theme
44
- end until theme.in? themes
47
+ theme = account.theme || themes.first
48
+ if talkative_install?
49
+ theme = begin
50
+ theme = ask("What theme do you want to use? (#{themes.join('/')}) [#{theme}]").presence || theme
51
+ end until theme.in? themes
52
+ end
45
53
 
46
- account.update_attribute(:theme, theme)
54
+ account.update(theme: theme)
47
55
  end
48
56
 
49
57
  def copy_template_files
58
+ return if options['first_deploy']
50
59
  theme = ::Spina::Account.first.theme
51
60
  if theme.in? ['default', 'demo']
52
61
  template "config/initializers/themes/#{theme}.rb"
@@ -59,10 +68,15 @@ module Spina
59
68
 
60
69
  def create_user
61
70
  return if ::Spina::User.exists? && !no?('A user already exists. Skip? [Yn]')
71
+
62
72
  email = 'admin@domain.com'
63
- email = ask("Please enter an email address for your first user: [#{email}]").presence || email
73
+ if talkative_install?
74
+ email = ask("Please enter an email address for your first user: [#{email}]").presence || email
75
+ end
64
76
  password = 'password'
65
- password = ask("Create a temporary password: [#{password}]").presence || password
77
+ if talkative_install?
78
+ password = ask("Create a temporary password: [#{password}]").presence || password
79
+ end
66
80
  @temporary_password = password
67
81
  ::Spina::User.create name: 'admin', email: email, password: password, admin: true
68
82
  end
@@ -91,6 +105,14 @@ module Spina
91
105
  themes = Spina::Theme.all.map(&:name)
92
106
  themes | ['default', 'demo']
93
107
  end
108
+
109
+ def first_deploy?
110
+ options['first_deploy']
111
+ end
112
+
113
+ def talkative_install?
114
+ !options['silent']
115
+ end
94
116
 
95
117
  end
96
118
  end
@@ -0,0 +1,18 @@
1
+ class <%= class_name %> < Spina::Embeds::Base
2
+ attributes <%= attributes.map{|attr| ":#{attr.name}"}.join(", ") %>
3
+
4
+ # You can use Rails validations on your attributes
5
+ validates <%= attributes.map{|attr| ":#{attr.name}"}.join(", ") %>, presence: true
6
+
7
+ # Pick an icon at https://heroicons.com
8
+ # and it'll show up in the list of embeddable components
9
+ heroicon "chip"
10
+
11
+ # If you want to render your embeddable component differently in Trix,
12
+ # you can choose to render a different partial
13
+ # Default: _<%= file_name %>.html.erb
14
+ #
15
+ # def to_trix_partial_path
16
+ # "spina/embeds/<%= plural_file_name %>/trix_<%= file_name %>"
17
+ # end
18
+ end
@@ -0,0 +1,13 @@
1
+ <div class="text-xl font-bold mb-3 text-gray-800">
2
+ Your embed
3
+ <div class="text-sm text-gray-500 font-normal">
4
+ Descriptive text
5
+ </div>
6
+ </div>
7
+
8
+ <!--
9
+ Put your fields here using Spina's built-in ViewComponents:
10
+
11
+ render Spina::Forms::LabelComponent.new(f, :url)
12
+ render Spina::Forms::TextFieldComponent.new(f, :url, autofocus: true)
13
+ -->
@@ -0,0 +1,2 @@
1
+ <!-- This is what visitors will see -->
2
+ Your embed
data/lib/spina/engine.rb CHANGED
@@ -9,7 +9,7 @@ require 'mobility'
9
9
  require 'rack-rewrite'
10
10
  require 'babosa'
11
11
  require 'attr_json'
12
- require 'view_component/engine'
12
+ require 'view_component'
13
13
  require 'jsonapi/serializer'
14
14
  require 'browser'
15
15
 
data/lib/spina/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spina
2
- VERSION = "2.5.0"
2
+ VERSION = "2.6.0"
3
3
  end
data/lib/spina.rb CHANGED
@@ -88,5 +88,10 @@ module Spina
88
88
 
89
89
  config_obj
90
90
  end
91
+
92
+ def mounted_at
93
+ Spina::Engine.routes.find_script_name({})
94
+ end
95
+
91
96
  end
92
97
  end
@@ -1,5 +1,22 @@
1
1
  namespace :spina do
2
-
2
+
3
+ desc "Install Spina"
4
+ task install: :environment do
5
+ begin
6
+ ActiveRecord::Base.connection
7
+ rescue ActiveRecord::NoDatabaseError
8
+ puts "ERROR: database does not exist, run \"rails db:create\" first"
9
+ else
10
+ Rails::Command.invoke :generate, ["spina:install"]
11
+ end
12
+ end
13
+
14
+ desc "First deploy"
15
+ task first_deploy: :environment do
16
+ # First deploy will run the same steps as the install generator, but skips copying files
17
+ Rails::Command.invoke :generate, ["spina:install", "--first-deploy"]
18
+ end
19
+
3
20
  desc "Generate all pages based on the theme config"
4
21
  task bootstrap: :environment do
5
22
  Spina::Account.first.save
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spina
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bram Jetten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-17 00:00:00.000000000 Z
11
+ date: 2021-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -196,16 +196,16 @@ dependencies:
196
196
  name: turbo-rails
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">="
199
+ - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: 0.8.0
201
+ version: '0.9'
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">="
206
+ - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 0.8.0
208
+ version: '0.9'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: stimulus-rails
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -1108,7 +1108,9 @@ files:
1108
1108
  - db/migrate/8_create_spina_media_folders.rb
1109
1109
  - db/migrate/9_create_spina_images.rb
1110
1110
  - db/seeds.rb
1111
+ - lib/generators/spina/embed_generator.rb
1111
1112
  - lib/generators/spina/install_generator.rb
1113
+ - lib/generators/spina/templates/app/models/spina/embeds/embed.rb.tt
1112
1114
  - lib/generators/spina/templates/app/views/default/pages/homepage.html.erb
1113
1115
  - lib/generators/spina/templates/app/views/default/pages/show.html.erb
1114
1116
  - lib/generators/spina/templates/app/views/default/shared/_navigation.html.erb
@@ -1119,6 +1121,8 @@ files:
1119
1121
  - lib/generators/spina/templates/app/views/demo/shared/_navigation.html.erb
1120
1122
  - lib/generators/spina/templates/app/views/layouts/default/application.html.erb
1121
1123
  - lib/generators/spina/templates/app/views/layouts/demo/application.html.erb
1124
+ - lib/generators/spina/templates/app/views/spina/embeds/_fields.html.erb
1125
+ - lib/generators/spina/templates/app/views/spina/embeds/_partial.html.erb
1122
1126
  - lib/generators/spina/templates/config/initializers/mobility.rb
1123
1127
  - lib/generators/spina/templates/config/initializers/spina.rb
1124
1128
  - lib/generators/spina/templates/config/initializers/themes/default.rb
@@ -1158,7 +1162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1158
1162
  requirements:
1159
1163
  - - ">="
1160
1164
  - !ruby/object:Gem::Version
1161
- version: '0'
1165
+ version: 2.7.0
1162
1166
  required_rubygems_version: !ruby/object:Gem::Requirement
1163
1167
  requirements:
1164
1168
  - - ">="