Commit 3361a871 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

feat: Have the ability to set id of rtitle blocks and rblock blocks

parent e70b724b
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
## What is that? ## What is that?
A collection of Jekyll plugins (tags and filters) that allow the user to include components from _frozen-pages_ layout seamlessly. A collection of Jekyll plugins (tags and filters) that allow the user to include components from _frozen-pages_ layout seamlessly.
## How to use? ## How to use it in your repository?
There are two changes to be made in your Jekyll project in order to use this: There are two changes to be made in your Jekyll project in order to use this:
* in `Gemfile`, inside `group :jekyll_plugins do` add the following: * in `Gemfile`, inside `group :jekyll_plugins do` add the following:
``` ```
gem 'jekyll-theme-lcsb-frozen-components', gem 'jekyll-theme-lcsb-frozen-components',
'~> 0.0.1', '~> 0.0.2',
:git => "https://git-r3lab.uni.lu/core-services/jekyll-theme-lcsb-frozen-components.git", :git => "https://git-r3lab.uni.lu/core-services/jekyll-theme-lcsb-frozen-components.git",
:branch => "master" :branch => "master"
``` ```
...@@ -26,7 +26,7 @@ group :jekyll_plugins do ...@@ -26,7 +26,7 @@ group :jekyll_plugins do
"~> 0.6" "~> 0.6"
gem 'jekyll-theme-lcsb-frozen-components', gem 'jekyll-theme-lcsb-frozen-components',
'~> 0.0.1', '~> 0.0.2',
:git => "https://git-r3lab.uni.lu/core-services/jekyll-theme-lcsb-frozen-components.git", :git => "https://git-r3lab.uni.lu/core-services/jekyll-theme-lcsb-frozen-components.git",
:branch => "master" :branch => "master"
end end
...@@ -47,6 +47,35 @@ plugins: ...@@ -47,6 +47,35 @@ plugins:
- jekyll-theme-lcsb-frozen-components - jekyll-theme-lcsb-frozen-components
``` ```
## How to actually use it?
### RTitle
It is the element to create title box - usually it would contain the paper's title, authors and some basic information about the project.
```
{% rtitle Here goes the title | html-id-of-the-element %}
Here goes the content of the box.
{% endrtitle %}
```
### RGridBlock
This is a container, which keeps the smaller boxes (_rblocks_).
```
{% rgridblock a-unique-html-id %}
// all of the rblocks must be here!
{% endrgridblock %}
```
### RBlock
This is the small box element. It supports font-awesome's icons (take a look on [https://fontawesome.com/icons?d=gallery](https://fontawesome.com/icons?d=gallery)).
```
{% rgridblock a-unique-html-id %} // don't forget about it!
{% rblock Title of a box | icon CSS classes, like: fas fa-globe | html-id-of-the-element %}
Here goes the content of the box.
{% endrblock %}
{% endrgridblock %}
```
## Developer's notes ## Developer's notes
1. **Note, that this repository does not contain CSS files!** They stay within the theme. 1. **Note, that this repository does not contain CSS files!** They stay within the theme.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = "jekyll-theme-lcsb-frozen-components" spec.name = "jekyll-theme-lcsb-frozen-components"
spec.version = "0.0.1" spec.version = "0.0.2"
spec.authors = ["jaceklebioda_lux"] spec.authors = ["jaceklebioda_lux"]
spec.email = ["lcsb-sysadmins@uni.lu"] spec.email = ["lcsb-sysadmins@uni.lu"]
...@@ -14,6 +14,6 @@ Gem::Specification.new do |spec| ...@@ -14,6 +14,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "jekyll", "> 3.0" spec.add_runtime_dependency "jekyll", "> 3.0"
spec.add_development_dependency "bundler", "~> 1.12" spec.add_development_dependency "bundler", "> 1.12"
spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rake", "> 10.0"
end end
...@@ -10,12 +10,21 @@ module Jekyll ...@@ -10,12 +10,21 @@ module Jekyll
super super
args = split_params(block_options) args = split_params(block_options)
@title = args[0] @title = args[0]
if args.length >1
# Optional - using your own icons
if args.length > 1
@icon = args[1] @icon = args[1]
else else
#default icon # Default icon
@icon = "fas fa-code" @icon = "fas fa-code"
end end
# Optional - setting your own ID
if args.length > 2
@block_id_html = " id=\"#{args[2]}\""
else
@block_id_html = ""
end
end end
def render(context) def render(context)
...@@ -25,13 +34,11 @@ module Jekyll ...@@ -25,13 +34,11 @@ module Jekyll
site = context.registers[:site] site = context.registers[:site]
converter = site.find_converter_instance(::Jekyll::Converters::Markdown) converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
content = converter.convert(super) content = converter.convert(super)
#Because we’re not changing the context, there’s no need to push the context stack as with the rgridblock. #Because we’re not changing the context, there’s no need to push the context stack as with the rgridblock.
# generate collapsible card HTML # generate collapsible card HTML
output = <<~EOS output = <<~EOS
<div class="rblock"> <div class="rblock"#{@block_id_html}>
<h3> <h3>
<i class="#{@icon}"></i> <i class="#{@icon}"></i>
#{@title} #{@title}
......
module Jekyll module Jekyll
module Tags module Tags
class RtitleTag < Liquid::Block class RtitleTag < Liquid::Block
def split_params(params)
params.split("|").map(&:strip)
end
def initialize(tag_name, block_options, liquid_options) def initialize(tag_name, block_options, liquid_options)
super super
@title = block_options.strip
args = split_params(block_options)
@title = args[0]
# Optional - setting your own ID
if args.length > 1
@block_id_html = " id=\"#{args[1]}\""
else
@block_id_html = ""
end
end end
def render(context) def render(context)
...@@ -11,7 +25,7 @@ module Jekyll ...@@ -11,7 +25,7 @@ module Jekyll
converter = site.find_converter_instance(::Jekyll::Converters::Markdown) converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
content = converter.convert(super) content = converter.convert(super)
output = <<~EOS output = <<~EOS
<div class="rtitle"> <div class="rtitle"#{@block_id_html}>
<h2>#{@title}</h2> <h2>#{@title}</h2>
<hr> <hr>
#{content} #{content}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment