Created
September 27, 2010 23:38
-
-
Save deanlandolt/600088 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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