aboutsummaryrefslogtreecommitdiff
path: root/telem.lua
diff options
context:
space:
mode:
Diffstat (limited to 'telem.lua')
-rwxr-xr-xtelem.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/telem.lua b/telem.lua
index 9612a4b..bef5569 100755
--- a/telem.lua
+++ b/telem.lua
@@ -56,13 +56,17 @@ end
-- Internals
function update_boards()
- for board in lfs.dir(path.join(_BBS_ROOT, "boards")) do
- if string.sub(board, 1, 1) ~= "." and not board_names[board] then
- board_names[board] = true
+ for boarddir in lfs.dir(path.join(_BBS_ROOT, "boards")) do
+ if string.sub(boarddir, 1, 1) ~= "." and not board_names[boarddir] then
+ local board = {}
+ board.name = boarddir
+ board.directory = path.join(_BBS_ROOT, "boards", boarddir)
+ board.topic = file.read(path.join(board.directory, "topic"))
+ board_names[board.name] = true
table.insert(boards, board)
end
end
- table.sort(boards)
+ table.sort(boards, function(x,y) return x.name > y.name end)
end
function check_at_board()
@@ -147,9 +151,7 @@ function do_board()
local topic_file = path.join(board_dir, "topic")
file.write(topic_file, desc)
-- Update representation of BBS
- board_names[board] = true
- table.insert(boards, board)
- table.sort(boards)
+ update_boards()
-- Done!
print("Board created.")
end