From 6ce953fecb8369ff64865f3a2f44291640e4b925 Mon Sep 17 00:00:00 2001 From: echicken <echicken@bbs.electronicchicken.com> Date: Wed, 30 Sep 2020 01:25:42 -0400 Subject: [PATCH] Added QWK list/download to the Gopher service. Added section headers to the main directory listing; the meaning of each directory entry was unclear. (These use the non-standard but commonly-used item type 'i'.) Should satisfy issue #67. https://gitlab.synchro.net/sbbs/sbbs/-/issues/67 This one's for all you folks who have QWK bulletins on your systems and want people to be able to read them via Gopher. --- exec/gopherservice.js | 59 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/exec/gopherservice.js b/exec/gopherservice.js index 8234f6ef4a..dfe1f62276 100644 --- a/exec/gopherservice.js +++ b/exec/gopherservice.js @@ -50,6 +50,13 @@ function send_file(fname) writeln(strip_ctrl(txt[l])); } +function getQwkBulletins() { + var dir = system.text_dir + 'qwk'; + if (!file_isdir(dir)) return []; + var bulletins = directory(backslash(dir) + '*'); + return bulletins; +} + var msgbase=null; if(!login("guest")) @@ -81,19 +88,41 @@ if(gopher_plus) if(request=="" || request=='/') { /* "root" */ - for(g in msg_area.grp_list) - writeln(prefix - + "1" + msg_area.grp_list[g].description - + "\tgrp:" + msg_area.grp_list[g].name.toLowerCase() - + "\t" + system.host_name - + "\t" + GOPHER_PORT); - for(l in file_area.lib_list) - writeln(format("1%s\tlib:%s\t%s\t%u" - ,file_area.lib_list[l].description - ,file_area.lib_list[l].name.toLowerCase() - ,system.host_name - ,GOPHER_PORT + if (msg_area.grp_list.length) { + writeln(prefix + 'iMessage Groups\t\tfake\t1'); + for(g in msg_area.grp_list) { + writeln( + prefix + + "1" + msg_area.grp_list[g].description + + "\tgrp:" + msg_area.grp_list[g].name.toLowerCase() + + "\t" + system.host_name + + "\t" + GOPHER_PORT + ); + } + writeln(prefix + 'i \t\tfake\t1'); + } + if (file_area.lib_list.length) { + writeln(prefix + 'iFile Libraries\t\tfake\t1'); + for(l in file_area.lib_list) { + writeln(format("1%s\tlib:%s\t%s\t%u" + ,file_area.lib_list[l].description + ,file_area.lib_list[l].name.toLowerCase() + ,system.host_name + ,GOPHER_PORT )); + } + writeln(prefix + 'i \t\tfake\t1'); + } + var qwkBulletins = getQwkBulletins(); + if (qwkBulletins.length) { + writeln(prefix + 'iQWK Bulletins\t\tfake\t1'); + qwkBulletins.forEach(function (e) { + var f = file_getname(e); + writeln(prefix + '0' + f + '\tqwkbulletin:' + f + '\t' + system.host_name + '\t' + GOPHER_PORT); + }); + writeln(prefix + 'i \t\tfake\t1'); + } + writeln(prefix + 'iSystem Information\t\tfake\t1'); writeln(prefix + "0Node List\tnodelist" +"\t" + system.host_name @@ -309,6 +338,12 @@ switch(field[0]) { } } break; + case "qwkbulletin": + if (field.length == 2) { + var fname = backslash(system.text_dir + 'qwk') + field[1]; + if (file_exists(fname)) client.socket.sendfile(fname); + } + break; } writeln("."); -- GitLab