Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "ep_linkify", | ||
"description": "Adds internal links to etherpad lite. This is a plugin for etherpad lite, so you'll need to install etherpad-lite to use it.", | ||
"version": "0.1.0", | ||
"description": "Adds internal links to etherpad lite. To create internal links use [[example]] style formatting", | ||
"version": "0.1.1", | ||
"author": "fourplusone <info@fourplusone.de>", | ||
@@ -10,3 +10,7 @@ "contributors": [ | ||
"email": "mba@fourplusone.de" | ||
} | ||
}, | ||
{ | ||
"name": "John McLear", | ||
"email": "john@mclear.co.uk" | ||
} | ||
], | ||
@@ -13,0 +17,0 @@ "dependencies": {}, |
@@ -1,6 +0,11 @@ | ||
var Security = require('ep_etherpad-lite/static/js/security.js'); | ||
/* Include the Security module, we will use this later to escape a HTML attribute*/ | ||
var Security = require('ep_etherpad-lite/static/js/security.js'); | ||
/* Define the regular expressions we will use to detect if a string looks like a reference to a pad IE [[foo]] */ | ||
var internalHrefRegexp = new RegExp(/\[\[([^\]]+)\]\]/g); | ||
// Define a regexp to detect if we are in timeslider | ||
var timesliderRegexp = new RegExp(/p\/[^\/]*\/timeslider/g); | ||
/* Take the string and remove the first and last 2 characters IE [[foo]] returns foo */ | ||
var linkSanitizingFn = function(result){ | ||
@@ -17,2 +22,6 @@ if(!result) return result; | ||
/* CustomRegexp provides a wrapper around a RegExp Object which applies a given function to the result of the Regexp | ||
@param regexp the regexp to be wrapped | ||
@param sanitizeResultFn the function to be applied to the result. | ||
*/ | ||
var CustomRegexp = function(regexp, sanitizeResultFn){ | ||
@@ -23,2 +32,3 @@ this.regexp = regexp; | ||
CustomRegexp.prototype.exec = function(text){ | ||
@@ -29,7 +39,12 @@ var result = this.regexp.exec(text); | ||
var getCustomRegexpFilter = function(regExp, tag, sanitizeFn, linestylefilter) | ||
/* getCustomRegexpFilter returns a linestylefilter compatible filter for a CustomRegexp | ||
@param customRegexp the CustomRegexp Object | ||
@param tag the tag to be filtered | ||
@param linestylefilter reference to linestylefilter module | ||
*/ | ||
var getCustomRegexpFilter = function(customRegexp, tag, linestylefilter) | ||
{ | ||
var customRegexp = new CustomRegexp(regExp, sanitizeFn); | ||
var filter = linestylefilter.getRegexpFilter(customRegexp, tag); | ||
return filter | ||
return filter; | ||
} | ||
@@ -39,3 +54,2 @@ | ||
exports.aceCreateDomLine = function(name, context){ | ||
var internalHref; | ||
@@ -48,3 +62,3 @@ var cls = context.cls; | ||
if (cls.indexOf('internalHref') >= 0) | ||
if (cls.indexOf('internalHref') >= 0) // if it already has the class of internalHref | ||
{ | ||
@@ -60,3 +74,2 @@ cls = cls.replace(/(^| )internalHref:(\S+)/g, function(x0, space, url) | ||
{ | ||
var url = (inTimeslider ? '../' : './') + internalHref; | ||
@@ -75,11 +88,8 @@ var modifier = { | ||
var linestylefilter = context.linestylefilter; | ||
var filter = getCustomRegexpFilter( | ||
internalHrefRegexp, | ||
new CustomRegexp(internalHrefRegexp, linkSanitizingFn), | ||
'internalHref', | ||
linkSanitizingFn, | ||
linestylefilter | ||
); | ||
return [filter]; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3829
84
5