5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 05:46:23 +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 '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
gem 'lograge'
end

View file

@ -86,23 +86,8 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.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)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
autoprefixer-rails (10.4.7.0)
execjs (~> 2)
@ -173,26 +158,7 @@ GEM
railties (>= 3.2)
down (5.4.0)
addressable (~> 2.8)
ed25519 (1.3.0-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)
ed25519 (1.2.4-x86_64-linux-musl)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
@ -369,13 +335,9 @@ GEM
mini_histogram (0.3.1)
mini_magick (4.12.0)
mini_mime (1.1.2)
mini_portile2 (2.8.1)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.16.3)
mobility (1.2.9)
mini_portile2 (2.6.1)
minitest (5.14.4)
mobility (1.2.4)
i18n (>= 0.6.10, < 2)
request_store (~> 1.0)
multi_xml (0.6.0)
@ -423,31 +385,20 @@ GEM
rack (>= 1.2.0)
rack-proxy (0.7.4)
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.7)
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)
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.7)
sprockets-rails (>= 2.0.0)
@ -472,27 +423,9 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
recursero-jekyll-theme (0.2.0)
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-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 (4.5.1)
redis-actionpack (5.2.0)
actionpack (>= 5, < 7)
redis-rack (>= 2.1.0, < 3)
redis-store (>= 1.1.0, < 2)
redis-activesupport (5.3.0)
@ -563,15 +496,7 @@ GEM
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_range (3.0.0)
sexp_processor (4.16.1)
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)
sexp_processor (4.16.0)
simpleidn (0.2.1)
unf (~> 0.1.4)
sourcemap (0.1.1)
@ -596,31 +521,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.11.6)
sutty-liquid (0.7.4)
fast_blank (~> 1.0)
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)
sysexits (1.2.0)
temple (0.9.1)
@ -669,7 +572,6 @@ PLATFORMS
x86_64-linux-musl
DEPENDENCIES
adhesiones-jekyll-theme
bcrypt (~> 3.1.7)
bcrypt_pbkdf
blazer
@ -687,7 +589,6 @@ DEPENDENCIES
dotenv-rails
down
ed25519
editorial-autogestiva-jekyll-theme
email_address!
exception_notification
factory_bot_rails
@ -719,7 +620,6 @@ DEPENDENCIES
mail (~> 2.7.1)
memory_profiler
mini_magick
minima
mobility
net-ssh
nokogiri
@ -731,12 +631,10 @@ DEPENDENCIES
pundit
rack-cors
rack-mini-profiler
radios-comunitarias-jekyll-theme
rails (~> 6.1.0)
rails (~> 6)
rails-i18n
rails_warden
recursero-jekyll-theme
redis (~> 4.0)
redis
redis-rails
reek
rollups!
@ -746,17 +644,13 @@ DEPENDENCIES
safe_yaml
sassc-rails
selenium-webdriver
share-to-fediverse-jekyll-theme
sourcemap
spring
spring-watcher-listen
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

@ -93,10 +93,11 @@ class DeployLocal < Deploy
end
def bundle
if Rails.env.production?
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

View file

@ -54,10 +54,6 @@ class Site < ApplicationRecord
before_create :clone_skel!
# Elimina el directorio al destruir un sitio
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
before_update :update_name!
before_save :add_private_key_if_missing!
@ -355,9 +351,18 @@ class Site < ApplicationRecord
status == 'building'
end
def jekyll?
File.directory? path
end
def jekyll
run_in_path do
@jekyll ||= Jekyll::Site.new(configuration)
@jekyll ||=
begin
install_gems
Jekyll::Site.new(configuration).tap do |site|
site.reader = JekyllData::Reader.new(site) if site.theme
end
end
end
@ -404,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|
@ -416,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')
@ -468,7 +456,7 @@ class Site < ApplicationRecord
# Clona el esqueleto de Sutty para crear el sitio nuevo, no pasa nada
# si el sitio ya existe
def clone_skel!
return if File.directory? path
return if jekyll?
Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path
end
@ -551,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

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

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