A lot :)
This commit is contained in:
parent
aad67af0d1
commit
63fc206c27
153 changed files with 2043 additions and 646 deletions
|
|
@ -2,5 +2,8 @@ version: '3.8'
|
||||||
services:
|
services:
|
||||||
# Update this to the name of the service you want to work with in your docker-compose.yml file
|
# Update this to the name of the service you want to work with in your docker-compose.yml file
|
||||||
app:
|
app:
|
||||||
|
environment:
|
||||||
|
EDITOR: code
|
||||||
|
SHELL: fish
|
||||||
command: /bin/sh -c "while sleep 1000; do :; done"
|
command: /bin/sh -c "while sleep 1000; do :; done"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,3 +40,4 @@
|
||||||
/docker-compose.yml
|
/docker-compose.yml
|
||||||
|
|
||||||
/.forgejo/
|
/.forgejo/
|
||||||
|
/core*
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ jobs:
|
||||||
path: repository
|
path: repository
|
||||||
key: ${{ runner.os }}-repository-${{ github.sha }}
|
key: ${{ runner.os }}-repository-${{ github.sha }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-repository-
|
${{ runner.os }}-repository
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
|
|
@ -1,12 +0,0 @@
|
||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for more information:
|
|
||||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
# https://containers.dev/guide/dependabot
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "devcontainers"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: weekly
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
inherit_gem:
|
||||||
|
rubocop-rails-omakase: rubocop.yml
|
||||||
|
|
||||||
require:
|
require:
|
||||||
- rubocop-capybara
|
- rubocop-capybara
|
||||||
- rubocop-rails
|
- rubocop-rails
|
||||||
|
|
|
||||||
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
|
|
@ -10,18 +10,5 @@
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"preLaunchTask": "dev"
|
"preLaunchTask": "dev"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "ruby_lsp",
|
|
||||||
"name": "Debug script",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "ruby ${file}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ruby_lsp",
|
|
||||||
"name": "Debug test",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "ruby -Itest ${relativeFile}"
|
|
||||||
},
|
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
15
.vscode/tasks.json
vendored
15
.vscode/tasks.json
vendored
|
|
@ -2,10 +2,21 @@
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "process",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "silent",
|
||||||
|
"focus": false,
|
||||||
|
"panel": "dedicated",
|
||||||
|
"showReuseMessage": true,
|
||||||
|
"clear": false,
|
||||||
|
"revealProblems": "always",
|
||||||
|
"group": "dev",
|
||||||
|
"close": true
|
||||||
|
},
|
||||||
"command": "dev",
|
"command": "dev",
|
||||||
"label": "dev",
|
"label": "dev",
|
||||||
"isBackground": true
|
"isBackground": true,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
156
Dockerfile
156
Dockerfile
|
|
@ -47,7 +47,7 @@ RUN \
|
||||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
||||||
apt-get update -yqq && \
|
apt-get update -yqq && \
|
||||||
apt-get install -yqq --no-install-recommends \
|
apt-get install -yqq --no-install-recommends \
|
||||||
sqlite3 nodejs npm sassc yarn libvips fish ranger pandoc && \
|
sqlite3 nodejs npm sassc yarn libvips fish ranger pandoc libjemalloc2 && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
npm install tabby-agent && \
|
npm install tabby-agent && \
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||||
|
|
@ -55,26 +55,23 @@ RUN \
|
||||||
gem update --system && \
|
gem update --system && \
|
||||||
bundle config set app_config ${GEM_HOME}
|
bundle config set app_config ${GEM_HOME}
|
||||||
|
|
||||||
|
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
|
||||||
|
|
||||||
USER ${NAME}
|
USER ${NAME}
|
||||||
|
|
||||||
FROM development AS builder
|
RUN mkdir -p ~/.config/fish && echo "set fish_greeting" >> ~/.config/fish/config.fish
|
||||||
|
RUN \
|
||||||
|
echo >> ~/.config/fish/config.fish &&\
|
||||||
|
echo "function fish_prompt" >> ~/.config/fish/config.fish &&\
|
||||||
|
echo " set -l last_status \$status" >> ~/.config/fish/config.fish &&\
|
||||||
|
echo " set -l stat" >> ~/.config/fish/config.fish &&\
|
||||||
|
echo " if test \$last_status -ne 0" >> ~/.config/fish/config.fish &&\
|
||||||
|
echo " set stat (set_color red)\"[\$last_status]\"(set_color normal)" >> ~/.config/fish/config.fish &&\
|
||||||
|
echo " end" >> ~/.config/fish/config.fish &&\
|
||||||
|
echo " string join '' -- (set_color green) (prompt_pwd) (set_color normal) \$stat ' 🐳 '" >> ~/.config/fish/config.fish && \
|
||||||
|
echo "end" >> ~/.config/fish/config.fish
|
||||||
|
|
||||||
USER root
|
FROM ruby:${RUBY_VERSION}-alpine AS builder
|
||||||
|
|
||||||
COPY Gemfile Gemfile.lock package.json yarn.lock ./
|
|
||||||
|
|
||||||
RUN bundle install && yarn install
|
|
||||||
|
|
||||||
FROM builder AS assets
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
COPY --from=builder /app/.bundle /app/.bundle
|
|
||||||
COPY --from=builder /app/node_modules /app/node_modules
|
|
||||||
|
|
||||||
RUN RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 rails assets:precompile
|
|
||||||
|
|
||||||
FROM ruby:${RUBY_VERSION}-slim AS production
|
|
||||||
|
|
||||||
ARG NAME
|
ARG NAME
|
||||||
ARG UID
|
ARG UID
|
||||||
|
|
@ -84,50 +81,111 @@ ARG INSTALL_DIR
|
||||||
|
|
||||||
WORKDIR ${INSTALL_DIR}
|
WORKDIR ${INSTALL_DIR}
|
||||||
|
|
||||||
|
ENV GEM_HOME=${INSTALL_DIR}/.bundle
|
||||||
|
|
||||||
ENV \
|
ENV \
|
||||||
LANG=C.UTF-8 \
|
LANG=C.UTF-8 \
|
||||||
INSTALL_DIR=${INSTALL_DIR} \
|
INSTALL_DIR=${INSTALL_DIR} \
|
||||||
RAILS_ENV=production \
|
RAILS_ENV=development \
|
||||||
TZ=Europe/Zurich \
|
TZ=Europe/Zurich \
|
||||||
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
|
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH \
|
||||||
|
EDITOR=vim
|
||||||
|
|
||||||
ENV GEM_HOME=${INSTALL_DIR}/.bundle
|
RUN apk add --update --no-cache \
|
||||||
|
binutils-gold \
|
||||||
RUN \
|
build-base \
|
||||||
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
|
curl \
|
||||||
echo $TZ > /etc/timezone && \
|
file \
|
||||||
addgroup --gid ${GID} ${NAME} && \
|
g++ \
|
||||||
adduser \
|
gcc \
|
||||||
--gecos GECOS \
|
git \
|
||||||
--home /home/${NAME} \
|
less \
|
||||||
--uid ${UID} \
|
libstdc++ \
|
||||||
--gid ${GID} \
|
libffi-dev \
|
||||||
--disabled-password \
|
libc-dev \
|
||||||
--disabled-login \
|
linux-headers \
|
||||||
--shell /bin/bash \
|
libxml2-dev \
|
||||||
${NAME} && \
|
libxslt-dev \
|
||||||
apt-get update -yqq && \
|
libgcrypt-dev \
|
||||||
apt-get install -yqq --no-install-recommends \
|
make \
|
||||||
sqlite3 libvips pandoc && \
|
netcat-openbsd \
|
||||||
apt-get clean && \
|
nodejs \
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
openssl \
|
||||||
|
pkgconfig \
|
||||||
|
tzdata \
|
||||||
|
yarn \
|
||||||
|
sqlite \
|
||||||
|
vips-dev \
|
||||||
|
npm \
|
||||||
|
sassc \
|
||||||
|
jemalloc \
|
||||||
|
pandoc-cli \
|
||||||
|
sqlite-libs \
|
||||||
|
build-base && \
|
||||||
truncate -s 0 /var/log/*log && \
|
truncate -s 0 /var/log/*log && \
|
||||||
gem update --system && \
|
gem update --system && \
|
||||||
bundle config set app_config ${GEM_HOME}
|
bundle config set app_config ${GEM_HOME}
|
||||||
|
|
||||||
EXPOSE 3000
|
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
|
||||||
|
|
||||||
ENTRYPOINT [ "bin/entrypoint" ]
|
USER ${NAME}
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
COPY Gemfile Gemfile.lock package.json yarn.lock ./
|
||||||
|
|
||||||
|
RUN bundle config without test development && bundle install && yarn install
|
||||||
|
|
||||||
|
FROM builder AS assets
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
COPY --from=builder /app/.bundle /app/.bundle
|
COPY --from=builder ${INSTALL_DIR}/.bundle ${INSTALL_DIR}/.bundle
|
||||||
COPY --from=assets /app/public/assets /app/public/assets
|
COPY --from=builder ${INSTALL_DIR}/node_modules ${INSTALL_DIR}/node_modules
|
||||||
|
|
||||||
RUN chown -R app:app /app/tmp /app/log /app/storage
|
RUN RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 rails assets:precompile
|
||||||
RUN date +"%Y-%m-%d %H:%M:%S %Z" >> .build_version
|
|
||||||
|
FROM ruby:${RUBY_VERSION}-alpine AS production
|
||||||
|
|
||||||
|
ARG INSTALL_DIR
|
||||||
|
ARG NAME
|
||||||
|
|
||||||
|
WORKDIR ${INSTALL_DIR}
|
||||||
|
|
||||||
|
ENV GEM_HOME=${INSTALL_DIR}/.bundle
|
||||||
|
|
||||||
|
ENV \
|
||||||
|
RAILS_ENV=production \
|
||||||
|
PATH=${INSTALL_DIR}/bin:$GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH \
|
||||||
|
TZ=Europe/Zurich
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
adduser ${NAME} --disabled-password --shell /bin/ash && \
|
||||||
|
apk add --update --no-cache \
|
||||||
|
tzdata \
|
||||||
|
sqlite \
|
||||||
|
vips-dev \
|
||||||
|
jemalloc && \
|
||||||
|
gem update --system && \
|
||||||
|
bundle config set app_config ${GEM_HOME} && \
|
||||||
|
bundle config set without development test && \
|
||||||
|
apk add patchelf && \
|
||||||
|
patchelf --add-needed libjemalloc.so.2 /usr/local/bin/ruby && \
|
||||||
|
apk del patchelf && \
|
||||||
|
truncate -s 0 /var/log/*log
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
COPY --from=builder ${INSTALL_DIR}/.bundle ${INSTALL_DIR}/.bundle
|
||||||
|
COPY --from=assets ${INSTALL_DIR}/public/assets ${INSTALL_DIR}/public/assets
|
||||||
|
|
||||||
|
RUN chown -R ${NAME}:${NAME} ${INSTALL_DIR}/tmp ${INSTALL_DIR}/log ${INSTALL_DIR}/storage && \
|
||||||
|
date +"%Y-%m-%d %H:%M:%S %Z" >> .build_version
|
||||||
|
|
||||||
|
USER ${NAME}
|
||||||
|
|
||||||
|
ENTRYPOINT [ "bin/entrypoint" ]
|
||||||
|
|
||||||
USER app
|
|
||||||
# Using variables in command list is not possible:
|
|
||||||
# https://stackoverflow.com/questions/40454470/how-can-i-use-a-variable-inside-a-dockerfile-cmd
|
|
||||||
CMD [ "rails", "server", "--binding", "0.0.0.0", "--no-daemon", "--port" , "3000" ]
|
CMD [ "rails", "server", "--binding", "0.0.0.0", "--no-daemon", "--port" , "3000" ]
|
||||||
|
|
|
||||||
68
Gemfile
68
Gemfile
|
|
@ -1,35 +1,36 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
source "https://rubygems.org"
|
||||||
|
|
||||||
ruby '3.3.4'
|
ruby "3.3.4"
|
||||||
|
|
||||||
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
||||||
gem 'rails', '~> 7.1.3', '>= 7.1.3.4'
|
gem "rails", "~> 7.2"
|
||||||
|
|
||||||
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
|
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
|
||||||
gem 'sprockets-rails'
|
gem "sprockets-rails"
|
||||||
|
|
||||||
# Use sqlite3 as the database for Active Record
|
# Use sqlite3 as the database for Active Record
|
||||||
gem 'sqlite3', '~> 1.4'
|
# gem "sqlite3", "~> 1.4"
|
||||||
|
gem "sqlite3", ">= 2.0"
|
||||||
|
|
||||||
# Use the Puma web server [https://github.com/puma/puma]
|
# Use the Puma web server [https://github.com/puma/puma]
|
||||||
gem 'puma', '>= 5.0'
|
gem "puma", ">= 5.0"
|
||||||
|
|
||||||
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
|
# Bundle and transpile JavaScript [https://github.com/rails/jsbundling-rails]
|
||||||
gem 'jsbundling-rails'
|
gem "jsbundling-rails"
|
||||||
|
|
||||||
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
|
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
|
||||||
gem 'turbo-rails'
|
gem "turbo-rails"
|
||||||
|
|
||||||
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
|
# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
|
||||||
gem 'stimulus-rails'
|
gem "stimulus-rails"
|
||||||
|
|
||||||
# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
|
# Bundle and process CSS [https://github.com/rails/cssbundling-rails]
|
||||||
gem 'cssbundling-rails'
|
gem "cssbundling-rails"
|
||||||
|
|
||||||
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
||||||
gem 'jbuilder'
|
gem "jbuilder"
|
||||||
|
|
||||||
# Use Redis adapter to run Action Cable in production
|
# Use Redis adapter to run Action Cable in production
|
||||||
# gem "redis", ">= 4.0.1"
|
# gem "redis", ">= 4.0.1"
|
||||||
|
|
@ -41,45 +42,50 @@ gem 'jbuilder'
|
||||||
# gem "bcrypt", "~> 3.1.7"
|
# gem "bcrypt", "~> 3.1.7"
|
||||||
|
|
||||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
gem 'tzinfo-data', platforms: %i[windows jruby]
|
gem "tzinfo-data", platforms: %i[windows jruby]
|
||||||
|
|
||||||
# Reduces boot times through caching; required in config/boot.rb
|
# Reduces boot times through caching; required in config/boot.rb
|
||||||
gem 'bootsnap', require: false
|
gem "bootsnap", require: false
|
||||||
|
|
||||||
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
|
||||||
gem 'bootstrap_form'
|
gem "bootstrap_form"
|
||||||
gem 'caxlsx'
|
gem "caxlsx"
|
||||||
gem 'caxlsx_rails'
|
gem "caxlsx_rails"
|
||||||
gem 'image_processing', '~> 1.2'
|
gem "image_processing", "~> 1.2"
|
||||||
gem 'pagy', '~> 9.0'
|
gem "openxml-docx"
|
||||||
gem 'pandoc-ruby'
|
gem "pagy", "~> 9.0"
|
||||||
gem 'prawn-markup'
|
gem "pandoc-ruby"
|
||||||
gem 'prawn-rails'
|
gem "prawn-markup"
|
||||||
gem 'sablon'
|
gem "prawn-rails"
|
||||||
|
gem "sablon"
|
||||||
|
gem "activerecord-enhancedsqlite3-adapter"
|
||||||
|
gem "slim"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
||||||
gem 'debug', platforms: %i[mri windows]
|
gem "debug", platforms: %i[mri windows]
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# Use console on exceptions pages [https://github.com/rails/web-console]
|
# Use console on exceptions pages [https://github.com/rails/web-console]
|
||||||
gem 'web-console'
|
gem "web-console"
|
||||||
|
|
||||||
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
|
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
|
||||||
# gem "rack-mini-profiler"
|
# gem "rack-mini-profiler"
|
||||||
|
|
||||||
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
|
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
|
||||||
# gem "spring"
|
# gem "spring"
|
||||||
gem 'rubocop'
|
gem "brakeman"
|
||||||
gem 'rubocop-capybara'
|
gem "rubocop"
|
||||||
gem 'rubocop-rails'
|
gem "rubocop-capybara"
|
||||||
gem 'ruby-lsp'
|
gem "rubocop-rails"
|
||||||
gem 'ruby-lsp-rails'
|
gem "rubocop-rails-omakase", require: false
|
||||||
|
gem "ruby-lsp"
|
||||||
|
gem "ruby-lsp-rails"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
|
||||||
gem 'capybara'
|
gem "capybara"
|
||||||
gem 'selenium-webdriver'
|
gem "selenium-webdriver"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
190
Gemfile.lock
190
Gemfile.lock
|
|
@ -1,80 +1,79 @@
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actioncable (7.1.3.4)
|
actioncable (7.2.0)
|
||||||
actionpack (= 7.1.3.4)
|
actionpack (= 7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (>= 0.6.1)
|
websocket-driver (>= 0.6.1)
|
||||||
zeitwerk (~> 2.6)
|
zeitwerk (~> 2.6)
|
||||||
actionmailbox (7.1.3.4)
|
actionmailbox (7.2.0)
|
||||||
actionpack (= 7.1.3.4)
|
actionpack (= 7.2.0)
|
||||||
activejob (= 7.1.3.4)
|
activejob (= 7.2.0)
|
||||||
activerecord (= 7.1.3.4)
|
activerecord (= 7.2.0)
|
||||||
activestorage (= 7.1.3.4)
|
activestorage (= 7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
mail (>= 2.7.1)
|
mail (>= 2.8.0)
|
||||||
net-imap
|
actionmailer (7.2.0)
|
||||||
net-pop
|
actionpack (= 7.2.0)
|
||||||
net-smtp
|
actionview (= 7.2.0)
|
||||||
actionmailer (7.1.3.4)
|
activejob (= 7.2.0)
|
||||||
actionpack (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
actionview (= 7.1.3.4)
|
mail (>= 2.8.0)
|
||||||
activejob (= 7.1.3.4)
|
|
||||||
activesupport (= 7.1.3.4)
|
|
||||||
mail (~> 2.5, >= 2.5.4)
|
|
||||||
net-imap
|
|
||||||
net-pop
|
|
||||||
net-smtp
|
|
||||||
rails-dom-testing (~> 2.2)
|
rails-dom-testing (~> 2.2)
|
||||||
actionpack (7.1.3.4)
|
actionpack (7.2.0)
|
||||||
actionview (= 7.1.3.4)
|
actionview (= 7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
nokogiri (>= 1.8.5)
|
nokogiri (>= 1.8.5)
|
||||||
racc
|
racc
|
||||||
rack (>= 2.2.4)
|
rack (>= 2.2.4, < 3.2)
|
||||||
rack-session (>= 1.0.1)
|
rack-session (>= 1.0.1)
|
||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
rails-dom-testing (~> 2.2)
|
rails-dom-testing (~> 2.2)
|
||||||
rails-html-sanitizer (~> 1.6)
|
rails-html-sanitizer (~> 1.6)
|
||||||
actiontext (7.1.3.4)
|
useragent (~> 0.16)
|
||||||
actionpack (= 7.1.3.4)
|
actiontext (7.2.0)
|
||||||
activerecord (= 7.1.3.4)
|
actionpack (= 7.2.0)
|
||||||
activestorage (= 7.1.3.4)
|
activerecord (= 7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activestorage (= 7.2.0)
|
||||||
|
activesupport (= 7.2.0)
|
||||||
globalid (>= 0.6.0)
|
globalid (>= 0.6.0)
|
||||||
nokogiri (>= 1.8.5)
|
nokogiri (>= 1.8.5)
|
||||||
actionview (7.1.3.4)
|
actionview (7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.11)
|
erubi (~> 1.11)
|
||||||
rails-dom-testing (~> 2.2)
|
rails-dom-testing (~> 2.2)
|
||||||
rails-html-sanitizer (~> 1.6)
|
rails-html-sanitizer (~> 1.6)
|
||||||
activejob (7.1.3.4)
|
activejob (7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (7.1.3.4)
|
activemodel (7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
activerecord (7.1.3.4)
|
activerecord (7.2.0)
|
||||||
activemodel (= 7.1.3.4)
|
activemodel (= 7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
timeout (>= 0.4.0)
|
timeout (>= 0.4.0)
|
||||||
activestorage (7.1.3.4)
|
activerecord-enhancedsqlite3-adapter (0.8.0)
|
||||||
actionpack (= 7.1.3.4)
|
activerecord (>= 7.1)
|
||||||
activejob (= 7.1.3.4)
|
sqlite3 (>= 1.6)
|
||||||
activerecord (= 7.1.3.4)
|
activestorage (7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
actionpack (= 7.2.0)
|
||||||
|
activejob (= 7.2.0)
|
||||||
|
activerecord (= 7.2.0)
|
||||||
|
activesupport (= 7.2.0)
|
||||||
marcel (~> 1.0)
|
marcel (~> 1.0)
|
||||||
activesupport (7.1.3.4)
|
activesupport (7.2.0)
|
||||||
base64
|
base64
|
||||||
bigdecimal
|
bigdecimal
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
||||||
connection_pool (>= 2.2.5)
|
connection_pool (>= 2.2.5)
|
||||||
drb
|
drb
|
||||||
i18n (>= 1.6, < 2)
|
i18n (>= 1.6, < 2)
|
||||||
|
logger (>= 1.4.2)
|
||||||
minitest (>= 5.1)
|
minitest (>= 5.1)
|
||||||
mutex_m
|
securerandom (>= 0.3)
|
||||||
tzinfo (~> 2.0)
|
tzinfo (~> 2.0, >= 2.0.5)
|
||||||
addressable (2.8.7)
|
addressable (2.8.7)
|
||||||
public_suffix (>= 2.0.2, < 7.0)
|
public_suffix (>= 2.0.2, < 7.0)
|
||||||
ast (2.4.2)
|
ast (2.4.2)
|
||||||
|
|
@ -86,6 +85,8 @@ GEM
|
||||||
bootstrap_form (5.4.0)
|
bootstrap_form (5.4.0)
|
||||||
actionpack (>= 6.1)
|
actionpack (>= 6.1)
|
||||||
activemodel (>= 6.1)
|
activemodel (>= 6.1)
|
||||||
|
brakeman (6.1.2)
|
||||||
|
racc
|
||||||
builder (3.3.0)
|
builder (3.3.0)
|
||||||
capybara (3.40.0)
|
capybara (3.40.0)
|
||||||
addressable
|
addressable
|
||||||
|
|
@ -155,7 +156,6 @@ GEM
|
||||||
mini_mime (1.1.5)
|
mini_mime (1.1.5)
|
||||||
minitest (5.24.1)
|
minitest (5.24.1)
|
||||||
msgpack (1.7.2)
|
msgpack (1.7.2)
|
||||||
mutex_m (0.2.0)
|
|
||||||
net-imap (0.4.14)
|
net-imap (0.4.14)
|
||||||
date
|
date
|
||||||
net-protocol
|
net-protocol
|
||||||
|
|
@ -178,6 +178,19 @@ GEM
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.16.6-x86_64-linux)
|
nokogiri (1.16.6-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
|
openxml-docx (0.11.5)
|
||||||
|
nokogiri
|
||||||
|
openxml-drawingml
|
||||||
|
openxml-package (>= 0.2.2)
|
||||||
|
ox (~> 2.9)
|
||||||
|
openxml-drawingml (0.3.1)
|
||||||
|
nokogiri
|
||||||
|
openxml-package (~> 0.3.2)
|
||||||
|
openxml-package (0.3.4)
|
||||||
|
nokogiri
|
||||||
|
ox
|
||||||
|
rubyzip
|
||||||
|
ox (2.14.18)
|
||||||
pagy (9.0.2)
|
pagy (9.0.2)
|
||||||
pandoc-ruby (2.1.10)
|
pandoc-ruby (2.1.10)
|
||||||
parallel (1.25.1)
|
parallel (1.25.1)
|
||||||
|
|
@ -214,20 +227,20 @@ GEM
|
||||||
rackup (2.1.0)
|
rackup (2.1.0)
|
||||||
rack (>= 3)
|
rack (>= 3)
|
||||||
webrick (~> 1.8)
|
webrick (~> 1.8)
|
||||||
rails (7.1.3.4)
|
rails (7.2.0)
|
||||||
actioncable (= 7.1.3.4)
|
actioncable (= 7.2.0)
|
||||||
actionmailbox (= 7.1.3.4)
|
actionmailbox (= 7.2.0)
|
||||||
actionmailer (= 7.1.3.4)
|
actionmailer (= 7.2.0)
|
||||||
actionpack (= 7.1.3.4)
|
actionpack (= 7.2.0)
|
||||||
actiontext (= 7.1.3.4)
|
actiontext (= 7.2.0)
|
||||||
actionview (= 7.1.3.4)
|
actionview (= 7.2.0)
|
||||||
activejob (= 7.1.3.4)
|
activejob (= 7.2.0)
|
||||||
activemodel (= 7.1.3.4)
|
activemodel (= 7.2.0)
|
||||||
activerecord (= 7.1.3.4)
|
activerecord (= 7.2.0)
|
||||||
activestorage (= 7.1.3.4)
|
activestorage (= 7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
bundler (>= 1.15.0)
|
bundler (>= 1.15.0)
|
||||||
railties (= 7.1.3.4)
|
railties (= 7.2.0)
|
||||||
rails-dom-testing (2.2.0)
|
rails-dom-testing (2.2.0)
|
||||||
activesupport (>= 5.0.0)
|
activesupport (>= 5.0.0)
|
||||||
minitest
|
minitest
|
||||||
|
|
@ -235,10 +248,10 @@ GEM
|
||||||
rails-html-sanitizer (1.6.0)
|
rails-html-sanitizer (1.6.0)
|
||||||
loofah (~> 2.21)
|
loofah (~> 2.21)
|
||||||
nokogiri (~> 1.14)
|
nokogiri (~> 1.14)
|
||||||
railties (7.1.3.4)
|
railties (7.2.0)
|
||||||
actionpack (= 7.1.3.4)
|
actionpack (= 7.2.0)
|
||||||
activesupport (= 7.1.3.4)
|
activesupport (= 7.2.0)
|
||||||
irb
|
irb (~> 1.13)
|
||||||
rackup (>= 1.0.0)
|
rackup (>= 1.0.0)
|
||||||
rake (>= 12.2)
|
rake (>= 12.2)
|
||||||
thor (~> 1.0, >= 1.2.2)
|
thor (~> 1.0, >= 1.2.2)
|
||||||
|
|
@ -252,7 +265,7 @@ GEM
|
||||||
regexp_parser (2.9.2)
|
regexp_parser (2.9.2)
|
||||||
reline (0.5.9)
|
reline (0.5.9)
|
||||||
io-console (~> 0.5)
|
io-console (~> 0.5)
|
||||||
rexml (3.3.1)
|
rexml (3.3.2)
|
||||||
strscan
|
strscan
|
||||||
rubocop (1.65.0)
|
rubocop (1.65.0)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
|
|
@ -269,11 +282,22 @@ GEM
|
||||||
parser (>= 3.3.1.0)
|
parser (>= 3.3.1.0)
|
||||||
rubocop-capybara (2.21.0)
|
rubocop-capybara (2.21.0)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
|
rubocop-minitest (0.35.1)
|
||||||
|
rubocop (>= 1.61, < 2.0)
|
||||||
|
rubocop-ast (>= 1.31.1, < 2.0)
|
||||||
|
rubocop-performance (1.21.1)
|
||||||
|
rubocop (>= 1.48.1, < 2.0)
|
||||||
|
rubocop-ast (>= 1.31.1, < 2.0)
|
||||||
rubocop-rails (2.25.1)
|
rubocop-rails (2.25.1)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
rack (>= 1.1)
|
rack (>= 1.1)
|
||||||
rubocop (>= 1.33.0, < 2.0)
|
rubocop (>= 1.33.0, < 2.0)
|
||||||
rubocop-ast (>= 1.31.1, < 2.0)
|
rubocop-ast (>= 1.31.1, < 2.0)
|
||||||
|
rubocop-rails-omakase (1.0.0)
|
||||||
|
rubocop
|
||||||
|
rubocop-minitest
|
||||||
|
rubocop-performance
|
||||||
|
rubocop-rails
|
||||||
ruby-lsp (0.17.7)
|
ruby-lsp (0.17.7)
|
||||||
language_server-protocol (~> 3.17.0)
|
language_server-protocol (~> 3.17.0)
|
||||||
prism (>= 0.29.0, < 0.31)
|
prism (>= 0.29.0, < 0.31)
|
||||||
|
|
@ -288,12 +312,16 @@ GEM
|
||||||
sablon (0.4.1)
|
sablon (0.4.1)
|
||||||
nokogiri (>= 1.8.5)
|
nokogiri (>= 1.8.5)
|
||||||
rubyzip (>= 1.3.0)
|
rubyzip (>= 1.3.0)
|
||||||
selenium-webdriver (4.22.0)
|
securerandom (0.3.1)
|
||||||
|
selenium-webdriver (4.23.0)
|
||||||
base64 (~> 0.2)
|
base64 (~> 0.2)
|
||||||
logger (~> 1.4)
|
logger (~> 1.4)
|
||||||
rexml (~> 3.2, >= 3.2.5)
|
rexml (~> 3.2, >= 3.2.5)
|
||||||
rubyzip (>= 1.2.2, < 3.0)
|
rubyzip (>= 1.2.2, < 3.0)
|
||||||
websocket (~> 1.0)
|
websocket (~> 1.0)
|
||||||
|
slim (5.2.1)
|
||||||
|
temple (~> 0.10.0)
|
||||||
|
tilt (>= 2.1.0)
|
||||||
sorbet-runtime (0.5.11481)
|
sorbet-runtime (0.5.11481)
|
||||||
sprockets (4.2.1)
|
sprockets (4.2.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
|
|
@ -302,17 +330,19 @@ GEM
|
||||||
actionpack (>= 6.1)
|
actionpack (>= 6.1)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sqlite3 (1.7.3-aarch64-linux)
|
sqlite3 (2.0.3-aarch64-linux-gnu)
|
||||||
sqlite3 (1.7.3-arm-linux)
|
sqlite3 (2.0.3-arm-linux-gnu)
|
||||||
sqlite3 (1.7.3-arm64-darwin)
|
sqlite3 (2.0.3-arm64-darwin)
|
||||||
sqlite3 (1.7.3-x86-linux)
|
sqlite3 (2.0.3-x86-linux-gnu)
|
||||||
sqlite3 (1.7.3-x86_64-darwin)
|
sqlite3 (2.0.3-x86_64-darwin)
|
||||||
sqlite3 (1.7.3-x86_64-linux)
|
sqlite3 (2.0.3-x86_64-linux-gnu)
|
||||||
stimulus-rails (1.3.3)
|
stimulus-rails (1.3.3)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
stringio (3.1.1)
|
stringio (3.1.1)
|
||||||
strscan (3.1.0)
|
strscan (3.1.0)
|
||||||
|
temple (0.10.3)
|
||||||
thor (1.3.1)
|
thor (1.3.1)
|
||||||
|
tilt (2.4.0)
|
||||||
timeout (0.4.1)
|
timeout (0.4.1)
|
||||||
ttfunk (1.8.0)
|
ttfunk (1.8.0)
|
||||||
bigdecimal (~> 3.1)
|
bigdecimal (~> 3.1)
|
||||||
|
|
@ -323,6 +353,7 @@ GEM
|
||||||
tzinfo (2.0.6)
|
tzinfo (2.0.6)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
unicode-display_width (2.5.0)
|
unicode-display_width (2.5.0)
|
||||||
|
useragent (0.16.10)
|
||||||
web-console (4.2.1)
|
web-console (4.2.1)
|
||||||
actionview (>= 6.0.0)
|
actionview (>= 6.0.0)
|
||||||
activemodel (>= 6.0.0)
|
activemodel (>= 6.0.0)
|
||||||
|
|
@ -346,8 +377,10 @@ PLATFORMS
|
||||||
x86_64-linux
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
activerecord-enhancedsqlite3-adapter
|
||||||
bootsnap
|
bootsnap
|
||||||
bootstrap_form
|
bootstrap_form
|
||||||
|
brakeman
|
||||||
capybara
|
capybara
|
||||||
caxlsx
|
caxlsx
|
||||||
caxlsx_rails
|
caxlsx_rails
|
||||||
|
|
@ -356,21 +389,24 @@ DEPENDENCIES
|
||||||
image_processing (~> 1.2)
|
image_processing (~> 1.2)
|
||||||
jbuilder
|
jbuilder
|
||||||
jsbundling-rails
|
jsbundling-rails
|
||||||
|
openxml-docx
|
||||||
pagy (~> 9.0)
|
pagy (~> 9.0)
|
||||||
pandoc-ruby
|
pandoc-ruby
|
||||||
prawn-markup
|
prawn-markup
|
||||||
prawn-rails
|
prawn-rails
|
||||||
puma (>= 5.0)
|
puma (>= 5.0)
|
||||||
rails (~> 7.1.3, >= 7.1.3.4)
|
rails (~> 7.2)
|
||||||
rubocop
|
rubocop
|
||||||
rubocop-capybara
|
rubocop-capybara
|
||||||
rubocop-rails
|
rubocop-rails
|
||||||
|
rubocop-rails-omakase
|
||||||
ruby-lsp
|
ruby-lsp
|
||||||
ruby-lsp-rails
|
ruby-lsp-rails
|
||||||
sablon
|
sablon
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
|
slim
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
sqlite3 (~> 1.4)
|
sqlite3 (>= 2.0)
|
||||||
stimulus-rails
|
stimulus-rails
|
||||||
turbo-rails
|
turbo-rails
|
||||||
tzinfo-data
|
tzinfo-data
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,4 @@ $enable-rounded: false;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@import "./layout";
|
@import "./layout";
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class BackupsController < ApplicationController
|
class BackupsController < ApplicationController
|
||||||
# GET /admin/backups/1
|
# GET /admin/backups/1
|
||||||
def show
|
def show
|
||||||
send_file Backup.db_xlsx, filename: 'backup.xlsx', disposition: :attachment
|
send_file Backup.db_xlsx, filename: "backup.xlsx", disposition: :attachment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,20 +3,24 @@
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
include Pagy::Backend
|
include Pagy::Backend
|
||||||
|
|
||||||
|
# allow_browser versions: :modern
|
||||||
|
|
||||||
before_action :initialize_navbar
|
before_action :initialize_navbar
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def initialize_navbar
|
def initialize_navbar
|
||||||
@nav_path = controller_name
|
return unless request.get?
|
||||||
|
|
||||||
@navbar_items = [
|
@navbar_items = [
|
||||||
{ label: 'Dashboard', icon: :speedometer2, path: :root },
|
{ label: "Dashboard", icon: :speedometer2, path: :root },
|
||||||
{ label: Report.model_name.human(count: 2), icon: :'journal-text', path: :reports },
|
{ label: Report.model_name.human(count: 2), icon: :'journal-text', path: :reports },
|
||||||
{ label: Checklist.model_name.human(count: 2), icon: :'list-check', path: :checklists },
|
{ label: Checklist.model_name.human(count: 2), icon: :'list-check', path: :checklists },
|
||||||
{ label: Check.model_name.human(count: 2), icon: :check2, path: :checks },
|
{ label: Check.model_name.human(count: 2), icon: :check2, path: :checks },
|
||||||
{ label: Link.model_name.human(count: 2), icon: :link, path: :links },
|
{ label: Link.model_name.human(count: 2), icon: :link, path: :links },
|
||||||
{ label: LinkCategory.model_name.human(count: 2), icon: :"folder", path: :link_categories }
|
{ label: LinkCategory.model_name.human(count: 2), icon: :folder, path: :link_categories }
|
||||||
]
|
]
|
||||||
@search_url = nil # root_url
|
@nav_path = controller_name
|
||||||
|
@search_url = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
213
app/controllers/benchmarking_controller.rb
Normal file
213
app/controllers/benchmarking_controller.rb
Normal file
|
|
@ -0,0 +1,213 @@
|
||||||
|
class BenchmarkingController < ApplicationController
|
||||||
|
protect_from_forgery with: :null_session
|
||||||
|
before_action :set_user_update_last_seen_at
|
||||||
|
|
||||||
|
# POST /benchmarking/read_heavy
|
||||||
|
def read_heavy
|
||||||
|
act_and_respond(
|
||||||
|
link_create: 0.1,
|
||||||
|
link_destroy: 0.1,
|
||||||
|
link_show: 0.4,
|
||||||
|
links_index: 0.4,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /benchmarking/write_heavy
|
||||||
|
def write_heavy
|
||||||
|
act_and_respond(
|
||||||
|
link_create: 0.4,
|
||||||
|
link_destroy: 0.4,
|
||||||
|
link_show: 0.1,
|
||||||
|
links_index: 0.1,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /benchmarking/balanced
|
||||||
|
def balanced
|
||||||
|
act_and_respond(
|
||||||
|
link_create: 0.25,
|
||||||
|
link_destroy: 0.25,
|
||||||
|
link_show: 0.25,
|
||||||
|
links_index: 0.25,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_create
|
||||||
|
link = LinkCategory.create!(name: "Benchmark #{request.uuid}", description_html: "<pre>#{format(request:)}</pre>")
|
||||||
|
redirect_to link
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_destroy
|
||||||
|
link = LinkCategory.where("id >= ?", rand(LinkCategory.minimum(:id)..LinkCategory.maximum(:id))).limit(1).first
|
||||||
|
link.destroy!
|
||||||
|
redirect_to links_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def link_show
|
||||||
|
@link_category = LinkCategory.where("id >= ?", rand(LinkCategory.minimum(:id)..LinkCategory.maximum(:id))).limit(1).first
|
||||||
|
render "link_categories/show", status: :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def links_index
|
||||||
|
@link_categories = LinkCategory.where("id >= ?", rand(LinkCategory.minimum(:id)..LinkCategory.maximum(:id))).limit(100)
|
||||||
|
render "link_categories/index", status: :ok
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_user_update_last_seen_at
|
||||||
|
# @user = User.where("id >= ?", rand(User.minimum(:id)..User.maximum(:id))).limit(1).first
|
||||||
|
# @user.update!(last_seen_at: Time.now)
|
||||||
|
end
|
||||||
|
|
||||||
|
def act_and_respond(actions_with_weighted_distribution)
|
||||||
|
action = actions_with_weighted_distribution.max_by { |_, weight| rand ** (1.0 / weight) }.first
|
||||||
|
|
||||||
|
send(action)
|
||||||
|
end
|
||||||
|
|
||||||
|
def format(request:)
|
||||||
|
request.headers.to_h.slice(
|
||||||
|
"GATEWAY_INTERFACE",
|
||||||
|
"HTTP_ACCEPT",
|
||||||
|
"HTTP_HOST",
|
||||||
|
"HTTP_USER_AGENT",
|
||||||
|
"HTTP_VERSION",
|
||||||
|
"ORIGINAL_FULLPATH",
|
||||||
|
"ORIGINAL_SCRIPT_NAME",
|
||||||
|
"PATH_INFO",
|
||||||
|
"QUERY_STRING",
|
||||||
|
"REMOTE_ADDR",
|
||||||
|
"REQUEST_METHOD",
|
||||||
|
"REQUEST_PATH",
|
||||||
|
"REQUEST_URI",
|
||||||
|
"SCRIPT_NAME",
|
||||||
|
"SERVER_NAME",
|
||||||
|
"SERVER_PORT",
|
||||||
|
"SERVER_PROTOCOL",
|
||||||
|
"SERVER_SOFTWARE",
|
||||||
|
"action_dispatch.request_id",
|
||||||
|
"puma.request_body_wait",
|
||||||
|
).map { _1.join(": ") }.join("\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# class BenchmarkingController < ApplicationController
|
||||||
|
# skip_before_action :verify_authenticity_token
|
||||||
|
# skip_before_action :ensure_user_authenticated!
|
||||||
|
# before_action :set_user_update_last_seen_at
|
||||||
|
|
||||||
|
# # POST /benchmarking/read_heavy
|
||||||
|
# def read_heavy
|
||||||
|
# act_and_respond(
|
||||||
|
# link_create: 0.10,
|
||||||
|
# comment_create: 0.10,
|
||||||
|
# post_destroy: 0.02,
|
||||||
|
# comment_destroy: 0.03,
|
||||||
|
# post_show: 0.25,
|
||||||
|
# posts_index: 0.25,
|
||||||
|
# user_show: 0.25,
|
||||||
|
# )
|
||||||
|
# end
|
||||||
|
|
||||||
|
# # POST /benchmarking/write_heavy
|
||||||
|
# def write_heavy
|
||||||
|
# act_and_respond(
|
||||||
|
# link_create: 0.25,
|
||||||
|
# comment_create: 0.25,
|
||||||
|
# post_destroy: 0.05,
|
||||||
|
# comment_destroy: 0.20,
|
||||||
|
# post_show: 0.05,
|
||||||
|
# posts_index: 0.15,
|
||||||
|
# user_show: 0.05,
|
||||||
|
# )
|
||||||
|
# end
|
||||||
|
|
||||||
|
# # POST /benchmarking/balanced
|
||||||
|
# def balanced
|
||||||
|
# act_and_respond(
|
||||||
|
# link_create: 0.17,
|
||||||
|
# comment_create: 0.17,
|
||||||
|
# post_destroy: 0.05,
|
||||||
|
# comment_destroy: 0.11,
|
||||||
|
# post_show: 0.17,
|
||||||
|
# posts_index: 0.17,
|
||||||
|
# user_show: 0.16,
|
||||||
|
# )
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def link_create
|
||||||
|
# post = Post.create!(user: @user, title: "Post #{request.uuid}", description: format(request:))
|
||||||
|
# redirect_to post
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def comment_create
|
||||||
|
# post = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(1).first
|
||||||
|
# comment = Comment.create!(user: @user, post: post, body: "Comment #{request.uuid}")
|
||||||
|
# redirect_to comment.post
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def post_destroy
|
||||||
|
# post = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(1).first
|
||||||
|
# post.destroy!
|
||||||
|
# redirect_to posts_path
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def comment_destroy
|
||||||
|
# comment = Comment.where("id >= ?", rand(Comment.minimum(:id)..Comment.maximum(:id))).limit(1).first
|
||||||
|
# comment.destroy!
|
||||||
|
# redirect_to comment.post
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def post_show
|
||||||
|
# @post = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(1).first
|
||||||
|
# render "posts/show", status: :ok
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def posts_index
|
||||||
|
# @posts = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(100)
|
||||||
|
# render "posts/index", status: :ok
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def user_show
|
||||||
|
# render "users/show", status: :ok
|
||||||
|
# end
|
||||||
|
|
||||||
|
# private
|
||||||
|
|
||||||
|
# def set_user_update_last_seen_at
|
||||||
|
# @user = User.where("id >= ?", rand(User.minimum(:id)..User.maximum(:id))).limit(1).first
|
||||||
|
# @user.update!(last_seen_at: Time.now)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def act_and_respond(actions_with_weighted_distribution)
|
||||||
|
# action = actions_with_weighted_distribution.max_by { |_, weight| rand ** (1.0 / weight) }.first
|
||||||
|
|
||||||
|
# send(action)
|
||||||
|
# end
|
||||||
|
|
||||||
|
# def format(request:)
|
||||||
|
# request.headers.to_h.slice(
|
||||||
|
# "GATEWAY_INTERFACE",
|
||||||
|
# "HTTP_ACCEPT",
|
||||||
|
# "HTTP_HOST",
|
||||||
|
# "HTTP_USER_AGENT",
|
||||||
|
# "HTTP_VERSION",
|
||||||
|
# "ORIGINAL_FULLPATH",
|
||||||
|
# "ORIGINAL_SCRIPT_NAME",
|
||||||
|
# "PATH_INFO",
|
||||||
|
# "QUERY_STRING",
|
||||||
|
# "REMOTE_ADDR",
|
||||||
|
# "REQUEST_METHOD",
|
||||||
|
# "REQUEST_PATH",
|
||||||
|
# "REQUEST_URI",
|
||||||
|
# "SCRIPT_NAME",
|
||||||
|
# "SERVER_NAME",
|
||||||
|
# "SERVER_PORT",
|
||||||
|
# "SERVER_PROTOCOL",
|
||||||
|
# "SERVER_SOFTWARE",
|
||||||
|
# "action_dispatch.request_id",
|
||||||
|
# "puma.request_body_wait",
|
||||||
|
# ).map { _1.join(": ") }.join("\n")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ChecklistEntriesController < ApplicationController
|
class ChecklistEntriesController < ApplicationController
|
||||||
before_action :set_checklist_entry, only: %i[show edit update destroy]
|
before_action :set_checklist_entry, only: %i[show edit update destroy]
|
||||||
|
|
||||||
|
|
@ -7,8 +9,7 @@ class ChecklistEntriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /checklist_entries/1
|
# GET /checklist_entries/1
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /checklist_entries/new
|
# GET /checklist_entries/new
|
||||||
def new
|
def new
|
||||||
|
|
@ -16,15 +17,14 @@ class ChecklistEntriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /checklist_entries/1/edit
|
# GET /checklist_entries/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /checklist_entries
|
# POST /checklist_entries
|
||||||
def create
|
def create
|
||||||
@checklist_entry = ChecklistEntry.new(checklist_entry_params)
|
@checklist_entry = ChecklistEntry.new(checklist_entry_params)
|
||||||
|
|
||||||
if @checklist_entry.save
|
if @checklist_entry.save
|
||||||
redirect_to @checklist_entry.checklist, notice: 'Checklist entry was successfully created.'
|
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully created."
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +33,7 @@ class ChecklistEntriesController < ApplicationController
|
||||||
# PATCH/PUT /checklist_entries/1
|
# PATCH/PUT /checklist_entries/1
|
||||||
def update
|
def update
|
||||||
if @checklist_entry.update(checklist_entry_params)
|
if @checklist_entry.update(checklist_entry_params)
|
||||||
redirect_to @checklist_entry.checklist, notice: 'Checklist entry was successfully updated.',
|
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully updated.",
|
||||||
status: :see_other
|
status: :see_other
|
||||||
else
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
|
|
@ -45,7 +45,7 @@ class ChecklistEntriesController < ApplicationController
|
||||||
@checklist_entry.destroy!
|
@checklist_entry.destroy!
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
redirect_to checklist_entries_url, notice: 'Checklist entry was successfully destroyed.', status: :see_other
|
redirect_to checklist_entries_url, notice: "Checklist entry was successfully destroyed.", status: :see_other
|
||||||
end
|
end
|
||||||
format.turbo_stream
|
format.turbo_stream
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ChecklistsController < ApplicationController
|
class ChecklistsController < ApplicationController
|
||||||
before_action :set_checklist, only: %i[show edit update destroy]
|
before_action :set_checklist, only: %i[show edit update destroy]
|
||||||
|
|
||||||
|
|
@ -7,8 +9,7 @@ class ChecklistsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /checklists/1
|
# GET /checklists/1
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /checklists/new
|
# GET /checklists/new
|
||||||
def new
|
def new
|
||||||
|
|
@ -16,15 +17,14 @@ class ChecklistsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /checklists/1/edit
|
# GET /checklists/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /checklists
|
# POST /checklists
|
||||||
def create
|
def create
|
||||||
@checklist = Checklist.new(checklist_params)
|
@checklist = Checklist.new(checklist_params)
|
||||||
|
|
||||||
if @checklist.save
|
if @checklist.save
|
||||||
redirect_to @checklist, notice: 'Checklist was successfully created.'
|
redirect_to @checklist, notice: "Checklist was successfully created."
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +33,7 @@ class ChecklistsController < ApplicationController
|
||||||
# PATCH/PUT /checklists/1
|
# PATCH/PUT /checklists/1
|
||||||
def update
|
def update
|
||||||
if @checklist.update(checklist_params)
|
if @checklist.update(checklist_params)
|
||||||
redirect_to @checklist, notice: 'Checklist was successfully updated.', status: :see_other
|
redirect_to @checklist, notice: "Checklist was successfully updated.", status: :see_other
|
||||||
else
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -42,7 +42,7 @@ class ChecklistsController < ApplicationController
|
||||||
# DELETE /checklists/1
|
# DELETE /checklists/1
|
||||||
def destroy
|
def destroy
|
||||||
@checklist.destroy!
|
@checklist.destroy!
|
||||||
redirect_to checklists_url, notice: 'Checklist was successfully destroyed.', status: :see_other
|
redirect_to checklists_url, notice: "Checklist was successfully destroyed.", status: :see_other
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ChecksController < ApplicationController
|
class ChecksController < ApplicationController
|
||||||
before_action :set_check, only: %i[show edit update destroy]
|
before_action :set_check, only: %i[show edit update destroy]
|
||||||
|
|
||||||
# GET /checks or /checks.json
|
# GET /checks or /checks.json
|
||||||
def index
|
def index
|
||||||
@pagy, @checks = pagy(Check.search(filter_params[:s]))
|
@pagy, @checks = if filter_params[:s]
|
||||||
|
pagy(Check.search(filter_params[:s]).order(:conformity_level))
|
||||||
|
else
|
||||||
|
pagy(Check.all.order(:conformity_level))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /checks/1 or /checks/1.json
|
# GET /checks/1 or /checks/1.json
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /checks/new
|
# GET /checks/new
|
||||||
def new
|
def new
|
||||||
|
|
@ -16,8 +21,7 @@ class ChecksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /checks/1/edit
|
# GET /checks/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /checks or /checks.json
|
# POST /checks or /checks.json
|
||||||
def create
|
def create
|
||||||
|
|
@ -27,11 +31,11 @@ class ChecksController < ApplicationController
|
||||||
if @check.save
|
if @check.save
|
||||||
format.html do
|
format.html do
|
||||||
redirect_to check_url(@check),
|
redirect_to check_url(@check),
|
||||||
notice: t('scaffold.model_created_successfully', model: @check.model_name.human)
|
notice: t("scaffold.model_created_successfully", model: @check.model_name.human)
|
||||||
end
|
end
|
||||||
format.json { render :show, status: :created, location: @check }
|
format.json { render :show, status: :created, location: @check }
|
||||||
else
|
else
|
||||||
flash[:alert] = t('there_were_errors', count: @check.errors.size)
|
flash[:alert] = t("there_were_errors", count: @check.errors.size)
|
||||||
format.html { render :new, status: :unprocessable_entity }
|
format.html { render :new, status: :unprocessable_entity }
|
||||||
format.json { render json: @check.errors, status: :unprocessable_entity }
|
format.json { render json: @check.errors, status: :unprocessable_entity }
|
||||||
end
|
end
|
||||||
|
|
@ -44,7 +48,7 @@ class ChecksController < ApplicationController
|
||||||
if @check.update(check_params)
|
if @check.update(check_params)
|
||||||
format.html do
|
format.html do
|
||||||
redirect_to check_url(@check),
|
redirect_to check_url(@check),
|
||||||
notice: t('scaffold.model_updated_successfully', model: @check.model_name.human)
|
notice: t("scaffold.model_updated_successfully", model: @check.model_name.human)
|
||||||
end
|
end
|
||||||
format.json { render :show, status: :ok, location: @check }
|
format.json { render :show, status: :ok, location: @check }
|
||||||
else
|
else
|
||||||
|
|
@ -60,7 +64,7 @@ class ChecksController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
redirect_to checks_url, notice: t('scaffold.model_destroyed_successfully', model: @check.model_name.human)
|
redirect_to checks_url, notice: t("scaffold.model_destroyed_successfully", model: @check.model_name.human)
|
||||||
end
|
end
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
|
|
@ -79,6 +83,43 @@ class ChecksController < ApplicationController
|
||||||
|
|
||||||
# Only allow a list of trusted parameters through.
|
# Only allow a list of trusted parameters through.
|
||||||
def check_params
|
def check_params
|
||||||
params.require(:check).permit(:position, :name, :success_criterion, :success_criterion_html, :level)
|
params.require(:check).permit(:principle_id,
|
||||||
|
:number,
|
||||||
|
:name_de,
|
||||||
|
:name_en,
|
||||||
|
:standard_id,
|
||||||
|
:visual,
|
||||||
|
:auditory,
|
||||||
|
:physical,
|
||||||
|
:cognitive,
|
||||||
|
:applicable_to_app,
|
||||||
|
:applicable_to_web,
|
||||||
|
:external_number,
|
||||||
|
:conformity_level,
|
||||||
|
:conformity_notice_de,
|
||||||
|
:conformity_notice_en,
|
||||||
|
:priority,
|
||||||
|
:quick_criterion_de,
|
||||||
|
:quick_criterion_en,
|
||||||
|
:quick_fail_de,
|
||||||
|
:quick_fail_en,
|
||||||
|
:quick_fix_de,
|
||||||
|
:quick_fix_en,
|
||||||
|
:criterion_de,
|
||||||
|
:criterion_en,
|
||||||
|
:criterion_details_de,
|
||||||
|
:criterion_details_en,
|
||||||
|
:example_de,
|
||||||
|
:example_en,
|
||||||
|
:exemption_details_de,
|
||||||
|
:exemption_details_en,
|
||||||
|
:standard_text_de,
|
||||||
|
:standard_text_en,
|
||||||
|
:test_instructions,
|
||||||
|
:powerpoint_text_de,
|
||||||
|
:powerpoint_text_en,
|
||||||
|
:comment,
|
||||||
|
link_ids: [],
|
||||||
|
standard_ids: [])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ElementsController < ApplicationController
|
class ElementsController < ApplicationController
|
||||||
before_action :set_element, only: %i[show edit update destroy]
|
before_action :set_element, only: %i[show edit update destroy]
|
||||||
|
|
||||||
|
|
@ -7,8 +9,7 @@ class ElementsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /elements/1
|
# GET /elements/1
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /elements/new
|
# GET /elements/new
|
||||||
def new
|
def new
|
||||||
|
|
@ -16,8 +17,7 @@ class ElementsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /elements/1/edit
|
# GET /elements/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /elements
|
# POST /elements
|
||||||
def create
|
def create
|
||||||
|
|
@ -28,11 +28,11 @@ class ElementsController < ApplicationController
|
||||||
|
|
||||||
if @element.save
|
if @element.save
|
||||||
checklist.checks.each do |check|
|
checklist.checks.each do |check|
|
||||||
@element.success_criteria.create!(title: check.name, description_html: check.success_criterion_html,
|
@element.success_criteria.create!(title: check.t_name, description_html: check.t_criterion,
|
||||||
level: check.level)
|
level: check.level)
|
||||||
end
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to @element.report, notice: 'Element was successfully created.' }
|
format.html { redirect_to @element.report, notice: "Element was successfully created." }
|
||||||
format.turbo_stream
|
format.turbo_stream
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
@ -43,7 +43,7 @@ class ElementsController < ApplicationController
|
||||||
# PATCH/PUT /elements/1
|
# PATCH/PUT /elements/1
|
||||||
def update
|
def update
|
||||||
if @element.update(element_params)
|
if @element.update(element_params)
|
||||||
redirect_to @element, notice: 'Element was successfully updated.', status: :see_other
|
redirect_to @element, notice: "Element was successfully updated.", status: :see_other
|
||||||
else
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -52,7 +52,7 @@ class ElementsController < ApplicationController
|
||||||
# DELETE /elements/1
|
# DELETE /elements/1
|
||||||
def destroy
|
def destroy
|
||||||
@element.destroy!
|
@element.destroy!
|
||||||
redirect_to elements_url, notice: 'Element was successfully destroyed.', status: :see_other
|
redirect_to elements_url, notice: "Element was successfully destroyed.", status: :see_other
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
def show; end
|
def show
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class LinkCategoriesController < ApplicationController
|
class LinkCategoriesController < ApplicationController
|
||||||
before_action :set_link_category, only: %i[ show edit update destroy ]
|
before_action :set_link_category, only: %i[show edit update destroy]
|
||||||
|
|
||||||
# GET /link_categories
|
# GET /link_categories
|
||||||
def index
|
def index
|
||||||
|
|
@ -7,8 +9,7 @@ class LinkCategoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /link_categories/1
|
# GET /link_categories/1
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /link_categories/new
|
# GET /link_categories/new
|
||||||
def new
|
def new
|
||||||
|
|
@ -16,8 +17,7 @@ class LinkCategoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /link_categories/1/edit
|
# GET /link_categories/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /link_categories
|
# POST /link_categories
|
||||||
def create
|
def create
|
||||||
|
|
@ -46,13 +46,14 @@ class LinkCategoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
|
||||||
def set_link_category
|
|
||||||
@link_category = LinkCategory.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
# Only allow a list of trusted parameters through.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def link_category_params
|
def set_link_category
|
||||||
params.require(:link_category).permit(:name, :description, :rich_text)
|
@link_category = LinkCategory.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Only allow a list of trusted parameters through.
|
||||||
|
def link_category_params
|
||||||
|
params.require(:link_category).permit(:name, :description, :rich_text)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class LinksController < ApplicationController
|
class LinksController < ApplicationController
|
||||||
before_action :set_link, only: %i[show edit update destroy]
|
before_action :set_link, only: %i[show edit update destroy]
|
||||||
|
|
||||||
|
|
@ -7,8 +9,7 @@ class LinksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /links/1
|
# GET /links/1
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /links/new
|
# GET /links/new
|
||||||
def new
|
def new
|
||||||
|
|
@ -16,15 +17,14 @@ class LinksController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /links/1/edit
|
# GET /links/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /links
|
# POST /links
|
||||||
def create
|
def create
|
||||||
@link = Link.new(link_params)
|
@link = Link.new(link_params)
|
||||||
|
|
||||||
if @link.save
|
if @link.save
|
||||||
redirect_to @link, notice: 'Link was successfully created.'
|
redirect_to @link, notice: "Link was successfully created."
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +33,7 @@ class LinksController < ApplicationController
|
||||||
# PATCH/PUT /links/1
|
# PATCH/PUT /links/1
|
||||||
def update
|
def update
|
||||||
if @link.update(link_params)
|
if @link.update(link_params)
|
||||||
redirect_to @link, notice: 'Link was successfully updated.', status: :see_other
|
redirect_to @link, notice: "Link was successfully updated.", status: :see_other
|
||||||
else
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -42,7 +42,7 @@ class LinksController < ApplicationController
|
||||||
# DELETE /links/1
|
# DELETE /links/1
|
||||||
def destroy
|
def destroy
|
||||||
@link.destroy!
|
@link.destroy!
|
||||||
redirect_to links_url, notice: 'Link was successfully destroyed.', status: :see_other
|
redirect_to links_url, notice: "Link was successfully destroyed.", status: :see_other
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ReportsController < ApplicationController
|
class ReportsController < ApplicationController
|
||||||
before_action :set_report, only: %i[show edit update destroy work]
|
before_action :set_report, only: %i[show edit update destroy work]
|
||||||
|
|
||||||
|
|
@ -12,26 +14,56 @@ class ReportsController < ApplicationController
|
||||||
format.html
|
format.html
|
||||||
format.pdf
|
format.pdf
|
||||||
format.xlsx do
|
format.xlsx do
|
||||||
response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'xlsx')}")
|
response.headers["Content-Disposition"] = %(attachment; filename="#{filename(@report, extension: 'xlsx')}")
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
format.xml do
|
format.xml do
|
||||||
response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'html')}")
|
response.headers["Content-Disposition"] = %(attachment; filename="#{filename(@report, extension: 'html')}")
|
||||||
render formats: [:odt], layout: false
|
render formats: [ :odt ], layout: false
|
||||||
end
|
end
|
||||||
format.rtf do
|
format.rtf do
|
||||||
html = render_to_string(template: 'reports/show', formats: [:odt],
|
html = render_to_string(template: "reports/show", formats: [ :odt ],
|
||||||
layout: false)
|
layout: false)
|
||||||
rtf = "{\\rtf1\n#{PandocRuby.html(html).to_rtf}}"
|
rtf = "{\\rtf1\n#{PandocRuby.html(html).to_rtf}}"
|
||||||
send_data rtf, filename: filename(@report, extension: 'rtf')
|
send_data rtf, filename: filename(@report, extension: "rtf")
|
||||||
end
|
end
|
||||||
format.odt do
|
format.odt do
|
||||||
html = render_to_string(layout: false)
|
html = render_to_string(layout: false)
|
||||||
odt = PandocRuby.html(html).to_odt
|
odt = PandocRuby.html(html).to_odt
|
||||||
send_data odt, filename: filename(@report, extension: 'odt')
|
send_data odt, filename: filename(@report, extension: "odt")
|
||||||
end
|
end
|
||||||
format.docx do
|
format.docx do
|
||||||
template = Sablon.template(Rails.root.join('lib/templates/docx/report.docx'))
|
send_file(Docx::Document.new.generate do |document|
|
||||||
|
document.heading1(@report.name)
|
||||||
|
document.paragraph(@report.comment_html)
|
||||||
|
# document.heading1("slfkj")
|
||||||
|
# document.paragraph("sldkfj")
|
||||||
|
@report.elements.each do |element|
|
||||||
|
document.heading2(element.title)
|
||||||
|
element.success_criteria.each do |sc|
|
||||||
|
document.heading3(sc.title)
|
||||||
|
document.paragraph(sc.description_html)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, filename: filename(@report, extension: "docx"),
|
||||||
|
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
text = OpenXml::Docx::Elements::Text.new(@report.name)
|
||||||
|
run = OpenXml::Docx::Elements::Run.new
|
||||||
|
run.bold = true
|
||||||
|
run << text
|
||||||
|
paragraph = OpenXml::Docx::Elements::Paragraph.new
|
||||||
|
paragraph << run
|
||||||
|
|
||||||
|
document = OpenXml::Docx::Package.new
|
||||||
|
document.document << paragraph
|
||||||
|
document.save(Rails.root.join("tmp", "output.docx"))
|
||||||
|
send_file Rails.root.join("tmp", "output.docx")
|
||||||
|
return
|
||||||
|
|
||||||
|
template = Sablon.template(Rails.root.join("lib/templates/docx/report.docx"))
|
||||||
context = {
|
context = {
|
||||||
person: OpenStruct.new(first_name: @report.name),
|
person: OpenStruct.new(first_name: @report.name),
|
||||||
skills: [],
|
skills: [],
|
||||||
|
|
@ -40,10 +72,10 @@ class ReportsController < ApplicationController
|
||||||
referees: []
|
referees: []
|
||||||
}
|
}
|
||||||
|
|
||||||
template.render_to_file(Rails.root.join('tmp/output.docx'), context)
|
template.render_to_file(Rails.root.join("tmp/output.docx"), context)
|
||||||
send_file Rails.root.join('tmp/output.docx'),
|
send_file Rails.root.join("tmp/output.docx"),
|
||||||
filename: filename(@report, extension: 'docx'),
|
filename: filename(@report, extension: "docx"),
|
||||||
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -54,15 +86,14 @@ class ReportsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /reports/1/edit
|
# GET /reports/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /reports
|
# POST /reports
|
||||||
def create
|
def create
|
||||||
@report = Report.new(report_params)
|
@report = Report.new(report_params)
|
||||||
|
|
||||||
if @report.save
|
if @report.save
|
||||||
redirect_to @report, notice: 'Report was successfully created.'
|
redirect_to @report, notice: "Report was successfully created."
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -71,7 +102,7 @@ class ReportsController < ApplicationController
|
||||||
# PATCH/PUT /reports/1
|
# PATCH/PUT /reports/1
|
||||||
def update
|
def update
|
||||||
if @report.update(report_params)
|
if @report.update(report_params)
|
||||||
redirect_to @report, notice: 'Report was successfully updated.', status: :see_other
|
redirect_to @report, notice: "Report was successfully updated.", status: :see_other
|
||||||
else
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -80,7 +111,7 @@ class ReportsController < ApplicationController
|
||||||
# DELETE /reports/1
|
# DELETE /reports/1
|
||||||
def destroy
|
def destroy
|
||||||
@report.destroy!
|
@report.destroy!
|
||||||
redirect_to reports_url, notice: 'Report was successfully destroyed.', status: :see_other
|
redirect_to reports_url, notice: "Report was successfully destroyed.", status: :see_other
|
||||||
end
|
end
|
||||||
|
|
||||||
def work
|
def work
|
||||||
|
|
@ -99,7 +130,7 @@ class ReportsController < ApplicationController
|
||||||
params.require(:report).permit(:name, :comment_html)
|
params.require(:report).permit(:name, :comment_html)
|
||||||
end
|
end
|
||||||
|
|
||||||
def filename(report, extension: 'html')
|
def filename(report, extension: "html")
|
||||||
"#{report.name}-#{Time.current.strftime('%Y%m%d%H%M')}.#{extension}"
|
"#{report.name}-#{Time.current.strftime('%Y%m%d%H%M')}.#{extension}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SuccessCriteriaController < ApplicationController
|
class SuccessCriteriaController < ApplicationController
|
||||||
before_action :set_success_criterion, only: %i[show edit update destroy]
|
before_action :set_success_criterion, only: %i[show edit update destroy]
|
||||||
|
|
||||||
|
|
@ -7,8 +9,7 @@ class SuccessCriteriaController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /success_criteria/1
|
# GET /success_criteria/1
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
# GET /success_criteria/new
|
# GET /success_criteria/new
|
||||||
def new
|
def new
|
||||||
|
|
@ -16,15 +17,14 @@ class SuccessCriteriaController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /success_criteria/1/edit
|
# GET /success_criteria/1/edit
|
||||||
def edit
|
def edit; end
|
||||||
end
|
|
||||||
|
|
||||||
# POST /success_criteria
|
# POST /success_criteria
|
||||||
def create
|
def create
|
||||||
@success_criterion = SuccessCriterion.new(success_criterion_params)
|
@success_criterion = SuccessCriterion.new(success_criterion_params)
|
||||||
|
|
||||||
if @success_criterion.save
|
if @success_criterion.save
|
||||||
redirect_to @success_criterion, notice: 'Erfolgskriterium was successfully created.'
|
redirect_to @success_criterion, notice: "Erfolgskriterium was successfully created."
|
||||||
else
|
else
|
||||||
render :new, status: :unprocessable_entity
|
render :new, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -33,7 +33,7 @@ class SuccessCriteriaController < ApplicationController
|
||||||
# PATCH/PUT /success_criteria/1
|
# PATCH/PUT /success_criteria/1
|
||||||
def update
|
def update
|
||||||
if @success_criterion.update(success_criterion_params)
|
if @success_criterion.update(success_criterion_params)
|
||||||
redirect_to @success_criterion, notice: 'Erfolgskriterium was successfully updated.', status: :see_other
|
redirect_to @success_criterion, notice: "Erfolgskriterium was successfully updated.", status: :see_other
|
||||||
else
|
else
|
||||||
render :edit, status: :unprocessable_entity
|
render :edit, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
|
@ -44,7 +44,7 @@ class SuccessCriteriaController < ApplicationController
|
||||||
@success_criterion.destroy!
|
@success_criterion.destroy!
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
redirect_to success_criteria_url, notice: 'Erfolgskriterium was successfully destroyed.', status: :see_other
|
redirect_to success_criteria_url, notice: "Erfolgskriterium was successfully destroyed.", status: :see_other
|
||||||
end
|
end
|
||||||
format.turbo_stream
|
format.turbo_stream
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,16 @@ module ApplicationHelper
|
||||||
include Pagy::Frontend
|
include Pagy::Frontend
|
||||||
|
|
||||||
delegate :filter_params, to: :controller
|
delegate :filter_params, to: :controller
|
||||||
|
|
||||||
|
def multilang_form_field(form, attribute, as: :text_field)
|
||||||
|
col_width = as == :rich_text_area ? 12 : 12 / I18n.available_locales.count
|
||||||
|
tag.div(class: "row") do
|
||||||
|
fields = I18n.available_locales.map { _1.to_s.split("-").first }.map do |lang|
|
||||||
|
tag.div(class: "col-lg-#{col_width}") do
|
||||||
|
form.send(as, "#{attribute}_#{lang}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
safe_join(fields)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ChecklistEntriesHelper
|
module ChecklistEntriesHelper
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ChecklistsHelper
|
module ChecklistsHelper
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ChecksHelper
|
module ChecksHelper
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ElementsHelper
|
module ElementsHelper
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module LinkCategoriesHelper
|
module LinkCategoriesHelper
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module LinksHelper
|
module LinksHelper
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PdfHelper
|
module PdfHelper
|
||||||
def prepare_rich_text(rich_text)
|
def prepare_rich_text(rich_text)
|
||||||
return rich_text
|
return rich_text
|
||||||
|
|
||||||
{ del: 'strikethrough' }.each do |tag, replacement|
|
{ del: "strikethrough" }.each do |tag, replacement|
|
||||||
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
|
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
|
||||||
rich_text = rich_text.to_s.gsub("</#{tag}>", "</#{replacement}>")
|
rich_text = rich_text.to_s.gsub("</#{tag}>", "</#{replacement}>")
|
||||||
end
|
end
|
||||||
|
|
||||||
%w[div p del blockquote pre code].each do |tag|
|
%w[div p del blockquote pre code].each do |tag|
|
||||||
rich_text = rich_text.to_s.gsub(%r{<#{tag}.*?>|</#{tag}>}, '')
|
rich_text = rich_text.to_s.gsub(%r{<#{tag}.*?>|</#{tag}>}, "")
|
||||||
end
|
end
|
||||||
rich_text.gsub!(/<h1.*?>/, '')
|
rich_text.gsub!(/<h1.*?>/, "")
|
||||||
rich_text.gsub!(%r{</h1>}, '<br><br>')
|
rich_text.gsub!(%r{</h1>}, "<br><br>")
|
||||||
rich_text
|
rich_text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ReportsHelper
|
module ReportsHelper
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module SuccessCriteriaHelper
|
module SuccessCriteriaHelper
|
||||||
def success_criterion_result_icon_classes(sc)
|
def success_criterion_result_icon_classes(sc)
|
||||||
if sc.passed?
|
if sc.passed?
|
||||||
'bi bi-check text-success'
|
"bi bi-check text-success"
|
||||||
elsif sc.failed?
|
elsif sc.failed?
|
||||||
'bi bi-exclamation-lg text-danger'
|
"bi bi-exclamation-lg text-danger"
|
||||||
elsif sc.not_applicable?
|
elsif sc.not_applicable?
|
||||||
'bi bi-dash text-muted'
|
"bi bi-dash text-muted"
|
||||||
else
|
else
|
||||||
'bi bi-question text-warning'
|
"bi bi-question text-warning"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -16,13 +18,13 @@ module SuccessCriteriaHelper
|
||||||
if edit_mode
|
if edit_mode
|
||||||
success_criterion
|
success_criterion
|
||||||
else
|
else
|
||||||
[:edit,
|
[ :edit,
|
||||||
success_criterion]
|
success_criterion ]
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
success_criterion.element
|
success_criterion.element
|
||||||
end
|
end
|
||||||
link_to tag.i(class: 'bi bi-pencil'),
|
link_to tag.i(class: "bi bi-pencil"),
|
||||||
path,
|
path,
|
||||||
class: "btn btn-#{edit_mode ? 'link text-warning' : 'link text-secondary'}"
|
class: "btn btn-#{edit_mode ? 'link text-warning' : 'link text-secondary'}"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@ import * as bootstrap from "bootstrap"
|
||||||
|
|
||||||
import "trix"
|
import "trix"
|
||||||
import "@rails/actiontext"
|
import "@rails/actiontext"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,4 @@ application.register("set-theme", SetThemeController)
|
||||||
|
|
||||||
import ThemeSwitcherController from "./theme_switcher_controller"
|
import ThemeSwitcherController from "./theme_switcher_controller"
|
||||||
application.register("theme-switcher", ThemeSwitcherController)
|
application.register("theme-switcher", ThemeSwitcherController)
|
||||||
|
|
||||||
|
|
|
||||||
133
app/lib/docx/document.rb
Normal file
133
app/lib/docx/document.rb
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
module Docx
|
||||||
|
class Document
|
||||||
|
include OpenXml::Docx::Elements
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate
|
||||||
|
yield(self)
|
||||||
|
|
||||||
|
tmpfile = Tempfile.new("#{Time.current.to_f}.xlsx", Rails.root.join("tmp"))
|
||||||
|
_document.save(tmpfile.path)
|
||||||
|
tmpfile.path
|
||||||
|
end
|
||||||
|
|
||||||
|
def heading1(text)
|
||||||
|
paragraph = create_paragraph(text)
|
||||||
|
paragraph.paragraph_style = "Heading 1"
|
||||||
|
_document.document << paragraph
|
||||||
|
end
|
||||||
|
|
||||||
|
def heading2(text)
|
||||||
|
paragraph = create_paragraph(text)
|
||||||
|
paragraph.paragraph_style = "Heading 2"
|
||||||
|
_document.document << paragraph
|
||||||
|
end
|
||||||
|
|
||||||
|
def heading3(text)
|
||||||
|
paragraph = create_paragraph(text)
|
||||||
|
paragraph.paragraph_style = "Heading 3"
|
||||||
|
_document.document << paragraph
|
||||||
|
end
|
||||||
|
|
||||||
|
def paragraph(text)
|
||||||
|
html = Nokogiri::HTML5.fragment(text)
|
||||||
|
html.search(".trix-content").each do |node|
|
||||||
|
node.children.each do |child|
|
||||||
|
Rails.logger.debug { "content kids: #{child.class}: #{child.name} (#{child.children.size}): #{child.text}" }
|
||||||
|
case child
|
||||||
|
when Nokogiri::XML::Text
|
||||||
|
paragraph = create_paragraph(child.text)
|
||||||
|
_document.document << paragraph
|
||||||
|
when Nokogiri::XML::Element
|
||||||
|
case child.name
|
||||||
|
when "h1"
|
||||||
|
paragraph = create_paragraph(child.text)
|
||||||
|
paragraph.paragraph_style = "Heading 3"
|
||||||
|
when "div"
|
||||||
|
paragraph = Paragraph.new
|
||||||
|
paragraph.paragraph_style = "Body Text"
|
||||||
|
child.children.each do |node|
|
||||||
|
Rails.logger.debug { "div kids: #{node.class}: #{node.name} (#{node.children.size}): #{node.text}" }
|
||||||
|
case node.name
|
||||||
|
when "strong"
|
||||||
|
paragraph << create_run(node.text, bold: true)
|
||||||
|
when "em"
|
||||||
|
paragraph << create_run(node.text, italic: true)
|
||||||
|
when "del"
|
||||||
|
paragraph << create_run(node.text, strike_through: true)
|
||||||
|
when "br"
|
||||||
|
paragraph << create_run("\n")
|
||||||
|
else
|
||||||
|
paragraph << create_run(node.text)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
when "ul"
|
||||||
|
# paragraph = Paragraph.new
|
||||||
|
# paragraph.paragraph_style = "Body Text"
|
||||||
|
# # Create an abstract numbering that describes a bulleted list:
|
||||||
|
# abstract_numbering = AbstractNumbering.new(0)
|
||||||
|
|
||||||
|
# # Each numbering can have multiple levels. Define the first level as a bulleted list:
|
||||||
|
# level_0 = Level.new
|
||||||
|
# level_0.level = 0
|
||||||
|
# level_0.start = 1
|
||||||
|
# level_0.number_format = :bullet
|
||||||
|
# # This is the default bullet Word uses
|
||||||
|
# level_0.level_text = "\u00B7".encode("UTF-8")
|
||||||
|
# level_0.alignment = :left
|
||||||
|
# level_0.character_style.font.ascii = "Symbol"
|
||||||
|
# level_0.character_style.font.high_ansi = "Symbol"
|
||||||
|
# level_0.character_style.font.hint = :default
|
||||||
|
# level_0.paragraph_style.indentation.left = 720
|
||||||
|
# level_0.paragraph_style.indentation.hanging = 360
|
||||||
|
# abstract_numbering << level_0
|
||||||
|
|
||||||
|
# _document.numbering << abstract_numbering
|
||||||
|
when "ol"
|
||||||
|
else
|
||||||
|
paragraph = create_paragraph(child.text)
|
||||||
|
paragraph.paragraph_style = "Body Text"
|
||||||
|
end
|
||||||
|
|
||||||
|
_document.document << paragraph
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def create_run(content, bold: false, italic: false, strike_through: false)
|
||||||
|
text = Text.new(content)
|
||||||
|
text.space = :preserve
|
||||||
|
run = Run.new
|
||||||
|
run.bold = bold
|
||||||
|
run.italics = italic
|
||||||
|
run.strikethrough = strike_through
|
||||||
|
run << text
|
||||||
|
run
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_paragraph(content)
|
||||||
|
text = case content
|
||||||
|
when String
|
||||||
|
Text.new(content)
|
||||||
|
when ActionText::RichText
|
||||||
|
Text.new(content.to_plain_text)
|
||||||
|
else
|
||||||
|
Text.new(content.to_s)
|
||||||
|
end
|
||||||
|
run = Run.new
|
||||||
|
run << text
|
||||||
|
paragraph = Paragraph.new
|
||||||
|
paragraph << run
|
||||||
|
paragraph
|
||||||
|
end
|
||||||
|
|
||||||
|
def _document
|
||||||
|
@_document ||= OpenXml::Docx::Package.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module LinkChecker
|
module LinkChecker
|
||||||
UA = "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0"
|
UA = "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0"
|
||||||
module_function def http(input)
|
|
||||||
response = Net::HTTP.get_response(URI.parse(input), {"User-Agent": UA})
|
module_function
|
||||||
|
|
||||||
|
def http(input)
|
||||||
|
response = Net::HTTP.get_response(URI.parse(input), { 'User-Agent': UA })
|
||||||
# debugger
|
# debugger
|
||||||
case response
|
case response
|
||||||
when Net::HTTPSuccess
|
when Net::HTTPSuccess
|
||||||
|
|
@ -13,4 +18,3 @@ module LinkChecker
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
default from: 'from@example.com'
|
default from: "from@example.com"
|
||||||
layout 'mailer'
|
layout "mailer"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module ActionText
|
module ActionText
|
||||||
class RichText < Record
|
class RichText < Record
|
||||||
before_save do
|
before_save do
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Admin
|
module Admin
|
||||||
class Backup
|
class Backup
|
||||||
class << self
|
class << self
|
||||||
def zip
|
def zip
|
||||||
create_records_xlsx
|
create_records_xlsx
|
||||||
|
|
||||||
ZipFileGenerator.new(Rails.root.join('storage')).write
|
ZipFileGenerator.new(Rails.root.join("storage")).write
|
||||||
end
|
end
|
||||||
|
|
||||||
def db_xlsx
|
def db_xlsx
|
||||||
|
|
@ -21,7 +23,7 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
path = Rails.root.join('storage/data.xls')
|
path = Rails.root.join("storage/data.xls")
|
||||||
xlsx.serialize(path)
|
xlsx.serialize(path)
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
@ -29,7 +31,7 @@ module Admin
|
||||||
private
|
private
|
||||||
|
|
||||||
def file_path(name)
|
def file_path(name)
|
||||||
Rails.root.join('storage', name)
|
Rails.root.join("storage", name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -53,9 +55,9 @@ module Admin
|
||||||
# Zip the input directory.
|
# Zip the input directory.
|
||||||
def write
|
def write
|
||||||
entries = Dir.entries(@input_dir) - %w[. ..]
|
entries = Dir.entries(@input_dir) - %w[. ..]
|
||||||
path = Rails.root.join('tmp', Time.now.to_i.to_s)
|
path = Rails.root.join("tmp", Time.now.to_i.to_s)
|
||||||
::Zip::File.open(path, create: true) do |zipfile|
|
::Zip::File.open(path, create: true) do |zipfile|
|
||||||
write_entries entries, '', zipfile
|
write_entries entries, "", zipfile
|
||||||
end
|
end
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
|
@ -65,7 +67,7 @@ module Admin
|
||||||
# A helper method to make the recursion work.
|
# A helper method to make the recursion work.
|
||||||
def write_entries(entries, path, zipfile)
|
def write_entries(entries, path, zipfile)
|
||||||
entries.each do |e|
|
entries.each do |e|
|
||||||
zipfile_path = path == '' ? e : File.join(path, e)
|
zipfile_path = path == "" ? e : File.join(path, e)
|
||||||
disk_file_path = File.join(@input_dir, zipfile_path)
|
disk_file_path = File.join(@input_dir, zipfile_path)
|
||||||
|
|
||||||
if File.directory? disk_file_path
|
if File.directory? disk_file_path
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,17 @@
|
||||||
|
|
||||||
class ApplicationRecord < ActiveRecord::Base
|
class ApplicationRecord < ActiveRecord::Base
|
||||||
primary_abstract_class
|
primary_abstract_class
|
||||||
|
|
||||||
|
class << self
|
||||||
|
def translates_attributes(*attributes)
|
||||||
|
attributes.each do |attribute|
|
||||||
|
define_method("t_#{attribute}") do
|
||||||
|
lang = I18n.locale.to_s.split("-").first
|
||||||
|
send("#{attribute}_#{lang}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
alias_method :translates_attribute, :translates_attributes
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,67 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Check < ApplicationRecord
|
class Check < ApplicationRecord
|
||||||
include RichTextTargetBlank
|
include RichTextTargetBlank
|
||||||
|
|
||||||
enum :level, %i[A AA AAA]
|
belongs_to :principle
|
||||||
|
|
||||||
has_rich_text :success_criterion_html
|
has_and_belongs_to_many :links
|
||||||
|
has_and_belongs_to_many :standards
|
||||||
|
|
||||||
scope :search, lambda { |term|
|
accepts_nested_attributes_for :links, allow_destroy: true
|
||||||
joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where('checks.name LIKE :term OR action_text_rich_texts.body_text LIKE :term', term: "%#{term}%")
|
|
||||||
}
|
enum :conformity_level, %i[A AA AAA]
|
||||||
|
enum :priority, %i[highest high normal low]
|
||||||
|
|
||||||
|
has_rich_text :conformity_notice_de
|
||||||
|
has_rich_text :conformity_notice_en
|
||||||
|
has_rich_text :quick_criterion_de
|
||||||
|
has_rich_text :quick_criterion_en
|
||||||
|
has_rich_text :quick_fail_de
|
||||||
|
has_rich_text :quick_fail_en
|
||||||
|
has_rich_text :quick_fix_de
|
||||||
|
has_rich_text :quick_fix_en
|
||||||
|
|
||||||
|
has_rich_text :criterion_de
|
||||||
|
has_rich_text :criterion_en
|
||||||
|
has_rich_text :criterion_details_de
|
||||||
|
has_rich_text :criterion_details_en
|
||||||
|
has_rich_text :example_de
|
||||||
|
has_rich_text :example_en
|
||||||
|
has_rich_text :exemption_details_de
|
||||||
|
has_rich_text :exemption_details_en
|
||||||
|
has_rich_text :standard_text_de
|
||||||
|
has_rich_text :standard_text_en
|
||||||
|
|
||||||
|
has_rich_text :test_instructions
|
||||||
|
|
||||||
|
has_rich_text :powerpoint_text_de
|
||||||
|
has_rich_text :powerpoint_text_en
|
||||||
|
|
||||||
|
has_rich_text :comment
|
||||||
|
|
||||||
|
translates_attributes :name,
|
||||||
|
:conformity_notice,
|
||||||
|
:quick_criterion,
|
||||||
|
:quick_fail,
|
||||||
|
:quick_fix,
|
||||||
|
:criterion,
|
||||||
|
:criterion_details,
|
||||||
|
:example,
|
||||||
|
:exemption_details,
|
||||||
|
:standard_text,
|
||||||
|
:powerpoint_text
|
||||||
|
|
||||||
|
scope(:search, lambda do |term|
|
||||||
|
# TODO: Search only fields for current locale.
|
||||||
|
joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where("checks.name_de LIKE :term OR checks.name_de LIKE :term OR action_text_rich_texts.body LIKE :term", term: "%#{term}%").distinct
|
||||||
|
end)
|
||||||
|
|
||||||
|
def display_target_disabilities
|
||||||
|
%i[visual auditory physical cognitive].select { |d| send(:"#{d}?") }.map { |d| I18n.t("disability.#{d}") }.map(&:first).join(", ")
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_applicabilities
|
||||||
|
%i[applicable_to_app applicable_to_web].select { |a| send(:"#{a}?") }.map { |a| I18n.t("applicability.#{a}") }.map(&:first).join(", ")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Checklist < ApplicationRecord
|
class Checklist < ApplicationRecord
|
||||||
has_many :checklist_entries, -> { order(position: :asc) }, dependent: :destroy, inverse_of: :checklist
|
has_many :checklist_entries, -> { order(position: :asc) }, dependent: :destroy, inverse_of: :checklist
|
||||||
has_many :checks, through: :checklist_entries
|
has_many :checks, through: :checklist_entries
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ChecklistEntry < ApplicationRecord
|
class ChecklistEntry < ApplicationRecord
|
||||||
belongs_to :checklist
|
belongs_to :checklist
|
||||||
belongs_to :check
|
belongs_to :check
|
||||||
|
|
||||||
before_validation :set_position
|
before_validation :set_position
|
||||||
after_validation :normalize_positions
|
before_create :update_positions
|
||||||
|
before_update :update_positions, if: :position_changed?
|
||||||
|
|
||||||
def set_position
|
def set_position
|
||||||
self.position ||= checklist.checklist_entries.maximum(:position).to_i + 1
|
self.position ||= (checklist.checklist_entries.pluck(:position).max || 0) + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize_positions
|
def normalize_positions
|
||||||
|
|
@ -15,4 +18,11 @@ class ChecklistEntry < ApplicationRecord
|
||||||
# entry.update_column(:position, index + 1) if entry.position != index + 1
|
# entry.update_column(:position, index + 1) if entry.position != index + 1
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_positions
|
||||||
|
if position_was
|
||||||
|
checklist.checklist_entries.where("position > ?", position_was).update_all("position = position - 1")
|
||||||
|
end
|
||||||
|
checklist.checklist_entries.where(position: position..).update_all("position = position + 1")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module RichTextTargetBlank
|
module RichTextTargetBlank
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
|
@ -11,7 +13,7 @@ module RichTextTargetBlank
|
||||||
rich_text_attribute = send(name)
|
rich_text_attribute = send(name)
|
||||||
if rich_text_attribute.present?
|
if rich_text_attribute.present?
|
||||||
doc = Nokogiri::HTML::DocumentFragment.parse(rich_text_attribute.body.to_html)
|
doc = Nokogiri::HTML::DocumentFragment.parse(rich_text_attribute.body.to_html)
|
||||||
doc.css('a').each { |a| a['target'] ||= '_blank' }
|
doc.css("a").each { |a| a["target"] ||= "_blank" }
|
||||||
rich_text_attribute.body = doc.to_html
|
rich_text_attribute.body = doc.to_html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Element < ApplicationRecord
|
class Element < ApplicationRecord
|
||||||
attr_accessor :checklist_id
|
attr_accessor :checklist_id
|
||||||
|
|
||||||
|
|
@ -22,8 +24,8 @@ class Element < ApplicationRecord
|
||||||
|
|
||||||
return nil if possible_levels.empty?
|
return nil if possible_levels.empty?
|
||||||
|
|
||||||
puts possible_levels.inspect
|
Rails.logger.debug possible_levels.inspect
|
||||||
puts min_failed
|
Rails.logger.debug min_failed
|
||||||
possible_levels[possible_levels.find_index(min_failed) - 1]
|
possible_levels[possible_levels.find_index(min_failed) - 1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
require 'net/http'
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "net/http"
|
||||||
|
|
||||||
class Link < ApplicationRecord
|
class Link < ApplicationRecord
|
||||||
belongs_to :link_category
|
belongs_to :link_category
|
||||||
|
has_and_belongs_to_many :checks
|
||||||
|
|
||||||
has_rich_text :description_html
|
has_rich_text :description_html
|
||||||
|
|
||||||
validates :url, :text, presence: true
|
validates :url, :text, presence: true
|
||||||
|
|
@ -10,13 +14,21 @@ class Link < ApplicationRecord
|
||||||
|
|
||||||
before_validation :ensure_absolute_url
|
before_validation :ensure_absolute_url
|
||||||
|
|
||||||
|
def t_text
|
||||||
|
text
|
||||||
|
end
|
||||||
|
|
||||||
def ok?
|
def ok?
|
||||||
fail_count == 0
|
fail_count.zero?
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"#{text} (#{url})"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0'
|
USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"
|
||||||
|
|
||||||
def check_url(input = url, add_error = true)
|
def check_url(input = url, add_error = true)
|
||||||
response = begin
|
response = begin
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class LinkCategory < ApplicationRecord
|
class LinkCategory < ApplicationRecord
|
||||||
has_many :links
|
has_many :links
|
||||||
|
|
||||||
has_rich_text :description_html
|
has_rich_text :description
|
||||||
|
|
||||||
|
def t_name
|
||||||
|
name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PdfDocuments
|
module PdfDocuments
|
||||||
class Base
|
class Base
|
||||||
attr_reader :params
|
attr_reader :params
|
||||||
|
|
@ -11,7 +13,7 @@ module PdfDocuments
|
||||||
# exta_bold: 'vendor/assets/fonts/Lexend-ExtraBold.ttf',
|
# exta_bold: 'vendor/assets/fonts/Lexend-ExtraBold.ttf',
|
||||||
# italic: 'vendor/assets/fonts/Lexend-Regular.ttf'
|
# italic: 'vendor/assets/fonts/Lexend-Regular.ttf'
|
||||||
# })
|
# })
|
||||||
@prawn_document.font 'Helvetica', size: 12
|
@prawn_document.font "Helvetica", size: 12
|
||||||
@params = OpenStruct.new(params)
|
@params = OpenStruct.new(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -47,7 +49,7 @@ module PdfDocuments
|
||||||
end
|
end
|
||||||
|
|
||||||
def hr
|
def hr
|
||||||
@prawn_document.markup '<hr>'
|
@prawn_document.markup "<hr>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def markup_options
|
def markup_options
|
||||||
|
|
@ -63,12 +65,12 @@ module PdfDocuments
|
||||||
end
|
end
|
||||||
|
|
||||||
def logo
|
def logo
|
||||||
@prawn_document.image 'app/assets/images/logo-apfelschule.png', width: 150
|
@prawn_document.image "app/assets/images/logo-apfelschule.png", width: 150
|
||||||
@prawn_document.move_down 30
|
@prawn_document.move_down 30
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_rich_text(rich_text)
|
def prepare_rich_text(rich_text)
|
||||||
{ h1: 'h4' }.each do |tag, replacement|
|
{ h1: "h4" }.each do |tag, replacement|
|
||||||
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
|
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
|
||||||
rich_text = rich_text.to_s.gsub("</#{tag}>", "</#{replacement}>")
|
rich_text = rich_text.to_s.gsub("</#{tag}>", "</#{replacement}>")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,21 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module PdfDocuments
|
module PdfDocuments
|
||||||
class CustomerReport < Base
|
class CustomerReport < Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate
|
def generate
|
||||||
logo
|
logo
|
||||||
@prawn_document.formatted_text_box [{
|
@prawn_document.formatted_text_box [ {
|
||||||
text: "Dieses Dokument wurd am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')} erstellt.", size: 8, align: :right
|
text: "Dieses Dokument wurd am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')} erstellt.", size: 8, align: :right
|
||||||
}], align: :right
|
} ], align: :right
|
||||||
|
|
||||||
heading1 params.report.name
|
heading1 params.report.name
|
||||||
rich_text params.report.comment_html
|
rich_text params.report.comment_html
|
||||||
|
|
||||||
params.report.elements.each.with_index(1) do |element, element_index|
|
params.report.elements.each.with_index(1) do |element, element_index|
|
||||||
heading2 "#{element_index} #{element.title}"
|
heading2 "#{element_index} #{element.title}"
|
||||||
formatted_text [{ text: element.path, styles: %i[bold italic underline] }]
|
formatted_text [ { text: element.path, styles: %i[bold italic underline] } ]
|
||||||
move_down(5)
|
move_down(5)
|
||||||
rich_text element.description_html
|
rich_text element.description_html
|
||||||
|
|
||||||
|
|
|
||||||
3
app/models/principle.rb
Normal file
3
app/models/principle.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
class Principle < ApplicationRecord
|
||||||
|
translates_attribute :name
|
||||||
|
end
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Report < ApplicationRecord
|
class Report < ApplicationRecord
|
||||||
has_rich_text :comment_html
|
has_rich_text :comment_html
|
||||||
|
|
||||||
|
|
|
||||||
5
app/models/standard.rb
Normal file
5
app/models/standard.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class Standard < ApplicationRecord
|
||||||
|
has_and_belongs_to_many :checks
|
||||||
|
|
||||||
|
translates_attribute :name
|
||||||
|
end
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class SuccessCriterion < ApplicationRecord
|
class SuccessCriterion < ApplicationRecord
|
||||||
enum :result, %i[passed failed not_applicable]
|
enum :result, %i[passed failed not_applicable]
|
||||||
enum :level, %i[A AA AAA]
|
enum :level, %i[A AA AAA]
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! checklist_entry, :id, :checklist_id, :check_id, :position, :created_at, :updated_at
|
json.extract! checklist_entry, :id, :checklist_id, :check_id, :position, :created_at, :updated_at
|
||||||
json.url checklist_entry_url(checklist_entry, format: :json)
|
json.url checklist_entry_url(checklist_entry, format: :json)
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @checklist_entries, partial: "checklist_entries/checklist_entry", as: :checklist_entry
|
json.array! @checklist_entries, partial: "checklist_entries/checklist_entry", as: :checklist_entry
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "checklist_entries/checklist_entry", checklist_entry: @checklist_entry
|
json.partial! "checklist_entries/checklist_entry", checklist_entry: @checklist_entry
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! checklist, :id, :code, :name, :description_html, :created_at, :updated_at
|
json.extract! checklist, :id, :code, :name, :description_html, :created_at, :updated_at
|
||||||
json.url checklist_url(checklist, format: :json)
|
json.url checklist_url(checklist, format: :json)
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @checklists, partial: "checklists/checklist", as: :checklist
|
json.array! @checklists, partial: "checklists/checklist", as: :checklist
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "checklists/checklist", checklist: @checklist
|
json.partial! "checklists/checklist", checklist: @checklist
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
<div id="<%= dom_id check %>">
|
|
||||||
<p>
|
|
||||||
<strong><%= Check.human_attribute_name(:position) %>:</strong>
|
|
||||||
<%= check.position %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<strong><%= Check.human_attribute_name(:name) %>:</strong>
|
|
||||||
<%= check.name %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<strong><%= Check.human_attribute_name(:success_criterion_html) %>:</strong>
|
|
||||||
<%= check.success_criterion_html %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<strong><%= Check.human_attribute_name(:level) %>:</strong>
|
|
||||||
<%= check.level %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
68
app/views/checks/_check.html.slim
Normal file
68
app/views/checks/_check.html.slim
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
div id=dom_id(check)
|
||||||
|
table.table
|
||||||
|
tbody
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:id)
|
||||||
|
td = check.id
|
||||||
|
tr
|
||||||
|
th = Principle.model_name.human
|
||||||
|
td = check.principle&.t_name
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:number)
|
||||||
|
td = check.number
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:name)
|
||||||
|
td = check.t_name
|
||||||
|
tr
|
||||||
|
th = Standard.model_name.human(count: check.standard_ids.size)
|
||||||
|
td = check.standards.map(&:t_name).join(", ")
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:target_disabilities)
|
||||||
|
td = check.display_target_disabilities
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:applicabilities)
|
||||||
|
td = check.display_applicabilities
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:external_number)
|
||||||
|
td = check.external_number
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:conformity_level)
|
||||||
|
td = check.conformity_level
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:conformity_notice_de)
|
||||||
|
td = check.conformity_notice_de
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:conformity_notice_en)
|
||||||
|
td = check.conformity_notice_en
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:priority)
|
||||||
|
td = check.priority
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:quick_criterion_de)
|
||||||
|
td = check.quick_criterion_de
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:quick_criterion_en)
|
||||||
|
td = check.quick_criterion_en
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:quick_fail_de)
|
||||||
|
td = check.quick_fail_de
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:quick_fail_en)
|
||||||
|
td = check.quick_fail_en
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:quick_fix_de)
|
||||||
|
td = check.quick_fix_de
|
||||||
|
tr
|
||||||
|
th = Check.human_attribute_name(:quick_fix_en)
|
||||||
|
td = check.quick_fix_en
|
||||||
|
tr
|
||||||
|
th = Link.model_name.human(count: check.links.size)
|
||||||
|
td
|
||||||
|
.row
|
||||||
|
.col
|
||||||
|
- check.links.map(&:link_category).uniq.each do |category|
|
||||||
|
span = category.name
|
||||||
|
ul
|
||||||
|
- check.links.select{ _1.link_category == category }.map { |link| link_to link.text, link.url, target: :_blank }.each do |link|
|
||||||
|
li = link
|
||||||
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! check, :id, :position, :name, :success_criterion_html, :level, :created_at, :updated_at
|
json.extract! check, :id, :position, :name, :success_criterion_html, :level, :created_at, :updated_at
|
||||||
json.url check_url(check, format: :json)
|
json.url check_url(check, format: :json)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
<%= bootstrap_form_with(model: check, remote: true) do |form| %>
|
|
||||||
<%= form.text_field :position %>
|
|
||||||
<%= form.text_field :name %>
|
|
||||||
<%= form.rich_text_area :success_criterion_html %>
|
|
||||||
<%= form.select :level, Check.levels.keys, add_blank: !form.object.level.present? %>
|
|
||||||
<%= form.submit %>
|
|
||||||
<% end %>
|
|
||||||
53
app/views/checks/_form.html.slim
Normal file
53
app/views/checks/_form.html.slim
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
= bootstrap_form_with(model: check, remote: true) do |form|
|
||||||
|
h2 Details
|
||||||
|
= form.collection_select :principle_id, Principle.all.sort_by(&:t_name), :id, :t_name
|
||||||
|
= form.text_field :number
|
||||||
|
= multilang_form_field(form, :name)
|
||||||
|
= form.collection_check_boxes :standard_ids, Standard.all.sort_by(&:t_name), :id, :t_name, include_blank: true
|
||||||
|
h2 Zugänglichkeit
|
||||||
|
.row
|
||||||
|
.col-md-3
|
||||||
|
= form.check_box :visual, label: t("disability.visual").capitalize
|
||||||
|
.col-md-3
|
||||||
|
= form.check_box :auditory, label: t("disability.auditory").capitalize
|
||||||
|
.col-md-3
|
||||||
|
= form.check_box :physical, label: t("disability.physical").capitalize
|
||||||
|
.col-md-3
|
||||||
|
= form.check_box :cognitive, label: t("disability.cognitive").capitalize
|
||||||
|
h2 Anwendbarkeit
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
= form.check_box :applicable_to_web, label: t("applicability.applicable_to_web").capitalize
|
||||||
|
.col-md-6
|
||||||
|
= form.check_box :applicable_to_app, label: t("applicability.applicable_to_app").capitalize
|
||||||
|
h2 Richtlinie
|
||||||
|
= form.text_field :external_number
|
||||||
|
= form.select :conformity_level, Check.conformity_levels.keys, include_blank: true
|
||||||
|
= multilang_form_field(form, :conformity_notice, as: :rich_text_area)
|
||||||
|
|
||||||
|
= form.select :priority, Check.priorities.keys.map{ [t("priority.#{_1}"), _1] }, include_blank: true
|
||||||
|
h2 Quick Infos
|
||||||
|
= multilang_form_field(form, :quick_criterion, as: :rich_text_area)
|
||||||
|
= multilang_form_field(form, :quick_fail, as: :rich_text_area)
|
||||||
|
= multilang_form_field(form, :quick_fix, as: :rich_text_area)
|
||||||
|
|
||||||
|
h2 Regular-Kriterium
|
||||||
|
= multilang_form_field(form, :criterion, as: :rich_text_area)
|
||||||
|
= multilang_form_field(form, :criterion_details, as: :rich_text_area)
|
||||||
|
= multilang_form_field(form, :example, as: :rich_text_area)
|
||||||
|
= multilang_form_field(form, :exemption_details, as: :rich_text_area)
|
||||||
|
= multilang_form_field(form, :standard_text, as: :rich_text_area)
|
||||||
|
|
||||||
|
h2 Intern
|
||||||
|
= form.rich_text_area :test_instructions
|
||||||
|
= multilang_form_field(form, :powerpoint_text, as: :rich_text_area)
|
||||||
|
= form.rich_text_area :comment
|
||||||
|
|
||||||
|
h2 Links
|
||||||
|
- LinkCategory.all.sort_by(&:t_name).each do |c|
|
||||||
|
h3 = c.t_name
|
||||||
|
= form.collection_check_boxes(:link_ids, c.links.sort_by(&:t_text), :id, :to_s, hide_label: true)
|
||||||
|
/ = form.collection_check_boxes :link_ids, Link.all.sort_by(&:text), :id, :to_s
|
||||||
|
|
||||||
|
/ = form.rich_text_area :success_criterion_de
|
||||||
|
= form.submit
|
||||||
|
|
@ -15,18 +15,24 @@
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= Check.human_attribute_name(:id) %></th>
|
<th><%= Check.human_attribute_name(:number) %></th>
|
||||||
<th><%= Check.human_attribute_name(:level) %></th>
|
|
||||||
<th><%= Check.human_attribute_name(:name) %></th>
|
<th><%= Check.human_attribute_name(:name) %></th>
|
||||||
<th><%= Check.human_attribute_name(:success_criterion_html) %></th>
|
<th><%= Check.human_attribute_name(:standards) %></th>
|
||||||
|
<th><%= t("checks.target_disabilities") %></th>
|
||||||
|
<th><%= t("checks.applicability") %></th>
|
||||||
|
<th><%= Check.human_attribute_name(:external_number) %></th>
|
||||||
|
<th><%= Check.human_attribute_name(:conformity_level) %></th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @checks.each do |check| %>
|
<% @checks.each do |check| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= check.id %></td>
|
<td><%= check.number %></td>
|
||||||
<td><%= check.level %></td>
|
<td><%= check.t_name %></td>
|
||||||
<td><%= link_to(check.name, url_for(check)) %></td>
|
<td><%= check.standards.map(&:t_name).join(", ") %></td>
|
||||||
<td><%= link_to(truncate(strip_tags(check.success_criterion_html.to_s)), url_for(check)) %></td>
|
<td><%= check.display_target_disabilities %></td>
|
||||||
|
<td><%= check.t_name %></td>
|
||||||
|
<td><%= check.t_name %></td>
|
||||||
|
<td><%= link_to(check.t_name, url_for(check)) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
51
app/views/checks/index.html.slim
Normal file
51
app/views/checks/index.html.slim
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
h1
|
||||||
|
= t("scaffold.pagetitle_index", model: Check.model_name.human(count: 2))
|
||||||
|
= bootstrap_form_with(url: checks_path(page: params[:page]), method: :get, scope: :filter) do |form|
|
||||||
|
= form.hidden_field :page, value: params[:page] if params[:page]
|
||||||
|
.row
|
||||||
|
.col-md-3
|
||||||
|
= form.text_field(:s, placeholder: "suchen...", hide_label: true, value: filter_params[:s])
|
||||||
|
.col
|
||||||
|
= form.submit name: "", value: "Suchen"
|
||||||
|
= link_to "Filter löschen", checks_path, class: "btn btn-outline-secondary ms-3" if filter_params[:s]
|
||||||
|
table.table.table-striped
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
th ID
|
||||||
|
th
|
||||||
|
= Check.human_attribute_name(:number)
|
||||||
|
th
|
||||||
|
= Check.human_attribute_name(:name)
|
||||||
|
th
|
||||||
|
= Check.human_attribute_name(:standard_ids)
|
||||||
|
th
|
||||||
|
= Check.human_attribute_name(:target_disability)
|
||||||
|
th
|
||||||
|
= Check.human_attribute_name(:applicability)
|
||||||
|
th
|
||||||
|
= Check.human_attribute_name(:external_number)
|
||||||
|
th
|
||||||
|
= Check.human_attribute_name(:conformity_level)
|
||||||
|
tbody
|
||||||
|
- @checks.each do |check|
|
||||||
|
tr
|
||||||
|
td = link_to check.id, check
|
||||||
|
td
|
||||||
|
= link_to(check.number, check)
|
||||||
|
td
|
||||||
|
= link_to check.t_name&.truncate(64), check
|
||||||
|
td
|
||||||
|
= link_to check.standards.map(&:t_name).join(", "), check
|
||||||
|
td
|
||||||
|
= link_to check.display_target_disabilities, check
|
||||||
|
td
|
||||||
|
= link_to check.display_applicabilities, check
|
||||||
|
td
|
||||||
|
= link_to check.external_number, check
|
||||||
|
td
|
||||||
|
= link_to check.conformity_level, check
|
||||||
|
.my-3
|
||||||
|
== pagy_info(@pagy)
|
||||||
|
== pagy_bootstrap_nav(@pagy)
|
||||||
|
.action-row
|
||||||
|
= link_to t("scaffold.link_new", model: Check.model_name.human), new_check_path
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @checks, partial: "checks/check", as: :check
|
json.array! @checks, partial: "checks/check", as: :check
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<h1><%= t("scaffold.pagetitle_show", model: @check.class.model_name.human) %></h1>
|
<h1><%= @check.t_name %></h1>
|
||||||
|
|
||||||
<%= render @check %>
|
<%= render @check %>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "checks/check", check: @check
|
json.partial! "checks/check", check: @check
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! element, :id, :report_id, :path, :title, :description_html, :created_at, :updated_at
|
json.extract! element, :id, :report_id, :path, :title, :description_html, :created_at, :updated_at
|
||||||
json.url element_url(element, format: :json)
|
json.url element_url(element, format: :json)
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @elements, partial: "elements/element", as: :element
|
json.array! @elements, partial: "elements/element", as: :element
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "elements/element", element: @element
|
json.partial! "elements/element", element: @element
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html <%== cookies[:"modeTheme"] && "data-bs-theme=\"#{cookies[:"modeTheme"]}\"" %> data-controller="set-theme">
|
<html data-bs-theme="<%= cookies[:"modeTheme"] || "light" %>" data-controller="set-theme">
|
||||||
<head>
|
<head>
|
||||||
<title>a11ydive</title>
|
<title>a11ydive</title>
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Description:</strong>
|
<strong>Description:</strong>
|
||||||
<%= link_category.description_html %>
|
<%= link_category.description %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! link_category, :id, :name, :description, :rich_text, :created_at, :updated_at
|
json.extract! link_category, :id, :name, :description, :rich_text, :created_at, :updated_at
|
||||||
json.url link_category_url(link_category, format: :json)
|
json.url link_category_url(link_category, format: :json)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<td><%= link_to(link_category.name, url_for(link_category)) %></td>
|
<td><%= link_to(link_category.name, url_for(link_category)) %></td>
|
||||||
|
|
||||||
<td><%= link_to(link_category.description, url_for(link_category)) %></td>
|
<td><%= link_to(truncate(link_category.description.to_plain_text), url_for(link_category)) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @link_categories, partial: "link_categories/link_category", as: :link_category
|
json.array! @link_categories, partial: "link_categories/link_category", as: :link_category
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "link_categories/link_category", link_category: @link_category
|
json.partial! "link_categories/link_category", link_category: @link_category
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
json.extract! link, :id, :url, :text, :description, :last_check_at, :fail_count, :link_category_id, :created_at, :updated_at
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
json.extract! link, :id, :url, :text, :description, :last_check_at, :fail_count, :link_category_id, :created_at,
|
||||||
|
:updated_at
|
||||||
json.url link_url(link, format: :json)
|
json.url link_url(link, format: :json)
|
||||||
json.description link.description.to_s
|
json.description link.description.to_s
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @links, partial: "links/link", as: :link
|
json.array! @links, partial: "links/link", as: :link
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "links/link", link: @link
|
json.partial! "links/link", link: @link
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! report, :id, :name, :comment_html, :created_at, :updated_at
|
json.extract! report, :id, :name, :comment_html, :created_at, :updated_at
|
||||||
json.url report_url(report, format: :json)
|
json.url report_url(report, format: :json)
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @reports, partial: "reports/report", as: :report
|
json.array! @reports, partial: "reports/report", as: :report
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "reports/report", report: @report
|
json.partial! "reports/report", report: @report
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
wb = xlsx_package.workbook
|
wb = xlsx_package.workbook
|
||||||
wb.add_worksheet(name: "Erfolgskriterien") do |sheet|
|
wb.add_worksheet(name: "Erfolgskriterien") do |sheet|
|
||||||
sheet.add_row SuccessCriterion.column_names
|
sheet.add_row SuccessCriterion.column_names
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.extract! success_criterion, :id, :element_id, :title, :description_html, :level, :result, :comment_html,
|
json.extract! success_criterion, :id, :element_id, :title, :description_html, :level, :result, :comment_html,
|
||||||
:created_at, :updated_at
|
:created_at, :updated_at
|
||||||
json.url success_criterion_url(success_criterion, format: :json)
|
json.url success_criterion_url(success_criterion, format: :json)
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.array! @success_criteria, partial: "success_criteria/success_criterion", as: :success_criterion
|
json.array! @success_criteria, partial: "success_criteria/success_criterion", as: :success_criterion
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.partial! "success_criteria/success_criterion", success_criterion: @success_criterion
|
json.partial! "success_criteria/success_criterion", success_criterion: @success_criterion
|
||||||
|
|
|
||||||
9
bin/brakeman
Executable file
9
bin/brakeman
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
require 'bundler/setup'
|
||||||
|
|
||||||
|
ARGV.unshift('--ensure-latest')
|
||||||
|
|
||||||
|
load Gem.bin_path('brakeman', 'brakeman')
|
||||||
|
|
@ -1,20 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/ash
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "1: ${1}"
|
|
||||||
echo "2: ${2}"
|
|
||||||
if [ -f tmp/pids/server.pid ]; then
|
if [ -f tmp/pids/server.pid ]; then
|
||||||
rm tmp/pids/server.pid
|
rm tmp/pids/server.pid
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make the if statement match any invocation of the "rails server" command
|
# Make the if statement match any invocation of the "rails server" command
|
||||||
if [[ "${1}" == *rails ]] && ([ "${2}" == "server" ] || [ "${2}" == "s" ]); then
|
if [[ "${1}" == *rails ]] && ([ "${2}" == "server" ] || [ "${2}" == "s" ]); then
|
||||||
|
echo "+ preparing database..."
|
||||||
|
./bin/rails db:prepare
|
||||||
|
echo "- preparing database done."
|
||||||
|
|
||||||
if [ ! -f /app/no_migrate ] && [ ! -v NO_MIGRATE ]; then
|
if [ -n "$ASSETS_PATH" ]; then
|
||||||
echo "+ preparing database..."
|
echo "+ copying assets..."
|
||||||
./bin/rails db:prepare
|
cp -nr public/* $ASSETS_PATH
|
||||||
echo "- preparing database done."
|
echo "- copying assets done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Execute the given or default command:
|
# Execute the given or default command:
|
||||||
|
|
|
||||||
10
bin/rubocop
Executable file
10
bin/rubocop
Executable file
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rubygems'
|
||||||
|
require 'bundler/setup'
|
||||||
|
|
||||||
|
# explicit rubocop config increases performance slightly while avoiding config confusion.
|
||||||
|
ARGV.unshift('--config', File.expand_path('../.rubocop.yml', __dir__))
|
||||||
|
|
||||||
|
load Gem.bin_path('rubocop', 'rubocop')
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
require "fileutils"
|
require "fileutils"
|
||||||
|
|
||||||
# path to your application root.
|
|
||||||
APP_ROOT = File.expand_path("..", __dir__)
|
APP_ROOT = File.expand_path("..", __dir__)
|
||||||
|
APP_NAME = "a11yist"
|
||||||
|
|
||||||
def system!(*args)
|
def system!(*args)
|
||||||
system(*args, exception: true)
|
system(*args, exception: true)
|
||||||
|
|
@ -17,9 +17,6 @@ FileUtils.chdir APP_ROOT do
|
||||||
system! "gem install bundler --conservative"
|
system! "gem install bundler --conservative"
|
||||||
system("bundle check") || system!("bundle install")
|
system("bundle check") || system!("bundle install")
|
||||||
|
|
||||||
# Install JavaScript dependencies
|
|
||||||
system("yarn check --check-files") || system!("yarn install")
|
|
||||||
|
|
||||||
# puts "\n== Copying sample files =="
|
# puts "\n== Copying sample files =="
|
||||||
# unless File.exist?("config/database.yml")
|
# unless File.exist?("config/database.yml")
|
||||||
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
||||||
|
|
@ -33,4 +30,8 @@ FileUtils.chdir APP_ROOT do
|
||||||
|
|
||||||
puts "\n== Restarting application server =="
|
puts "\n== Restarting application server =="
|
||||||
system! "bin/rails restart"
|
system! "bin/rails restart"
|
||||||
|
|
||||||
|
# puts "\n== Configuring puma-dev =="
|
||||||
|
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
|
||||||
|
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||||
|
|
||||||
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
require "bundler/setup" # Set up gems listed in the Gemfile.
|
||||||
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
|
require "bootsnap/setup" # Speed up boot time by caching expensive operations.
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ default: &default
|
||||||
adapter: sqlite3
|
adapter: sqlite3
|
||||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
default_transaction_mode: IMMEDIATE
|
||||||
|
|
||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
require 'active_support/core_ext/integer/time'
|
require "active_support/core_ext/integer/time"
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
@ -14,19 +14,17 @@ Rails.application.configure do
|
||||||
# Show full error reports.
|
# Show full error reports.
|
||||||
config.consider_all_requests_local = true
|
config.consider_all_requests_local = true
|
||||||
|
|
||||||
# Enable server timing
|
# Enable server timing.
|
||||||
config.server_timing = true
|
config.server_timing = true
|
||||||
|
|
||||||
# Enable/disable caching. By default caching is disabled.
|
# Enable/disable caching. By default caching is disabled.
|
||||||
# Run rails dev:cache to toggle caching.
|
# Run rails dev:cache to toggle caching.
|
||||||
if Rails.root.join('tmp/caching-dev.txt').exist?
|
if Rails.root.join("tmp/caching-dev.txt").exist?
|
||||||
config.action_controller.perform_caching = true
|
config.action_controller.perform_caching = true
|
||||||
config.action_controller.enable_fragment_cache_logging = true
|
config.action_controller.enable_fragment_cache_logging = true
|
||||||
|
|
||||||
config.cache_store = :memory_store
|
config.cache_store = :memory_store
|
||||||
config.public_file_server.headers = {
|
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
|
||||||
'Cache-Control' => "public, max-age=#{2.days.to_i}"
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
config.action_controller.perform_caching = false
|
config.action_controller.perform_caching = false
|
||||||
|
|
||||||
|
|
@ -39,8 +37,12 @@ Rails.application.configure do
|
||||||
# Don't care if the mailer can't send.
|
# Don't care if the mailer can't send.
|
||||||
config.action_mailer.raise_delivery_errors = false
|
config.action_mailer.raise_delivery_errors = false
|
||||||
|
|
||||||
|
# Disable caching for Action Mailer templates even if Action Controller
|
||||||
|
# caching is enabled.
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
|
config.action_mailer.default_url_options = { host: "a11yist.localhost" }
|
||||||
|
|
||||||
# Print deprecation notices to the Rails logger.
|
# Print deprecation notices to the Rails logger.
|
||||||
config.active_support.deprecation = :log
|
config.active_support.deprecation = :log
|
||||||
|
|
||||||
|
|
@ -66,13 +68,16 @@ Rails.application.configure do
|
||||||
# config.i18n.raise_on_missing_translations = true
|
# config.i18n.raise_on_missing_translations = true
|
||||||
|
|
||||||
# Annotate rendered view with file names.
|
# Annotate rendered view with file names.
|
||||||
# config.action_view.annotate_rendered_view_with_filenames = true
|
config.action_view.annotate_rendered_view_with_filenames = true
|
||||||
|
|
||||||
# Uncomment if you wish to allow Action Cable access from any origin.
|
# Uncomment if you wish to allow Action Cable access from any origin.
|
||||||
# config.action_cable.disable_request_forgery_protection = true
|
# config.action_cable.disable_request_forgery_protection = true
|
||||||
|
|
||||||
# Raise error when a before_action's only/except options reference missing actions
|
# Raise error when a before_action's only/except options reference missing actions.
|
||||||
config.action_controller.raise_on_missing_callback_actions = true
|
config.action_controller.raise_on_missing_callback_actions = true
|
||||||
|
|
||||||
config.web_console.permissions = ['192.168.0.0/16', '10.10.0.0/16']
|
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
|
||||||
|
# config.generators.apply_rubocop_autocorrect_after_generate!
|
||||||
|
#
|
||||||
|
config.web_console.allowed_ips = ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "127.0.0.0/8"]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
require 'active_support/core_ext/integer/time'
|
require "active_support/core_ext/integer/time"
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
@ -21,7 +21,7 @@ Rails.application.configure do
|
||||||
# config.require_master_key = true
|
# config.require_master_key = true
|
||||||
|
|
||||||
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
|
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
|
||||||
# config.public_file_server.enabled = false
|
config.public_file_server.enabled = ENV.fetch("ASSETS_PATH") { nil }.nil?
|
||||||
|
|
||||||
# Compress CSS using a preprocessor.
|
# Compress CSS using a preprocessor.
|
||||||
# config.assets.css_compressor = :sass
|
# config.assets.css_compressor = :sass
|
||||||
|
|
@ -49,20 +49,25 @@ Rails.application.configure do
|
||||||
# config.assume_ssl = true
|
# config.assume_ssl = true
|
||||||
|
|
||||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||||
config.force_ssl = true
|
config.force_ssl = false
|
||||||
|
|
||||||
|
# Skip http-to-https redirect for the default health check endpoint.
|
||||||
|
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
|
||||||
|
|
||||||
|
config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new("log/#{Rails.env}.log"))
|
||||||
|
|
||||||
# Log to STDOUT by default
|
# Log to STDOUT by default
|
||||||
config.logger = ActiveSupport::Logger.new(STDOUT)
|
# config.logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
|
# .tap { |logger| logger.formatter = ::Logger::Formatter.new }
|
||||||
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
# .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
||||||
|
|
||||||
# Prepend all log lines with the following tags.
|
# Prepend all log lines with the following tags.
|
||||||
config.log_tags = [:request_id]
|
config.log_tags = [ :request_id, :remote_ip ]
|
||||||
|
|
||||||
# "info" includes generic and useful information about system operation, but avoids logging too much
|
# "info" includes generic and useful information about system operation, but avoids logging too much
|
||||||
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
||||||
# want to log everything, set the level to "debug".
|
# want to log everything, set the level to "debug".
|
||||||
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
|
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
|
||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
# config.cache_store = :mem_cache_store
|
# config.cache_store = :mem_cache_store
|
||||||
|
|
@ -71,6 +76,8 @@ Rails.application.configure do
|
||||||
# config.active_job.queue_adapter = :resque
|
# config.active_job.queue_adapter = :resque
|
||||||
# config.active_job.queue_name_prefix = "a11yist_production"
|
# config.active_job.queue_name_prefix = "a11yist_production"
|
||||||
|
|
||||||
|
# Disable caching for Action Mailer templates even if Action Controller
|
||||||
|
# caching is enabled.
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
# Ignore bad email addresses and do not raise email delivery errors.
|
# Ignore bad email addresses and do not raise email delivery errors.
|
||||||
|
|
@ -92,8 +99,6 @@ Rails.application.configure do
|
||||||
# "example.com", # Allow requests from example.com
|
# "example.com", # Allow requests from example.com
|
||||||
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
||||||
# ]
|
# ]
|
||||||
config.hosts = ENV.fetch('APP_HOSTS', '').split(',')
|
|
||||||
# Skip DNS rebinding protection for the default health check endpoint.
|
# Skip DNS rebinding protection for the default health check endpoint.
|
||||||
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
||||||
config.active_record.sqlite3_production_warning=false
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
require 'active_support/core_ext/integer/time'
|
require "active_support/core_ext/integer/time"
|
||||||
|
|
||||||
# The test environment is used exclusively to run your application's
|
# The test environment is used exclusively to run your application's
|
||||||
# test suite. You never need to work with it otherwise. Remember that
|
# test suite. You never need to work with it otherwise. Remember that
|
||||||
|
|
@ -15,13 +15,10 @@ Rails.application.configure do
|
||||||
# this is usually not necessary, and can slow down your test suite. However, it's
|
# this is usually not necessary, and can slow down your test suite. However, it's
|
||||||
# recommended that you enable it in continuous integration systems to ensure eager
|
# recommended that you enable it in continuous integration systems to ensure eager
|
||||||
# loading is working properly before deploying your code.
|
# loading is working properly before deploying your code.
|
||||||
config.eager_load = ENV['CI'].present?
|
config.eager_load = ENV["CI"].present?
|
||||||
|
|
||||||
# Configure public file server for tests with Cache-Control for performance.
|
# Configure public file server for tests with Cache-Control for performance.
|
||||||
config.public_file_server.enabled = true
|
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
|
||||||
config.public_file_server.headers = {
|
|
||||||
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show full error reports and disable caching.
|
# Show full error reports and disable caching.
|
||||||
config.consider_all_requests_local = true
|
config.consider_all_requests_local = true
|
||||||
|
|
@ -37,6 +34,8 @@ Rails.application.configure do
|
||||||
# Store uploaded files on the local file system in a temporary directory.
|
# Store uploaded files on the local file system in a temporary directory.
|
||||||
config.active_storage.service = :test
|
config.active_storage.service = :test
|
||||||
|
|
||||||
|
# Disable caching for Action Mailer templates even if Action Controller
|
||||||
|
# caching is enabled.
|
||||||
config.action_mailer.perform_caching = false
|
config.action_mailer.perform_caching = false
|
||||||
|
|
||||||
# Tell Action Mailer not to deliver emails to the real world.
|
# Tell Action Mailer not to deliver emails to the real world.
|
||||||
|
|
@ -44,6 +43,10 @@ Rails.application.configure do
|
||||||
# ActionMailer::Base.deliveries array.
|
# ActionMailer::Base.deliveries array.
|
||||||
config.action_mailer.delivery_method = :test
|
config.action_mailer.delivery_method = :test
|
||||||
|
|
||||||
|
# Unlike controllers, the mailer instance doesn't have any context about the
|
||||||
|
# incoming request so you'll need to provide the :host parameter yourself.
|
||||||
|
config.action_mailer.default_url_options = { host: "www.example.com" }
|
||||||
|
|
||||||
# Print deprecation notices to the stderr.
|
# Print deprecation notices to the stderr.
|
||||||
config.active_support.deprecation = :stderr
|
config.active_support.deprecation = :stderr
|
||||||
|
|
||||||
|
|
@ -59,6 +62,6 @@ Rails.application.configure do
|
||||||
# Annotate rendered view with file names.
|
# Annotate rendered view with file names.
|
||||||
# config.action_view.annotate_rendered_view_with_filenames = true
|
# config.action_view.annotate_rendered_view_with_filenames = true
|
||||||
|
|
||||||
# Raise error when a before_action's only/except options reference missing actions
|
# Raise error when a before_action's only/except options reference missing actions.
|
||||||
config.action_controller.raise_on_missing_callback_actions = true
|
config.action_controller.raise_on_missing_callback_actions = true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@
|
||||||
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
|
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
|
||||||
# Use this to limit dissemination of sensitive information.
|
# Use this to limit dissemination of sensitive information.
|
||||||
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
||||||
Rails.application.config.filter_parameters += %i[
|
Rails.application.config.filter_parameters += [
|
||||||
passw secret token _key crypt salt certificate otp ssn
|
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
|
# I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
|
||||||
|
|
||||||
# Permitted locales available for the application
|
# Permitted locales available for the application
|
||||||
I18n.available_locales = [:"de-CH"]
|
I18n.available_locales = [:"de-CH", :en]
|
||||||
|
|
||||||
# Set default locale to something other than :en
|
# Set default locale to something other than :en
|
||||||
I18n.default_locale = :"de-CH"
|
I18n.default_locale = :"de-CH"
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue