forked from forgejo/forgejo
* Cleaning up public/ and documenting js/css libs. This commit mostly addresses #1484 by moving vendor'ed plugins into a vendor/ directory and documenting their upstream source and license in vendor/librejs.html. This also proves gitea is using only open source js/css libraries which helps toward reaching #1524. * Removing unused css file. The version of this file in use is located at: vendor/plugins/highlight/github.css * Cleaned up librejs.html and added javascript header A SafeJS function was added to templates/helper.go to allow keeping comments inside of javascript. A javascript comment was added in the header of templates/base/head.tmpl to mark all non-inline source as free. The librejs.html file was updated to meet the current librejs spec. I have now verified that the librejs plugin detects most of the scripts included in gitea and suspect the non-free detections are the result of a bug in the plugin. I believe this commit is enough to meet the C0.0 requirement of #1534. * Updating SafeJS function per lint suggestion * Added VERSIONS file, per request
This commit is contained in:
parent
64b7068846
commit
a915a09e4f
1339 changed files with 813 additions and 126 deletions
142
public/vendor/plugins/codemirror/mode/tcl/index.html
vendored
Normal file
142
public/vendor/plugins/codemirror/mode/tcl/index.html
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Tcl mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/night.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="tcl.js"></script>
|
||||
<script src="../../addon/scroll/scrollpastend.js"></script>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/codemirror/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Tcl</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Tcl mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
##############################################################################################
|
||||
## ## whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
|
||||
##############################################################################################
|
||||
## To use this script you must set channel flag +whois (ie .chanset #chan +whois) ##
|
||||
##############################################################################################
|
||||
## ____ __ ########################################### ##
|
||||
## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
|
||||
## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
|
||||
## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
|
||||
## /___/ /___/ /_/ ########################################### ##
|
||||
## ########################################### ##
|
||||
##############################################################################################
|
||||
## ## Start Setup. ## ##
|
||||
##############################################################################################
|
||||
namespace eval whois {
|
||||
## change cmdchar to the trigger you want to use ## ##
|
||||
variable cmdchar "!"
|
||||
## change command to the word trigger you would like to use. ## ##
|
||||
## Keep in mind, This will also change the .chanset +/-command ## ##
|
||||
variable command "whois"
|
||||
## change textf to the colors you want for the text. ## ##
|
||||
variable textf "\017\00304"
|
||||
## change tagf to the colors you want for tags: ## ##
|
||||
variable tagf "\017\002"
|
||||
## Change logo to the logo you want at the start of the line. ## ##
|
||||
variable logo "\017\00304\002\[\00306W\003hois\00304\]\017"
|
||||
## Change lineout to the results you want. Valid results are channel users modes topic ## ##
|
||||
variable lineout "channel users modes topic"
|
||||
##############################################################################################
|
||||
## ## End Setup. ## ##
|
||||
##############################################################################################
|
||||
variable channel ""
|
||||
setudef flag $whois::command
|
||||
bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::list
|
||||
bind raw -|- "311" whois::311
|
||||
bind raw -|- "312" whois::312
|
||||
bind raw -|- "319" whois::319
|
||||
bind raw -|- "317" whois::317
|
||||
bind raw -|- "313" whois::multi
|
||||
bind raw -|- "310" whois::multi
|
||||
bind raw -|- "335" whois::multi
|
||||
bind raw -|- "301" whois::301
|
||||
bind raw -|- "671" whois::multi
|
||||
bind raw -|- "320" whois::multi
|
||||
bind raw -|- "401" whois::multi
|
||||
bind raw -|- "318" whois::318
|
||||
bind raw -|- "307" whois::307
|
||||
}
|
||||
proc whois::311 {from key text} {
|
||||
if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} {
|
||||
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Host:${whois::textf} \
|
||||
$nick \(${ident}@${host}\) ${whois::tagf}Realname:${whois::textf} $realname"
|
||||
}
|
||||
}
|
||||
proc whois::multi {from key text} {
|
||||
if {[regexp {\:(.*)$} $text match $key]} {
|
||||
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Note:${whois::textf} [subst $$key]"
|
||||
return 1
|
||||
}
|
||||
}
|
||||
proc whois::312 {from key text} {
|
||||
regexp {([^\s]+)\s\:} $text match server
|
||||
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Server:${whois::textf} $server"
|
||||
}
|
||||
proc whois::319 {from key text} {
|
||||
if {[regexp {.+\:(.+)$} $text match channels]} {
|
||||
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Channels:${whois::textf} $channels"
|
||||
}
|
||||
}
|
||||
proc whois::317 {from key text} {
|
||||
if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} {
|
||||
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Connected:${whois::textf} \
|
||||
[ctime $signon] ${whois::tagf}Idle:${whois::textf} [duration $idle]"
|
||||
}
|
||||
}
|
||||
proc whois::301 {from key text} {
|
||||
if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} {
|
||||
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg"
|
||||
}
|
||||
}
|
||||
proc whois::318 {from key text} {
|
||||
namespace eval whois {
|
||||
variable channel ""
|
||||
}
|
||||
variable whois::channel ""
|
||||
}
|
||||
proc whois::307 {from key text} {
|
||||
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Services:${whois::textf} Registered Nick"
|
||||
}
|
||||
proc whois::list {nick host hand chan text} {
|
||||
if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} {
|
||||
namespace eval whois {
|
||||
variable channel ""
|
||||
}
|
||||
variable whois::channel $chan
|
||||
putserv "WHOIS $text"
|
||||
}
|
||||
}
|
||||
putlog "\002*Loaded* \017\00304\002\[\00306W\003hois\00304\]\017 \002by \
|
||||
Ford_Lawnmower irc.GeekShed.net #Script-Help"
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
theme: "night",
|
||||
lineNumbers: true,
|
||||
indentUnit: 2,
|
||||
scrollPastEnd: true,
|
||||
mode: "text/x-tcl"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-tcl</code>.</p>
|
||||
|
||||
</article>
|
139
public/vendor/plugins/codemirror/mode/tcl/tcl.js
vendored
Normal file
139
public/vendor/plugins/codemirror/mode/tcl/tcl.js
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("tcl", function() {
|
||||
function parseWords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var keywords = parseWords("Tcl safe after append array auto_execok auto_import auto_load " +
|
||||
"auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror " +
|
||||
"binary break catch cd close concat continue dde eof encoding error " +
|
||||
"eval exec exit expr fblocked fconfigure fcopy file fileevent filename " +
|
||||
"filename flush for foreach format gets glob global history http if " +
|
||||
"incr info interp join lappend lindex linsert list llength load lrange " +
|
||||
"lreplace lsearch lset lsort memory msgcat namespace open package parray " +
|
||||
"pid pkg::create pkg_mkIndex proc puts pwd re_syntax read regex regexp " +
|
||||
"registry regsub rename resource return scan seek set socket source split " +
|
||||
"string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord " +
|
||||
"tcl_wordBreakAfter tcl_startOfPreviousWord tcl_wordBreakBefore tcltest " +
|
||||
"tclvars tell time trace unknown unset update uplevel upvar variable " +
|
||||
"vwait");
|
||||
var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");
|
||||
var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;
|
||||
function chain(stream, state, f) {
|
||||
state.tokenize = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
function tokenBase(stream, state) {
|
||||
var beforeParams = state.beforeParams;
|
||||
state.beforeParams = false;
|
||||
var ch = stream.next();
|
||||
if ((ch == '"' || ch == "'") && state.inParams) {
|
||||
return chain(stream, state, tokenString(ch));
|
||||
} else if (/[\[\]{}\(\),;\.]/.test(ch)) {
|
||||
if (ch == "(" && beforeParams) state.inParams = true;
|
||||
else if (ch == ")") state.inParams = false;
|
||||
return null;
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
} else if (ch == "#") {
|
||||
if (stream.eat("*"))
|
||||
return chain(stream, state, tokenComment);
|
||||
if (ch == "#" && stream.match(/ *\[ *\[/))
|
||||
return chain(stream, state, tokenUnparsed);
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if (ch == '"') {
|
||||
stream.skipTo(/"/);
|
||||
return "comment";
|
||||
} else if (ch == "$") {
|
||||
stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);
|
||||
stream.eatWhile(/}/);
|
||||
state.beforeParams = true;
|
||||
return "builtin";
|
||||
} else if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "comment";
|
||||
} else {
|
||||
stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
|
||||
var word = stream.current().toLowerCase();
|
||||
if (keywords && keywords.propertyIsEnumerable(word))
|
||||
return "keyword";
|
||||
if (functions && functions.propertyIsEnumerable(word)) {
|
||||
state.beforeParams = true;
|
||||
return "keyword";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end) state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "#" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
function tokenUnparsed(stream, state) {
|
||||
var maybeEnd = 0, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "#" && maybeEnd == 2) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
if (ch == "]")
|
||||
maybeEnd++;
|
||||
else if (ch != " ")
|
||||
maybeEnd = 0;
|
||||
}
|
||||
return "meta";
|
||||
}
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
beforeParams: false,
|
||||
inParams: false
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
};
|
||||
});
|
||||
CodeMirror.defineMIME("text/x-tcl", "tcl");
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue