mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-01 14:19:34 +02:00
fix: fix minimization of the client js
This commit is contained in:
1 parent
9e995a04db
commit
c3a890dac7
2 files changed
+85
-74
No files matched your search
+84
-73
@@ -196,32 +196,35 @@ angular
|
||||
return capitalized.join(" ");
|
||||
};
|
||||
})
|
||||
.filter("diff", function ($sce) {
|
||||
return function (str) {
|
||||
if (!str) return str;
|
||||
const lines = str.split("\n");
|
||||
const o = [];
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
lines[i] = lines[i].replace(/</g, "<").replace(/>/g, ">");
|
||||
if (lines[i].startsWith("+++")) {
|
||||
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("---")) {
|
||||
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("@@")) {
|
||||
o.push(`<span class="diff-lines">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("index")) {
|
||||
o.push(`<span class="diff-index">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("+")) {
|
||||
o.push(`<span class="diff-add">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("-")) {
|
||||
o.push(`<span class="diff-remove">${lines[i]}</span>`);
|
||||
} else {
|
||||
o.push(`<span class="diff-line">${lines[i]}</span>`);
|
||||
.filter("diff", [
|
||||
"$sce",
|
||||
function ($sce) {
|
||||
return function (str) {
|
||||
if (!str) return str;
|
||||
const lines = str.split("\n");
|
||||
const o = [];
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
lines[i] = lines[i].replace(/</g, "<").replace(/>/g, ">");
|
||||
if (lines[i].startsWith("+++")) {
|
||||
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("---")) {
|
||||
o.push(`<span class="diff-file">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("@@")) {
|
||||
o.push(`<span class="diff-lines">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("index")) {
|
||||
o.push(`<span class="diff-index">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("+")) {
|
||||
o.push(`<span class="diff-add">${lines[i]}</span>`);
|
||||
} else if (lines[i].startsWith("-")) {
|
||||
o.push(`<span class="diff-remove">${lines[i]}</span>`);
|
||||
} else {
|
||||
o.push(`<span class="diff-line">${lines[i]}</span>`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sce.trustAsHtml(o.join("\n"));
|
||||
};
|
||||
})
|
||||
return $sce.trustAsHtml(o.join("\n"));
|
||||
};
|
||||
},
|
||||
])
|
||||
.directive("markdown", [
|
||||
"$location",
|
||||
function ($location) {
|
||||
@@ -394,37 +397,42 @@ angular
|
||||
return {
|
||||
restrict: "E",
|
||||
scope: { file: "=" },
|
||||
controller: function ($element, $scope, $http) {
|
||||
function renderNotebookJSON(json) {
|
||||
const notebook = nb.parse(json);
|
||||
try {
|
||||
$element.html("");
|
||||
$element.append(notebook.render());
|
||||
Prism.highlightAll();
|
||||
} catch (error) {
|
||||
$element.html("Unable to render the notebook.");
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
if ($scope.$parent.content) {
|
||||
controller: [
|
||||
"$element",
|
||||
"$scope",
|
||||
"$http",
|
||||
function ($element, $scope, $http) {
|
||||
function renderNotebookJSON(json) {
|
||||
const notebook = nb.parse(json);
|
||||
try {
|
||||
renderNotebookJSON(JSON.parse($scope.$parent.content));
|
||||
$element.html("");
|
||||
$element.append(notebook.render());
|
||||
Prism.highlightAll();
|
||||
} catch (error) {
|
||||
$element.html(
|
||||
"Unable to render the notebook invalid notebook format."
|
||||
);
|
||||
$element.html("Unable to render the notebook.");
|
||||
}
|
||||
} else if ($scope.file) {
|
||||
$http
|
||||
.get($scope.file.download_url)
|
||||
.then((res) => renderNotebookJSON(res.data));
|
||||
}
|
||||
}
|
||||
$scope.$watch("file", (v) => {
|
||||
function render() {
|
||||
if ($scope.$parent.content) {
|
||||
try {
|
||||
renderNotebookJSON(JSON.parse($scope.$parent.content));
|
||||
} catch (error) {
|
||||
$element.html(
|
||||
"Unable to render the notebook invalid notebook format."
|
||||
);
|
||||
}
|
||||
} else if ($scope.file) {
|
||||
$http
|
||||
.get($scope.file.download_url)
|
||||
.then((res) => renderNotebookJSON(res.data));
|
||||
}
|
||||
}
|
||||
$scope.$watch("file", (v) => {
|
||||
render();
|
||||
});
|
||||
render();
|
||||
});
|
||||
render();
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
])
|
||||
@@ -435,32 +443,35 @@ angular
|
||||
scope: { stats: "=" },
|
||||
template:
|
||||
"<div class='lang' ng-repeat='lang in elements' title='{{lang.lang|title}}: {{lang.loc | number}} lines' data-toggle='tooltip' data-placement='bottom' style='width:{{lang.loc*100/total}}%;background:{{lang.color}};'></div>",
|
||||
controller: function ($scope) {
|
||||
function render() {
|
||||
$scope.elements = [];
|
||||
$scope.total = 0;
|
||||
for (let lang in $scope.stats) {
|
||||
const loc = $scope.stats[lang].code;
|
||||
if (!loc) {
|
||||
continue;
|
||||
controller: [
|
||||
"$scope",
|
||||
function ($scope) {
|
||||
function render() {
|
||||
$scope.elements = [];
|
||||
$scope.total = 0;
|
||||
for (let lang in $scope.stats) {
|
||||
const loc = $scope.stats[lang].code;
|
||||
if (!loc) {
|
||||
continue;
|
||||
}
|
||||
$scope.total += loc;
|
||||
$scope.elements.push({
|
||||
lang,
|
||||
loc,
|
||||
color: langColors[lang],
|
||||
});
|
||||
}
|
||||
$scope.total += loc;
|
||||
$scope.elements.push({
|
||||
lang,
|
||||
loc,
|
||||
color: langColors[lang],
|
||||
});
|
||||
setTimeout(() => {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
}, 100);
|
||||
}
|
||||
setTimeout(() => {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
$scope.$watch("stats", (v) => {
|
||||
$scope.$watch("stats", (v) => {
|
||||
render();
|
||||
});
|
||||
render();
|
||||
});
|
||||
render();
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
])
|
||||
|
||||
Vendored
+1
-1
@@ -6,4 +6,4 @@ ${e}</blockquote>
|
||||
`}table(e,t){return"<table>\n<thead>\n"+e+"</thead>\n"+(t=t&&`<tbody>${t}</tbody>`)+"</table>\n"}tablerow(e){return`<tr>
|
||||
${e}</tr>
|
||||
`}tablecell(e,t){var i=t.header?"th":"td";return(t.align?`<${i} align="${t.align}">`:`<${i}>`)+e+`</${i}>
|
||||
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,i){var n=c(e);if(null===n)return i;let s='<a href="'+(e=n)+'"';return t&&(s+=' title="'+t+'"'),s+=">"+i+"</a>"}image(e,t,i){var n=c(e);if(null===n)return i;let s=`<img src="${e=n}" alt="${i}"`;return t&&(s+=` title="${t}"`),s+=">"}text(e){return e}}class R{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class L{options;renderer;textRenderer;constructor(e){this.options=e||t.defaults,this.options.renderer=this.options.renderer||new E,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new R}static parse(e,t){return new L(t).parse(e)}static parseInline(e,t){return new L(t).parseInline(e)}parse(n,s=!0){let o="";for(let i=0;i<n.length;i++){var r=n[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const n=r,s=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==s||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(n.type)){o+=s||"";continue}}switch(r.type){case"space":continue;case"hr":o+=this.renderer.hr();continue;case"heading":{const n=r;o+=this.renderer.heading(this.parseInline(n.tokens),n.depth,this.parseInline(n.tokens,this.textRenderer).replace(F,(e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""));continue}case"code":{const n=r;o+=this.renderer.code(n.text,n.lang,!!n.escaped);continue}case"table":{const n=r;let e="",t="";for(let e=0;e<n.header.length;e++)t+=this.renderer.tablecell(this.parseInline(n.header[e].tokens),{header:!0,align:n.align[e]});e+=this.renderer.tablerow(t);let i="";for(let e=0;e<n.rows.length;e++){const o=n.rows[e];t="";for(let e=0;e<o.length;e++)t+=this.renderer.tablecell(this.parseInline(o[e].tokens),{header:!1,align:n.align[e]});i+=this.renderer.tablerow(t)}o+=this.renderer.table(e,i);continue}case"blockquote":{const n=r,s=this.parse(n.tokens);o+=this.renderer.blockquote(s);continue}case"list":{const n=r,s=n.ordered,e=n.start,a=n.loose;let i="";for(let t=0;t<n.items.length;t++){const o=n.items[t],c=o.checked,l=o.task;let e="";if(o.task){const n=this.renderer.checkbox(!!c);a?0<o.tokens.length&&"paragraph"===o.tokens[0].type?(o.tokens[0].text=n+" "+o.tokens[0].text,o.tokens[0].tokens&&0<o.tokens[0].tokens.length&&"text"===o.tokens[0].tokens[0].type&&(o.tokens[0].tokens[0].text=n+" "+o.tokens[0].tokens[0].text)):o.tokens.unshift({type:"text",text:n+" "}):e+=n+" "}e+=this.parse(o.tokens,a),i+=this.renderer.listitem(e,l,!!c)}o+=this.renderer.list(i,s,e);continue}case"html":{const n=r;o+=this.renderer.html(n.text,n.block);continue}case"paragraph":{const n=r;o+=this.renderer.paragraph(this.parseInline(n.tokens));continue}case"text":{let e=r,t=e.tokens?this.parseInline(e.tokens):e.text;for(;i+1<n.length&&"text"===n[i+1].type;)e=n[++i],t+="\n"+(e.tokens?this.parseInline(e.tokens):e.text);o+=s?this.renderer.paragraph(t):t;continue}default:{const n='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(n),"";throw new Error(n)}}}return o}parseInline(t,i){i=i||this.renderer;let n="";for(let e=0;e<t.length;e++){var s=t[e];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]){const t=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==t||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=t||"";continue}}switch(s.type){case"escape":{const t=s;n+=i.text(t.text);break}case"html":{const t=s;n+=i.html(t.text);break}case"link":{const t=s;n+=i.link(t.href,t.title,this.parseInline(t.tokens,i));break}case"image":{const t=s;n+=i.image(t.href,t.title,t.text);break}case"strong":{const t=s;n+=i.strong(this.parseInline(t.tokens,i));break}case"em":{const t=s;n+=i.em(this.parseInline(t.tokens,i));break}case"codespan":{const t=s;n+=i.codespan(t.text);break}case"br":n+=i.br();break;case"del":{const t=s;n+=i.del(this.parseInline(t.tokens,i));break}case"text":{const t=s;n+=i.text(t.text);break}default:{const t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return n}}class M{options;constructor(e){this.options=e||t.defaults}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}class ce{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(T.lex,L.parse);parseInline=this.#e(T.lexInline,L.parseInline);Parser=L;Renderer=E;TextRenderer=RLine truncated
|
||||
`}strong(e){return`<strong>${e}</strong>`}em(e){return`<em>${e}</em>`}codespan(e){return`<code>${e}</code>`}br(){return"<br>"}del(e){return`<del>${e}</del>`}link(e,t,i){var n=c(e);if(null===n)return i;let s='<a href="'+(e=n)+'"';return t&&(s+=' title="'+t+'"'),s+=">"+i+"</a>"}image(e,t,i){var n=c(e);if(null===n)return i;let s=`<img src="${e=n}" alt="${i}"`;return t&&(s+=` title="${t}"`),s+=">"}text(e){return e}}class R{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class L{options;renderer;textRenderer;constructor(e){this.options=e||t.defaults,this.options.renderer=this.options.renderer||new E,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new R}static parse(e,t){return new L(t).parse(e)}static parseInline(e,t){return new L(t).parseInline(e)}parse(n,s=!0){let o="";for(let i=0;i<n.length;i++){var r=n[i];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[r.type]){const n=r,s=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==s||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(n.type)){o+=s||"";continue}}switch(r.type){case"space":continue;case"hr":o+=this.renderer.hr();continue;case"heading":{const n=r;o+=this.renderer.heading(this.parseInline(n.tokens),n.depth,this.parseInline(n.tokens,this.textRenderer).replace(F,(e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""));continue}case"code":{const n=r;o+=this.renderer.code(n.text,n.lang,!!n.escaped);continue}case"table":{const n=r;let e="",t="";for(let e=0;e<n.header.length;e++)t+=this.renderer.tablecell(this.parseInline(n.header[e].tokens),{header:!0,align:n.align[e]});e+=this.renderer.tablerow(t);let i="";for(let e=0;e<n.rows.length;e++){const o=n.rows[e];t="";for(let e=0;e<o.length;e++)t+=this.renderer.tablecell(this.parseInline(o[e].tokens),{header:!1,align:n.align[e]});i+=this.renderer.tablerow(t)}o+=this.renderer.table(e,i);continue}case"blockquote":{const n=r,s=this.parse(n.tokens);o+=this.renderer.blockquote(s);continue}case"list":{const n=r,s=n.ordered,e=n.start,a=n.loose;let i="";for(let t=0;t<n.items.length;t++){const o=n.items[t],c=o.checked,l=o.task;let e="";if(o.task){const n=this.renderer.checkbox(!!c);a?0<o.tokens.length&&"paragraph"===o.tokens[0].type?(o.tokens[0].text=n+" "+o.tokens[0].text,o.tokens[0].tokens&&0<o.tokens[0].tokens.length&&"text"===o.tokens[0].tokens[0].type&&(o.tokens[0].tokens[0].text=n+" "+o.tokens[0].tokens[0].text)):o.tokens.unshift({type:"text",text:n+" "}):e+=n+" "}e+=this.parse(o.tokens,a),i+=this.renderer.listitem(e,l,!!c)}o+=this.renderer.list(i,s,e);continue}case"html":{const n=r;o+=this.renderer.html(n.text,n.block);continue}case"paragraph":{const n=r;o+=this.renderer.paragraph(this.parseInline(n.tokens));continue}case"text":{let e=r,t=e.tokens?this.parseInline(e.tokens):e.text;for(;i+1<n.length&&"text"===n[i+1].type;)e=n[++i],t+="\n"+(e.tokens?this.parseInline(e.tokens):e.text);o+=s?this.renderer.paragraph(t):t;continue}default:{const n='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(n),"";throw new Error(n)}}}return o}parseInline(t,i){i=i||this.renderer;let n="";for(let e=0;e<t.length;e++){var s=t[e];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[s.type]){const t=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==t||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=t||"";continue}}switch(s.type){case"escape":{const t=s;n+=i.text(t.text);break}case"html":{const t=s;n+=i.html(t.text);break}case"link":{const t=s;n+=i.link(t.href,t.title,this.parseInline(t.tokens,i));break}case"image":{const t=s;n+=i.image(t.href,t.title,t.text);break}case"strong":{const t=s;n+=i.strong(this.parseInline(t.tokens,i));break}case"em":{const t=s;n+=i.em(this.parseInline(t.tokens,i));break}case"codespan":{const t=s;n+=i.codespan(t.text);break}case"br":n+=i.br();break;case"del":{const t=s;n+=i.del(this.parseInline(t.tokens,i));break}case"text":{const t=s;n+=i.text(t.text);break}default:{const t='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(t),"";throw new Error(t)}}}return n}}class M{options;constructor(e){this.options=e||t.defaults}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}}class ce{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.#e(T.lex,L.parse);parseInline=this.#e(T.lexInline,L.parseInline);Parser=L;Renderer=E;TextRenderer=RLine truncated
|
||||
Reference in new issue
Block a user