Skip to content

Commit

Permalink
mvp-tema-i18n (#9), menus (#10): HapiApi, implementando dicas não rac…
Browse files Browse the repository at this point in the history
…istas do rubocop
  • Loading branch information
fititnt committed May 18, 2021
1 parent 6ce146b commit 60ffb14
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 53 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ charset = utf-8
indent_style = space
indent_size = 2



# https://github.com/rubocop/ruby-style-guide
# "Use two spaces per indentation level (aka soft tabs)."
[*.rb]
indent_style = space
indent_size = 2
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ _site/
.sass-cache/
.jekyll-cache/
.jekyll-metadata
.rubocop.yml

# Ignore folders generated by Bundler
.bundle/
Expand Down Expand Up @@ -37,4 +38,4 @@ api/*/*/*/index.html


# Temporary
schema/iso/iso639-3/eng/graphql-doc
schema/iso/iso639-3/eng/graphql-doc
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@ sera completamente ignorada.
> - https://github.com/twbs/bootstrap/releases/tag/v5.0.1
> - https://github.com/twbs/bootstrap/pull/33709

<!--
# VSCode
# ext install misogi.ruby-rubocop
# https://github.com/misogi/vscode-ruby-rubocop
# ext install rebornix.Ruby
# https://github.com/rubyide/vscode-ruby
sudo gem install rubocop
-->


### Licença
<!--TODO: o texto em português da licença é um rascunho. Ainda precisa ser revisado -->

Expand Down
52 changes: 0 additions & 52 deletions _plugins/jekyll-hapi-api.rb

This file was deleted.

66 changes: 66 additions & 0 deletions _plugins/jekyll_hapi_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# WTF!? @see https://github.com/rubocop/ruby-style-guide/issues/301
# rubocop:disable AsciiComments

# frozen_string_literal: true

# Trivia:
# - 'pāginam'
# - https://en.wiktionary.org/wiki/pagina#Latin
# - ūtilitātem
# - https://en.wiktionary.org/wiki/utilitas#Latin

# TODO: document
# lorem ipsum..
module HapiApi
# TODO: document
# lorem ipsum..
class HapiApiGenerator < Jekyll::Generator
safe true

def generate(site)
site.categories.each do |category, posts|
site.pages << ApiPaginam.new(site, category, posts)
end
end
end

# Subclass of `Jekyll::Page` with custom method definitions.
class ApiPaginam < Jekyll::Page
def initialize(site, category, posts)
@site = site # the current site instance.
@base = site.source # path to the source directory.
@dir = category # the directory the page will reside in.

# All pages have the same filename, so define attributes straight away.
@basename = 'index' # filename without the extension.
@ext = '.html' # the extension.
@name = 'index.html' # basically @basename + @ext.

# Initialize data hash with a key pointing to all posts under current category.
# This allows accessing the list in a template via `page.linked_docs`.
@data = {
'linked_docs' => posts
}

# Look up front matter defaults scoped to type `categories`, if given key
# doesn't exist in the `data` hash.
data.default_proc = proc do |_, key|
site.frontmatter_defaults.find(relative_path, :categories, key)
end
end

# Placeholders that are used in constructing page URL.
def url_placeholders
{
category: @dir,
basename: basename,
output_ext: output_ext
}
end
end
end

# Liquid::Template.register_filter(Jekyll::DataPageLinkGenerator)
# WTF!? @see https://github.com/rubocop/ruby-style-guide/issues/301
# Essa porra é tão racista que obriga por rubocop:enable AsciiComments
# rubocop:enable AsciiComments
File renamed without changes.

0 comments on commit 60ffb14

Please sign in to comment.