aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-05-29 16:55:04 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-05-29 16:55:04 +0200
commit735734647e119b1ef13a321ad1381dab9b2f22e2 (patch)
tree70eadcd919fabcf3486e86ef084e7bae283564c0 /lib
parentf27a0c88e0e48b1b4f4b64590443e0bb23c6738e (diff)
downloadrails-735734647e119b1ef13a321ad1381dab9b2f22e2.tar.gz
rails-735734647e119b1ef13a321ad1381dab9b2f22e2.tar.bz2
rails-735734647e119b1ef13a321ad1381dab9b2f22e2.zip
Add installer that copies migration and stylesheet link
Diffstat (limited to 'lib')
-rw-r--r--lib/tasks/actiontext.rake28
-rw-r--r--lib/templates/actiontext.css7
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/tasks/actiontext.rake b/lib/tasks/actiontext.rake
new file mode 100644
index 0000000000..817a4c67f0
--- /dev/null
+++ b/lib/tasks/actiontext.rake
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+namespace :action_text do
+ # Prevent migration installation task from showing up twice.
+ Rake::Task["install:migrations"].clear_comments
+
+ desc "Copy over the migration, stylesheet, and JavaScript files"
+ task install: %i( environment copy_migration copy_stylesheet )
+
+ task :copy_migration do
+ if Rake::Task.task_defined?("action_text:install:migrations")
+ Rake::Task["action_text:install:migrations"].invoke
+ else
+ Rake::Task["app:action_text:install:migrations"].invoke
+ end
+ end
+
+ STYLESHEET_TEMPLATE_PATH = File.expand_path("../templates/actiontext.css", __dir__)
+ STYLESHEET_APP_PATH = Rails.root.join("app/assets/stylesheets/actiontext.css")
+
+ task :copy_stylesheet do
+ if File.exist?(STYLESHEET_APP_PATH)
+ puts "Won't copy Action Text stylesheet as it already exists"
+ else
+ FileUtils.cp STYLESHEET_TEMPLATE_PATH, STYLESHEET_APP_PATH
+ end
+ end
+end
diff --git a/lib/templates/actiontext.css b/lib/templates/actiontext.css
new file mode 100644
index 0000000000..97c083c24b
--- /dev/null
+++ b/lib/templates/actiontext.css
@@ -0,0 +1,7 @@
+/*
+ * Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
+ * the trix-editor content (whether displayed or under editing). Feel free to incorporate this
+ * inclusion directly in any other asset bundle and remove this file.
+ *
+ *= require trix/dist/trix
+*/