Skip to content

Instantly share code, notes, and snippets.

@echicken
Last active October 18, 2018 15:45
Show Gist options
  • Save echicken/5fdb45d19826ab1d0470ad53ed04f12d to your computer and use it in GitHub Desktop.
Save echicken/5fdb45d19826ab1d0470ad53ed04f12d to your computer and use it in GitHub Desktop.
// /sbbs/ctrl/410.txt would be a line-by-line list of paths to pages that no longer exist:
// /some/deleted/page.html
load('sbbsdefs.js');
var line;
const f = new File(system.ctrl_dir + '410.txt');
if (f.open('r')) {
var bork = false;
while (!bork && !f.eof) {
line = f.readln();
if (line !== null && line.replace(/\/$/, '').toLowerCase() == http_request.virtual_path.replace(/\/$/, '').toLowerCase()) {
http_reply.status = '410 Gone';
writeln('Page is gone.');
writeln(http_request.virtual_path);
bork = true;
log(LOG_DEBUG, 'something something 410');
}
}
f.close();
if (bork) exit();
}
writeln('File not found');
@echicken
Copy link
Author

const f = new File(system.ctrl_dir + '410.txt');
if (f.open('r')) {
  var bork = false;
  while (!bork && !f.eof) {
      if (f.readln() == http_request.virtual_path) {
          http_reply.status = '410 Gone';
          writeln('Page is gone.');
          bork = true;
      }
  }
  f.close();
  if (bork) exit();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment