hscc

The personnal website source code of Hugo Soucy. Creates from an homebrewed static website generator.
Log | Files | Refs

commit d19929ff2708fb346db4dfabe6ae30f26fbdae02
parent 64247637f252589fa30005ee0dd8e495b977bea9
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Wed,  9 Dec 2020 21:51:15 -0500

Add bin scripts

Diffstat:
Mbin/image | 2++
Mbin/reply | 26+++++++++++++++-----------
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/bin/image b/bin/image @@ -13,3 +13,5 @@ # do # mogrify -path . -filter Triangle -define filter:support=2 -thumbnail 300 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB "$line" # done < "${1:-/dev/stdin}" + +mogrify -path "$3" -filter Triangle -define filter:support=2 -thumbnail "$2" -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB $1 diff --git a/bin/reply b/bin/reply @@ -4,7 +4,7 @@ do package.path = package.path .. ';'.. arg[0]:match("(.*/)") ..'/?.lua' -- local inspect = require 'inspect' - --local gumbo = require 'gumbo' + local htmlparser = require 'htmlparser' local lustache = require 'lustache' local file = require 'utils.file' local slugify = require 'utils.slugify' @@ -36,17 +36,21 @@ do tostring(reply_url) until string.len(reply_url) > 0 - -- local function get_e_content() - -- local _file = assert(io.popen('curl ' .. reply_url)) - -- local data = assert(_file:read("*a")) - -- local document = assert(gumbo.parse(data)) - -- local econtent = document:getElementsByClassName('detailed-status')[1] - -- :getElementsByClassName('e-content')[1].innerHTML + local function get_econtent() + local _file = assert(io.popen('curl ' .. reply_url)) + local data = assert(_file:read("*a")) + local root = htmlparser.parse(data) + local elements = root:select(".detailed-status:first") + local e_content - -- _file:close() + _file:close() - -- return econtent - -- end + for _, e in ipairs(elements) do + e_content = e:getcontent() + end + + return e_content + end -- Set the structure of the data file local reply_model = { @@ -55,7 +59,7 @@ do date = os.date('%Y-%m-%d'), datetime = os.date('%H:%M:%S'), posttype = "reply", - --inreplyto = get_e_content() or nil + inreplyto = get_econtent() or nil } -- Render the markdown file