Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reviewable file that was not generated by rails plugin new.

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,53 @@ jobs:
run: |
cd rails/actiontext
bundle exec rake test test:system
action_text-trix:
name: Action Text tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- ruby: "3.2"
branch: 7-2-stable
experimental: false
- ruby: "3.3"
branch: 7-2-stable

- ruby: "3.2"
branch: 8-0-stable
experimental: false
- ruby: "3.3"
branch: 8-0-stable

- ruby: "3.2"
branch: main
experimental: true
- ruby: "3.3"
branch: main
experimental: true
- ruby: head
branch: main
experimental: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "yarn"
- uses: ruby/setup-ruby@v1
env:
BRANCH: ${{ matrix.branch }}
with:
working-directory: "./action_text-trix"
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
env:
BRANCH: ${{ matrix.branch }}
continue-on-error: ${{ matrix.experimental }}
working-directory: "./action_text-trix"
run: bin/rails test:all

env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
Expand Down
4 changes: 4 additions & 0 deletions action_text-trix/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
Gemfile.lock
pkg
tmp/
log/
storage/
vendor/
11 changes: 11 additions & 0 deletions action_text-trix/Gemfile
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reviewable file that was not generated by rails plugin new.

Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@ source "https://rubygems.org"

# Specify your gem's dependencies in trix.gemspec.
gemspec

branch = ENV.fetch("BRANCH", "main")
gem "rails", github: "rails/rails", branch: branch
gem "importmap-rails"
gem "propshaft"
gem "puma"
gem "sqlite3"

group :test do
gem "cuprite", require: "capybara/cuprite"
end
7 changes: 7 additions & 0 deletions action_text-trix/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require "bundler/gem_tasks"
require "rake/clean"

begin
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
load "rails/tasks/engine.rake" rescue nil
rescue LoadError
# do nothing
end
Comment on lines +4 to +9
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rescue block is in support of the yarn build-js command's dependency on executing rake sync from the root directory instead of action_text-trix/.


task :sync do
require "json"

Expand Down
15 changes: 15 additions & 0 deletions action_text-trix/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/action_text/trix/engine.rb', __dir__)
APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require "rails/all"
require "rails/test_unit/railtie"
require "rails/engine/commands"
12 changes: 12 additions & 0 deletions action_text-trix/test/application_system_test_case.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require "test_helper"

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :cuprite, using: :chrome, options: {
js_errors: true,
headless: ENV["HEADLESS"] != "0"
}
end

Capybara.server = :puma, { Silent: true }
6 changes: 6 additions & 0 deletions action_text-trix/test/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative "config/application"

Rails.application.load_tasks
Empty file.
440 changes: 440 additions & 0 deletions action_text-trix/test/dummy/app/assets/stylesheets/actiontext.css

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions action_text-trix/test/dummy/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationController < ActionController::Base
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
allow_browser versions: :modern
end
Empty file.
24 changes: 24 additions & 0 deletions action_text-trix/test/dummy/app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class MessagesController < ApplicationController
def index
@messages = Message.all
end

def new
@message = Message.new
end

def create
@message = Message.create!(message_params)

redirect_to action: :index
end

private
def message_params
if params.respond_to?(:expect)
params.expect(message: [ :subject, :content ])
else
params.require(:message).permit(:subject, :content)
end
end
end
2 changes: 2 additions & 0 deletions action_text-trix/test/dummy/app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "trix"
3 changes: 3 additions & 0 deletions action_text-trix/test/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
Empty file.
3 changes: 3 additions & 0 deletions action_text-trix/test/dummy/app/models/message.rb
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reviewable file that was not generated by rails plugin new.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Message < ApplicationRecord
has_rich_text :content
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
<% if blob.representable? %>
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
<% end %>

<figcaption class="attachment__caption">
<% if caption = blob.try(:caption) %>
<%= caption %>
<% else %>
<span class="attachment__name"><%= blob.filename %></span>
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
<% end %>
</figcaption>
</figure>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="trix-content">
<%= yield -%>
</div>
28 changes: 28 additions & 0 deletions action_text-trix/test/dummy/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<title><%= content_for(:title) || "Dummy" %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= yield :head %>

<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>

<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">

<%# Includes all stylesheet files in app/assets/stylesheets %>
<%= stylesheet_link_tag :app %>
<%= javascript_importmap_tags %>
</head>

<body>
<%= yield %>
</body>
</html>
13 changes: 13 additions & 0 deletions action_text-trix/test/dummy/app/views/layouts/mailer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Email styles need to be inline */
</style>
</head>

<body>
<%= yield %>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= yield %>
9 changes: 9 additions & 0 deletions action_text-trix/test/dummy/app/views/messages/_form.html.erb
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reviewable file that was not generated by rails plugin new.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%= form_with(model: message) do |form| %>
<%= form.label :subject %> <br>
<%= form.text_field :subject %> <br>

<%= form.label :content %> <br>
<%= form.rich_text_area :content %>

<%= form.submit %>
<% end %>
19 changes: 19 additions & 0 deletions action_text-trix/test/dummy/app/views/messages/index.html.erb
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reviewable file that was not generated by rails plugin new.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h1>Messages</h1>

<table>
<thead>
<tr>
<th>Subject</th>
<th>Content</th>
</tr>
</thead>

<tbody>
<% @messages.each do |message| %>
<tr>
<td><%= message.subject %></td>
<td><%= message.content %></td>
</tr>
<% end %>
</tbody>
</table>
3 changes: 3 additions & 0 deletions action_text-trix/test/dummy/app/views/messages/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1>New Message</h1>

<%= render "form", message: @message %>
22 changes: 22 additions & 0 deletions action_text-trix/test/dummy/app/views/pwa/manifest.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Dummy",
"icons": [
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512"
},
{
"src": "/icon.png",
"type": "image/png",
"sizes": "512x512",
"purpose": "maskable"
}
],
"start_url": "/",
"display": "standalone",
"scope": "/",
"description": "Dummy.",
"theme_color": "red",
"background_color": "red"
}
26 changes: 26 additions & 0 deletions action_text-trix/test/dummy/app/views/pwa/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Add a service worker for processing Web Push notifications:
//
// self.addEventListener("push", async (event) => {
// const { title, options } = await event.data.json()
// event.waitUntil(self.registration.showNotification(title, options))
// })
//
// self.addEventListener("notificationclick", function(event) {
// event.notification.close()
// event.waitUntil(
// clients.matchAll({ type: "window" }).then((clientList) => {
// for (let i = 0; i < clientList.length; i++) {
// let client = clientList[i]
// let clientPath = (new URL(client.url)).pathname
//
// if (clientPath == event.notification.data.path && "focus" in client) {
// return client.focus()
// }
// }
//
// if (clients.openWindow) {
// return clients.openWindow(event.notification.data.path)
// }
// })
// )
// })
2 changes: 2 additions & 0 deletions action_text-trix/test/dummy/bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env ruby
exec "./bin/rails", "server", *ARGV
4 changes: 4 additions & 0 deletions action_text-trix/test/dummy/bin/importmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require_relative "../config/application"
require "importmap/commands"
4 changes: 4 additions & 0 deletions action_text-trix/test/dummy/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
4 changes: 4 additions & 0 deletions action_text-trix/test/dummy/bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative "../config/boot"
require "rake"
Rake.application.run
34 changes: 34 additions & 0 deletions action_text-trix/test/dummy/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env ruby
require "fileutils"

APP_ROOT = File.expand_path("..", __dir__)

def system!(*args)
system(*args, exception: true)
end

FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.

puts "== Installing dependencies =="
system("bundle check") || system!("bundle install")

# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end

puts "\n== Preparing database =="
system! "bin/rails db:prepare"

puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"

unless ARGV.include?("--skip-server")
puts "\n== Starting development server =="
STDOUT.flush # flush the output before exec(2) so that it displays
exec "bin/dev"
end
end
6 changes: 6 additions & 0 deletions action_text-trix/test/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is used by Rack-based servers to start the application.

require_relative "config/environment"

run Rails.application
Rails.application.load_server
Loading
Loading