Skip to content

muhme/quote

Repository files navigation

README

Ruby on Rails (RoR) web application running the website zitat-service.de.

The database is used for JSON API api.zitat-service.de too. The API itself is used by this RoR web application and also by the Joomla module github.com/muhme/quote_joomla and WordPress plugin github.com/muhme/quote_wordpress.

Scripts

Some bash-scripts are prepared for a pleasant and also faster development, see folder scripts and commented list of scripts there.

Prerequisites

Git and Docker in a scripting environment are required. Tested with macOS 14 Sonoma, Ubuntu 22 Jammy Jellyfish and Microsoft Windows 11 WSL 2.

Docker Containers

There is a Docker test and development environment prepared. You can create your own local test and development instance with the following commands:

git clone https://github.com/muhme/quote
cd quote
scripts/compose.sh

Then five containers are running:

NAMES              IMAGE                        PORTS
quote_rails        quote-rails                  0.0.0.0:8102->3000/tcp
quote_mysqladmin   phpmyadmin/phpmyadmin        0.0.0.0:8101->80/tcp
quote_mariadb      mariadb                      3306/tcp
quote_chrome       selenium/standalone-chrome   4444/tcp, 0.0.0.0:8104->5900/tcp, 0.0.0.0:8105->7900/tcp
quote_maildev      maildev/maildev              1025/tcp, 0.0.0.0:8106->1080/tcp
  • quote_mariadb – MariaDB database server
    • database admin user is root/root
    • Database quote_development with database user quote_development/quote_development and cleaned LIVE database import from August 2023 and three additional users created with the three different user roles
    • database quote_test with database user quote_test/quote_test created
  • quote_mysqladmin – phpMyAdmin (user root/root)
  • quote_rails – Rails web application zitat-service
  • quote_chrome – Selenium Standalone with Chrome and VNC server
  • quote_maildev – SMTP Server and Web Interface for viewing and testing mails during development

Machine Translation

The application uses DeepL API Free for translation.

You can register there for free and then use your own key in the rails application, in the tests and for translations with i18n-tasks command. The easiest way is to start with DEEPL_API_KEY at the beginning:

DEEPL_API_KEY="sample11-key1-ab12-1234-qbc123456789:fx" scripts/compose.sh

Or set the key manually in .env file and in the .bashrc of the quote_rails container.

You can then use machine translation on the development server. The tests that use machine translation will run. And you can use i18n-tasks within the Rails container to check if the keys are ok, normalize the order or translate missing keys:

docker exec -it quote_rails i18n-tasks health
docker exec -it quote_rails i18n-tasks normalize
docker exec -it quote_rails bash -c ". ~/.bashrc && i18n-tasks translate-missing --backend=deepl"

Testing

Mini tests and system tests are available for application validation.

You can run all mini tests and system tests:

scripts/test.sh

Mini tests are sometimes integration tests, when the interaction with external services such as Deepl or Gravatar is also tested.

After running the tests you can find simplecov report in the directory coverage, e.g.: simplecov.png

While the system tests are running, you can access the test environment web application in parallel via http:https://localhost:8112. Or you can start the Rails server for the test environment manually inside the docker container to inspect the web application working with test test environment data:

docker exec -it quote_rails bash -c "export PORT=3100 && rails server --environment test -P /tmp/test.pid"

👉 If you are using Rails 7.1.3.3 there is a hack needed to run the system tests. scripts/compose.sh is doing it by extending line #19 in file /usr/local/bundle/gems/actionpack-7.1.3.2/lib/action_dispatch/system_testing/driver.rb, see rails/issues/50827:

< @browser.preload
> @browser.preload unless @options[:browser] == :remote

JavaScript

For JavaScript files and debugging see folder app/javascript.

New Server Version

Todo list before create a new server image:

History

  • 2024 upgraded to Rails 7.1.3, added avatar images
  • 2023 updated Rails 7.0.5 ... 7.0.8, Ruby 3.1
  • 2023 everything translated from German into English, español, 日本語 and українська
  • 2023 using Hotwire Turbo (see Autocomplete mit Rails & Turbo)
  • 2022 updated to Ruby 3.0 and Rails 7.0.1 ... 7.0.4
  • 2021 updated to Rails 6.1.3 ... 6.1.4
  • 2020 updated to Rails 6.0.2 ... 6.1.0
  • 2019 updated to Rails 5.2.3 / 5.2.4, upgraded to 6.0.1
  • 2018 migrated to Rails 5.1.5, updated to Rails 5.2.1 / 5.2.2
  • 2009 upgraded to Rails 2.0
  • 2006 developed with Rails 1.2

Contact

Don't hesitate to ask if you have any questions or comments.