aboutsummaryrefslogtreecommitdiff
path: root/_plugins
diff options
context:
space:
mode:
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/log.rb51
-rw-r--r--_plugins/modified_time_helper.rb2
-rw-r--r--_plugins/twitter.rb22
-rw-r--r--_plugins/type.rb32
4 files changed, 54 insertions, 53 deletions
diff --git a/_plugins/log.rb b/_plugins/log.rb
index 203f583..436b902 100644
--- a/_plugins/log.rb
+++ b/_plugins/log.rb
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-require "date"
-require_relative "modified_time_helper"
+require 'date'
+require_relative 'modified_time_helper'
module Jekyll
# Render the last modification time of the given page.
@@ -24,10 +24,10 @@ module Jekyll
include ::Jekyll::ModifiedTimeHelper
def render(context)
- time = Time.iso8601(modified_time(context["page"]))
+ time = Time.iso8601(modified_time(context['page']))
- if context["page"]["lang"] == "en"
- time.strftime("%B %-d, %Y, at %H:%m")
+ if context['page']['lang'] == 'en'
+ time.strftime('%B %-d, %Y, at %H:%m')
else
time.strftime("%-d de #{catalan_month(time.month)} de %Y, a les %H:%m")
end
@@ -40,31 +40,31 @@ module Jekyll
def catalan_month(month)
case month
when 1
- "gener"
+ 'gener'
when 2
- "febrer"
+ 'febrer'
when 3
- "març"
+ 'març'
when 4
- "abril"
+ 'abril'
when 5
- "maig"
+ 'maig'
when 6
- "juny"
+ 'juny'
when 7
- "juliol"
+ 'juliol'
when 8
- "agost"
+ 'agost'
when 9
- "setembre"
+ 'setembre'
when 10
- "octubre"
+ 'octubre'
when 11
- "novembre"
+ 'novembre'
when 12
- "desembre"
+ 'desembre'
else
- ""
+ ''
end
end
# rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
@@ -74,14 +74,15 @@ module Jekyll
class RenderLogLink < Liquid::Tag
include ::Jekyll::ModifiedTimeHelper
- WEBSITE_BASE = "http://git.mssola.com"
- WEBSITE_REPO = "jo.git"
+ WEBSITE_BASE = 'https://github.com'
+ WEBSITE_REPO = 'mssola/jo.mssola.com'
+ WEBSITE_BRANCH = 'main'
def render(context)
- page = context["page"]
- url = "#{WEBSITE_BASE}/#{WEBSITE_REPO}/log/#{page["relative_path"]}"
+ page = context['page']
+ url = "#{WEBSITE_BASE}/#{WEBSITE_REPO}/commits/#{WEBSITE_BRANCH}/#{page['relative_path']}"
- if page["lang"] == "en"
+ if page['lang'] == 'en'
"<a href=\"#{url}\" title=\"Log for this page\">here</a>"
else
"<a href=\"#{url}\" title=\"Historial d'aquesta pàgina (anglès)\">aquí</a>"
@@ -90,5 +91,5 @@ module Jekyll
end
end
-Liquid::Template.register_tag("render_modified_at", Jekyll::RenderModifiedAt)
-Liquid::Template.register_tag("render_log_link", Jekyll::RenderLogLink)
+Liquid::Template.register_tag('render_modified_at', Jekyll::RenderModifiedAt)
+Liquid::Template.register_tag('render_log_link', Jekyll::RenderLogLink)
diff --git a/_plugins/modified_time_helper.rb b/_plugins/modified_time_helper.rb
index af29b89..52a780b 100644
--- a/_plugins/modified_time_helper.rb
+++ b/_plugins/modified_time_helper.rb
@@ -20,7 +20,7 @@ module Jekyll
module ModifiedTimeHelper
# Returns the modified time of the given page.
def modified_time(page)
- path = File.expand_path(File.join(File.dirname(__FILE__), "..", page["path"]))
+ path = File.expand_path(File.join(File.dirname(__FILE__), '..', page['path']))
out = `git log -n 1 --pretty='format:%cd' --date=iso8601-strict -- #{path}`
begin
diff --git a/_plugins/twitter.rb b/_plugins/twitter.rb
index 4f2f3d2..e211374 100644
--- a/_plugins/twitter.rb
+++ b/_plugins/twitter.rb
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-require_relative "render_helper"
+require_relative 'render_helper'
module Jekyll
# Render the OG image meta HTML tag for the currently rendered page.
@@ -23,32 +23,32 @@ module Jekyll
include ::Jekyll::RenderHelper
# The path to be used when the current page does not have a specific image.
- DEFAULT_PATH = "/images/default.png"
+ DEFAULT_PATH = '/images/default.png'
def render(context)
- img = "#{normalize(context["raw_title"])}.png"
+ img = "#{normalize(context['raw_title'])}.png"
path = image_exists?(img) ? "/images/posts/#{img}" : DEFAULT_PATH
- render_meta("og:image", "http://jo.mssola.com#{path}") +
- render_meta("og:image:width", 630) +
- render_meta("og:image:height", 315) +
- render_meta("twitter:image", "http://jo.mssola.com#{path}", name: true)
+ render_meta('og:image', "http://jo.mssola.com#{path}") +
+ render_meta('og:image:width', 630) +
+ render_meta('og:image:height', 315) +
+ render_meta('twitter:image', "http://jo.mssola.com#{path}", name: true)
end
protected
# Returns true if the given image exists inside of /images/posts.
def image_exists?(image)
- return false if image == ".png"
+ return false if image == '.png'
- path = File.expand_path(File.join(File.dirname(__FILE__), "..", "images", "posts", image))
+ path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'images', 'posts', image))
File.file?(path)
end
# Downcases the given string and replaces space characters with "-"
def normalize(str)
- str.gsub(/\s/, "-").downcase
+ str.gsub(/\s/, '-').downcase
end
end
end
-Liquid::Template.register_tag("render_og_image", Jekyll::RenderOGImageTag)
+Liquid::Template.register_tag('render_og_image', Jekyll::RenderOGImageTag)
diff --git a/_plugins/type.rb b/_plugins/type.rb
index 8c4c2b8..f17d2f4 100644
--- a/_plugins/type.rb
+++ b/_plugins/type.rb
@@ -15,9 +15,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-require "time"
-require_relative "render_helper"
-require_relative "modified_time_helper"
+require 'time'
+require_relative 'render_helper'
+require_relative 'modified_time_helper'
module Jekyll
# Render og:type related tags.
@@ -26,8 +26,8 @@ module Jekyll
include ::Jekyll::ModifiedTimeHelper
def render(context)
- if ["posts"].include?(context["page"]["collection"])
- render_article_tags(context["page"])
+ if ['posts'].include?(context['page']['collection'])
+ render_article_tags(context['page'])
else
'<meta property="og:type" content="website" />'
end
@@ -37,18 +37,18 @@ module Jekyll
# Render all the tags related to the article og:type.
def render_article_tags(page)
- tags = page["tags"].inject("") { |acc, t| acc + render_meta("article:tag", t) }
+ tags = page['tags'].inject('') { |acc, t| acc + render_meta('article:tag', t) }
# rubocop:disable Style/StringConcatenation
'<meta property="og:type" content="article" />' +
- render_meta("og:author", "Miquel Sabaté Solà") +
- render_meta("profile:first_name", "Miquel") +
- render_meta("profile:last_name", "Sabaté Solà") +
- render_meta("profile:username", "mssola") +
- render_meta("profile:gender", "male") +
- render_meta("article:section", page["collection"]) +
- render_meta("article:published_time", published_time(page)) +
- render_meta("article:modified_time", modified_time(page)) +
+ render_meta('og:author', 'Miquel Sabaté Solà') +
+ render_meta('profile:first_name', 'Miquel') +
+ render_meta('profile:last_name', 'Sabaté Solà') +
+ render_meta('profile:username', 'mssola') +
+ render_meta('profile:gender', 'male') +
+ render_meta('article:section', page['collection']) +
+ render_meta('article:published_time', published_time(page)) +
+ render_meta('article:modified_time', modified_time(page)) +
tags
# rubocop:enable Style/StringConcatenation
end
@@ -57,9 +57,9 @@ module Jekyll
def published_time(page)
# We could do fancy stuff like using DateTime.strptime and so on, but
# Jekyll completely disregards the hour, minutes, etc., so why bother.
- page["date"].to_s.split.first
+ page['date'].to_s.split.first
end
end
end
-Liquid::Template.register_tag("render_type_tags", Jekyll::RenderTypeTags)
+Liquid::Template.register_tag('render_type_tags', Jekyll::RenderTypeTags)