Splits up type js into js and json.

This commit is contained in:
Lars Jung 2012-10-11 18:28:12 +02:00
parent 69ffcc2d32
commit a8e0c049f2
5 changed files with 12 additions and 28 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

View file

@ -1,29 +1,7 @@
modulejs.define('parser/generic-json', ['_', '$', 'core/settings', 'model/entry'], function (_, $, settings, Entry) { modulejs.define('parser/generic-json', ['_', '$', 'model/entry'], function (_, $, Entry) {
var parseJson = function (absHref, json) { var parse = function (absHref, html) {
if (!settings.custom) {
settings.custom = {};
}
if (_.has(json, 'customHeader')) {
settings.custom.header = json.customHeader;
}
if (_.has(json, 'customFooter')) {
settings.custom.footer = json.customFooter;
}
return _.map(json.entries, function (jsonEntry) {
return Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status, jsonEntry.content);
});
},
parseJsonStr = function (absHref, jsonStr) {
return parseJson(absHref, JSON.parse($.trim(jsonStr) || '{}'));
},
parse = function (absHref, html) {
var id = '#data-generic-json', var id = '#data-generic-json',
$html = $(html), $html = $(html),
@ -33,7 +11,11 @@ modulejs.define('parser/generic-json', ['_', '$', 'core/settings', 'model/entry'
$id = $html.find(id); $id = $html.find(id);
} }
return parseJsonStr(absHref, $id.text()); var json = JSON.parse($.trim($id.text()) || '{}');
return _.map(json.entries, function (jsonEntry) {
return Entry.get(jsonEntry.absHref, jsonEntry.time, jsonEntry.size, jsonEntry.status, jsonEntry.content);
});
}; };
return { return {

View file

@ -223,16 +223,17 @@ Options
"install": "plain", "install": "plain",
"log": "plain", "log": "plain",
"java": "java", "java": "java",
"js": "js",
"json": "js",
"makefile": "xml", "makefile": "xml",
"markdown": "plain", "markdown": "plain",
/*"php": "php",*/ // "php": "php",
"python": "python", "python": "python",
"readme": "plain", "readme": "plain",
"rb": "ruby", "rb": "ruby",
"rtf": "plain", "rtf": "plain",
"script": "shell", "script": "shell",
"text": "plain", "text": "plain",
"js": "js",
"xml": "xml" "xml": "xml"
} }
}, },

View file

@ -40,7 +40,8 @@ File types mapped to file extensions
"install": ["install"], "install": ["install"],
"java": [".java"], "java": [".java"],
"jpg": [".jpg", ".jpeg"], "jpg": [".jpg", ".jpeg"],
"js": [".js", ".json"], "js": [".js"],
"json": [".json"],
"log": [".log", "changelog"], "log": [".log", "changelog"],
"makefile": [".pom", "build.xml", "pom.xml"], "makefile": [".pom", "build.xml", "pom.xml"],
"markdown": [".markdown", ".md"], "markdown": [".markdown", ".md"],