Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnMcLear committed Jan 24, 2013
1 parent 17dfce5 commit 6bb857f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
5 changes: 3 additions & 2 deletions 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"
}
}
]
Expand Down
47 changes: 47 additions & 0 deletions 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,"<br/>");
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 = "<html><body>";
args.content += "<style>body{font-family:arial;font-size:14px;margin-top:20px;max-width:800px;margin-left:auto;margin-right:auto;}#editLink{float:right;font-weight:bold;margin-top:20px;}</style>";
args.content += "<div id='padContents'>"+text+"</div>";
args.content += "<div id='editLink'><a href='/p/"+padId+"'>Edit this pad</a></div>";
args.content += "</body></html>";
res.send(args.content);
callback();
},
]);
});
}


function safe_tags(str) {
return str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') ;
}
11 changes: 4 additions & 7 deletions 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",
Expand All @@ -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": {}
Expand Down

0 comments on commit 6bb857f

Please sign in to comment.