diff options
author | Solderpunk <solderpunk@sdf.org> | 2018-12-08 17:39:37 +0000 |
---|---|---|
committer | Solderpunk <solderpunk@sdf.org> | 2018-12-08 17:39:37 +0000 |
commit | 1ccba296e9be272aa48c5d6d5dc4b6386a3378d5 (patch) | |
tree | 47f8594265a61580f9d2138b7360ed78be1dca6b | |
parent | Store boards not just as strings, but as tables with the topic as a member. (diff) |
Make board/message listing formatting a bit prettier.
Diffstat (limited to '')
-rwxr-xr-x | telem.lua | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -8,6 +8,7 @@ lfs = require("lfs") os = require("os") path = require("pl.path") string = require("string") +stringx = require("pl.stringx") table = require("table") _BBS_ROOT = "/var/bbs/" @@ -179,20 +180,31 @@ end function do_list() update_boards() - for _,b in ipairs(boards) do + for _,board in ipairs(boards) do local threads = -3 -- Don't want to count "topic" file or "." or ".." - for topic in lfs.dir(path.join(_BBS_ROOT, "boards", b)) do + for thread in lfs.dir(board.directory) do threads = threads +1 end - print(string.format("%s [%d threads]", b, threads)) + print(string.format("%s %s [%3d threads]", + stringx.ljust(board.name,20), + stringx.ljust(board.topic,50), threads)) end end function do_messages() if not check_at_board() then return end current_board_threads = get_threads(current_board) + if #current_board_threads == 0 then + print("Empty board!") + return + end + print("ID", "Created", stringx.ljust("author",16), stringx.ljust("Subject", 50)) + print(string.rep("-",70)) for i, thread in ipairs(current_board_threads) do - print(tostring(i), os.date("%x %H:%M", thread.timestamp), thread.author, thread.subject, "("..tostring(thread.post_count).." posts)") + print(tostring(i), os.date("%x %H:%M", thread.timestamp), + stringx.ljust(thread.author,16), + stringx.ljust(thread.subject,50), + "["..tostring(thread.post_count).." posts]") end end |