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
25 lines (24 loc) • 955 B
JavaScript
(function () {
var cogClass = function () {};
cogClass.prototype.exec = function (params, request, response) {
var oops = this.sys.apiError;
var sys = this.sys;
var str = params.str;
if (!str) {
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(JSON.stringify([]));
}
var sql = 'SELECT documentID AS attachmentID, title AS attachment '
+ 'FROM documents '
+ 'JOIN titles USING(titleID) '
+ 'WHERE uploadDate IS NULL '
+ ' AND title LIKE \'%' + str + '%\' '
+ 'ORDER BY title;';
sys.db.all(sql,function(err,rows){
if (err||!rows) {return oops(response,err,'events/searchattachments(1)')};
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(JSON.stringify(rows));
});
}
exports.cogClass = cogClass;
})();