mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 01:21:41 +00:00
Merge branch 'rails' of 0xacab.org:sutty/sutty into issue-12760
This commit is contained in:
commit
3074b176a7
266 changed files with 6703 additions and 1228 deletions
11
.editorconfig
Normal file
11
.editorconfig
Normal file
|
@ -0,0 +1,11 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
|
@ -1,7 +1,9 @@
|
|||
# pwgen -1 32
|
||||
RAILS_MASTER_KEY=11111111111111111111111111111111
|
||||
RAILS_GROUPS=assets
|
||||
DELEGATE=athshe.sutty.nl
|
||||
HAINISH=../haini.sh/haini.sh
|
||||
DATABASE=
|
||||
DATABASE_URL=postgres://suttier@postgresql.sutty.local/sutty
|
||||
RAILS_ENV=development
|
||||
IMAP_SERVER=
|
||||
DEFAULT_FROM=
|
||||
|
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
public/assets/** filter=lfs diff=lfs merge=lfs -text
|
||||
public/packs/** filter=lfs diff=lfs merge=lfs -text
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -34,12 +34,7 @@
|
|||
/config/master.key
|
||||
/config/credentials.yml.enc
|
||||
|
||||
/public/packs
|
||||
/public/packs-test
|
||||
/public/assets
|
||||
/public/assets-production
|
||||
/public/packs
|
||||
/public/packs-production
|
||||
/node_modules
|
||||
/yarn-error.log
|
||||
yarn-debug.log*
|
||||
|
@ -49,8 +44,6 @@ yarn-debug.log*
|
|||
*.key
|
||||
*.crt
|
||||
|
||||
/public/packs
|
||||
/public/packs-test
|
||||
/node_modules
|
||||
/yarn-error.log
|
||||
yarn-debug.log*
|
||||
|
|
33
.gitlab-ci.yml
Normal file
33
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
image: "gitea.nulo.in/sutty/panel:3.14.10-2.7.8-panel.sutty.nl"
|
||||
variables:
|
||||
RAILS_ENV: "production"
|
||||
LC_ALL: "C.UTF-8"
|
||||
cache:
|
||||
paths:
|
||||
- "vendor/ruby"
|
||||
assets:
|
||||
stage: "build"
|
||||
rules:
|
||||
- if: "$CI_COMMIT_BRANCH == \"panel.sutty.nl\""
|
||||
- if: "$CI_COMMIT_BRANCH"
|
||||
changes:
|
||||
compare_to: "refs/heads/rails"
|
||||
paths:
|
||||
- "package.json"
|
||||
- "app/javascript/**/*"
|
||||
- "app/assets/**/*"
|
||||
before_script:
|
||||
- "git config --global user.email \"${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}\""
|
||||
- "git config --global user.name \"${GIT_USER_NAME:-$GITLAB_USER_NAME}\""
|
||||
- "git remote set-url --push origin \"https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git\""
|
||||
- "apk add python2 dotenv brotli"
|
||||
- "mv config/credentials.yml.enc.ci config/credentials.yml.enc"
|
||||
- "cp .env.example .env"
|
||||
- "dotenv bundle install --path=vendor"
|
||||
script:
|
||||
- "dotenv RAILS_ENV=production bundle exec rails webpacker:clobber"
|
||||
- "dotenv RAILS_ENV=production bundle exec rails assets:precompile"
|
||||
- "dotenv RAILS_ENV=production bundle exec rails assets:clean"
|
||||
after_script:
|
||||
- "git add public && git commit -m \"ci: assets [skip ci]\""
|
||||
- "git push -o ci.skip"
|
83
.woodpecker.yml
Normal file
83
.woodpecker.yml
Normal file
|
@ -0,0 +1,83 @@
|
|||
pipeline:
|
||||
publish:
|
||||
image: "docker.io/woodpeckerci/plugin-docker-buildx"
|
||||
settings:
|
||||
registry: "gitea.nulo.in"
|
||||
username: "sutty"
|
||||
repo: "gitea.nulo.in/sutty/panel"
|
||||
tags:
|
||||
- "${ALPINE_VERSION}-${RUBY_VERSION}.${RUBY_PATCH}-${CI_COMMIT_BRANCH}"
|
||||
- "latest"
|
||||
build_args:
|
||||
- "RUBY_VERSION=${RUBY_VERSION}"
|
||||
- "RUBY_PATCH=${RUBY_PATCH}"
|
||||
- "ALPINE_VERSION=${ALPINE_VERSION}"
|
||||
- "BASE_IMAGE=gitea.nulo.in/sutty/rails"
|
||||
purge: false
|
||||
secrets:
|
||||
- "DOCKER_PASSWORD"
|
||||
when:
|
||||
branch:
|
||||
- "rails"
|
||||
- "panel.sutty.nl"
|
||||
- "17.3.alpine.panel.sutty.nl"
|
||||
event: "push"
|
||||
path:
|
||||
include:
|
||||
- "Dockerfile"
|
||||
- ".dockerignore"
|
||||
- ".woodpecker.yml"
|
||||
assets:
|
||||
image: "gitea.nulo.in/sutty/panel:3.14.10-2.7.8"
|
||||
commands:
|
||||
- "apk add python2 dotenv openssh-client brotli"
|
||||
- "install -d -m 700 ~/.ssh/"
|
||||
- "echo \"$${KNOWN_HOSTS}\" | base64 -d >> ~/.ssh/known_hosts"
|
||||
- "chmod 600 ~/.ssh/known_hosts"
|
||||
- "eval $(ssh-agent -s)"
|
||||
- "echo \"$${SSH_KEY}\" | base64 -d | ssh-add -"
|
||||
- "ssh $${ORIGIN%:*}"
|
||||
- "git config user.name Woodpecker"
|
||||
- "git config user.email ci@sutty.coop.ar"
|
||||
- "git remote add upstream $${ORIGIN}"
|
||||
- "git checkout -B ${CI_COMMIT_BRANCH}"
|
||||
- "mv config/credentials.yml.enc.ci config/credentials.yml.enc"
|
||||
- "yarn"
|
||||
- "cp .env.example .env"
|
||||
- "dotenv bundle install --path=vendor"
|
||||
- "dotenv RAILS_ENV=production bundle exec rails webpacker:clobber"
|
||||
- "dotenv RAILS_ENV=production bundle exec rails assets:precompile"
|
||||
- "dotenv RAILS_ENV=production bundle exec rails assets:clean"
|
||||
- "find public -type f -print0 | xargs -r0 brotli -k9f"
|
||||
- "git add public && git commit -m \"ci: assets [skip ci]\""
|
||||
- "git pull upstream ${CI_COMMIT_BRANCH}"
|
||||
- "git push upstream ${CI_COMMIT_BRANCH}"
|
||||
environment:
|
||||
- "RUBY_VERSION=${RUBY_VERSION}"
|
||||
- "GEMS_SOURCE=https://14.3.alpine.gems.sutty.nl"
|
||||
secrets:
|
||||
- "SSH_KEY"
|
||||
- "KNOWN_HOSTS"
|
||||
- "ORIGIN"
|
||||
when:
|
||||
branch:
|
||||
- "rails"
|
||||
- "panel.sutty.nl"
|
||||
path:
|
||||
include:
|
||||
- "app/assets/**/*"
|
||||
- "app/javascript/**/*"
|
||||
- "package.json"
|
||||
- "yarn.lock"
|
||||
matrix:
|
||||
ALPINE_VERSION: "3.14.10"
|
||||
RUBY_VERSION: "2.7"
|
||||
RUBY_PATCH: "8"
|
||||
matrix:
|
||||
include:
|
||||
- ALPINE_VERSION: "3.17.3"
|
||||
RUBY_VERSION: "3.1"
|
||||
RUBY_PATCH: "4"
|
||||
- ALPINE_VERSION: "3.14.10"
|
||||
RUBY_VERSION: "2.7"
|
||||
RUBY_PATCH: "8"
|
13
Dockerfile
13
Dockerfile
|
@ -1,5 +1,9 @@
|
|||
FROM registry.nulo.in/sutty/rails:3.13.6-2.7.5
|
||||
ARG PANDOC_VERSION=2.17.1.1
|
||||
ARG RUBY_VERSION=2.7
|
||||
ARG RUBY_PATCH=6
|
||||
ARG ALPINE_VERSION=3.13.10
|
||||
ARG BASE_IMAGE=registry.nulo.in/sutty/rails
|
||||
FROM ${BASE_IMAGE}:${ALPINE_VERSION}-${RUBY_VERSION}.${RUBY_PATCH}
|
||||
ARG PANDOC_VERSION=2.18
|
||||
ENV RAILS_ENV production
|
||||
|
||||
# Instalar las dependencias, separamos la librería de base de datos para
|
||||
|
@ -10,13 +14,16 @@ ENV RAILS_ENV production
|
|||
# principal
|
||||
RUN apk add --no-cache libxslt libxml2 postgresql-libs libssh2 \
|
||||
rsync git jpegoptim vips tectonic oxipng git-lfs openssh-client \
|
||||
yarn daemonize ruby-webrick
|
||||
yarn daemonize ruby-webrick postgresql-client dateutils file
|
||||
|
||||
RUN gem install --no-document --no-user-install foreman
|
||||
RUN wget https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz -O - | tar --strip-components 1 -xvzf - pandoc-${PANDOC_VERSION}/bin/pandoc && mv /bin/pandoc /usr/bin/pandoc
|
||||
RUN apk add npm && npm install -g pnpm@~7 && apk del npm
|
||||
|
||||
COPY ./monit.conf /etc/monit.d/sutty.conf
|
||||
|
||||
RUN apk add npm && npm install -g pnpm && apk del npm
|
||||
|
||||
VOLUME "/srv"
|
||||
|
||||
EXPOSE 3000
|
||||
|
|
32
Gemfile
32
Gemfile
|
@ -1,14 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
puts 'Usa haini.sh para generar un entorno de trabajo reproducible'
|
||||
source 'https://gems.sutty.nl'
|
||||
source ENV.fetch('GEMS_SOURCE', 'https://17.3.alpine.gems.sutty.nl')
|
||||
|
||||
ruby '~> 2.7'
|
||||
ruby "~> #{ENV.fetch('RUBY_VERSION', '3.1')}"
|
||||
|
||||
gem 'dotenv-rails', require: 'dotenv/rails-now'
|
||||
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '~> 6'
|
||||
gem 'rails', '~> 6.1.0'
|
||||
# Use Puma as the app server
|
||||
gem 'puma'
|
||||
|
||||
|
@ -23,6 +22,7 @@ if ENV['RAILS_GROUPS']&.split(',')&.include? 'assets'
|
|||
end
|
||||
|
||||
gem 'nokogiri'
|
||||
gem 'rgl'
|
||||
|
||||
# Turbolinks makes navigating your web application faster. Read more:
|
||||
# https://github.com/turbolinks/turbolinks
|
||||
|
@ -32,12 +32,14 @@ gem 'turbolinks', '~> 5'
|
|||
gem 'jbuilder', '~> 2.5'
|
||||
# Use ActiveModel has_secure_password
|
||||
gem 'bcrypt', '~> 3.1.7'
|
||||
gem 'safely_block', '~> 0.3.0'
|
||||
gem 'blazer'
|
||||
gem 'chartkick'
|
||||
gem 'commonmarker'
|
||||
gem 'devise'
|
||||
gem 'devise-i18n'
|
||||
gem 'devise_invitable'
|
||||
gem 'distributed-press-api-client', '~> 0.3.0rc0'
|
||||
gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n'
|
||||
gem 'exception_notification'
|
||||
gem 'fast_blank'
|
||||
|
@ -48,10 +50,10 @@ gem 'image_processing'
|
|||
gem 'icalendar'
|
||||
gem 'inline_svg'
|
||||
gem 'httparty'
|
||||
gem 'safe_yaml'
|
||||
gem 'jekyll', '~> 4.2'
|
||||
gem 'safe_yaml', require: false
|
||||
gem 'jekyll', '~> 4.2.0'
|
||||
gem 'jekyll-data'
|
||||
gem 'jekyll-commonmark'
|
||||
gem 'jekyll-commonmark', '~> 1.4.0'
|
||||
gem 'jekyll-images'
|
||||
gem 'jekyll-include-cache'
|
||||
gem 'sutty-liquid', '>= 0.7.3'
|
||||
|
@ -62,19 +64,21 @@ gem 'mobility'
|
|||
gem 'pundit'
|
||||
gem 'rails-i18n'
|
||||
gem 'rails_warden'
|
||||
gem 'redis', require: %w[redis redis/connection/hiredis]
|
||||
gem 'redis', '~> 4.0', require: %w[redis redis/connection/hiredis]
|
||||
gem 'redis-rails'
|
||||
gem 'rollups', git: 'https://github.com/fauno/rollup.git', branch: 'update'
|
||||
gem 'rubyzip'
|
||||
gem 'rugged'
|
||||
gem 'rugged', '1.5.0.1'
|
||||
gem 'git_clone_url'
|
||||
gem 'concurrent-ruby-ext'
|
||||
gem 'sucker_punch'
|
||||
gem 'que'
|
||||
gem 'symbol-fstring', require: 'fstring/all'
|
||||
gem 'terminal-table'
|
||||
gem 'validates_hostname'
|
||||
gem 'webpacker'
|
||||
gem 'yaml_db', git: 'https://0xacab.org/sutty/yaml_db.git'
|
||||
gem 'kaminari'
|
||||
gem 'device_detector'
|
||||
|
||||
# database
|
||||
gem 'hairtrigger'
|
||||
|
@ -108,7 +112,7 @@ group :development, :test do
|
|||
gem 'pry'
|
||||
# Adds support for Capybara system testing and selenium driver
|
||||
gem 'capybara', '~> 2.13'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'selenium-webdriver', '~> 4.8.0'
|
||||
gem 'sqlite3'
|
||||
end
|
||||
|
||||
|
@ -116,11 +120,11 @@ group :development do
|
|||
gem 'brakeman'
|
||||
gem 'haml-lint', require: false
|
||||
gem 'letter_opener'
|
||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||
gem 'listen'
|
||||
gem 'rubocop-rails'
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
gem 'web-console', '>= 3.3.0'
|
||||
gem 'spring-watcher-listen'
|
||||
gem 'web-console'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
|
587
Gemfile.lock
587
Gemfile.lock
|
@ -25,86 +25,86 @@ GIT
|
|||
groupdate (>= 5.2)
|
||||
|
||||
GEM
|
||||
remote: https://gems.sutty.nl/
|
||||
remote: https://17.3.alpine.gems.sutty.nl/
|
||||
specs:
|
||||
actioncable (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
actioncable (6.1.7.3)
|
||||
actionpack (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activestorage (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
actionmailbox (6.1.7.3)
|
||||
actionpack (= 6.1.7.3)
|
||||
activejob (= 6.1.7.3)
|
||||
activerecord (= 6.1.7.3)
|
||||
activestorage (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
actionview (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
actionmailer (6.1.7.3)
|
||||
actionpack (= 6.1.7.3)
|
||||
actionview (= 6.1.7.3)
|
||||
activejob (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (6.1.4.1)
|
||||
actionview (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
actionpack (6.1.7.3)
|
||||
actionview (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
rack (~> 2.0, >= 2.0.9)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activestorage (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
actiontext (6.1.7.3)
|
||||
actionpack (= 6.1.7.3)
|
||||
activerecord (= 6.1.7.3)
|
||||
activestorage (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
actionview (6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
activejob (6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
activerecord (6.1.4.1)
|
||||
activemodel (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
activestorage (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
marcel (~> 1.0.0)
|
||||
activemodel (6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
activerecord (6.1.7.3)
|
||||
activemodel (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
activestorage (6.1.7.3)
|
||||
actionpack (= 6.1.7.3)
|
||||
activejob (= 6.1.7.3)
|
||||
activerecord (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
marcel (~> 1.0)
|
||||
mini_mime (>= 1.1.0)
|
||||
activesupport (6.1.4.1)
|
||||
activesupport (6.1.7.3)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
zeitwerk (~> 2.3)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
addressable (2.8.4)
|
||||
public_suffix (>= 2.0.2, < 6.0)
|
||||
ast (2.4.2)
|
||||
autoprefixer-rails (10.3.3.0)
|
||||
autoprefixer-rails (10.4.13.0)
|
||||
execjs (~> 2)
|
||||
bcrypt (3.1.16-x86_64-linux-musl)
|
||||
bcrypt (3.1.19-x86_64-linux-musl)
|
||||
bcrypt_pbkdf (1.1.0-x86_64-linux-musl)
|
||||
benchmark-ips (2.9.2)
|
||||
benchmark-ips (2.12.0)
|
||||
bindex (0.8.1-x86_64-linux-musl)
|
||||
blazer (2.4.7)
|
||||
blazer (2.6.5)
|
||||
activerecord (>= 5)
|
||||
chartkick (>= 3.2)
|
||||
railties (>= 5)
|
||||
safely_block (>= 0.1.1)
|
||||
bootstrap (4.6.0)
|
||||
bootstrap (4.6.2)
|
||||
autoprefixer-rails (>= 9.1.0)
|
||||
popper_js (>= 1.14.3, < 2)
|
||||
popper_js (>= 1.16.1, < 2)
|
||||
sassc-rails (>= 2.0.0)
|
||||
brakeman (5.1.2)
|
||||
brakeman (5.4.1)
|
||||
builder (3.2.4)
|
||||
capybara (2.18.0)
|
||||
addressable
|
||||
|
@ -113,24 +113,24 @@ GEM
|
|||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (>= 2.0, < 4.0)
|
||||
chartkick (4.1.2)
|
||||
childprocess (4.1.0)
|
||||
chartkick (5.0.2)
|
||||
climate_control (1.2.0)
|
||||
coderay (1.1.3)
|
||||
colorator (1.1.0)
|
||||
commonmarker (0.21.2-x86_64-linux-musl)
|
||||
ruby-enum (~> 0.5)
|
||||
concurrent-ruby (1.1.9)
|
||||
concurrent-ruby-ext (1.1.9-x86_64-linux-musl)
|
||||
concurrent-ruby (= 1.1.9)
|
||||
commonmarker (0.23.10-x86_64-linux-musl)
|
||||
concurrent-ruby (1.2.2)
|
||||
concurrent-ruby-ext (1.2.2-x86_64-linux-musl)
|
||||
concurrent-ruby (= 1.2.2)
|
||||
crass (1.0.6)
|
||||
database_cleaner (2.0.1)
|
||||
database_cleaner-active_record (~> 2.0.0)
|
||||
database_cleaner-active_record (2.0.1)
|
||||
database_cleaner (2.0.2)
|
||||
database_cleaner-active_record (>= 2, < 3)
|
||||
database_cleaner-active_record (2.1.0)
|
||||
activerecord (>= 5.a)
|
||||
database_cleaner-core (~> 2.0.0)
|
||||
database_cleaner-core (2.0.1)
|
||||
dead_end (3.1.0)
|
||||
derailed_benchmarks (2.1.1)
|
||||
date (3.3.3-x86_64-linux-musl)
|
||||
dead_end (4.0.0)
|
||||
derailed_benchmarks (2.1.2)
|
||||
benchmark-ips (~> 2)
|
||||
dead_end
|
||||
get_process_mem (~> 0)
|
||||
|
@ -142,68 +142,105 @@ GEM
|
|||
rake (> 10, < 14)
|
||||
ruby-statistics (>= 2.1)
|
||||
thor (>= 0.19, < 2)
|
||||
devise (4.8.0)
|
||||
device_detector (1.1.1)
|
||||
devise (4.9.2)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
devise-i18n (1.10.1)
|
||||
devise (>= 4.8.0)
|
||||
devise_invitable (2.0.5)
|
||||
devise-i18n (1.11.0)
|
||||
devise (>= 4.9.0)
|
||||
devise_invitable (2.0.8)
|
||||
actionmailer (>= 5.0)
|
||||
devise (>= 4.6)
|
||||
dotenv (2.7.6)
|
||||
dotenv-rails (2.7.6)
|
||||
dotenv (= 2.7.6)
|
||||
distributed-press-api-client (0.3.0rc0)
|
||||
addressable (~> 2.3, >= 2.3.0)
|
||||
climate_control
|
||||
dry-schema
|
||||
httparty (~> 0.18)
|
||||
json (~> 2.1, >= 2.1.0)
|
||||
jwt (~> 2.6.0)
|
||||
dotenv (2.8.1)
|
||||
dotenv-rails (2.8.1)
|
||||
dotenv (= 2.8.1)
|
||||
railties (>= 3.2)
|
||||
down (5.2.4)
|
||||
down (5.4.1)
|
||||
addressable (~> 2.8)
|
||||
ed25519 (1.2.4-x86_64-linux-musl)
|
||||
dry-configurable (1.0.1)
|
||||
dry-core (~> 1.0, < 2)
|
||||
zeitwerk (~> 2.6)
|
||||
dry-core (1.0.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
zeitwerk (~> 2.6)
|
||||
dry-inflector (1.0.0)
|
||||
dry-initializer (3.1.1)
|
||||
dry-logic (1.5.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
dry-core (~> 1.0, < 2)
|
||||
zeitwerk (~> 2.6)
|
||||
dry-schema (1.13.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
dry-configurable (~> 1.0, >= 1.0.1)
|
||||
dry-core (~> 1.0, < 2)
|
||||
dry-initializer (~> 3.0)
|
||||
dry-logic (>= 1.4, < 2)
|
||||
dry-types (>= 1.7, < 2)
|
||||
zeitwerk (~> 2.6)
|
||||
dry-types (1.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
dry-core (~> 1.0)
|
||||
dry-inflector (~> 1.0)
|
||||
dry-logic (~> 1.4)
|
||||
zeitwerk (~> 2.6)
|
||||
ed25519 (1.3.0-x86_64-linux-musl)
|
||||
em-websocket (0.5.3)
|
||||
eventmachine (>= 0.12.9)
|
||||
http_parser.rb (~> 0)
|
||||
errbase (0.2.1)
|
||||
erubi (1.10.0)
|
||||
errbase (0.2.2)
|
||||
erubi (1.12.0)
|
||||
eventmachine (1.2.7-x86_64-linux-musl)
|
||||
exception_notification (4.4.3)
|
||||
actionmailer (>= 4.0, < 7)
|
||||
activesupport (>= 4.0, < 7)
|
||||
exception_notification (4.5.0)
|
||||
actionmailer (>= 5.2, < 8)
|
||||
activesupport (>= 5.2, < 8)
|
||||
execjs (2.8.1)
|
||||
factory_bot (6.2.0)
|
||||
factory_bot (6.2.1)
|
||||
activesupport (>= 5.0.0)
|
||||
factory_bot_rails (6.2.0)
|
||||
factory_bot (~> 6.2.0)
|
||||
railties (>= 5.0.0)
|
||||
fast_blank (1.0.1-x86_64-linux-musl)
|
||||
fast_jsonparser (0.5.0-x86_64-linux-musl)
|
||||
ffi (1.15.4-x86_64-linux-musl)
|
||||
ffi (1.15.5-x86_64-linux-musl)
|
||||
flamegraph (0.9.5)
|
||||
forwardable-extended (2.6.0)
|
||||
friendly_id (5.4.2)
|
||||
friendly_id (5.5.0)
|
||||
activerecord (>= 4.0.0)
|
||||
get_process_mem (0.2.7)
|
||||
ffi (~> 1.0)
|
||||
globalid (0.6.0)
|
||||
git_clone_url (2.0.0)
|
||||
uri-ssh_git (>= 2.0)
|
||||
globalid (1.1.0)
|
||||
activesupport (>= 5.0)
|
||||
groupdate (6.1.0)
|
||||
groupdate (6.2.1)
|
||||
activesupport (>= 5.2)
|
||||
hairtrigger (0.2.24)
|
||||
activerecord (>= 5.0, < 7)
|
||||
hairtrigger (1.0.0)
|
||||
activerecord (>= 6.0, < 8)
|
||||
ruby2ruby (~> 2.4)
|
||||
ruby_parser (~> 3.10)
|
||||
haml (5.2.2)
|
||||
temple (>= 0.8.0)
|
||||
haml (6.1.2-x86_64-linux-musl)
|
||||
temple (>= 0.8.2)
|
||||
thor
|
||||
tilt
|
||||
haml-lint (0.999.999)
|
||||
haml_lint
|
||||
haml_lint (0.37.1)
|
||||
haml (>= 4.0, < 5.3)
|
||||
haml_lint (0.45.0)
|
||||
haml (>= 4.0, < 6.2)
|
||||
parallel (~> 1.10)
|
||||
rainbow
|
||||
rubocop (>= 0.50.0)
|
||||
sysexits (~> 1.1)
|
||||
hamlit (2.15.1-x86_64-linux-musl)
|
||||
hamlit (3.0.3-x86_64-linux-musl)
|
||||
temple (>= 0.8.2)
|
||||
thor
|
||||
tilt
|
||||
|
@ -216,23 +253,24 @@ GEM
|
|||
thor
|
||||
hiredis (0.6.3-x86_64-linux-musl)
|
||||
http_parser.rb (0.8.0-x86_64-linux-musl)
|
||||
httparty (0.18.1)
|
||||
mime-types (~> 3.0)
|
||||
httparty (0.21.0)
|
||||
mini_mime (>= 1.0.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (1.8.11)
|
||||
i18n (1.14.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
icalendar (2.7.1)
|
||||
icalendar (2.8.0)
|
||||
ice_cube (~> 0.16)
|
||||
ice_cube (0.16.4)
|
||||
image_processing (1.12.1)
|
||||
image_processing (1.12.2)
|
||||
mini_magick (>= 4.9.5, < 5)
|
||||
ruby-vips (>= 2.0.17, < 3)
|
||||
inline_svg (1.7.2)
|
||||
inline_svg (1.9.0)
|
||||
activesupport (>= 3.0)
|
||||
nokogiri (>= 1.6)
|
||||
jbuilder (2.11.3)
|
||||
jbuilder (2.11.5)
|
||||
actionview (>= 5.0.0)
|
||||
activesupport (>= 5.0.0)
|
||||
jekyll (4.2.1)
|
||||
jekyll (4.2.2)
|
||||
addressable (~> 2.4)
|
||||
colorator (~> 1.0)
|
||||
em-websocket (~> 0.5)
|
||||
|
@ -247,233 +285,216 @@ GEM
|
|||
rouge (~> 3.0)
|
||||
safe_yaml (~> 1.0)
|
||||
terminal-table (~> 2.0)
|
||||
jekyll-commonmark (1.3.2)
|
||||
commonmarker (~> 0.14, < 0.22)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-commonmark (1.4.0)
|
||||
commonmarker (~> 0.22)
|
||||
jekyll-data (1.1.2)
|
||||
jekyll (>= 3.3, < 5.0.0)
|
||||
jekyll-dotenv (0.2.0)
|
||||
dotenv (~> 2.7)
|
||||
jekyll (~> 4)
|
||||
jekyll-feed (0.15.1)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-hardlinks (0.1.2)
|
||||
jekyll (~> 4)
|
||||
jekyll-ignore-layouts (0.1.2)
|
||||
jekyll (~> 4)
|
||||
jekyll-images (0.3.2)
|
||||
jekyll-images (0.4.1)
|
||||
jekyll (~> 4)
|
||||
ruby-filemagic (~> 0.7)
|
||||
ruby-vips (~> 2)
|
||||
jekyll-include-cache (0.2.1)
|
||||
jekyll (>= 3.7, < 5.0)
|
||||
jekyll-linked-posts (0.4.2)
|
||||
jekyll (~> 4)
|
||||
jekyll-locales (0.1.13)
|
||||
jekyll-lunr (0.3.0)
|
||||
loofah (~> 2.4)
|
||||
jekyll-order (0.1.4)
|
||||
jekyll-relative-urls (0.0.6)
|
||||
jekyll (~> 4)
|
||||
jekyll-sass-converter (2.1.0)
|
||||
jekyll-sass-converter (2.2.0)
|
||||
sassc (> 2.0.1, < 3.0)
|
||||
jekyll-seo-tag (2.7.1)
|
||||
jekyll (>= 3.8, < 5.0)
|
||||
jekyll-spree-client (0.1.19)
|
||||
fast_blank (~> 1)
|
||||
spree-api-client (>= 0.2.4)
|
||||
jekyll-turbolinks (0.0.5)
|
||||
jekyll (~> 4)
|
||||
turbolinks-source (~> 5)
|
||||
jekyll-unique-urls (0.1.1)
|
||||
jekyll (~> 4)
|
||||
jekyll-watch (2.2.1)
|
||||
listen (~> 3.0)
|
||||
jekyll-write-and-commit-changes (0.2.1)
|
||||
jekyll (~> 4)
|
||||
rugged (~> 1)
|
||||
kaminari (1.2.1)
|
||||
json (2.6.3-x86_64-linux-musl)
|
||||
jwt (2.6.0)
|
||||
kaminari (1.2.2)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.2.1)
|
||||
kaminari-activerecord (= 1.2.1)
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-actionview (1.2.1)
|
||||
kaminari-actionview (= 1.2.2)
|
||||
kaminari-activerecord (= 1.2.2)
|
||||
kaminari-core (= 1.2.2)
|
||||
kaminari-actionview (1.2.2)
|
||||
actionview
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-activerecord (1.2.1)
|
||||
kaminari-core (= 1.2.2)
|
||||
kaminari-activerecord (1.2.2)
|
||||
activerecord
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-core (1.2.1)
|
||||
kramdown (2.3.1)
|
||||
kaminari-core (= 1.2.2)
|
||||
kaminari-core (1.2.2)
|
||||
kramdown (2.4.0)
|
||||
rexml
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
launchy (2.5.0)
|
||||
addressable (~> 2.7)
|
||||
letter_opener (1.7.0)
|
||||
launchy (~> 2.2)
|
||||
liquid (4.0.3)
|
||||
listen (3.1.5)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
ruby_dep (~> 1.2)
|
||||
launchy (2.5.2)
|
||||
addressable (~> 2.8)
|
||||
letter_opener (1.8.1)
|
||||
launchy (>= 2.2, < 3)
|
||||
liquid (4.0.4)
|
||||
listen (3.8.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
loaf (0.10.0)
|
||||
railties (>= 3.2)
|
||||
lockbox (0.6.6)
|
||||
lograge (0.11.2)
|
||||
lockbox (1.2.0)
|
||||
lograge (0.12.0)
|
||||
actionpack (>= 4)
|
||||
activesupport (>= 4)
|
||||
railties (>= 4)
|
||||
request_store (~> 1.0)
|
||||
loofah (2.12.0)
|
||||
loofah (2.21.3)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
nokogiri (>= 1.12.0)
|
||||
mail (2.8.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
net-imap
|
||||
net-pop
|
||||
net-smtp
|
||||
marcel (1.0.2)
|
||||
memory_profiler (1.0.0)
|
||||
memory_profiler (1.0.1)
|
||||
mercenary (0.4.0)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.4.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2021.1115)
|
||||
mini_histogram (0.3.1)
|
||||
mini_magick (4.11.0)
|
||||
mini_magick (4.12.0)
|
||||
mini_mime (1.1.2)
|
||||
mini_portile2 (2.6.1)
|
||||
minitest (5.14.4)
|
||||
mobility (1.2.4)
|
||||
mini_portile2 (2.8.2)
|
||||
minitest (5.18.0)
|
||||
mobility (1.2.9)
|
||||
i18n (>= 0.6.10, < 2)
|
||||
request_store (~> 1.0)
|
||||
multi_xml (0.6.0)
|
||||
net-ssh (6.1.0)
|
||||
netaddr (2.0.5)
|
||||
nio4r (2.5.8-x86_64-linux-musl)
|
||||
nokogiri (1.12.5-x86_64-linux-musl)
|
||||
mini_portile2 (~> 2.6.1)
|
||||
net-imap (0.3.4)
|
||||
date
|
||||
net-protocol
|
||||
net-pop (0.1.2)
|
||||
net-protocol
|
||||
net-protocol (0.2.1)
|
||||
timeout
|
||||
net-smtp (0.3.3)
|
||||
net-protocol
|
||||
net-ssh (7.1.0)
|
||||
netaddr (2.0.6)
|
||||
nio4r (2.5.9-x86_64-linux-musl)
|
||||
nokogiri (1.15.4-x86_64-linux-musl)
|
||||
mini_portile2 (~> 2.8.2)
|
||||
racc (~> 1.4)
|
||||
orm_adapter (0.5.0)
|
||||
parallel (1.21.0)
|
||||
parser (3.0.2.0)
|
||||
pairing_heap (3.0.1)
|
||||
parallel (1.23.0)
|
||||
parser (3.2.2.1)
|
||||
ast (~> 2.4.1)
|
||||
pathutil (0.16.2)
|
||||
forwardable-extended (~> 2.6)
|
||||
pg (1.2.3-x86_64-linux-musl)
|
||||
pg_search (2.3.5)
|
||||
pg (1.5.3-x86_64-linux-musl)
|
||||
pg_search (2.3.6)
|
||||
activerecord (>= 5.2)
|
||||
activesupport (>= 5.2)
|
||||
popper_js (1.16.0)
|
||||
prometheus_exporter (1.0.0)
|
||||
popper_js (1.16.1)
|
||||
prometheus_exporter (2.0.8)
|
||||
webrick
|
||||
pry (0.14.1)
|
||||
pry (0.14.2)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
public_suffix (4.0.6)
|
||||
puma (5.5.2-x86_64-linux-musl)
|
||||
public_suffix (5.0.3)
|
||||
puma (6.3.1-x86_64-linux-musl)
|
||||
nio4r (~> 2.0)
|
||||
pundit (2.1.1)
|
||||
pundit (2.3.0)
|
||||
activesupport (>= 3.0.0)
|
||||
racc (1.6.0-x86_64-linux-musl)
|
||||
rack (2.2.3)
|
||||
rack-cors (1.1.1)
|
||||
que (2.2.1)
|
||||
racc (1.7.1-x86_64-linux-musl)
|
||||
rack (2.2.7)
|
||||
rack-cors (2.0.1)
|
||||
rack (>= 2.0.0)
|
||||
rack-mini-profiler (2.3.3)
|
||||
rack-mini-profiler (3.1.0)
|
||||
rack (>= 1.2.0)
|
||||
rack-proxy (0.7.0)
|
||||
rack-proxy (0.7.6)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (6.1.4.1)
|
||||
actioncable (= 6.1.4.1)
|
||||
actionmailbox (= 6.1.4.1)
|
||||
actionmailer (= 6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
actiontext (= 6.1.4.1)
|
||||
actionview (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activemodel (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activestorage (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
rack-test (2.1.0)
|
||||
rack (>= 1.3)
|
||||
rails (6.1.7.3)
|
||||
actioncable (= 6.1.7.3)
|
||||
actionmailbox (= 6.1.7.3)
|
||||
actionmailer (= 6.1.7.3)
|
||||
actionpack (= 6.1.7.3)
|
||||
actiontext (= 6.1.7.3)
|
||||
actionview (= 6.1.7.3)
|
||||
activejob (= 6.1.7.3)
|
||||
activemodel (= 6.1.7.3)
|
||||
activerecord (= 6.1.7.3)
|
||||
activestorage (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
bundler (>= 1.15.0)
|
||||
railties (= 6.1.4.1)
|
||||
railties (= 6.1.7.3)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.4.2)
|
||||
loofah (~> 2.3)
|
||||
rails-i18n (6.0.0)
|
||||
rails-html-sanitizer (1.5.0)
|
||||
loofah (~> 2.19, >= 2.19.1)
|
||||
rails-i18n (7.0.7)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 6.0.0, < 7)
|
||||
railties (>= 6.0.0, < 8)
|
||||
rails_warden (0.6.0)
|
||||
warden (>= 1.2.0)
|
||||
railties (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
railties (6.1.7.3)
|
||||
actionpack (= 6.1.7.3)
|
||||
activesupport (= 6.1.7.3)
|
||||
method_source
|
||||
rake (>= 0.13)
|
||||
rake (>= 12.2)
|
||||
thor (~> 1.0)
|
||||
rainbow (3.0.0)
|
||||
rainbow (3.1.1)
|
||||
rake (13.0.6)
|
||||
rb-fsevent (0.11.0)
|
||||
rb-fsevent (0.11.2)
|
||||
rb-inotify (0.10.1)
|
||||
ffi (~> 1.0)
|
||||
redis (4.5.1)
|
||||
redis-actionpack (5.2.0)
|
||||
actionpack (>= 5, < 7)
|
||||
redis (4.8.1)
|
||||
redis-actionpack (5.3.0)
|
||||
actionpack (>= 5, < 8)
|
||||
redis-rack (>= 2.1.0, < 3)
|
||||
redis-store (>= 1.1.0, < 2)
|
||||
redis-activesupport (5.2.1)
|
||||
activesupport (>= 3, < 7)
|
||||
redis-activesupport (5.3.0)
|
||||
activesupport (>= 3, < 8)
|
||||
redis-store (>= 1.3, < 2)
|
||||
redis-rack (2.1.3)
|
||||
redis-rack (2.1.4)
|
||||
rack (>= 2.0.8, < 3)
|
||||
redis-store (>= 1.2, < 2)
|
||||
redis-rails (5.0.2)
|
||||
redis-actionpack (>= 5.0, < 6)
|
||||
redis-activesupport (>= 5.0, < 6)
|
||||
redis-store (>= 1.2, < 2)
|
||||
redis-store (1.9.0)
|
||||
redis (>= 4, < 5)
|
||||
regexp_parser (2.1.1)
|
||||
request_store (1.5.0)
|
||||
redis-store (1.9.2)
|
||||
redis (>= 4, < 6)
|
||||
regexp_parser (2.8.0)
|
||||
request_store (1.5.1)
|
||||
rack (>= 1.4)
|
||||
responders (3.0.1)
|
||||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
responders (3.1.0)
|
||||
actionpack (>= 5.2)
|
||||
railties (>= 5.2)
|
||||
rexml (3.2.5)
|
||||
rouge (3.26.1)
|
||||
rubocop (1.23.0)
|
||||
rgl (0.6.3)
|
||||
pairing_heap (>= 0.3.0)
|
||||
rexml (~> 3.2, >= 3.2.4)
|
||||
stream (~> 0.5.3)
|
||||
rouge (3.30.0)
|
||||
rubocop (1.42.0)
|
||||
json (~> 2.3)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.0.0.0)
|
||||
parser (>= 3.1.2.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 1.12.0, < 2.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.24.1, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.13.0)
|
||||
parser (>= 3.0.1.1)
|
||||
rubocop-rails (2.12.4)
|
||||
rubocop-ast (1.28.1)
|
||||
parser (>= 3.2.1.0)
|
||||
rubocop-rails (2.19.1)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
ruby-enum (0.9.0)
|
||||
i18n
|
||||
ruby-filemagic (0.7.2-x86_64-linux-musl)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby-statistics (3.0.0)
|
||||
rubocop (>= 1.33.0, < 2.0)
|
||||
ruby-filemagic (0.7.3-x86_64-linux-musl)
|
||||
ruby-progressbar (1.13.0)
|
||||
ruby-statistics (3.0.2)
|
||||
ruby-vips (2.1.4)
|
||||
ffi (~> 1.12)
|
||||
ruby2ruby (2.4.4)
|
||||
ruby2ruby (2.5.0)
|
||||
ruby_parser (~> 3.1)
|
||||
sexp_processor (~> 4.6)
|
||||
ruby_dep (1.5.0)
|
||||
ruby_parser (3.18.1)
|
||||
ruby_parser (3.20.1)
|
||||
sexp_processor (~> 4.16)
|
||||
rubyzip (2.3.2)
|
||||
rugged (1.2.0-x86_64-linux-musl)
|
||||
rugged (1.5.0.1-x86_64-linux-musl)
|
||||
safe_yaml (1.0.6)
|
||||
safely_block (0.3.0)
|
||||
errbase (>= 0.1.1)
|
||||
|
@ -485,58 +506,55 @@ GEM
|
|||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
selenium-webdriver (4.1.0)
|
||||
childprocess (>= 0.5, < 5.0)
|
||||
selenium-webdriver (4.8.6)
|
||||
rexml (~> 3.2, >= 3.2.5)
|
||||
rubyzip (>= 1.2.2)
|
||||
rubyzip (>= 1.2.2, < 3.0)
|
||||
websocket (~> 1.0)
|
||||
semantic_range (3.0.0)
|
||||
sexp_processor (4.16.0)
|
||||
sexp_processor (4.17.0)
|
||||
simpleidn (0.2.1)
|
||||
unf (~> 0.1.4)
|
||||
sourcemap (0.1.1)
|
||||
spree-api-client (0.2.4)
|
||||
fast_blank (~> 1)
|
||||
httparty (~> 0.18.0)
|
||||
spring (2.1.1)
|
||||
spring-watcher-listen (2.0.1)
|
||||
spring (4.1.1)
|
||||
spring-watcher-listen (2.1.0)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
sprockets (4.0.2)
|
||||
spring (>= 4)
|
||||
sprockets (4.2.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.4.1)
|
||||
rack (>= 2.2.4, < 4)
|
||||
sprockets-rails (3.4.2)
|
||||
actionpack (>= 5.2)
|
||||
activesupport (>= 5.2)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.4.2-x86_64-linux-musl)
|
||||
stackprof (0.2.17-x86_64-linux-musl)
|
||||
sucker_punch (3.0.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
sutty-archives (2.5.4)
|
||||
jekyll (>= 3.6, < 5.0)
|
||||
sutty-liquid (0.7.4)
|
||||
sqlite3 (1.6.3-x86_64-linux-musl)
|
||||
mini_portile2 (~> 2.8.0)
|
||||
stackprof (0.2.25-x86_64-linux-musl)
|
||||
stream (0.5.5)
|
||||
sutty-liquid (0.11.11)
|
||||
fast_blank (~> 1.0)
|
||||
jekyll (~> 4)
|
||||
symbol-fstring (1.0.2-x86_64-linux-musl)
|
||||
sysexits (1.2.0)
|
||||
temple (0.8.2)
|
||||
temple (0.10.1)
|
||||
terminal-table (2.0.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
thor (1.1.0)
|
||||
tilt (2.0.10)
|
||||
timecop (0.9.4)
|
||||
thor (1.2.2)
|
||||
tilt (2.1.0)
|
||||
timecop (0.9.6)
|
||||
timeout (0.3.2)
|
||||
turbolinks (5.2.1)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
tzinfo (2.0.4)
|
||||
tzinfo (2.0.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.8-x86_64-linux-musl)
|
||||
unf_ext (0.0.8.2-x86_64-linux-musl)
|
||||
unicode-display_width (1.8.0)
|
||||
validates_hostname (1.0.11)
|
||||
uri-ssh_git (2.0.0)
|
||||
validates_hostname (1.0.13)
|
||||
activerecord (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
warden (1.2.9)
|
||||
|
@ -546,21 +564,21 @@ GEM
|
|||
activemodel (>= 6.0.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 6.0.0)
|
||||
webpacker (5.4.3)
|
||||
webpacker (5.4.4)
|
||||
activesupport (>= 5.2)
|
||||
rack-proxy (>= 0.6.1)
|
||||
railties (>= 5.2)
|
||||
semantic_range (>= 2.3.0)
|
||||
webrick (1.7.0)
|
||||
websocket-driver (0.7.5-x86_64-linux-musl)
|
||||
webrick (1.8.1)
|
||||
websocket (1.2.9)
|
||||
websocket-driver (0.7.6-x86_64-linux-musl)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
zeitwerk (2.5.1)
|
||||
zeitwerk (2.6.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86_64-linux-musl
|
||||
|
||||
DEPENDENCIES
|
||||
|
@ -575,9 +593,11 @@ DEPENDENCIES
|
|||
concurrent-ruby-ext
|
||||
database_cleaner
|
||||
derailed_benchmarks
|
||||
device_detector
|
||||
devise
|
||||
devise-i18n
|
||||
devise_invitable
|
||||
distributed-press-api-client (~> 0.3.0rc0)
|
||||
dotenv-rails
|
||||
down
|
||||
ed25519
|
||||
|
@ -585,9 +605,10 @@ DEPENDENCIES
|
|||
exception_notification
|
||||
factory_bot_rails
|
||||
fast_blank
|
||||
fast_jsonparser
|
||||
fast_jsonparser (~> 0.5.0)
|
||||
flamegraph
|
||||
friendly_id
|
||||
git_clone_url
|
||||
hairtrigger
|
||||
haml-lint
|
||||
hamlit-rails
|
||||
|
@ -597,14 +618,14 @@ DEPENDENCIES
|
|||
image_processing
|
||||
inline_svg
|
||||
jbuilder (~> 2.5)
|
||||
jekyll (~> 4.2)
|
||||
jekyll-commonmark
|
||||
jekyll (~> 4.2.0)
|
||||
jekyll-commonmark (~> 1.4.0)
|
||||
jekyll-data
|
||||
jekyll-images
|
||||
jekyll-include-cache
|
||||
kaminari
|
||||
letter_opener
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
listen
|
||||
loaf
|
||||
lockbox
|
||||
lograge
|
||||
|
@ -619,26 +640,28 @@ DEPENDENCIES
|
|||
pry
|
||||
puma
|
||||
pundit
|
||||
que
|
||||
rack-cors
|
||||
rack-mini-profiler
|
||||
rails (~> 6)
|
||||
rails (~> 6.1.0)
|
||||
rails-i18n
|
||||
rails_warden
|
||||
redis
|
||||
redis (~> 4.0)
|
||||
redis-rails
|
||||
rgl
|
||||
rollups!
|
||||
rubocop-rails
|
||||
rubyzip
|
||||
rugged
|
||||
rugged (= 1.5.0.1)
|
||||
safe_yaml
|
||||
safely_block (~> 0.3.0)
|
||||
sassc-rails
|
||||
selenium-webdriver
|
||||
selenium-webdriver (~> 4.8.0)
|
||||
sourcemap
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
spring-watcher-listen
|
||||
sqlite3
|
||||
stackprof
|
||||
sucker_punch
|
||||
sutty-liquid (>= 0.7.3)
|
||||
symbol-fstring
|
||||
terminal-table
|
||||
|
@ -646,12 +669,12 @@ DEPENDENCIES
|
|||
turbolinks (~> 5)
|
||||
uglifier (>= 1.3.0)
|
||||
validates_hostname
|
||||
web-console (>= 3.3.0)
|
||||
web-console
|
||||
webpacker
|
||||
yaml_db!
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.7.1p83
|
||||
ruby 3.1.4p223
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.2
|
||||
2.4.17
|
||||
|
|
20
Makefile
20
Makefile
|
@ -48,8 +48,6 @@ help: always ## Ayuda
|
|||
@echo -e "\nArgumentos:\n"
|
||||
@grep -E "^[a-z\-]+ \?=.*##" Makefile | sed -re "s/(.*) \?=.*##(.*)/\1;\2/" | column -s ";" -t | sed -re "s/^([^ ]+) /\x1B[38;5;197m\1\x1B[0m/"
|
||||
|
||||
assets: public/packs/manifest.json.br ## Compilar los assets
|
||||
|
||||
test: always ## Ejecutar los tests
|
||||
$(MAKE) rake args="test RAILS_ENV=test $(args)"
|
||||
|
||||
|
@ -71,14 +69,14 @@ rake: ## Corre rake dentro del entorno de desarrollo (pasar argumentos con args=
|
|||
bundle: ## Corre bundle dentro del entorno de desarrollo (pasar argumentos con args=).
|
||||
$(hain) 'bundle $(args)'
|
||||
|
||||
psql := psql -h $(PG_HOST) -U $(PG_USER) -p $(PG_PORT) -d sutty
|
||||
psql := psql $(DATABASE_URL)
|
||||
copy-table:
|
||||
test -n "$(table)"
|
||||
echo "truncate $(table) $(cascade);" | $(psql)
|
||||
ssh $(delegate) docker exec postgresql pg_dump -U sutty -d sutty -t $(table) | $(psql)
|
||||
|
||||
psql:
|
||||
$(psql)
|
||||
$(hain) $(psql)
|
||||
|
||||
rubocop: ## Yutea el código que está por ser commiteado
|
||||
git status --porcelain \
|
||||
|
@ -110,21 +108,13 @@ save: ## Subir la imagen Docker al nodo delegado
|
|||
date +%F | xargs -I {} git tag -f $(container)-{}
|
||||
@echo -e "\a"
|
||||
|
||||
ota-js: assets ## Actualizar Javascript en el nodo delegado
|
||||
rsync -avi --delete-after --chown 1000:82 public/ root@$(delegate):/srv/sutty/srv/http/data/_$(public)/
|
||||
ssh root@$(delegate) docker exec $(container) sh -c "cat /srv/http/tmp/puma.pid | xargs -r kill -USR2"
|
||||
|
||||
ota: ## Actualizar Rails en el nodo delegado
|
||||
ssh $(delegate) git -C /srv/sutty/srv/http/panel.sutty.nl pull ; true
|
||||
git push
|
||||
ssh $(delegate) git -C /srv/sutty/srv/http/panel.sutty.nl pull
|
||||
ssh $(delegate) git -C /srv/sutty/srv/http/panel.sutty.nl lfs prune
|
||||
ssh $(delegate) chown -R 1000:82 /srv/sutty/srv/http/panel.sutty.nl
|
||||
ssh $(delegate) docker exec $(container) rails reload
|
||||
|
||||
# Todos los archivos de assets. Si alguno cambia, se van a recompilar
|
||||
# los assets que luego se suben al nodo delegado.
|
||||
assets := package.json yarn.lock $(shell find app/assets/ app/javascript/ -type f)
|
||||
public/packs/manifest.json.br: $(assets)
|
||||
$(hain) 'PANEL_URL=https://panel.sutty.nl RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile assets:clean'
|
||||
|
||||
# Correr un test en particular por ejemplo
|
||||
# `make test/models/usuarie_test.rb`
|
||||
tests := $(shell find test/ -name "*_test.rb")
|
||||
|
|
9
Procfile
9
Procfile
|
@ -1,2 +1,11 @@
|
|||
migrate: bundle exec rake db:prepare db:seed
|
||||
sutty: bundle exec puma config.ru
|
||||
blazer_5m: bundle exec rake blazer:run_checks SCHEDULE="5 minutes"
|
||||
blazer_1h: bundle exec rake blazer:run_checks SCHEDULE="1 hour"
|
||||
blazer_1d: bundle exec rake blazer:run_checks SCHEDULE="1 day"
|
||||
blazer: bundle exec rake blazer:send_failing_checks
|
||||
prometheus: bundle exec prometheus_exporter -b 0.0.0.0 --prefix "sutty_"
|
||||
distributed_press_tokens_renew: bundle exec rake distributed_press:tokens:renew
|
||||
cleanup: bundle exec rake cleanup:everything
|
||||
stats: bundle exec rake stats:process_all
|
||||
que: daemonize -c /srv/ -p /srv/tmp/que.pid -u rails /usr/local/bin/syslogize bundle exec que
|
||||
|
|
|
@ -16,7 +16,7 @@ $primary: $magenta;
|
|||
$secondary: $black;
|
||||
$jumbotron-bg: transparent;
|
||||
$enable-rounded: false;
|
||||
$form-feedback-valid-color: $cyan;
|
||||
$form-feedback-valid-color: $black;
|
||||
$form-feedback-invalid-color: $magenta;
|
||||
$form-feedback-icon-valid-color: $black;
|
||||
$component-active-bg: $magenta;
|
||||
|
@ -29,6 +29,11 @@ $sizes: (
|
|||
"70ch": 70ch,
|
||||
);
|
||||
|
||||
.btn {
|
||||
background-color: var(--foreground);
|
||||
color: var(--background);
|
||||
}
|
||||
|
||||
@import "bootstrap";
|
||||
@import "editor";
|
||||
|
||||
|
@ -158,6 +163,12 @@ ol.breadcrumb {
|
|||
transition: all 3s;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
legend {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.mapable,
|
||||
.taggable {
|
||||
.input-map,
|
||||
|
@ -198,8 +209,6 @@ svg {
|
|||
}
|
||||
|
||||
.btn {
|
||||
background-color: var(--foreground);
|
||||
color: var(--background);
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
margin-right: 0.3rem;
|
||||
|
@ -377,6 +386,9 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
|
|||
}
|
||||
}
|
||||
|
||||
.word-break-all { word-break: break-all !important; }
|
||||
.hyphens { hyphens: auto; }
|
||||
|
||||
/*
|
||||
* Modificadores de Bootstrap que no tienen versión responsive.
|
||||
*/
|
||||
|
@ -399,6 +411,8 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
|
|||
.text-#{$grid-breakpoint}-right { text-align: right !important; }
|
||||
.text-#{$grid-breakpoint}-center { text-align: center !important; }
|
||||
|
||||
.word-break-#{$grid-breakpoint}-all { word-break: break-all !important; }
|
||||
|
||||
// posición
|
||||
@each $position in $positions {
|
||||
.position-#{$grid-breakpoint}-#{$position} { position: $position !important; }
|
||||
|
|
|
@ -18,7 +18,7 @@ module Api
|
|||
|
||||
# Si todo salió bien, enviar los correos y redirigir al sitio.
|
||||
# El sitio nos dice a dónde tenemos que ir.
|
||||
ContactJob.perform_async site.id,
|
||||
ContactJob.perform_later site.id,
|
||||
params[:form],
|
||||
contact_params.to_h.symbolize_keys,
|
||||
params[:redirect]
|
||||
|
|
|
@ -10,7 +10,7 @@ module Api
|
|||
# solo si la API key es verificable. Del otro lado siempre
|
||||
# respondemos con lo mismo.
|
||||
def create
|
||||
if site&.airbrake_valid? airbrake_token
|
||||
if (site&.airbrake_valid? airbrake_token) && !detected_device.bot?
|
||||
BacktraceJob.perform_later site_id: params[:site_id],
|
||||
params: airbrake_params.to_h
|
||||
end
|
||||
|
@ -34,6 +34,11 @@ module Api
|
|||
def airbrake_token
|
||||
@airbrake_token ||= params[:key]
|
||||
end
|
||||
|
||||
# @return [DeviceDetector]
|
||||
def detected_device
|
||||
@detected_device ||= DeviceDetector.new(request.headers['User-Agent'], request.headers)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,31 +12,6 @@ module Api
|
|||
render json: sites_names + alternative_names + api_names + www_names
|
||||
end
|
||||
|
||||
# Sitios con hidden service de Tor
|
||||
#
|
||||
# @return [Array] lista de nombres de sitios sin onion aun
|
||||
def hidden_services
|
||||
render json: DeployHiddenService.where(values: nil).includes(:site).pluck(:name)
|
||||
end
|
||||
|
||||
# Tor va a enviar el onion junto con el nombre del sitio y tenemos
|
||||
# que guardarlo en su deploy_hidden_service.
|
||||
#
|
||||
# @params [String] name
|
||||
# @params [String] onion
|
||||
def add_onion
|
||||
site = Site.find_by(name: params[:name])
|
||||
|
||||
if site
|
||||
usuarie = GitAuthor.new email: "tor@#{Site.domain}", name: 'Tor'
|
||||
service = SiteService.new site: site, usuarie: usuarie,
|
||||
params: params
|
||||
service.add_onion
|
||||
end
|
||||
|
||||
head :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def canonicalize(name)
|
||||
|
|
77
app/controllers/api/v1/webhooks_controller.rb
Normal file
77
app/controllers/api/v1/webhooks_controller.rb
Normal file
|
@ -0,0 +1,77 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Api
|
||||
module V1
|
||||
# Recibe webhooks y lanza un PullJob
|
||||
class WebhooksController < BaseController
|
||||
# responde con forbidden si falla la validación del token
|
||||
rescue_from ActiveRecord::RecordNotFound, with: :platforms_answer
|
||||
|
||||
# Trae los cambios a partir de un post de Webhooks:
|
||||
# (Gitlab, Github, Gitea, etc)
|
||||
#
|
||||
# @return [nil]
|
||||
def pull
|
||||
message = I18n.with_locale(site.default_locale) do
|
||||
I18n.t('webhooks.pull.message')
|
||||
end
|
||||
|
||||
GitPullJob.perform_later(site, usuarie, message)
|
||||
head :ok
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# encuentra el sitio a partir de la url
|
||||
def site
|
||||
@site ||= Site.find_by_name!(params[:site_id])
|
||||
end
|
||||
|
||||
# valida el token que envía la plataforma del webhook
|
||||
#
|
||||
# @return [String]
|
||||
def token
|
||||
@token ||=
|
||||
begin
|
||||
# Gitlab
|
||||
if request.headers['X-Gitlab-Token'].present?
|
||||
request.headers['X-Gitlab-Token']
|
||||
# Github
|
||||
elsif request.headers['X-Hub-Signature-256'].present?
|
||||
token_from_signature(request.headers['X-Hub-Signature-256'], 'sha256=')
|
||||
# Gitea
|
||||
elsif request.headers['X-Gitea-Signature'].present?
|
||||
token_from_signature(request.headers['X-Gitea-Signature'])
|
||||
else
|
||||
raise ActiveRecord::RecordNotFound, 'proveedor no soportado'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# valida token a partir de firma de webhook
|
||||
#
|
||||
# @return [String, Boolean]
|
||||
def token_from_signature(signature, prepend = '')
|
||||
payload = request.body.read
|
||||
site.roles.where(temporal: false, rol: 'usuarie').pluck(:token).find do |token|
|
||||
new_signature = prepend + OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), token, payload)
|
||||
ActiveSupport::SecurityUtils.secure_compare(new_signature, signature.to_s)
|
||||
end.tap do |t|
|
||||
raise ActiveRecord::RecordNotFound, 'token no encontrado' if t.nil?
|
||||
end
|
||||
end
|
||||
|
||||
# encuentra le usuarie
|
||||
def usuarie
|
||||
@usuarie ||= site.roles.find_by!(temporal: false, rol: 'usuarie', token: token).usuarie
|
||||
end
|
||||
|
||||
# respuesta de error a plataformas
|
||||
def platforms_answer(exception)
|
||||
ExceptionNotifier.notify_exception(exception, data: { headers: request.headers.to_h }
|
||||
|
||||
head :forbidden
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
before_action :prepare_exception_notifier
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
before_action :notify_unconfirmed_email, unless: :devise_controller?
|
||||
around_action :set_locale
|
||||
|
||||
rescue_from Pundit::NilPolicyError, with: :page_not_found
|
||||
|
@ -27,6 +28,15 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
private
|
||||
|
||||
def notify_unconfirmed_email
|
||||
return unless current_usuarie
|
||||
return if current_usuarie.confirmed?
|
||||
|
||||
I18n.with_locale(current_usuarie.lang) do
|
||||
flash[:notice] ||= I18n.t('devise.registrations.signed_up')
|
||||
end
|
||||
end
|
||||
|
||||
def uuid?(string)
|
||||
/[a-f0-9]{8}-([a-f0-9]{4}-){3}[a-f0-9]{12}/ =~ string
|
||||
end
|
||||
|
@ -49,7 +59,11 @@ class ApplicationController < ActionController::Base
|
|||
#
|
||||
# @return [String,Symbol]
|
||||
def current_locale
|
||||
session[:locale] = params[:change_locale_to] if params[:change_locale_to].present?
|
||||
locale = params[:change_locale_to]
|
||||
|
||||
if locale.present? && I18n.locale_available?(locale)
|
||||
session[:locale] = params[:change_locale_to]
|
||||
end
|
||||
|
||||
session[:locale] || current_usuarie&.lang || I18n.locale
|
||||
end
|
||||
|
@ -81,9 +95,14 @@ class ApplicationController < ActionController::Base
|
|||
breadcrumb 'stats.index', root_path, match: :exact
|
||||
end
|
||||
|
||||
def site
|
||||
@site ||= find_site
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.permit(:sign_up, keys: Usuarie::CONSENT_FIELDS)
|
||||
devise_parameter_sanitizer.permit(:account_update, keys: %i[lang])
|
||||
end
|
||||
|
||||
|
|
46
app/controllers/build_stats_controller.rb
Normal file
46
app/controllers/build_stats_controller.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# La lista de estados de compilación, por ahora solo mostramos el último
|
||||
# estado.
|
||||
class BuildStatsController < ApplicationController
|
||||
include ActionView::Helpers::NumberHelper
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
before_action :authenticate_usuarie!
|
||||
|
||||
breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path
|
||||
breadcrumb 'sites.index', :sites_path, match: :exact
|
||||
breadcrumb -> { site.title }, -> { site_posts_path(site, locale: locale) }, match: :exact
|
||||
|
||||
def index
|
||||
authorize SiteBuildStat.new(site)
|
||||
breadcrumb I18n.t('build_stats.index.title'), ''
|
||||
|
||||
@headers = %w[type url seconds size].map do |header|
|
||||
t("deploy_mailer.deployed.th.#{header}")
|
||||
end
|
||||
|
||||
@table = site.deployment_list.map do |deploy|
|
||||
type = deploy.class.name.underscore
|
||||
urls = deploy.urls.map do |url|
|
||||
URI.parse(url)
|
||||
rescue URI::Error
|
||||
nil
|
||||
end.compact
|
||||
|
||||
urls = [nil] if urls.empty?
|
||||
build_stat = deploy.build_stats.where(status: true).last
|
||||
seconds = build_stat&.seconds || 0
|
||||
|
||||
{
|
||||
title: t("deploy_mailer.deployed.#{type}.title"),
|
||||
urls: urls,
|
||||
seconds: {
|
||||
human: distance_of_time_in_words(seconds),
|
||||
machine: "PT#{seconds}S"
|
||||
},
|
||||
size: number_to_human_size(build_stat&.bytes || 0, precision: 2)
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,6 +5,7 @@ class EnvController < ActionController::Base
|
|||
|
||||
def index
|
||||
@site = Site.find_by_name('panel')
|
||||
stale? @site
|
||||
|
||||
stale? @site if @site
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,7 @@ class PostsController < ApplicationController
|
|||
|
||||
# Todos los artículos de este sitio para el idioma actual
|
||||
@posts = site.indexed_posts.where(locale: locale)
|
||||
@posts = @posts.page(filter_params.delete(:page)) if site.pagination
|
||||
# De este tipo
|
||||
@posts = @posts.where(layout: filter_params[:layout]) if filter_params[:layout]
|
||||
# Que estén dentro de la categoría
|
||||
|
@ -154,15 +155,11 @@ class PostsController < ApplicationController
|
|||
#
|
||||
# @return [Hash]
|
||||
def filter_params
|
||||
@filter_params ||= params.permit(:q, :category, :layout).to_hash.select do |_, v|
|
||||
@filter_params ||= params.permit(:q, :category, :layout, :page).to_hash.select do |_, v|
|
||||
v.present?
|
||||
end.transform_keys(&:to_sym)
|
||||
end
|
||||
|
||||
def site
|
||||
@site ||= find_site
|
||||
end
|
||||
|
||||
def post
|
||||
@post ||= site.posts(lang: locale).find(params[:post_id] || params[:id])
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ class SitesController < ApplicationController
|
|||
# Ver un listado de sitios
|
||||
def index
|
||||
authorize Site
|
||||
@sites = current_usuarie.sites.order(:title)
|
||||
@sites = current_usuarie.sites.order(updated_at: :desc)
|
||||
|
||||
fresh_when @sites
|
||||
end
|
||||
|
@ -28,8 +28,6 @@ class SitesController < ApplicationController
|
|||
|
||||
@site = Site.new
|
||||
authorize @site
|
||||
|
||||
@site.deploys.build type: 'DeployLocal'
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -59,6 +57,7 @@ class SitesController < ApplicationController
|
|||
usuarie: current_usuarie)
|
||||
|
||||
if service.update.valid?
|
||||
flash[:notice] = I18n.t('sites.update.post')
|
||||
redirect_to site_posts_path(site, locale: site.default_locale)
|
||||
else
|
||||
render 'edit'
|
||||
|
|
|
@ -47,7 +47,7 @@ class UsuariesController < ApplicationController
|
|||
@usuarie = Usuarie.find(params[:usuarie_id])
|
||||
|
||||
if @site.usuaries.count > 1
|
||||
@usuarie.rol_for_site(@site).update_attribute :rol, 'invitade'
|
||||
@usuarie.rol_for_site(@site).update_attribute :rol, Rol::INVITADE
|
||||
else
|
||||
flash[:warning] = I18n.t('usuaries.index.demote.denied')
|
||||
end
|
||||
|
@ -61,7 +61,7 @@ class UsuariesController < ApplicationController
|
|||
authorize SiteUsuarie.new(@site, current_usuarie)
|
||||
|
||||
@usuarie = Usuarie.find(params[:usuarie_id])
|
||||
@usuarie.rol_for_site(@site).update_attribute :rol, 'usuarie'
|
||||
@usuarie.rol_for_site(@site).update_attribute :rol, Rol::USUARIE
|
||||
|
||||
redirect_to site_usuaries_path
|
||||
end
|
||||
|
@ -72,6 +72,8 @@ class UsuariesController < ApplicationController
|
|||
site_usuarie = SiteUsuarie.new(@site, current_usuarie)
|
||||
authorize site_usuarie
|
||||
|
||||
params[:invite_as] = invite_as
|
||||
|
||||
@policy = policy(site_usuarie)
|
||||
end
|
||||
|
||||
|
@ -81,27 +83,33 @@ class UsuariesController < ApplicationController
|
|||
authorize SiteUsuarie.new(@site, current_usuarie)
|
||||
|
||||
# Enviar la invitación si es necesario y agregar al sitio
|
||||
invitaciones.each do |invitacion|
|
||||
# Si la cuenta no existe, envía una invitación por correo, sino,
|
||||
# no se envía nada
|
||||
#
|
||||
# TODO: Enviar invitación igual! Podemos no usar el Mailer de
|
||||
# DeviseInvitations y usar uno propio que contenga texto y se
|
||||
# envíe de todas formas.
|
||||
usuarie = Usuarie.invite! email: invitacion.address,
|
||||
skip_invitation: true
|
||||
invitaciones.each do |address|
|
||||
next if Usuarie.where(id: @site.roles.pluck(:usuarie_id)).find_by_email(address)
|
||||
|
||||
# No invitar al sitio si ya estaba en la lista!
|
||||
#
|
||||
# XXX: En este caso no estamos enviando ninguna invitación
|
||||
next if usuarie.sites.exists? @site.id
|
||||
Usuarie.transaction do
|
||||
usuarie = Usuarie.find_by_email(address)
|
||||
usuarie ||= Usuarie.invite!({ email: address, skip_invitation: true }).tap do |u|
|
||||
u.send :generate_invitation_token!
|
||||
end
|
||||
|
||||
@site.roles << Rol.create(usuarie: usuarie, site: @site,
|
||||
temporal: true, rol: invited_as)
|
||||
role = @site.roles.create(usuarie: usuarie, temporal: true, rol: invited_as)
|
||||
|
||||
# XXX: La invitación tiene que ser enviada luego de crear el rol
|
||||
if role.persisted?
|
||||
# Si es una cuenta manual que no está confirmada aun,
|
||||
# aprovechar para reconfirmarla.
|
||||
if !usuarie.confirmed? && !usuarie.created_by_invite?
|
||||
usuarie.confirmation_token = nil
|
||||
usuarie.send :generate_confirmation_token!
|
||||
end
|
||||
|
||||
# Invitamos después de crear el rol para que el correo de
|
||||
# invitación pueda recibir el sitio.
|
||||
usuarie.deliver_invitation
|
||||
else
|
||||
raise ArgumentError, role.errors.full_messages
|
||||
end
|
||||
rescue ArgumentError => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: @site.name, address: address })
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to site_usuaries_path(@site)
|
||||
|
@ -142,6 +150,8 @@ class UsuariesController < ApplicationController
|
|||
private
|
||||
|
||||
# Traer todas las invitaciones que al menos tengan usuarie y dominio
|
||||
#
|
||||
# @return [Array]
|
||||
def invitaciones
|
||||
# XXX: Podríamos usar EmailAddress pero hace chequeos más lentos
|
||||
params[:invitaciones]&.tr("\r", '')&.split("\n")&.map do |m|
|
||||
|
@ -150,17 +160,19 @@ class UsuariesController < ApplicationController
|
|||
nil
|
||||
end.compact.select do |m|
|
||||
m.local && m.domain
|
||||
end
|
||||
end.map(&:address)
|
||||
end
|
||||
|
||||
# El tipo de invitación que tenemos que enviar, si alguien mandó
|
||||
# cualquier cosa, usamos el privilegio menor.
|
||||
#
|
||||
# @return [String]
|
||||
def invited_as
|
||||
if Rol::ROLES.include?(params[:invited_as])
|
||||
params[:invited_as]
|
||||
else
|
||||
'invitade'
|
||||
Rol.role?(params[:invited_as]) ? params[:invited_as] : Rol::INVITADE
|
||||
end
|
||||
|
||||
def invite_as
|
||||
Rol.role?(params[:invite_as]&.singularize) ? params[:invite_as] : Rol::INVITADE.pluralize
|
||||
end
|
||||
|
||||
def site
|
||||
|
|
|
@ -2,11 +2,21 @@
|
|||
|
||||
import { Notifier } from '@airbrake/browser'
|
||||
|
||||
window.airbrake = new Notifier({
|
||||
projectId: window.env.AIRBRAKE_SITE_ID,
|
||||
projectKey: window.env.AIRBRAKE_API_KEY,
|
||||
try {
|
||||
window.airbrake = new Notifier({
|
||||
projectId: window.env.AIRBRAKE_PROJECT_ID,
|
||||
projectKey: window.env.AIRBRAKE_PROJECT_KEY,
|
||||
host: window.env.PANEL_URL
|
||||
})
|
||||
});
|
||||
|
||||
console.originalError = console.error;
|
||||
console.error = (...e) => {
|
||||
window.airbrake.notify(e.join(" "));
|
||||
return console.originalError(...e);
|
||||
};
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
import 'core-js/stable'
|
||||
import 'regenerator-runtime/runtime'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Base para trabajos
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
include SuckerPunch::Job
|
||||
include Que::ActiveJob::JobExtensions
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@ class BacktraceJob < ApplicationJob
|
|||
|
||||
EMPTY_SOURCEMAP = { 'mappings' => '' }.freeze
|
||||
|
||||
queue_as :low_priority
|
||||
|
||||
attr_reader :params, :site_id
|
||||
|
||||
def perform(site_id:, params:)
|
||||
|
|
|
@ -4,9 +4,21 @@
|
|||
class DeployJob < ApplicationJob
|
||||
class DeployException < StandardError; end
|
||||
class DeployTimedOutException < DeployException; end
|
||||
class DeployAlreadyRunningException < DeployException; end
|
||||
|
||||
discard_on ActiveRecord::RecordNotFound
|
||||
|
||||
# Lanzar lo antes posible
|
||||
self.priority = 10
|
||||
|
||||
def handle_error(error)
|
||||
case error
|
||||
when DeployAlreadyRunningException then retry_in 1.minute
|
||||
when DeployTimedOutException then expire
|
||||
else super
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def perform(site, notify: true, time: Time.now, output: false)
|
||||
@output = output
|
||||
|
@ -20,89 +32,106 @@ class DeployJob < ApplicationJob
|
|||
# Como el trabajo actual se aplaza al siguiente, arrastrar la
|
||||
# hora original para poder ir haciendo timeouts.
|
||||
if @site.building?
|
||||
if 10.minutes.ago >= time
|
||||
notify = false
|
||||
|
||||
if 10.minutes.ago >= time
|
||||
raise DeployTimedOutException,
|
||||
"#{@site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original"
|
||||
else
|
||||
raise DeployAlreadyRunningException
|
||||
end
|
||||
end
|
||||
|
||||
DeployJob.perform_in(60, site, notify: notify, time: time, output: output)
|
||||
return
|
||||
end
|
||||
|
||||
@deployed = {}
|
||||
@site.update status: 'building'
|
||||
# Asegurarse que DeployLocal sea el primero!
|
||||
@deployed = {
|
||||
deploy_local: {
|
||||
status: deploy_locally,
|
||||
seconds: deploy_local.build_stats.last.seconds,
|
||||
size: deploy_local.size,
|
||||
urls: [deploy_local.url]
|
||||
}
|
||||
}
|
||||
@site.deployment_list.each do |d|
|
||||
begin
|
||||
raise DeployException, 'Una dependencia falló' if failed_dependencies? d
|
||||
|
||||
# No es opcional
|
||||
unless @deployed[:deploy_local][:status]
|
||||
# Hacer fallar la tarea
|
||||
raise DeployException, "#{@site.name}: Falló la compilación"
|
||||
status = d.deploy(output: @output)
|
||||
seconds = d.build_stats.last.try(:seconds) || 0
|
||||
size = d.size
|
||||
urls = d.urls.map do |url|
|
||||
URI.parse url
|
||||
rescue URI::Error
|
||||
nil
|
||||
end.compact
|
||||
|
||||
if d == @site.deployment_list.last && !status
|
||||
raise DeployException, 'Falló la compilación'
|
||||
end
|
||||
rescue StandardError => e
|
||||
status = false
|
||||
seconds ||= 0
|
||||
size ||= 0
|
||||
# XXX: Hace que se vea la tabla
|
||||
urls ||= [nil]
|
||||
|
||||
notify_exception e, d
|
||||
end
|
||||
|
||||
deploy_others
|
||||
rescue DeployTimedOutException => e
|
||||
notify_exception e
|
||||
rescue DeployException => e
|
||||
notify_exception e, deploy_local
|
||||
@deployed[d.type.underscore.to_sym] = {
|
||||
status: status,
|
||||
seconds: seconds,
|
||||
size: size,
|
||||
urls: urls
|
||||
}
|
||||
end
|
||||
|
||||
return unless @output
|
||||
|
||||
puts (Terminal::Table.new do |t|
|
||||
t << (%w[type] + @deployed.values.first.keys)
|
||||
t.add_separator
|
||||
@deployed.each do |type, row|
|
||||
t << ([type.to_s] + row.values)
|
||||
end
|
||||
end)
|
||||
ensure
|
||||
@site&.update status: 'waiting'
|
||||
if @site.present?
|
||||
@site.update status: 'waiting'
|
||||
|
||||
notify_usuaries if notify
|
||||
|
||||
puts "\a" if @output
|
||||
end
|
||||
end
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
private
|
||||
|
||||
# Detecta si un método de publicación tiene dependencias fallidas
|
||||
#
|
||||
# @param :deploy [Deploy]
|
||||
# @return [Boolean]
|
||||
def failed_dependencies?(deploy)
|
||||
failed_dependencies(deploy).present?
|
||||
end
|
||||
|
||||
# Obtiene las dependencias fallidas de un deploy
|
||||
#
|
||||
# @param :deploy [Deploy]
|
||||
# @return [Array]
|
||||
def failed_dependencies(deploy)
|
||||
deploy.class::DEPENDENCIES & (@deployed.reject do |_, v|
|
||||
v[:status]
|
||||
end.keys)
|
||||
end
|
||||
|
||||
# @param :exception [StandardError]
|
||||
# @param :deploy [Deploy]
|
||||
def notify_exception(exception, deploy = nil)
|
||||
data = {
|
||||
site: @site.id,
|
||||
deploy: deploy&.type,
|
||||
log: deploy&.build_stats&.last&.log
|
||||
log: deploy&.build_stats&.last&.log,
|
||||
failed_dependencies: (failed_dependencies(deploy) if deploy)
|
||||
}
|
||||
|
||||
ExceptionNotifier.notify_exception(exception, data: data)
|
||||
end
|
||||
|
||||
def deploy_local
|
||||
@deploy_local ||= @site.deploys.find_by(type: 'DeployLocal')
|
||||
end
|
||||
|
||||
def deploy_locally
|
||||
deploy_local.deploy(output: @output)
|
||||
end
|
||||
|
||||
def deploy_others
|
||||
@site.deploys.where.not(type: 'DeployLocal').find_each do |d|
|
||||
begin
|
||||
status = d.deploy(output: @output)
|
||||
seconds = d.build_stats.last.try(:seconds)
|
||||
rescue StandardError => e
|
||||
status = false
|
||||
seconds = 0
|
||||
|
||||
notify_exception e, d
|
||||
end
|
||||
|
||||
@deployed[d.type.underscore.to_sym] = {
|
||||
status: status,
|
||||
seconds: seconds || 0,
|
||||
size: d.size,
|
||||
urls: d.respond_to?(:urls) ? d.urls : [d.url].compact
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def notify_usuaries
|
||||
@site.roles.where(rol: 'usuarie', temporal: false).pluck(:usuarie_id).each do |usuarie|
|
||||
DeployMailer.with(usuarie: usuarie, site: @site.id)
|
||||
|
|
16
app/jobs/git_pull_job.rb
Normal file
16
app/jobs/git_pull_job.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Permite traer los cambios desde webhooks
|
||||
|
||||
class GitPullJob < ApplicationJob
|
||||
# @param :site [Site]
|
||||
# @param :usuarie [Usuarie]
|
||||
# @return [nil]
|
||||
def perform(site, usuarie)
|
||||
return unless site.repository.origin
|
||||
return unless site.repository.fetch.positive?
|
||||
|
||||
site.repository.merge(usuarie)
|
||||
site.reindex_changes!
|
||||
end
|
||||
end
|
11
app/jobs/git_push_job.rb
Normal file
11
app/jobs/git_push_job.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Permite pushear los cambios cada vez que se
|
||||
# hacen commits en un sitio
|
||||
class GitPushJob < ApplicationJob
|
||||
# @param :site [Site]
|
||||
# @return [nil]
|
||||
def perform(site)
|
||||
site.repository.push if site.repository.origin
|
||||
end
|
||||
end
|
|
@ -10,13 +10,11 @@ class GitlabNotifierJob < ApplicationJob
|
|||
# Variables que vamos a acceder luego
|
||||
attr_reader :exception, :options, :issue_data, :cached
|
||||
|
||||
queue_as :low_priority
|
||||
|
||||
# @param [Exception] la excepción lanzada
|
||||
# @param [Hash] opciones de ExceptionNotifier
|
||||
def perform(exception, **options)
|
||||
@exception = exception
|
||||
@options = options
|
||||
@options = fix_options options
|
||||
@issue_data = { count: 1 }
|
||||
# Necesitamos saber si el issue ya existía
|
||||
@cached = false
|
||||
|
@ -37,7 +35,7 @@ class GitlabNotifierJob < ApplicationJob
|
|||
}
|
||||
end
|
||||
|
||||
unless @issue['iid']
|
||||
if @issue['iid'].blank? && issue_data[:issue].blank?
|
||||
Rails.cache.delete(cache_key)
|
||||
raise GitlabNotifierError, @issue.dig('message', 'title')&.join(', ')
|
||||
end
|
||||
|
@ -61,9 +59,9 @@ class GitlabNotifierJob < ApplicationJob
|
|||
Rails.cache.write(cache_key, issue_data)
|
||||
# Si este trabajo genera una excepción va a entrar en un loop, así que
|
||||
# la notificamos por correo
|
||||
rescue Exception => e
|
||||
email_notification.call(e)
|
||||
email_notification.call(exception, options)
|
||||
rescue StandardError => e
|
||||
email_notification.call(e, data: @issue)
|
||||
email_notification.call(exception, data: @options)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -84,10 +82,15 @@ class GitlabNotifierJob < ApplicationJob
|
|||
exception.class.name,
|
||||
Digest::SHA1.hexdigest(exception.message),
|
||||
Digest::SHA1.hexdigest(backtrace&.first.to_s),
|
||||
Digest::SHA1.hexdigest(options.dig(:data, :params, 'errors').to_s)
|
||||
Digest::SHA1.hexdigest(errors.to_s)
|
||||
].join('/')
|
||||
end
|
||||
|
||||
# @return [Array]
|
||||
def errors
|
||||
options.dig(:data, :params, 'errors') || []
|
||||
end
|
||||
|
||||
# Define si es una excepción de javascript o local
|
||||
#
|
||||
# @see BacktraceJob
|
||||
|
@ -126,6 +129,7 @@ class GitlabNotifierJob < ApplicationJob
|
|||
# @return [String]
|
||||
def body
|
||||
@body ||= ''.dup.tap do |b|
|
||||
b << log_section
|
||||
b << request_section
|
||||
b << javascript_footer
|
||||
b << data_section
|
||||
|
@ -162,14 +166,16 @@ class GitlabNotifierJob < ApplicationJob
|
|||
|
||||
# @return [String]
|
||||
def log_section
|
||||
return '' unless options[:log]
|
||||
return '' unless options.dig(:data, :log)
|
||||
|
||||
<<~LOG
|
||||
# Log
|
||||
|
||||
# Build log
|
||||
|
||||
```
|
||||
#{options[:log]}
|
||||
#{options[:data].delete(:log)}
|
||||
```
|
||||
|
||||
LOG
|
||||
end
|
||||
|
||||
|
@ -257,8 +263,8 @@ class GitlabNotifierJob < ApplicationJob
|
|||
|
||||
## Data
|
||||
|
||||
```
|
||||
#{pp options[:data]}
|
||||
```yaml
|
||||
#{options[:data].to_yaml}
|
||||
```
|
||||
|
||||
DATA
|
||||
|
@ -279,4 +285,16 @@ class GitlabNotifierJob < ApplicationJob
|
|||
def url
|
||||
@url ||= request&.url || options.dig(:data, :params, 'context', 'url')
|
||||
end
|
||||
|
||||
# Define llaves necesarias
|
||||
#
|
||||
# @param :options [Hash]
|
||||
# @return [Hash]
|
||||
def fix_options(options)
|
||||
options = { data: options } unless options.is_a? Hash
|
||||
options[:data] ||= {}
|
||||
options[:data][:params] ||= {}
|
||||
|
||||
options
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
# bundle exec rails c
|
||||
# m = Maintenance.create message_en: 'reason', message_es: 'razón',
|
||||
# estimated_from: Time.now, estimated_to: Time.now + 1.hour
|
||||
# MaintenanceJob.perform_async(maintenance_id: m.id)
|
||||
# MaintenanceJob.perform_later(maintenance_id: m.id)
|
||||
#
|
||||
# Lo mismo para salir de mantenimiento, agregando el atributo
|
||||
# are_we_back: true al crear el Maintenance.
|
||||
|
|
17
app/jobs/renew_distributed_press_tokens_job.rb
Normal file
17
app/jobs/renew_distributed_press_tokens_job.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Renueva los tokens de Distributed Press antes que se venzan,
|
||||
# activando los callbacks que hacen que se refresque el token.
|
||||
class RenewDistributedPressTokensJob < ApplicationJob
|
||||
# Renueva todos los tokens a punto de vencer o informa el error sin
|
||||
# detener la tarea si algo pasa.
|
||||
def perform
|
||||
DistributedPressPublisher.with_about_to_expire_tokens.find_each do |publisher|
|
||||
publisher.save
|
||||
rescue DistributedPress::V1::Error => e
|
||||
data = { instance: publisher.instance, expires_at: publisher.client.token.expires_at }
|
||||
|
||||
ExceptionNotifier.notify_exception(e, data: data)
|
||||
end
|
||||
end
|
||||
end
|
22
app/lib/active_job/serializers/exception_serializer.rb
Normal file
22
app/lib/active_job/serializers/exception_serializer.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'json/add/exception'
|
||||
|
||||
module ActiveJob
|
||||
module Serializers
|
||||
class ExceptionSerializer < ObjectSerializer # :nodoc:
|
||||
def serialize(ex)
|
||||
super('value' => { 'class' => ex.class.name, 'exception' => ex.as_json })
|
||||
end
|
||||
|
||||
def deserialize(hash)
|
||||
hash.dig('value', 'class').constantize.json_create(hash.dig('value', 'exception'))
|
||||
end
|
||||
|
||||
private
|
||||
def klass
|
||||
Exception
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,11 +4,6 @@ module ActiveStorage
|
|||
class Service
|
||||
# Sube los archivos a cada repositorio y los agrega al LFS de su
|
||||
# repositorio git.
|
||||
#
|
||||
# @todo: Implementar LFS. No nos gusta mucho la idea porque duplica
|
||||
# el espacio en disco, pero es la única forma que tenemos (hasta que
|
||||
# implementemos IPFS) para poder transferir los archivos junto con el
|
||||
# sitio.
|
||||
class JekyllService < Service::DiskService
|
||||
# Genera un servicio para un sitio determinado
|
||||
#
|
||||
|
@ -27,7 +22,10 @@ module ActiveStorage
|
|||
# @param :checksum [String]
|
||||
def upload(key, io, checksum: nil, **)
|
||||
instrument :upload, key: key, checksum: checksum do
|
||||
IO.copy_stream(io, make_path_for(key)) unless exist?(key)
|
||||
unless exist?(key)
|
||||
IO.copy_stream(io, make_path_for(key))
|
||||
LfsObjectService.new(site: site, blob: blob_for(key)).process
|
||||
end
|
||||
ensure_integrity_of(key, checksum) if checksum
|
||||
end
|
||||
end
|
||||
|
@ -79,7 +77,7 @@ module ActiveStorage
|
|||
# @param :key [String]
|
||||
# @return [String]
|
||||
def filename_for(key)
|
||||
ActiveStorage::Blob.where(key: key).limit(1).pluck(:filename).first.tap do |filename|
|
||||
blob_for(key).filename.to_s.tap do |filename|
|
||||
raise ArgumentError, "Filename for key #{key} is blank" if filename.blank?
|
||||
end
|
||||
end
|
||||
|
@ -91,6 +89,15 @@ module ActiveStorage
|
|||
def path_for(key)
|
||||
File.join root, folder_for(key), filename_for(key)
|
||||
end
|
||||
|
||||
# @return [Site]
|
||||
def site
|
||||
@site ||= Site.find_by_name(name)
|
||||
end
|
||||
|
||||
def blob_for(key)
|
||||
ActiveStorage::Blob.find_by(key: key, service_name: name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
21
app/lib/devise/failure_app_decorator.rb
Normal file
21
app/lib/devise/failure_app_decorator.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Devise
|
||||
module FailureAppDecorator
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include AbstractController::Callbacks
|
||||
|
||||
around_action :set_locale
|
||||
|
||||
private
|
||||
|
||||
def set_locale(&action)
|
||||
I18n.with_locale(session[:locale] || I18n.locale, &action)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Devise::FailureApp.include Devise::FailureAppDecorator
|
|
@ -8,10 +8,15 @@ module ExceptionNotifier
|
|||
# Recibe la excepción y empieza la tarea de notificación en segundo
|
||||
# plano.
|
||||
#
|
||||
# @param [Exception]
|
||||
# @param [Hash]
|
||||
def call(exception, **options)
|
||||
GitlabNotifierJob.perform_async(exception, **options)
|
||||
# @param :exception [Exception]
|
||||
# @param :options [Hash]
|
||||
def call(exception, options, &block)
|
||||
case exception
|
||||
when BacktraceJob::BacktraceException
|
||||
GitlabNotifierJob.perform_later(exception, **options)
|
||||
else
|
||||
GitlabNotifierJob.perform_now(exception, **options)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
13
app/lib/hidden_service_client.rb
Normal file
13
app/lib/hidden_service_client.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'httparty'
|
||||
|
||||
class HiddenServiceClient
|
||||
include HTTParty
|
||||
|
||||
base_uri ENV.fetch('HIDDEN_SERVICE', 'http://tor:3000')
|
||||
|
||||
def create(name)
|
||||
self.class.get("/#{name}").body
|
||||
end
|
||||
end
|
|
@ -52,7 +52,7 @@ class DeployMailer < ApplicationMailer
|
|||
t << (row.map do |k, v|
|
||||
case k
|
||||
when :seconds then v[:human]
|
||||
when :urls then url
|
||||
when :urls then url.to_s
|
||||
else v
|
||||
end
|
||||
end)
|
||||
|
|
14
app/models/code_of_conduct.rb
Normal file
14
app/models/code_of_conduct.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Códigos de conducta
|
||||
class CodeOfConduct < ApplicationRecord
|
||||
extend Mobility
|
||||
|
||||
translates :title, type: :string, locale_accessors: true
|
||||
translates :description, type: :text, locale_accessors: true
|
||||
translates :content, type: :text, locale_accessors: true
|
||||
|
||||
validates :title, presence: true, uniqueness: true
|
||||
validates :description, presence: true
|
||||
validates :content, presence: true
|
||||
end
|
26
app/models/concerns/usuarie/consent.rb
Normal file
26
app/models/concerns/usuarie/consent.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Usuarie
|
||||
# Gestiona los campos de consentimiento
|
||||
module Consent
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
CONSENT_FIELDS = %i[privacy_policy_accepted terms_of_service_accepted code_of_conduct_accepted available_for_feedback_accepted]
|
||||
|
||||
CONSENT_FIELDS.each do |field|
|
||||
attribute field, :boolean
|
||||
end
|
||||
|
||||
before_save :update_consent_fields!
|
||||
|
||||
private
|
||||
|
||||
def update_consent_fields!
|
||||
CONSENT_FIELDS.each do |field|
|
||||
send(:"#{field}_at=", Time.now) if send(field).present?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'open3'
|
||||
|
||||
# Este modelo implementa los distintos tipos de alojamiento que provee
|
||||
# Sutty.
|
||||
#
|
||||
|
@ -11,6 +12,9 @@ class Deploy < ApplicationRecord
|
|||
belongs_to :site
|
||||
has_many :build_stats, dependent: :destroy
|
||||
|
||||
DEPENDENCIES = []
|
||||
SOFT_DEPENDENCIES = []
|
||||
|
||||
def deploy(**)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
@ -19,6 +23,11 @@ class Deploy < ApplicationRecord
|
|||
raise NotImplementedError
|
||||
end
|
||||
|
||||
# @return [Array]
|
||||
def urls
|
||||
[url].compact
|
||||
end
|
||||
|
||||
def limit
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
@ -51,6 +60,22 @@ class Deploy < ApplicationRecord
|
|||
@gems_dir ||= Rails.root.join('_storage', 'gems', site.name)
|
||||
end
|
||||
|
||||
# Un entorno que solo tiene lo que necesitamos
|
||||
#
|
||||
# @return [Hash]
|
||||
def env
|
||||
# XXX: This doesn't support Windows paths :B
|
||||
paths = [File.dirname(`which bundle`), '/usr/local/bin', '/usr/bin', '/bin']
|
||||
|
||||
# Las variables de entorno extra no pueden superponerse al local.
|
||||
extra_env.merge({
|
||||
'HOME' => home_dir,
|
||||
'PATH' => paths.join(':'),
|
||||
'JEKYLL_ENV' => Rails.env,
|
||||
'LANG' => ENV['LANG'],
|
||||
})
|
||||
end
|
||||
|
||||
# Corre un comando, lo registra en la base de datos y devuelve el
|
||||
# estado.
|
||||
#
|
||||
|
@ -61,8 +86,7 @@ class Deploy < ApplicationRecord
|
|||
lines = []
|
||||
|
||||
time_start
|
||||
Dir.chdir(site.path) do
|
||||
Open3.popen2e(env, cmd, unsetenv_others: true) do |_, o, t|
|
||||
Open3.popen2e(env, cmd, unsetenv_others: true, chdir: site.path) do |_, o, t|
|
||||
# TODO: Enviar a un websocket para ver el proceso en vivo?
|
||||
Thread.new do
|
||||
o.each do |line|
|
||||
|
@ -77,7 +101,6 @@ class Deploy < ApplicationRecord
|
|||
|
||||
r = t.value
|
||||
end
|
||||
end
|
||||
time_stop
|
||||
|
||||
build_stats.create action: readable_cmd(cmd),
|
||||
|
@ -89,11 +112,60 @@ class Deploy < ApplicationRecord
|
|||
r&.success?
|
||||
end
|
||||
|
||||
# Variables de entorno
|
||||
#
|
||||
# @return [Hash]
|
||||
def local_env
|
||||
@local_env ||= {}
|
||||
end
|
||||
|
||||
# Devuelve opciones para jekyll build
|
||||
#
|
||||
# @return [String,nil]
|
||||
def flags_for_build(**args); end
|
||||
|
||||
# Trae todas las dependencias
|
||||
#
|
||||
# @return [Array]
|
||||
def self.all_dependencies
|
||||
self::DEPENDENCIES | self::SOFT_DEPENDENCIES
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Escribe el contenido en un archivo temporal y ejecuta el bloque
|
||||
# provisto con el archivo como parámetro
|
||||
#
|
||||
# @param :content [String]
|
||||
def with_tempfile(content, &block)
|
||||
Tempfile.create(SecureRandom.hex) do |file|
|
||||
file.write content.to_s
|
||||
file.rewind
|
||||
file.close
|
||||
|
||||
# @yieldparam :file [File]
|
||||
yield file
|
||||
end
|
||||
end
|
||||
|
||||
# @param [String]
|
||||
# @return [String]
|
||||
def readable_cmd(cmd)
|
||||
cmd.split(' -', 2).first.tr(' ', '_')
|
||||
end
|
||||
|
||||
def deploy_local
|
||||
@deploy_local ||= site.deploys.find_by(type: 'DeployLocal')
|
||||
end
|
||||
|
||||
# Consigue todas las variables de entorno configuradas por otros
|
||||
# deploys.
|
||||
#
|
||||
# @return [Hash]
|
||||
def extra_env
|
||||
@extra_env ||=
|
||||
site.deployment_list.reduce({}) do |extra, deploy|
|
||||
extra.merge deploy.local_env
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
class DeployAlternativeDomain < Deploy
|
||||
store :values, accessors: %i[hostname], coder: JSON
|
||||
|
||||
DEPENDENCIES = %i[deploy_local]
|
||||
|
||||
# Generar un link simbólico del sitio principal al alternativo
|
||||
def deploy(**)
|
||||
File.symlink?(destination) ||
|
||||
|
@ -18,7 +20,11 @@ class DeployAlternativeDomain < Deploy
|
|||
end
|
||||
|
||||
def destination
|
||||
@destination ||= File.join(Rails.root, '_deploy', hostname.gsub(/\.\z/, ''))
|
||||
@destination ||= File.join(Rails.root, '_deploy', fqdn)
|
||||
end
|
||||
|
||||
def fqdn
|
||||
hostname.gsub(/\.\z/, '')
|
||||
end
|
||||
|
||||
def url
|
||||
|
|
159
app/models/deploy_distributed_press.rb
Normal file
159
app/models/deploy_distributed_press.rb
Normal file
|
@ -0,0 +1,159 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'distributed_press/v1/client/site'
|
||||
|
||||
# Soportar Distributed Press APIv1
|
||||
#
|
||||
# Usa tokens de publicación efímeros para todas las acciones.
|
||||
#
|
||||
# Al ser creado, genera el sitio en la instancia de Distributed Press
|
||||
# configurada y almacena el ID.
|
||||
#
|
||||
# Al ser publicado, envía los archivos en un tarball y actualiza la
|
||||
# información.
|
||||
class DeployDistributedPress < Deploy
|
||||
store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON
|
||||
|
||||
before_create :create_remote_site!
|
||||
before_destroy :delete_remote_site!
|
||||
|
||||
DEPENDENCIES = %i[deploy_local]
|
||||
|
||||
# Actualiza la información y luego envía los cambios
|
||||
#
|
||||
# @param :output [Bool]
|
||||
# @return [Bool]
|
||||
def deploy
|
||||
status = false
|
||||
log = []
|
||||
|
||||
time_start
|
||||
|
||||
create_remote_site! if remote_site_id.blank?
|
||||
save
|
||||
|
||||
if remote_site_id.blank?
|
||||
raise DeployJob::DeployException, 'El sitio no se creó en Distributed Press'
|
||||
end
|
||||
|
||||
site_client.tap do |c|
|
||||
stdout = Thread.new(publisher.logger_out) do |io|
|
||||
until io.eof?
|
||||
line = io.gets
|
||||
|
||||
puts line if output
|
||||
log << line
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
status = c.publish(publishing_site, deploy_local.destination)
|
||||
rescue DistributedPress::V1::Error => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
||||
status = false
|
||||
end
|
||||
|
||||
if status
|
||||
self.remote_info[:distributed_press] = c.show(publishing_site).to_h
|
||||
save
|
||||
end
|
||||
|
||||
publisher.logger.close
|
||||
stdout.join
|
||||
end
|
||||
|
||||
time_stop
|
||||
|
||||
create_stat! status, log.join
|
||||
|
||||
status
|
||||
end
|
||||
|
||||
def limit; end
|
||||
|
||||
def size
|
||||
deploy_local.size
|
||||
end
|
||||
|
||||
def destination; end
|
||||
|
||||
# Devuelve las URLs de todos los protocolos
|
||||
def urls
|
||||
gateway_urls
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# @return [Array]
|
||||
def gateway_urls
|
||||
remote_info.dig(:distributed_press, :links)&.values&.map do |protocol|
|
||||
[ protocol[:link], protocol[:gateway] ]
|
||||
end&.flatten&.compact&.select do |link|
|
||||
link.include? '://'
|
||||
end || []
|
||||
end
|
||||
|
||||
# El cliente de la API
|
||||
#
|
||||
# TODO: cuando soportemos más, tiene que haber una relación entre
|
||||
# DeployDistributedPress y DistributedPressPublisher.
|
||||
#
|
||||
# @return [DistributedPressPublisher]
|
||||
def publisher
|
||||
@publisher ||= DistributedPressPublisher.last
|
||||
end
|
||||
|
||||
# El cliente para actualizar el sitio
|
||||
#
|
||||
# @return [DistributedPress::V1::Client::Site]
|
||||
def site_client
|
||||
DistributedPress::V1::Client::Site.new(publisher.client)
|
||||
end
|
||||
|
||||
# Genera el esquema de datos para poder publicar el sitio
|
||||
#
|
||||
# @return [DistributedPress::V1::Schemas::PublishingSite]
|
||||
def publishing_site
|
||||
DistributedPress::V1::Schemas::PublishingSite.new.call(id: remote_site_id)
|
||||
end
|
||||
|
||||
# Genera el esquema de datos para crear el sitio
|
||||
#
|
||||
# @return [DistributedPressPublisher::V1::Schemas::NewSite]
|
||||
def create_site
|
||||
DistributedPress::V1::Schemas::NewSite.new.call(domain: hostname, protocols: { http: true, ipfs: true, hyper: true })
|
||||
end
|
||||
|
||||
# Crea el sitio en la instancia con el hostname especificado
|
||||
#
|
||||
# @return [nil]
|
||||
def create_remote_site!
|
||||
created_site = site_client.create(create_site)
|
||||
|
||||
self.remote_site_id = created_site[:id]
|
||||
self.remote_info ||= {}
|
||||
self.remote_info[:distributed_press] = created_site.to_h
|
||||
nil
|
||||
rescue DistributedPress::V1::Error => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
||||
nil
|
||||
end
|
||||
|
||||
# Registra lo que sucedió
|
||||
#
|
||||
# @param status [Bool]
|
||||
# @param log [String]
|
||||
# @return [nil]
|
||||
def create_stat!(status, log)
|
||||
build_stats.create action: publisher.to_s,log: log, seconds: time_spent_in_seconds, bytes: size, status: status
|
||||
nil
|
||||
end
|
||||
|
||||
def delete_remote_site!
|
||||
site_client.delete(publishing_site)
|
||||
nil
|
||||
rescue DistributedPress::V1::Error => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
||||
nil
|
||||
end
|
||||
end
|
30
app/models/deploy_full_rsync.rb
Normal file
30
app/models/deploy_full_rsync.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DeployFullRsync < DeployRsync
|
||||
SOFT_DEPENDENCIES = %i[
|
||||
deploy_alternative_domain
|
||||
deploy_localized_domain
|
||||
deploy_hidden_service
|
||||
deploy_www
|
||||
]
|
||||
|
||||
# Sincroniza las ubicaciones alternativas también, ignorando las que
|
||||
# todavía no se generaron. Solo falla si ningún sitio fue
|
||||
# sincronizado o si alguna sincronización falló.
|
||||
#
|
||||
# @param :output [Boolean]
|
||||
# @return [Boolean]
|
||||
def rsync(output: false)
|
||||
result =
|
||||
self.class.all_dependencies.map(&:to_s).map(&:classify).map do |dependency|
|
||||
site.deploys.where(type: dependency).find_each.map do |deploy|
|
||||
next unless File.exist? deploy.destination
|
||||
|
||||
run %(rsync -aviH --delete-after --timeout=5 #{Shellwords.escape deploy.destination} #{Shellwords.escape destination}), output: output
|
||||
rescue StandardError
|
||||
end
|
||||
end.flatten.compact
|
||||
|
||||
result.present? && result.all?
|
||||
end
|
||||
end
|
|
@ -2,17 +2,36 @@
|
|||
|
||||
# Genera una versión onion
|
||||
class DeployHiddenService < DeployWww
|
||||
def deploy(**)
|
||||
return true if fqdn.blank?
|
||||
store :values, accessors: %i[onion], coder: JSON
|
||||
|
||||
super
|
||||
end
|
||||
before_create :create_hidden_service!
|
||||
|
||||
ONION_RE = /\A[a-z0-9]{56}\.onion\z/.freeze
|
||||
|
||||
def fqdn
|
||||
values[:onion]
|
||||
create_hidden_service! if onion.blank?
|
||||
|
||||
onion.tap do |onion|
|
||||
raise ArgumentError, 'Aun no se generó la dirección .onion' if onion.blank?
|
||||
end
|
||||
end
|
||||
|
||||
def url
|
||||
"http://#{fqdn}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_hidden_service!
|
||||
onion_address = HiddenServiceClient.new.create(site.name)
|
||||
|
||||
if ONION_RE =~ onion_address
|
||||
self.onion = onion_address
|
||||
|
||||
usuarie = GitAuthor.new email: "tor@#{Site.domain}", name: 'Tor'
|
||||
params = { onion: onion_address, deploy: self }
|
||||
|
||||
SiteService.new(site: site, usuarie: usuarie, params: params).add_onion
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,9 @@ class DeployLocal < Deploy
|
|||
# Sutty
|
||||
def deploy(output: false)
|
||||
return false unless mkdir
|
||||
return false unless git_lfs(output: output)
|
||||
return false unless yarn(output: output)
|
||||
return false unless pnpm(output: output)
|
||||
return false unless bundle(output: output)
|
||||
|
||||
jekyll_build(output: output)
|
||||
|
@ -60,34 +62,34 @@ class DeployLocal < Deploy
|
|||
FileUtils.rm_rf(File.join(site.path, '.jekyll-cache'))
|
||||
end
|
||||
|
||||
# Opciones necesarias para la compilación del sitio
|
||||
#
|
||||
# @return [Hash]
|
||||
def local_env
|
||||
@local_env ||= {
|
||||
'SPREE_API_KEY' => site.tienda_api_key,
|
||||
'SPREE_URL' => site.tienda_url,
|
||||
'AIRBRAKE_PROJECT_ID' => site.id.to_s,
|
||||
'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key,
|
||||
'YARN_CACHE_FOLDER' => yarn_cache_dir,
|
||||
'GEMS_SOURCE' => ENV['GEMS_SOURCE']
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mkdir
|
||||
FileUtils.mkdir_p destination
|
||||
end
|
||||
|
||||
# Un entorno que solo tiene lo que necesitamos
|
||||
def env
|
||||
# XXX: This doesn't support Windows paths :B
|
||||
paths = [File.dirname(`which bundle`), '/usr/bin', '/bin']
|
||||
|
||||
{
|
||||
'HOME' => home_dir,
|
||||
'PATH' => paths.join(':'),
|
||||
'SPREE_API_KEY' => site.tienda_api_key,
|
||||
'SPREE_URL' => site.tienda_url,
|
||||
'AIRBRAKE_PROJECT_ID' => site.id.to_s,
|
||||
'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key,
|
||||
'JEKYLL_ENV' => Rails.env,
|
||||
'LANG' => ENV['LANG'],
|
||||
'YARN_CACHE_FOLDER' => yarn_cache_dir
|
||||
}
|
||||
end
|
||||
|
||||
def yarn_cache_dir
|
||||
Rails.root.join('_yarn_cache').to_s
|
||||
end
|
||||
|
||||
def pnpm_cache_dir
|
||||
Rails.root.join('_pnpm_cache').to_s
|
||||
end
|
||||
|
||||
def yarn_lock
|
||||
File.join(site.path, 'yarn.lock')
|
||||
end
|
||||
|
@ -96,6 +98,19 @@ class DeployLocal < Deploy
|
|||
File.exist? yarn_lock
|
||||
end
|
||||
|
||||
def pnpm_lock
|
||||
File.join(site.path, 'pnpm-lock.yaml')
|
||||
end
|
||||
|
||||
def pnpm_lock?
|
||||
File.exist? pnpm_lock
|
||||
end
|
||||
|
||||
def git_lfs(output: false)
|
||||
run %(git lfs fetch), output: output
|
||||
run %(git lfs checkout), output: output
|
||||
end
|
||||
|
||||
def gem(output: false)
|
||||
run %(gem install bundler --no-document), output: output
|
||||
end
|
||||
|
@ -107,12 +122,28 @@ class DeployLocal < Deploy
|
|||
run 'yarn install --production', output: output
|
||||
end
|
||||
|
||||
def pnpm(output: false)
|
||||
return true unless pnpm_lock?
|
||||
|
||||
run %(pnpm config set store-dir "#{pnpm_cache_dir}"), output: output
|
||||
run 'pnpm install --production', output: output
|
||||
end
|
||||
|
||||
def bundle(output: false)
|
||||
run %(bundle install --no-cache --path="#{gems_dir}" --clean --without test development), output: output
|
||||
run %(bundle config set --local clean 'true'), output: output
|
||||
run %(bundle config set --local deployment 'true'), output: output
|
||||
run %(bundle config set --local path '#{gems_dir}'), output: output
|
||||
run %(bundle config set --local without 'test development'), output: output
|
||||
run %(bundle config set --local cache_all 'false'), output: output
|
||||
run %(bundle install), output: output
|
||||
end
|
||||
|
||||
def jekyll_build(output: false)
|
||||
run %(bundle exec jekyll build --trace --profile --destination "#{escaped_destination}"), output: output
|
||||
with_tempfile(site.private_key_pem) do |file|
|
||||
flags = extra_flags(private_key: file)
|
||||
|
||||
run %(bundle exec jekyll build --trace --profile #{flags} --destination "#{escaped_destination}"), output: output
|
||||
end
|
||||
end
|
||||
|
||||
# no debería haber espacios ni caracteres especiales, pero por si
|
||||
|
@ -125,4 +156,14 @@ class DeployLocal < Deploy
|
|||
def remove_destination!
|
||||
FileUtils.rm_rf destination
|
||||
end
|
||||
|
||||
# Genera opciones extra desde los otros deploys
|
||||
#
|
||||
# @param :args [Hash]
|
||||
# @return [String]
|
||||
def extra_flags(**args)
|
||||
site.deployment_list.map do |deploy|
|
||||
deploy.flags_for_build(**args)
|
||||
end.compact.join(' ')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
# XXX: La plantilla tiene que soportar esto con el plugin
|
||||
# jekyll-private-data
|
||||
class DeployPrivate < DeployLocal
|
||||
DEPENDENCIES = %i[deploy_local]
|
||||
|
||||
# No es necesario volver a instalar dependencias
|
||||
def deploy(output: false)
|
||||
jekyll_build(output: output)
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
# Sincroniza sitios a servidores remotos usando Rsync. El servidor
|
||||
# remoto tiene que tener rsync instalado.
|
||||
class DeployRsync < Deploy
|
||||
store :values, accessors: %i[destination host_keys], coder: JSON
|
||||
store :values, accessors: %i[hostname destination host_keys], coder: JSON
|
||||
|
||||
DEPENDENCIES = %i[deploy_local deploy_zip]
|
||||
|
||||
def deploy(output: false)
|
||||
ssh? && rsync(output: output)
|
||||
|
@ -23,6 +25,11 @@ class DeployRsync < Deploy
|
|||
end
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def url
|
||||
"https://#{hostname}/"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Verificar la conexión SSH implementando Trust On First Use
|
||||
|
@ -31,6 +38,7 @@ class DeployRsync < Deploy
|
|||
#
|
||||
# @return [Boolean]
|
||||
def ssh?
|
||||
return true if destination.start_with? 'rsync://'
|
||||
user, host = user_host
|
||||
ssh_available = false
|
||||
|
||||
|
@ -83,8 +91,8 @@ class DeployRsync < Deploy
|
|||
# Sincroniza hacia el directorio remoto
|
||||
#
|
||||
# @return [Boolean]
|
||||
def rsync(output: output)
|
||||
run %(rsync -aviH --timeout=5 #{Shellwords.escape source}/ #{Shellwords.escape destination}/), output: output
|
||||
def rsync(output: false)
|
||||
run %(rsync -aviH --delete-after --timeout=5 #{Shellwords.escape source}/ #{Shellwords.escape destination}/), output: output
|
||||
end
|
||||
|
||||
# El origen es el destino de la compilación
|
||||
|
|
55
app/models/deploy_social_distributed_press.rb
Normal file
55
app/models/deploy_social_distributed_press.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'distributed_press/v1/social/client'
|
||||
|
||||
# Publicar novedades al Fediverso
|
||||
class DeploySocialDistributedPress < Deploy
|
||||
# Solo luego de publicar remotamente
|
||||
DEPENDENCIES = %i[deploy_distributed_press deploy_rsync deploy_full_rsync]
|
||||
|
||||
# Envía las notificaciones
|
||||
def deploy(output: false)
|
||||
with_tempfile(site.private_key_pem) do |file|
|
||||
key = Shellwords.escape file.path
|
||||
dest = Shellwords.escape destination
|
||||
|
||||
run %(bundle exec jekyll notify --trace --key #{key} --destination "#{dest}"), output: output
|
||||
end
|
||||
end
|
||||
|
||||
# Igual que DeployLocal
|
||||
#
|
||||
# @return [String]
|
||||
def destination
|
||||
File.join(Rails.root, '_deploy', site.hostname)
|
||||
end
|
||||
|
||||
# Solo uno
|
||||
#
|
||||
# @return [Integer]
|
||||
def limit
|
||||
1
|
||||
end
|
||||
|
||||
# Espacio ocupado, pero no podemos calcularlo
|
||||
#
|
||||
# @return [Integer]
|
||||
def size
|
||||
0
|
||||
end
|
||||
|
||||
# El perfil de actor
|
||||
#
|
||||
# @return [String,nil]
|
||||
def url
|
||||
site.data.dig('activity_pub', 'actor')
|
||||
end
|
||||
|
||||
# Genera la opción de llave privada para jekyll build
|
||||
#
|
||||
# @params :args [Hash]
|
||||
# @return [String]
|
||||
def flags_for_build(**args)
|
||||
"--key #{Shellwords.escape args[:private_key].path}"
|
||||
end
|
||||
end
|
|
@ -4,9 +4,13 @@
|
|||
class DeployWww < Deploy
|
||||
store :values, accessors: %i[], coder: JSON
|
||||
|
||||
DEPENDENCIES = %i[deploy_local]
|
||||
|
||||
before_destroy :remove_destination!
|
||||
|
||||
def deploy(**)
|
||||
def deploy(output: false)
|
||||
puts "Creando symlink #{site.hostname} => #{destination}" if output
|
||||
|
||||
File.symlink?(destination) ||
|
||||
File.symlink(site.hostname, destination).zero?
|
||||
end
|
||||
|
@ -28,7 +32,7 @@ class DeployWww < Deploy
|
|||
end
|
||||
|
||||
def url
|
||||
"https://www.#{site.hostname}/"
|
||||
"https://#{fqdn}/"
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,28 +8,49 @@ require 'zip'
|
|||
class DeployZip < Deploy
|
||||
store :values, accessors: %i[], coder: JSON
|
||||
|
||||
DEPENDENCIES = %i[deploy_local]
|
||||
|
||||
# Una vez que el sitio está generado, tomar todos los archivos y
|
||||
# y generar un zip accesible públicamente.
|
||||
#
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def deploy(**)
|
||||
def deploy(output: false)
|
||||
FileUtils.rm_f path
|
||||
|
||||
time_start
|
||||
Dir.chdir(destination) do
|
||||
Zip::File.open(path, Zip::File::CREATE) do |z|
|
||||
Dir.glob('./**/**').each do |f|
|
||||
File.directory?(f) ? z.mkdir(f) : z.add(f, f)
|
||||
Zip::File.open(path, Zip::File::CREATE) do |zip|
|
||||
Dir.glob(File.join(destination, '**', '**')).each do |file|
|
||||
entry = Pathname.new(file).relative_path_from(destination).to_s
|
||||
|
||||
if File.directory? file
|
||||
log "Creando directorio #{entry}", output
|
||||
|
||||
zip.mkdir(entry)
|
||||
else
|
||||
log "Comprimiendo #{entry}", output
|
||||
zip.add(entry, file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
time_stop
|
||||
|
||||
File.exist?(path).tap do |status|
|
||||
build_stats.create action: 'zip',
|
||||
seconds: time_spent_in_seconds,
|
||||
bytes: size
|
||||
bytes: size,
|
||||
log: @log.join("\n"),
|
||||
status: status
|
||||
end
|
||||
rescue Zip::Error => e
|
||||
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
||||
|
||||
File.exist? path
|
||||
build_stats.create action: 'zip',
|
||||
seconds: 0,
|
||||
bytes: 0,
|
||||
log: @log.join("\n"),
|
||||
status: false
|
||||
|
||||
false
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
|
@ -41,8 +62,11 @@ class DeployZip < Deploy
|
|||
File.size path
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def destination
|
||||
File.join(Rails.root, '_deploy', site.hostname)
|
||||
Rails.root.join('_deploy', site.hostname).realpath.to_s
|
||||
rescue Errno::ENOENT
|
||||
Rails.root.join('_deploy', site.hostname).to_s
|
||||
end
|
||||
|
||||
def file
|
||||
|
@ -56,4 +80,15 @@ class DeployZip < Deploy
|
|||
def path
|
||||
File.join(destination, file)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# @param :line [String]
|
||||
# @param :output [Boolean]
|
||||
def log(line, output)
|
||||
@log ||= []
|
||||
@log << line
|
||||
|
||||
puts line if output
|
||||
end
|
||||
end
|
||||
|
|
84
app/models/distributed_press_publisher.rb
Normal file
84
app/models/distributed_press_publisher.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'distributed_press/v1'
|
||||
|
||||
# Almacena el token de autenticación y la URL, por ahora solo vamos
|
||||
# a tener uno, pero queda abierta la posibilidad de agregar más.
|
||||
class DistributedPressPublisher < ApplicationRecord
|
||||
# Cifrar la información del token en la base de datos
|
||||
has_encrypted :token
|
||||
|
||||
# La salida del log
|
||||
#
|
||||
# @return [IO]
|
||||
attr_reader :logger_out
|
||||
|
||||
# La instancia es única
|
||||
validates_uniqueness_of :instance
|
||||
|
||||
# El token es necesario
|
||||
validates_presence_of :token
|
||||
|
||||
# Mantener la fecha de vencimiento actualizada
|
||||
before_save :update_expires_at_from_token!, :update_token_from_client!
|
||||
|
||||
# Devuelve todos los tokens que vencen en una hora
|
||||
scope :with_about_to_expire_tokens, lambda {
|
||||
where('expires_at > ? and expires_at < ?', Time.now, Time.now + 1.hour)
|
||||
}
|
||||
|
||||
# Instancia un cliente de Distributed Press a partir del token. Al
|
||||
# cargar un token a punto de vencer se renueva automáticamente.
|
||||
#
|
||||
# @return [DistributedPress::V1::Client]
|
||||
def client
|
||||
@client ||= DistributedPress::V1::Client.new(url: instance, token: token, logger: logger)
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def to_s
|
||||
"Distributed Press <#{instance}>"
|
||||
end
|
||||
|
||||
# Devuelve el hostname de la instancia
|
||||
#
|
||||
# @return [String]
|
||||
def hostname
|
||||
@hostname ||= URI.parse(instance).hostname
|
||||
end
|
||||
|
||||
# @return [Logger]
|
||||
def logger
|
||||
@logger ||=
|
||||
begin
|
||||
@logger_out, @logger_in = IO.pipe
|
||||
::Logger.new @logger_in, formatter: formatter
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def formatter
|
||||
@formatter ||= lambda do |_, _, _, msg|
|
||||
"#{msg}\n"
|
||||
end
|
||||
end
|
||||
|
||||
# Actualiza o desactiva la fecha de vencimiento a partir de la
|
||||
# información del token.
|
||||
#
|
||||
# @return [nil]
|
||||
def update_expires_at_from_token!
|
||||
self.expires_at = client.token.forever? ? nil : client.token.expires_at
|
||||
nil
|
||||
end
|
||||
|
||||
# Actualiza el token a partir del cliente, que ya actualiza el token
|
||||
# automáticamente.
|
||||
#
|
||||
# @return [nil]
|
||||
def update_token_from_client!
|
||||
self.token = client.token.to_s
|
||||
nil
|
||||
end
|
||||
end
|
|
@ -36,6 +36,15 @@ class IndexedPost < ApplicationRecord
|
|||
|
||||
belongs_to :site
|
||||
|
||||
# Encuentra el post original
|
||||
#
|
||||
# @return [nil,Post]
|
||||
def post
|
||||
return if post_id.blank?
|
||||
|
||||
@post ||= site.posts(lang: locale).find(post_id, uuid: true)
|
||||
end
|
||||
|
||||
# Convertir locale a direccionario de PG
|
||||
#
|
||||
# @param [String,Symbol]
|
||||
|
|
|
@ -9,6 +9,13 @@ Layout = Struct.new(:site, :name, :meta, :metadata, keyword_init: true) do
|
|||
name.to_s
|
||||
end
|
||||
|
||||
# Obtiene todos los layouts (schemas) dependientes de este.
|
||||
#
|
||||
# @return [Array]
|
||||
def schemas
|
||||
@schemas ||= site.layouts.to_h.slice(*site.schema_organization[name]).values
|
||||
end
|
||||
|
||||
def attributes
|
||||
@attributes ||= metadata.keys.map(&:to_sym)
|
||||
end
|
||||
|
|
|
@ -7,6 +7,7 @@ class Licencia < ApplicationRecord
|
|||
translates :name, type: :string, locale_accessors: true
|
||||
translates :url, type: :string, locale_accessors: true
|
||||
translates :description, type: :text, locale_accessors: true
|
||||
translates :short_description, type: :string, locale_accessors: true
|
||||
translates :deed, type: :text, locale_accessors: true
|
||||
|
||||
has_many :sites
|
||||
|
@ -14,5 +15,10 @@ class Licencia < ApplicationRecord
|
|||
validates :name, presence: true, uniqueness: true
|
||||
validates :url, presence: true
|
||||
validates :description, presence: true
|
||||
validates :short_description, presence: true
|
||||
validates :deed, presence: true
|
||||
|
||||
def custom?
|
||||
icons == 'custom'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@ class LogEntry < ApplicationRecord
|
|||
def resend
|
||||
return if sent
|
||||
|
||||
ContactJob.perform_async site_id, params[:form], params
|
||||
ContactJob.perform_later site_id, params[:form], params
|
||||
end
|
||||
|
||||
def params
|
||||
|
|
|
@ -4,8 +4,12 @@
|
|||
#
|
||||
# Esto es increíblemente difícil de lograr que salga bien!
|
||||
class MetadataBoolean < MetadataTemplate
|
||||
# El valor por defecto es una versión booleana de lo que diga (o no
|
||||
# diga) el esquema
|
||||
#
|
||||
# @return [Boolean]
|
||||
def default_value
|
||||
false
|
||||
!!super
|
||||
end
|
||||
|
||||
# Los checkboxes son especiales porque la especificación de HTML
|
||||
|
|
19
app/models/metadata_created_at.rb
Normal file
19
app/models/metadata_created_at.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Fecha y hora de creación
|
||||
class MetadataCreatedAt < MetadataTemplate
|
||||
# Por defecto la hora actual, pero por retrocompatibilidad, queremos
|
||||
# la fecha de publicación
|
||||
def default_value
|
||||
if post.date.value.to_date < Time.now.to_date
|
||||
post.date.value
|
||||
else
|
||||
Time.now
|
||||
end
|
||||
end
|
||||
|
||||
# Nunca cambia
|
||||
def value=(new_value)
|
||||
value
|
||||
end
|
||||
end
|
|
@ -1,22 +1,49 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Los valores de este metadato son artículos en otros idiomas
|
||||
class MetadataLocales < MetadataTemplate
|
||||
def default_value
|
||||
super || []
|
||||
end
|
||||
|
||||
class MetadataLocales < MetadataHasAndBelongsToMany
|
||||
# Todos los valores posibles para cada idioma disponible
|
||||
#
|
||||
# TODO: Optimizar?
|
||||
# TODO: Mantener sincronizados
|
||||
#
|
||||
# @return { lang: { title: uuid } }
|
||||
def values
|
||||
@values ||= site.locales.map do |locale|
|
||||
[locale, site.posts(lang: locale).map do |post|
|
||||
[post.title.value, post.uuid.value]
|
||||
[locale, posts.where(lang: locale).map do |post|
|
||||
[title(post), post.uuid.value]
|
||||
end.to_h]
|
||||
end.to_h
|
||||
end
|
||||
|
||||
# Siempre hay una relación inversa
|
||||
#
|
||||
# @return [True]
|
||||
def inverse?
|
||||
true
|
||||
end
|
||||
|
||||
# El campo inverso se llama igual en el otro post
|
||||
#
|
||||
# @return [Symbol]
|
||||
def inverse
|
||||
:locales
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Obtiene todos los locales distintos a este post
|
||||
#
|
||||
# @return [Array]
|
||||
def other_locales
|
||||
site.locales.reject do |locale|
|
||||
locale == post.lang.value.to_sym
|
||||
end
|
||||
end
|
||||
|
||||
# Obtiene todos los posts de los otros locales con el mismo layout
|
||||
#
|
||||
# @return [PostRelation]
|
||||
def posts
|
||||
other_locales.map do |locale|
|
||||
site.posts(lang: locale).where(layout: post.layout.value)
|
||||
end.reduce(&:concat) || PostRelation.new(site: site, lang: 'any')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ class MetadataRelatedPosts < MetadataArray
|
|||
end
|
||||
|
||||
def title(post)
|
||||
"#{post&.title&.value || post&.slug&.value} (#{post.layout.humanized_name})"
|
||||
"#{post&.title&.value || post&.slug&.value} #{post&.date&.value.strftime('%F')} (#{post.layout.humanized_name})"
|
||||
end
|
||||
|
||||
# Encuentra el filtro
|
||||
|
|
|
@ -202,7 +202,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
|
|||
|
||||
def allowed_attributes
|
||||
@allowed_attributes ||= %w[style href src alt controls data-align data-multimedia data-multimedia-inner id
|
||||
name].freeze
|
||||
name start].freeze
|
||||
end
|
||||
|
||||
def allowed_tags
|
||||
|
|
|
@ -12,7 +12,7 @@ class Post
|
|||
DEFAULT_ATTRIBUTES = %i[site document layout].freeze
|
||||
# Otros atributos que no vienen en los metadatos
|
||||
PRIVATE_ATTRIBUTES = %i[path slug attributes errors].freeze
|
||||
PUBLIC_ATTRIBUTES = %i[lang date uuid].freeze
|
||||
PUBLIC_ATTRIBUTES = %i[lang date uuid created_at].freeze
|
||||
ATTR_SUFFIXES = %w[? =].freeze
|
||||
|
||||
attr_reader :attributes, :errors, :layout, :site, :document
|
||||
|
@ -217,6 +217,11 @@ class Post
|
|||
post: self, required: true)
|
||||
end
|
||||
|
||||
# La fecha de creación inmodificable del post
|
||||
def created_at
|
||||
@metadata[:created_at] ||= MetadataCreatedAt.new(document: document, site: site, layout: layout, name: :created_at, type: :created_at, post: self, required: true)
|
||||
end
|
||||
|
||||
# Detecta si es un atributo válido o no, a partir de la tabla de la
|
||||
# plantilla
|
||||
def attribute?(mid)
|
||||
|
@ -267,6 +272,7 @@ class Post
|
|||
# Y que no se procese liquid
|
||||
yaml['liquid'] = false
|
||||
yaml['usuaries'] = usuaries.map(&:id).uniq
|
||||
yaml['created_at'] = created_at.value
|
||||
yaml['last_modified_at'] = modified_at
|
||||
|
||||
"#{yaml.to_yaml}---\n\n#{body}"
|
||||
|
|
14
app/models/privacy_policy.rb
Normal file
14
app/models/privacy_policy.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Políticas de privacidad
|
||||
class PrivacyPolicy < ApplicationRecord
|
||||
extend Mobility
|
||||
|
||||
translates :title, type: :string, locale_accessors: true
|
||||
translates :description, type: :text, locale_accessors: true
|
||||
translates :content, type: :text, locale_accessors: true
|
||||
|
||||
validates :title, presence: true, uniqueness: true
|
||||
validates :description, presence: true
|
||||
validates :content, presence: true
|
||||
end
|
|
@ -14,6 +14,8 @@ class Rol < ApplicationRecord
|
|||
|
||||
validates_inclusion_of :rol, in: ROLES
|
||||
|
||||
before_save :add_token_if_missing!
|
||||
|
||||
def invitade?
|
||||
rol == INVITADE
|
||||
end
|
||||
|
@ -21,4 +23,15 @@ class Rol < ApplicationRecord
|
|||
def usuarie?
|
||||
rol == USUARIE
|
||||
end
|
||||
|
||||
def self.role?(rol)
|
||||
ROLES.include? rol
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Asegurarse que tenga un token
|
||||
def add_token_if_missing!
|
||||
self.token ||= SecureRandom.hex(64)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,10 @@ class Site < ApplicationRecord
|
|||
include Site::Forms
|
||||
include Site::FindAndReplace
|
||||
include Site::Api
|
||||
include Site::DeployDependencies
|
||||
include Site::BuildStats
|
||||
include Site::LayoutOrdering
|
||||
include Site::SocialDistributedPress
|
||||
include Tienda
|
||||
|
||||
# Cifrar la llave privada que cifra y decifra campos ocultos. Sutty
|
||||
|
@ -15,10 +19,6 @@ class Site < ApplicationRecord
|
|||
# protege de acceso al panel de Sutty!
|
||||
encrypts :private_key
|
||||
|
||||
# TODO: Hacer que los diferentes tipos de deploy se auto registren
|
||||
# @see app/services/site_service.rb
|
||||
DEPLOYS = %i[local private www zip hidden_service].freeze
|
||||
|
||||
validates :name, uniqueness: true, hostname: {
|
||||
allow_root_label: true
|
||||
}
|
||||
|
@ -444,6 +444,10 @@ class Site < ApplicationRecord
|
|||
find_by(name: "#{Site.domain}.")
|
||||
end
|
||||
|
||||
def self.one_at_a_time
|
||||
@@one_at_a_time ||= Thread::Mutex.new
|
||||
end
|
||||
|
||||
def reset
|
||||
@read = false
|
||||
@layouts = nil
|
||||
|
@ -471,6 +475,9 @@ class Site < ApplicationRecord
|
|||
return if jekyll?
|
||||
|
||||
Rugged::Repository.clone_at(ENV['SKEL_SUTTY'], path, checkout_branch: design.gem)
|
||||
|
||||
# Necesita un bloque
|
||||
repository.rugged.remotes.rename('origin', 'upstream') {}
|
||||
end
|
||||
|
||||
# Elimina el directorio del sitio
|
||||
|
@ -494,8 +501,8 @@ class Site < ApplicationRecord
|
|||
config.theme = design.gem unless design.no_theme?
|
||||
config.description = description
|
||||
config.title = title
|
||||
config.url = url(slash: false)
|
||||
config.hostname = hostname
|
||||
config.url ||= url(slash: false)
|
||||
config.hostname ||= hostname
|
||||
config.locales = locales.map(&:to_s)
|
||||
end
|
||||
|
||||
|
@ -550,13 +557,40 @@ class Site < ApplicationRecord
|
|||
end
|
||||
|
||||
def run_in_path(&block)
|
||||
Site.one_at_a_time.synchronize do
|
||||
Dir.chdir path, &block
|
||||
end
|
||||
end
|
||||
|
||||
# Instala las gemas cuando es necesario:
|
||||
#
|
||||
# * El sitio existe
|
||||
# * No están instaladas
|
||||
# * El archivo Gemfile se modificó
|
||||
# * El archivo Gemfile.lock se modificó
|
||||
def install_gems
|
||||
return unless persisted?
|
||||
return if Rails.root.join('_storage', 'gems', name).directory?
|
||||
|
||||
deploys.find_by_type('DeployLocal').send(:git_lfs)
|
||||
|
||||
if !gem_dir? || gemfile_updated? || gemfile_lock_updated?
|
||||
deploys.find_by_type('DeployLocal').send(:bundle)
|
||||
touch
|
||||
end
|
||||
end
|
||||
|
||||
# Detecta si el repositorio de gemas existe
|
||||
def gem_dir?
|
||||
Rails.root.join('_storage', 'gems', name).directory?
|
||||
end
|
||||
|
||||
# Detecta si el Gemfile fue modificado
|
||||
def gemfile_updated?
|
||||
updated_at < File.mtime(File.join(path, 'Gemfile'))
|
||||
end
|
||||
|
||||
# Detecta si el Gemfile.lock fue modificado
|
||||
def gemfile_lock_updated?
|
||||
updated_at < File.mtime(File.join(path, 'Gemfile.lock'))
|
||||
end
|
||||
end
|
||||
|
|
111
app/models/site/build_stats.rb
Normal file
111
app/models/site/build_stats.rb
Normal file
|
@ -0,0 +1,111 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Site
|
||||
module BuildStats
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# Devuelve el tiempo promedio de publicación para este sitio
|
||||
#
|
||||
# @return [Integer]
|
||||
def average_publication_time
|
||||
build_stats.group(:action).average(:seconds).values.reduce(:+).round
|
||||
end
|
||||
|
||||
# Devuelve el tiempo promedio de compilación para sitios similares
|
||||
# a este.
|
||||
#
|
||||
# @return [Integer]
|
||||
def average_publication_time_for_similar_sites
|
||||
similar_deploys = Deploy.where(type: deploys.pluck(:type)).pluck(:id)
|
||||
|
||||
BuildStat.where(deploy_id: similar_deploys).group(:action).average(:seconds).values.reduce(:+).round
|
||||
end
|
||||
|
||||
# Define si podemos calcular el tiempo promedio de publicación
|
||||
# para este sitio
|
||||
#
|
||||
# @return [Boolean]
|
||||
def average_publication_time_calculable?
|
||||
build_stats.jekyll.where(status: true).count > 1
|
||||
end
|
||||
|
||||
def similar_sites?
|
||||
!design.no_theme?
|
||||
end
|
||||
|
||||
# Detecta si el sitio todavía no ha sido publicado
|
||||
#
|
||||
# @return [Boolean]
|
||||
def not_published_yet?
|
||||
build_stats.jekyll.where(status: true).count.zero?
|
||||
end
|
||||
|
||||
# Cambios posibles luego de la última publicación exitosa:
|
||||
#
|
||||
# * Artículos modificados
|
||||
# * Configuración modificada
|
||||
# * Métodos de publicación añadidos
|
||||
#
|
||||
# @return [Boolean]
|
||||
def awaiting_publication?
|
||||
waiting? && (post_pending? || deploy_pending? || configuration_pending?)
|
||||
end
|
||||
|
||||
# Se modificaron artículos después de publicar el sitio por última
|
||||
# vez
|
||||
#
|
||||
# @return [Boolean]
|
||||
def post_pending?
|
||||
last_indexed_post_time > last_publication_time
|
||||
end
|
||||
|
||||
# Se modificó el sitio después de publicarlo por última vez
|
||||
#
|
||||
# @return [Boolean]
|
||||
def deploy_pending?
|
||||
last_deploy_time > last_publication_time
|
||||
end
|
||||
|
||||
# Se modificó la configuración del sitio
|
||||
#
|
||||
# @return [Boolean]
|
||||
def configuration_pending?
|
||||
last_configuration_time > last_publication_time
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Encuentra la fecha del último artículo modificado. Si no hay
|
||||
# ninguno, devuelve la fecha de modificación del sitio.
|
||||
#
|
||||
# @return [Time]
|
||||
def last_indexed_post_time
|
||||
indexed_posts.order(updated_at: :desc).select(:updated_at).first&.updated_at || updated_at
|
||||
end
|
||||
|
||||
# Encuentra la fecha de última modificación de los métodos de
|
||||
# publicación.
|
||||
#
|
||||
# @return [Time]
|
||||
def last_deploy_time
|
||||
deploys.order(created_at: :desc).select(:created_at).first&.created_at || updated_at
|
||||
end
|
||||
|
||||
# Encuentra la fecha de última publicación exitosa, si no hay
|
||||
# ninguno, devuelve la fecha de modificación del sitio.
|
||||
#
|
||||
# @return [Time]
|
||||
def last_publication_time
|
||||
build_stats.jekyll.where(status: true).order(created_at: :desc).select(:created_at).first&.created_at || updated_at
|
||||
end
|
||||
|
||||
# Fecha de última modificación de la configuración
|
||||
#
|
||||
# @return [Time]
|
||||
def last_configuration_time
|
||||
File.mtime(config.path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -31,7 +31,7 @@ class Site
|
|||
|
||||
# Escribe los cambios en el repositorio
|
||||
def write
|
||||
return if persisted?
|
||||
return true if persisted?
|
||||
|
||||
@saved = Site::Writer.new(site: site, file: path, content: content.to_yaml).save.tap do |result|
|
||||
# Actualizar el hash para no escribir dos veces
|
||||
|
|
38
app/models/site/deploy_dependencies.rb
Normal file
38
app/models/site/deploy_dependencies.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rgl/adjacency'
|
||||
require 'rgl/topsort'
|
||||
|
||||
class Site
|
||||
module DeployDependencies
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# Genera un grafo dirigido de todos los métodos de publicación
|
||||
#
|
||||
# @return [RGL::DirectedAdjacencyGraph]
|
||||
def deployment_graph
|
||||
@deployment_graph ||= RGL::DirectedAdjacencyGraph.new.tap do |graph|
|
||||
deploys.each do |deploy|
|
||||
graph.add_vertex deploy
|
||||
end
|
||||
|
||||
deploys.each do |deploy|
|
||||
deploy.class.all_dependencies.each do |dependency|
|
||||
deploys.where(type: dependency.to_s.classify).each do |deploy_dependency|
|
||||
graph.add_edge deploy_dependency, deploy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Devuelve una lista ordenada de todos los métodos de publicación
|
||||
#
|
||||
# @return [Array]
|
||||
def deployment_list
|
||||
@deployment_list ||= deployment_graph.topsort_iterator.to_a
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -37,7 +37,7 @@ class Site
|
|||
|
||||
author = GitAuthor.new email: "sutty@#{Site.domain}", name: 'Sutty'
|
||||
|
||||
repository.commit(file: modified,
|
||||
repository.commit(add: modified,
|
||||
message: I18n.t('sites.find_and_replace'),
|
||||
usuarie: author)
|
||||
end
|
||||
|
|
|
@ -1,22 +1,125 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Indexa todos los artículos de un sitio
|
||||
#
|
||||
# TODO: Hacer opcional
|
||||
class Site
|
||||
# Indexa todos los artículos de un sitio
|
||||
#
|
||||
# TODO: Hacer opcional
|
||||
module Index
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# TODO: Debería ser un Job?
|
||||
after_create :index_posts!
|
||||
has_many :indexed_posts, dependent: :destroy
|
||||
|
||||
MODIFIED_STATUSES = %i[added modified].freeze
|
||||
DELETED_STATUSES = %i[deleted].freeze
|
||||
LOCALE_FROM_PATH = /\A_/.freeze
|
||||
|
||||
def index_posts!
|
||||
Site.transaction do
|
||||
docs.each(&:index!)
|
||||
|
||||
update(last_indexed_commit: repository.head_commit.oid)
|
||||
end
|
||||
end
|
||||
|
||||
# Encuentra los artículos modificados entre dos commits y los
|
||||
# reindexa.
|
||||
def reindex_changes!
|
||||
return unless reindexable?
|
||||
|
||||
Site.transaction do
|
||||
remove_deleted_posts!
|
||||
reindex_modified_posts!
|
||||
|
||||
update(last_indexed_commit: repository.head_commit.oid)
|
||||
end
|
||||
end
|
||||
|
||||
# No hacer nada si el repositorio no cambió o no hubo cambios
|
||||
# necesarios
|
||||
def reindexable?
|
||||
return false if last_indexed_commit.blank?
|
||||
return false if last_indexed_commit == repository.head_commit.oid
|
||||
|
||||
!indexable_posts.empty?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Trae el último commit indexado desde el repositorio
|
||||
#
|
||||
# @return [Rugged::Commit]
|
||||
def indexed_commit
|
||||
@indexed_commit ||= repository.rugged.lookup(last_indexed_commit)
|
||||
end
|
||||
|
||||
# Calcula la diferencia entre el último commit indexado y el
|
||||
# actual
|
||||
#
|
||||
# XXX: Esto no tiene en cuenta modificaciones en la historia como
|
||||
# cambio de ramas, reverts y etc, solo asume que se mueve hacia
|
||||
# adelante en la misma rama o las dos ramas están relacionadas.
|
||||
#
|
||||
# @return [Rugged::Diff]
|
||||
def diff_with_head
|
||||
@diff_with_head ||= indexed_commit.diff(repository.head_commit)
|
||||
end
|
||||
|
||||
# Obtiene todos los archivos a reindexar
|
||||
#
|
||||
# @return [Array<Rugged::Delta>]
|
||||
def indexable_posts
|
||||
@indexable_posts ||=
|
||||
diff_with_head.each_delta.select do |delta|
|
||||
locales.any? do |locale|
|
||||
delta.old_file[:path].start_with? "_#{locale}/"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Elimina los artículos eliminados o que cambiaron de ubicación
|
||||
# del índice
|
||||
def remove_deleted_posts!
|
||||
indexable_posts.select do |delta|
|
||||
DELETED_STATUSES.include? delta.status
|
||||
end.each do |delta|
|
||||
locale, path = locale_and_path_from(delta.old_file[:path])
|
||||
|
||||
indexed_posts.destroy_by(locale: locale, path: path).tap do |destroyed_posts|
|
||||
next unless destroyed_posts.empty?
|
||||
|
||||
Rails.logger.info I18n.t('indexed_posts.deleted', site: name, path: path, records: destroyed_posts.count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Reindexa artículos que cambiaron de ubicación, se agregaron
|
||||
# o fueron modificados
|
||||
def reindex_modified_posts!
|
||||
indexable_posts.select do |delta|
|
||||
MODIFIED_STATUSES.include? delta.status
|
||||
end.each do |delta|
|
||||
locale, path = locale_and_path_from(delta.new_file[:path])
|
||||
|
||||
posts(lang: locale).find(path).index!
|
||||
end
|
||||
end
|
||||
|
||||
# Obtiene el idioma y la ruta del post a partir de la ubicación en
|
||||
# el disco.
|
||||
#
|
||||
# Las rutas vienen en ASCII-9BIT desde Rugged, pero en realidad
|
||||
# son UTF-8
|
||||
#
|
||||
# @return [Array<String>]
|
||||
def locale_and_path_from(path)
|
||||
locale, path = path.force_encoding('utf-8').split(File::SEPARATOR, 2)
|
||||
|
||||
[
|
||||
locale.sub(LOCALE_FROM_PATH, ''),
|
||||
File.basename(path, '.*')
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
38
app/models/site/layout_ordering.rb
Normal file
38
app/models/site/layout_ordering.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Site
|
||||
# Obtiene un listado de layouts (schemas)
|
||||
module LayoutOrdering
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
|
||||
# Obtiene o genera un listado de layouts (schemas) con sus
|
||||
# dependencias, para poder generar un árbol.
|
||||
#
|
||||
# Por defecto, si el sitio no lo soporta, se obtienen los layouts
|
||||
# ordenados alfabéticamente por traducción.
|
||||
#
|
||||
# @return [Hash]
|
||||
def schema_organization
|
||||
@schema_organization ||=
|
||||
begin
|
||||
schema_organization = data.dig('schema', 'organization')
|
||||
schema_organization&.symbolize_keys!
|
||||
schema_organization&.transform_values! do |ary|
|
||||
ary.map(&:to_sym)
|
||||
end
|
||||
|
||||
schema_organization ||
|
||||
begin
|
||||
layouts = self.layouts.sort_by(&:humanized_name).map(&:name)
|
||||
Hash[layouts.zip([].fill([], 0, layouts.size))]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: Deprecar cuando renombremos layouts a schemas
|
||||
alias layout_organization schema_organization
|
||||
end
|
||||
end
|
||||
end
|
|
@ -29,7 +29,7 @@ class Site
|
|||
|
||||
# Obtiene el origin
|
||||
#
|
||||
# @return [Rugged::Remote]
|
||||
# @return [Rugged::Remote, nil]
|
||||
def origin
|
||||
@origin ||= rugged.remotes.find do |remote|
|
||||
remote.name == 'origin'
|
||||
|
@ -54,7 +54,7 @@ class Site
|
|||
# Incorpora los cambios en el repositorio actual
|
||||
#
|
||||
# @return [Rugged::Commit]
|
||||
def merge(usuarie)
|
||||
def merge(usuarie, message = I18n.t('sites.fetch.merge.message'))
|
||||
merge = rugged.merge_commits(head_commit, remote_head_commit)
|
||||
|
||||
# No hacemos nada si hay conflictos, pero notificarnos
|
||||
|
@ -69,12 +69,16 @@ class Site
|
|||
.create(rugged, update_ref: 'HEAD',
|
||||
parents: [head_commit, remote_head_commit],
|
||||
tree: merge.write_tree(rugged),
|
||||
message: I18n.t('sites.fetch.merge.message'),
|
||||
message: message,
|
||||
author: author(usuarie), committer: committer)
|
||||
|
||||
# Forzamos el checkout para mover el HEAD al último commit y
|
||||
# escribir los cambios
|
||||
rugged.checkout 'HEAD', strategy: :force
|
||||
|
||||
git_sh("git", "lfs", "fetch", "origin", default_branch)
|
||||
# reemplaza los pointers por los archivos correspondientes
|
||||
git_sh("git", "lfs", "checkout")
|
||||
commit
|
||||
end
|
||||
|
||||
|
@ -114,11 +118,21 @@ class Site
|
|||
end
|
||||
|
||||
# Guarda los cambios en git
|
||||
def commit(file:, usuarie:, message:, remove: false)
|
||||
file = [file] unless file.respond_to? :each
|
||||
#
|
||||
# @param :add [Array] Archivos a agregar
|
||||
# @param :rm [Array] Archivos a eliminar
|
||||
# @param :usuarie [Usuarie] Quién hace el commit
|
||||
# @param :message [String] Mensaje
|
||||
def commit(add: [], rm: [], usuarie:, message:)
|
||||
# Cargar el árbol actual
|
||||
rugged.index.read_tree rugged.head.target.tree
|
||||
|
||||
file.each do |f|
|
||||
remove ? rm(f) : add(f)
|
||||
add.each do |file|
|
||||
rugged.index.add(relativize(file))
|
||||
end
|
||||
|
||||
rm.each do |file|
|
||||
rugged.index.remove(relativize(file))
|
||||
end
|
||||
|
||||
# Escribir los cambios para que el repositorio se vea tal cual
|
||||
|
@ -139,41 +153,58 @@ class Site
|
|||
{ name: 'Sutty', email: "sutty@#{Site.domain}", time: Time.now }
|
||||
end
|
||||
|
||||
def add(file)
|
||||
rugged.index.add(relativize(file))
|
||||
end
|
||||
|
||||
def rm(file)
|
||||
rugged.index.remove(relativize(file))
|
||||
end
|
||||
|
||||
# Garbage collection
|
||||
#
|
||||
# @return [Boolean]
|
||||
def gc
|
||||
env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path }
|
||||
cmd = 'git gc'
|
||||
|
||||
r = nil
|
||||
Dir.chdir(path) do
|
||||
Open3.popen2e(env, cmd, unsetenv_others: true) do |_, _, t|
|
||||
r = t.value
|
||||
end
|
||||
git_sh("git", "gc")
|
||||
end
|
||||
|
||||
r&.success?
|
||||
# Pushea cambios al repositorio remoto
|
||||
#
|
||||
# @param :remote [Rugged::Remote]
|
||||
# @return [Boolean, nil]
|
||||
def push(remote = origin)
|
||||
remote.push(rugged.head.canonical_name, credentials: credentials_for(remote))
|
||||
git_sh('git', 'lfs', 'push', remote.name, default_branch)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# @deprecated
|
||||
def credentials
|
||||
@credentials ||= credentials_for(origin)
|
||||
end
|
||||
|
||||
# Si Sutty tiene una llave privada de tipo ED25519, devuelve las
|
||||
# credenciales necesarias para trabajar con repositorios remotos.
|
||||
#
|
||||
# @param :remote [Rugged::Remote]
|
||||
# @return [Nil, Rugged::Credentials::SshKey]
|
||||
def credentials
|
||||
def credentials_for(remote)
|
||||
return unless File.exist? private_key
|
||||
|
||||
@credentials ||= Rugged::Credentials::SshKey.new username: 'git', publickey: public_key, privatekey: private_key
|
||||
Rugged::Credentials::SshKey.new username: username_for(remote), publickey: public_key, privatekey: private_key
|
||||
end
|
||||
|
||||
# Obtiene el nombre de usuario para el repositorio remoto, por
|
||||
# defecto git
|
||||
#
|
||||
# @param :remote [Rugged::Remote]
|
||||
# @return [String]
|
||||
def username_for(remote)
|
||||
username = parse_url(remote.url)&.user if remote.respond_to? :url
|
||||
|
||||
username || 'git'
|
||||
end
|
||||
|
||||
# @param :url [String]
|
||||
# @return [URI, nil]
|
||||
def parse_url(url)
|
||||
GitCloneUrl.parse(url)
|
||||
rescue URI::Error => e
|
||||
ExceptionNotifier.notify_exception(e, data: { path: path, url: url })
|
||||
nil
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
|
@ -189,5 +220,20 @@ class Site
|
|||
def relativize(file)
|
||||
Pathname.new(file).relative_path_from(Pathname.new(path)).to_s
|
||||
end
|
||||
|
||||
# Ejecuta un comando de git
|
||||
#
|
||||
# @param :args [Array]
|
||||
# @return [Boolean]
|
||||
def git_sh(*args)
|
||||
env = { 'PATH' => '/usr/bin', 'LANG' => ENV['LANG'], 'HOME' => path }
|
||||
|
||||
r = nil
|
||||
Open3.popen2e(env, *args, unsetenv_others: true, chdir: path) do |_, _, t|
|
||||
r = t.value
|
||||
end
|
||||
|
||||
r&.success?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
23
app/models/site/social_distributed_press.rb
Normal file
23
app/models/site/social_distributed_press.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Site
|
||||
# Agrega soporte para Social Distributed Press en los sitios
|
||||
module SocialDistributedPress
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
encrypts :private_key_pem
|
||||
|
||||
before_save :generate_private_key_pem!, unless: :private_key_pem?
|
||||
|
||||
private
|
||||
|
||||
# Genera la llave privada y la almacena
|
||||
#
|
||||
# @return [nil]
|
||||
def generate_private_key_pem!
|
||||
self.private_key_pem ||= DistributedPress::V1::Social::Client.new(public_key_url: nil, key_size: 2048).private_key.export
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
3
app/models/site_build_stat.rb
Normal file
3
app/models/site_build_stat.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
SiteBuildStat = Struct.new(:site)
|
|
@ -2,14 +2,19 @@
|
|||
|
||||
# Usuarie de la plataforma
|
||||
class Usuarie < ApplicationRecord
|
||||
include Usuarie::Consent
|
||||
|
||||
devise :invitable, :database_authenticatable,
|
||||
:recoverable, :rememberable, :validatable,
|
||||
:confirmable, :lockable, :registerable
|
||||
|
||||
validates_uniqueness_of :email
|
||||
validates_with EmailAddress::ActiveRecordValidator, field: :email
|
||||
validate :locale_available!
|
||||
|
||||
before_create :lang_from_locale!
|
||||
before_update :remove_confirmation_invitation_inconsistencies!
|
||||
before_update :accept_invitation_after_confirmation!
|
||||
|
||||
has_many :roles
|
||||
has_many :sites, through: :roles
|
||||
|
@ -41,9 +46,48 @@ class Usuarie < ApplicationRecord
|
|||
lock_access! if attempts_exceeded? && !access_locked?
|
||||
end
|
||||
|
||||
def send_devise_notification(notification, *args)
|
||||
I18n.with_locale(lang) do
|
||||
devise_mailer.send(notification, self, *args).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
# Les usuaries necesitan link de invitación si no tenían cuenta
|
||||
# y todavía no aceptaron la invitación anterior.
|
||||
def needs_invitation_link?
|
||||
created_by_invite? && !invitation_accepted?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def lang_from_locale!
|
||||
self.lang = I18n.locale.to_s
|
||||
end
|
||||
|
||||
# El invitation_token solo es necesario cuando fue creade por otre
|
||||
# usuarie. De lo contrario lo que queremos es un proceso de
|
||||
# confirmación.
|
||||
def remove_confirmation_invitation_inconsistencies!
|
||||
self.invitation_token = nil unless created_by_invite?
|
||||
end
|
||||
|
||||
# Si le usuarie (re)confirma su cuenta con una invitación pendiente,
|
||||
# considerarla aceptada también.
|
||||
def accept_invitation_after_confirmation!
|
||||
if confirmed?
|
||||
self.invitation_token = nil
|
||||
self.invitation_accepted_at ||= Time.now.utc
|
||||
end
|
||||
end
|
||||
|
||||
# Muestra un error si el idioma no está disponible al cambiar el
|
||||
# idioma de la cuenta.
|
||||
#
|
||||
# @return [nil]
|
||||
def locale_available!
|
||||
return if I18n.locale_available? self.lang
|
||||
|
||||
errors.add(:lang, I18n.t('activerecord.errors.models.usuarie.attributes.lang.not_available'))
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
66
app/policies/indexed_post_policy.rb
Normal file
66
app/policies/indexed_post_policy.rb
Normal file
|
@ -0,0 +1,66 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Política de acceso a artículos
|
||||
class IndexedPostPolicy
|
||||
attr_reader :indexed_post, :usuarie, :site
|
||||
|
||||
def initialize(usuarie, indexed_post)
|
||||
@usuarie = usuarie
|
||||
@indexed_post = indexed_post
|
||||
@site = indexed_post.site
|
||||
end
|
||||
|
||||
def index?
|
||||
true
|
||||
end
|
||||
|
||||
# Les invitades solo pueden ver sus propios posts
|
||||
def show?
|
||||
site.usuarie?(usuarie) || site.indexed_posts.by_usuarie(usuarie.id).find_by_post_id(indexed_post.post_id).present?
|
||||
end
|
||||
|
||||
def preview?
|
||||
show?
|
||||
end
|
||||
|
||||
def new?
|
||||
create?
|
||||
end
|
||||
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def edit?
|
||||
update?
|
||||
end
|
||||
|
||||
# Les invitades solo pueden modificar sus propios artículos
|
||||
def update?
|
||||
show?
|
||||
end
|
||||
|
||||
# Solo las usuarias pueden eliminar artículos. Les invitades pueden
|
||||
# borrar sus propios artículos
|
||||
def destroy?
|
||||
update?
|
||||
end
|
||||
|
||||
# Las usuarias pueden ver todos los posts
|
||||
#
|
||||
# Les invitades solo pueden ver sus propios posts
|
||||
class Scope
|
||||
attr_reader :usuarie, :scope
|
||||
|
||||
def initialize(usuarie, scope)
|
||||
@usuarie = usuarie
|
||||
@scope = scope
|
||||
end
|
||||
|
||||
def resolve
|
||||
return scope if scope&.first&.site&.usuarie? usuarie
|
||||
|
||||
scope.by_usuarie(usuarie.id)
|
||||
end
|
||||
end
|
||||
end
|
16
app/policies/site_build_stat_policy.rb
Normal file
16
app/policies/site_build_stat_policy.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Quiénes pueden ver estados de compilación de un sitio
|
||||
class SiteBuildStatPolicy
|
||||
attr_reader :site_build_stat, :usuarie
|
||||
|
||||
def initialize(usuarie, site_build_stat)
|
||||
@usuarie = usuarie
|
||||
@site_build_stat = site_build_stat
|
||||
end
|
||||
|
||||
# Todes les usuaries e invitades de este sitio
|
||||
def index?
|
||||
site_build_stat.site.usuarie?(usuarie) || site_build_stat.site.invitade?(usuarie)
|
||||
end
|
||||
end
|
67
app/services/lfs_object_service.rb
Normal file
67
app/services/lfs_object_service.rb
Normal file
|
@ -0,0 +1,67 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Representa un objeto git LFS
|
||||
class LfsObjectService
|
||||
attr_reader :site, :blob
|
||||
|
||||
# @param :site [Site]
|
||||
# @param :blob [ActiveStorage::Blob]
|
||||
def initialize(site:, blob:)
|
||||
@site = site
|
||||
@blob = blob
|
||||
end
|
||||
|
||||
def process
|
||||
# Crear el directorio
|
||||
FileUtils.mkdir_p(File.dirname(object_path))
|
||||
|
||||
# Mover el archivo
|
||||
FileUtils.mv(path, object_path) unless File.exist? object_path
|
||||
|
||||
# Crear el pointer
|
||||
Site::Writer.new(site: site, file: path, content: pointer).save
|
||||
|
||||
# Commitear el pointer
|
||||
site.repository.commit(add: [path], usuarie: author, message: File.basename(path))
|
||||
|
||||
# Eliminar el pointer
|
||||
FileUtils.rm(path)
|
||||
|
||||
# Hacer link duro del objeto al archivo
|
||||
FileUtils.ln(object_path, path)
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def path
|
||||
@path ||= blob.service.path_for(blob.key)
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def digest
|
||||
@digest ||= Digest::SHA256.file(path).hexdigest
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def object_path
|
||||
@object_path ||= File.join(site.path, '.git', 'lfs', 'objects', digest[0..1], digest[2..3], digest)
|
||||
end
|
||||
|
||||
# @return [Integer]
|
||||
def size
|
||||
@size ||= File.size(File.exist?(object_path) ? object_path : path)
|
||||
end
|
||||
|
||||
# @return [String]
|
||||
def pointer
|
||||
@pointer ||=
|
||||
<<~POINTER
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:#{digest}
|
||||
size #{size}
|
||||
POINTER
|
||||
end
|
||||
|
||||
def author
|
||||
@author ||= GitAuthor.new email: "disk_service@#{Site.domain}", name: 'DiskService'
|
||||
end
|
||||
end
|
|
@ -12,7 +12,13 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
post.usuaries << usuarie
|
||||
params[:post][:draft] = true if site.invitade? usuarie
|
||||
|
||||
commit(action: :created, file: update_related_posts) if post.update(post_params)
|
||||
params.require(:post).permit(:slug).tap do |p|
|
||||
post.slug.value = p[:slug] if p[:slug].present?
|
||||
end
|
||||
|
||||
commit(action: :created, add: update_related_posts) if post.update(post_params)
|
||||
|
||||
update_site_license!
|
||||
|
||||
# Devolver el post aunque no se haya salvado para poder rescatar los
|
||||
# errores
|
||||
|
@ -28,7 +34,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
# Los artículos anónimos siempre son borradores
|
||||
params[:draft] = true
|
||||
|
||||
commit(action: :created) if post.update(anon_post_params)
|
||||
commit(action: :created, add: [post.path.absolute]) if post.update(anon_post_params)
|
||||
post
|
||||
end
|
||||
|
||||
|
@ -36,9 +42,17 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
post.usuaries << usuarie
|
||||
params[:post][:draft] = true if site.invitade? usuarie
|
||||
|
||||
# Eliminar ("mover") el archivo si cambió de ubicación.
|
||||
if post.update(post_params)
|
||||
rm = []
|
||||
rm << post.path.value_was if post.path.changed?
|
||||
|
||||
# Es importante que el artículo se guarde primero y luego los
|
||||
# relacionados.
|
||||
commit(action: :updated, file: update_related_posts) if post.update(post_params)
|
||||
commit(action: :updated, add: update_related_posts, rm: rm)
|
||||
|
||||
update_site_license!
|
||||
end
|
||||
|
||||
# Devolver el post aunque no se haya salvado para poder rescatar los
|
||||
# errores
|
||||
|
@ -48,7 +62,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
def destroy
|
||||
post.destroy!
|
||||
|
||||
commit(action: :destroyed) if post.destroyed?
|
||||
commit(action: :destroyed, rm: [post.path.absolute]) if post.destroyed?
|
||||
|
||||
post
|
||||
end
|
||||
|
@ -77,17 +91,19 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
|
||||
# TODO: Implementar transacciones!
|
||||
posts.save_all(validate: false) &&
|
||||
commit(action: :reorder, file: files)
|
||||
commit(action: :reorder, add: files)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def commit(action:, file: nil)
|
||||
site.repository.commit(file: file || post.path.absolute,
|
||||
def commit(action:, add: [], rm: [])
|
||||
site.repository.commit(add: add,
|
||||
rm: rm,
|
||||
usuarie: usuarie,
|
||||
remove: action == :destroyed,
|
||||
message: I18n.t("post_service.#{action}",
|
||||
title: post&.title&.value))
|
||||
|
||||
GitPushJob.perform_later(site)
|
||||
end
|
||||
|
||||
# Solo permitir cambiar estos atributos de cada articulo
|
||||
|
@ -133,4 +149,12 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do
|
|||
p.path.absolute if p.save(validate: false)
|
||||
end.compact << post.path.absolute
|
||||
end
|
||||
|
||||
# Si les usuaries modifican o crean una licencia, considerarla
|
||||
# personalizada en el panel.
|
||||
def update_site_license!
|
||||
if site.usuarie?(usuarie) && post.layout.name == :license && !site.licencia.custom?
|
||||
site.update licencia: Licencia.find_by_icons('custom')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
||||
def deploy
|
||||
site.enqueue!
|
||||
DeployJob.perform_async site.id
|
||||
DeployJob.perform_later site.id
|
||||
end
|
||||
|
||||
# Crea un sitio, agrega un rol nuevo y guarda los cambios a la
|
||||
|
@ -14,7 +14,9 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
self.site = Site.new params
|
||||
|
||||
add_role temporal: false, rol: 'usuarie'
|
||||
sync_nodes
|
||||
site.deploys.build type: 'DeployLocal'
|
||||
# Los sitios de testing no se sincronizan
|
||||
sync_nodes unless site.name.end_with? '.testing'
|
||||
|
||||
I18n.with_locale(usuarie.lang.to_sym || I18n.default_locale) do
|
||||
# No se puede llamar a site.config antes de save porque el sitio
|
||||
|
@ -26,12 +28,14 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
|
||||
site.save &&
|
||||
site.config.write &&
|
||||
commit_config(action: :create)
|
||||
end
|
||||
|
||||
add_licencias
|
||||
|
||||
commit_config(action: :create) &&
|
||||
site.reset.nil? &&
|
||||
add_licencias &&
|
||||
add_code_of_conduct &&
|
||||
add_privacy_policy &&
|
||||
site.index_posts! &&
|
||||
deploy
|
||||
end
|
||||
|
||||
site
|
||||
end
|
||||
|
@ -41,19 +45,18 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
I18n.with_locale(usuarie&.lang&.to_sym || I18n.default_locale) do
|
||||
site.update(params) &&
|
||||
site.config.write &&
|
||||
commit_config(action: :update)
|
||||
end
|
||||
|
||||
commit_config(action: :update) &&
|
||||
site.reset.nil? &&
|
||||
change_licencias
|
||||
end
|
||||
|
||||
site
|
||||
end
|
||||
|
||||
# Genera los Deploy necesarios para el sitio a menos que ya los tenga.
|
||||
def build_deploys
|
||||
Site::DEPLOYS.map { |deploy| "Deploy#{deploy.to_s.camelcase}" }
|
||||
.each do |deploy|
|
||||
next if site.deploys.find_by type: deploy
|
||||
Deploy.subclasses.each do |deploy|
|
||||
next if site.deploys.find_by type: deploy.name
|
||||
|
||||
site.deploys.build type: deploy
|
||||
end
|
||||
|
@ -62,14 +65,11 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
# Agregar una dirección oculta de Tor al DeployHiddenService y a la
|
||||
# configuración del Site.
|
||||
def add_onion
|
||||
onion = params[:onion].strip
|
||||
deploy = DeployHiddenService.find_by(site: site)
|
||||
onion = params[:onion]
|
||||
deploy = params[:deploy]
|
||||
|
||||
return false unless !onion.blank? && deploy
|
||||
|
||||
deploy.values[:onion] = onion
|
||||
deploy.save
|
||||
|
||||
site.config['onion-location'] = onion
|
||||
site.config.write
|
||||
|
||||
|
@ -94,9 +94,11 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
def commit_config(action:)
|
||||
site.repository
|
||||
.commit(usuarie: usuarie,
|
||||
file: site.config.path,
|
||||
add: [site.config.path],
|
||||
message: I18n.t("site_service.#{action}",
|
||||
name: site.name))
|
||||
|
||||
GitPushJob.perform_later(site)
|
||||
end
|
||||
|
||||
def add_role(temporal: true, rol: 'invitade')
|
||||
|
@ -105,24 +107,28 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
end
|
||||
|
||||
# Crea la licencia del sitio para cada locale disponible en el sitio
|
||||
#
|
||||
# @return [Boolean]
|
||||
def add_licencias
|
||||
site.locales.each do |locale|
|
||||
next unless I18n.available_locales.include? locale
|
||||
return true unless site.layout? :license
|
||||
return true if site.licencia.custom?
|
||||
|
||||
Mobility.with_locale(locale) do
|
||||
with_all_locales do |locale|
|
||||
add_licencia lang: locale
|
||||
end
|
||||
end
|
||||
end.compact.map(&:valid?).all?
|
||||
end
|
||||
|
||||
# Crea una licencia
|
||||
#
|
||||
# @return [Post]
|
||||
def add_licencia(lang:)
|
||||
params = ActionController::Parameters.new(
|
||||
post: {
|
||||
layout: 'license',
|
||||
slug: Jekyll::Utils.slugify(I18n.t('activerecord.models.licencia')),
|
||||
lang: lang,
|
||||
title: site.licencia.name,
|
||||
description: I18n.t('sites.form.licencia.title'),
|
||||
author: %w[Sutty],
|
||||
permalink: "#{I18n.t('activerecord.models.licencia').downcase}/",
|
||||
description: site.licencia.short_description,
|
||||
content: CommonMarker.render_html(site.licencia.deed)
|
||||
}
|
||||
)
|
||||
|
@ -133,25 +139,27 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
# Encuentra la licencia a partir de su enlace permanente y le cambia
|
||||
# el contenido
|
||||
#
|
||||
# TODO: Crear un layout específico para licencias así es más certera
|
||||
# la búsqueda.
|
||||
# @return [Boolean]
|
||||
def change_licencias
|
||||
site.locales.each do |locale|
|
||||
next unless I18n.available_locales.include? locale
|
||||
return true unless site.layout? :license
|
||||
return true if site.licencia.custom?
|
||||
|
||||
Mobility.with_locale(locale) do
|
||||
permalink = "#{I18n.t('activerecord.models.licencia').downcase}/"
|
||||
post = site.posts(lang: locale).find_by(permalink: permalink)
|
||||
with_all_locales do |locale|
|
||||
post = site.posts(lang: locale).find_by(layout: 'license')
|
||||
|
||||
post ? change_licencia(post: post) : add_licencia(lang: locale)
|
||||
end
|
||||
end
|
||||
change_licencia(post: post) if post
|
||||
end.compact.map(&:valid?).all?
|
||||
end
|
||||
|
||||
# Cambia una licencia
|
||||
#
|
||||
# @param :post [Post]
|
||||
# @return [Post]
|
||||
def change_licencia(post:)
|
||||
params = ActionController::Parameters.new(
|
||||
post: {
|
||||
title: site.licencia.name,
|
||||
description: site.licencia.short_description,
|
||||
content: CommonMarker.render_html(site.licencia.deed)
|
||||
}
|
||||
)
|
||||
|
@ -160,10 +168,69 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
params: params).update
|
||||
end
|
||||
|
||||
# Agrega un código de conducta
|
||||
#
|
||||
# @return [Boolean]
|
||||
def add_code_of_conduct
|
||||
return true unless site.layout?(:code_of_conduct) || site.layout?(:page)
|
||||
|
||||
# TODO: soportar más códigos de conducta
|
||||
coc = CodeOfConduct.first
|
||||
|
||||
with_all_locales do |locale|
|
||||
params = ActionController::Parameters.new(
|
||||
post: {
|
||||
layout: site.layout?(:code_of_conduct) ? 'code_of_conduct' : 'page',
|
||||
lang: locale.to_s,
|
||||
title: coc.title,
|
||||
description: coc.description,
|
||||
content: CommonMarker.render_html(coc.content)
|
||||
}
|
||||
)
|
||||
|
||||
PostService.new(site: site, usuarie: usuarie, params: params).create
|
||||
end.compact.map(&:valid?).all?
|
||||
end
|
||||
|
||||
# Agrega política de privacidad
|
||||
#
|
||||
# @return [Boolean]
|
||||
def add_privacy_policy
|
||||
return true unless site.layout?(:privacy_policy) || site.layout?(:page)
|
||||
|
||||
pp = PrivacyPolicy.first
|
||||
|
||||
with_all_locales do |locale|
|
||||
params = ActionController::Parameters.new(
|
||||
post: {
|
||||
layout: site.layout?(:privacy_policy) ? 'privacy_policy' : 'page',
|
||||
lang: locale.to_s,
|
||||
title: pp.title,
|
||||
description: pp.description,
|
||||
content: CommonMarker.render_html(pp.content)
|
||||
}
|
||||
)
|
||||
|
||||
PostService.new(site: site, usuarie: usuarie, params: params).create
|
||||
end.compact.map(&:valid?).all?
|
||||
end
|
||||
|
||||
# Crea los deploys necesarios para sincronizar a otros nodos de Sutty
|
||||
def sync_nodes
|
||||
Rails.application.nodes.each do |node|
|
||||
site.deploys.build(type: 'DeployRsync', destination: "sutty@#{node}:#{site.hostname}")
|
||||
site.deploys.build(type: 'DeployFullRsync', destination: "rsync://rsyncd.#{node}/deploys/", hostname: node)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def with_all_locales(&block)
|
||||
site.locales.map do |locale|
|
||||
next unless I18n.available_locales.include? locale
|
||||
|
||||
Mobility.with_locale(locale) do
|
||||
yield locale
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
6
app/views/bootstrap/_custom_checkbox.haml
Normal file
6
app/views/bootstrap/_custom_checkbox.haml
Normal file
|
@ -0,0 +1,6 @@
|
|||
- help_id = "#{id}_help"
|
||||
|
||||
.custom-control.custom-checkbox
|
||||
%input.custom-control-input{ id: id, type: 'checkbox', name: name, value: value, required: required }
|
||||
%label.custom-control-label{ for: id, aria: { describedby: help_id } }= content
|
||||
%small.form-text.text-muted{ id: help_id }= yield
|
20
app/views/build_stats/index.haml
Normal file
20
app/views/build_stats/index.haml
Normal file
|
@ -0,0 +1,20 @@
|
|||
%main.row
|
||||
%aside.menu.col-md-3
|
||||
= render 'sites/header', site: @site
|
||||
.col
|
||||
%h1= t('.title')
|
||||
|
||||
%table.table
|
||||
%thead
|
||||
%tr
|
||||
- @headers.each do |header|
|
||||
%th{ scope: 'col' }= header
|
||||
%tbody
|
||||
- @table.each do |row|
|
||||
- row[:urls].each do |url|
|
||||
%tr
|
||||
%th{ scope: 'row' }= row[:title]
|
||||
%td= link_to_if (url.present? && url.scheme.present?), url.to_s, url.to_s, class: 'word-break-all'
|
||||
%td
|
||||
%time{ datetime: row[:seconds][:machine] }= row[:seconds][:human]
|
||||
%td= row[:size]
|
|
@ -13,7 +13,7 @@
|
|||
%tr
|
||||
%td= row[:title]
|
||||
%td= row[:status]
|
||||
%td= link_to_if url.present?, url, url
|
||||
%td= link_to_if (url.present? && url.scheme.present?), url.to_s, url.to_s
|
||||
%td
|
||||
%time{ datetime: row[:seconds][:machine] }= row[:seconds][:human]
|
||||
%td= row[:size]
|
||||
|
|
21
app/views/deploys/_deploy_distributed_press.haml
Normal file
21
app/views/deploys/_deploy_distributed_press.haml
Normal file
|
@ -0,0 +1,21 @@
|
|||
-# Publicar a la web distribuida
|
||||
|
||||
.row
|
||||
.col
|
||||
= deploy.hidden_field :id
|
||||
= deploy.hidden_field :type
|
||||
.custom-control.custom-switch
|
||||
-#
|
||||
El checkbox invierte la lógica de destrucción porque queremos
|
||||
crear el deploy si está activado y destruirlo si está
|
||||
desactivado.
|
||||
= deploy.check_box :_destroy,
|
||||
{ checked: deploy.object.persisted?, class: 'custom-control-input' },
|
||||
'0', '1'
|
||||
= deploy.label :_destroy, class: 'custom-control-label' do
|
||||
%h3= t('.title')
|
||||
= sanitize_markdown t('.help', public_url: deploy.object.site.url),
|
||||
tags: %w[p strong em a]
|
||||
|
||||
|
||||
%hr/
|
1
app/views/deploys/_deploy_full_rsync.haml
Normal file
1
app/views/deploys/_deploy_full_rsync.haml
Normal file
|
@ -0,0 +1 @@
|
|||
-# nada
|
|
@ -17,7 +17,8 @@
|
|||
= sanitize_markdown t('.help', public_url: deploy.object.site.url),
|
||||
tags: %w[p strong em a]
|
||||
|
||||
- if deploy.object.fqdn
|
||||
- begin
|
||||
= sanitize_markdown t('.help_2', url: deploy.object.url),
|
||||
tags: %w[p strong em a]
|
||||
- rescue ArgumentError
|
||||
%hr/
|
||||
|
|
1
app/views/deploys/_deploy_localized_domain.haml
Normal file
1
app/views/deploys/_deploy_localized_domain.haml
Normal file
|
@ -0,0 +1 @@
|
|||
-# nada
|
21
app/views/deploys/_deploy_social_distributed_press.haml
Normal file
21
app/views/deploys/_deploy_social_distributed_press.haml
Normal file
|
@ -0,0 +1,21 @@
|
|||
-# Publicar a la web distribuida
|
||||
|
||||
.row
|
||||
.col
|
||||
= deploy.hidden_field :id
|
||||
= deploy.hidden_field :type
|
||||
.custom-control.custom-switch
|
||||
-#
|
||||
El checkbox invierte la lógica de destrucción porque queremos
|
||||
crear el deploy si está activado y destruirlo si está
|
||||
desactivado.
|
||||
= deploy.check_box :_destroy,
|
||||
{ checked: deploy.object.persisted?, class: 'custom-control-input' },
|
||||
'0', '1'
|
||||
= deploy.label :_destroy, class: 'custom-control-label' do
|
||||
%h3= t('.title')
|
||||
= sanitize_markdown t('.help'),
|
||||
tags: %w[p strong em a]
|
||||
|
||||
|
||||
%hr/
|
|
@ -1,4 +1,4 @@
|
|||
- site = @resource.sites.last
|
||||
- site = @resource.roles.where(temporal: true).last&.site
|
||||
|
||||
%p= t('devise.mailer.invitation_instructions.hello',
|
||||
email: @resource.email)
|
||||
|
@ -8,12 +8,17 @@
|
|||
%h1= site.title
|
||||
%p= site.description
|
||||
|
||||
%p= link_to t('devise.mailer.invitation_instructions.accept'),
|
||||
- if @resource.needs_invitation_link?
|
||||
%p= link_to t('devise.mailer.invitation_instructions.accept'),
|
||||
accept_invitation_url(@resource, invitation_token: @token, change_locale_to: @resource.lang)
|
||||
|
||||
- if @resource.invitation_due_at
|
||||
- if @resource.invitation_due_at
|
||||
%p= t('devise.mailer.invitation_instructions.accept_until',
|
||||
due_date: l(@resource.invitation_due_at,
|
||||
format: :'devise.mailer.invitation_instructions.accept_until_format'))
|
||||
|
||||
%p= t('devise.mailer.invitation_instructions.ignore')
|
||||
%p= t('devise.mailer.invitation_instructions.ignore')
|
||||
- elsif !@resource.confirmed? && @resource.confirmation_token
|
||||
= confirmation_url(@resource, confirmation_token: @resource.confirmation_token, change_locale_to: @resource.lang)
|
||||
- else
|
||||
%p= link_to t('devise.mailer.invitation_instructions.sign_in'), root_url
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- site = @resource.sites.last
|
||||
- site = @resource.roles.where(temporal: true).last&.site
|
||||
|
||||
= t('devise.mailer.invitation_instructions.hello', email: @resource.email)
|
||||
\
|
||||
|
@ -9,11 +9,17 @@
|
|||
\
|
||||
= site.description
|
||||
\
|
||||
= accept_invitation_url(@resource, invitation_token: @token, change_locale_to: @resource.lang)
|
||||
\
|
||||
- if @resource.invitation_due_at
|
||||
- if @resource.needs_invitation_link?
|
||||
= accept_invitation_url(@resource, invitation_token: @token, change_locale_to: @resource.lang)
|
||||
\
|
||||
- if @resource.invitation_due_at
|
||||
= t('devise.mailer.invitation_instructions.accept_until',
|
||||
due_date: l(@resource.invitation_due_at,
|
||||
format: :'devise.mailer.invitation_instructions.accept_until_format'))
|
||||
\
|
||||
= t('devise.mailer.invitation_instructions.ignore')
|
||||
\
|
||||
= t('devise.mailer.invitation_instructions.ignore')
|
||||
- elsif !@resource.confirmed? && @resource.confirmation_token
|
||||
= confirmation_url(@resource, confirmation_token: @resource.confirmation_token, change_locale_to: @resource.lang)
|
||||
- else
|
||||
= root_url(change_locale_to: @resource.lang)
|
||||
= t('devise.mailer.invitation_instructions.sign_in')
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
= render 'devise/shared/error_messages', resource: resource
|
||||
|
||||
.row.align-items-center.justify-content-center.full-height
|
||||
.col-md-5.align-self-center
|
||||
.col-md-6.align-self-center
|
||||
%h2= t('.sign_up')
|
||||
%p= t('.help')
|
||||
|
||||
|
@ -39,6 +39,21 @@
|
|||
min: @minimum_password_length,
|
||||
aria: { describedby: 'minimum-password-length' },
|
||||
placeholder: t("#{password}_confirmation")
|
||||
|
||||
.form-group
|
||||
- Usuarie::CONSENT_FIELDS.each do |field|
|
||||
- required = t(".#{field}.required", default: '').present?
|
||||
- id = "usuarie_#{field}"
|
||||
- name = "usuarie[#{field}]"
|
||||
- content = t(".#{field}.label")
|
||||
- href = t(".#{field}.href", default: '')
|
||||
- help_content = t(".#{field}.help")
|
||||
= render 'bootstrap/custom_checkbox', id: id, name: name, content: content, required: required, value: "1" do
|
||||
- if href.present?
|
||||
= link_to help_content, href, target: '_blank', rel: 'noopener'
|
||||
- else
|
||||
= help_content
|
||||
|
||||
.actions
|
||||
= f.submit t('.sign_up'),
|
||||
class: 'btn btn-lg btn-block'
|
||||
|
|
3
app/views/env/index.js.haml
vendored
3
app/views/env/index.js.haml
vendored
|
@ -1,4 +1,5 @@
|
|||
= cache @site do
|
||||
- if @site
|
||||
= cache @site do
|
||||
:plain
|
||||
window.env = {
|
||||
AIRBRAKE_SITE_ID: #{@site.id},
|
||||
|
|
|
@ -19,10 +19,15 @@
|
|||
= link_to t('.tienda'), @site.tienda_url,
|
||||
role: 'button', class: 'btn'
|
||||
|
||||
%li.nav-item
|
||||
= link_to t('.contact_us'), t('.contact_us_href'),
|
||||
class: 'btn', rel: 'me', target: '_blank'
|
||||
|
||||
%li.nav-item
|
||||
= link_to t('.logout'), main_app.destroy_usuarie_session_path,
|
||||
method: :delete, role: 'button', class: 'btn'
|
||||
- else
|
||||
- params.permit!
|
||||
- I18n.available_locales.each do |locale|
|
||||
- next if locale == I18n.locale
|
||||
= link_to t(locale), "?change_locale_to=#{locale}"
|
||||
= link_to t("switch_locale.#{locale}"), params.to_h.merge(change_locale_to: locale)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- flash.each do |type, message|
|
||||
- unless type == 'js'
|
||||
= render 'bootstrap/alert' do
|
||||
= message
|
||||
= sanitize_markdown message, tags: %w[a strong em]
|
||||
|
|
7
app/views/layouts/_link_rel_alternate.haml
Normal file
7
app/views/layouts/_link_rel_alternate.haml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- unless current_usuarie
|
||||
- params.permit!
|
||||
- I18n.available_locales.each do |locale|
|
||||
- url = url_for(**params.to_h.merge(change_locale_to: locale), only_path: false)
|
||||
- if locale == I18n.default_locale
|
||||
%link{ rel: 'alternate', hreflang: 'x-default', href: url }
|
||||
%link{ rel: 'alternate', hreflang: locale, href: url }
|
|
@ -4,7 +4,7 @@
|
|||
%meta{ charset: 'UTF-8' }/
|
||||
%meta{ content: 'text/html; charset=UTF-8',
|
||||
'http-equiv': 'Content-Type' }/
|
||||
%meta{ name: 'color-scheme', content: 'light dark' }/
|
||||
%meta{ name: 'color-scheme', content: 'light' }/
|
||||
%meta{ name: 'viewport',
|
||||
content: 'width=device-width, initial-scale=1.0' }/
|
||||
%meta{ name: 'referrer', content: 'same-origin' }/
|
||||
|
@ -17,6 +17,7 @@
|
|||
= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'
|
||||
= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload'
|
||||
= favicon_link_tag 'sutty_cuadrada.png', rel: 'apple-touch-icon', type: 'image/png'
|
||||
= render 'layouts/link_rel_alternate'
|
||||
|
||||
%body{ class: yield(:body) }
|
||||
.container-fluid#sutty
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
- invalid_help = site.config.fetch('invalid_help', t('.invalid_help'))
|
||||
- sending_help = site.config.fetch('sending_help', t('.sending_help'))
|
||||
.form-group
|
||||
= submit_tag t('.save'), class: 'btn submit-post'
|
||||
= render 'bootstrap/alert', class: 'invalid-help d-none' do
|
||||
= site.config.fetch('invalid_help', t('.invalid_help'))
|
||||
= invalid_help
|
||||
= render 'bootstrap/alert', class: 'sending-help d-none' do
|
||||
= site.config.fetch('sending_help', t('.sending_help'))
|
||||
= sending_help
|
||||
|
|
4
app/views/posts/attribute_ro/_created_at.haml
Normal file
4
app/views/posts/attribute_ro/_created_at.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
%tr{ id: attribute }
|
||||
%th= post_label_t(attribute, post: post)
|
||||
%td{ dir: dir, lang: locale }
|
||||
%time{ datetime: metadata.value.xmlschema }= l metadata.value
|
|
@ -1,4 +1,5 @@
|
|||
%tr{ id: attribute }
|
||||
- if site.locales.count > 1
|
||||
%tr{ id: attribute }
|
||||
%th= post_label_t(attribute, post: post)
|
||||
%td
|
||||
%ul
|
||||
|
|
1
app/views/posts/attributes/_created_at.haml
Normal file
1
app/views/posts/attributes/_created_at.haml
Normal file
|
@ -0,0 +1 @@
|
|||
-# nada
|
|
@ -22,7 +22,7 @@
|
|||
= file_field(*field_name_for(base, attribute, :path),
|
||||
**field_options(attribute, metadata, required: (metadata.required && !metadata.path?)),
|
||||
class: "custom-file-input #{invalid(post, attribute)}",
|
||||
accept: 'image/*', data: { preview: "#{attribute}-preview" })
|
||||
accept: ActiveStorage.web_image_content_types.join(','), data: { preview: "#{attribute}-preview" })
|
||||
= label_tag "#{base}_#{attribute}_path",
|
||||
post_label_t(attribute, :path, post: post), class: 'custom-file-label'
|
||||
= render 'posts/attribute_feedback',
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue