newswriter
Version:
NewsWriter is a generic tool for maintaining news and announcements on a website news page. Details are held in an SQLite database, from which the tool generates the index page (typically the top page of the target site), individual pages for events and a
30 lines (27 loc) • 1.1 kB
JavaScript
(function () {
var cogClass = function () {};
cogClass.prototype.exec = function (params, request, response) {
var oops = this.sys.apiError;
var sys = this.sys;
var sql = 'SELECT eventID,'
+ 'strftime("%Y-%m-%d",pageDate,"unixepoch") || " | " || '
+ 'CASE WHEN events.presenterID IS NOT NULL '
+ ' THEN names.name || " | " || title '
+ ' ELSE title '
+ 'END AS title,'
+ 'status,'
+ 'published '
+ 'FROM events '
+ 'JOIN titles USING(titleID) '
+ 'LEFT JOIN persons ON persons.personID=events.presenterID '
+ 'LEFT JOIN names ON names.nameID=persons.nameID '
+ 'WHERE status=-1 '
+ 'ORDER BY pageDate DESC';
sys.db.all(sql,function(err,rows){
if (err||!rows) {return oops(response,err,'gettrashlist(1)')};
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(JSON.stringify(rows))
});
}
exports.cogClass = cogClass;
})();