5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 06:56:22 +00:00

Merge branch 'issue-1849' into panel.sutty.nl

This commit is contained in:
f 2022-12-27 18:50:42 -03:00
commit 7b70f429b6
5 changed files with 84 additions and 160 deletions

17
Gemfile
View file

@ -48,9 +48,9 @@ gem 'image_processing'
gem 'icalendar'
gem 'inline_svg'
gem 'httparty'
gem 'safe_yaml', source: 'https://gems.sutty.nl'
gem 'safe_yaml'
gem 'jekyll', '~> 4.2'
gem 'jekyll-data', source: 'https://gems.sutty.nl'
gem 'jekyll-data'
gem 'jekyll-commonmark'
gem 'jekyll-images'
gem 'jekyll-include-cache'
@ -99,19 +99,6 @@ gem 'net-ssh'
gem 'ed25519'
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', '~> 0.1.0', require: false
gem 'observatorio-jekyll-theme', require: false
end
group :production do
gem 'lograge'
end

View file

@ -88,16 +88,6 @@ GEM
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
adhesiones-jekyll-theme (0.2.1)
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)
ansi (1.5.0)
ast (2.4.2)
autoprefixer-rails (10.3.3.0)
execjs (~> 2)
@ -170,25 +160,6 @@ GEM
down (5.2.4)
addressable (~> 2.8)
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)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
@ -411,12 +382,8 @@ GEM
mini_histogram (0.3.1)
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.16.1)
mini_portile2 (2.6.1)
minitest (5.14.4)
mobility (1.2.4)
i18n (>= 0.6.10, < 2)
request_store (~> 1.0)
@ -484,31 +451,20 @@ GEM
rack (>= 1.2.0)
rack-proxy (0.7.0)
rack
rack-test (2.0.2)
rack (>= 1.3)
radios-comunitarias-jekyll-theme (0.1.5)
jekyll (~> 4.0)
jekyll-data (~> 1.1)
jekyll-feed (~> 0.9)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-linked-posts (~> 0)
jekyll-locales (~> 0.1)
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
jekyll-turbolinks (~> 0)
rails (6.1.4.7)
actioncable (= 6.1.4.7)
actionmailbox (= 6.1.4.7)
actionmailer (= 6.1.4.7)
actionpack (= 6.1.4.7)
actiontext (= 6.1.4.7)
actionview (= 6.1.4.7)
activejob (= 6.1.4.7)
activemodel (= 6.1.4.7)
activerecord (= 6.1.4.7)
activestorage (= 6.1.4.7)
activesupport (= 6.1.4.7)
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)
bundler (>= 1.15.0)
railties (= 6.1.4.7)
sprockets-rails (>= 2.0.0)
@ -533,23 +489,6 @@ GEM
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)
recursero-jekyll-theme (0.1.3)
jekyll (~> 4.0)
jekyll-data (~> 1.1)
jekyll-feed (~> 0.9)
jekyll-images (~> 0.2)
jekyll-include-cache (~> 0)
jekyll-linked-posts (~> 0.2)
jekyll-locales (~> 0.1)
jekyll-lunr (~> 0.1)
jekyll-node-modules (~> 0.1)
jekyll-order (~> 0.1)
jekyll-relative-urls (~> 0.0)
jekyll-seo-tag (~> 2.1)
jekyll-turbolinks (~> 0)
jekyll-unique-urls (~> 0.1)
sutty-archives (~> 2.2)
sutty-liquid (~> 0.1)
redis (4.5.1)
redis-actionpack (5.2.0)
actionpack (>= 5, < 7)
@ -625,14 +564,6 @@ GEM
rubyzip (>= 1.2.2)
semantic_range (3.0.0)
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)
unf (~> 0.1.4)
sourcemap (0.1.1)
@ -656,30 +587,9 @@ GEM
concurrent-ruby (~> 1.0)
sutty-archives (2.5.5)
jekyll (>= 3.6, < 5.0)
sutty-donaciones-jekyll-theme (0.1.2)
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.7.4)
fast_blank (~> 1.0)
jekyll (~> 4)
sutty-minima (2.5.0)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
symbol-fstring (1.0.2-x86_64-linux-musl)
sysexits (1.2.0)
temple (0.8.2)
@ -728,7 +638,6 @@ PLATFORMS
x86_64-linux-musl
DEPENDENCIES
adhesiones-jekyll-theme
bcrypt (~> 3.1.7)
bcrypt_pbkdf
blazer
@ -746,7 +655,6 @@ DEPENDENCIES
dotenv-rails
down
ed25519
editorial-autogestiva-jekyll-theme
email_address!
exception_notification
factory_bot_rails
@ -765,7 +673,7 @@ DEPENDENCIES
jbuilder (~> 2.5)
jekyll (~> 4.2)
jekyll-commonmark
jekyll-data!
jekyll-data
jekyll-images
jekyll-include-cache
kaminari
@ -776,7 +684,6 @@ DEPENDENCIES
lograge
memory_profiler
mini_magick
minima
mobility
net-ssh
nokogiri
@ -789,31 +696,25 @@ DEPENDENCIES
pundit
rack-cors
rack-mini-profiler
radios-comunitarias-jekyll-theme
rails (~> 6.1.4.0)
rails (~> 6)
rails-i18n
rails_warden
recursero-jekyll-theme (~> 0.1.0)
redis
redis-rails
rollups!
rubocop-rails
rubyzip
rugged
safe_yaml!
safe_yaml
sassc-rails
selenium-webdriver
share-to-fediverse-jekyll-theme
sourcemap
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
stackprof
sucker_punch
sutty-donaciones-jekyll-theme
sutty-jekyll-theme
sutty-liquid (>= 0.7.3)
sutty-minima
symbol-fstring
terminal-table
timecop

View file

@ -111,13 +111,9 @@ class DeployLocal < Deploy
end
def bundle(output: false)
if Rails.env.production?
# XXX: Desde que ya no compartimos el directorio de gemas, tenemos
# que hacer limpieza después de instalar.
run %(bundle install --no-cache --path="#{gems_dir}" --clean --without test development), output: output
else
run %(bundle install), output: output
end
# XXX: Desde que ya no compartimos el directorio de gemas, tenemos
# que hacer limpieza después de instalar.
run %(bundle install --no-cache --path="#{gems_dir}" --clean --without test development), output: output
end
def jekyll_build(output: false)

View file

@ -56,8 +56,8 @@ class Site < ApplicationRecord
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
after_initialize :install_gems, :load_jekyll
after_create :install_gems, :load_jekyll
# Cambiar el nombre del directorio
before_update :update_name!
before_save :add_private_key_if_missing!
@ -359,7 +359,10 @@ class Site < ApplicationRecord
def jekyll
run_in_path do
@jekyll ||= Jekyll::Site.new(configuration)
@jekyll ||=
Jekyll::Site.new(configuration).tap do |site|
site.reader = JekyllData::Reader.new(site) if site.theme
end
end
end
@ -406,9 +409,6 @@ class Site < ApplicationRecord
@configuration[unneeded] = [] if @configuration.key? unneeded
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
# en "colecciones"
locales.map(&:to_s).each do |i|
@ -418,20 +418,6 @@ class Site < ApplicationRecord
@configuration
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
def self.domain
ENV.fetch('SUTTY', 'sutty.nl')
@ -553,4 +539,11 @@ class Site < ApplicationRecord
def run_in_path(&block)
Dir.chdir path, &block
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

View file

@ -37,6 +37,13 @@ end
#
# TODO: Aplicar monkey patches en otro lado...
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
# No necesitamos otros posts
def retrieve_posts(_); end
@ -69,6 +76,46 @@ module Jekyll
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
ThemeAssetsReader.class_eval do
def read; end