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
24 lines (21 loc) • 836 B
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") || " | " || title AS title,'
+ 'status,'
+ 'published '
+ 'FROM events '
+ 'JOIN titles USING(titleID) '
+ 'WHERE presenterID IS NULL AND status > -1 '
+ 'ORDER BY pageDate DESC';
sys.db.all(sql,function(err,rows){
if (err||!rows) {return oops(response,err,'getannouncementlist(1)')};
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(JSON.stringify(rows))
});
}
exports.cogClass = cogClass;
})();