read-only-gollum 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/HISTORY.md +102 -0
- data/Home.md +3 -0
- data/LICENSE +21 -0
- data/README.md +477 -0
- data/Rakefile +142 -0
- data/bin/read-only-gollum +126 -0
- data/docs/sanitization.md +32 -0
- data/lib/gollum.rb +41 -0
- data/lib/gollum/blob_entry.rb +78 -0
- data/lib/gollum/committer.rb +218 -0
- data/lib/gollum/file.rb +64 -0
- data/lib/gollum/frontend/app.rb +225 -0
- data/lib/gollum/frontend/public/css/dialog.css +141 -0
- data/lib/gollum/frontend/public/css/editor.css +537 -0
- data/lib/gollum/frontend/public/css/gollum.css +660 -0
- data/lib/gollum/frontend/public/css/ie7.css +69 -0
- data/lib/gollum/frontend/public/css/template.css +381 -0
- data/lib/gollum/frontend/public/images/icon-sprite.png +0 -0
- data/lib/gollum/frontend/public/javascript/editor/gollum.editor.js +1096 -0
- data/lib/gollum/frontend/public/javascript/editor/langs/asciidoc.js +167 -0
- data/lib/gollum/frontend/public/javascript/editor/langs/creole.js +104 -0
- data/lib/gollum/frontend/public/javascript/editor/langs/markdown.js +211 -0
- data/lib/gollum/frontend/public/javascript/editor/langs/org.js +173 -0
- data/lib/gollum/frontend/public/javascript/editor/langs/pod.js +111 -0
- data/lib/gollum/frontend/public/javascript/editor/langs/rdoc.js +74 -0
- data/lib/gollum/frontend/public/javascript/editor/langs/textile.js +175 -0
- data/lib/gollum/frontend/public/javascript/gollum.dialog.js +263 -0
- data/lib/gollum/frontend/public/javascript/gollum.js +161 -0
- data/lib/gollum/frontend/public/javascript/gollum.placeholder.js +54 -0
- data/lib/gollum/frontend/public/javascript/jquery.color.js +123 -0
- data/lib/gollum/frontend/public/javascript/jquery.js +7179 -0
- data/lib/gollum/frontend/templates/compare.mustache +38 -0
- data/lib/gollum/frontend/templates/create.mustache +17 -0
- data/lib/gollum/frontend/templates/edit.mustache +17 -0
- data/lib/gollum/frontend/templates/editor.mustache +116 -0
- data/lib/gollum/frontend/templates/error.mustache +8 -0
- data/lib/gollum/frontend/templates/history.mustache +58 -0
- data/lib/gollum/frontend/templates/layout.mustache +28 -0
- data/lib/gollum/frontend/templates/page.mustache +37 -0
- data/lib/gollum/frontend/templates/pages.mustache +35 -0
- data/lib/gollum/frontend/templates/search.mustache +36 -0
- data/lib/gollum/frontend/templates/searchbar.mustache +10 -0
- data/lib/gollum/frontend/views/compare.rb +94 -0
- data/lib/gollum/frontend/views/create.rb +48 -0
- data/lib/gollum/frontend/views/edit.rb +52 -0
- data/lib/gollum/frontend/views/editable.rb +13 -0
- data/lib/gollum/frontend/views/error.rb +7 -0
- data/lib/gollum/frontend/views/history.rb +44 -0
- data/lib/gollum/frontend/views/layout.rb +20 -0
- data/lib/gollum/frontend/views/page.rb +57 -0
- data/lib/gollum/frontend/views/pages.rb +19 -0
- data/lib/gollum/frontend/views/search.rb +20 -0
- data/lib/gollum/git_access.rb +248 -0
- data/lib/gollum/markup.rb +489 -0
- data/lib/gollum/page.rb +430 -0
- data/lib/gollum/pagination.rb +61 -0
- data/lib/gollum/sanitization.rb +174 -0
- data/lib/gollum/tex.rb +89 -0
- data/lib/gollum/web_sequence_diagram.rb +43 -0
- data/lib/gollum/wiki.rb +636 -0
- data/read-only-gollum.gemspec +224 -0
- data/templates/formatting.html +92 -0
- data/test/examples/empty.git/HEAD +1 -0
- data/test/examples/empty.git/config +5 -0
- data/test/examples/empty.git/description +1 -0
- data/test/examples/empty.git/hooks/applypatch-msg.sample +15 -0
- data/test/examples/empty.git/hooks/commit-msg.sample +24 -0
- data/test/examples/empty.git/hooks/post-commit.sample +8 -0
- data/test/examples/empty.git/hooks/post-receive.sample +15 -0
- data/test/examples/empty.git/hooks/post-update.sample +8 -0
- data/test/examples/empty.git/hooks/pre-applypatch.sample +14 -0
- data/test/examples/empty.git/hooks/pre-commit.sample +46 -0
- data/test/examples/empty.git/hooks/pre-rebase.sample +169 -0
- data/test/examples/empty.git/hooks/prepare-commit-msg.sample +36 -0
- data/test/examples/empty.git/hooks/update.sample +128 -0
- data/test/examples/empty.git/info/exclude +6 -0
- data/test/examples/empty.git/objects/info/.gitkeep +0 -0
- data/test/examples/empty.git/objects/pack/.gitkeep +0 -0
- data/test/examples/empty.git/refs/heads/.gitkeep +0 -0
- data/test/examples/lotr.git/COMMIT_EDITMSG +1 -0
- data/test/examples/lotr.git/HEAD +1 -0
- data/test/examples/lotr.git/ORIG_HEAD +1 -0
- data/test/examples/lotr.git/config +12 -0
- data/test/examples/lotr.git/description +1 -0
- data/test/examples/lotr.git/index +0 -0
- data/test/examples/lotr.git/info/exclude +6 -0
- data/test/examples/lotr.git/logs/HEAD +3 -0
- data/test/examples/lotr.git/logs/refs/heads/master +3 -0
- data/test/examples/lotr.git/objects/06/131480411710c92a82fe2d1e76932c70feb2e5 +0 -0
- data/test/examples/lotr.git/objects/0a/de1e2916346d4c1f2fb63b863fd3c16808fe44 +0 -0
- data/test/examples/lotr.git/objects/0e/d8cbe0a25235bd867e65193c7d837c66b328ef +3 -0
- data/test/examples/lotr.git/objects/12/629d666c5e3178f82f533f543d61b53dc78c0b +0 -0
- data/test/examples/lotr.git/objects/1d/b89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 +2 -0
- data/test/examples/lotr.git/objects/24/49c2681badfd3c189e8ed658dacffe8ba48fe5 +0 -0
- data/test/examples/lotr.git/objects/25/4bdc1ba27d8b8a794538a8522d9a2b56ec2dd9 +0 -0
- data/test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad +4 -0
- data/test/examples/lotr.git/objects/5d/cac289a8603188d2c5caf481dcba2985126aaa +0 -0
- data/test/examples/lotr.git/objects/60/f12f4254f58801b9ee7db7bca5fa8aeefaa56b +0 -0
- data/test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f +0 -0
- data/test/examples/lotr.git/objects/84/0ec5b1ba1320e8ec443f28f99566f615d5af10 +0 -0
- data/test/examples/lotr.git/objects/93/6b83ee0dd8837adb82511e40d5e4ebe59bb675 +0 -0
- data/test/examples/lotr.git/objects/94/523d7ae48aeba575099dd12926420d8fd0425d +2 -0
- data/test/examples/lotr.git/objects/96/97dc65e095658bbd1b8e8678e08881e86d32f1 +0 -0
- data/test/examples/lotr.git/objects/a3/1ca2a7c352c92531a8b99815d15843b259e814 +0 -0
- data/test/examples/lotr.git/objects/a6/59b3763b822dd97544621fd0beef162ea37b14 +4 -0
- data/test/examples/lotr.git/objects/a8/ad3c09dd842a3517085bfadd37718856dee813 +0 -0
- data/test/examples/lotr.git/objects/aa/b61fe89d56f8614c0a8151da34f939dcedfa68 +0 -0
- data/test/examples/lotr.git/objects/bc/4b5fc0ce2c2ba3acef6647e4f67256ee45ab60 +0 -0
- data/test/examples/lotr.git/objects/c3/b43e9f08966b088e7a0192e436b7a884542e05 +0 -0
- data/test/examples/lotr.git/objects/dc/596d6b2dd89ab05c66f4abd7d5eb706bc17f19 +0 -0
- data/test/examples/lotr.git/objects/ec/da3205bee14520aab5a7bb307392064b938e83 +0 -0
- data/test/examples/lotr.git/objects/f4/84ebb1f40f8eb20d1bcd8d1d71934d2b8ae961 +0 -0
- data/test/examples/lotr.git/objects/fa/e7ef5344202bba4129abdc13060d9297d99465 +3 -0
- data/test/examples/lotr.git/objects/info/packs +2 -0
- data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.idx +0 -0
- data/test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack +0 -0
- data/test/examples/lotr.git/packed-refs +2 -0
- data/test/examples/lotr.git/refs/heads/master +1 -0
- data/test/examples/lotr.git/refs/remotes/origin/HEAD +1 -0
- data/test/examples/page_file_dir.git/COMMIT_EDITMSG +1 -0
- data/test/examples/page_file_dir.git/HEAD +1 -0
- data/test/examples/page_file_dir.git/config +6 -0
- data/test/examples/page_file_dir.git/description +1 -0
- data/test/examples/page_file_dir.git/index +0 -0
- data/test/examples/page_file_dir.git/info/exclude +6 -0
- data/test/examples/page_file_dir.git/logs/HEAD +1 -0
- data/test/examples/page_file_dir.git/logs/refs/heads/master +1 -0
- data/test/examples/page_file_dir.git/objects/0c/7d27db1f575263efdcab3dc650f4502a2dbcbf +0 -0
- data/test/examples/page_file_dir.git/objects/22/b404803c966dd92865614d86ff22ca12e50c1e +0 -0
- data/test/examples/page_file_dir.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99 +0 -0
- data/test/examples/page_file_dir.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6 +0 -0
- data/test/examples/page_file_dir.git/objects/5b/43e14e0a15fb6f08feab1773d1c0991e9f71e2 +0 -0
- data/test/examples/page_file_dir.git/refs/heads/master +1 -0
- data/test/examples/revert.git/COMMIT_EDITMSG +1 -0
- data/test/examples/revert.git/HEAD +1 -0
- data/test/examples/revert.git/config +12 -0
- data/test/examples/revert.git/description +1 -0
- data/test/examples/revert.git/index +0 -0
- data/test/examples/revert.git/info/exclude +6 -0
- data/test/examples/revert.git/logs/HEAD +2 -0
- data/test/examples/revert.git/logs/refs/heads/master +2 -0
- data/test/examples/revert.git/objects/20/2ced67cea93c7b6bd2928aa1daef8d1d55a20d +0 -0
- data/test/examples/revert.git/objects/41/76394bfa11222363c66ce7e84b5f154095b6d9 +0 -0
- data/test/examples/revert.git/objects/6a/69f92020f5df77af6e8813ff1232493383b708 +0 -0
- data/test/examples/revert.git/objects/b4/785957bc986dc39c629de9fac9df46972c00fc +0 -0
- data/test/examples/revert.git/objects/f4/03b791119f8232b7cb0ba455c624ac6435f433 +0 -0
- data/test/examples/revert.git/objects/info/packs +2 -0
- data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.idx +0 -0
- data/test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack +0 -0
- data/test/examples/revert.git/packed-refs +2 -0
- data/test/examples/revert.git/refs/heads/master +1 -0
- data/test/examples/revert.git/refs/remotes/origin/HEAD +1 -0
- data/test/examples/yubiwa.git/HEAD +1 -0
- data/test/examples/yubiwa.git/config +5 -0
- data/test/examples/yubiwa.git/description +1 -0
- data/test/examples/yubiwa.git/info/exclude +6 -0
- data/test/examples/yubiwa.git/objects/10/fa2ddc4e3b4009d8a453aace10bd6148c1ad00 +0 -0
- data/test/examples/yubiwa.git/objects/52/4b82874327ea7cbf730389964ba7cb3de966de +0 -0
- data/test/examples/yubiwa.git/objects/58/3fc201cb457fb3f1480f3e1e5999b119633835 +0 -0
- data/test/examples/yubiwa.git/objects/87/bc1dd46ab3d3874d4e898d45dd512cc20a7cc8 +1 -0
- data/test/examples/yubiwa.git/objects/89/64ed1b4e21aa90e831763bbce9034bfda81b70 +0 -0
- data/test/examples/yubiwa.git/objects/9f/f6dd0660da5fba2d3374adb2b84fa653bb538b +0 -0
- data/test/examples/yubiwa.git/objects/ac/e97abf2b177815a1972d7db22f229f58c83309 +0 -0
- data/test/examples/yubiwa.git/objects/b1/f443863a4816628807fbf86141ebef055dda34 +0 -0
- data/test/examples/yubiwa.git/refs/heads/master +1 -0
- data/test/helper.rb +66 -0
- data/test/test_app.rb +169 -0
- data/test/test_committer.rb +64 -0
- data/test/test_file.rb +27 -0
- data/test/test_git_access.rb +52 -0
- data/test/test_markup.rb +628 -0
- data/test/test_page.rb +166 -0
- data/test/test_page_revert.rb +45 -0
- data/test/test_wiki.rb +462 -0
- metadata +470 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
/**
|
2
|
+
* ASCIIDoc Language Definition
|
3
|
+
*
|
4
|
+
*/
|
5
|
+
|
6
|
+
(function($) {
|
7
|
+
|
8
|
+
var ASCIIDoc = {
|
9
|
+
|
10
|
+
'function-bold' : {
|
11
|
+
search: /(^[\n]+)([\n\s]*)/g,
|
12
|
+
replace: "*$1*$2"
|
13
|
+
},
|
14
|
+
|
15
|
+
'function-italic' : {
|
16
|
+
search: /(^[\n]+)([\n\s]*)/g,
|
17
|
+
replace: "_$1_$2"
|
18
|
+
},
|
19
|
+
|
20
|
+
'function-code' : {
|
21
|
+
search: /(^[\n]+)([\n\s]*)/g,
|
22
|
+
replace: "+$1+$2"
|
23
|
+
},
|
24
|
+
|
25
|
+
'function-ul' : {
|
26
|
+
search: /(^[\n]+)([\n\s]*)/g,
|
27
|
+
replace: "* $1$2"
|
28
|
+
},
|
29
|
+
|
30
|
+
'function-ol' : {
|
31
|
+
search: /(.+)([\n]?)/g,
|
32
|
+
replace: ". $1$2"
|
33
|
+
},
|
34
|
+
|
35
|
+
'function-blockquote' : {
|
36
|
+
search: /(.+)([\n]?)/g,
|
37
|
+
replace: "----\n$1$2\n----\n"
|
38
|
+
},
|
39
|
+
|
40
|
+
'function-link' : {
|
41
|
+
exec: function( txt, selText, $field ) {
|
42
|
+
var results = null;
|
43
|
+
$.GollumEditor.Dialog.init({
|
44
|
+
title: 'Insert Link',
|
45
|
+
fields: [
|
46
|
+
{
|
47
|
+
id: 'text',
|
48
|
+
name: 'Link Text',
|
49
|
+
type: 'text',
|
50
|
+
help: 'The text to display to the user.'
|
51
|
+
},
|
52
|
+
{
|
53
|
+
id: 'href',
|
54
|
+
name: 'URL',
|
55
|
+
type: 'text',
|
56
|
+
help: 'The URL to link to.'
|
57
|
+
}
|
58
|
+
],
|
59
|
+
OK: function( res ) {
|
60
|
+
var h = '';
|
61
|
+
if ( res['text'] && res['href'] ) {
|
62
|
+
h = res['href'] + '[' +
|
63
|
+
res['text'] + ']';
|
64
|
+
}
|
65
|
+
$.GollumEditor.replaceSelection( h );
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
|
70
|
+
}
|
71
|
+
},
|
72
|
+
|
73
|
+
'function-image' : {
|
74
|
+
exec: function( txt, selText, $field ) {
|
75
|
+
var results = null;
|
76
|
+
$.GollumEditor.Dialog.init({
|
77
|
+
title: 'Insert Image',
|
78
|
+
fields: [
|
79
|
+
{
|
80
|
+
id: 'url',
|
81
|
+
name: 'Image URL',
|
82
|
+
type: 'text'
|
83
|
+
},
|
84
|
+
{
|
85
|
+
id: 'alt',
|
86
|
+
name: 'Alt Text',
|
87
|
+
type: 'text'
|
88
|
+
}
|
89
|
+
],
|
90
|
+
OK: function( res ) {
|
91
|
+
var h = '';
|
92
|
+
if ( res['url'] && res['alt'] ) {
|
93
|
+
h = 'image::' + res['url'] +
|
94
|
+
'[' + res['alt'] + ']';
|
95
|
+
}
|
96
|
+
$.GollumEditor.replaceSelection( h );
|
97
|
+
}
|
98
|
+
});
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
};
|
103
|
+
|
104
|
+
$.GollumEditor.defineLanguage('asciidoc', ASCIIDoc);
|
105
|
+
|
106
|
+
|
107
|
+
var ASCIIDocHelp = [
|
108
|
+
{
|
109
|
+
menuName: 'Text Formatting',
|
110
|
+
content: [
|
111
|
+
{
|
112
|
+
menuName: 'Headers',
|
113
|
+
data: '<p>ASCIIDoc headers can be written in two ways: with differing underlines or with different indentation using <code>=</code> (equals sign). ASCIIDoc supports headings 1-4. The editor will automatically use the <code>=</code> notation. To create a level one header, prefix your line with one <code>=</code>. Level two headers are created with <code>==</code> and so on.</p>'
|
114
|
+
},
|
115
|
+
{
|
116
|
+
menuName: 'Bold / Italic',
|
117
|
+
data: '<p>To display text as <strong>bold</strong>, wrap the text in <code>*</code> (asterisks). To display text as <em>italic</em>, wrap the text in <code>_</code> (underscores). To create <code>monospace</code> text, wrap the text in <code>+</code> (plus signs).'
|
118
|
+
},
|
119
|
+
{
|
120
|
+
menuName: 'Scripts',
|
121
|
+
data: '<p>Superscript and subscript is created the same way as other inline formats. To create superscript text, wrap your text in <code>^</code> (carats). To create subscript text, wrap your text in <code>~</code> (tildes).</p>'
|
122
|
+
},
|
123
|
+
{
|
124
|
+
menuName: 'Special Characters',
|
125
|
+
data: '<p>ASCIIDoc will automatically convert textual representations of commonly-used special characters. For example, <code>(R)</code> becomes ®, <code>(C)</code> becomes © and <code>(TM)</code> becomes ™.</p>'
|
126
|
+
}
|
127
|
+
]
|
128
|
+
},
|
129
|
+
{
|
130
|
+
menuName: 'Blocks',
|
131
|
+
content: [
|
132
|
+
{
|
133
|
+
menuName: 'Paragraphs',
|
134
|
+
data: '<p>ASCIIDoc allows paragraphs to have optional titles or icons to denote special sections. To make a normal paragraph, simply add a line between blocks and a new paragraph will start. If you want to title your paragraphs, adda line prefixed by <code>.</code> (full stop). An example paragraph with optional title is displayed below:<br><br><code>.Optional Title<br><br>This is my paragraph. It is two sentences long.</code></p>'
|
135
|
+
},
|
136
|
+
{
|
137
|
+
menuName: 'Source Blocks',
|
138
|
+
data: '<p>To create source blocks (long blocks of code), follow the same syntax as above but with an extra line denoting the inline source and lines of four dashes (<code>----</code>) delimiting the source block.. An example of Python source is below:<br><br><code>.python.py<br>[source,python]<br>----<br># i just wrote a comment in python<br># and maybe one more<br>----</code></p>'
|
139
|
+
},
|
140
|
+
{
|
141
|
+
menuName: 'Comment Blocks',
|
142
|
+
data: '<p>Comment blocks are useful if you want to keep notes for yourself inline but do not want them displayed to the public. To create a comment block, simply wrap the paragraph in dividers with four slashes (<code>////</code>). An example comment block is below:<br><br><code>////<br>My comment block is here now<br><br>It can be multiple paragraphs. Really.<br>////</p>'
|
143
|
+
},
|
144
|
+
{
|
145
|
+
menuName: 'Quote Blocks',
|
146
|
+
data: '<p>Quote blocks work much like comment blocks — simply create dividers using four underscores (<code>____</code>) around your quote. An example quote block is displayed below:<br><code>____<br>This is my quote block. Quote something nice here, otherwise there is no point in quoting.<br>____</code></p>'
|
147
|
+
}
|
148
|
+
]
|
149
|
+
},
|
150
|
+
{
|
151
|
+
menuName: 'Macros',
|
152
|
+
content: [
|
153
|
+
{
|
154
|
+
menuName: 'Links',
|
155
|
+
data: '<p>To create links to external pages, you can simply write the URI if you want the URI to link to itself. (i.e., <code>http://github.com/</code> will automatically be parsed to <a href="javascript:void(0);">http://github.com/</a>. If you want different text to be displayed, simply append it to the end of the URI in between <code>[</code> (brackets.) For example, <code>http://github.com/[GitHub]</code> will be parsed as <a href="javascript:void(0);">GitHub</a>, with the URI pointing to <code>http://github.com</code>.</p>'
|
156
|
+
},
|
157
|
+
{
|
158
|
+
menuName: 'Images',
|
159
|
+
data: '<p>Images in ASCIIDoc work much like hyperlinks, but image URLs are prefixed with <code>image:</code>. For example, to link to an image at <code>images/icons/home.png</code>, write <code>image:images/icons/home.png</code>. Alt text can be added by appending the text to the URI in <code>[</code> (brackets).</p>'
|
160
|
+
}
|
161
|
+
]
|
162
|
+
}
|
163
|
+
];
|
164
|
+
|
165
|
+
$.GollumEditor.defineHelp('asciidoc', ASCIIDocHelp);
|
166
|
+
|
167
|
+
})(jQuery);
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/**
|
2
|
+
* Creole Language Definition
|
3
|
+
*
|
4
|
+
*/
|
5
|
+
(function($) {
|
6
|
+
|
7
|
+
var Creole = {
|
8
|
+
|
9
|
+
'function-bold' : {
|
10
|
+
search: /([^\n]+)([\n]*)/gi,
|
11
|
+
replace: "**$1**$2"
|
12
|
+
},
|
13
|
+
|
14
|
+
'function-italic' : {
|
15
|
+
search: /([^\n]+)([\n]*)/gi,
|
16
|
+
replace: "//$1//$2"
|
17
|
+
},
|
18
|
+
|
19
|
+
'function-code' : {
|
20
|
+
search: /([^\n]+)([\n]*)/gi,
|
21
|
+
replace: "{{{$1}}}$2"
|
22
|
+
},
|
23
|
+
|
24
|
+
'function-hr' : {
|
25
|
+
append: "\n\n----\n\n"
|
26
|
+
},
|
27
|
+
|
28
|
+
'function-ul' : {
|
29
|
+
search: /(.+)([\n]?)/gi,
|
30
|
+
replace: "* $1$2"
|
31
|
+
},
|
32
|
+
|
33
|
+
/* This looks silly but is completely valid Markdown */
|
34
|
+
'function-ol' : {
|
35
|
+
search: /(.+)([\n]?)/gi,
|
36
|
+
replace: "# $1$2"
|
37
|
+
},
|
38
|
+
|
39
|
+
'function-link' : {
|
40
|
+
exec: function( txt, selText, $field ) {
|
41
|
+
var results = null;
|
42
|
+
$.GollumEditor.Dialog.init({
|
43
|
+
title: 'Insert Link',
|
44
|
+
fields: [
|
45
|
+
{
|
46
|
+
id: 'text',
|
47
|
+
name: 'Link Text',
|
48
|
+
type: 'text',
|
49
|
+
help: 'The text to display to the user.'
|
50
|
+
},
|
51
|
+
{
|
52
|
+
id: 'href',
|
53
|
+
name: 'URL',
|
54
|
+
type: 'text',
|
55
|
+
help: 'The URL to link to.'
|
56
|
+
}
|
57
|
+
],
|
58
|
+
OK: function( res ) {
|
59
|
+
var h = '[[' + res['href'] + '|' +
|
60
|
+
res['text'] + ']]';
|
61
|
+
$.GollumEditor.replaceSelection( h );
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
|
66
|
+
}
|
67
|
+
},
|
68
|
+
|
69
|
+
'function-image' : {
|
70
|
+
exec: function( txt, selText, $field ) {
|
71
|
+
var results = null;
|
72
|
+
$.GollumEditor.Dialog.init({
|
73
|
+
title: 'Insert Image',
|
74
|
+
fields: [
|
75
|
+
{
|
76
|
+
id: 'url',
|
77
|
+
name: 'Image URL',
|
78
|
+
type: 'text'
|
79
|
+
},
|
80
|
+
{
|
81
|
+
id: 'alt',
|
82
|
+
name: 'Alt Text',
|
83
|
+
type: 'text'
|
84
|
+
}
|
85
|
+
],
|
86
|
+
OK: function( res ) {
|
87
|
+
var h = '';
|
88
|
+
if ( res['url'] && res['alt'] ) {
|
89
|
+
h = '{{' + res['url'];
|
90
|
+
if ( res['alt'] != '' ) {
|
91
|
+
h += '|' + res['alt'] + '}}';
|
92
|
+
}
|
93
|
+
}
|
94
|
+
$.GollumEditor.replaceSelection( h );
|
95
|
+
}
|
96
|
+
});
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
};
|
101
|
+
|
102
|
+
$.GollumEditor.defineLanguage('creole', Creole);
|
103
|
+
|
104
|
+
})(jQuery);
|
@@ -0,0 +1,211 @@
|
|
1
|
+
/**
|
2
|
+
* Markdown Language Definition
|
3
|
+
*
|
4
|
+
* A language definition for string manipulation operations, in this case
|
5
|
+
* for the Markdown, uh, markup language. Uses regexes for various functions
|
6
|
+
* by default. If regexes won't do and you need to do some serious
|
7
|
+
* manipulation, you can declare a function in the object instead.
|
8
|
+
*
|
9
|
+
* Code example:
|
10
|
+
* 'functionbar-id' : {
|
11
|
+
* exec: function(text, selectedText) {
|
12
|
+
* functionStuffHere();
|
13
|
+
* },
|
14
|
+
* search: /somesearchregex/gi,
|
15
|
+
* replace: 'replace text for RegExp.replace',
|
16
|
+
* append: "just add this where the cursor is"
|
17
|
+
* }
|
18
|
+
*
|
19
|
+
**/
|
20
|
+
(function($) {
|
21
|
+
|
22
|
+
var MarkDown = {
|
23
|
+
|
24
|
+
'function-bold' : {
|
25
|
+
search: /([^\n]+)([\n\s]*)/g,
|
26
|
+
replace: "**$1**$2"
|
27
|
+
},
|
28
|
+
|
29
|
+
'function-italic' : {
|
30
|
+
search: /([^\n]+)([\n\s]*)/g,
|
31
|
+
replace: "_$1_$2"
|
32
|
+
},
|
33
|
+
|
34
|
+
'function-code' : {
|
35
|
+
search: /(^[\n]+)([\n\s]*)/g,
|
36
|
+
replace: "`$1`$2"
|
37
|
+
},
|
38
|
+
|
39
|
+
'function-hr' : {
|
40
|
+
append: "\n***\n"
|
41
|
+
},
|
42
|
+
|
43
|
+
'function-ul' : {
|
44
|
+
search: /(.+)([\n]?)/g,
|
45
|
+
replace: "* $1$2"
|
46
|
+
},
|
47
|
+
|
48
|
+
/* This looks silly but is completely valid Markdown */
|
49
|
+
'function-ol' : {
|
50
|
+
search: /(.+)([\n]?)/g,
|
51
|
+
replace: "1. $1$2"
|
52
|
+
},
|
53
|
+
|
54
|
+
'function-blockquote' : {
|
55
|
+
search: /(.+)([\n]?)/g,
|
56
|
+
replace: "> $1$2"
|
57
|
+
},
|
58
|
+
|
59
|
+
'function-h1' : {
|
60
|
+
search: /(.+)([\n]?)/g,
|
61
|
+
replace: "# $1$2"
|
62
|
+
},
|
63
|
+
|
64
|
+
'function-h2' : {
|
65
|
+
search: /(.+)([\n]?)/g,
|
66
|
+
replace: "## $1$2"
|
67
|
+
},
|
68
|
+
|
69
|
+
'function-h3' : {
|
70
|
+
search: /(.+)([\n]?)/g,
|
71
|
+
replace: "### $1$2"
|
72
|
+
},
|
73
|
+
|
74
|
+
'function-link' : {
|
75
|
+
exec: function( txt, selText, $field ) {
|
76
|
+
var results = null;
|
77
|
+
$.GollumEditor.Dialog.init({
|
78
|
+
title: 'Insert Link',
|
79
|
+
fields: [
|
80
|
+
{
|
81
|
+
id: 'text',
|
82
|
+
name: 'Link Text',
|
83
|
+
type: 'text'
|
84
|
+
},
|
85
|
+
{
|
86
|
+
id: 'href',
|
87
|
+
name: 'URL',
|
88
|
+
type: 'text'
|
89
|
+
}
|
90
|
+
],
|
91
|
+
OK: function( res ) {
|
92
|
+
var rep = '';
|
93
|
+
if ( res['text'] && res['href'] ) {
|
94
|
+
rep = '[' + res['text'] + '](' +
|
95
|
+
res['href'] + ')';
|
96
|
+
}
|
97
|
+
$.GollumEditor.replaceSelection( rep );
|
98
|
+
}
|
99
|
+
});
|
100
|
+
}
|
101
|
+
},
|
102
|
+
|
103
|
+
'function-image' : {
|
104
|
+
exec: function( txt, selText, $field ) {
|
105
|
+
var results = null;
|
106
|
+
$.GollumEditor.Dialog.init({
|
107
|
+
title: 'Insert Image',
|
108
|
+
fields: [
|
109
|
+
{
|
110
|
+
id: 'url',
|
111
|
+
name: 'Image URL',
|
112
|
+
type: 'text'
|
113
|
+
},
|
114
|
+
{
|
115
|
+
id: 'alt',
|
116
|
+
name: 'Alt Text',
|
117
|
+
type: 'text'
|
118
|
+
}
|
119
|
+
],
|
120
|
+
OK: function( res ) {
|
121
|
+
var rep = '';
|
122
|
+
if ( res['url'] && res['alt'] ) {
|
123
|
+
rep = '![' + res['alt'] + ']' +
|
124
|
+
'(' + res['url'] + ')';
|
125
|
+
}
|
126
|
+
$.GollumEditor.replaceSelection( rep );
|
127
|
+
}
|
128
|
+
});
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
};
|
133
|
+
|
134
|
+
var MarkDownHelp = [
|
135
|
+
|
136
|
+
{
|
137
|
+
menuName: 'Block Elements',
|
138
|
+
content: [
|
139
|
+
{
|
140
|
+
menuName: 'Paragraphs & Breaks',
|
141
|
+
data: '<p>To create a paragraph, simply create a block of text that is not separated by one or more blank lines. Blocks of text separated by one or more blank lines will be parsed as paragraphs.</p><p>If you want to create a line break, end a line with two or more spaces, then hit Return/Enter.</p>'
|
142
|
+
},
|
143
|
+
{
|
144
|
+
menuName: 'Headers',
|
145
|
+
data: '<p>Markdown supports two header formats. The wiki editor uses the “atx’-style headers. Simply prefix your header text with the number of <code>#</code> characters to specify heading depth. For example: <code># Header 1</code>, <code>## Header 2</code> and <code>### Header 3</code> will be progressively smaller headers. You may end your headers with any number of hashes.</p>'
|
146
|
+
},
|
147
|
+
{
|
148
|
+
menuName: 'Blockquotes',
|
149
|
+
data: '<p>Markdown creates blockquotes email-style by prefixing each line with the <code>></code>. This looks best if you decide to hard-wrap text and prefix each line with a <code>></code> character, but Markdown supports just putting <code>></code> before your paragraph.</p>'
|
150
|
+
},
|
151
|
+
{
|
152
|
+
menuName: 'Lists',
|
153
|
+
data: '<p>Markdown supports both ordered and unordered lists. To create an ordered list, simply prefix each line with a number (any number will do — this is why the editor only uses one number.) To create an unordered list, you can prefix each line with <code>*</code>, <code>+</code> or <code>-</code>.</p> List items can contain multiple paragraphs, however each paragraph must be indented by at least 4 spaces or a tab.'
|
154
|
+
},
|
155
|
+
{
|
156
|
+
menuName: 'Code Blocks',
|
157
|
+
data: '<p>Markdown wraps code blocks in pre-formatted tags to preserve indentation in your code blocks. To create a code block, indent the entire block by at least 4 spaces or one tab. Markdown will strip the extra indentation you’ve added to the code block.</p>'
|
158
|
+
},
|
159
|
+
{
|
160
|
+
menuName: 'Horizontal Rules',
|
161
|
+
data: 'Horizontal rules are created by placing three or more hyphens, asterisks or underscores on a line by themselves. Spaces are allowed between the hyphens, asterisks or underscores.'
|
162
|
+
}
|
163
|
+
]
|
164
|
+
},
|
165
|
+
|
166
|
+
{
|
167
|
+
menuName: 'Span Elements',
|
168
|
+
content: [
|
169
|
+
{
|
170
|
+
menuName: 'Links',
|
171
|
+
data: '<p>Markdown has two types of links: <strong>inline</strong> and <strong>reference</strong>. For both types of links, the text you want to display to the user is placed in square brackets. For example, if you want your link to display the text “GitHub”, you write <code>[GitHub]</code>.</p><p>To create an inline link, create a set of parentheses immediately after the brackets and write your URL within the parentheses. (e.g., <code>[GitHub](http://github.com/)</code>). Relative paths are allowed in inline links.</p><p>To create a reference link, use two sets of square brackets. <code>[my internal link][internal-ref]</code> will link to the internal reference <code>internal-ref</code>.</p>'
|
172
|
+
},
|
173
|
+
|
174
|
+
{
|
175
|
+
menuName: 'Emphasis',
|
176
|
+
data: '<p>Asterisks (<code>*</code>) and underscores (<code>_</code>) are treated as emphasis and are wrapped with an <code><em></code> tag, which usually displays as italics in most browsers. Double asterisks (<code>**</code>) or double underscores (<code>__</code>) are treated as bold using the <code><strong></code> tag. To create italic or bold text, simply wrap your words in single/double asterisks/underscores. For example, <code>**My double emphasis text**</code> becomes <strong>My double emphasis text</strong>, and <code>*My single emphasis text*</code> becomes <em>My single emphasis text</em>.</p>'
|
177
|
+
},
|
178
|
+
|
179
|
+
{
|
180
|
+
menuName: 'Code',
|
181
|
+
data: '<p>To create inline spans of code, simply wrap the code in backticks (<code>`</code>). Markdown will turn <code>`myFunction`</code> into <code>myFunction</code>.</p>'
|
182
|
+
},
|
183
|
+
|
184
|
+
{
|
185
|
+
menuName: 'Images',
|
186
|
+
data: '<p>Markdown image syntax looks a lot like the syntax for links; it is essentially the same syntax preceded by an exclamation point (<code>!</code>). For example, if you want to link to an image at <code>http://github.com/unicorn.png</code> with the alternate text <code>My Unicorn</code>, you would write <code>![My Unicorn](http://github.com/unicorn.png)</code>.</p>'
|
187
|
+
}
|
188
|
+
]
|
189
|
+
},
|
190
|
+
|
191
|
+
{
|
192
|
+
menuName: 'Miscellaneous',
|
193
|
+
content: [
|
194
|
+
{
|
195
|
+
menuName: 'Automatic Links',
|
196
|
+
data: '<p>If you want to create a link that displays the actual URL, markdown allows you to quickly wrap the URL in <code><</code> and <code>></code> to do so. For example, the link <a href="javascript:void(0);">http://github.com/</a> is easily produced by writing <code><http://github.com/></code>.</p>'
|
197
|
+
},
|
198
|
+
|
199
|
+
{
|
200
|
+
menuName: 'Escaping',
|
201
|
+
data: '<p>If you want to use a special Markdown character in your document (such as displaying literal asterisks), you can escape the character with the backslash (<code>\\</code>). Markdown will ignore the character directly after a backslash.'
|
202
|
+
}
|
203
|
+
]
|
204
|
+
}
|
205
|
+
];
|
206
|
+
|
207
|
+
|
208
|
+
$.GollumEditor.defineLanguage('markdown', MarkDown);
|
209
|
+
$.GollumEditor.defineHelp('markdown', MarkDownHelp);
|
210
|
+
|
211
|
+
})(jQuery);
|