action_mosaico 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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +6 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +5 -0
  6. data/CODE_OF_CONDUCT.md +84 -0
  7. data/Gemfile +19 -0
  8. data/Gemfile.lock +114 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +45 -0
  11. data/Rakefile +16 -0
  12. data/action_mosaico.gemspec +45 -0
  13. data/app/assets/javascripts/action_mosaico.js +0 -0
  14. data/app/assets/stylesheets/action_mosaico.css +0 -0
  15. data/app/helpers/action_mosaico/content_helper.rb +51 -0
  16. data/app/helpers/action_mosaico/tag_helper.rb +95 -0
  17. data/app/javascript/action_mosaico/attachment_upload.js +45 -0
  18. data/app/javascript/action_mosaico/index.js +10 -0
  19. data/app/models/action_mosaico/encrypted_rich_text.rb +9 -0
  20. data/app/models/action_mosaico/record.rb +9 -0
  21. data/app/models/action_mosaico/rich_text.rb +33 -0
  22. data/app/views/action_text/attachables/_missing_attachable.html.erb +1 -0
  23. data/app/views/action_text/attachables/_remote_image.html.erb +8 -0
  24. data/app/views/action_text/attachment_galleries/_attachment_gallery.html.erb +3 -0
  25. data/app/views/action_text/contents/_content.html.erb +1 -0
  26. data/app/views/active_storage/blobs/_blob.html.erb +14 -0
  27. data/app/views/layouts/action_text/contents/_content.html.erb +3 -0
  28. data/bin/console +15 -0
  29. data/bin/setup +8 -0
  30. data/db/migrate/20180528164100_create_action_mosaico_tables.rb +28 -0
  31. data/lib/action_mosaico/attachable.rb +91 -0
  32. data/lib/action_mosaico/attachables/content_attachment.rb +37 -0
  33. data/lib/action_mosaico/attachables/missing_attachable.rb +13 -0
  34. data/lib/action_mosaico/attachables/remote_image.rb +45 -0
  35. data/lib/action_mosaico/attachment.rb +109 -0
  36. data/lib/action_mosaico/attachment_gallery.rb +70 -0
  37. data/lib/action_mosaico/attachments/caching.rb +17 -0
  38. data/lib/action_mosaico/attachments/minification.rb +17 -0
  39. data/lib/action_mosaico/attachments/mosaico_conversion.rb +37 -0
  40. data/lib/action_mosaico/attribute.rb +66 -0
  41. data/lib/action_mosaico/content.rb +132 -0
  42. data/lib/action_mosaico/encryption.rb +39 -0
  43. data/lib/action_mosaico/engine.rb +86 -0
  44. data/lib/action_mosaico/fixture_set.rb +61 -0
  45. data/lib/action_mosaico/fragment.rb +57 -0
  46. data/lib/action_mosaico/html_conversion.rb +25 -0
  47. data/lib/action_mosaico/mosaico_attachment.rb +95 -0
  48. data/lib/action_mosaico/plain_text_conversion.rb +84 -0
  49. data/lib/action_mosaico/rendering.rb +30 -0
  50. data/lib/action_mosaico/serialization.rb +36 -0
  51. data/lib/action_mosaico/system_test_helper.rb +55 -0
  52. data/lib/action_mosaico/version.rb +5 -0
  53. data/lib/action_mosaico.rb +40 -0
  54. data/lib/generators/action_mosaico/install/install_generator.rb +60 -0
  55. data/lib/generators/action_mosaico/install/templates/actiontext.css +35 -0
  56. data/lib/tasks/action_mosaico.rake +6 -0
  57. data/package.json +32 -0
  58. metadata +172 -0
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionMosaico
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+ require 'active_support/rails'
5
+
6
+ require 'nokogiri'
7
+
8
+ module ActionMosaico
9
+ extend ActiveSupport::Autoload
10
+
11
+ autoload :Attachable
12
+ autoload :AttachmentGallery
13
+ autoload :Attachment
14
+ autoload :Attribute
15
+ autoload :Content
16
+ autoload :Encryption
17
+ autoload :Fragment
18
+ autoload :FixtureSet
19
+ autoload :HtmlConversion
20
+ autoload :PlainTextConversion
21
+ autoload :Rendering
22
+ autoload :Serialization
23
+ autoload :MosaicoAttachment
24
+
25
+ module Attachables
26
+ extend ActiveSupport::Autoload
27
+
28
+ autoload :ContentAttachment
29
+ autoload :MissingAttachable
30
+ autoload :RemoteImage
31
+ end
32
+
33
+ module Attachments
34
+ extend ActiveSupport::Autoload
35
+
36
+ autoload :Caching
37
+ autoload :Minification
38
+ autoload :MosaicoConversion
39
+ end
40
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+ require 'json'
5
+
6
+ module ActionMosaico
7
+ module Generators
8
+ class InstallGenerator < ::Rails::Generators::Base
9
+ source_root File.expand_path('templates', __dir__)
10
+
11
+ def install_javascript_dependencies
12
+ if Pathname(destination_root).join('package.json').exist?
13
+ say 'Installing JavaScript dependencies', :green
14
+ run 'yarn add action_mosaico mosaico'
15
+ end
16
+ end
17
+
18
+ def append_javascript_dependencies
19
+ destination = Pathname(destination_root)
20
+
21
+ if (application_javascript_path = destination.join('app/javascript/application.js')).exist?
22
+ insert_into_file application_javascript_path.to_s, %(import "mosaico"\nimport actionmosaico"\n)
23
+ else
24
+ say <<~INSTRUCTIONS, :green
25
+ You must import the actionmosaico and mosaico JavaScript modules in your application entrypoint.
26
+ INSTRUCTIONS
27
+ end
28
+
29
+ if (importmap_path = destination.join('config/importmap.rb')).exist?
30
+ append_to_file importmap_path.to_s, %(pin "mosaico"\npin "actionmosaico", to: "actionmosaico.js"\n)
31
+ end
32
+ end
33
+
34
+ def create_actionmosaico_files
35
+ template 'actionmosaico.css', 'app/assets/stylesheets/actionmosaico.css'
36
+
37
+ gem_root = "#{__dir__}/../../../.."
38
+
39
+ copy_file "#{gem_root}/app/views/active_storage/blobs/_blob.html.erb",
40
+ 'app/views/active_storage/blobs/_blob.html.erb'
41
+
42
+ copy_file "#{gem_root}/app/views/layouts/action_mosaico/contents/_content.html.erb",
43
+ 'app/views/layouts/action_mosaico/contents/_content.html.erb'
44
+ end
45
+
46
+ def enable_image_processing_gem
47
+ if (gemfile_path = Pathname(destination_root).join('Gemfile')).exist?
48
+ say 'Ensure image_processing gem has been enabled so image uploads will work (remember to bundle!)'
49
+ uncomment_lines gemfile_path, /gem "image_processing"/
50
+ end
51
+ end
52
+
53
+ def create_migrations
54
+ rails_command 'railties:install:migrations FROM=active_storage,action_mosaico', inline: true
55
+ end
56
+
57
+ hook_for :test_framework
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
3
+ * the mosaico-editor content (whether displayed or under editing). Feel free to incorporate this
4
+ * inclusion directly in any other asset bundle and remove this file.
5
+ *
6
+ <%- if defined?(Webpacker::Engine) -%>
7
+ *= require mosaico/dist/mosaico
8
+ <%- else -%>
9
+ *= require mosaico
10
+ <% end -%>
11
+ */
12
+
13
+ /*
14
+ * We need to override trix.css’s image gallery styles to accommodate the
15
+ * <action-text-attachment> element we wrap around attachments. Otherwise,
16
+ * images in galleries will be squished by the max-width: 33%; rule.
17
+ */
18
+ .trix-content .attachment-gallery > action-text-attachment,
19
+ .trix-content .attachment-gallery > .attachment {
20
+ flex: 1 0 33%;
21
+ padding: 0 0.5em;
22
+ max-width: 33%;
23
+ }
24
+
25
+ .trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
26
+ .trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
27
+ .trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
28
+ flex-basis: 50%;
29
+ max-width: 50%;
30
+ }
31
+
32
+ .trix-content action-text-attachment .attachment {
33
+ padding: 0 !important;
34
+ max-width: 100% !important;
35
+ }
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ desc 'Copy over the migration, stylesheet, and JavaScript files'
4
+ task 'action_mosaico:install' do
5
+ Rails::Command.invoke :generate, ['action_mosaico:install']
6
+ end
data/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "action_mosaico",
3
+ "version": "0.1.0",
4
+ "description": "The Mosaico email editor on Rails",
5
+ "main": "app/javascript/action_mosaico/index.js",
6
+ "type": "module",
7
+ "files": [
8
+ "app/javascript/action_mosaico/*.js"
9
+ ],
10
+ "homepage": "https://github.com/aventumx/action_mosaico",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/aventumx/action_mosaico.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/aventumx/action_mosaico/issues"
17
+ },
18
+ "author": "AventumX, LLP",
19
+ "contributors": [
20
+ "Recker Swartz <reckerswartz@hotmail.com>"
21
+ ],
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "@rails/activestorage": ">= 7.0.0-alpha1"
25
+ },
26
+ "peerDependencies": {
27
+ "mosaico": "^0.17.5"
28
+ },
29
+ "devDependencies": {
30
+ "mosaico": "^0.17.5"
31
+ }
32
+ }
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: action_mosaico
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Recker Swartz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '6.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '6.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '6.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activestorage
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '6.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '6.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: actionpack
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '6.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.8.5
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.5
83
+ description: The Mosaico email editor on Rails.
84
+ email:
85
+ - reckerswartz@hotmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".rubocop.yml"
91
+ - ".ruby-gemset"
92
+ - ".ruby-version"
93
+ - CHANGELOG.md
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - action_mosaico.gemspec
101
+ - app/assets/javascripts/action_mosaico.js
102
+ - app/assets/stylesheets/action_mosaico.css
103
+ - app/helpers/action_mosaico/content_helper.rb
104
+ - app/helpers/action_mosaico/tag_helper.rb
105
+ - app/javascript/action_mosaico/attachment_upload.js
106
+ - app/javascript/action_mosaico/index.js
107
+ - app/models/action_mosaico/encrypted_rich_text.rb
108
+ - app/models/action_mosaico/record.rb
109
+ - app/models/action_mosaico/rich_text.rb
110
+ - app/views/action_text/attachables/_missing_attachable.html.erb
111
+ - app/views/action_text/attachables/_remote_image.html.erb
112
+ - app/views/action_text/attachment_galleries/_attachment_gallery.html.erb
113
+ - app/views/action_text/contents/_content.html.erb
114
+ - app/views/active_storage/blobs/_blob.html.erb
115
+ - app/views/layouts/action_text/contents/_content.html.erb
116
+ - bin/console
117
+ - bin/setup
118
+ - db/migrate/20180528164100_create_action_mosaico_tables.rb
119
+ - lib/action_mosaico.rb
120
+ - lib/action_mosaico/attachable.rb
121
+ - lib/action_mosaico/attachables/content_attachment.rb
122
+ - lib/action_mosaico/attachables/missing_attachable.rb
123
+ - lib/action_mosaico/attachables/remote_image.rb
124
+ - lib/action_mosaico/attachment.rb
125
+ - lib/action_mosaico/attachment_gallery.rb
126
+ - lib/action_mosaico/attachments/caching.rb
127
+ - lib/action_mosaico/attachments/minification.rb
128
+ - lib/action_mosaico/attachments/mosaico_conversion.rb
129
+ - lib/action_mosaico/attribute.rb
130
+ - lib/action_mosaico/content.rb
131
+ - lib/action_mosaico/encryption.rb
132
+ - lib/action_mosaico/engine.rb
133
+ - lib/action_mosaico/fixture_set.rb
134
+ - lib/action_mosaico/fragment.rb
135
+ - lib/action_mosaico/html_conversion.rb
136
+ - lib/action_mosaico/mosaico_attachment.rb
137
+ - lib/action_mosaico/plain_text_conversion.rb
138
+ - lib/action_mosaico/rendering.rb
139
+ - lib/action_mosaico/serialization.rb
140
+ - lib/action_mosaico/system_test_helper.rb
141
+ - lib/action_mosaico/version.rb
142
+ - lib/generators/action_mosaico/install/install_generator.rb
143
+ - lib/generators/action_mosaico/install/templates/actiontext.css
144
+ - lib/tasks/action_mosaico.rake
145
+ - package.json
146
+ homepage: https://github.com/aventumx/action_mosaico
147
+ licenses:
148
+ - MIT
149
+ metadata:
150
+ homepage_uri: https://github.com/aventumx/action_mosaico
151
+ source_code_uri: https://github.com/aventumx/action_mosaico
152
+ changelog_uri: https://github.com/aventumx/action_mosaico
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: 2.7.0
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 1.8.11
167
+ requirements: []
168
+ rubygems_version: 3.2.27
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: The Mosaico email editor on Rails.
172
+ test_files: []