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
157
public/vendor/plugins/codemirror/mode/dart/dart.js
vendored
Normal file
157
public/vendor/plugins/codemirror/mode/dart/dart.js
vendored
Normal file
|
@ -0,0 +1,157 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../clike/clike"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../clike/clike"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var keywords = ("this super static final const abstract class extends external factory " +
|
||||
"implements get native operator set typedef with enum throw rethrow " +
|
||||
"assert break case continue default in return new deferred async await " +
|
||||
"try catch finally do else for if switch while import library export " +
|
||||
"part of show hide is as").split(" ");
|
||||
var blockKeywords = "try catch finally do else for if switch while".split(" ");
|
||||
var atoms = "true false null".split(" ");
|
||||
var builtins = "void bool num int double dynamic var String".split(" ");
|
||||
|
||||
function set(words) {
|
||||
var obj = {};
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function pushInterpolationStack(state) {
|
||||
(state.interpolationStack || (state.interpolationStack = [])).push(state.tokenize);
|
||||
}
|
||||
|
||||
function popInterpolationStack(state) {
|
||||
return (state.interpolationStack || (state.interpolationStack = [])).pop();
|
||||
}
|
||||
|
||||
function sizeInterpolationStack(state) {
|
||||
return state.interpolationStack ? state.interpolationStack.length : 0;
|
||||
}
|
||||
|
||||
CodeMirror.defineMIME("application/dart", {
|
||||
name: "clike",
|
||||
keywords: set(keywords),
|
||||
blockKeywords: set(blockKeywords),
|
||||
builtin: set(builtins),
|
||||
atoms: set(atoms),
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_\.]/);
|
||||
return "meta";
|
||||
},
|
||||
|
||||
// custom string handling to deal with triple-quoted strings and string interpolation
|
||||
"'": function(stream, state) {
|
||||
return tokenString("'", stream, state, false);
|
||||
},
|
||||
"\"": function(stream, state) {
|
||||
return tokenString("\"", stream, state, false);
|
||||
},
|
||||
"r": function(stream, state) {
|
||||
var peek = stream.peek();
|
||||
if (peek == "'" || peek == "\"") {
|
||||
return tokenString(stream.next(), stream, state, true);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
"}": function(_stream, state) {
|
||||
// "}" is end of interpolation, if interpolation stack is non-empty
|
||||
if (sizeInterpolationStack(state) > 0) {
|
||||
state.tokenize = popInterpolationStack(state);
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
"/": function(stream, state) {
|
||||
if (!stream.eat("*")) return false
|
||||
state.tokenize = tokenNestedComment(1)
|
||||
return state.tokenize(stream, state)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function tokenString(quote, stream, state, raw) {
|
||||
var tripleQuoted = false;
|
||||
if (stream.eat(quote)) {
|
||||
if (stream.eat(quote)) tripleQuoted = true;
|
||||
else return "string"; //empty string
|
||||
}
|
||||
function tokenStringHelper(stream, state) {
|
||||
var escaped = false;
|
||||
while (!stream.eol()) {
|
||||
if (!raw && !escaped && stream.peek() == "$") {
|
||||
pushInterpolationStack(state);
|
||||
state.tokenize = tokenInterpolation;
|
||||
return "string";
|
||||
}
|
||||
var next = stream.next();
|
||||
if (next == quote && !escaped && (!tripleQuoted || stream.match(quote + quote))) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
escaped = !raw && !escaped && next == "\\";
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
state.tokenize = tokenStringHelper;
|
||||
return tokenStringHelper(stream, state);
|
||||
}
|
||||
|
||||
function tokenInterpolation(stream, state) {
|
||||
stream.eat("$");
|
||||
if (stream.eat("{")) {
|
||||
// let clike handle the content of ${...},
|
||||
// we take over again when "}" appears (see hooks).
|
||||
state.tokenize = null;
|
||||
} else {
|
||||
state.tokenize = tokenInterpolationIdentifier;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function tokenInterpolationIdentifier(stream, state) {
|
||||
stream.eatWhile(/[\w_]/);
|
||||
state.tokenize = popInterpolationStack(state);
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenNestedComment(depth) {
|
||||
return function (stream, state) {
|
||||
var ch
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "*" && stream.eat("/")) {
|
||||
if (depth == 1) {
|
||||
state.tokenize = null
|
||||
break
|
||||
} else {
|
||||
state.tokenize = tokenNestedComment(depth - 1)
|
||||
return state.tokenize(stream, state)
|
||||
}
|
||||
} else if (ch == "/" && stream.eat("*")) {
|
||||
state.tokenize = tokenNestedComment(depth + 1)
|
||||
return state.tokenize(stream, state)
|
||||
}
|
||||
}
|
||||
return "comment"
|
||||
}
|
||||
}
|
||||
|
||||
CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
|
||||
|
||||
// This is needed to make loading through meta.js work.
|
||||
CodeMirror.defineMode("dart", function(conf) {
|
||||
return CodeMirror.getMode(conf, "application/dart");
|
||||
}, "clike");
|
||||
});
|
71
public/vendor/plugins/codemirror/mode/dart/index.html
vendored
Normal file
71
public/vendor/plugins/codemirror/mode/dart/index.html
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Dart mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../clike/clike.js"></script>
|
||||
<script src="dart.js"></script>
|
||||
<style>.CodeMirror {border: 1px solid #dee;}</style>
|
||||
<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="#">Dart</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Dart mode</h2>
|
||||
<form>
|
||||
<textarea id="code" name="code">
|
||||
import 'dart:math' show Random;
|
||||
|
||||
void main() {
|
||||
print(new Die(n: 12).roll());
|
||||
}
|
||||
|
||||
// Define a class.
|
||||
class Die {
|
||||
// Define a class variable.
|
||||
static Random shaker = new Random();
|
||||
|
||||
// Define instance variables.
|
||||
int sides, value;
|
||||
|
||||
// Define a method using shorthand syntax.
|
||||
String toString() => '$value';
|
||||
|
||||
// Define a constructor.
|
||||
Die({int n: 6}) {
|
||||
if (4 <= n && n <= 20) {
|
||||
sides = n;
|
||||
} else {
|
||||
// Support for errors and exceptions.
|
||||
throw new ArgumentError(/* */);
|
||||
}
|
||||
}
|
||||
|
||||
// Define an instance method.
|
||||
int roll() {
|
||||
return value = shaker.nextInt(sides) + 1;
|
||||
}
|
||||
}
|
||||
</textarea>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: "application/dart"
|
||||
});
|
||||
</script>
|
||||
|
||||
</article>
|
Loading…
Add table
Add a link
Reference in a new issue