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
112 changes: 95 additions & 17 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,37 @@ jobs:
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

mysql:
image: mysql:8.0
env:
MYSQL_DATABASE: "maglev_engine_test"
MYSQL_ROOT_PASSWORD: "password"
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

mariadb:
image: mariadb:11.8
env:
MARIADB_DATABASE: "maglev_engine_test"
MARIADB_ROOT_PASSWORD: "password"
ports:
- 3307:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3

strategy:
matrix:
node: [20, 23]
gemfile: ["Gemfile.rails_7_0", "Gemfile.rails_7_2", "Gemfile"]
gemfile: ["Gemfile", "Gemfile.rails_7_0", "Gemfile.rails_7_2"]
database: [postgres, sqlite, mysql, mariadb]
exclude:
- gemfile: Gemfile.rails_7_0
database: mysql
- gemfile: Gemfile.rails_7_0
database: mariadb

steps:
- name: Checkout code
Expand All @@ -41,17 +68,22 @@ jobs:
run: |
corepack enable

- name: Use Node.js ${{ matrix.node }}
- name: Use Node.js v23
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: 23
cache: yarn

- name: Install packages
run: |
yarn install

- name: Setup test database
- name: Run Javascript tests
run: yarn test

# === Postgresql 🐘 ===
- name: Setup test database (Postgresql) 🐘
if: ${{ matrix.database == 'postgres' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
RAILS_ENV: test
Expand All @@ -60,14 +92,17 @@ jobs:
run: |
bin/rails db:setup

- name: Run Rails tests
- name: Run Rails tests (Postgresql) 🐘
if: ${{ matrix.database == 'postgres' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
MAGLEV_APP_DATABASE_USERNAME: "maglev"
MAGLEV_APP_DATABASE_PASSWORD: "password"
run: bundle exec rspec
run: bundle exec rspec

- name: Setup test database (SQLite)
# === SQLite 🪽 ===
- name: Setup test database (SQLite) 🪽
if: ${{ matrix.database == 'sqlite' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
RAILS_ENV: test
Expand All @@ -79,21 +114,64 @@ jobs:
cp spec/legacy_dummy/db/schema.sqlite.rb spec/legacy_dummy/db/schema.rb
bin/rails db:setup

- name: Run Rails tests (SQLite)
- name: Run Rails tests (SQLite) 🪽
if: ${{ matrix.database == 'sqlite' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
USE_SQLITE: true
USE_SQLITE: 1
run: bundle exec rspec

- name: Cleanup DB schema files
# === MYSQL 🐬 ===
- name: Setup test database (MySQL) 🐬
if: ${{ matrix.database == 'mysql' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
RAILS_ENV: test
USE_MYSQL: 1
MAGLEV_APP_DATABASE_HOST: "127.0.0.1"
MAGLEV_APP_DATABASE_USERNAME: "root"
MAGLEV_APP_DATABASE_PASSWORD: "password"
run: |
cp spec/dummy/db/schema.pg.rb spec/dummy/db/schema.rb
cp spec/legacy_dummy/db/schema.pg.rb spec/legacy_dummy/db/schema.rb
rm -f spec/dummy/db/maglev_engine_test.sqlite3
rm -f spec/legacy_dummy/db/maglev_engine_test.sqlite3
cp spec/dummy/db/schema.mysql.rb spec/dummy/db/schema.rb
cp spec/legacy_dummy/db/schema.mysql.rb spec/legacy_dummy/db/schema.rb
bin/rails db:setup

- name: Run Javascript tests
run: yarn test
- name: Run Rails tests (MySQL) 🐬
if: ${{ matrix.database == 'mysql' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
USE_MYSQL: 1
MAGLEV_APP_DATABASE_HOST: "127.0.0.1"
MAGLEV_APP_DATABASE_USERNAME: "root"
MAGLEV_APP_DATABASE_PASSWORD: "password"
run: bundle exec rspec

# === MariaDB 🦭===
- name: Setup test database (MariaDB) 🦭
if: ${{ matrix.database == 'mariadb' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
RAILS_ENV: test
USE_MYSQL: 1
MAGLEV_APP_DATABASE_HOST: "127.0.0.1"
MAGLEV_APP_DATABASE_PORT: 3307
MAGLEV_APP_DATABASE_USERNAME: "root"
MAGLEV_APP_DATABASE_PASSWORD: "password"
run: |
cp spec/dummy/db/schema.mariadb.rb spec/dummy/db/schema.rb
cp spec/legacy_dummy/db/schema.mariadb.rb spec/legacy_dummy/db/schema.rb
bin/rails db:setup

- name: Run Rails tests (MariaDB) 🦭
if: ${{ matrix.database == 'mariadb' }}
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
USE_MYSQL: 1
MAGLEV_APP_DATABASE_HOST: "127.0.0.1"
MAGLEV_APP_DATABASE_PORT: 3307
MAGLEV_APP_DATABASE_USERNAME: "root"
MAGLEV_APP_DATABASE_PASSWORD: "password"
run: bundle exec rspec

# NOTE: disabled because an error of eslint in the GH env
# - name: Run Javascript linter
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ bin/test
spec/dummy/db/*.sqlite3
spec/legacy_dummy/db/*.sqlite3

docker-compose.yml
db/mysql/init/01-init-databases.sql

docs/
TODO.md
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ gem 'puma'
# To use a debugger
# gem 'byebug', group: [:development, :test]

# Use SQLite/PostgreSQL for development and test
# Use SQLite/PostgreSQL/MariaDB for development and test
gem 'mysql2'
gem 'pg', '~> 1.5.9'
gem 'sqlite3'

Expand All @@ -55,6 +56,8 @@ group :development, :test do
gem 'annotaterb'

gem 'rdoc', '>= 6.6.3.1'

gem 'dotenv'
end

group :test do
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ GEM
date (3.4.1)
diff-lcs (1.5.1)
docile (1.4.1)
dotenv (3.1.8)
drb (2.2.3)
dry-cli (1.2.0)
erubi (1.13.0)
Expand Down Expand Up @@ -161,6 +162,7 @@ GEM
mini_portile2 (2.8.9)
minitest (5.25.5)
mutex_m (0.3.0)
mysql2 (0.5.6)
net-imap (0.5.8)
date
net-protocol
Expand Down Expand Up @@ -369,10 +371,12 @@ PLATFORMS
DEPENDENCIES
annotaterb
bcrypt
dotenv
factory_bot_rails (~> 6.2.0)
generator_spec
image_processing (~> 1.12.2)
maglevcms!
mysql2
nokogiri (>= 1.15.6)
observer
ostruct
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.rails_7_0
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ gem 'puma'
# Use SQLite/PostgreSQL for development and test
gem 'pg', '~> 1.5.9'
gem 'sqlite3', '~> 1.4'
gem 'mysql2', '~> 0.5.6'

# Gems no longer be part of the default gems from Ruby 3.5.0
gem 'observer'
Expand All @@ -45,6 +46,7 @@ gem 'bigdecimal'
gem 'mutex_m'
gem 'drb'
gem 'fiddle'
gem 'benchmark'

group :development, :test do
# Use SCSS for stylesheets
Expand All @@ -60,6 +62,10 @@ group :development, :test do
gem 'generator_spec'

gem 'nokogiri', '>= 1.13.10'

gem 'dotenv'

gem 'database_cleaner-active_record'
end

group :test do
Expand Down
11 changes: 11 additions & 0 deletions Gemfile.rails_7_0.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ GEM
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
benchmark (0.4.1)
bigdecimal (3.1.9)
builder (3.3.0)
concurrent-ruby (1.3.4)
crass (1.0.6)
database_cleaner-active_record (2.2.2)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0)
database_cleaner-core (2.0.1)
date (3.4.0)
diff-lcs (1.5.1)
docile (1.4.1)
dotenv (3.1.8)
drb (2.2.1)
dry-cli (1.2.0)
erubi (1.13.0)
Expand Down Expand Up @@ -141,6 +147,7 @@ GEM
mini_portile2 (2.8.9)
minitest (5.25.1)
mutex_m (0.3.0)
mysql2 (0.5.6)
net-imap (0.5.1)
date
net-protocol
Expand Down Expand Up @@ -302,7 +309,10 @@ PLATFORMS
DEPENDENCIES
base64
bcrypt
benchmark
bigdecimal
database_cleaner-active_record
dotenv
drb
factory_bot_rails (~> 6.2.0)
fiddle
Expand All @@ -311,6 +321,7 @@ DEPENDENCIES
maglevcms!
mini_magick (~> 4.11)
mutex_m
mysql2 (~> 0.5.6)
nokogiri (>= 1.13.10)
observer
ostruct
Expand Down
5 changes: 5 additions & 0 deletions Gemfile.rails_7_2
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ gem 'puma'
# Use SQLite/PostgreSQL for development and test
gem 'pg', '~> 1.5.9'
gem 'sqlite3'
gem 'mysql2', '~> 0.5.6'

# Gems no longer be part of the default gems from Ruby 3.5.0
gem 'observer'
Expand All @@ -60,6 +61,10 @@ group :development, :test do
gem 'nokogiri', '>= 1.15.6'

gem 'rdoc', '>= 6.6.3.1'

gem 'dotenv'

gem 'database_cleaner-active_record'
end

group :test do
Expand Down
9 changes: 9 additions & 0 deletions Gemfile.rails_7_2.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ GEM
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
database_cleaner-active_record (2.2.2)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0)
database_cleaner-core (2.0.1)
date (3.4.0)
diff-lcs (1.5.1)
docile (1.4.1)
dotenv (3.1.8)
drb (2.2.1)
dry-cli (1.2.0)
erubi (1.13.0)
Expand Down Expand Up @@ -151,6 +156,7 @@ GEM
mini_portile2 (2.8.9)
minitest (5.25.2)
mutex_m (0.3.0)
mysql2 (0.5.6)
net-imap (0.5.1)
date
net-protocol
Expand Down Expand Up @@ -343,10 +349,13 @@ PLATFORMS

DEPENDENCIES
bcrypt
database_cleaner-active_record
dotenv
factory_bot_rails (~> 6.2.0)
generator_spec
image_processing (~> 1.12.2)
maglevcms!
mysql2 (~> 0.5.6)
nokogiri (>= 1.15.6)
observer
ostruct
Expand Down
37 changes: 37 additions & 0 deletions app/controllers/maglev/api/page_translations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

module Maglev
module Api
class PageTranslationsController < ::Maglev::ApiController
before_action :set_page

def index
translations = @page.translations_for(:sections, params[:locale])
render json: { translated: translations&.size.to_i > 0 }
end

def create
translate_page(@page)
head :ok
end

private

def set_page
@page ||= resources.find(params[:page_id])
end

def translate_page(page)
services.translate_page.call(
page: page,
locale: params[:locale],
source_locale: maglev_site.default_locale_prefix.to_s
)
end

def resources
::Maglev::Page
end
end
end
end
1 change: 1 addition & 0 deletions app/frontend/editor/assets/remixicons/ri-translate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
:name="setting.id"
v-model="inputValue"
:selectOptions="options.selectOptions"
:i18nScope="i18nScope"
v-if="setting.type == 'select'"
/>
<uikit-collection-item-input
Expand Down
Loading