Skip to content

Commit

Permalink
mvp-schemam-paginam (#14): iniciado, baseado em ApiPaginam
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jun 14, 2021
1 parent eb68e2a commit bcdfcf8
Show file tree
Hide file tree
Showing 6 changed files with 291 additions and 3 deletions.
4 changes: 3 additions & 1 deletion _data/schemam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@
typum: schemam
gid: XZ
lid: ISO-15924 # ISO_15924_slug
lid_n10n: "{% _🗣️ ISO_15924_slug 🗣️_ %}"
lid_l10n: "{% _🗣️ ISO_15924_slug 🗣️_ %}"
namen: "{% _🗣️ ISO_15924_nomen 🗣️_ %}"
namen_l10n: "{% _🗣️ ISO_15924_nomen 🗣️_ %}"
summarius: "{% _🗣️ ISO_15924_summarius 🗣️_ %}"
summarius_l10n: "{% _🗣️ ISO_15924_summarius 🗣️_ %}"
situs_interretialis:
referens_officinale:
- https://www.unicode.org/iso15924/
Expand Down
2 changes: 2 additions & 0 deletions _includes/temporarium/schemam.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[por]_
-->



<h3 id="{% _🗣️ 🔎🔕🔍 ISO_639-3_slug 🔎🔕🔍 🗣️_ %}">
{% _🗣️ ISO_639-3_nomen 🗣️_ %}
</h3>
Expand Down
2 changes: 1 addition & 1 deletion _plugins/jekyll_hapi_api.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ARCHĪVUM: _lugins/hapi/utilitatem.rb
# ARCHĪVUM: _plugins/jekyll_hapi_api.rb
#
# rubocop:disable RubocopIsRacistAndIcanProveIt/AsciiComments
# @see https://github.com/rubocop/ruby-style-guide/issues/301
Expand Down
271 changes: 271 additions & 0 deletions _plugins/jekyll_hapi_schemam.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
# ARCHĪVUM: _plugins/jekyll_hapi_schemam.rb
#
# rubocop:disable RubocopIsRacistAndIcanProveIt/AsciiComments
# @see https://github.com/rubocop/ruby-style-guide/issues/301
# @see https://github.com/rubocop/ruby-style-guide/issues/137
#
# Trivia:
# - 'Hapi'
# - https://hapi.etica.ai/
# - 'schēmam'
# - https://en.wiktionary.org/wiki/schema#Latin
# - 'datum'
# - https://en.wiktionary.org/wiki/datum#Latin
# - 'pāginam'
# - https://en.wiktionary.org/wiki/pagina#Latin
# - ūtilitātem
# - https://en.wiktionary.org/wiki/utilitas#Latin
# - 'expandendum'
# - https://en.wiktionary.org/wiki/expando#Latin
# frozen_string_literal: true

require 'json'

module Hapi
# HapiApiGenerator is (TODO: document)
class HapiSchemamGenerator < Jekyll::Generator
safe true

def generate(site) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
@debug_all = false

unless site.data['l10n']['apil10n'] && site.data['l10n']['referensl10n']
puts "\n\n\t[🔎ℹ️ #{self.class.name}:#{__LINE__}] requīrendum: 'bundle exec jekyll build' !!!"
return nil
end

# @apis = Utilitatem.expandendum_api_datum(site.data['api'], site.data['referens'])
@apis = Utilitatem.expandendum_api_datum(
site.data['l10n']['apil10n'],
site.data['l10n']['referensl10n']
)
# puts 'oooooi'
# _[eng] We override site.data.api [eng]_
# _[por] Sobrescrevemos o site.data.api [por]_
site.data['api'] = @apis

site.data['api'].each do |api_datum|
@debug_est = @debug_all or api_datum['debug']
site.pages << SchemamPaginam.new(site, api_datum, @debug_est)
end
end
end

# _[eng] Subclass of `Jekyll::Page` with custom method definitions. [eng]_
# _[eng] Subclasse de `Jekyll::Page` com customizações nos métodos [eng]_
class SchemamPaginam < Jekyll::Page
attr_accessor :datum, :gid, :uid, :xdefallo, :xdefallo_est, :alternativum,
:opus_in_progressu

# Attributes for Liquid templates
ATTRIBUTES_FOR_LIQUID = %w[
alternativum
gid
uid
titulum
html_body_class
namen
summarius
opus_in_progressu
xdefallo
xdefallo_est
content
dir
path
url
].freeze
# excerpt
# name

# rubocop:disable Lint/MissingSuper

# _[eng] Initialize a new page [eng]_
# _[por] Inicializa uma nova página [por]_
#
# site - Jekyll site obiectum
# api_datum - API Datum
# debug - Debug est?
def initialize(site, api_datum, _debug) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
# super()
@site = site # the current site instance.
@base = site.source # path to the source directory.
# @dir = api_datum['dir'] # the directory the page will reside in.
# @name = api_datum['lid']
# @dir = api_datum['dir'] + '/' + api_datum['lid'] + '/'
@dir = "#{api_datum['dir']}/#{api_datum['lid']}/"
# @dir = @dir.gsub(/\/api\//, '/schemam/')
# @dir = @dir.sub '/api/' '/schemam/'
@dir = @dir.sub('/api/', '/schemam/')
# puts @dir
# raise 'error'
# @name = 'index.html'
@name = 'index.html'
template = api_datum['jekyll-page']['template']

@path = if @site.layouts[template].path.end_with? 'html'
@site.layouts[template].path.dup
else
File.join(@site.layouts[template].path, @site.layouts[template].name)
end

@datum = api_datum
@gid = api_datum['gid']
@uid = api_datum['uid']
@xdefallo = api_datum['xdefallo']
@xdefallo_est = !!api_datum['xdefallo_est']
@opus_in_progressu = !!api_datum['opus_in_progressu']
# puts api_datum['opus_in_progressu']
# puts api_datum
# @trivum = 'teste'

# Hapi::HapiApiGenerator.quod_datum_api_liquify(site, '/data/api.json')
# HapiApiGenerator.quod_datum_api_liquify(site, '/data/api.json')

# site.pages.each do |paginam|
# puts JSON.parse(paginam.content) if paginam.url == '/data/api.json'
# end

process(name)
# read_yaml(PathManager.join(base, dir), name)

base_path = @site.layouts[template].path
base_path.slice! @site.layouts[template].name

# self.read_yaml, rubocop complaints about self.
read_yaml(base_path, @site.layouts[template].name)

generate_excerpt if site.config['page_excerpts']

# _[por] Não estamos usando Jekyll defaults [por]_
data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(relative_path, type, key)
end

# self.data, rubocop complaints about self.
data['datum'] = api_datum
data.merge!(api_datum['jekyll-page'])

Jekyll::Hooks.trigger :pages, :post_init, self
end
# rubocop:enable Lint/MissingSuper

# Trivia
# - 'alternātīvum'
# - https://en.wiktionary.org/wiki/alternativus#Latin
def alternativum
# Utilitatem.digitum_premendum(relative_path)
resultatum = []
apis = Hapi::HSD.api_paginam?
apis&.each do |api|
# puts api.class
resultatum.append(api) if @xdefallo == api.xdefallo
end

resultatum
end

# Trivia
# - 'digitum'
# - https://en.wiktionary.org/wiki/digitus#Latin
# - 'signātūrum'
# - https://en.wiktionary.org/wiki/signaturus#Latin
def digitum_signaturum
Utilitatem.digitum_premendum(relative_path)
end

# Trivia
# - 'gid'
# - https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
def gid_est?(gid)
@gid == gid
end

def html_body_class
[
'paginam-typum-api',
"paginam-linguam-#{@datum['linguam']}"
]
end

def keys
ATTRIBUTES_FOR_LIQUID
end

def openapi_filum
# @datum['jekyll-page']['openapi_filum2'] || '<mark lang="la">Nulla openapi filum. Adiuva me 🥺</mark>'
@datum['jekyll-page']['openapi_filum2']
end

def opus_in_progressu
!!@opus_in_progressu
end

# TODO: remove obsolete parts
def summarius
@summarius || @datum['jekyll-page']['summarius'] || '<mark lang="la">Nulla summarius. Adiuva me 🥺</mark>'
end
# TODO: remove obsolete parts
def titulum
@titulum || @namen || @title
end

def namen
@titulum || @namen || @title
end

# Trivia
# - 'trivium'
# - https://en.wiktionary.org/wiki/trivium#Latin
# - 'xdefallo'
# - https://developers.google.com/search/blog/2013/04/x-default-hreflang-for-international-pages
def trivium
@datum
end

# _[eng] Returns the object as a debug String [eng]_
# @see https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
# @see https://github.com/jekyll/jekyll/blob/master/lib/jekyll/page.rb
# # .
# def inspect
# # puts 'datum'
# # puts @datum

# # "#<#{self.class} @relative_path=#{relative_path.inspect} xdefallo=#{@trivum}>"
# "#<#{self.class} @uid=#{@uid} xdefallo=#{@xdefallo}>"
# end

# _[eng] Returns the object as a debug String [eng]_
# @see https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
# @see https://github.com/jekyll/jekyll/blob/master/lib/jekyll/page.rb
# # .
def to_s
# puts 'datum'
# puts @datum

# "#<#{self.class} @relative_path=#{relative_path.inspect} xdefallo=#{@trivum}>"
"#<#{self.class} @uid=#{@uid} xdefallo=#{@xdefallo}>"
end

attr_reader :xdefallo

# _[eng] Is this an xdefallo API? [eng]_
# _[por] Esta é uma API xdefallo? [por]_
# Trivia
# - 'trivium'
# - https://en.wiktionary.org/wiki/trivium#Latin
# - 'xdefallo'
# - https://developers.google.com/search/blog/2013/04/x-default-hreflang-for-international-pages
def xdefallo_est
# @datum['linguam'] == 'mul' || @datum['linguam'] == 'mul-Zyyy'
# puts "#{@uid} == #{@xdefallo}"
# puts @uid == @xdefallo
# puts ''
# @uid == @xdefallo
@xdefallo_est
end
end
end

# _[por] rubocop é tão racista que obriga re-habilitar
# AsciiComments [por]_
# rubocop:enable RubocopIsRacistAndIcanProveIt/AsciiComments
2 changes: 1 addition & 1 deletion documentum/data/schema.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ iso6391: pt
iso6393: por
iso15924: Latn
---
{{- site.data['schema'] | bellum_json | liquify -}}
{{- site.data['schemam'] | bellum_json | liquify -}}
13 changes: 13 additions & 0 deletions documentum/data/schemam.l10n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
layout: null
title: /data/schemam.l10n.json
permalink: /data/schemam.l10n.json
sitemap:
exclude: 'yes'
linguam: por-Latn
htmldir: ltr
iso6391: pt
iso6393: por
iso15924: Latn
---
{{- site.data['schemam'] | bellum_json | liquify -}}

0 comments on commit bcdfcf8

Please sign in to comment.