diff --git a/ep.json b/ep.json index 709f659..a5cacf8 100644 --- a/ep.json +++ b/ep.json @@ -1,9 +1,10 @@ { "parts": [ { - "name": "noscript", + "name": "ep_public_view", "hooks": { - "eejsBlock_body": "ep_text_content_in_noscripts_tag/noscript" + "expressConfigure" : "ep_public_view/index:expressConfigure", + "expressCreateServer" : "ep_public_view/index:expressServer" } } ] diff --git a/index.js b/index.js new file mode 100644 index 0000000..1b0ae87 --- /dev/null +++ b/index.js @@ -0,0 +1,47 @@ + var eejs = require('ep_etherpad-lite/node/eejs/'), + padManager = require('ep_etherpad-lite/node/db/PadManager'), + ERR = require("ep_etherpad-lite/node_modules/async-stacktrace"), + async = require('ep_etherpad-lite/node_modules/async'), + express = require('ep_etherpad-lite/node_modules/express'); + +exports.expressConfigure = function(hook_name, args, cb) { +} + +exports.expressServer = function (hook_name, args, cb) { + args.app.get('/public/:padId(*)', function(req, res) { + var padId = req.params.padId.replace(/\.\./g, '').split("?")[0]; + + var pad; + async.series([ + function(callback){ // Get the pad Text + var padText = padManager.getPad(padId, function(err, _pad){ + console.warn(_pad); + pad = _pad; + text = pad.text().replace(/\n/g,"
"); + ERR(err); + callback(); + }); + }, + + function(callback){ // Append the pad Text to the Body + + /* Why don't we use EEJS require here? Well EEJS require isn't ASYNC so on first load + it would bring in the .ejs content only and then on second load pad contents would be included.. + Sorry this is ugly but that's how the plugin FW was designed by @redhog -- bug him for a fix! */ + + args.content = ""; + args.content += ""; + args.content += "
"+text+"
"; + args.content += ""; + args.content += ""; + res.send(args.content); + callback(); + }, + ]); + }); +} + + +function safe_tags(str) { + return str.replace(/&/g,'&').replace(//g,'>') ; +} diff --git a/package.json b/package.json index 05ec68b..94ef98d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "ep_text_content_in_noscripts_tag", - "description": "USE THIS PLUGIN WITH CAUTION. This plugin will help make content indexable by evil search engines and the hordes of social networks waiting to suckle on the bussum of your content. This plugin Allows search engines to use the noscript tags to get pad text contents, use with robots override plugin for publicly indexable pads", - "homepage": "https://github.com/johnmclear/ep_text_content_in_noscripts_tag", + "name": "ep_public_view", + "description": "USE THIS PLUGIN WITH CAUTION. This plugin will help make content indexable by evil search engines and the hordes of social networks waiting to suckle on the bussum of your content. This plugin Allows search engines to get pad text contents, use with robots override plugin for publicly indexable pads .. This plugin supercedes ep_text_content_in_noscripts_tag", + "homepage": "https://github.com/johnmclear/ep_public_view", "keywords": [ "search", "engine", @@ -14,13 +14,10 @@ "email": "john@mclear.co.uk", "url": "http://mclear.co.uk" }, - "contributors": { - "name": "Marcel Klehr" - }, "version": "0.0.7", "repository": { "type": "git", - "url": "git://github.com/johnmclear/ep_text_content_in_noscripts_tag.git" + "url": "git://github.com/johnmclear/ep_public_view.git" }, "dependencies": {}, "devDependencies": {}