Commit 068c2c0e authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

chore: Merge branch '6-have-the-ability-to-set-id-of-rtitle-block' into 'master'

Resolve "Have the ability to set id of rtitle-block"

Closes #6

See merge request !7
parents e70b724b 3361a871
......@@ -3,13 +3,13 @@
## What is that?
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:
* in `Gemfile`, inside `group :jekyll_plugins do` add the following:
```
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",
:branch => "master"
```
......@@ -26,7 +26,7 @@ group :jekyll_plugins do
"~> 0.6"
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",
:branch => "master"
end
......@@ -47,6 +47,35 @@ plugins:
- 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
1. **Note, that this repository does not contain CSS files!** They stay within the theme.
......
......@@ -2,7 +2,7 @@
Gem::Specification.new do |spec|
spec.name = "jekyll-theme-lcsb-frozen-components"
spec.version = "0.0.1"
spec.version = "0.0.2"
spec.authors = ["jaceklebioda_lux"]
spec.email = ["lcsb-sysadmins@uni.lu"]
......@@ -14,6 +14,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "jekyll", "> 3.0"
spec.add_development_dependency "bundler", "~> 1.12"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "bundler", "> 1.12"
spec.add_development_dependency "rake", "> 10.0"
end
......@@ -10,12 +10,21 @@ module Jekyll
super
args = split_params(block_options)
@title = args[0]
if args.length >1
# Optional - using your own icons
if args.length > 1
@icon = args[1]
else
#default icon
# Default icon
@icon = "fas fa-code"
end
# Optional - setting your own ID
if args.length > 2
@block_id_html = " id=\"#{args[2]}\""
else
@block_id_html = ""
end
end
def render(context)
......@@ -25,13 +34,11 @@ module Jekyll
site = context.registers[:site]
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
content = converter.convert(super)
#Because we’re not changing the context, there’s no need to push the context stack as with the rgridblock.
# generate collapsible card HTML
output = <<~EOS
<div class="rblock">
<div class="rblock"#{@block_id_html}>
<h3>
<i class="#{@icon}"></i>
#{@title}
......
module Jekyll
module Tags
class RtitleTag < Liquid::Block
def split_params(params)
params.split("|").map(&:strip)
end
def initialize(tag_name, block_options, liquid_options)
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
def render(context)
......@@ -11,7 +25,7 @@ module Jekyll
converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
content = converter.convert(super)
output = <<~EOS
<div class="rtitle">
<div class="rtitle"#{@block_id_html}>
<h2>#{@title}</h2>
<hr>
#{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