plutonium 0.12.10 → 0.12.11

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: 443b2efe86f5242ef6355f8da9d8af08dbbf66ebeaf8feb3adebbe9c0858cf45
4
+ data.tar.gz: 532843ca3dd3a9456e135dfa371d5110f46c726f5d86fed70a1ebe02ed8cfde5
5
5
  SHA512:
6
- metadata.gz: bdeb350835e78ff12d69789507bb3be8ac9b36dfb174e56d0e85ec85b97a47a41d32080ba626fb19cfaa46b3bc31913f209c58a3a4484dc40c8588398c83ada9
7
- data.tar.gz: cd0601de7a8d83add613e97695abad65639bdf988c609c3e587ca41d152aa21dfdb7384e602110dc87ac75d6007d583c52879c8311d4ae83f83022275a202a99
6
+ metadata.gz: 0d19d82bd1f5ac2a2fd4d383fffbc78d0c773213ff1c6648e44723c113ae4e6a4c8065ec2318df7738012f676547c60231aa895542a139e5d55394179476c3bc
7
+ data.tar.gz: 22bbf75790b8bc214be9946f339e7d607a64e31e363bf6d76eead20713536168dbbd6838d6c4bb62f453ec168fa458c6126a48c0c083ec839c83675d71bcec91
@@ -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
+ rails g pu:core:install
11
+ bundle add plutonium
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:text 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
+ ```
@@ -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.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
@@ -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