mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
init
This commit is contained in:
4
javascripts/libs/jquery-1.7.1.min.js
vendored
Executable file
4
javascripts/libs/jquery-1.7.1.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
771
javascripts/libs/marked.js
Executable file
771
javascripts/libs/marked.js
Executable file
@@ -0,0 +1,771 @@
|
||||
/**
|
||||
* marked - A markdown parser (https://github.com/chjj/marked)
|
||||
* Copyright (c) 2011-2012, Christopher Jeffrey. (MIT Licensed)
|
||||
*/
|
||||
|
||||
;(function() {
|
||||
|
||||
/**
|
||||
* Block-Level Grammar
|
||||
*/
|
||||
|
||||
var block = {
|
||||
newline: /^\n+/,
|
||||
code: /^( {4}[^\n]+\n*)+/,
|
||||
fences: noop,
|
||||
hr: /^( *[\-*_]){3,} *(?:\n+|$)/,
|
||||
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
|
||||
lheading: /^([^\n]+)\n *(=|-){3,} *\n*/,
|
||||
blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/,
|
||||
list: /^( *)([*+-]|\d+\.) [^\0]+?(?:\n{2,}(?! )(?!\1bullet)\n*|\s*$)/,
|
||||
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
|
||||
def: /^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
|
||||
paragraph: /^([^\n]+\n?(?!body))+\n*/,
|
||||
text: /^[^\n]+/
|
||||
};
|
||||
|
||||
block.list = replace(block.list)
|
||||
('bullet', /(?:[*+-](?!(?: *[-*]){2,})|\d+\.)/)
|
||||
();
|
||||
|
||||
block.html = replace(block.html)
|
||||
('comment', /<!--[^\0]*?-->/)
|
||||
('closed', /<(tag)[^\0]+?<\/\1>/)
|
||||
('closing', /<tag(?!:\/|@)\b(?:"[^"]*"|'[^']*'|[^'">])*?>/)
|
||||
(/tag/g, tag())
|
||||
();
|
||||
|
||||
block.paragraph = (function() {
|
||||
var paragraph = block.paragraph.source
|
||||
, body = [];
|
||||
|
||||
(function push(rule) {
|
||||
rule = block[rule] ? block[rule].source : rule;
|
||||
body.push(rule.replace(/(^|[^\[])\^/g, '$1'));
|
||||
return push;
|
||||
})
|
||||
('hr')
|
||||
('heading')
|
||||
('lheading')
|
||||
('blockquote')
|
||||
('<' + tag())
|
||||
('def');
|
||||
|
||||
return new
|
||||
RegExp(paragraph.replace('body', body.join('|')));
|
||||
})();
|
||||
|
||||
block.normal = {
|
||||
fences: block.fences,
|
||||
paragraph: block.paragraph
|
||||
};
|
||||
|
||||
block.gfm = {
|
||||
fences: /^ *``` *(\w+)? *\n([^\0]+?)\s*``` *(?:\n+|$)/,
|
||||
paragraph: /^/
|
||||
};
|
||||
|
||||
block.gfm.paragraph = replace(block.paragraph)
|
||||
('(?!', '(?!' + block.gfm.fences.source.replace(/(^|[^\[])\^/g, '$1') + '|')
|
||||
();
|
||||
|
||||
/**
|
||||
* Block Lexer
|
||||
*/
|
||||
|
||||
block.lexer = function(src) {
|
||||
var tokens = [];
|
||||
|
||||
tokens.links = {};
|
||||
|
||||
src = src
|
||||
.replace(/\r\n|\r/g, '\n')
|
||||
.replace(/\t/g, ' ');
|
||||
|
||||
return block.token(src, tokens, true);
|
||||
};
|
||||
|
||||
block.token = function(src, tokens, top) {
|
||||
var src = src.replace(/^ +$/gm, '')
|
||||
, next
|
||||
, loose
|
||||
, cap
|
||||
, item
|
||||
, space
|
||||
, i
|
||||
, l;
|
||||
|
||||
while (src) {
|
||||
// newline
|
||||
if (cap = block.newline.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
if (cap[0].length > 1) {
|
||||
tokens.push({
|
||||
type: 'space'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// code
|
||||
if (cap = block.code.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
cap = cap[0].replace(/^ {4}/gm, '');
|
||||
tokens.push({
|
||||
type: 'code',
|
||||
text: !options.pedantic
|
||||
? cap.replace(/\n+$/, '')
|
||||
: cap
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// fences (gfm)
|
||||
if (cap = block.fences.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'code',
|
||||
lang: cap[1],
|
||||
text: cap[2]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// heading
|
||||
if (cap = block.heading.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'heading',
|
||||
depth: cap[1].length,
|
||||
text: cap[2]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// lheading
|
||||
if (cap = block.lheading.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'heading',
|
||||
depth: cap[2] === '=' ? 1 : 2,
|
||||
text: cap[1]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// hr
|
||||
if (cap = block.hr.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'hr'
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// blockquote
|
||||
if (cap = block.blockquote.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
|
||||
tokens.push({
|
||||
type: 'blockquote_start'
|
||||
});
|
||||
|
||||
cap = cap[0].replace(/^ *> ?/gm, '');
|
||||
|
||||
// Pass `top` to keep the current
|
||||
// "toplevel" state. This is exactly
|
||||
// how markdown.pl works.
|
||||
block.token(cap, tokens, top);
|
||||
|
||||
tokens.push({
|
||||
type: 'blockquote_end'
|
||||
});
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// list
|
||||
if (cap = block.list.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
|
||||
tokens.push({
|
||||
type: 'list_start',
|
||||
ordered: isFinite(cap[2])
|
||||
});
|
||||
|
||||
// Get each top-level item.
|
||||
cap = cap[0].match(
|
||||
/^( *)([*+-]|\d+\.) [^\n]*(?:\n(?!\1(?:[*+-]|\d+\.) )[^\n]*)*/gm
|
||||
);
|
||||
|
||||
next = false;
|
||||
l = cap.length;
|
||||
i = 0;
|
||||
|
||||
for (; i < l; i++) {
|
||||
item = cap[i];
|
||||
|
||||
// Remove the list item's bullet
|
||||
// so it is seen as the next token.
|
||||
space = item.length;
|
||||
item = item.replace(/^ *([*+-]|\d+\.) +/, '');
|
||||
|
||||
// Outdent whatever the
|
||||
// list item contains. Hacky.
|
||||
if (~item.indexOf('\n ')) {
|
||||
space -= item.length;
|
||||
item = !options.pedantic
|
||||
? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
|
||||
: item.replace(/^ {1,4}/gm, '');
|
||||
}
|
||||
|
||||
// Determine whether item is loose or not.
|
||||
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
|
||||
// for discount behavior.
|
||||
loose = next || /\n\n(?!\s*$)/.test(item);
|
||||
if (i !== l - 1) {
|
||||
next = item[item.length-1] === '\n';
|
||||
if (!loose) loose = next;
|
||||
}
|
||||
|
||||
tokens.push({
|
||||
type: loose
|
||||
? 'loose_item_start'
|
||||
: 'list_item_start'
|
||||
});
|
||||
|
||||
// Recurse.
|
||||
block.token(item, tokens);
|
||||
|
||||
tokens.push({
|
||||
type: 'list_item_end'
|
||||
});
|
||||
}
|
||||
|
||||
tokens.push({
|
||||
type: 'list_end'
|
||||
});
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// html
|
||||
if (cap = block.html.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'html',
|
||||
pre: cap[1] === 'pre',
|
||||
text: cap[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// def
|
||||
if (top && (cap = block.def.exec(src))) {
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.links[cap[1].toLowerCase()] = {
|
||||
href: cap[2],
|
||||
title: cap[3]
|
||||
};
|
||||
continue;
|
||||
}
|
||||
|
||||
// top-level paragraph
|
||||
if (top && (cap = block.paragraph.exec(src))) {
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'paragraph',
|
||||
text: cap[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// text
|
||||
if (cap = block.text.exec(src)) {
|
||||
// Top-level should never reach here.
|
||||
src = src.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'text',
|
||||
text: cap[0]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return tokens;
|
||||
};
|
||||
|
||||
/**
|
||||
* Inline Processing
|
||||
*/
|
||||
|
||||
var inline = {
|
||||
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
|
||||
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
||||
url: noop,
|
||||
tag: /^<!--[^\0]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
||||
link: /^!?\[(inside)\]\(href\)/,
|
||||
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
||||
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
||||
strong: /^__([^\0]+?)__(?!_)|^\*\*([^\0]+?)\*\*(?!\*)/,
|
||||
em: /^\b_((?:__|[^\0])+?)_\b|^\*((?:\*\*|[^\0])+?)\*(?!\*)/,
|
||||
code: /^(`+)([^\0]*?[^`])\1(?!`)/,
|
||||
br: /^ {2,}\n(?!\s*$)/,
|
||||
text: /^[^\0]+?(?=[\\<!\[_*`]| {2,}\n|$)/
|
||||
};
|
||||
|
||||
inline._linkInside = /(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/;
|
||||
inline._linkHref = /\s*<?([^\s]*?)>?(?:\s+['"]([^\0]*?)['"])?\s*/;
|
||||
|
||||
inline.link = replace(inline.link)
|
||||
('inside', inline._linkInside)
|
||||
('href', inline._linkHref)
|
||||
();
|
||||
|
||||
inline.reflink = replace(inline.reflink)
|
||||
('inside', inline._linkInside)
|
||||
();
|
||||
|
||||
inline.normal = {
|
||||
url: inline.url,
|
||||
strong: inline.strong,
|
||||
em: inline.em,
|
||||
text: inline.text
|
||||
};
|
||||
|
||||
inline.pedantic = {
|
||||
strong: /^__(?=\S)([^\0]*?\S)__(?!_)|^\*\*(?=\S)([^\0]*?\S)\*\*(?!\*)/,
|
||||
em: /^_(?=\S)([^\0]*?\S)_(?!_)|^\*(?=\S)([^\0]*?\S)\*(?!\*)/
|
||||
};
|
||||
|
||||
inline.gfm = {
|
||||
url: /^(https?:\/\/[^\s]+[^.,:;"')\]\s])/,
|
||||
text: /^[^\0]+?(?=[\\<!\[_*`]|https?:\/\/| {2,}\n|$)/
|
||||
};
|
||||
|
||||
/**
|
||||
* Inline Lexer
|
||||
*/
|
||||
|
||||
inline.lexer = function(src) {
|
||||
var out = ''
|
||||
, links = tokens.links
|
||||
, link
|
||||
, text
|
||||
, href
|
||||
, cap;
|
||||
|
||||
while (src) {
|
||||
// escape
|
||||
if (cap = inline.escape.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += cap[1];
|
||||
continue;
|
||||
}
|
||||
|
||||
// autolink
|
||||
if (cap = inline.autolink.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
if (cap[2] === '@') {
|
||||
text = cap[1][6] === ':'
|
||||
? mangle(cap[1].substring(7))
|
||||
: mangle(cap[1]);
|
||||
href = mangle('mailto:') + text;
|
||||
} else {
|
||||
text = escape(cap[1]);
|
||||
href = text;
|
||||
}
|
||||
out += '<a href="'
|
||||
+ href
|
||||
+ '">'
|
||||
+ text
|
||||
+ '</a>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// url (gfm)
|
||||
if (cap = inline.url.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
text = escape(cap[1]);
|
||||
href = text;
|
||||
out += '<a href="'
|
||||
+ href
|
||||
+ '">'
|
||||
+ text
|
||||
+ '</a>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// tag
|
||||
if (cap = inline.tag.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += options.sanitize
|
||||
? escape(cap[0])
|
||||
: cap[0];
|
||||
continue;
|
||||
}
|
||||
|
||||
// link
|
||||
if (cap = inline.link.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += outputLink(cap, {
|
||||
href: cap[2],
|
||||
title: cap[3]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// reflink, nolink
|
||||
if ((cap = inline.reflink.exec(src))
|
||||
|| (cap = inline.nolink.exec(src))) {
|
||||
src = src.substring(cap[0].length);
|
||||
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
|
||||
link = links[link.toLowerCase()];
|
||||
if (!link || !link.href) {
|
||||
out += cap[0][0];
|
||||
src = cap[0].substring(1) + src;
|
||||
continue;
|
||||
}
|
||||
out += outputLink(cap, link);
|
||||
continue;
|
||||
}
|
||||
|
||||
// strong
|
||||
if (cap = inline.strong.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += '<strong>'
|
||||
+ inline.lexer(cap[2] || cap[1])
|
||||
+ '</strong>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// em
|
||||
if (cap = inline.em.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += '<em>'
|
||||
+ inline.lexer(cap[2] || cap[1])
|
||||
+ '</em>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// code
|
||||
if (cap = inline.code.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += '<code>'
|
||||
+ escape(cap[2], true)
|
||||
+ '</code>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// br
|
||||
if (cap = inline.br.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += '<br>';
|
||||
continue;
|
||||
}
|
||||
|
||||
// text
|
||||
if (cap = inline.text.exec(src)) {
|
||||
src = src.substring(cap[0].length);
|
||||
out += escape(cap[0]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
var outputLink = function(cap, link) {
|
||||
if (cap[0][0] !== '!') {
|
||||
return '<a href="'
|
||||
+ escape(link.href)
|
||||
+ '"'
|
||||
+ (link.title
|
||||
? ' title="'
|
||||
+ escape(link.title)
|
||||
+ '"'
|
||||
: '')
|
||||
+ '>'
|
||||
+ inline.lexer(cap[1])
|
||||
+ '</a>';
|
||||
} else {
|
||||
return '<img src="'
|
||||
+ escape(link.href)
|
||||
+ '" alt="'
|
||||
+ escape(cap[1])
|
||||
+ '"'
|
||||
+ (link.title
|
||||
? ' title="'
|
||||
+ escape(link.title)
|
||||
+ '"'
|
||||
: '')
|
||||
+ '>';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Parsing
|
||||
*/
|
||||
|
||||
var tokens
|
||||
, token;
|
||||
|
||||
var next = function() {
|
||||
return token = tokens.pop();
|
||||
};
|
||||
|
||||
var tok = function() {
|
||||
switch (token.type) {
|
||||
case 'space': {
|
||||
return '';
|
||||
}
|
||||
case 'hr': {
|
||||
return '<hr>\n';
|
||||
}
|
||||
case 'heading': {
|
||||
return '<h'
|
||||
+ token.depth
|
||||
+ '>'
|
||||
+ inline.lexer(token.text)
|
||||
+ '</h'
|
||||
+ token.depth
|
||||
+ '>\n';
|
||||
}
|
||||
case 'code': {
|
||||
return '<pre><code'
|
||||
+ (token.lang
|
||||
? ' class="'
|
||||
+ token.lang
|
||||
+ '"'
|
||||
: '')
|
||||
+ '>'
|
||||
+ (token.escaped
|
||||
? token.text
|
||||
: escape(token.text, true))
|
||||
+ '</code></pre>\n';
|
||||
}
|
||||
case 'blockquote_start': {
|
||||
var body = '';
|
||||
|
||||
while (next().type !== 'blockquote_end') {
|
||||
body += tok();
|
||||
}
|
||||
|
||||
return '<blockquote>\n'
|
||||
+ body
|
||||
+ '</blockquote>\n';
|
||||
}
|
||||
case 'list_start': {
|
||||
var type = token.ordered ? 'ol' : 'ul'
|
||||
, body = '';
|
||||
|
||||
while (next().type !== 'list_end') {
|
||||
body += tok();
|
||||
}
|
||||
|
||||
return '<'
|
||||
+ type
|
||||
+ '>\n'
|
||||
+ body
|
||||
+ '</'
|
||||
+ type
|
||||
+ '>\n';
|
||||
}
|
||||
case 'list_item_start': {
|
||||
var body = '';
|
||||
|
||||
while (next().type !== 'list_item_end') {
|
||||
body += token.type === 'text'
|
||||
? parseText()
|
||||
: tok();
|
||||
}
|
||||
|
||||
return '<li>'
|
||||
+ body
|
||||
+ '</li>\n';
|
||||
}
|
||||
case 'loose_item_start': {
|
||||
var body = '';
|
||||
|
||||
while (next().type !== 'list_item_end') {
|
||||
body += tok();
|
||||
}
|
||||
|
||||
return '<li>'
|
||||
+ body
|
||||
+ '</li>\n';
|
||||
}
|
||||
case 'html': {
|
||||
if (options.sanitize) {
|
||||
return inline.lexer(token.text);
|
||||
}
|
||||
return !token.pre && !options.pedantic
|
||||
? inline.lexer(token.text)
|
||||
: token.text;
|
||||
}
|
||||
case 'paragraph': {
|
||||
return '<p>'
|
||||
+ inline.lexer(token.text)
|
||||
+ '</p>\n';
|
||||
}
|
||||
case 'text': {
|
||||
return '<p>'
|
||||
+ parseText()
|
||||
+ '</p>\n';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var parseText = function() {
|
||||
var body = token.text
|
||||
, top;
|
||||
|
||||
while ((top = tokens[tokens.length-1])
|
||||
&& top.type === 'text') {
|
||||
body += '\n' + next().text;
|
||||
}
|
||||
|
||||
return inline.lexer(body);
|
||||
};
|
||||
|
||||
var parse = function(src) {
|
||||
tokens = src.reverse();
|
||||
|
||||
var out = '';
|
||||
while (next()) {
|
||||
out += tok();
|
||||
}
|
||||
|
||||
tokens = null;
|
||||
token = null;
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
var escape = function(html, encode) {
|
||||
return html
|
||||
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
};
|
||||
|
||||
var mangle = function(text) {
|
||||
var out = ''
|
||||
, l = text.length
|
||||
, i = 0
|
||||
, ch;
|
||||
|
||||
for (; i < l; i++) {
|
||||
ch = text.charCodeAt(i);
|
||||
if (Math.random() > 0.5) {
|
||||
ch = 'x' + ch.toString(16);
|
||||
}
|
||||
out += '&#' + ch + ';';
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
function tag() {
|
||||
var tag = '(?!(?:'
|
||||
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
||||
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
||||
+ '|span|br|wbr|ins|del|img)\\b)\\w+';
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
function replace(regex) {
|
||||
regex = regex.source;
|
||||
return function self(name, val) {
|
||||
if (!name) return new RegExp(regex);
|
||||
regex = regex.replace(name, val.source || val);
|
||||
return self;
|
||||
};
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
noop.exec = noop;
|
||||
|
||||
/**
|
||||
* Marked
|
||||
*/
|
||||
|
||||
var marked = function(src, opt) {
|
||||
setOptions(opt);
|
||||
return parse(block.lexer(src));
|
||||
};
|
||||
|
||||
/**
|
||||
* Options
|
||||
*/
|
||||
|
||||
var options
|
||||
, defaults;
|
||||
|
||||
var setOptions = function(opt) {
|
||||
if (!opt) opt = defaults;
|
||||
if (options === opt) return;
|
||||
options = opt;
|
||||
|
||||
if (options.gfm) {
|
||||
block.fences = block.gfm.fences;
|
||||
block.paragraph = block.gfm.paragraph;
|
||||
inline.text = inline.gfm.text;
|
||||
inline.url = inline.gfm.url;
|
||||
} else {
|
||||
block.fences = block.normal.fences;
|
||||
block.paragraph = block.normal.paragraph;
|
||||
inline.text = inline.normal.text;
|
||||
inline.url = inline.normal.url;
|
||||
}
|
||||
|
||||
if (options.pedantic) {
|
||||
inline.em = inline.pedantic.em;
|
||||
inline.strong = inline.pedantic.strong;
|
||||
} else {
|
||||
inline.em = inline.normal.em;
|
||||
inline.strong = inline.normal.strong;
|
||||
}
|
||||
};
|
||||
|
||||
marked.options =
|
||||
marked.setOptions = function(opt) {
|
||||
defaults = opt;
|
||||
setOptions(opt);
|
||||
};
|
||||
|
||||
marked.options({
|
||||
gfm: true,
|
||||
pedantic: false,
|
||||
sanitize: false
|
||||
});
|
||||
|
||||
/**
|
||||
* Expose
|
||||
*/
|
||||
|
||||
marked.parser = function(src, opt) {
|
||||
setOptions(opt);
|
||||
return parse(src);
|
||||
};
|
||||
|
||||
marked.lexer = function(src, opt) {
|
||||
setOptions(opt);
|
||||
return block.lexer(src);
|
||||
};
|
||||
|
||||
marked.parse = marked;
|
||||
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = marked;
|
||||
} else {
|
||||
this.marked = marked;
|
||||
}
|
||||
|
||||
}).call(this);
|
||||
4
javascripts/libs/modernizr-2.0.6.min.js
vendored
Executable file
4
javascripts/libs/modernizr-2.0.6.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
278
javascripts/releasenotes.js
Normal file
278
javascripts/releasenotes.js
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright, Cedric Dugas,
|
||||
* Do not sell or redistribute
|
||||
*/
|
||||
|
||||
|
||||
(function($)
|
||||
{
|
||||
// mardown parser options, do not touch
|
||||
marked.setOptions({
|
||||
gfm: true,
|
||||
pedantic: false,
|
||||
sanitize: true
|
||||
});
|
||||
|
||||
// Default setting
|
||||
var defaultSettings = {
|
||||
milestonesShown : 10,
|
||||
// If you want to show private repo
|
||||
// You need to add repo credentials in api.php
|
||||
phpApi : false,
|
||||
phpApiPath : '/',
|
||||
showDescription : true,
|
||||
showComments : true,
|
||||
// Used if phpApi is set to false
|
||||
repo : 'rails',
|
||||
username : 'rails'
|
||||
};
|
||||
|
||||
$.fn.releaseNotes = function(settings){
|
||||
settings = $.extend({}, defaultSettings, settings || {});
|
||||
var apiPath = settings.phpApiPath+"api.php";
|
||||
var respType = (settings.phpApi) ? "json" : "jsonp";
|
||||
|
||||
var releases = {
|
||||
load: function(el){
|
||||
var _this = this;
|
||||
this.$el = $(el);
|
||||
this.loadEvents();
|
||||
|
||||
var options = $.extend(settings, {
|
||||
state: "closed",
|
||||
action: "milestones",
|
||||
sort:"due_date"
|
||||
});
|
||||
|
||||
this.callApi(options).success(function(resp){
|
||||
if(resp.data) resp= resp.data;
|
||||
_this.showMilestones(resp);
|
||||
}).error(function(resp){
|
||||
console.log(resp)
|
||||
});
|
||||
},
|
||||
loadEvents : function(){
|
||||
var _this = this;
|
||||
if(settings.showDescription) this.$el.delegate(".issue", "click", function(){ _this.loadIssueDesc(this); return false;});
|
||||
if(settings.showComments) this.$el.delegate(".btnComments", "click", function(){ _this.loadComments(this); return false;});
|
||||
},
|
||||
loadIssueDesc : function(el){
|
||||
var $issue = $(el);
|
||||
var data = $issue.data("issue");
|
||||
$bigIssue = $issue.find(".issueBig");
|
||||
|
||||
if(!$bigIssue.is(":visible")){
|
||||
$(".issueBig").not($bigIssue).slideUp();
|
||||
$bigIssue.find(".container").html(components.bigIssue(data, settings.showComments));
|
||||
$bigIssue.slideDown();
|
||||
}else{
|
||||
$bigIssue.slideUp();
|
||||
}
|
||||
},
|
||||
showMilestones : function(milestones){
|
||||
var _this = this;
|
||||
milestones.sort(this.sortDate);
|
||||
$.each(milestones, function(i, milestone){
|
||||
if(i == settings.milestonesShown) return false;
|
||||
milestone.prettyDate = (milestone.due_on) ? _this.getPrettyDate(milestone.due_on) : _this.getPrettyDate(milestone.created_at);
|
||||
_this.$el.append(components.milestone(milestone));
|
||||
var options = $.extend(settings, {
|
||||
milestone: milestone.number,
|
||||
sort:"created",
|
||||
action:"issues",
|
||||
state:"closed"
|
||||
});
|
||||
_this.callApi(options).success(function(resp, textStatus, jqXHR){
|
||||
if(resp.data) resp= resp.data;
|
||||
_this.showIssues(resp);
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
loadComments : function(el){
|
||||
|
||||
var _this =this;
|
||||
var issueid =$(el).attr("data-issue-id");
|
||||
$(el).fadeOut().slideUp();
|
||||
|
||||
var options = $.extend(settings, {
|
||||
issueid:issueid,
|
||||
action:"comments"
|
||||
});
|
||||
|
||||
this.callApi(options).success(function(resp, textStatus, jqXHR){
|
||||
if(resp.data) resp= resp.data;
|
||||
_this.showComments(resp, issueid);
|
||||
});
|
||||
},
|
||||
showComments : function(comments,issueid){
|
||||
var _this = this;
|
||||
|
||||
var $commentContainer = _this.$el.find("#issue"+issueid).find(".comments").empty();
|
||||
$.each(comments, function(i, comment){
|
||||
comment.prettyDate = _this.getPrettyDate(comment.created_at);
|
||||
$commentContainer.append(components.comment(comment, issueid));
|
||||
});
|
||||
$commentContainer.slideDown();
|
||||
},
|
||||
showIssues : function(issues){
|
||||
var _this = this;
|
||||
var jqMilestone = _this.$el.find("[data-id-milestone="+issues[0].milestone.number+"]");
|
||||
var jqMilestoneIssues = jqMilestone.find(".issues");
|
||||
issues.sort(this.sortLabel);
|
||||
$.each(issues, function(i, issue){
|
||||
issue.prettyDate = _this.getPrettyDate(issue.closed_at);
|
||||
jqMilestoneIssues.append(components.issue(issue));
|
||||
});
|
||||
jqMilestone.addClass("separator");
|
||||
if(settings.showDescription) jqMilestone.find(".issue").addClass("cursor");
|
||||
},
|
||||
getPrettyDate : function(date){
|
||||
var dateFormat = "";
|
||||
var date = date.split("T");
|
||||
var dateArray = date[0].split("-");
|
||||
var dateObj = new Date(dateArray[0],(dateArray[1]-1),dateArray[2]);
|
||||
|
||||
var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday");
|
||||
var monthname=new Array("January","February","March","April","May","June","July","August", "September","October","November","December");
|
||||
dateFormat += weekday[dateObj.getDay()] + ", ";
|
||||
dateFormat += monthname[dateObj.getMonth()] + " ";
|
||||
dateFormat += dateObj.getDate() + ", ";
|
||||
dateFormat += dateObj.getFullYear();
|
||||
return dateFormat;
|
||||
},
|
||||
sortDate : function (milestone1, milestone2) {
|
||||
|
||||
milestone1.dateTest = (milestone1.due_on) ? milestone1.due_on : milestone1.created_at;
|
||||
milestone2.dateTest = (milestone2.due_on) ? milestone2.due_on : milestone2.created_at;
|
||||
|
||||
var date1 = new Date(milestone1.dateTest );
|
||||
var date2 = new Date(milestone2.dateTest );
|
||||
|
||||
if (date1 < date2) return 1;
|
||||
if (date1 > date2) return -1;
|
||||
return 0;
|
||||
},
|
||||
sortLabel :function(thisObject,thatObject) {
|
||||
if(!thisObject.labels.length) return 1;
|
||||
if(!thatObject.labels.length) return -1;
|
||||
if (thisObject.labels[0].name > thatObject.labels[0].name){
|
||||
return 1;
|
||||
}
|
||||
else if (thisObject.labels[0].name < thatObject.labels[0].name){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
callApi: function(options){
|
||||
var myoption = $.extend({}, options);
|
||||
if(myoption.repo) delete myoption.repo;
|
||||
return $.ajax({
|
||||
url:this.urls[options.action](options),
|
||||
dataType:respType,
|
||||
data:myoption
|
||||
});
|
||||
},
|
||||
urls : {
|
||||
domainName : "https://api.github.com",
|
||||
milestones : function(){
|
||||
if(!settings.phpApi){
|
||||
return $url = this.domainName+ "/repos/"+settings.username +"/"+ settings.repo +"/milestones";
|
||||
}else{
|
||||
return apiPath;
|
||||
};
|
||||
},
|
||||
issues : function(){
|
||||
if(!settings.phpApi){
|
||||
return $url = this.domainName+"/repos/"+ settings.username +"/"+ settings.repo +"/issues";
|
||||
}else{
|
||||
return apiPath;
|
||||
};
|
||||
},
|
||||
comments : function(options){
|
||||
if(!settings.phpApi){
|
||||
return $url = this.domainName+"/repos/"+ settings.username +"/"+ settings.repo+"/issues/"+ options.issueid +"/comments";
|
||||
}else{
|
||||
return apiPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this.each(function(){
|
||||
releases.load(this, settings);
|
||||
});
|
||||
};
|
||||
var components = {
|
||||
milestone : function(data){
|
||||
return $('<div data-id-milestone="'+data.number+'" class="milestoneContainer"> \
|
||||
<h3 class="release">'+data.title+'</h3>\
|
||||
<p class="dateRelease">Release Date: '+data.prettyDate+'</p>\
|
||||
<div class="issues"></div>\
|
||||
</div>').data("milestone", data);
|
||||
},
|
||||
issue : function(data){
|
||||
var labels = "",
|
||||
_this = this;
|
||||
|
||||
$.each(data.labels, function(i, label){ labels += _this.label(label); });
|
||||
return $('<div id="issue'+data.number+'" class="issue" >\
|
||||
<div class="issueSmall">\
|
||||
<div class="issueTitle">'+labels+' '+$("<span>").html(data.title).text()+' </div>\
|
||||
</div>\
|
||||
<div style="display:none;" class="issueBig">\
|
||||
<div class="container"></div>\
|
||||
<div style="display:none;" class="comments"></div>\
|
||||
</div>').data("issue", data);
|
||||
},
|
||||
label : function(data){
|
||||
return '<span style="background-color:#'+data.color+';" class="label">'+data.name+'</span>';
|
||||
},
|
||||
bigIssue : function(data, showComment){
|
||||
var commentLink = (data.comments != 0 && showComment) ? '<a data-issue-id="'+data.number+'" href="#" class="btnComments btn">See Comments</a>' : "";
|
||||
|
||||
return $('<div class="avatar-bubble js-comment-container">\
|
||||
<span class="avatar"><img height="48" src="'+data.user.avatar_url+'" width="48"></span>\
|
||||
<div class="bubble">\
|
||||
<div class="comment starting-comment adminable" id="issue-3542089">\
|
||||
<div class="body">\
|
||||
<p class="author">Opened by <a href="'+data.user.url+'">'+data.user.login+'</a>, issue closed on '+data.prettyDate+'</p>\
|
||||
<h2 class="content-title"> '+$("<span>").html(data.title).text()+'</h2>\
|
||||
<div class="formatted-content"> \
|
||||
<div class="content-body markdown-body markdown-format">\
|
||||
'+marked(data.body)+'\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>'+commentLink).data("issue", data);
|
||||
},
|
||||
comment : function(data){
|
||||
return '<div class="avatar-bubble js-comment-container">\
|
||||
<span class="avatar"><img height="48" src="'+data.user.avatar_url+'" width="48"></span>\
|
||||
<div class="bubble">\
|
||||
<div id="issuecomment-4369977" class="comment normal-comment adminable">\
|
||||
<div class="cmeta">\
|
||||
<p class="author">\
|
||||
<span class="icon"></span>\
|
||||
<strong class="author"><a href="'+data.user.url+'">'+data.user.login+'</a></strong>\
|
||||
<em class="action-text">\
|
||||
commented\
|
||||
</em>\
|
||||
</p>\
|
||||
<p class="info">\
|
||||
<em class="date"><time class="js-relative-date">'+data.prettyDate+'</time></em>\
|
||||
</p>\
|
||||
</div>\
|
||||
<div class="body">\
|
||||
<div class="formatted-content">\
|
||||
<div class="content-body markdown-body markdown-format">'+marked(data.body)+'</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
})(jQuery);
|
||||
20
javascripts/scale.fix.js
Normal file
20
javascripts/scale.fix.js
Normal file
@@ -0,0 +1,20 @@
|
||||
fixScale = function(doc) {
|
||||
|
||||
var addEvent = 'addEventListener',
|
||||
type = 'gesturestart',
|
||||
qsa = 'querySelectorAll',
|
||||
scales = [1, 1],
|
||||
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
|
||||
|
||||
function fix() {
|
||||
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
|
||||
doc.removeEventListener(type, fix, true);
|
||||
}
|
||||
|
||||
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
|
||||
fix();
|
||||
scales = [.25, 1.6];
|
||||
doc[addEvent](type, fix, true);
|
||||
}
|
||||
|
||||
};
|
||||
99
javascripts/script.js
Normal file
99
javascripts/script.js
Normal file
@@ -0,0 +1,99 @@
|
||||
(function($) {
|
||||
$(document).ready(function(){
|
||||
|
||||
// putting lines by the pre blocks
|
||||
$("pre").each(function(){
|
||||
var pre = $(this).text().split("\n");
|
||||
var lines = new Array(pre.length+1);
|
||||
for(var i = 0; i < pre.length; i++) {
|
||||
var wrap = Math.floor(pre[i].split("").length / 70)
|
||||
if (pre[i]==""&&i==pre.length-1) {
|
||||
lines.splice(i, 1);
|
||||
} else {
|
||||
lines[i] = i+1;
|
||||
for(var j = 0; j < wrap; j++) {
|
||||
lines[i] += "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$(this).before("<pre class='lines'>" + lines.join("\n") + "</pre>");
|
||||
});
|
||||
|
||||
var headings = [];
|
||||
|
||||
var collectHeaders = function(){
|
||||
headings.push({"top":$(this).offset().top - 15,"text":$(this).text()});
|
||||
}
|
||||
|
||||
if($(".markdown-body h1").length > 1) $(".markdown-body h1").each(collectHeaders)
|
||||
else if($(".markdown-body h2").length > 1) $(".markdown-body h2").each(collectHeaders)
|
||||
else if($(".markdown-body h3").length > 1) $(".markdown-body h3").each(collectHeaders)
|
||||
|
||||
$(window).scroll(function(){
|
||||
if(headings.length==0) return true;
|
||||
var scrolltop = $(window).scrollTop() || 0;
|
||||
if(headings[0] && scrolltop < headings[0].top) {
|
||||
$(".current-section").css({"opacity":0,"visibility":"hidden"});
|
||||
return false;
|
||||
}
|
||||
$(".current-section").css({"opacity":1,"visibility":"visible"});
|
||||
for(var i in headings) {
|
||||
if(scrolltop >= headings[i].top) {
|
||||
$(".current-section .name").text(headings[i].text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".current-section a").click(function(){
|
||||
$(window).scrollTop(0);
|
||||
return false;
|
||||
})
|
||||
});
|
||||
}
|
||||
var defaultSettings = {
|
||||
milestoneNumber : 10,
|
||||
usePHPapi : true,
|
||||
apiPath : '/',
|
||||
repo : 'rails',
|
||||
username : 'rails'
|
||||
};
|
||||
$.fn.releaseNotes = function(settings){
|
||||
settings = $.extend({}, defaultSettings, settings || {});
|
||||
var apiPath = apiPath."api.php";
|
||||
var respType = (settings.usePHPapi) ? "jsonp" : "json"
|
||||
|
||||
return this.each(function(){
|
||||
releases.load(this, settings);
|
||||
});
|
||||
|
||||
var releases = {
|
||||
|
||||
load: function(){
|
||||
this.callApi({
|
||||
action:"milestones"
|
||||
}).success(function(resp){
|
||||
console.log(resp)
|
||||
})
|
||||
},
|
||||
callApi: function(action){
|
||||
|
||||
return $.ajax({
|
||||
url:this.urls[action](),
|
||||
dataType:respType,
|
||||
data:settings
|
||||
})
|
||||
},
|
||||
urls : {
|
||||
milestones : function(){
|
||||
if(settings.usePHPapi){
|
||||
return $url = "/repos/". $configs["username"] ."/". $configs["repo"] ."/milestones";
|
||||
}else{
|
||||
return apiPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
)(jQuery)
|
||||
Reference in New Issue
Block a user