plutonium 0.12.10 → 0.12.12

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: 053e7c4ed94242099eed9ecf819521ccb175ab5e8649a6b771ffe86b743cff64
4
- data.tar.gz: 83a54d5ded5d6ed7fcf68179cc0ecd99d92975f1965edefb029731b749c1963c
3
+ metadata.gz: 8a2acf897212a5a3c4311c5b31b90068bef1f527c01ef26f7f2786f83208b5fc
4
+ data.tar.gz: 0a1dc0f87bea2371ce6c15fea9cc9d15965a2f7c61898796da7b4f0a568813e8
5
5
  SHA512:
6
- metadata.gz: bdeb350835e78ff12d69789507bb3be8ac9b36dfb174e56d0e85ec85b97a47a41d32080ba626fb19cfaa46b3bc31913f209c58a3a4484dc40c8588398c83ada9
7
- data.tar.gz: cd0601de7a8d83add613e97695abad65639bdf988c609c3e587ca41d152aa21dfdb7384e602110dc87ac75d6007d583c52879c8311d4ae83f83022275a202a99
6
+ metadata.gz: 3cfc8b3eaa72e09e3029cba86f3cce37a2892d08a6b4f4b239f560c4c4a4a5d2aacb1aae9073bd6c7239ad51ca82f6d5ea46c6a80ec0bf0310f0eda745625e95
7
+ data.tar.gz: c4fa401ee4a836fa312e8af919ed4d6b0a3092f309176471de6deab64085298d1e05163d49b1b94657ff30efc36865c42b4f54437ff0c3d3580dc3430062806b
@@ -0,0 +1,218 @@
1
+ # Plutonium: The pre-alpha demo
2
+
3
+ - Introduce the project
4
+ - Install Rails
5
+ ```bash
6
+ rails new demo -c tailwind -j esbuild
7
+ ```
8
+ - Install Plutonium
9
+ ```bash
10
+ bundle add plutonium
11
+ rails g pu:core:install
12
+ ```
13
+ - Install useful gems
14
+ ```bash
15
+ rails g pu:gem:annotate
16
+ ```
17
+ - Install rodauth
18
+ ```bash
19
+ rails g pu:rodauth:install
20
+ ```
21
+ - Create rodauth user account
22
+ ```bash
23
+ rails g pu:rodauth:account user
24
+ ```
25
+ - Create blogging feature package
26
+ ```bash
27
+ rails g pu:pkg:feature blogging
28
+ ```
29
+ - Create blog resource
30
+ ```bash
31
+ rails g pu:res:scaffold blog user:belongs_to slug:string title:string content:text state:string published_at:datetime
32
+ ```
33
+ - Create dashboard app package
34
+ ```bash
35
+ rails g pu:pkg:app dashboard
36
+ ```
37
+ - Connect the blog to the dashboard
38
+ ```bash
39
+ rails g pu:res:conn
40
+ ```
41
+ - Scope dashboard to user
42
+
43
+ ```ruby
44
+ # packages/dashboard_app/lib/engine.rb
45
+
46
+ scope_to_entity User, strategy: :current_user
47
+ # add directives above.
48
+ ```
49
+
50
+ - Demonstrate queries
51
+
52
+ ```ruby
53
+ # packages/dashboard_app/lib/engine.rb
54
+
55
+ def define_filters
56
+ # define custom filters
57
+ define_search -> (scope, search:) { scope.where("title LIKE ?", "%#{search}%") }
58
+ end
59
+
60
+ def define_scopes
61
+ # define custom scopes
62
+ define_scope :published, -> (scope) { scope.where(state: :published) }
63
+ define_scope :drafts, -> (scope) { scope.where(state: :draft) }
64
+ end
65
+
66
+ def define_sorters
67
+ # define custom sorters
68
+ define_sorter :title
69
+ define_sorter :content
70
+ end
71
+ ```
72
+
73
+ - Create a custom action
74
+
75
+ ```ruby
76
+ # packages/blogging/app/interactions/blogging/blog_interactions/publish.rb
77
+
78
+ module Blogging
79
+ module BlogInteractions
80
+ class Publish < ResourceInteraction
81
+ object :resource, class: Blog
82
+
83
+ def execute
84
+ errors.merge!(resource.errors) unless resource.update(state: "published", published_at: Time.current)
85
+ resource
86
+ end
87
+ end
88
+ end
89
+ end
90
+ ```
91
+
92
+ ```ruby
93
+ # packages/blogging/app/presenters/blogging/blog_presenter.rb
94
+
95
+ define_interactive_action :publish, label: 'Publish',
96
+ interaction: BlogInteractions::Publish,
97
+ icon: "outline/book",
98
+ color: :green
99
+ ```
100
+
101
+ - Create blog_comment resource
102
+ ```bash
103
+ rails g pu:res:scaffold blog_comment blogging/blog:belongs_to user:belongs_to content:text
104
+ ```
105
+ - Define associations
106
+
107
+ ```ruby
108
+ # packages/blogging/app/models/blogging/blog.rb
109
+
110
+ has_many :comments
111
+ ```
112
+
113
+ ```ruby
114
+ # packages/blogging/app/policies/blogging/blog_policy.rb
115
+
116
+ def permitted_attributes_for_show
117
+ super + [:comments]
118
+ end
119
+ ```
120
+
121
+ - Connect comments to demonstrate auto linking
122
+ ```bash
123
+ rail g pu:res:conn
124
+ ```
125
+ - Demonstrate plutonium association panels
126
+
127
+ ```ruby
128
+ # packages/blogging/app/policies/blogging/blog_policy.rb
129
+
130
+ def permitted_attributes_for_show
131
+ super
132
+ end
133
+
134
+ def permitted_associations
135
+ %i[comments]
136
+ end
137
+ ```
138
+
139
+ 19. Demonstrate nested_attributes
140
+
141
+ ```ruby
142
+ accepts_nested_attributes_for :comments, reject_if: :all_blank
143
+
144
+ define_nested_input :comments, inputs: %i[user content], limit: 1 do |input|
145
+ input.define_field_input :content, type: :markdown
146
+ end
147
+ ```
148
+
149
+ - Create a custom field renderer
150
+
151
+ ```bash
152
+ rails g pu:field:renderer markdown
153
+ bundle add redcarpet markdown
154
+ ```
155
+
156
+ ```ruby
157
+ Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true).render "content"
158
+ ```
159
+
160
+ - Create a custom field input
161
+
162
+ ```bash
163
+ rails g pu:field:input
164
+ ```
165
+
166
+ https://github.com/Ionaru/easy-markdown-editor
167
+
168
+ ```html
169
+ # app/views/layouts/resource.html.erb <% layout.with_assets do %>
170
+ <link
171
+ rel="stylesheet"
172
+ href="https://unpkg.com/easymde/dist/easymde.min.css"
173
+ />
174
+ <script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
175
+ <% end %>
176
+ ```
177
+
178
+ ```bash
179
+ rails g stimulus markdown_input
180
+ ```
181
+
182
+ ```js
183
+ // app/javascript/controllers/markdown_input_controller.js
184
+
185
+ connect() {
186
+ console.log("markdown-input connected", this.element)
187
+
188
+ this.markdown = new EasyMDE({
189
+ element: this.element,
190
+ toolbar: ["bold", "italic", "heading", "|", "quote"]
191
+ })
192
+ }
193
+
194
+ disconnect() {
195
+ this.markdown.toTextArea()
196
+ this.markdown = null
197
+ }
198
+ ```
199
+
200
+ ```ruby
201
+ # app/plutonium/fields/inputs/markdown_input.rb
202
+
203
+ class MarkdownInput < Plutonium::Core::Fields::Inputs::Base
204
+ def render
205
+ form.input name, **options
206
+ end
207
+
208
+ private
209
+
210
+ def input_options
211
+ {input_html: {data: {controller: "markdown-input"}}}
212
+ end
213
+ end
214
+ ```
215
+
216
+ ```bash
217
+ rails g pu:core:assets
218
+ ```
@@ -27,6 +27,7 @@ module Pu
27
27
 
28
28
  def install_dependencies
29
29
  `yarn add @radioactive-labs/plutonium`
30
+ `yarn add flowbite @tailwindcss/forms`
30
31
  end
31
32
 
32
33
  def configure_application
@@ -1,12 +1,12 @@
1
1
  const { execSync } = require('child_process');
2
2
  const plutoniumGemPath = execSync("bundle show plutonium").toString().trim();
3
- const plutoniumTailwindConfig = require(`${plutoniumGemPath}/tailwind.config.js`)
3
+ const plutoniumTailwindConfig = require(`${plutoniumGemPath}/tailwind.options.js`)
4
4
 
5
5
  module.exports = {
6
6
  darkMode: plutoniumTailwindConfig.darkMode,
7
7
  plugins: [
8
8
  // add plugins here
9
- ].concat(plutoniumTailwindConfig.plugins),
9
+ ].concat(plutoniumTailwindConfig.plugins.map((plugin) => require(plugin))),
10
10
  theme: plutoniumTailwindConfig.theme,
11
11
  content: [
12
12
  `${__dirname}/app/views/**/*.html.erb`,
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../lib/plutonium_generators"
4
+
5
+ module Pu
6
+ module Gem
7
+ class AnnotateGenerator < Rails::Generators::Base
8
+ include PlutoniumGenerators::Generator
9
+
10
+ source_root File.expand_path("templates", __dir__)
11
+
12
+ desc "Install the annnotate gem"
13
+
14
+ def start
15
+ bundle "annotate", group: :development
16
+ copy_file "lib/tasks/auto_annotate_models.rake"
17
+ rescue => e
18
+ exception "#{self.class} failed:", e
19
+ end
20
+ end
21
+ end
22
+ end
File without changes
@@ -0,0 +1,59 @@
1
+ # NOTE: only doing this in development as some production environments (Heroku)
2
+ # NOTE: are sensitive to local FS writes, and besides -- it's just not proper
3
+ # NOTE: to have a dev-mode tool do its thing in production.
4
+ return unless Rails.env.development?
5
+
6
+ require "annotate"
7
+ task :set_annotation_options do
8
+ # You can override any of these by setting an environment variable of the
9
+ # same name.
10
+ Annotate.set_defaults(
11
+ "active_admin" => "false",
12
+ "additional_file_patterns" => [],
13
+ "routes" => "false",
14
+ "models" => "true",
15
+ "position_in_routes" => "before",
16
+ "position_in_class" => "before",
17
+ "position_in_test" => "before",
18
+ "position_in_fixture" => "before",
19
+ "position_in_factory" => "before",
20
+ "position_in_serializer" => "before",
21
+ "show_foreign_keys" => "true",
22
+ "show_complete_foreign_keys" => "false",
23
+ "show_indexes" => "true",
24
+ "simple_indexes" => "false",
25
+ "model_dir" => ([Rails.application.root.join("app/models")] + Dir[Rails.application.root.join("packages/*/app/models")]).join(","),
26
+ "root_dir" => "",
27
+ "include_version" => "false",
28
+ "require" => "",
29
+ "exclude_tests" => "true",
30
+ "exclude_fixtures" => "true",
31
+ "exclude_factories" => "true",
32
+ "exclude_serializers" => "true",
33
+ "exclude_scaffolds" => "true",
34
+ "exclude_controllers" => "true",
35
+ "exclude_helpers" => "true",
36
+ "exclude_sti_subclasses" => "false",
37
+ "ignore_model_sub_dir" => "false",
38
+ "ignore_columns" => nil,
39
+ "ignore_routes" => nil,
40
+ "ignore_unknown_models" => "false",
41
+ "hide_limit_column_types" => "integer,bigint,boolean",
42
+ "hide_default_column_types" => "json,jsonb,hstore",
43
+ "skip_on_db_migrate" => "false",
44
+ "format_bare" => "true",
45
+ "format_rdoc" => "false",
46
+ "format_yard" => "false",
47
+ "format_markdown" => "false",
48
+ "sort" => "false",
49
+ "force" => "false",
50
+ "frozen" => "false",
51
+ "classified_sort" => "true",
52
+ "trace" => "false",
53
+ "wrapper_open" => nil,
54
+ "wrapper_close" => nil,
55
+ "with_comment" => "true"
56
+ )
57
+ end
58
+
59
+ Annotate.load_tasks
@@ -1,3 +1,3 @@
1
1
  module Plutonium
2
- VERSION = "0.12.10"
2
+ VERSION = "0.12.12"
3
3
  end
data/tailwind.config.js CHANGED
@@ -1,91 +1,9 @@
1
1
  /** @type {import('tailwindcss').Config} */
2
2
 
3
- export const content = [
4
- `${__dirname}/src/**/*.{css,js}`,
5
- `${__dirname}/app/views/**/*.{rb,erb,js}`,
6
- `${__dirname}/config/initializers/simple_form.rb`,
3
+ import options from "./tailwind.options.js"
7
4
 
8
- // node modules are not packaged as part of the gem.
9
- // requires users to have flowbite installed in their own project.
10
- './node_modules/flowbite/**/*.js',
11
- // TODO: temporary workaround for legacy components.
12
- // To be removed after converting buttons_helper and other files containing tailwind to components .
13
- // `${__dirname}/lib/plutonium/**/*.{rb,erb}`
14
- ];
15
- export const darkMode = "selector";
16
- export const plugins = [
17
- // requires users to have the required packages installed in their own project.
18
- require('@tailwindcss/forms'),
19
- require('flowbite/plugin'),
20
- ];
21
- export const theme = {
22
- extend: {
23
- colors: {
24
- primary: {
25
- '50': '#f0f7fe',
26
- '100': '#ddecfc',
27
- '200': '#c3dffa',
28
- '300': '#99ccf7',
29
- '400': '#69b0f1',
30
- '500': '#4691eb',
31
- '600': '#3174df',
32
- '700': '#285fcc',
33
- '800': '#274ea6',
34
- '900': '#244484',
35
- '950': '#1b2b50',
36
- },
37
- },
38
- screens: {
39
- 'xs': '475px',
40
- },
41
- },
42
- fontFamily: {
43
- 'body': [
44
- 'Lato',
45
- 'ui-sans-serif',
46
- 'system-ui',
47
- '-apple-system',
48
- 'system-ui',
49
- 'Segoe UI',
50
- 'Roboto',
51
- 'Helvetica Neue',
52
- 'Arial',
53
- 'Noto Sans',
54
- 'sans-serif',
55
- 'Apple Color Emoji',
56
- 'Segoe UI Emoji',
57
- 'Segoe UI Symbol',
58
- 'Noto Color Emoji'
59
- ],
60
- 'sans': [
61
- 'Lato',
62
- 'ui-sans-serif',
63
- 'system-ui',
64
- '-apple-system',
65
- 'system-ui',
66
- 'Segoe UI',
67
- 'Roboto',
68
- 'Helvetica Neue',
69
- 'Arial',
70
- 'Noto Sans',
71
- 'sans-serif',
72
- 'Apple Color Emoji',
73
- 'Segoe UI Emoji',
74
- 'Segoe UI Symbol',
75
- 'Noto Color Emoji'
76
- ]
77
- }
78
- };
79
-
80
-
81
- // const _safelist = [];
82
- // // Object.keys(colors).forEach((color) => {
83
- // // if (typeof colors[color] === 'object') {
84
- // // Object.keys(colors[color]).forEach((shade) => {
85
- // // safelist.push(`bg-${color}-${shade}`);
86
- // // safelist.push(`text-${color}-${shade}`);
87
- // // // Add other utilities as needed
88
- // // });
89
- // // }
90
- // // });
91
- // export const safelist = _safelist;
5
+ export const content = options.content
6
+ export const darkMode = options.darkMode
7
+ export const plugins = options.plugins.map((plugin) => require(plugin))
8
+ export const theme = options.theme
9
+ export const safelist = options.safelist
@@ -0,0 +1,89 @@
1
+ export const content = [
2
+ `${__dirname}/src/**/*.{css,js}`,
3
+ `${__dirname}/app/views/**/*.{rb,erb,js}`,
4
+ `${__dirname}/config/initializers/simple_form.rb`,
5
+
6
+ // node modules are not packaged as part of the gem.
7
+ // requires users to have flowbite installed in their own project.
8
+ './node_modules/flowbite/**/*.js',
9
+ // TODO: temporary workaround for legacy components.
10
+ // To be removed after converting buttons_helper and other files containing tailwind to components .
11
+ // `${__dirname}/lib/plutonium/**/*.{rb,erb}`
12
+ ];
13
+ export const darkMode = "selector";
14
+ export const plugins = [
15
+ // requires users to have the required packages installed in their own project.
16
+ "@tailwindcss/forms",
17
+ "flowbite/plugin"
18
+ ];
19
+ export const theme = {
20
+ extend: {
21
+ colors: {
22
+ primary: {
23
+ '50': '#f0f7fe',
24
+ '100': '#ddecfc',
25
+ '200': '#c3dffa',
26
+ '300': '#99ccf7',
27
+ '400': '#69b0f1',
28
+ '500': '#4691eb',
29
+ '600': '#3174df',
30
+ '700': '#285fcc',
31
+ '800': '#274ea6',
32
+ '900': '#244484',
33
+ '950': '#1b2b50',
34
+ },
35
+ },
36
+ screens: {
37
+ 'xs': '475px',
38
+ },
39
+ },
40
+ fontFamily: {
41
+ 'body': [
42
+ 'Lato',
43
+ 'ui-sans-serif',
44
+ 'system-ui',
45
+ '-apple-system',
46
+ 'system-ui',
47
+ 'Segoe UI',
48
+ 'Roboto',
49
+ 'Helvetica Neue',
50
+ 'Arial',
51
+ 'Noto Sans',
52
+ 'sans-serif',
53
+ 'Apple Color Emoji',
54
+ 'Segoe UI Emoji',
55
+ 'Segoe UI Symbol',
56
+ 'Noto Color Emoji'
57
+ ],
58
+ 'sans': [
59
+ 'Lato',
60
+ 'ui-sans-serif',
61
+ 'system-ui',
62
+ '-apple-system',
63
+ 'system-ui',
64
+ 'Segoe UI',
65
+ 'Roboto',
66
+ 'Helvetica Neue',
67
+ 'Arial',
68
+ 'Noto Sans',
69
+ 'sans-serif',
70
+ 'Apple Color Emoji',
71
+ 'Segoe UI Emoji',
72
+ 'Segoe UI Symbol',
73
+ 'Noto Color Emoji'
74
+ ]
75
+ }
76
+ };
77
+
78
+ export const safelist = [];
79
+
80
+ // // Object.keys(colors).forEach((color) => {
81
+ // // if (typeof colors[color] === 'object') {
82
+ // // Object.keys(colors[color]).forEach((shade) => {
83
+ // // safelist.push(`bg-${color}-${shade}`);
84
+ // // safelist.push(`text-${color}-${shade}`);
85
+ // // // Add other utilities as needed
86
+ // // });
87
+ // // }
88
+ // // });
89
+ // export const safelist = _safelist;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.10
4
+ version: 0.12.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-11 00:00:00.000000000 Z
11
+ date: 2024-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -208,6 +208,7 @@ executables:
208
208
  extensions: []
209
209
  extra_rdoc_files: []
210
210
  files:
211
+ - "# Plutonium: The pre-alpha demo.md"
211
212
  - ".node-version"
212
213
  - ".rspec"
213
214
  - ".ruby-version"
@@ -883,6 +884,9 @@ files:
883
884
  - lib/generators/pu/field/renderer/renderer_generator.rb
884
885
  - lib/generators/pu/field/renderer/templates/.keep
885
886
  - lib/generators/pu/field/renderer/templates/renderer.rb.tt
887
+ - lib/generators/pu/gem/annotate/annotate_generator.rb
888
+ - lib/generators/pu/gem/annotate/templates/.keep
889
+ - lib/generators/pu/gem/annotate/templates/lib/tasks/auto_annotate_models.rake
886
890
  - lib/generators/pu/gem/dotenv/dotenv_generator.rb
887
891
  - lib/generators/pu/gem/dotenv/templates/.env
888
892
  - lib/generators/pu/gem/dotenv/templates/.env.local
@@ -1161,6 +1165,7 @@ files:
1161
1165
  - src/js/turbo/turbo_debug.js
1162
1166
  - src/js/turbo/turbo_frame_monkey_patch.js
1163
1167
  - tailwind.config.js
1168
+ - tailwind.options.js
1164
1169
  - templates/base.rb
1165
1170
  homepage: https://github.com/radioactive-labs/plutonium-core
1166
1171
  licenses: