5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 07:26:22 +00:00

Merge branch 'issue-1849' into issue-9357-1

This commit is contained in:
f 2022-12-30 18:16:06 -03:00
commit f3e1314c1a
6 changed files with 99 additions and 174 deletions

12
Gemfile
View file

@ -101,18 +101,6 @@ gem 'net-ssh'
gem 'ed25519' gem 'ed25519'
gem 'bcrypt_pbkdf' gem 'bcrypt_pbkdf'
group :themes do
gem 'adhesiones-jekyll-theme', require: false
gem 'editorial-autogestiva-jekyll-theme', require: false
gem 'minima', require: false
gem 'sutty-minima', require: false
gem 'radios-comunitarias-jekyll-theme', require: false
gem 'share-to-fediverse-jekyll-theme', require: false
gem 'sutty-donaciones-jekyll-theme', require: false
gem 'sutty-jekyll-theme', require: false
gem 'recursero-jekyll-theme', require: false
end
group :production do group :production do
gem 'lograge' gem 'lograge'
end end

View file

@ -86,23 +86,8 @@ GEM
minitest (>= 5.1) minitest (>= 5.1)
tzinfo (~> 2.0) tzinfo (~> 2.0)
zeitwerk (~> 2.3) zeitwerk (~> 2.3)
addressable (2.8.1) addressable (2.8.0)
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 5.0)
adhesiones-jekyll-theme (0.2.5)
jekyll (~> 4)
jekyll-commonmark (~> 1.3)
jekyll-data (~> 1.1)
jekyll-dotenv (>= 0.2)
jekyll-feed (~> 0.15)
jekyll-ignore-layouts (~> 0)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-linked-posts (~> 0)
jekyll-locales (~> 0.1)
jekyll-order (~> 0)
jekyll-relative-urls (~> 0)
jekyll-seo-tag (~> 2)
sutty-liquid (~> 0)
ast (2.4.2) ast (2.4.2)
autoprefixer-rails (10.4.7.0) autoprefixer-rails (10.4.7.0)
execjs (~> 2) execjs (~> 2)
@ -173,26 +158,7 @@ GEM
railties (>= 3.2) railties (>= 3.2)
down (5.4.0) down (5.4.0)
addressable (~> 2.8) addressable (~> 2.8)
ed25519 (1.3.0-x86_64-linux-musl) ed25519 (1.2.4-x86_64-linux-musl)
editorial-autogestiva-jekyll-theme (0.3.4)
jekyll (~> 4)
jekyll-commonmark (~> 1.3)
jekyll-data (~> 1.1)
jekyll-dotenv (>= 0.2)
jekyll-feed (~> 0.15)
jekyll-hardlinks (~> 0)
jekyll-ignore-layouts (~> 0)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-linked-posts (~> 0)
jekyll-locales (~> 0.1)
jekyll-order (~> 0)
jekyll-relative-urls (~> 0)
jekyll-seo-tag (~> 2)
jekyll-spree-client (~> 0)
jekyll-unique-urls (~> 0)
jekyll-write-and-commit-changes (~> 0)
sutty-liquid (~> 0)
em-websocket (0.5.3) em-websocket (0.5.3)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
http_parser.rb (~> 0) http_parser.rb (~> 0)
@ -369,13 +335,9 @@ GEM
mini_histogram (0.3.1) mini_histogram (0.3.1)
mini_magick (4.12.0) mini_magick (4.12.0)
mini_mime (1.1.2) mini_mime (1.1.2)
mini_portile2 (2.8.1) mini_portile2 (2.6.1)
minima (2.5.1) minitest (5.14.4)
jekyll (>= 3.5, < 5.0) mobility (1.2.4)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.16.3)
mobility (1.2.9)
i18n (>= 0.6.10, < 2) i18n (>= 0.6.10, < 2)
request_store (~> 1.0) request_store (~> 1.0)
multi_xml (0.6.0) multi_xml (0.6.0)
@ -423,31 +385,20 @@ GEM
rack (>= 1.2.0) rack (>= 1.2.0)
rack-proxy (0.7.4) rack-proxy (0.7.4)
rack rack
rack-test (2.0.2) rack-test (1.1.0)
rack (>= 1.3) rack (>= 1.0, < 3)
radios-comunitarias-jekyll-theme (0.1.5) rails (6.1.4.1)
jekyll (~> 4.0) actioncable (= 6.1.4.1)
jekyll-data (~> 1.1) actionmailbox (= 6.1.4.1)
jekyll-feed (~> 0.9) actionmailer (= 6.1.4.1)
jekyll-images (~> 0.2) actionpack (= 6.1.4.1)
jekyll-include-cache (~> 0) actiontext (= 6.1.4.1)
jekyll-linked-posts (~> 0) actionview (= 6.1.4.1)
jekyll-locales (~> 0.1) activejob (= 6.1.4.1)
jekyll-relative-urls (~> 0.0) activemodel (= 6.1.4.1)
jekyll-seo-tag (~> 2.1) activerecord (= 6.1.4.1)
jekyll-turbolinks (~> 0) activestorage (= 6.1.4.1)
rails (6.1.7) activesupport (= 6.1.4.1)
actioncable (= 6.1.7)
actionmailbox (= 6.1.7)
actionmailer (= 6.1.7)
actionpack (= 6.1.7)
actiontext (= 6.1.7)
actionview (= 6.1.7)
activejob (= 6.1.7)
activemodel (= 6.1.7)
activerecord (= 6.1.7)
activestorage (= 6.1.7)
activesupport (= 6.1.7)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 6.1.7) railties (= 6.1.7)
sprockets-rails (>= 2.0.0) sprockets-rails (>= 2.0.0)
@ -472,27 +423,9 @@ GEM
rb-fsevent (0.11.2) rb-fsevent (0.11.2)
rb-inotify (0.10.1) rb-inotify (0.10.1)
ffi (~> 1.0) ffi (~> 1.0)
recursero-jekyll-theme (0.2.0) redis (4.5.1)
jekyll (~> 4) redis-actionpack (5.2.0)
jekyll-commonmark (~> 1.3) actionpack (>= 5, < 7)
jekyll-data (~> 1.1)
jekyll-dotenv (>= 0.2)
jekyll-feed (~> 0.15)
jekyll-ignore-layouts (~> 0)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-linked-posts (~> 0)
jekyll-locales (~> 0.1)
jekyll-lunr (~> 0.1)
jekyll-order (~> 0)
jekyll-relative-urls (~> 0)
jekyll-seo-tag (~> 2)
jekyll-unique-urls (~> 0.1)
sutty-archives (~> 2.2)
sutty-liquid (~> 0)
redis (4.8.0)
redis-actionpack (5.3.0)
actionpack (>= 5, < 8)
redis-rack (>= 2.1.0, < 3) redis-rack (>= 2.1.0, < 3)
redis-store (>= 1.1.0, < 2) redis-store (>= 1.1.0, < 2)
redis-activesupport (5.3.0) redis-activesupport (5.3.0)
@ -563,15 +496,7 @@ GEM
rubyzip (>= 1.2.2, < 3.0) rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0) websocket (~> 1.0)
semantic_range (3.0.0) semantic_range (3.0.0)
sexp_processor (4.16.1) sexp_processor (4.16.0)
share-to-fediverse-jekyll-theme (0.1.4)
jekyll (~> 4.0)
jekyll-data (~> 1.1)
jekyll-feed (~> 0.9)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
simpleidn (0.2.1) simpleidn (0.2.1)
unf (~> 0.1.4) unf (~> 0.1.4)
sourcemap (0.1.1) sourcemap (0.1.1)
@ -596,31 +521,9 @@ GEM
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
sutty-archives (2.5.5) sutty-archives (2.5.5)
jekyll (>= 3.6, < 5.0) jekyll (>= 3.6, < 5.0)
sutty-donaciones-jekyll-theme (0.1.2) sutty-liquid (0.7.4)
jekyll (~> 4.0)
jekyll-data (~> 1.1)
jekyll-feed (~> 0.9)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-locales (~> 0.1)
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
sutty-archives (~> 2.2)
sutty-jekyll-theme (0.1.2)
jekyll (~> 4.0)
jekyll-feed (~> 0.9)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
sutty-liquid (0.11.6)
fast_blank (~> 1.0) fast_blank (~> 1.0)
jekyll (~> 4) jekyll (~> 4)
sutty-minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-relative-urls (~> 0)
jekyll-seo-tag (~> 2.1)
symbol-fstring (1.0.2-x86_64-linux-musl) symbol-fstring (1.0.2-x86_64-linux-musl)
sysexits (1.2.0) sysexits (1.2.0)
temple (0.9.1) temple (0.9.1)
@ -669,7 +572,6 @@ PLATFORMS
x86_64-linux-musl x86_64-linux-musl
DEPENDENCIES DEPENDENCIES
adhesiones-jekyll-theme
bcrypt (~> 3.1.7) bcrypt (~> 3.1.7)
bcrypt_pbkdf bcrypt_pbkdf
blazer blazer
@ -687,7 +589,6 @@ DEPENDENCIES
dotenv-rails dotenv-rails
down down
ed25519 ed25519
editorial-autogestiva-jekyll-theme
email_address! email_address!
exception_notification exception_notification
factory_bot_rails factory_bot_rails
@ -719,7 +620,6 @@ DEPENDENCIES
mail (~> 2.7.1) mail (~> 2.7.1)
memory_profiler memory_profiler
mini_magick mini_magick
minima
mobility mobility
net-ssh net-ssh
nokogiri nokogiri
@ -731,12 +631,10 @@ DEPENDENCIES
pundit pundit
rack-cors rack-cors
rack-mini-profiler rack-mini-profiler
radios-comunitarias-jekyll-theme rails (~> 6)
rails (~> 6.1.0)
rails-i18n rails-i18n
rails_warden rails_warden
recursero-jekyll-theme redis
redis (~> 4.0)
redis-rails redis-rails
reek reek
rollups! rollups!
@ -746,17 +644,13 @@ DEPENDENCIES
safe_yaml safe_yaml
sassc-rails sassc-rails
selenium-webdriver selenium-webdriver
share-to-fediverse-jekyll-theme
sourcemap sourcemap
spring spring
spring-watcher-listen spring-watcher-listen
sqlite3 sqlite3
stackprof stackprof
sucker_punch sucker_punch
sutty-donaciones-jekyll-theme
sutty-jekyll-theme
sutty-liquid (>= 0.7.3) sutty-liquid (>= 0.7.3)
sutty-minima
symbol-fstring symbol-fstring
terminal-table terminal-table
timecop timecop

View file

@ -93,10 +93,11 @@ class DeployLocal < Deploy
end end
def bundle def bundle
if Rails.env.production?
run %(bundle install --no-cache --path="#{gems_dir}") run %(bundle install --no-cache --path="#{gems_dir}")
else
run %(bundle install) # Eliminar archivos que no se usan
Dir.glob("#{gems_dir}/ruby/2.7.0/{cache/*,gems/*/{spec,test,ext,vendor}}").each do |dir|
FileUtils.rm_rf(dir)
end end
end end

View file

@ -54,10 +54,6 @@ class Site < ApplicationRecord
before_create :clone_skel! before_create :clone_skel!
# Elimina el directorio al destruir un sitio # Elimina el directorio al destruir un sitio
before_destroy :remove_directories! before_destroy :remove_directories!
# Carga el sitio Jekyll una vez que se inicializa el modelo o después
# de crearlo
after_initialize :load_jekyll
after_create :load_jekyll
# Cambiar el nombre del directorio # Cambiar el nombre del directorio
before_update :update_name! before_update :update_name!
before_save :add_private_key_if_missing! before_save :add_private_key_if_missing!
@ -355,10 +351,19 @@ class Site < ApplicationRecord
status == 'building' status == 'building'
end end
def jekyll?
File.directory? path
end
def jekyll def jekyll
run_in_path do @jekyll ||=
@jekyll ||= Jekyll::Site.new(configuration) begin
end install_gems
Jekyll::Site.new(configuration).tap do |site|
site.reader = JekyllData::Reader.new(site) if site.theme
end
end
end end
# Cargar el sitio Jekyll # Cargar el sitio Jekyll
@ -404,9 +409,6 @@ class Site < ApplicationRecord
@configuration[unneeded] = [] if @configuration.key? unneeded @configuration[unneeded] = [] if @configuration.key? unneeded
end end
# Eliminar el theme si no es una gema válida
@configuration.delete('theme') unless theme_available?
# Si estamos usando nuestro propio plugin de i18n, los posts están # Si estamos usando nuestro propio plugin de i18n, los posts están
# en "colecciones" # en "colecciones"
locales.map(&:to_s).each do |i| locales.map(&:to_s).each do |i|
@ -416,20 +418,6 @@ class Site < ApplicationRecord
@configuration @configuration
end end
# Lista los nombres de las plantillas disponibles como gemas,
# tomándolas dinámicamente de las que agreguemos en el grupo :themes
# del Gemfile.
def available_themes
@available_themes ||= Bundler.load.current_dependencies.select do |gem|
gem.groups.include? :themes
end.map(&:name)
end
# Detecta si el tema actual es una gema
def theme_available?
available_themes.include? design&.gem
end
# Devuelve el dominio actual # Devuelve el dominio actual
def self.domain def self.domain
ENV.fetch('SUTTY', 'sutty.nl') ENV.fetch('SUTTY', 'sutty.nl')
@ -468,7 +456,7 @@ class Site < ApplicationRecord
# Clona el esqueleto de Sutty para crear el sitio nuevo, no pasa nada # Clona el esqueleto de Sutty para crear el sitio nuevo, no pasa nada
# si el sitio ya existe # si el sitio ya existe
def clone_skel! def clone_skel!
return if File.directory? path return if jekyll?
Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path
end end
@ -551,4 +539,11 @@ class Site < ApplicationRecord
def run_in_path(&block) def run_in_path(&block)
Dir.chdir path, &block Dir.chdir path, &block
end end
def install_gems
return unless persisted?
return if Rails.root.join('_storage', 'gems', name).directory?
deploys.find_by_type('DeployLocal').send(:bundle)
end
end end

View file

@ -14,7 +14,7 @@
%table.table.table-condensed %table.table.table-condensed
%tbody %tbody
- @sites.each do |site| - @sites.each do |site|
- next unless site.jekyll - next unless site.jekyll?
- rol = current_usuarie.rol_for_site(site) - rol = current_usuarie.rol_for_site(site)
-# -#
TODO: Solo les usuaries cachean porque tenemos que separar TODO: Solo les usuaries cachean porque tenemos que separar

View file

@ -37,6 +37,13 @@ end
# #
# TODO: Aplicar monkey patches en otro lado... # TODO: Aplicar monkey patches en otro lado...
module Jekyll module Jekyll
Site.class_eval do
def configure_theme
self.theme = nil
self.theme = Jekyll::Theme.new(config['theme'], self) unless config['theme'].nil?
end
end
Reader.class_eval do Reader.class_eval do
# No necesitamos otros posts # No necesitamos otros posts
def retrieve_posts(_); end def retrieve_posts(_); end
@ -69,6 +76,46 @@ module Jekyll
end end
end end
Theme.class_eval do
attr_reader :site
def initialize(name, site)
@name = name.downcase.strip
@site = site
end
def root
@root ||= begin
lockfile = Bundler::LockfileParser.new(File.read(site.in_source_dir('Gemfile.lock')))
spec = lockfile.specs.find do |spec|
spec.name == name
end
ruby_version = Gem::Version.new(RUBY_VERSION)
ruby_version.canonical_segments[2] = 0
base_path = Rails.root.join('_storage', 'gems', File.basename(site.source), 'ruby',
ruby_version.canonical_segments.join('.'))
File.realpath(
case spec.source
when Bundler::Source::Git
File.join(base_path, 'bundler', 'gems', spec.source.extension_dir_name)
when Bundler::Source::Rubygems
File.join(base_path, 'gems', spec.full_name)
end
)
end
end
def runtime_dependencies
[]
end
private
def gemspec; end
end
# No necesitamos los archivos de la plantilla # No necesitamos los archivos de la plantilla
ThemeAssetsReader.class_eval do ThemeAssetsReader.class_eval do
def read; end def read; end