mirror of
https://github.com/go-gitea/gitea.git
synced 2025-12-18 19:11:36 +00:00
Move 3rd party js/css into public/vendor and document sources (#2383)
This commit cherry picks the following commits (master -> v1.2):a915a09874f9be233bbcfRef: https://github.com/go-gitea/gitea/issues/1484 Signed-off-by: Michael Lustfield <michael@lustfield.net>
This commit is contained in:
committed by
Lunny Xiao
parent
e13eef8cfe
commit
9df0eafa25
21
public/vendor/plugins/autolink/LICENSE
vendored
Normal file
21
public/vendor/plugins/autolink/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 egoist 0x142857@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
45
public/vendor/plugins/autolink/autolink.js
vendored
Normal file
45
public/vendor/plugins/autolink/autolink.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
(function () {
|
||||
var re = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-]*)?\??(?:[\-\+:=&;%@\.\w]*)#?(?:[\.\!\/\\\w]*))?)/g;
|
||||
function textNodesUnder(node) {
|
||||
var textNodes = [];
|
||||
if(typeof document.createTreeWalker === 'function') {
|
||||
// Efficient TreeWalker
|
||||
var currentNode, walker;
|
||||
walker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT, null, false);
|
||||
while(currentNode = walker.nextNode()) {
|
||||
textNodes.push(currentNode);
|
||||
}
|
||||
} else {
|
||||
// Less efficient recursive function
|
||||
for(node = node.firstChild; node; node = node.nextSibling) {
|
||||
if(node.nodeType === 3) {
|
||||
textNodes.push(node);
|
||||
} else {
|
||||
textNodes = textNodes.concat(textNodesUnder(node));
|
||||
}
|
||||
}
|
||||
}
|
||||
return textNodes;
|
||||
}
|
||||
|
||||
function processNode(node) {
|
||||
re.lastIndex = 0;
|
||||
var results = re.exec(node.textContent);
|
||||
if(results !== null) {
|
||||
if($(node).parents().filter('pre>code').length === 0) {
|
||||
$(node).replaceWith(
|
||||
$('<span />').html(
|
||||
node.nodeValue.replace(re, '<a href="$1">$1</a>')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jQuery.fn.autolink = function () {
|
||||
this.each(function () {
|
||||
textNodesUnder(this).forEach(processNode);
|
||||
});
|
||||
return this;
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user