gollum 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of gollum might be problematic. Click here for more details.

Files changed (35) hide show
  1. checksums.yaml +13 -5
  2. data/HISTORY.md +14 -0
  3. data/README.md +15 -11
  4. data/bin/gollum +17 -4
  5. data/{openrc → contrib/openrc}/conf.d/gollum +0 -0
  6. data/{openrc → contrib/openrc}/init.d/gollum +0 -0
  7. data/contrib/systemd/gollum@.service +12 -0
  8. data/gollum.gemspec +9 -5
  9. data/lib/gollum.rb +1 -1
  10. data/lib/gollum/app.rb +44 -12
  11. data/lib/gollum/editing_auth.rb +34 -0
  12. data/lib/gollum/helpers.rb +12 -0
  13. data/lib/gollum/public/gollum/css/dialog.css +117 -15
  14. data/lib/gollum/public/gollum/css/editor.css +220 -62
  15. data/lib/gollum/public/gollum/css/gollum.css +139 -22
  16. data/lib/gollum/public/gollum/css/ie7.css +6 -0
  17. data/lib/gollum/public/gollum/css/template.css +56 -2
  18. data/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +60 -0
  19. data/lib/gollum/public/gollum/javascript/editor/langs/asciidoc.js +26 -11
  20. data/lib/gollum/public/gollum/javascript/gollum.dialog.js +26 -4
  21. data/lib/gollum/templates/compare.mustache +16 -10
  22. data/lib/gollum/templates/editor.mustache +6 -2
  23. data/lib/gollum/templates/history.mustache +4 -2
  24. data/lib/gollum/templates/latest_changes.mustache +39 -0
  25. data/lib/gollum/templates/layout.mustache +14 -5
  26. data/lib/gollum/templates/page.mustache +30 -15
  27. data/lib/gollum/templates/pages.mustache +4 -3
  28. data/lib/gollum/views/compare.rb +1 -1
  29. data/lib/gollum/views/create.rb +8 -0
  30. data/lib/gollum/views/edit.rb +8 -0
  31. data/lib/gollum/views/history.rb +1 -1
  32. data/lib/gollum/views/latest_changes.rb +90 -0
  33. data/lib/gollum/views/page.rb +33 -11
  34. data/lib/gollum/views/pages.rb +6 -2
  35. metadata +38 -34
@@ -1,11 +1,11 @@
1
1
  /**
2
- * ASCIIDoc Language Definition
2
+ * AsciiDoc Language Definition
3
3
  *
4
4
  */
5
5
 
6
6
  (function($) {
7
7
 
8
- var ASCIIDoc = {
8
+ var AsciiDoc = {
9
9
 
10
10
  'function-bold' : {
11
11
  search: /(^[\n]+)([\n\s]*)/g,
@@ -19,7 +19,7 @@ var ASCIIDoc = {
19
19
 
20
20
  'function-code' : {
21
21
  search: /(^[\n]+)([\n\s]*)/g,
22
- replace: "+$1+$2"
22
+ replace: "`$1`$2"
23
23
  },
24
24
 
25
25
  'function-ul' : {
@@ -37,6 +37,21 @@ var ASCIIDoc = {
37
37
  replace: "----\n$1$2\n----\n"
38
38
  },
39
39
 
40
+ 'function-h1' : {
41
+ search: /(.+)([\n]?)/g,
42
+ replace: "= $1$2"
43
+ },
44
+
45
+ 'function-h2' : {
46
+ search: /(.+)([\n]?)/g,
47
+ replace: "== $1$2"
48
+ },
49
+
50
+ 'function-h3' : {
51
+ search: /(.+)([\n]?)/g,
52
+ replace: "=== $1$2"
53
+ },
54
+
40
55
  'function-link' : {
41
56
  exec: function( txt, selText, $field ) {
42
57
  var results = null;
@@ -102,20 +117,20 @@ var ASCIIDoc = {
102
117
 
103
118
  };
104
119
 
105
- $.GollumEditor.defineLanguage('asciidoc', ASCIIDoc);
120
+ $.GollumEditor.defineLanguage('asciidoc', AsciiDoc);
106
121
 
107
122
 
108
- var ASCIIDocHelp = [
123
+ var AsciiDocHelp = [
109
124
  {
110
125
  menuName: 'Text Formatting',
111
126
  content: [
112
127
  {
113
128
  menuName: 'Headers',
114
- 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>'
129
+ 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>'
115
130
  },
116
131
  {
117
132
  menuName: 'Bold / Italic',
118
- 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).'
133
+ 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> (backtick).'
119
134
  },
120
135
  {
121
136
  menuName: 'Scripts',
@@ -123,7 +138,7 @@ var ASCIIDocHelp = [
123
138
  },
124
139
  {
125
140
  menuName: 'Special Characters',
126
- data: '<p>ASCIIDoc will automatically convert textual representations of commonly-used special characters. For example, <code>(R)</code> becomes &reg;, <code>(C)</code> becomes &copy; and <code>(TM)</code> becomes &trade;.</p>'
141
+ data: '<p>AsciiDoc will automatically convert textual representations of commonly-used special characters. For example, <code>(R)</code> becomes &reg;, <code>(C)</code> becomes &copy; and <code>(TM)</code> becomes &trade;.</p>'
127
142
  }
128
143
  ]
129
144
  },
@@ -132,7 +147,7 @@ var ASCIIDocHelp = [
132
147
  content: [
133
148
  {
134
149
  menuName: 'Paragraphs',
135
- 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>'
150
+ 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>'
136
151
  },
137
152
  {
138
153
  menuName: 'Source Blocks',
@@ -157,12 +172,12 @@ var ASCIIDocHelp = [
157
172
  },
158
173
  {
159
174
  menuName: 'Images',
160
- 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>'
175
+ 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>'
161
176
  }
162
177
  ]
163
178
  }
164
179
  ];
165
180
 
166
- $.GollumEditor.defineHelp('asciidoc', ASCIIDocHelp);
181
+ $.GollumEditor.defineHelp('asciidoc', AsciiDocHelp);
167
182
 
168
183
  })(jQuery);
@@ -13,6 +13,12 @@
13
13
  markupCreated: false,
14
14
  markup: '',
15
15
 
16
+ currentAspect: function(){
17
+ if (window.innerWidth < 480) return "small-mobile";
18
+ if ($('#gollum-dialog-dialog').css('position') == 'fixed') return "large-mobile";
19
+ return "desktop";
20
+ },
21
+
16
22
  attachEvents: function( evtOK ) {
17
23
  $('#gollum-dialog-action-ok').click(function( e ) {
18
24
  Dialog.eventOK( e, evtOK );
@@ -185,6 +191,8 @@
185
191
  }
186
192
  });
187
193
  }
194
+
195
+ $(window).unbind('resize', Dialog.resize);
188
196
  }
189
197
  },
190
198
 
@@ -268,14 +276,28 @@
268
276
  });
269
277
  }
270
278
  }
279
+
280
+ $(window).bind('resize', Dialog.resize);
271
281
  }
272
282
  },
273
283
 
284
+ resize: function(){
285
+ Dialog.position();
286
+ },
287
+
274
288
  position: function() {
275
- var dialogHeight = $('#gollum-dialog-dialog-inner').height();
276
- $('#gollum-dialog-dialog-inner')
277
- .css('height', dialogHeight + 'px')
278
- .css('margin-top', -1 * parseInt( dialogHeight / 2 ));
289
+ if (Dialog.currentAspect() == "small-mobile") {
290
+ $('#gollum-dialog-dialog-inner').css('height', '100%').css('margin-top', 'auto');
291
+ }
292
+ else if (Dialog.currentAspect() == "large-mobile") {
293
+ $('#gollum-dialog-dialog-inner').css('height', 'auto').css('margin-top', 'auto');
294
+ }
295
+ else if (Dialog.currentAspect() == "desktop") {
296
+ var dialogHeight = $('#gollum-dialog-dialog-inner').height();
297
+ $('#gollum-dialog-dialog-inner')
298
+ .css('height', dialogHeight + 'px')
299
+ .css('margin-top', -1 * parseInt( dialogHeight / 2 ));
300
+ }
279
301
  }
280
302
  };
281
303
 
@@ -8,8 +8,10 @@
8
8
  </li>
9
9
  <li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
10
10
  class="action-view-page">View Page</a></li>
11
- <li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
12
- class="action-edit-page">Edit Page</a></li>
11
+ {{#allow_editing}}
12
+ <li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
13
+ class="action-edit-page">Edit Page</a></li>
14
+ {{/allow_editing}}
13
15
  <li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
14
16
  class="action-page-history">Page History</a></li>
15
17
  </ul>
@@ -25,11 +27,13 @@
25
27
  <ul class="actions">
26
28
  <li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
27
29
  class="action-page-history">Back to Page History</a></li>
28
- <li class="minibutton">
29
- <form name="gollum-revert" action="{{base_url}}/revert/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
30
- <a href="#" class="gollum-revert-button">Revert Changes</a>
31
- </form>
32
- </li>
30
+ {{#allow_editing}}
31
+ <li class="minibutton">
32
+ <form name="gollum-revert" action="{{base_url}}/revert/{{escaped_url_path}}/{{before}}/{{after}}" method="post" id="gollum-revert-form">
33
+ <a href="#" class="gollum-revert-button">Revert Changes</a>
34
+ </form>
35
+ </li>
36
+ {{/allow_editing}}
33
37
  </ul>
34
38
  {{/show_revert}}
35
39
 
@@ -52,9 +56,11 @@
52
56
  <li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
53
57
  class="action-page-history">Back to Page History</a></li>
54
58
  {{#show_revert}}
55
- <li class="minibutton">
56
- <a href="#" class="gollum-revert-button">Revert Changes</a>
57
- </li>
59
+ {{#allow_editing}}
60
+ <li class="minibutton">
61
+ <a href="#" class="gollum-revert-button">Revert Changes</a>
62
+ </li>
63
+ {{/allow_editing}}
58
64
  {{/show_revert}}
59
65
  <li class="minibutton"><a href="#">Back to Top</a></li>
60
66
  </ul>
@@ -1,4 +1,4 @@
1
- <div id="gollum-editor" data-escaped-name="{{escaped_name}}" class="{{#is_create_page}}create{{/is_create_page}}{{#is_edit_page}}edit{{/is_edit_page}}">
1
+ <div id="gollum-editor" data-escaped-name="{{escaped_name}}" class="{{#is_create_page}}create{{/is_create_page}}{{#is_edit_page}}edit{{/is_edit_page}} {{#allow_uploads}}uploads-allowed{{/allow_uploads}}">
2
2
  {{#is_create_page}}
3
3
  <form name="gollum-editor" action="{{base_url}}/create" method="post">
4
4
  {{/is_create_page}}
@@ -55,6 +55,7 @@
55
55
  </div>
56
56
 
57
57
  <div id="gollum-editor-format-selector">
58
+ <label for="format">Edit Mode</label>
58
59
  <select id="wiki_format" name="format">
59
60
  {{#formats}}
60
61
  <option {{#selected}}selected="selected" {{/selected}}value="{{id}}">
@@ -62,7 +63,6 @@
62
63
  </option>
63
64
  {{/formats}}
64
65
  </select>
65
- <label for="format">Edit Mode</label>
66
66
  </div>
67
67
  </div>
68
68
  <div id="gollum-editor-help" class="jaws">
@@ -89,6 +89,10 @@
89
89
  </div>
90
90
  <textarea id="gollum-editor-body"
91
91
  data-markup-lang="{{format}}" name="content" class="mousetrap">{{content}}</textarea>
92
+ <div>
93
+ <i class="fa fa-spinner fa-spin"></i>
94
+ Uploading file ...
95
+ </div>
92
96
 
93
97
  {{#header}}
94
98
  <div id="gollum-editor-edit-header" class="collapsed">
@@ -7,8 +7,10 @@
7
7
  </li>
8
8
  <li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
9
9
  class="action-view-page">View Page</a></li>
10
- <li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
11
- class="action-edit-page">Edit Page</a></li>
10
+ {{#allow_editing}}
11
+ <li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
12
+ class="action-edit-page">Edit Page</a></li>
13
+ {{/allow_editing}}
12
14
  </ul>
13
15
  </div>
14
16
  <div id="wiki-history">
@@ -0,0 +1,39 @@
1
+ <div id="wiki-wrapper" class="history">
2
+ <div id="head">
3
+ <h1><strong>{{title}}</strong></h1>
4
+ <ul class="actions">
5
+ <li class="minibutton"><a href="{{base_url}}/{{escaped_url_path}}"
6
+ class="action-view-page">Home</a></li>
7
+ </ul>
8
+ </div>
9
+ <div id="wiki-history">
10
+
11
+ <fieldset>
12
+ <table>
13
+ <tbody>
14
+
15
+ {{#versions}}
16
+ <tr>
17
+ <td class="author">
18
+ {{>author_template}}
19
+ </td>
20
+ <td class="commit-name">
21
+ <span class="time-elapsed" title="{{date_full}}">{{date}}:</span>&nbsp;
22
+ {{message}}
23
+ [{{id7}}]
24
+ {{#files}}
25
+ <br>
26
+ <a href="{{link}}">{{file}}</a>
27
+ {{/files}}
28
+ </td>
29
+ </tr>
30
+ {{/versions}}
31
+
32
+ </tbody>
33
+ </table>
34
+ </fieldset>
35
+ </div>
36
+ <div id="footer">
37
+
38
+ </div>
39
+ </div>
@@ -2,6 +2,9 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta http-equiv="Content-type" content="text/html;charset=utf-8">
5
+ <meta name="MobileOptimized" content="width">
6
+ <meta name="HandheldFriendly" content="true">
7
+ <meta name="viewport" content="width=device-width">
5
8
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/gollum.css" media="all">
6
9
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/editor.css" media="all">
7
10
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all">
@@ -16,9 +19,9 @@
16
19
 
17
20
  <script>
18
21
  var baseUrl = '{{base_url}}';
22
+ var uploadDest = '{{upload_dest}}';
19
23
  {{#page}}
20
24
  var pageFullPath = '{{url_path_display}}';
21
- var uploadDest = '{{upload_dest}}';
22
25
  {{/page}}
23
26
  </script>
24
27
  <script type="text/javascript" src="{{base_url}}/javascript/jquery-1.7.2.min.js"></script>
@@ -31,18 +34,24 @@
31
34
  <script type="text/javascript" src="{{base_url}}/javascript/identicon_canvas.js"></script>
32
35
  {{/use_identicon}}
33
36
  {{#mathjax}}
34
- <script type="text/x-mathjax-config">
35
- MathJax.Hub.Config({
37
+ {{^mathjax_config}}
38
+ <script type="text/javascript">
39
+ window.MathJax = {
36
40
  tex2jax: {
37
41
  inlineMath: [ ['\\(','\\)'] ],
38
42
  displayMath: [ ['$$','$$'], ['\\[','\\]'] ],
39
43
  processEscapes: true
40
44
  },
41
- TeX: { extensions: ["autoload-all.js"] }});
45
+ TeX: { extensions: ["autoload-all.js"] }
46
+ };
42
47
  </script>
48
+ {{/mathjax_config}}
49
+ {{#mathjax_config}}
50
+ <script type="text/javascript" src="{{base_url}}/{{mathjax_config}}"></script>
51
+ {{/mathjax_config}}
43
52
  <script>(function(d,j){
44
53
  j = d.createElement('script');
45
- j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
54
+ j.src = '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
46
55
  (d.head || d.getElementsByTagName('head')[0]).appendChild(j);
47
56
  }(document));
48
57
  </script>{{/mathjax}}
@@ -18,22 +18,35 @@ Mousetrap.bind(['e'], function( e ) {
18
18
  class="action-all-pages">All</a></li>
19
19
  <li class="minibutton"><a href="{{base_url}}/fileview"
20
20
  class="action-fileview">Files</a></li>
21
- <li class="minibutton jaws">
22
- <a href="#" id="minibutton-new-page">New</a></li>
23
- {{#allow_uploads}}
24
- <li class="minibutton jaws">
25
- <a href="#" id="minibutton-upload-page">Upload</a></li>
26
- {{/allow_uploads}}
27
- {{#editable}}
28
- <li class="minibutton jaws">
29
- <a href="#" id="minibutton-rename-page">Rename</a></li>
30
- <li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
31
- class="action-edit-page">Edit</a></li>
32
- {{/editable}}
21
+ {{#allow_editing}}
22
+ <li class="minibutton jaws">
23
+ <a href="#" id="minibutton-new-page">New</a></li>
24
+ {{/allow_editing}}
25
+ {{#allow_editing}}
26
+ {{#allow_uploads}}
27
+ <li class="minibutton jaws">
28
+ <a href="#" id="minibutton-upload-page">Upload</a></li>
29
+ {{/allow_uploads}}
30
+ {{/allow_editing}}
31
+ {{#allow_editing}}
32
+ {{#editable}}
33
+ <li class="minibutton jaws">
34
+ <a href="#" id="minibutton-rename-page">Rename</a></li>
35
+ {{/editable}}
36
+ {{/allow_editing}}
37
+ {{#allow_editing}}
38
+ {{#editable}}
39
+ <li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
40
+ class="action-edit-page">Edit</a></li>
41
+ {{/editable}}
42
+ {{/allow_editing}}
33
43
  {{#page_exists}}
34
44
  <li class="minibutton jaws">
35
45
  <li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
36
46
  class="action-page-history">History</a></li>
47
+ <li class="minibutton jaws">
48
+ <li class="minibutton"><a href="{{base_url}}/latest_changes"
49
+ class="action-page-history">Latest Changes</a></li>
37
50
  {{/page_exists}}
38
51
  </ul>
39
52
  </div>
@@ -75,9 +88,11 @@ Mousetrap.bind(['e'], function( e ) {
75
88
  </div>
76
89
  <div id="footer">
77
90
  <p id="last-edit">Last edited by <b>{{author}}</b>, {{date}}</p>
78
- <p>
79
- <a id="delete-link" href="{{base_url}}/{{escaped_url_path}}" data-confirm="Are you sure you want to delete this page?"><span>Delete this Page</span></a>
80
- </p>
91
+ {{#allow_editing}}
92
+ <p>
93
+ <a id="delete-link" href="{{base_url}}/{{escaped_url_path}}" data-confirm="Are you sure you want to delete this page?"><span>Delete this Page</span></a>
94
+ </p>
95
+ {{/allow_editing}}
81
96
  </div>
82
97
  </div>
83
98
 
@@ -7,9 +7,10 @@
7
7
  </li>
8
8
  <li class="minibutton"><a href="{{base_url}}/"
9
9
  class="action-home-page">Home</a></li>
10
- <li class="minibutton jaws">
11
- <a href="#" id="minibutton-new-page">New</a>
12
- </li>
10
+ {{#allow_editing}}
11
+ <li class="minibutton jaws">
12
+ <a href="#" id="minibutton-new-page">New</a></li>
13
+ {{/allow_editing}}
13
14
  </ul>
14
15
  </div>
15
16
  <div id="pages">
@@ -3,7 +3,7 @@ module Precious
3
3
  class Compare < Layout
4
4
  include HasPage
5
5
 
6
- attr_reader :page, :diff, :versions, :message
6
+ attr_reader :page, :diff, :versions, :message, :allow_editing
7
7
 
8
8
  def title
9
9
  "Comparison of #{@page.title}"
@@ -17,6 +17,14 @@ module Precious
17
17
  false
18
18
  end
19
19
 
20
+ def allow_uploads
21
+ @allow_uploads
22
+ end
23
+
24
+ def upload_dest
25
+ @upload_dest
26
+ end
27
+
20
28
  def format
21
29
  @format = (@page.format || false) if @format.nil? && @page
22
30
  @format.to_s.downcase
@@ -60,6 +60,14 @@ module Precious
60
60
  true
61
61
  end
62
62
 
63
+ def allow_uploads
64
+ @allow_uploads
65
+ end
66
+
67
+ def upload_dest
68
+ @upload_dest
69
+ end
70
+
63
71
  def format
64
72
  @format = (@page.format || false) if @format.nil?
65
73
  @format.to_s.downcase