WIP open file for a while
This commit is contained in:
parent
f937019e42
commit
d280fb9af3
122 changed files with 5702 additions and 10 deletions
21
lib/plugin/format/format-csv.js
Normal file
21
lib/plugin/format/format-csv.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
module.exports = (function () {
|
||||
|
||||
return function FormatCsvPlugin() {
|
||||
|
||||
this.configPlugin = function (ctx) {
|
||||
ctx.key = 'formatCSV';
|
||||
ctx.description = 'Export tentity list/read api in csv format.';
|
||||
ctx.localDir = __dirname;
|
||||
ctx.localConfigTemplate = 'format-csv.json';
|
||||
};
|
||||
|
||||
this.configApiTListExport = function (ctx) {
|
||||
return ctx.renderTemplateDataList(ctx.tview.tmeta.tplugin.formatCSV.tmime);
|
||||
};
|
||||
|
||||
this.configApiTReadExport = function (ctx) {
|
||||
return ctx.renderTemplateDataRead(ctx.tview.tmeta.tplugin.formatCSV.tmime);
|
||||
};
|
||||
};
|
||||
})();
|
||||
18
lib/plugin/format/format-csv.json
Normal file
18
lib/plugin/format/format-csv.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"masterTEntityTemplate": {
|
||||
"tlist": { "tplugin": { "formatCSV": { "tslug": "list" }}},
|
||||
"tread": { "tplugin": { "formatCSV": { "tslug": "read" }}},
|
||||
"tmeta": { "tplugin": { "formatCSV": {
|
||||
"tslug": "csv",
|
||||
"tmime": "text/csv"
|
||||
}}}
|
||||
},
|
||||
"masterTEntityTHelp": {
|
||||
"tlist": { "tplugin": { "formatCSV": { "tslug": "csv slug of api url" }}},
|
||||
"tread": { "tplugin": { "formatCSV": { "tslug": "csv slug of api url" }}},
|
||||
"tmeta": { "tplugin": { "formatCSV": {
|
||||
"tslug": "The csv slug of api url.",
|
||||
"tmime": "The csv mime type header."
|
||||
}}}
|
||||
}
|
||||
}
|
||||
35
lib/plugin/format/format-json.js
Normal file
35
lib/plugin/format/format-json.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
// TODO: move to default-format-json.js ??
|
||||
|
||||
module.exports = (function () {
|
||||
|
||||
return function FormatJsonPlugin() {
|
||||
|
||||
this.configPlugin = function (ctx) {
|
||||
ctx.key = 'formatJSON';
|
||||
ctx.description = 'Export the tentity api in json format.';
|
||||
ctx.localDir = __dirname;
|
||||
ctx.localConfigTemplate = 'format-json.json';
|
||||
};
|
||||
|
||||
// flag that we support these all crud types.
|
||||
|
||||
this.configApiTListExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTCreateExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTReadExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTEditExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTDeleteExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTCountExport = function (ctx) {
|
||||
};
|
||||
};
|
||||
})();
|
||||
22
lib/plugin/format/format-json.json
Normal file
22
lib/plugin/format/format-json.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"masterTEntityTemplate": {
|
||||
"tlist": { "tplugin": { "formatJSON": { "tslug": "list" }}},
|
||||
"tcreate": { "tplugin": { "formatJSON": { "tslug": "create" }}},
|
||||
"tedit": { "tplugin": { "formatJSON": { "tslug": "edit" }}},
|
||||
"tread": { "tplugin": { "formatJSON": { "tslug": "read" }}},
|
||||
"tdelete": { "tplugin": { "formatJSON": { "tslug": "delete" }}},
|
||||
"tcount": { "tplugin": { "formatJSON": { "tslug": "list-count" }}},
|
||||
"tverify": { "tplugin": { "formatJSON": { "tslug": "verify" }}},
|
||||
"tmeta": { "tplugin": { "formatJSON": { "tslug": "json" }}}
|
||||
},
|
||||
"masterTEntityTHelp": {
|
||||
"tlist": { "tplugin": { "formatJSON": { "tslug": "tlist json slug part api url" }}},
|
||||
"tcreate": { "tplugin": { "formatJSON": { "tslug": "tcreate json slug part api url" }}},
|
||||
"tedit": { "tplugin": { "formatJSON": { "tslug": "tedit json slug part api url" }}},
|
||||
"tread": { "tplugin": { "formatJSON": { "tslug": "tread json slug part api url" }}},
|
||||
"delete": { "tplugin": { "formatJSON": { "tslug": "tdelete json slug part api url" }}},
|
||||
"tcount": { "tplugin": { "formatJSON": { "tslug": "tcount json slug part api url" }}},
|
||||
"tverify": { "tplugin": { "formatJSON": { "tslug": "tverifiy json slug part api url"}}},
|
||||
"tmeta": { "tplugin": { "formatJSON": { "tslug": "json group part api url" }}}
|
||||
}
|
||||
}
|
||||
13
lib/plugin/format/format-rss.js
Normal file
13
lib/plugin/format/format-rss.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
module.exports = (function () {
|
||||
|
||||
return function FormatRssPlugin() {
|
||||
|
||||
this.configPlugin = function (ctx) {
|
||||
ctx.key = 'formatRSS';
|
||||
ctx.description = 'Export tentity list/read api in rss format.';
|
||||
ctx.localDir = __dirname;
|
||||
ctx.localConfigTemplate = 'format-rss.json';
|
||||
};
|
||||
};
|
||||
})();
|
||||
17
lib/plugin/format/format-rss.json
Normal file
17
lib/plugin/format/format-rss.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"masterTEntityTemplate": {
|
||||
"tlist": { "tplugin": { "formatRSS": { "tslug": "list" }}},
|
||||
"tmeta": { "tplugin": { "formatRSS": {
|
||||
"tslug": "rss",
|
||||
"itemTitle": "$data._id",
|
||||
"itemLink": "$siteLink/ui/$modelUri/read/$[\"data._id\"]",
|
||||
"itemDate": "",
|
||||
"itemDescription": "",
|
||||
"itemFields": ""
|
||||
}}}
|
||||
},
|
||||
"masterTEntityTHelp": {
|
||||
"tlist": { "tplugin": { "formatRSS": { "tslug": "rss slug of api url" }}},
|
||||
"tmeta": { "tplugin": { "formatRSS": { "tslug": "rss slug of api url" }}}
|
||||
}
|
||||
}
|
||||
75
lib/plugin/format/format-xml.js
Normal file
75
lib/plugin/format/format-xml.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
var xmlmapping = require('xml-mapping');
|
||||
var rawbody = require('raw-body');
|
||||
var typeis = require('type-is');
|
||||
|
||||
module.exports = (function () {
|
||||
|
||||
function bodyParserXml() {
|
||||
return function(req, res, next) {
|
||||
if (req._body) return next();
|
||||
req.body = req.body || {};
|
||||
|
||||
if (!typeis(req, 'xml')) return next();
|
||||
|
||||
// flag as parsed
|
||||
req._body = true;
|
||||
|
||||
// parse
|
||||
rawbody(req, {
|
||||
limit: options.limit || '100kb',
|
||||
length: req.headers['content-length'],
|
||||
encoding: 'utf8'
|
||||
}, function (err, buf) {
|
||||
if (err) return next(err);
|
||||
|
||||
if (0 == buf.length) {
|
||||
return next(error(400, 'invalid xml, empty body'));
|
||||
}
|
||||
try {
|
||||
req.body = xmlmapping.dump(buf/*, options.reviver*/);
|
||||
} catch (err){
|
||||
err.body = buf;
|
||||
err.status = 400;
|
||||
return next(err);
|
||||
}
|
||||
next();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return function FormatXmlPlugin() {
|
||||
|
||||
this.configPlugin = function (ctx) {
|
||||
ctx.key = 'formatXML';
|
||||
ctx.description = 'Export the tentity api in xml format.';
|
||||
ctx.localDir = __dirname;
|
||||
ctx.localConfigTemplate = 'format-xml.json';
|
||||
};
|
||||
|
||||
this.configServer = function(ctx) {
|
||||
ctx.server.use(bodyParserXml());
|
||||
}
|
||||
|
||||
// flag that we support these all crud types.
|
||||
|
||||
this.configApiTListExport = function (ctx) {
|
||||
return ctx.renderTemplateDataList(ctx.tview.tmeta.tplugin.formatXML.tmime);
|
||||
};
|
||||
|
||||
this.configApiTCreateExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTReadExport = function (ctx) {
|
||||
return ctx.renderTemplateDataRead(ctx.tview.tmeta.tplugin.formatXML.tmime);
|
||||
};
|
||||
|
||||
this.configApiTEditExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTDeleteExport = function (ctx) {
|
||||
};
|
||||
|
||||
this.configApiTCountExport = function (ctx) {
|
||||
};
|
||||
};
|
||||
})();
|
||||
28
lib/plugin/format/format-xml.json
Normal file
28
lib/plugin/format/format-xml.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"masterTEntityTemplate": {
|
||||
"tlist": { "tplugin": { "formatXML": { "tslug": "list" }}},
|
||||
"tcreate": { "tplugin": { "formatXML": { "tslug": "create" }}},
|
||||
"tedit": { "tplugin": { "formatXML": { "tslug": "edit" }}},
|
||||
"tread": { "tplugin": { "formatXML": { "tslug": "read" }}},
|
||||
"tdelete": { "tplugin": { "formatXML": { "tslug": "delete" }}},
|
||||
"tcount": { "tplugin": { "formatXML": { "tslug": "list-count" }}},
|
||||
"tverify": { "tplugin": { "formatXML": { "tslug": "verify" }}},
|
||||
"tmeta": { "tplugin": { "formatXML": {
|
||||
"tslug": "xml",
|
||||
"tmime": "text/xml"
|
||||
}}}
|
||||
},
|
||||
"masterTEntityTHelp": {
|
||||
"tlist": { "tplugin": { "formatXML": { "tslug": "xml slug of api url" }}},
|
||||
"tcreate": { "tplugin": { "formatXML": { "tslug": "xml slug of api url" }}},
|
||||
"tedit": { "tplugin": { "formatXML": { "tslug": "xml slug of api url" }}},
|
||||
"tread": { "tplugin": { "formatXML": { "tslug": "xml slug of api url" }}},
|
||||
"tdelete": { "tplugin": { "formatXML": { "tslug": "xml slug of api url" }}},
|
||||
"tcount": { "tplugin": { "formatXML": { "tslug": "xml slug of api url" }}},
|
||||
"tverify": { "tplugin": { "formatXML": { "tslug": "xml slug of api url" }}},
|
||||
"tmeta": { "tplugin": { "formatXML": {
|
||||
"tslug": "The xml slug of api url.",
|
||||
"tmime": "The xml mime type header."
|
||||
}}}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue