Skip to content

Instantly share code, notes, and snippets.

@deanlandolt
Created September 27, 2010 23:38
Show Gist options
  • Save deanlandolt/600088 to your computer and use it in GitHub Desktop.
Save deanlandolt/600088 to your computer and use it in GitHub Desktop.
/**
* Media handler for generating HTML from Wiki markup-based doc
*/
var Media = require("pintura/media").Media,
when = require("promised-io/promise").when;
Media({
mediaType:"text/html",
getQuality: function(object) {
return 0.9
},
serialize: function(object, mediaParams, request, response) {
if (typeof object.forEach === "function") {
return {
forEach: function(write) {
write(getHeader());
return when(object.forEach(function(object) {
write(getObject(object));
}), function(end) {
write(getFooter());
return end;
});
}
};
}
return [
getHeader(),
getObject(object),
getFooter()
];
function getHeader() {
return "header...";
};
function getFooter() {
return "footer..."
};
function getObject(object) {
return "your object's id is: " + object.id;
};
},
deserialize: function(inputStream, request) {
throw new Error("NYI");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment