nodebb-plugin-reddit
Advanced tools
Comparing version 0.0.4 to 0.0.5
(function(Reddit) { | ||
"use strict"; | ||
var anchor = '<a href="http://reddit.com$1" target="_blank">$1</a>'; | ||
Reddit.parse = function(data, callback) { | ||
var regex = /\B(\/[ru]\/\w+)/g; | ||
Reddit.parsePost = function(data, callback) { | ||
var postContent = data && data.postData && data.postData.content; | ||
if (postContent && postContent.match(regex)) { | ||
data.postData.content = postContent.replace(regex, anchor); | ||
} | ||
data.postData.content = parse(postContent); | ||
callback(null, data); | ||
}; | ||
Reddit.parseRaw = function(raw, callback) { | ||
callback(null, parse(raw)); | ||
}; | ||
function parse(text) { | ||
var regex = /\B(\/[ru]\/\w+)/g; | ||
if (text && text.match(regex)) { | ||
return text.replace(regex, anchor); | ||
} else { | ||
return text; | ||
} | ||
} | ||
}(module.exports)); |
{ | ||
"name": "nodebb-plugin-reddit", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "NodeBB Reddit Plugin", | ||
@@ -5,0 +5,0 @@ "main": "library.js", |
{ | ||
"id": "nodebb-plugin-reddit", | ||
"name": "NodeBB Reddit Plugin", | ||
"description": "NodeBB Plugin that will create links to subreddits in /r/ notation.", | ||
"url": "https://github.com/Schamper/nodebb-plugin-reddit", | ||
"library": "./library.js", | ||
"hooks": [ | ||
{ "hook": "filter:parse.post", "method": "parse", "priority": 6 } | ||
] | ||
"id": "nodebb-plugin-reddit", | ||
"name": "NodeBB Reddit Plugin", | ||
"description": "NodeBB Plugin that will create links to subreddits in /r/ notation.", | ||
"url": "https://github.com/Schamper/nodebb-plugin-reddit", | ||
"library": "./library.js", | ||
"hooks": [ | ||
{ "hook": "filter:parse.post", "method": "parsePost", "priority": 6 }, | ||
{ "hook": "filter:parse.raw", "method": "parseRaw", "priority": 6 } | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
41553
18
31