inner_plan-trix 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2e402d6a4151154f84895ac83bacb670e6b8a6cf8a8a564ab08c51cf636948be
4
+ data.tar.gz: b5c8b56b57ab7d380202a67cf71df9e356379411b77870beb46e9ac962a40670
5
+ SHA512:
6
+ metadata.gz: 931b0226aac16c06e4d5d8f65c682ef34b989510b751530dfc8e07e8335fcb0ebf6c0c5a54022743a265a5e13399d3cdde008a7acfb6bdc1b87c30463e1bf6e1
7
+ data.tar.gz: d9db0278d8586e5a8d055c0613ee7976674444a855976586583deefb884eea2fbb55f0606b795cac40584ebc218bd4bc299ae83af11da3cb4ccf1b1323a2bc88
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # InnerPlan::Trix
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem "inner_plan-trix"
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install inner_plan-trix
22
+ ```
23
+
24
+ Rails 7.1 has a reduced amount of allowed tags and attributes therefore ActionText
25
+ output is getting sanitized. In order to fix that, you might want to add something
26
+ like that in your env file:
27
+
28
+ ```
29
+ config.after_initialize do
30
+ ActionText::ContentHelper.sanitizer.class.allowed_tags += [ActionText::Attachment.tag_name, 'img', 'br'] + Rails::HTML5::Sanitizer.safe_list_sanitizer.allowed_tags
31
+ ActionText::ContentHelper.sanitizer.class.allowed_attributes += ['src', 'abbr', 'alt', 'cite', 'class', 'datetime', 'height', 'lang', 'name', 'title', 'width', 'xml:lang']
32
+ end
33
+ ```
34
+
35
+ ## Contributing
36
+ Contribution directions go here.
37
+
38
+ ## License
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ //= link_directory ../stylesheets/inner_plan/trix .css
2
+ //= link inner_plan/trix/application.js
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,15 @@
1
+ module InnerPlan::List::Operation
2
+ module IndexPatch
3
+ def self.prepended(base)
4
+ base.step :include_description, after: :find_models
5
+ end
6
+
7
+ private
8
+
9
+ def include_description(ctx, models:, **)
10
+ ctx[:models] = models.includes(tasks: :rich_text_description)
11
+ end
12
+ end
13
+ end
14
+
15
+ InnerPlan::List::Operation::Index.prepend(InnerPlan::List::Operation::IndexPatch) unless InnerPlan::List::Operation::Index.include?(InnerPlan::List::Operation::IndexPatch)
@@ -0,0 +1,6 @@
1
+ module InnerPlan
2
+ module Trix
3
+ class ApplicationController < ActionController::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module InnerPlan
2
+ module Trix
3
+ module ApplicationHelper
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,2 @@
1
+ import 'trix'
2
+ import '@rails/actiontext'
@@ -0,0 +1,6 @@
1
+ module InnerPlan
2
+ module Trix
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module InnerPlan
2
+ module Trix
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: "from@example.com"
5
+ layout "mailer"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module InnerPlan
2
+ module TaskPatch
3
+ def self.prepended(base)
4
+ base.has_rich_text :description
5
+ end
6
+ end
7
+ end
8
+
9
+ InnerPlan::Task.prepend(InnerPlan::TaskPatch)
@@ -0,0 +1,7 @@
1
+ module InnerPlan
2
+ module Trix
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module InnerPlan
2
+ module Tasks
3
+ module DescriptionRendererPatch
4
+ def self.prepended(base)
5
+ base.step nil, delete: :apply_simple_format
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ # @todo why is that being called twice?
12
+ InnerPlan::Tasks::DescriptionRenderer.prepend(InnerPlan::Tasks::DescriptionRendererPatch) unless InnerPlan::Tasks::DescriptionRenderer.include?(InnerPlan::Tasks::DescriptionRendererPatch)
@@ -0,0 +1,14 @@
1
+ <figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
2
+ <% if blob.representable? %>
3
+ <%= image_tag main_app.url_for(blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ])) %>
4
+ <% end %>
5
+
6
+ <figcaption class="attachment__caption">
7
+ <% if caption = blob.try(:caption) %>
8
+ <%= caption %>
9
+ <% else %>
10
+ <span class="attachment__name"><%= blob.filename %></span>
11
+ <span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
12
+ <% end %>
13
+ </figcaption>
14
+ </figure>
@@ -0,0 +1,3 @@
1
+ <div class="trix-content">
2
+ <%= yield -%>
3
+ </div>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Inner plan trix</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag "inner_plan/trix/application", media: "all" %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ InnerPlan::Trix::Engine.routes.draw do
2
+ end
@@ -0,0 +1,44 @@
1
+ module InnerPlan
2
+ module Trix
3
+ class Engine < ::Rails::Engine
4
+ isolate_namespace InnerPlan::Trix
5
+
6
+ config.to_prepare do
7
+ Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_patch*.rb')) do |c|
8
+ Rails.configuration.cache_classes ? require(c) : load(c)
9
+ end
10
+
11
+ InnerPlan.importmap.pin "trix"
12
+ InnerPlan.importmap.pin "@rails/actiontext", to: "actiontext.esm.js"
13
+ InnerPlan.importmap.pin "inner_plan/trix/application", to: "inner_plan/trix/application.js", preload: true
14
+
15
+ InnerPlan.configuration.additional_importmap_modules << 'inner_plan/trix/application'
16
+ end
17
+
18
+ initializer "inner_plan_trix.importmap", before: "importmap" do |app|
19
+ # https://github.com/rails/importmap-rails#sweeping-the-cache-in-development-and-test
20
+ app.config.importmap.cache_sweepers << root.join("app/javascript")
21
+ end
22
+
23
+ initializer "inner_plan_trix.assets" do |app|
24
+ # my_engine/app/javascript needs to be in the asset path
25
+ app.config.assets.paths << root.join("app/javascript")
26
+ end
27
+
28
+ config.after_initialize do
29
+ InnerPlan.configuration.task_edit_view_rows
30
+ .get(:secondary_row)
31
+ .content
32
+ .replace(:description, InnerPlan::SmartArray::Item.new(
33
+ :description,
34
+ { span: 12 },
35
+ proc { |context:, form:|
36
+ InnerPlan::Tasks::Form::ItemComponent.new(icon: Phlex::Icons::Tabler::FileText, title: 'Description') do
37
+ context.plain form.rich_text_area(:description, autofocus: (context.focus == :description))
38
+ end
39
+ })
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module InnerPlan
2
+ module Trix
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "inner_plan/trix/version"
2
+ require "inner_plan/trix/engine"
3
+
4
+ module InnerPlan
5
+ module Trix
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :inner_plan_trix do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inner_plan-trix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mbajur
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.1.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 7.1.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: inner_plan
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Trix and ActionText plugin for InnerPlan
42
+ email:
43
+ - mbajur@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - Rakefile
50
+ - app/assets/config/inner_plan_trix_manifest.js
51
+ - app/assets/stylesheets/inner_plan/trix/application.css
52
+ - app/concepts/inner_plan/list/operation/index_patch.rb
53
+ - app/controllers/inner_plan/trix/application_controller.rb
54
+ - app/helpers/inner_plan/trix/application_helper.rb
55
+ - app/javascript/inner_plan/trix/application.js
56
+ - app/jobs/inner_plan/trix/application_job.rb
57
+ - app/mailers/inner_plan/trix/application_mailer.rb
58
+ - app/models/inner_plan/task_patch.rb
59
+ - app/models/inner_plan/trix/application_record.rb
60
+ - app/services/inner_plan/tasks/description_renderer_patch.rb
61
+ - app/views/active_storage/blobs/_blob.html.erb
62
+ - app/views/layouts/action_text/contents/_content.html.erb
63
+ - app/views/layouts/inner_plan/trix/application.html.erb
64
+ - config/routes.rb
65
+ - lib/inner_plan/trix.rb
66
+ - lib/inner_plan/trix/engine.rb
67
+ - lib/inner_plan/trix/version.rb
68
+ - lib/tasks/inner_plan/trix_tasks.rake
69
+ homepage: https://github.com/mbajur/inner_plan-trix
70
+ licenses: []
71
+ metadata:
72
+ homepage_uri: https://github.com/mbajur/inner_plan-trix
73
+ source_code_uri: https://github.com/mbajur/inner_plan-trix
74
+ changelog_uri: https://github.com/mbajur/inner_plan-trix
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.5.23
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Trix and ActionText plugin for InnerPlan
94
+ test_files: []