administrate-rich-text 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7920470be9deb106cd355f0f0e11cb920c222d291c963a8690e8f69c8676dc16
4
+ data.tar.gz: db5d55ddcc2adcf6bcdc136eeb75c55e0f355b122e1a307c8748a76caa00223b
5
+ SHA512:
6
+ metadata.gz: d612426e25b87a9e5f9a51b456e91b2e1c1e8d763a499d5de94105a628c0f58ab2ae06baffa46c618c2a79fb5f45314dcd45d0409bdc80b54a6a76b86834b8d2
7
+ data.tar.gz: b7bacb5264be003ad0900ea6608a4ffe4fee8751f96dab1ec581ced7aedf35877bcb78220d50b703fb6d480a733cf074043a212e44808e26e79cde6eb01ca31f
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-11-02
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in administrate-rich-text.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Benjamin Randles-Dunkley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # administrate-rich-text
2
+ > A plugin for Rails 7+ to allow the use of `ActionText` `rich_text_area` fields in [Administrate](https://github.com/thoughtbot/administrate).
3
+
4
+ `ActionTexct` is based on the [Trix](https://trix-editor.org) WYSIWYG editor.
5
+
6
+ The Administrate field is compatible with Rails [Active Storage](https://guides.rubyonrails.org/active_storage_overview.html), so Rails will seamlessly handle attachment storage in your Wysiwyg field.
7
+
8
+ ## Install
9
+
10
+ Add `administrate-rich-text`to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'administrate-rich-text'
14
+ ```
15
+
16
+ Install:
17
+
18
+ ```bash
19
+ $ bundle install
20
+ ```
21
+
22
+ Add javascript and CSS files to the asset pipeline and manifest:
23
+
24
+ ```bash
25
+ $ rails g admin:actiontext_assets
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ Add an `ActionText` `rich_text_area` field to `app/dashboards/foo_dashboard.rb`:
31
+
32
+ ```ruby
33
+ ATTRIBUTE_TYPES = {
34
+ bar: Field::RichTextArea
35
+ }.freeze
36
+ ```
37
+
38
+
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/administrate/rich/text/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "administrate-rich-text"
7
+ spec.version = Administrate::Rich::Text::VERSION
8
+ spec.authors = ["Benjamin Randles-Dunkley", "Oscar Randles-Dunkley"] # "Purr purr mew/,llllwqerp[ooooooooooooosdfa" - Oscar
9
+ spec.email = ["ben@chemica.co.uk"]
10
+
11
+ spec.summary = "Allow rich text editing in Administrate"
12
+ spec.description = "Incorporate ActionText into Administrate to allow rich text editing in the dashboard."
13
+ spec.homepage = "https://github.com/chemica/administrate-rich-text"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ spec.add_dependency 'administrate', '< 1.0.0'
33
+ spec.add_dependency 'rails', '>= 7.0.0'
34
+ end
@@ -0,0 +1,2 @@
1
+ //= require trix
2
+ //= require @rails/actiontext
@@ -0,0 +1 @@
1
+ @import 'actiontext.css';
@@ -0,0 +1,6 @@
1
+ <div class="field-unit__label">
2
+ <%= f.label field.attribute %>
3
+ </div>
4
+ <div class="field-unit__field">
5
+ <%= f.rich_text_area field.attribute %>
6
+ </div>
@@ -0,0 +1 @@
1
+ <%= field.to_s %>
@@ -0,0 +1 @@
1
+ <%= field.to_s %>
@@ -0,0 +1,18 @@
1
+ require 'rails'
2
+ require 'administrate/field/base'
3
+ require 'administrate/engine'
4
+
5
+ module Administrate
6
+ module Field
7
+ class RichTextArea < Administrate::Field::Base
8
+ class Engine < ::Rails::Engine
9
+ Administrate::Engine.add_javascript 'administrate-rich-text'
10
+ Administrate::Engine.add_stylesheet 'administrate-rich-text'
11
+ end
12
+
13
+ def to_s
14
+ data
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Administrate
4
+ module Rich
5
+ module Text
6
+ VERSION = "0.0.2"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require "administrate/field/rich_text_area"
3
+ require_relative "text/version"
4
+
5
+ module Administrate
6
+ module Rich
7
+ module Text
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Add the admin JS file for rich text fields in Administrate
3
+
4
+ Example:
5
+ bin/rails generate admin_js
6
+
7
+ This will create:
8
+ app/javascript/administrate-rich-text.js
@@ -0,0 +1,18 @@
1
+ module Admin
2
+ class ActiontextAssetsGenerator < Rails::Generators::Base
3
+ source_root File.expand_path("templates", __dir__)
4
+
5
+ def create_admin_js
6
+ template "administrate-rich-text.js.erb", "app/javascript/administrate-rich-text.js"
7
+
8
+ manifest_file = "app/assets/config/manifest.js"
9
+
10
+
11
+ if File.exist?(manifest_file)
12
+ append_to_file manifest_file do
13
+ "\n//= link administrate-rich-text.css\n//= link administrate-rich-text.js"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,2 @@
1
+ import "trix";
2
+ import "@rails/actiontext";
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: administrate-rich-text
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Randles-Dunkley
8
+ - Oscar Randles-Dunkley
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2023-11-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: administrate
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "<"
19
+ - !ruby/object:Gem::Version
20
+ version: 1.0.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "<"
26
+ - !ruby/object:Gem::Version
27
+ version: 1.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: rails
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 7.0.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 7.0.0
42
+ description: Incorporate ActionText into Administrate to allow rich text editing in
43
+ the dashboard.
44
+ email:
45
+ - ben@chemica.co.uk
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - administrate-rich-text.gemspec
55
+ - app/assets/javascripts/administrate-rich-text.js
56
+ - app/assets/stylesheets/administrate-rich-text.scss
57
+ - app/views/fields/rich_text_area/_form.html.erb
58
+ - app/views/fields/rich_text_area/_index.html.erb
59
+ - app/views/fields/rich_text_area/_show.html.erb
60
+ - lib/administrate/field/rich_text_area.rb
61
+ - lib/administrate/rich/text.rb
62
+ - lib/administrate/rich/text/version.rb
63
+ - lib/generators/admin/actiontext_assets/USAGE
64
+ - lib/generators/admin/actiontext_assets/actiontext_assets_generator.rb
65
+ - lib/generators/admin/actiontext_assets/templates/administrate-rich-text.js.erb
66
+ homepage: https://github.com/chemica/administrate-rich-text
67
+ licenses:
68
+ - MIT
69
+ metadata:
70
+ homepage_uri: https://github.com/chemica/administrate-rich-text
71
+ source_code_uri: https://github.com/chemica/administrate-rich-text
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.6.0
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.4.10
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Allow rich text editing in Administrate
91
+ test_files: []