💾 Archived View for bbs.geminispace.org › s › Gemini › 11524 captured on 2023-12-28 at 16:04:58. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-11-14)

🚧 View Differences

-=-=-=-=-=-=-

Possibly useful scripts for gemlog peeps on a Chromebook with Lua scripting predilection

In case there are any Chromebook folk that enjoy Lua thereupon:

I wound up formatting gemlog post file names: YYYY-MM-DD-HH-MM-SS.gmi

Along the way, it hit me that being able to compare the date/time-stamp in the file name with that returned by:

ls -l --time-style full-iso

would allow detecting post files to be considered updated, and thus to be included as "put"'s in a batchfile passed to sftp's -b flag.

I'm not going to show the entire solution, as I know people prefer to roll their own. But perhaps these scripts I wrote as part of my solution might save you time in that direction:

#! /usr/bin/env lua
if arg[1] then
  local ls = io.popen('ls -l --time-style full-iso ' .. arg[1])
  local line = ls:read('*l')
  ls:close()
  local year_ls, month_ls, date_ls, hour_ls, minute_ls, second_ls, year, month, date, hour, minute, second = string.match(line, '^.-steve3m%s-steve3m%s-%d-%s-(%d-)%-(%d-)%-(%d-)%s-(%d-):(%d-):(%d-)%.%d-%s-%-%d-%s-(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%.gmi


)
  if year_ls then
    local change = false
    if (year_ls ~= year) or (month_ls ~= month) or (date_ls ~= date) or (hour_ls ~= hour) or (minute_ls ~= minute) or (second_ls ~= second) then
      change = 'changed'
    else
      change = 'same'
    end
    local file = year .. '-' .. month .. '-' .. date .. '-' .. hour .. '-' .. minute .. '-' .. second .. '.gmi'
    print(year_ls, month_ls, date_ls, hour_ls, minute_ls, second_ls, year, month, date, hour, minute, second, file, change)
  else
    print('=== no such file')
  end
else
  print('=== missing required filename argument')
end
#! /usr/bin/env lua
local ls = io.popen('ls *.gmi')
for file in ls:lines() do
  local year, month, date, hour, minute, second = string.match(file, '^(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%.gmi


)
  if year then
    local command = './file-changed ' .. file
    --print('=== ' .. command)
    os.execute(command)
  else
    --print('=== "' .. file .. '" is not a post file')
  end
end
ls:close()
#! /usr/bin/env lua
if arg[1] then
  local year, month, date, hour, minute, second = string.match(arg[1], '^(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%.gmi


)
  if year then
    local command = 'sudo touch -t ' .. year .. month .. date .. hour .. minute .. '.' .. second .. ' ' .. arg[1]
    print('=== ' .. command)
    os.execute(command)
  else
    print('=== filename must have this format: YYYY-MM-DD-HH-MM-SS.gmi')
  end
else
  print('=== missing required filename argument')
end
#! /usr/bin/env lua
local ls = io.popen('ls *.gmi')
for file in ls:lines() do
  local year, month, date, hour, minute, second = string.match(file, '^(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%-(%d-)%.gmi


)
  if year then
    local command = './set-file-timedate ' .. file
    print('=== ' .. command)
    os.execute(command)
  else
    --print('=== "' .. file .. '" is not a post file')
  end
end
ls:close()

NOTE: I use tab's for indentation, with "set ts=2" in my .vimrc, but converted them to two space characters to post this because I can't stand eight space characters of indentation that a tab character tends to be rendered as.

Posted in: s/Gemini

☯️ oldernow

Nov 05 · 8 weeks ago