Skip to content

Commit

Permalink
mvp-tema-i18n (#9), menus (#10): jekyll_hapi_api.rb; quaaaase lá
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed May 19, 2021
1 parent 04285e9 commit f947f48
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 49 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
source "https://rubygems.org"
source 'https://rubygems.org'

# gem "github-pages", group: :jekyll_plugins
# gem "jekyll", "~> 3.9"

gem "jekyll", "~> 4.2"
gem 'jekyll', '~> 4.2'

group :jekyll_plugins do
# @see https://github.com/toshimaru/jekyll-toc
Expand Down
46 changes: 23 additions & 23 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,27 @@ defaults:
values:
sitemap: false

# @see https://github.com/avillafiorita/jekyll-datapage_gen
page_gen-dirs: true
page_gen:
# referens: api-BR-portais-ckan-brasil
- data: 'api'
template: 'api'
# name: 'title'
name_expr: "record['uid'].split('/').last"
# name_expr: "record['slug'] or record['lid']"
# dir: 'uid'
# "/mul/api/XZ/HXL-Proxy/".chomp("/mul/api/XZ/HXL-Proxy/".split('/').last + "/")
# record['uid'].chomp(record['uid'].split('/').last + "/")
dir_expr: "record['uid'].chomp(record['uid'].split('/').last + '/')"
# dir_expr: "record['uid']"
# dir_expr: "record['linguam'] + '/' + record['typum'] + '/' + record['gid']"
# filter_condition: "record['linguam'] != 'mul'"
# debug: true
# # @see https://github.com/avillafiorita/jekyll-datapage_gen
# page_gen-dirs: true
# page_gen:
# # referens: api-BR-portais-ckan-brasil
# - data: 'api'
# template: 'api'
# # name: 'title'
# name_expr: "record['uid'].split('/').last"
# # name_expr: "record['slug'] or record['lid']"
# # dir: 'uid'
# # "/mul/api/XZ/HXL-Proxy/".chomp("/mul/api/XZ/HXL-Proxy/".split('/').last + "/")
# # record['uid'].chomp(record['uid'].split('/').last + "/")
# dir_expr: "record['uid'].chomp(record['uid'].split('/').last + '/')"
# # dir_expr: "record['uid']"
# # dir_expr: "record['linguam'] + '/' + record['typum'] + '/' + record['gid']"
# # filter_condition: "record['linguam'] != 'mul'"
# # debug: true

# - data: 'api'
# template: 'api'
# name: 'slug'
# dir: 'eng/api-TEMP/BR'
# filter_condition: "record['gid'] == '/api/BR' and record['linguam'] == 'por'"
# debug: true
# # - data: 'api'
# # template: 'api'
# # name: 'slug'
# # dir: 'eng/api-TEMP/BR'
# # filter_condition: "record['gid'] == '/api/BR' and record['linguam'] == 'por'"
# # debug: true
30 changes: 15 additions & 15 deletions _data/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
linguam: eng
typum: api
gid: UN
# lid: HDX
lid: HDX
openapi_filum: /api/UN/HDX/eng/openapi.yaml
slug: humanitarian-data-exchange
title: HDX - The Humanitarian Data Exchange API
Expand All @@ -30,7 +30,7 @@
linguam: arb
typum: api
gid: UN
# lid: HDX
lid: 'اختبارات'
openapi_filum: /api/UN/HDX/eng/openapi.yaml
title: "اختبارات"
noindex: true
Expand All @@ -41,7 +41,7 @@
linguam: mul
typum: api
gid: UN
# lid: reliefweb
lid: reliefweb
title: "Index: ReliefWeb"
noindex: true

Expand All @@ -50,7 +50,7 @@
linguam: eng
typum: api
gid: UN
# lid: ReliefWeb
lid: reliefweb
openapi_filum: /api/UN/reliefweb/eng/openapi.yaml
slug: reliefweb
title: ReliefWeb - Informing humanitarians worldwide
Expand All @@ -63,7 +63,7 @@
linguam: mul
typum: api
gid: UN
# lid: CODV2API
lid: CODV2API
title: "Index: CODV2API"
noindex: true

Expand All @@ -72,7 +72,7 @@
linguam: eng
typum: api
gid: UN
# lid: CODV2API
lid: common-operational-datasets-api
openapi_filum: /api/UN/CODV2API/eng/openapi.yaml
# slug: common-operational-datasets-api
title: Common Operational Datasets Services 2 (COD Services)
Expand All @@ -86,7 +86,7 @@
linguam: mul
typum: api
gid: XZ
# lid: HXL-Proxy
lid: hxl-proxy
title: "Index: HXL-Proxy"
noindex: true

Expand All @@ -95,9 +95,9 @@
linguam: eng
typum: api
gid: XZ
# lid: HXL-Proxy
lid: hxl-proxy
openapi_filum: /api/XZ/HXL-Proxy/eng/openapi.yaml
slug: hxl-proxy
# slug: hxl-proxy
title: HXL-Proxy - Proxy of the Humanitarian Exchange Language
noindex: true

Expand All @@ -109,7 +109,7 @@
linguam: mul
typum: api
gid: BR
# lid: portais-ckan-brasil
lid: portais-ckan-brasil
title: "Index: Portais CKAN de dados abertos do Brasil"
noindex: true

Expand All @@ -118,7 +118,7 @@
linguam: eng
typum: api
gid: BR
# lid: portais-ckan-brasil
lid: brazilian-ckan-portals
openapi_filum: /api/BR/brazilian-ckan-portals/eng/openapi.yaml
slug: brazilian-ckan-portals
title: Brazilian CKAN Open Data Portals
Expand All @@ -131,9 +131,9 @@
linguam: por
typum: api
gid: BR
# lid: dados-abertos-ckan-brasil
lid: dados-abertos-ckan-brasil
openapi_filum: /api/BR/portais-ckan-brasil/por/openapi.yaml
slug: dados-abertos-ckan-brasil
# slug: dados-abertos-ckan-brasil
title: Portais CKAN de dados abertos do Brasil
description: |
Discussão em https://github.com/HXL-CPLP/COD-Services-API-doc/issues/4
Expand All @@ -145,7 +145,7 @@
linguam: mul
typum: api
gid: BR
# lid: portais-arcgis-brasil
lid: portais-arcgis-brasil
title: "Index: Portais ArcGIS de dados abertos do Brasil"
noindex: true

Expand All @@ -154,7 +154,7 @@
linguam: por
typum: api
gid: BR
# lid: portais-arcgis-brasil
lid: portais-arcgis-brasil
openapi_filum: /api/BR/portais-arcgis-brasil/por/openapi.yaml
slug: dados-abertos-arcgis-brasil
title: Portais ArcGIS de dados abertos do Brasil
Expand Down
79 changes: 72 additions & 7 deletions _plugins/jekyll_hapi_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,26 @@ def generate(site)
# # api['locale'] = linguam_to_html_lang(api['linguam'])
# end

@debug_all = true

@apis = Utilitatem.expandendum_api_datum(site.data['api'])

site.data['api'] = @apis

puts @apis[0]
# puts @apis[0]

site.data['api'].each do |api|
@debug_est = @debug_all or api['debug']
@template_est = 'api'
# puts api
# puts 'oi'
@teste = ApiPaginam.new(site, site.source, api['dir'], api['lid'], @template_est, @debug_est)
# debug @teste
# puts 'oi2'
# puts @teste.inspect
site.pages << ApiPaginam.new(site, site.source, api['dir'], api['lid'], @template_est, @debug_est)
# break
end

# site.pages << ApiPaginam.new(site)

Expand All @@ -62,7 +77,6 @@ class ApiPaginam < Jekyll::Page
# def initialize(site, category, posts)
# def initialize(site, _api)

# rubocop:disable Metrics/MethodLength
# rubocop:disable Lint/MissingSuper

# Initialize a new Page.
Expand All @@ -71,14 +85,63 @@ class ApiPaginam < Jekyll::Page
# base - The String path to the source.
# dir - The String path between the source and the file.
# name - The String filename of the file.
# def initialize(site, _base, _dir, _name)
def initialize(site)
# debug - Output more information about this item
def initialize(site, base, dir, name, template, debug)
# def initialize(site)
# warning:Lint/MissingSuper
# super()
@site = site # the current site instance.
@base = site.source # path to the source directory.
# @dir = category # the directory the page will reside in.
@base = base # path to the source directory.
@dir = dir # the directory the page will reside in.
@name = name

# @path = site.in_source_dir(base, dir, name)
# @path = File.join(@site.layouts[template].path, @site.layouts[template].name)

# puts @site.layouts
# puts 'oi3'
# puts @site.layouts['api']

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

# puts debug

# if debug
# [:base, :dir, :name].each do |variable|
# puts ">> #{variable}: #{eval(variable.to_s)}"

# if debug
# puts ">> base [#{base}] dir [#{dir}]"
# # puts ">> site.posts [#{site.posts}]"
# # require 'json'
# # puts ">> site.posts.docs.last [#{site.posts.docs.to_json}]"
# # puts ">> site.posts.docs.last [#{site.posts.docs[0]}]"
# puts ">> site.posts [#{site.posts.inspect}]"
# # puts ">> base [#{base}] dir [#{dir}]"
# # puts ">> base #{base}"
# 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(base_path, @site.layouts[template].name)


generate_excerpt if site.config['page_excerpts']

data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(relative_path, type, key)
end

Jekyll::Hooks.trigger :pages, :post_init, self

# return nil

# # All pages have the same filename, so define attributes straight away.
# @basename = 'index' # filename without the extension.
Expand Down Expand Up @@ -107,7 +170,6 @@ def initialize(site)
# }
# end

# rubocop:enable Metrics/MethodLength
# rubocop:enable Lint/MissingSuper
end

Expand Down Expand Up @@ -136,7 +198,10 @@ def sanitize_filename_i18n(name)
def expandendum_api_datum(apis)
apis.map do |api|
api['uid2'] = "/#{api['linguam']}/#{api['typum']}/#{api['gid']}/#{api['lid']}/"
api['dir'] = "/#{api['linguam']}/#{api['typum']}/#{api['gid']}/"
api['locale'] = Utilitatem.linguam_to_html_lang(api['linguam'])

api['debug'] = true
end

apis
Expand Down
2 changes: 1 addition & 1 deletion documentum/sitemap.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ <h2>sitemal.xml draft</h2>

</body>

</html>
</html>
2 changes: 1 addition & 1 deletion documentum/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ sitemap:
{% endif %}
{%- endfor %}

</urlset>
</urlset>

0 comments on commit f947f48

Please sign in to comment.