2019-08-01 23:13:38 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
String.include CoreExtensions::String::StripTags
|
2019-08-08 18:28:23 +00:00
|
|
|
Jekyll::Document.include CoreExtensions::Jekyll::Document::Path
|
2019-11-28 19:44:44 +00:00
|
|
|
|
2020-10-30 21:57:46 +00:00
|
|
|
# Definir tags de Liquid que provienen de complementos para que siempre
|
|
|
|
# devuelvan contenido vacío.
|
|
|
|
%w[seo feed_meta turbolinks].each do |tag|
|
|
|
|
Liquid::Template.register_tag(tag, Jekyll::Tags::Empty)
|
|
|
|
end
|
|
|
|
|
|
|
|
Liquid::Template.register_tag('base', Jekyll::Tags::Base)
|
|
|
|
|
2020-06-01 20:42:25 +00:00
|
|
|
module ActionDispatch
|
|
|
|
# Redefinir el formateo de URLs de Rails para eliminar parámetros
|
|
|
|
# selectivamente
|
|
|
|
module Journey
|
|
|
|
Formatter.class_eval do
|
|
|
|
alias_method :generate_original, :generate
|
|
|
|
|
|
|
|
# Eliminar el locale a menos que estemos generando la URL para un
|
|
|
|
# Post. Esto es para que las URLs no lleven un ?locale=XX
|
|
|
|
# innecesario y además porque generan conflictos en la subida de
|
|
|
|
# archivos de ActionText.
|
2020-12-24 18:02:03 +00:00
|
|
|
def generate(name, options, path_parameters)
|
2020-06-01 20:42:25 +00:00
|
|
|
options.delete(:locale) unless options[:controller] == 'posts'
|
|
|
|
|
2020-12-24 18:02:03 +00:00
|
|
|
generate_original(name, options, path_parameters)
|
2020-06-01 20:42:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-28 19:44:44 +00:00
|
|
|
# Lazy Loading de Jekyll, deshabilitando la instanciación de elementos
|
2021-05-07 22:02:15 +00:00
|
|
|
# que no necesitamos. Esto permite que podamos leer el sitio por partes
|
|
|
|
# en lugar de todo junto.
|
2019-11-28 19:44:44 +00:00
|
|
|
#
|
|
|
|
# TODO: Aplicar monkey patches en otro lado...
|
|
|
|
module Jekyll
|
|
|
|
Reader.class_eval do
|
2021-05-07 22:02:15 +00:00
|
|
|
# No necesitamos otros posts
|
2019-11-28 19:44:44 +00:00
|
|
|
def retrieve_posts(_); end
|
|
|
|
|
2021-05-07 22:02:15 +00:00
|
|
|
# No necesitamos otros directorios
|
2019-11-28 19:44:44 +00:00
|
|
|
def retrieve_dirs(_, _, _); end
|
|
|
|
|
2021-05-07 22:02:15 +00:00
|
|
|
# No necesitamos las páginas
|
2019-11-28 19:44:44 +00:00
|
|
|
def retrieve_pages(_, _); end
|
|
|
|
|
2021-05-07 22:02:15 +00:00
|
|
|
# No necesitamos los archivos estáticos
|
2019-11-28 19:44:44 +00:00
|
|
|
def retrieve_static_files(_, _); end
|
2021-05-07 22:02:15 +00:00
|
|
|
|
|
|
|
# Solo lee los datos
|
|
|
|
def read_data
|
2021-05-14 14:15:32 +00:00
|
|
|
@site.data = DataReader.new(site).read(site.config['data_dir'])
|
2021-05-07 22:02:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Lee todos los artículos del sitio
|
|
|
|
def read_collections
|
|
|
|
read_directories
|
|
|
|
read_included_excludes
|
|
|
|
sort_files!
|
|
|
|
CollectionReader.new(site).read
|
|
|
|
end
|
2019-11-28 19:44:44 +00:00
|
|
|
end
|
|
|
|
|
2021-05-07 22:02:15 +00:00
|
|
|
# No necesitamos los archivos de la plantilla
|
2019-11-28 19:44:44 +00:00
|
|
|
ThemeAssetsReader.class_eval do
|
|
|
|
def read; end
|
|
|
|
end
|
2020-01-02 23:20:41 +00:00
|
|
|
|
2021-05-07 22:02:15 +00:00
|
|
|
# Aplazar la lectura del documento
|
2020-01-02 23:20:41 +00:00
|
|
|
Document.class_eval do
|
|
|
|
alias_method :read!, :read
|
|
|
|
def read; end
|
2021-05-14 14:15:32 +00:00
|
|
|
|
|
|
|
# Permitir restablecer el documento sin crear uno nuevo
|
|
|
|
def reset
|
|
|
|
@path = @extname = @has_yaml_header = @relative_path = nil
|
|
|
|
@basename_without_ext = @data = @basename = nil
|
|
|
|
@renderer = @url_placeholders = @url = nil
|
|
|
|
@to_liquid = @write_p = @excerpt_separator = @id = nil
|
|
|
|
@related_posts = @cleaned_relative_path = self.content = nil
|
|
|
|
end
|
2020-01-02 23:20:41 +00:00
|
|
|
end
|
2020-12-29 17:40:27 +00:00
|
|
|
|
2021-05-07 22:02:15 +00:00
|
|
|
# Prevenir la instanciación de Time
|
|
|
|
#
|
|
|
|
# @see {https://github.com/jekyll/jekyll/pull/8425}
|
2020-12-29 17:40:27 +00:00
|
|
|
Utils.class_eval do
|
|
|
|
def parse_date(input, msg = 'Input could not be parsed.')
|
|
|
|
@parse_date_cache ||= {}
|
|
|
|
@parse_date_cache[input] ||= Time.parse(input).localtime
|
|
|
|
rescue ArgumentError
|
|
|
|
raise Errors::InvalidDateError, "Invalid date '#{input}': #{msg}"
|
|
|
|
end
|
|
|
|
end
|
2019-11-28 19:44:44 +00:00
|
|
|
end
|
2021-05-07 22:02:15 +00:00
|
|
|
|
|
|
|
# JekyllData::Reader del plugin jekyll-data modifica Jekyll::Site#reader
|
|
|
|
# para también leer los datos que vienen en el theme.
|
|
|
|
module JekyllData
|
|
|
|
Reader.class_eval do
|
|
|
|
def read_data
|
|
|
|
super
|
|
|
|
read_theme_data
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|