gollum 2.4.0 → 2.4.1

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.

data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
- gem 'rake', '~> 0.9'
4
+ gem 'rake', '~> 10.0.2'
data/bin/gollum CHANGED
@@ -73,6 +73,10 @@ opts = OptionParser.new do |opts|
73
73
  wiki_options[:mathjax] = true
74
74
  end
75
75
 
76
+ opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source|
77
+ wiki_options[:user_icons] = source
78
+ end
79
+
76
80
  opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do
77
81
  wiki_options[:show_all] = true
78
82
  end
@@ -181,6 +185,6 @@ else
181
185
  end
182
186
  end
183
187
  # Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
184
- Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port']).start
188
+ Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start
185
189
  end
186
190
  end
data/gollum.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.required_ruby_version = ">= 1.8.7"
6
6
 
7
7
  s.name = 'gollum'
8
- s.version = '2.4.0'
9
- s.date = '2012-11-11'
8
+ s.version = '2.4.1'
9
+ s.date = '2012-11-19'
10
10
  s.rubyforge_project = 'gollum'
11
11
 
12
12
  s.summary = "A simple, Git-powered wiki."
@@ -25,22 +25,22 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_dependency('grit', '~> 2.5.0')
27
27
  s.add_dependency('github-markup', ['>= 0.7.4', '< 1.0.0'])
28
- s.add_dependency('github-markdown', '~> 0.5.1')
28
+ s.add_dependency('github-markdown', '~> 0.5.3')
29
29
  s.add_dependency('pygments.rb', '~> 0.3.2')
30
30
  s.add_dependency('sinatra', '~> 1.3.3')
31
31
  s.add_dependency('mustache', ['>= 0.99.4', '< 1.0.0'])
32
32
  s.add_dependency('sanitize', '~> 2.0.3')
33
33
  s.add_dependency('nokogiri', '~> 1.5.5')
34
- s.add_dependency('useragent', '~> 0.4.12')
34
+ s.add_dependency('useragent', '~> 0.4.13')
35
35
  s.add_dependency('stringex', '~> 1.4.0')
36
36
 
37
37
  s.add_development_dependency('RedCloth', '~> 4.2.9')
38
- s.add_development_dependency('mocha', '~> 0.12.7')
38
+ s.add_development_dependency('mocha', '~> 0.13.0')
39
39
  s.add_development_dependency('org-ruby', '~> 0.7.2')
40
- s.add_development_dependency('shoulda', '~> 3.3.1')
40
+ s.add_development_dependency('shoulda', '~> 3.3.2')
41
41
  s.add_development_dependency('rack-test', '~> 0.6.2')
42
42
  s.add_development_dependency('wikicloth', '~> 0.8.0')
43
- s.add_development_dependency('rake', '~> 0.9')
43
+ s.add_development_dependency('rake', '~> 10.0.2')
44
44
  s.add_development_dependency('pry', '~> 0.9.10')
45
45
  # required by pry
46
46
  s.add_development_dependency('rb-readline', '~> 0.4.2')
@@ -75,6 +75,7 @@ Gem::Specification.new do |s|
75
75
  lib/gollum/frontend/public/gollum/images/fileview/toggle-small-expand.png
76
76
  lib/gollum/frontend/public/gollum/images/fileview/toggle-small.png
77
77
  lib/gollum/frontend/public/gollum/images/icon-sprite.png
78
+ lib/gollum/frontend/public/gollum/images/man_24.png
78
79
  lib/gollum/frontend/public/gollum/images/para.png
79
80
  lib/gollum/frontend/public/gollum/images/pin-16.png
80
81
  lib/gollum/frontend/public/gollum/images/pin-20.png
@@ -91,6 +92,7 @@ Gem::Specification.new do |s|
91
92
  lib/gollum/frontend/public/gollum/javascript/gollum.dialog.js
92
93
  lib/gollum/frontend/public/gollum/javascript/gollum.js
93
94
  lib/gollum/frontend/public/gollum/javascript/gollum.placeholder.js
95
+ lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
94
96
  lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js
95
97
  lib/gollum/frontend/public/gollum/javascript/jquery.color.js
96
98
  lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
@@ -438,6 +440,9 @@ Gem::Specification.new do |s|
438
440
  lib/gollum/frontend/templates/error.mustache
439
441
  lib/gollum/frontend/templates/file_view.mustache
440
442
  lib/gollum/frontend/templates/history.mustache
443
+ lib/gollum/frontend/templates/history_authors/gravatar.mustache
444
+ lib/gollum/frontend/templates/history_authors/identicon.mustache
445
+ lib/gollum/frontend/templates/history_authors/none.mustache
441
446
  lib/gollum/frontend/templates/layout.mustache
442
447
  lib/gollum/frontend/templates/page.mustache
443
448
  lib/gollum/frontend/templates/pages.mustache
data/lib/gollum.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # ~*~ encoding: utf-8 ~*~
2
2
  # stdlib
3
3
  require 'digest/md5'
4
+ require 'digest/sha1'
4
5
  require 'ostruct'
5
6
 
6
7
  # external
@@ -23,7 +24,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
23
24
  require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
24
25
 
25
26
  module Gollum
26
- VERSION = '2.4.0'
27
+ VERSION = '2.4.1'
27
28
 
28
29
  def self.assets_path
29
30
  ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
@@ -85,6 +85,7 @@ module Precious
85
85
  @base_url = url('/', false).chomp('/')
86
86
  # above will detect base_path when it's used with map in a config.ru
87
87
  settings.wiki_options.merge!({ :base_path => @base_url })
88
+ @css = settings.wiki_options[:css]
88
89
  end
89
90
 
90
91
  get '/' do
@@ -196,12 +197,10 @@ module Precious
196
197
  page_dir = settings.wiki_options[:page_file_dir].to_s
197
198
  path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
198
199
 
199
- # write_page is not directory aware so use wiki_options to emulate dir support.
200
- wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
201
- wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
200
+ wiki = wiki_new
202
201
 
203
202
  begin
204
- wiki.write_page(name, format, params[:content], commit_message)
203
+ wiki.write_page(name, format, params[:content], commit_message, path)
205
204
  redirect to("/#{clean_url(::File.join(path,name))}")
206
205
  rescue Gollum::DuplicatePageError => e
207
206
  @message = "Duplicate page: #{e.message}"
@@ -238,7 +237,6 @@ module Precious
238
237
  @content = @page.formatted_data
239
238
  @toc_content = wiki.universal_toc ? @page.toc_data : nil
240
239
  @mathjax = wiki.mathjax
241
- @css = wiki.css
242
240
  @h1_title = wiki.h1_title
243
241
  @editable = false
244
242
  mustache :page
@@ -284,10 +282,6 @@ module Precious
284
282
  mustache :compare
285
283
  end
286
284
 
287
- get %r{^/(javascript|css|images)} do
288
- halt 404
289
- end
290
-
291
285
  get %r{/(.+?)/([0-9a-f]{40})} do
292
286
  file_path = params[:captures][0]
293
287
  version = params[:captures][1]
@@ -362,7 +356,6 @@ module Precious
362
356
  @content = page.formatted_data
363
357
  @toc_content = wiki.universal_toc ? @page.toc_data : nil
364
358
  @mathjax = wiki.mathjax
365
- @css = wiki.css
366
359
  @h1_title = wiki.h1_title
367
360
  mustache :page
368
361
  elsif file = wiki.file(fullpath)
@@ -233,6 +233,7 @@
233
233
  $('#gollum-dialog-dialog').animate({ opacity: 1 }, {
234
234
  duration: 500
235
235
  });
236
+ $($('#gollum-dialog-dialog input[type="text"]').get(0)).focus();
236
237
  }
237
238
  });
238
239
  }
@@ -228,4 +228,21 @@ $(document).ready(function() {
228
228
  });
229
229
  $.GollumEditor({ NewFile: true, MarkupType: default_markup });
230
230
  }
231
+
232
+ if( $('#wiki-history').length ){
233
+ var lookup = {};
234
+ $('img.identicon').each(function(index, element){
235
+ var $item = $(element);
236
+ var code = parseInt($item.data('identicon'), 10);
237
+ var img_bin = lookup[code];
238
+ if( img_bin === undefined ){
239
+ var size = 16;
240
+ var canvas = $('<canvas width=16 height=16/>').get(0);
241
+ render_identicon(canvas, code, 16);
242
+ img_bin = canvas.toDataURL("image/png");
243
+ lookup[code] = img_bin;
244
+ }
245
+ $item.attr('src', img_bin);
246
+ });
247
+ }
231
248
  });
@@ -0,0 +1,111 @@
1
+ /*
2
+ Client-side Canvas tag based Identicon rendering code
3
+
4
+ @author Don Park
5
+ @version 0.2
6
+ @date January 21th, 2007
7
+ */
8
+
9
+ var patch0 = new Array( 0, 4, 24, 20 );
10
+ var patch1 = new Array( 0, 4, 20 );
11
+ var patch2 = new Array( 2, 24, 20 );
12
+ var patch3 = new Array( 0, 2, 20, 22 );
13
+ var patch4 = new Array( 2, 14, 22, 10 );
14
+ var patch5 = new Array( 0, 14, 24, 22 );
15
+ var patch6 = new Array( 2, 24, 22, 13, 11, 22, 20 );
16
+ var patch7 = new Array( 0, 14, 22 );
17
+ var patch8 = new Array( 6, 8, 18, 16 );
18
+ var patch9 = new Array( 4, 20, 10, 12, 2 );
19
+ var patch10 = new Array( 0, 2, 12, 10 );
20
+ var patch11 = new Array( 10, 14, 22 );
21
+ var patch12 = new Array( 20, 12, 24 );
22
+ var patch13 = new Array( 10, 2, 12 );
23
+ var patch14 = new Array( 0, 2, 10 );
24
+ var patchTypes = new Array( patch0, patch1, patch2, patch3, patch4,
25
+ patch5, patch6, patch7, patch8, patch9, patch10, patch11,
26
+ patch12, patch13, patch14, patch0 );
27
+ var centerPatchTypes = new Array(0, 4, 8, 15);
28
+
29
+ function render_identicon_patch(ctx, x, y, size, patch, turn, invert, foreColor, backColor) {
30
+ patch %= patchTypes.length;
31
+ turn %= 4;
32
+ if (patch == 15)
33
+ invert = !invert;
34
+
35
+ var vertices = patchTypes[patch];
36
+ var offset = size / 2;
37
+ var scale = size / 4;
38
+
39
+ ctx.save();
40
+
41
+ // paint background
42
+ ctx.fillStyle = invert ? foreColor : backColor;
43
+ ctx.fillRect(x, y, size, size);
44
+
45
+ // build patch path
46
+ ctx.translate(x + offset, y + offset);
47
+ ctx.rotate(turn * Math.PI / 2);
48
+ ctx.beginPath();
49
+ ctx.moveTo((vertices[0] % 5 * scale - offset), (Math.floor(vertices[0] / 5) * scale - offset));
50
+ for (var i = 1; i < vertices.length; i++)
51
+ ctx.lineTo((vertices[i] % 5 * scale - offset), (Math.floor(vertices[i] / 5) * scale - offset));
52
+ ctx.closePath();
53
+
54
+ // offset and rotate coordinate space by patch position (x, y) and
55
+ // 'turn' before rendering patch shape
56
+
57
+ // render rotated patch using fore color (back color if inverted)
58
+ ctx.fillStyle = invert ? backColor : foreColor;
59
+ ctx.fill();
60
+
61
+ // restore rotation
62
+ ctx.restore();
63
+ }
64
+
65
+ function render_identicon(node, code, size) {
66
+ if (!node || !code || !size) return;
67
+
68
+ var patchSize = size / 3;
69
+ var middleType = centerPatchTypes[code & 3];
70
+ var middleInvert = ((code >> 2) & 1) != 0;
71
+ var cornerType = (code >> 3) & 15;
72
+ var cornerInvert = ((code >> 7) & 1) != 0;
73
+ var cornerTurn = (code >> 8) & 3;
74
+ var sideType = (code >> 10) & 15;
75
+ var sideInvert = ((code >> 14) & 1) != 0;
76
+ var sideTurn = (code >> 15) & 3;
77
+ var blue = (code >> 16) & 31;
78
+ var green = (code >> 21) & 31;
79
+ var red = (code >> 27) & 31;
80
+ var foreColor = "rgb(" + (red << 3) + "," + (green << 3) + "," + (blue << 3) + ")";
81
+ var backColor = "rgb(255,255,255)";
82
+
83
+ var ctx = node.getContext("2d");
84
+
85
+ // middle patch
86
+ render_identicon_patch(ctx, patchSize, patchSize, patchSize, middleType, 0, middleInvert, foreColor, backColor);
87
+ // side patchs, starting from top and moving clock-wise
88
+ render_identicon_patch(ctx, patchSize, 0, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
89
+ render_identicon_patch(ctx, patchSize * 2, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
90
+ render_identicon_patch(ctx, patchSize, patchSize * 2, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
91
+ render_identicon_patch(ctx, 0, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
92
+ // corner patchs, starting from top left and moving clock-wise
93
+ render_identicon_patch(ctx, 0, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
94
+ render_identicon_patch(ctx, patchSize * 2, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
95
+ render_identicon_patch(ctx, patchSize * 2, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
96
+ render_identicon_patch(ctx, 0, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
97
+ }
98
+
99
+ function render_identicon_canvases(prefix) {
100
+ var canvases = document.getElementsByTagName("canvas");
101
+ var n = canvases.length;
102
+ for (var i = 0; i < n; i++) {
103
+ var node = canvases[i];
104
+ if (node.title && node.title.indexOf(prefix) == 0) {
105
+ if (node.style.display == 'none') node.style.display = "inline";
106
+ var code = node.title.substring(prefix.length) * 1;
107
+ var size = node.width;
108
+ render_identicon(node, code, size);
109
+ }
110
+ }
111
+ }
@@ -1,58 +1,58 @@
1
- /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
- *
4
- * The contents of this file are subject to the Mozilla Public License Version
5
- * 1.1 (the "License"); you may not use this file except in compliance with
6
- * the License. You may obtain a copy of the License at
7
- * http://www.mozilla.org/MPL/
8
- *
9
- * Software distributed under the License is distributed on an "AS IS" basis,
10
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
- * for the specific language governing rights and limitations under the
12
- * License.
13
- *
14
- * The Original Code is Ajax.org Code Editor (ACE).
15
- *
16
- * The Initial Developer of the Original Code is
17
- * Ajax.org B.V.
18
- * Portions created by the Initial Developer are Copyright (C) 2010
19
- * the Initial Developer. All Rights Reserved.
20
- *
21
- * Contributor(s):
22
- *
23
- * Alternatively, the contents of this file may be used under the terms of
24
- * either the GNU General Public License Version 2 or later (the "GPL"), or
25
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
- * in which case the provisions of the GPL or the LGPL are applicable instead
27
- * of those above. If you wish to allow use of your version of this file only
28
- * under the terms of either the GPL or the LGPL, and not to allow others to
29
- * use your version of this file under the terms of the MPL, indicate your
30
- * decision by deleting the provisions above and replace them with the notice
31
- * and other provisions required by the GPL or the LGPL. If you do not delete
32
- * the provisions above, a recipient may use your version of this file under
33
- * the terms of any one of the MPL, the GPL or the LGPL.
34
- *
35
- * ***** END LICENSE BLOCK ***** */
36
-
37
- define(function(require, exports, module) {
38
- "use strict";
39
-
40
- var oop = require("../lib/oop");
41
- var TextMode = require("./text").Mode;
42
- var Tokenizer = require("../tokenizer").Tokenizer;
43
- var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
44
- var FoldMode = require("./folding/diff").FoldMode;
45
-
46
- var Mode = function() {
47
- this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i");
48
- this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
49
- };
50
- oop.inherits(Mode, TextMode);
51
-
52
- (function() {
53
-
54
- }).call(Mode.prototype);
55
-
56
- exports.Mode = Mode;
57
-
58
- });
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
+ *
4
+ * The contents of this file are subject to the Mozilla Public License Version
5
+ * 1.1 (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ * http://www.mozilla.org/MPL/
8
+ *
9
+ * Software distributed under the License is distributed on an "AS IS" basis,
10
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
+ * for the specific language governing rights and limitations under the
12
+ * License.
13
+ *
14
+ * The Original Code is Ajax.org Code Editor (ACE).
15
+ *
16
+ * The Initial Developer of the Original Code is
17
+ * Ajax.org B.V.
18
+ * Portions created by the Initial Developer are Copyright (C) 2010
19
+ * the Initial Developer. All Rights Reserved.
20
+ *
21
+ * Contributor(s):
22
+ *
23
+ * Alternatively, the contents of this file may be used under the terms of
24
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
25
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
+ * in which case the provisions of the GPL or the LGPL are applicable instead
27
+ * of those above. If you wish to allow use of your version of this file only
28
+ * under the terms of either the GPL or the LGPL, and not to allow others to
29
+ * use your version of this file under the terms of the MPL, indicate your
30
+ * decision by deleting the provisions above and replace them with the notice
31
+ * and other provisions required by the GPL or the LGPL. If you do not delete
32
+ * the provisions above, a recipient may use your version of this file under
33
+ * the terms of any one of the MPL, the GPL or the LGPL.
34
+ *
35
+ * ***** END LICENSE BLOCK ***** */
36
+
37
+ define(function(require, exports, module) {
38
+ "use strict";
39
+
40
+ var oop = require("../lib/oop");
41
+ var TextMode = require("./text").Mode;
42
+ var Tokenizer = require("../tokenizer").Tokenizer;
43
+ var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
44
+ var FoldMode = require("./folding/diff").FoldMode;
45
+
46
+ var Mode = function() {
47
+ this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i");
48
+ this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
49
+ };
50
+ oop.inherits(Mode, TextMode);
51
+
52
+ (function() {
53
+
54
+ }).call(Mode.prototype);
55
+
56
+ exports.Mode = Mode;
57
+
58
+ });
@@ -1,108 +1,108 @@
1
- /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
- *
4
- * The contents of this file are subject to the Mozilla Public License Version
5
- * 1.1 (the "License"); you may not use this file except in compliance with
6
- * the License. You may obtain a copy of the License at
7
- * http://www.mozilla.org/MPL/
8
- *
9
- * Software distributed under the License is distributed on an "AS IS" basis,
10
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
- * for the specific language governing rights and limitations under the
12
- * License.
13
- *
14
- * The Original Code is Ajax.org Code Editor (ACE).
15
- *
16
- * The Initial Developer of the Original Code is
17
- * Ajax.org B.V.
18
- * Portions created by the Initial Developer are Copyright (C) 2010
19
- * the Initial Developer. All Rights Reserved.
20
- *
21
- * Contributor(s):
22
- *
23
- * Alternatively, the contents of this file may be used under the terms of
24
- * either the GNU General Public License Version 2 or later (the "GPL"), or
25
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
- * in which case the provisions of the GPL or the LGPL are applicable instead
27
- * of those above. If you wish to allow use of your version of this file only
28
- * under the terms of either the GPL or the LGPL, and not to allow others to
29
- * use your version of this file under the terms of the MPL, indicate your
30
- * decision by deleting the provisions above and replace them with the notice
31
- * and other provisions required by the GPL or the LGPL. If you do not delete
32
- * the provisions above, a recipient may use your version of this file under
33
- * the terms of any one of the MPL, the GPL or the LGPL.
34
- *
35
- * ***** END LICENSE BLOCK ***** */
36
-
37
- define(function(require, exports, module) {
38
- "use strict";
39
-
40
- var oop = require("../lib/oop");
41
- var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
42
-
43
- var DiffHighlightRules = function() {
44
- // regexp must not have capturing parentheses. Use (?:) instead.
45
- // regexps are ordered -> the first match is used
46
-
47
- this.$rules = {
48
- "start" : [{
49
- "regex": "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
50
- "token": "punctuation.definition.separator.diff",
51
- "name": "keyword"
52
- }, { //diff.range.unified
53
- "regex": "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
54
- "token": [
55
- "constant",
56
- "constant.numeric",
57
- "constant",
58
- "comment.doc.tag"
59
- ]
60
- }, { //diff.range.normal
61
- "regex": "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
62
- "token": [
63
- "constant.numeric",
64
- "punctuation.definition.range.diff",
65
- "constant.function",
66
- "constant.numeric",
67
- "punctuation.definition.range.diff",
68
- "invalid"
69
- ],
70
- "name": "meta."
71
- }, {
72
- "regex": "^(?:(\\-{3}|\\+{3}|\\*{3})( .+))$",
73
- "token": [
74
- "constant.numeric",
75
- "meta.tag"
76
- ]
77
- }, { // added
78
- "regex": "^([!+>])(.*?)(\\s*)$",
79
- "token": [
80
- "support.constant",
81
- "text",
82
- "invalid"
83
- ],
84
- }, { // removed
85
- "regex": "^([<\\-])(.*?)(\\s*)$",
86
- "token": [
87
- "support.function",
88
- "string",
89
- "invalid"
90
- ],
91
- }, {
92
- "regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
93
- "token": ["variable", "variable", "keyword", "variable"]
94
- }, {
95
- "regex": "^Index.+$",
96
- "token": "variable"
97
- }, {
98
- "regex": "^(.*?)(\\s*)$",
99
- "token": ["invisible", "invalid"]
100
- }
101
- ]
102
- };
103
- };
104
-
105
- oop.inherits(DiffHighlightRules, TextHighlightRules);
106
-
107
- exports.DiffHighlightRules = DiffHighlightRules;
108
- });
1
+ /* ***** BEGIN LICENSE BLOCK *****
2
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
+ *
4
+ * The contents of this file are subject to the Mozilla Public License Version
5
+ * 1.1 (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ * http://www.mozilla.org/MPL/
8
+ *
9
+ * Software distributed under the License is distributed on an "AS IS" basis,
10
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
+ * for the specific language governing rights and limitations under the
12
+ * License.
13
+ *
14
+ * The Original Code is Ajax.org Code Editor (ACE).
15
+ *
16
+ * The Initial Developer of the Original Code is
17
+ * Ajax.org B.V.
18
+ * Portions created by the Initial Developer are Copyright (C) 2010
19
+ * the Initial Developer. All Rights Reserved.
20
+ *
21
+ * Contributor(s):
22
+ *
23
+ * Alternatively, the contents of this file may be used under the terms of
24
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
25
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
+ * in which case the provisions of the GPL or the LGPL are applicable instead
27
+ * of those above. If you wish to allow use of your version of this file only
28
+ * under the terms of either the GPL or the LGPL, and not to allow others to
29
+ * use your version of this file under the terms of the MPL, indicate your
30
+ * decision by deleting the provisions above and replace them with the notice
31
+ * and other provisions required by the GPL or the LGPL. If you do not delete
32
+ * the provisions above, a recipient may use your version of this file under
33
+ * the terms of any one of the MPL, the GPL or the LGPL.
34
+ *
35
+ * ***** END LICENSE BLOCK ***** */
36
+
37
+ define(function(require, exports, module) {
38
+ "use strict";
39
+
40
+ var oop = require("../lib/oop");
41
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
42
+
43
+ var DiffHighlightRules = function() {
44
+ // regexp must not have capturing parentheses. Use (?:) instead.
45
+ // regexps are ordered -> the first match is used
46
+
47
+ this.$rules = {
48
+ "start" : [{
49
+ "regex": "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
50
+ "token": "punctuation.definition.separator.diff",
51
+ "name": "keyword"
52
+ }, { //diff.range.unified
53
+ "regex": "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
54
+ "token": [
55
+ "constant",
56
+ "constant.numeric",
57
+ "constant",
58
+ "comment.doc.tag"
59
+ ]
60
+ }, { //diff.range.normal
61
+ "regex": "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
62
+ "token": [
63
+ "constant.numeric",
64
+ "punctuation.definition.range.diff",
65
+ "constant.function",
66
+ "constant.numeric",
67
+ "punctuation.definition.range.diff",
68
+ "invalid"
69
+ ],
70
+ "name": "meta."
71
+ }, {
72
+ "regex": "^(?:(\\-{3}|\\+{3}|\\*{3})( .+))$",
73
+ "token": [
74
+ "constant.numeric",
75
+ "meta.tag"
76
+ ]
77
+ }, { // added
78
+ "regex": "^([!+>])(.*?)(\\s*)$",
79
+ "token": [
80
+ "support.constant",
81
+ "text",
82
+ "invalid"
83
+ ],
84
+ }, { // removed
85
+ "regex": "^([<\\-])(.*?)(\\s*)$",
86
+ "token": [
87
+ "support.function",
88
+ "string",
89
+ "invalid"
90
+ ],
91
+ }, {
92
+ "regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
93
+ "token": ["variable", "variable", "keyword", "variable"]
94
+ }, {
95
+ "regex": "^Index.+$",
96
+ "token": "variable"
97
+ }, {
98
+ "regex": "^(.*?)(\\s*)$",
99
+ "token": ["invisible", "invalid"]
100
+ }
101
+ ]
102
+ };
103
+ };
104
+
105
+ oop.inherits(DiffHighlightRules, TextHighlightRules);
106
+
107
+ exports.DiffHighlightRules = DiffHighlightRules;
108
+ });
@@ -298,6 +298,8 @@ var makePreviewHtml = function () {
298
298
  }
299
299
 
300
300
  var prevTime = new Date().getTime();
301
+ // Handle gollum file code insertion syntax.
302
+ text = text.replace(/^[ \t]*``` ?([^:\n\r]+:[^`\n\r]+)```/gm, '``$1``');
301
303
  text = md_to_html( text );
302
304
 
303
305
  // Calculate the processing time of the HTML creation.
@@ -5,6 +5,7 @@
5
5
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/gollum.css" media="all">
6
6
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
7
7
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/_styles.css" media="all">
8
+ {{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
8
9
  <title>{{title}}</title>
9
10
  </head>
10
11
  <body>
@@ -30,11 +30,7 @@
30
30
  <input type="checkbox" name="versions[]" value="{{id}}">
31
31
  </td>
32
32
  <td class="author">
33
- <a href="javascript:void(0)">
34
- <img src="https://secure.gravatar.com/avatar/{{gravatar}}?s=16"
35
- alt="avatar: {{author}}" class="mini-gravatar">
36
- <span class="username">{{author}}</span>
37
- </a>
33
+ {{>author_template}}
38
34
  </td>
39
35
  <td class="commit-name">
40
36
  <span class="time-elapsed">{{date}}:</span>&nbsp;
@@ -0,0 +1,5 @@
1
+ <a href="javascript:void(0)">
2
+ <img src="https://secure.gravatar.com/avatar/{{gravatar}}?s=16"
3
+ alt="avatar: {{author}}" class="mini-gravatar"/>
4
+ <span class="username">{{author}}</span>
5
+ </a>
@@ -0,0 +1,5 @@
1
+ <a href="javascript:void(0)">
2
+ <img src="{{base_url}}/images/man_24.png" alt="avatar: {{author}}"
3
+ class="mini-gravatar identicon" data-identicon="{{identicon}}"/>
4
+ <span class="username">{{author}}</span>
5
+ </a>
@@ -0,0 +1,3 @@
1
+ <a href="javascript:void(0)">
2
+ <span class="username">{{author}}</span>
3
+ </a>
@@ -19,6 +19,9 @@
19
19
  <script type="text/javascript" src="{{base_url}}/javascript/gollum.dialog.js"></script>
20
20
  <script type="text/javascript" src="{{base_url}}/javascript/gollum.placeholder.js"></script>
21
21
  <script type="text/javascript" src="{{base_url}}/javascript/editor/gollum.editor.js"></script>
22
+ {{#use_identicon}}
23
+ <script type="text/javascript" src="{{base_url}}/javascript/identicon_canvas.js"></script>
24
+ {{/use_identicon}}
22
25
  {{#mathjax}}
23
26
  <script type="text/x-mathjax-config">
24
27
  MathJax.Hub.Config({
@@ -19,8 +19,47 @@ module Precious
19
19
  :selected => @page.version.id == v.id,
20
20
  :author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
21
21
  :message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
22
- :date => v.committed_date.strftime("%B %d, %Y"),
23
- :gravatar => Digest::MD5.hexdigest(v.author.email) }
22
+ :date => v.authored_date.strftime("%B %d, %Y"),
23
+ :gravatar => Digest::MD5.hexdigest(v.author.email),
24
+ :identicon => self._identicon_code(v.author.email),
25
+ }
26
+ end
27
+ end
28
+
29
+ # http://stackoverflow.com/questions/9445760/bit-shifting-in-ruby
30
+ def left_shift int, shift
31
+ r = ((int & 0xFF) << (shift & 0x1F)) & 0xFFFFFFFF
32
+ # 1>>31, 2**32
33
+ (r & 2147483648) == 0 ? r : r - 4294967296
34
+ end
35
+
36
+ def string_to_code string
37
+ # sha bytes
38
+ b = [Digest::SHA1.hexdigest(string)[0,20]].pack('H*').bytes.to_a
39
+ # Thanks donpark's IdenticonUtil.java for this.
40
+ # Match the following Java code
41
+ # ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) |
42
+ # ((b[2] & 0xFF) << 8) | (b[3] & 0xFF)
43
+
44
+ return left_shift(b[0], 24) |
45
+ left_shift(b[1], 16) |
46
+ left_shift(b[2], 8) |
47
+ b[3] & 0xFF
48
+ end
49
+
50
+ def _identicon_code(blob)
51
+ string_to_code blob + @request.host
52
+ end
53
+
54
+ def use_identicon
55
+ @page.wiki.user_icons == 'identicon'
56
+ end
57
+
58
+ def partial(name)
59
+ if name == :author_template
60
+ self.class.partial("history_authors/#{@page.wiki.user_icons}")
61
+ else
62
+ super
24
63
  end
25
64
  end
26
65
 
@@ -23,6 +23,11 @@ module Precious
23
23
  def base_url
24
24
  @base_url
25
25
  end
26
+
27
+ def css # custom css
28
+ @css
29
+ end
30
+
26
31
  end
27
32
  end
28
33
  end
@@ -89,8 +89,8 @@ module Precious
89
89
  @mathjax
90
90
  end
91
91
 
92
- def css # custom css
93
- @css
92
+ def use_identicon
93
+ @page.wiki.user_icons == 'identicon'
94
94
  end
95
95
 
96
96
  # Access to embedded metadata.
data/lib/gollum/markup.rb CHANGED
@@ -395,12 +395,12 @@ module Gollum
395
395
  # name - The String absolute or relative path of the file.
396
396
  #
397
397
  # Returns the Gollum::File or nil if none was found.
398
- def find_file(name)
398
+ def find_file(name, version=@version)
399
399
  if name =~ /^\//
400
- @wiki.file(name[1..-1], @version)
400
+ @wiki.file(name[1..-1], version)
401
401
  else
402
402
  path = @dir == '.' ? name : ::File.join(@dir, name)
403
- @wiki.file(path, @version)
403
+ @wiki.file(path, version)
404
404
  end
405
405
  end
406
406
 
@@ -435,6 +435,10 @@ module Gollum
435
435
  #
436
436
  # Gitcode - fetch code from github search path and replace the contents
437
437
  # to a code-block that gets run the next parse.
438
+ # Acceptable formats:
439
+ # ```language:local-file.ext```
440
+ # ```language:/abs/other-file.ext```
441
+ # ```language:github/gollum/master/somefile.txt```
438
442
  #
439
443
  #########################################################################
440
444
 
@@ -445,12 +449,12 @@ module Gollum
445
449
  uri = $2 || ''
446
450
  # Detect local file.
447
451
  if uri[0..6] != 'github/'
448
- if uri[0..0] != '/' # relative file
449
- contents = @wiki.page(uri).formatted_data
450
- else # use full path
451
- contents = @wiki.paged( extract_name( clean_url( uri ) ),
452
- '/' + clean_url( extract_path( uri ) ) ).formatted_data
453
- end
452
+ if file = self.find_file(uri, @wiki.ref)
453
+ contents = file.raw_data
454
+ else
455
+ # How do we communicate a render error?
456
+ next "File not found: #{Rack::Utils::escape_html(uri)}"
457
+ end
454
458
  else
455
459
  contents = Gollum::Gitcode.new(uri).contents
456
460
  end
@@ -105,7 +105,7 @@ module Gollum
105
105
  attr_reader :transformers
106
106
 
107
107
  # Gets or sets a String prefix which is added to ID attributes.
108
- # Default: 'wiki-'
108
+ # Default: ''
109
109
  attr_accessor :id_prefix
110
110
 
111
111
  # Gets a Hash describing HTML attributes that Sanitize should add.
@@ -128,7 +128,7 @@ module Gollum
128
128
  @add_attributes = {}
129
129
  @remove_contents = REMOVE_CONTENTS.dup
130
130
  @allow_comments = false
131
- @id_prefix = 'wiki-'
131
+ @id_prefix = ''
132
132
  yield self if block_given?
133
133
  end
134
134
 
data/lib/gollum/wiki.rb CHANGED
@@ -163,6 +163,8 @@ module Gollum
163
163
  # :ref - String the repository ref to retrieve pages from
164
164
  # :ws_subs - Array of chars to sub for ws in filenames.
165
165
  # :mathjax - Set to false to disable mathjax.
166
+ # :user_icons - Enable user icons on the history page. [gravatar, identicon, none].
167
+ # Default: none
166
168
  # :show_all - Show all files in file view, not just valid pages.
167
169
  # Default: false
168
170
  # :collapse_tree - Start with collapsed file view. Default: false
@@ -201,6 +203,9 @@ module Gollum
201
203
  @collapse_tree = options.fetch :collapse_tree, false
202
204
  @css = options.fetch :css, false
203
205
  @h1_title = options.fetch :h1_title, false
206
+
207
+ @user_icons = ['gravatar', 'identicon'].include?( options[:user_icons] ) ?
208
+ options[:user_icons] : 'none'
204
209
  end
205
210
 
206
211
  # Public: check whether the wiki's git repo exists on the filesystem.
@@ -277,10 +282,11 @@ module Gollum
277
282
  # :committer - Optional Gollum::Committer instance. If provided,
278
283
  # assume that this operation is part of batch of
279
284
  # updates and the commit happens later.
280
- #
285
+ # dir - The String subdirectory of the Gollum::Page without any
286
+ # prefix or suffix slashes (e.g. "foo/bar").
281
287
  # Returns the String SHA1 of the newly written version, or the
282
288
  # Gollum::Committer instance if this is part of a batch update.
283
- def write_page(name, format, data, commit = {})
289
+ def write_page(name, format, data, commit = {}, dir = '')
284
290
  multi_commit = false
285
291
 
286
292
  committer = if obj = commit[:committer]
@@ -292,7 +298,7 @@ module Gollum
292
298
 
293
299
  filename = Gollum::Page.cname(name)
294
300
 
295
- committer.add_to_index('', filename, format, data)
301
+ committer.add_to_index(dir, filename, format, data)
296
302
 
297
303
  committer.after_commit do |index, sha|
298
304
  @access.refresh
@@ -609,6 +615,9 @@ module Gollum
609
615
  # Toggles mathjax.
610
616
  attr_reader :mathjax
611
617
 
618
+ # Toggles user icons. Default: 'none'
619
+ attr_reader :user_icons
620
+
612
621
  # Toggles showing all files in files view. Default is false.
613
622
  # When false, only valid pages in the git repo are displayed.
614
623
  attr_reader :show_all
@@ -30,3 +30,23 @@ http://www.thecssninja.com/css/css-tree-menu
30
30
  http://www.thecssninja.com/demo/license.txt
31
31
 
32
32
  lib/gollum/frontend/public/css/_styles.css
33
+
34
+ ---
35
+
36
+ Default profile image (man_24.png) is used under the CC BY-SA 3.0 Unported license.
37
+
38
+ CC BY-SA 3.0 Unported
39
+ http://blog.twg.ca/2010/11/retina-display-icon-set/
40
+ http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
41
+
42
+ lib/gollum/frontend/public/images/man_24.png
43
+
44
+ ---
45
+
46
+ The canvas_identicon code is used under the MIT license.
47
+
48
+ https://github.com/donpark/identicon/blob/master/identicon-canvas/identicon_canvas.js
49
+ https://github.com/donpark/identicon/blob/master/README
50
+
51
+ lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
52
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-11 00:00:00.000000000 Z
13
+ date: 2012-11-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: grit
@@ -57,7 +57,7 @@ dependencies:
57
57
  requirements:
58
58
  - - ~>
59
59
  - !ruby/object:Gem::Version
60
- version: 0.5.1
60
+ version: 0.5.3
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
@@ -65,7 +65,7 @@ dependencies:
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 0.5.1
68
+ version: 0.5.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pygments.rb
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +159,7 @@ dependencies:
159
159
  requirements:
160
160
  - - ~>
161
161
  - !ruby/object:Gem::Version
162
- version: 0.4.12
162
+ version: 0.4.13
163
163
  type: :runtime
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
@@ -167,7 +167,7 @@ dependencies:
167
167
  requirements:
168
168
  - - ~>
169
169
  - !ruby/object:Gem::Version
170
- version: 0.4.12
170
+ version: 0.4.13
171
171
  - !ruby/object:Gem::Dependency
172
172
  name: stringex
173
173
  requirement: !ruby/object:Gem::Requirement
@@ -207,7 +207,7 @@ dependencies:
207
207
  requirements:
208
208
  - - ~>
209
209
  - !ruby/object:Gem::Version
210
- version: 0.12.7
210
+ version: 0.13.0
211
211
  type: :development
212
212
  prerelease: false
213
213
  version_requirements: !ruby/object:Gem::Requirement
@@ -215,7 +215,7 @@ dependencies:
215
215
  requirements:
216
216
  - - ~>
217
217
  - !ruby/object:Gem::Version
218
- version: 0.12.7
218
+ version: 0.13.0
219
219
  - !ruby/object:Gem::Dependency
220
220
  name: org-ruby
221
221
  requirement: !ruby/object:Gem::Requirement
@@ -239,7 +239,7 @@ dependencies:
239
239
  requirements:
240
240
  - - ~>
241
241
  - !ruby/object:Gem::Version
242
- version: 3.3.1
242
+ version: 3.3.2
243
243
  type: :development
244
244
  prerelease: false
245
245
  version_requirements: !ruby/object:Gem::Requirement
@@ -247,7 +247,7 @@ dependencies:
247
247
  requirements:
248
248
  - - ~>
249
249
  - !ruby/object:Gem::Version
250
- version: 3.3.1
250
+ version: 3.3.2
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: rack-test
253
253
  requirement: !ruby/object:Gem::Requirement
@@ -287,7 +287,7 @@ dependencies:
287
287
  requirements:
288
288
  - - ~>
289
289
  - !ruby/object:Gem::Version
290
- version: '0.9'
290
+ version: 10.0.2
291
291
  type: :development
292
292
  prerelease: false
293
293
  version_requirements: !ruby/object:Gem::Requirement
@@ -295,7 +295,7 @@ dependencies:
295
295
  requirements:
296
296
  - - ~>
297
297
  - !ruby/object:Gem::Version
298
- version: '0.9'
298
+ version: 10.0.2
299
299
  - !ruby/object:Gem::Dependency
300
300
  name: pry
301
301
  requirement: !ruby/object:Gem::Requirement
@@ -365,6 +365,7 @@ files:
365
365
  - lib/gollum/frontend/public/gollum/images/fileview/toggle-small-expand.png
366
366
  - lib/gollum/frontend/public/gollum/images/fileview/toggle-small.png
367
367
  - lib/gollum/frontend/public/gollum/images/icon-sprite.png
368
+ - lib/gollum/frontend/public/gollum/images/man_24.png
368
369
  - lib/gollum/frontend/public/gollum/images/para.png
369
370
  - lib/gollum/frontend/public/gollum/images/pin-16.png
370
371
  - lib/gollum/frontend/public/gollum/images/pin-20.png
@@ -381,6 +382,7 @@ files:
381
382
  - lib/gollum/frontend/public/gollum/javascript/gollum.dialog.js
382
383
  - lib/gollum/frontend/public/gollum/javascript/gollum.js
383
384
  - lib/gollum/frontend/public/gollum/javascript/gollum.placeholder.js
385
+ - lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
384
386
  - lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js
385
387
  - lib/gollum/frontend/public/gollum/javascript/jquery.color.js
386
388
  - lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
@@ -728,6 +730,9 @@ files:
728
730
  - lib/gollum/frontend/templates/error.mustache
729
731
  - lib/gollum/frontend/templates/file_view.mustache
730
732
  - lib/gollum/frontend/templates/history.mustache
733
+ - lib/gollum/frontend/templates/history_authors/gravatar.mustache
734
+ - lib/gollum/frontend/templates/history_authors/identicon.mustache
735
+ - lib/gollum/frontend/templates/history_authors/none.mustache
731
736
  - lib/gollum/frontend/templates/layout.mustache
732
737
  - lib/gollum/frontend/templates/page.mustache
733
738
  - lib/gollum/frontend/templates/pages.mustache