commit e90f0d60e21296ff2b20d329e786e1453d7e1278
parent 43950197952ac453da7cdc9f4161ebdefcdb83c3
Author: Hugo Soucy <hugo@soucy.cc>
Date: Fri, 1 Oct 2021 18:57:36 -0400
Move and add thing in bin/
Diffstat:
5 files changed, 99 insertions(+), 3 deletions(-)
diff --git a/bin/image b/bin/_backup/image
diff --git a/bin/optimize-images.sh b/bin/_backup/optimize-images.sh
diff --git a/bin/archives b/bin/archives
@@ -0,0 +1,90 @@
+#!/usr/bin/env lua
+do
+ --
+ package.path = package.path .. ';'.. arg[0]:match("(.*/)") ..'/?.lua'
+ --
+ local config = require 'config'
+ local dirtree = require 'utils.dirtree'
+ local file = require 'utils.file'
+ local inspect = require 'inspect'
+ local etlua = require 'etlua'
+
+ local archives_table = {}
+ local archives_model
+ local archives_template
+ local archives_html
+ local archives_dir
+
+ --
+ for filepath in dirtree.get('content/') do
+ if file.is_markdown(filepath)
+ or file.is_html(filepath)
+ and file.get_metafile(filepath)
+ then
+ local metafile = file.get_metafile(filepath)
+
+ if metafile.date ~= '0000-00-00' then
+ local year = string.sub(metafile.date, 1, 4)
+ local month = string.sub(metafile.date, 6, 7)
+
+ if archives_table[year] then
+ archives_table[year][month] = {}
+ else
+ archives_table[year] = {
+ [month] = {}
+ }
+ end
+ end
+ end
+ end
+
+ for filepath in dirtree.get('content/') do
+ if file.is_markdown(filepath)
+ or file.is_html(filepath)
+ and file.get_metafile(filepath)
+ then
+ local metafile = file.get_metafile(filepath)
+
+ if metafile.date ~= '0000-00-00' then
+ local year = string.sub(metafile.date, 1, 4)
+ local month = string.sub(metafile.date, 6, 7)
+ local archive_info = {
+ title = metafile.title,
+ rellink = file.get_rellink(filepath, config.paths.content)
+ }
+
+ table.insert(archives_table[year][month], archive_info)
+ end
+ end
+ end
+
+ -- Set the structure of the data file
+ archives_model = {
+ title = 'Archives des contenus classés par années et mois',
+ time_modification = os.date('%Y-%m-%dT%H:%M:%S'),
+ archives = archives_table,
+ months_names = {
+ ["01"] = 'janvier',
+ ["02"] = 'février',
+ ["03"] = 'mars',
+ ["04"] = 'avril',
+ ["05"] = 'mai',
+ ["06"] = 'juin',
+ ["07"] = 'juillet',
+ ["08"] = 'août',
+ ["09"] = 'septembre',
+ ["10"] = 'octobre',
+ ["11"] = 'novembre',
+ ["12"] = 'décembre'
+ }
+ }
+
+ archives_template = etlua.compile(file.read('archetypes/archives.html'))
+ archives_html = archives_template(archives_model)
+ archives_dir = 'content/'
+
+ -- Write the HTML in a file
+ file.write(archives_dir .. 'archives.html', archives_html)
+
+ return --print(inspect(archives_table))
+end
diff --git a/bin/img b/bin/img
@@ -0,0 +1,9 @@
+#!/usr/bin/env lua
+--
+local vips = require 'vips'
+--
+do
+ local image = vips.Image.thumbnail('content/papa-lecteur-2019.jpg', 128)
+
+ image:write_to_file("tiny.jpg")
+end
diff --git a/bin/tags b/bin/tags
@@ -56,9 +56,6 @@ do
end
end
- --table.sort(tags_table, function(a, b) return a < b end)
- --table.sort(tags_table, function(a, b) return tags_table[a] < tags_table[b] end)
-
-- Set the structure of the data file
tags_model = {
title = 'Mots Clés',