trix_on_rails 0.1.4 → 0.2.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/trix-core.js +8 -8
  3. data/app/assets/javascripts/trix.js +10 -14
  4. data/app/assets/stylesheets/trix.css +268 -177
  5. data/lib/trix_on_rails/version.rb +1 -1
  6. data/test/dummy/Rakefile +1 -1
  7. data/test/dummy/app/assets/javascripts/application.js +2 -1
  8. data/test/dummy/app/assets/javascripts/cable.js +13 -0
  9. data/test/dummy/app/assets/stylesheets/application.css +1 -0
  10. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  11. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  12. data/test/dummy/app/controllers/application_controller.rb +0 -2
  13. data/test/dummy/app/controllers/pages_controller.rb +58 -0
  14. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  15. data/test/dummy/app/models/application_record.rb +3 -0
  16. data/test/dummy/app/models/page.rb +2 -0
  17. data/test/dummy/app/views/layouts/application.html.erb +9 -9
  18. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  19. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  20. data/test/dummy/app/views/pages/_form.html.erb +34 -0
  21. data/test/dummy/app/views/pages/edit.html.erb +6 -0
  22. data/test/dummy/app/views/pages/index.html.erb +31 -0
  23. data/test/dummy/app/views/pages/new.html.erb +5 -0
  24. data/test/dummy/app/views/pages/show.html.erb +19 -0
  25. data/test/dummy/bin/rails +1 -1
  26. data/test/dummy/bin/setup +8 -4
  27. data/test/dummy/bin/update +4 -4
  28. data/test/dummy/bin/yarn +11 -0
  29. data/test/dummy/config.ru +2 -1
  30. data/test/dummy/config/application.rb +4 -9
  31. data/test/dummy/config/boot.rb +2 -2
  32. data/test/dummy/config/cable.yml +10 -0
  33. data/test/dummy/config/database.yml +15 -8
  34. data/test/dummy/config/environment.rb +1 -1
  35. data/test/dummy/config/environments/development.rb +14 -11
  36. data/test/dummy/config/environments/production.rb +23 -10
  37. data/test/dummy/config/environments/test.rb +4 -6
  38. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -6
  39. data/test/dummy/config/initializers/assets.rb +6 -3
  40. data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
  41. data/test/dummy/config/locales/en.yml +10 -0
  42. data/test/dummy/config/puma.rb +56 -0
  43. data/test/dummy/config/routes.rb +2 -0
  44. data/test/dummy/config/secrets.yml +1 -5
  45. data/test/dummy/config/spring.rb +6 -0
  46. data/test/dummy/db/migrate/20171116134443_create_pages.rb +11 -0
  47. data/test/dummy/db/schema.rb +23 -0
  48. data/test/dummy/package.json +5 -0
  49. data/test/dummy/public/404.html +6 -6
  50. data/test/dummy/public/422.html +6 -6
  51. data/test/dummy/public/500.html +6 -6
  52. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  53. data/test/dummy/public/apple-touch-icon.png +0 -0
  54. data/test/dummy/test/application_system_test_case.rb +5 -0
  55. data/test/dummy/test/controllers/pages_controller_test.rb +48 -0
  56. data/test/dummy/test/fixtures/pages.yml +11 -0
  57. data/test/dummy/test/models/page_test.rb +7 -0
  58. data/test/dummy/test/system/pages_test.rb +9 -0
  59. metadata +82 -38
  60. data/test/dummy/README.md +0 -24
  61. data/test/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +0 -4
  62. data/test/dummy/config/initializers/callback_terminator.rb +0 -4
  63. data/test/dummy/config/initializers/cors.rb +0 -14
  64. data/test/dummy/config/initializers/session_store.rb +0 -3
  65. data/test/dummy/log/test.log +0 -8
@@ -1,3 +1,3 @@
1
1
  module TrixOnRails
2
- VERSION = '0.1.4'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative 'config/application'
5
5
 
6
6
  Rails.application.load_tasks
@@ -10,4 +10,5 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require_tree .
13
+ //= require trix
14
+
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -12,4 +12,5 @@
12
12
  *
13
13
  *= require_tree .
14
14
  *= require_self
15
+ *= require trix
15
16
  */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -1,5 +1,3 @@
1
1
  class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
2
  protect_from_forgery with: :exception
5
3
  end
@@ -0,0 +1,58 @@
1
+ class PagesController < ApplicationController
2
+ before_action :set_page, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /pages
5
+ def index
6
+ @pages = Page.all
7
+ end
8
+
9
+ # GET /pages/1
10
+ def show
11
+ end
12
+
13
+ # GET /pages/new
14
+ def new
15
+ @page = Page.new
16
+ end
17
+
18
+ # GET /pages/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /pages
23
+ def create
24
+ @page = Page.new(page_params)
25
+
26
+ if @page.save
27
+ redirect_to @page, notice: 'Page was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /pages/1
34
+ def update
35
+ if @page.update(page_params)
36
+ redirect_to @page, notice: 'Page was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /pages/1
43
+ def destroy
44
+ @page.destroy
45
+ redirect_to pages_url, notice: 'Page was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_page
51
+ @page = Page.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def page_params
56
+ params.require(:page).permit(:header, :title, :page)
57
+ end
58
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,2 @@
1
+ class Page < ApplicationRecord
2
+ end
@@ -1,14 +1,14 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
10
6
 
11
- <%= yield %>
7
+ <%= stylesheet_link_tag 'application', media: 'all' %>
8
+ <%= javascript_include_tag 'application' %>
9
+ </head>
12
10
 
13
- </body>
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
14
  </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,34 @@
1
+ <%= form_with(model: page, local: true) do |form| %>
2
+ <% if page.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(page.errors.count, "error") %> prohibited this page from being saved:</h2>
5
+
6
+ <ul>
7
+ <% page.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= form.label :header %>
16
+ <%= form.text_field :header, id: :page_header %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= form.label :title %>
21
+ <%= form.text_field :title, id: :page_title %>
22
+ </div>
23
+
24
+ <div class="field">
25
+ <%= form.label :page %>
26
+ <%= form.text_area :page, id: :page_page %>
27
+ </div>
28
+
29
+ <div class="actions">
30
+ <%= form.submit %>
31
+ </div>
32
+ <% end %>
33
+
34
+ <trix-editor></trix-editor>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Page</h1>
2
+
3
+ <%= render 'form', page: @page %>
4
+
5
+ <%= link_to 'Show', @page %> |
6
+ <%= link_to 'Back', pages_path %>
@@ -0,0 +1,31 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Pages</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>Header</th>
9
+ <th>Title</th>
10
+ <th>Page</th>
11
+ <th colspan="3"></th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <tbody>
16
+ <% @pages.each do |page| %>
17
+ <tr>
18
+ <td><%= page.header %></td>
19
+ <td><%= page.title %></td>
20
+ <td><%= page.page %></td>
21
+ <td><%= link_to 'Show', page %></td>
22
+ <td><%= link_to 'Edit', edit_page_path(page) %></td>
23
+ <td><%= link_to 'Destroy', page, method: :delete, data: { confirm: 'Are you sure?' } %></td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+
29
+ <br>
30
+
31
+ <%= link_to 'New Page', new_page_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New Page</h1>
2
+
3
+ <%= render 'form', page: @page %>
4
+
5
+ <%= link_to 'Back', pages_path %>
@@ -0,0 +1,19 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Header:</strong>
5
+ <%= @page.header %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Title:</strong>
10
+ <%= @page.title %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong>Page:</strong>
15
+ <%= @page.page %>
16
+ </p>
17
+
18
+ <%= link_to 'Edit', edit_page_path(@page) %> |
19
+ <%= link_to 'Back', pages_path %>
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
3
  require_relative '../config/boot'
4
4
  require 'rails/commands'
@@ -16,7 +16,11 @@ chdir APP_ROOT do
16
16
 
17
17
  puts '== Installing dependencies =='
18
18
  system! 'gem install bundler --conservative'
19
- system('bundle check') or system!('bundle install')
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # Install JavaScript dependencies if using Yarn
22
+ # system('bin/yarn')
23
+
20
24
 
21
25
  # puts "\n== Copying sample files =="
22
26
  # unless File.exist?('config/database.yml')
@@ -24,11 +28,11 @@ chdir APP_ROOT do
24
28
  # end
25
29
 
26
30
  puts "\n== Preparing database =="
27
- system! 'ruby bin/rake db:setup'
31
+ system! 'bin/rails db:setup'
28
32
 
29
33
  puts "\n== Removing old logs and tempfiles =="
30
- system! 'ruby bin/rake log:clear tmp:clear'
34
+ system! 'bin/rails log:clear tmp:clear'
31
35
 
32
36
  puts "\n== Restarting application server =="
33
- system! 'ruby bin/rake restart'
37
+ system! 'bin/rails restart'
34
38
  end
@@ -16,14 +16,14 @@ chdir APP_ROOT do
16
16
 
17
17
  puts '== Installing dependencies =='
18
18
  system! 'gem install bundler --conservative'
19
- system 'bundle check' or system! 'bundle install'
19
+ system('bundle check') || system!('bundle install')
20
20
 
21
21
  puts "\n== Updating database =="
22
- system! 'bin/rake db:migrate'
22
+ system! 'bin/rails db:migrate'
23
23
 
24
24
  puts "\n== Removing old logs and tempfiles =="
25
- system! 'bin/rake log:clear tmp:clear'
25
+ system! 'bin/rails log:clear tmp:clear'
26
26
 
27
27
  puts "\n== Restarting application server =="
28
- system! 'bin/rake restart'
28
+ system! 'bin/rails restart'
29
29
  end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ VENDOR_PATH = File.expand_path('..', __dir__)
3
+ Dir.chdir(VENDOR_PATH) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(" ")}"
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -1,4 +1,5 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require_relative 'config/environment'
4
+
4
5
  run Rails.application
@@ -1,4 +1,4 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require_relative 'boot'
2
2
 
3
3
  require 'rails/all'
4
4
 
@@ -7,17 +7,12 @@ require "trix_on_rails"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
10
+ # Initialize configuration defaults for originally generated Rails version.
11
+ config.load_defaults 5.1
12
+
10
13
  # Settings in config/environments/* take precedence over those specified here.
11
14
  # Application configuration should go into files in config/initializers
12
15
  # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake time:zones:all" for a time zone names list. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
16
  end
22
17
  end
23
18
 
@@ -1,5 +1,5 @@
1
1
  # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
3
 
4
4
  require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
10
+ channel_prefix: dummy_production
@@ -1,9 +1,20 @@
1
+ # MySQL. Versions 5.1.10 and up are supported.
2
+ #
3
+ # Install the MySQL driver
4
+ # gem install mysql2
5
+ #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
9
+ # And be sure to use new-style password hashing:
10
+ # http://dev.mysql.com/doc/refman/5.7/en/old-client.html
11
+ #
1
12
  default: &default
2
13
  adapter: mysql2
3
14
  encoding: utf8
4
- pool: 5
5
- username: <%=Rails.application.secrets.database["user"]%>
6
- password: <%=Rails.application.secrets.database["password"]%>
15
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
16
+ username: <%=Rails.application.secrets.database[:user]%>
17
+ password: <%=Rails.application.secrets.database[:password]%>
7
18
  socket: /tmp/mysql.sock
8
19
 
9
20
  development:
@@ -12,8 +23,4 @@ development:
12
23
 
13
24
  test:
14
25
  <<: *default
15
- database: dummy_test
16
-
17
- production:
18
- <<: *default
19
- database: dummy_production
26
+ database: dummy_test
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
2
+ require_relative 'application'
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!