Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 06e72a5a60 | |||
| 8fa62fc300 | |||
| 6c345fc508 | |||
| a34eac4ecb | |||
| 10c121e603 | |||
| 2b910167f4 | |||
| 7d5311a075 | |||
| f5581c4b49 | |||
| e09f7cd49c | |||
| 4dab03b61b | |||
| 2b5e017aa1 | |||
| 8b3d944fd2 | |||
| 2d886fd38a | |||
| 80088832b9 | |||
| be1883f317 | |||
| 30119e0c77 | |||
| c90c3b1544 | |||
| 578386f083 | |||
| 3d21ed362e | |||
| 9cf469b035 | |||
| 462c93ae43 | |||
| bda3b7b24d | |||
| d861a22cdd | |||
| 0de1a182da | |||
| b030554348 | |||
| 858bfa9ccd | |||
| ee8ec78da7 | |||
| c8f684895c | |||
| 138a155ba4 | |||
| ad749bf345 | |||
| ff0d59c16b |
@@ -1,4 +1,11 @@
|
||||
# https://help.github.com/articles/dealing-with-line-endings
|
||||
#
|
||||
# For Mac & Linux
|
||||
# git config --global core.autocrlf input
|
||||
#
|
||||
# For windows
|
||||
# git config --global core.autocrlf true
|
||||
#
|
||||
# Set default behaviour, in case users don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
|
||||
+2
-1
@@ -5,4 +5,5 @@ notifications:
|
||||
disabled: true
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y --force-yes asciidoc
|
||||
- sudo apt-get install -y --force-yes asciidoc
|
||||
- ASCIIDOC=1; export ASCIIDOC
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
source 'http://rubygems.org'
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gemspec
|
||||
gem 'rake', '~> 0.9'
|
||||
gem 'rake', '~> 10.0.2'
|
||||
|
||||
+5
-1
@@ -73,6 +73,10 @@ opts = OptionParser.new do |opts|
|
||||
wiki_options[:mathjax] = true
|
||||
end
|
||||
|
||||
opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source|
|
||||
wiki_options[:user_icons] = source
|
||||
end
|
||||
|
||||
opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do
|
||||
wiki_options[:show_all] = true
|
||||
end
|
||||
@@ -181,6 +185,6 @@ else
|
||||
end
|
||||
end
|
||||
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
|
||||
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port']).start
|
||||
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start
|
||||
end
|
||||
end
|
||||
|
||||
+12
-7
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = ">= 1.8.7"
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '2.4.0'
|
||||
s.date = '2012-11-11'
|
||||
s.version = '2.4.1'
|
||||
s.date = '2012-11-19'
|
||||
s.rubyforge_project = 'gollum'
|
||||
|
||||
s.summary = "A simple, Git-powered wiki."
|
||||
@@ -25,22 +25,22 @@ Gem::Specification.new do |s|
|
||||
|
||||
s.add_dependency('grit', '~> 2.5.0')
|
||||
s.add_dependency('github-markup', ['>= 0.7.4', '< 1.0.0'])
|
||||
s.add_dependency('github-markdown', '~> 0.5.1')
|
||||
s.add_dependency('github-markdown', '~> 0.5.3')
|
||||
s.add_dependency('pygments.rb', '~> 0.3.2')
|
||||
s.add_dependency('sinatra', '~> 1.3.3')
|
||||
s.add_dependency('mustache', ['>= 0.99.4', '< 1.0.0'])
|
||||
s.add_dependency('sanitize', '~> 2.0.3')
|
||||
s.add_dependency('nokogiri', '~> 1.5.5')
|
||||
s.add_dependency('useragent', '~> 0.4.12')
|
||||
s.add_dependency('useragent', '~> 0.4.13')
|
||||
s.add_dependency('stringex', '~> 1.4.0')
|
||||
|
||||
s.add_development_dependency('RedCloth', '~> 4.2.9')
|
||||
s.add_development_dependency('mocha', '~> 0.12.7')
|
||||
s.add_development_dependency('mocha', '~> 0.13.0')
|
||||
s.add_development_dependency('org-ruby', '~> 0.7.2')
|
||||
s.add_development_dependency('shoulda', '~> 3.3.1')
|
||||
s.add_development_dependency('shoulda', '~> 3.3.2')
|
||||
s.add_development_dependency('rack-test', '~> 0.6.2')
|
||||
s.add_development_dependency('wikicloth', '~> 0.8.0')
|
||||
s.add_development_dependency('rake', '~> 0.9')
|
||||
s.add_development_dependency('rake', '~> 10.0.2')
|
||||
s.add_development_dependency('pry', '~> 0.9.10')
|
||||
# required by pry
|
||||
s.add_development_dependency('rb-readline', '~> 0.4.2')
|
||||
@@ -75,6 +75,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/public/gollum/images/fileview/toggle-small-expand.png
|
||||
lib/gollum/frontend/public/gollum/images/fileview/toggle-small.png
|
||||
lib/gollum/frontend/public/gollum/images/icon-sprite.png
|
||||
lib/gollum/frontend/public/gollum/images/man_24.png
|
||||
lib/gollum/frontend/public/gollum/images/para.png
|
||||
lib/gollum/frontend/public/gollum/images/pin-16.png
|
||||
lib/gollum/frontend/public/gollum/images/pin-20.png
|
||||
@@ -91,6 +92,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/public/gollum/javascript/gollum.dialog.js
|
||||
lib/gollum/frontend/public/gollum/javascript/gollum.js
|
||||
lib/gollum/frontend/public/gollum/javascript/gollum.placeholder.js
|
||||
lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
|
||||
lib/gollum/frontend/public/gollum/javascript/jquery-1.7.2.min.js
|
||||
lib/gollum/frontend/public/gollum/javascript/jquery.color.js
|
||||
lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
|
||||
@@ -438,6 +440,9 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/templates/error.mustache
|
||||
lib/gollum/frontend/templates/file_view.mustache
|
||||
lib/gollum/frontend/templates/history.mustache
|
||||
lib/gollum/frontend/templates/history_authors/gravatar.mustache
|
||||
lib/gollum/frontend/templates/history_authors/identicon.mustache
|
||||
lib/gollum/frontend/templates/history_authors/none.mustache
|
||||
lib/gollum/frontend/templates/layout.mustache
|
||||
lib/gollum/frontend/templates/page.mustache
|
||||
lib/gollum/frontend/templates/pages.mustache
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
# stdlib
|
||||
require 'digest/md5'
|
||||
require 'digest/sha1'
|
||||
require 'ostruct'
|
||||
|
||||
# external
|
||||
@@ -23,7 +24,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
||||
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
||||
|
||||
module Gollum
|
||||
VERSION = '2.4.0'
|
||||
VERSION = '2.4.1'
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||
|
||||
@@ -85,6 +85,7 @@ module Precious
|
||||
@base_url = url('/', false).chomp('/')
|
||||
# above will detect base_path when it's used with map in a config.ru
|
||||
settings.wiki_options.merge!({ :base_path => @base_url })
|
||||
@css = settings.wiki_options[:css]
|
||||
end
|
||||
|
||||
get '/' do
|
||||
@@ -196,12 +197,10 @@ module Precious
|
||||
page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||
path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
|
||||
|
||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
wiki = wiki_new
|
||||
|
||||
begin
|
||||
wiki.write_page(name, format, params[:content], commit_message)
|
||||
wiki.write_page(name, format, params[:content], commit_message, path)
|
||||
redirect to("/#{clean_url(::File.join(path,name))}")
|
||||
rescue Gollum::DuplicatePageError => e
|
||||
@message = "Duplicate page: #{e.message}"
|
||||
@@ -238,7 +237,6 @@ module Precious
|
||||
@content = @page.formatted_data
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@mathjax = wiki.mathjax
|
||||
@css = wiki.css
|
||||
@h1_title = wiki.h1_title
|
||||
@editable = false
|
||||
mustache :page
|
||||
@@ -284,10 +282,6 @@ module Precious
|
||||
mustache :compare
|
||||
end
|
||||
|
||||
get %r{^/(javascript|css|images)} do
|
||||
halt 404
|
||||
end
|
||||
|
||||
get %r{/(.+?)/([0-9a-f]{40})} do
|
||||
file_path = params[:captures][0]
|
||||
version = params[:captures][1]
|
||||
@@ -362,7 +356,6 @@ module Precious
|
||||
@content = page.formatted_data
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@mathjax = wiki.mathjax
|
||||
@css = wiki.css
|
||||
@h1_title = wiki.h1_title
|
||||
mustache :page
|
||||
elsif file = wiki.file(fullpath)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 376 B |
@@ -233,6 +233,7 @@
|
||||
$('#gollum-dialog-dialog').animate({ opacity: 1 }, {
|
||||
duration: 500
|
||||
});
|
||||
$($('#gollum-dialog-dialog input[type="text"]').get(0)).focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -228,4 +228,21 @@ $(document).ready(function() {
|
||||
});
|
||||
$.GollumEditor({ NewFile: true, MarkupType: default_markup });
|
||||
}
|
||||
|
||||
if( $('#wiki-history').length ){
|
||||
var lookup = {};
|
||||
$('img.identicon').each(function(index, element){
|
||||
var $item = $(element);
|
||||
var code = parseInt($item.data('identicon'), 10);
|
||||
var img_bin = lookup[code];
|
||||
if( img_bin === undefined ){
|
||||
var size = 16;
|
||||
var canvas = $('<canvas width=16 height=16/>').get(0);
|
||||
render_identicon(canvas, code, 16);
|
||||
img_bin = canvas.toDataURL("image/png");
|
||||
lookup[code] = img_bin;
|
||||
}
|
||||
$item.attr('src', img_bin);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
Client-side Canvas tag based Identicon rendering code
|
||||
|
||||
@author Don Park
|
||||
@version 0.2
|
||||
@date January 21th, 2007
|
||||
*/
|
||||
|
||||
var patch0 = new Array( 0, 4, 24, 20 );
|
||||
var patch1 = new Array( 0, 4, 20 );
|
||||
var patch2 = new Array( 2, 24, 20 );
|
||||
var patch3 = new Array( 0, 2, 20, 22 );
|
||||
var patch4 = new Array( 2, 14, 22, 10 );
|
||||
var patch5 = new Array( 0, 14, 24, 22 );
|
||||
var patch6 = new Array( 2, 24, 22, 13, 11, 22, 20 );
|
||||
var patch7 = new Array( 0, 14, 22 );
|
||||
var patch8 = new Array( 6, 8, 18, 16 );
|
||||
var patch9 = new Array( 4, 20, 10, 12, 2 );
|
||||
var patch10 = new Array( 0, 2, 12, 10 );
|
||||
var patch11 = new Array( 10, 14, 22 );
|
||||
var patch12 = new Array( 20, 12, 24 );
|
||||
var patch13 = new Array( 10, 2, 12 );
|
||||
var patch14 = new Array( 0, 2, 10 );
|
||||
var patchTypes = new Array( patch0, patch1, patch2, patch3, patch4,
|
||||
patch5, patch6, patch7, patch8, patch9, patch10, patch11,
|
||||
patch12, patch13, patch14, patch0 );
|
||||
var centerPatchTypes = new Array(0, 4, 8, 15);
|
||||
|
||||
function render_identicon_patch(ctx, x, y, size, patch, turn, invert, foreColor, backColor) {
|
||||
patch %= patchTypes.length;
|
||||
turn %= 4;
|
||||
if (patch == 15)
|
||||
invert = !invert;
|
||||
|
||||
var vertices = patchTypes[patch];
|
||||
var offset = size / 2;
|
||||
var scale = size / 4;
|
||||
|
||||
ctx.save();
|
||||
|
||||
// paint background
|
||||
ctx.fillStyle = invert ? foreColor : backColor;
|
||||
ctx.fillRect(x, y, size, size);
|
||||
|
||||
// build patch path
|
||||
ctx.translate(x + offset, y + offset);
|
||||
ctx.rotate(turn * Math.PI / 2);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo((vertices[0] % 5 * scale - offset), (Math.floor(vertices[0] / 5) * scale - offset));
|
||||
for (var i = 1; i < vertices.length; i++)
|
||||
ctx.lineTo((vertices[i] % 5 * scale - offset), (Math.floor(vertices[i] / 5) * scale - offset));
|
||||
ctx.closePath();
|
||||
|
||||
// offset and rotate coordinate space by patch position (x, y) and
|
||||
// 'turn' before rendering patch shape
|
||||
|
||||
// render rotated patch using fore color (back color if inverted)
|
||||
ctx.fillStyle = invert ? backColor : foreColor;
|
||||
ctx.fill();
|
||||
|
||||
// restore rotation
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
function render_identicon(node, code, size) {
|
||||
if (!node || !code || !size) return;
|
||||
|
||||
var patchSize = size / 3;
|
||||
var middleType = centerPatchTypes[code & 3];
|
||||
var middleInvert = ((code >> 2) & 1) != 0;
|
||||
var cornerType = (code >> 3) & 15;
|
||||
var cornerInvert = ((code >> 7) & 1) != 0;
|
||||
var cornerTurn = (code >> 8) & 3;
|
||||
var sideType = (code >> 10) & 15;
|
||||
var sideInvert = ((code >> 14) & 1) != 0;
|
||||
var sideTurn = (code >> 15) & 3;
|
||||
var blue = (code >> 16) & 31;
|
||||
var green = (code >> 21) & 31;
|
||||
var red = (code >> 27) & 31;
|
||||
var foreColor = "rgb(" + (red << 3) + "," + (green << 3) + "," + (blue << 3) + ")";
|
||||
var backColor = "rgb(255,255,255)";
|
||||
|
||||
var ctx = node.getContext("2d");
|
||||
|
||||
// middle patch
|
||||
render_identicon_patch(ctx, patchSize, patchSize, patchSize, middleType, 0, middleInvert, foreColor, backColor);
|
||||
// side patchs, starting from top and moving clock-wise
|
||||
render_identicon_patch(ctx, patchSize, 0, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize * 2, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize, patchSize * 2, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, 0, patchSize, patchSize, sideType, sideTurn++, sideInvert, foreColor, backColor);
|
||||
// corner patchs, starting from top left and moving clock-wise
|
||||
render_identicon_patch(ctx, 0, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize * 2, 0, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, patchSize * 2, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
render_identicon_patch(ctx, 0, patchSize * 2, patchSize, cornerType, cornerTurn++, cornerInvert, foreColor, backColor);
|
||||
}
|
||||
|
||||
function render_identicon_canvases(prefix) {
|
||||
var canvases = document.getElementsByTagName("canvas");
|
||||
var n = canvases.length;
|
||||
for (var i = 0; i < n; i++) {
|
||||
var node = canvases[i];
|
||||
if (node.title && node.title.indexOf(prefix) == 0) {
|
||||
if (node.style.display == 'none') node.style.display = "inline";
|
||||
var code = node.title.substring(prefix.length) * 1;
|
||||
var size = node.width;
|
||||
render_identicon(node, code, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,58 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
|
||||
var FoldMode = require("./folding/diff").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i");
|
||||
this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var HighlightRules = require("./diff_highlight_rules").DiffHighlightRules;
|
||||
var FoldMode = require("./folding/diff").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new HighlightRules().getRules(), "i");
|
||||
this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
|
||||
+108
-108
@@ -1,108 +1,108 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DiffHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = {
|
||||
"start" : [{
|
||||
"regex": "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
|
||||
"token": "punctuation.definition.separator.diff",
|
||||
"name": "keyword"
|
||||
}, { //diff.range.unified
|
||||
"regex": "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
|
||||
"token": [
|
||||
"constant",
|
||||
"constant.numeric",
|
||||
"constant",
|
||||
"comment.doc.tag"
|
||||
]
|
||||
}, { //diff.range.normal
|
||||
"regex": "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"constant.function",
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"invalid"
|
||||
],
|
||||
"name": "meta."
|
||||
}, {
|
||||
"regex": "^(?:(\\-{3}|\\+{3}|\\*{3})( .+))$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"meta.tag"
|
||||
]
|
||||
}, { // added
|
||||
"regex": "^([!+>])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.constant",
|
||||
"text",
|
||||
"invalid"
|
||||
],
|
||||
}, { // removed
|
||||
"regex": "^([<\\-])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.function",
|
||||
"string",
|
||||
"invalid"
|
||||
],
|
||||
}, {
|
||||
"regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
|
||||
"token": ["variable", "variable", "keyword", "variable"]
|
||||
}, {
|
||||
"regex": "^Index.+$",
|
||||
"token": "variable"
|
||||
}, {
|
||||
"regex": "^(.*?)(\\s*)$",
|
||||
"token": ["invisible", "invalid"]
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DiffHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.DiffHighlightRules = DiffHighlightRules;
|
||||
});
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DiffHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = {
|
||||
"start" : [{
|
||||
"regex": "^(?:\\*{15}|={67}|-{3}|\\+{3})$",
|
||||
"token": "punctuation.definition.separator.diff",
|
||||
"name": "keyword"
|
||||
}, { //diff.range.unified
|
||||
"regex": "^(@@)(\\s*.+?\\s*)(@@)(.*)$",
|
||||
"token": [
|
||||
"constant",
|
||||
"constant.numeric",
|
||||
"constant",
|
||||
"comment.doc.tag"
|
||||
]
|
||||
}, { //diff.range.normal
|
||||
"regex": "^(\\d+)([,\\d]+)(a|d|c)(\\d+)([,\\d]+)(.*)$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"constant.function",
|
||||
"constant.numeric",
|
||||
"punctuation.definition.range.diff",
|
||||
"invalid"
|
||||
],
|
||||
"name": "meta."
|
||||
}, {
|
||||
"regex": "^(?:(\\-{3}|\\+{3}|\\*{3})( .+))$",
|
||||
"token": [
|
||||
"constant.numeric",
|
||||
"meta.tag"
|
||||
]
|
||||
}, { // added
|
||||
"regex": "^([!+>])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.constant",
|
||||
"text",
|
||||
"invalid"
|
||||
],
|
||||
}, { // removed
|
||||
"regex": "^([<\\-])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.function",
|
||||
"string",
|
||||
"invalid"
|
||||
],
|
||||
}, {
|
||||
"regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
|
||||
"token": ["variable", "variable", "keyword", "variable"]
|
||||
}, {
|
||||
"regex": "^Index.+$",
|
||||
"token": "variable"
|
||||
}, {
|
||||
"regex": "^(.*?)(\\s*)$",
|
||||
"token": ["invisible", "invalid"]
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
||||
|
||||
oop.inherits(DiffHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.DiffHighlightRules = DiffHighlightRules;
|
||||
});
|
||||
|
||||
@@ -298,6 +298,8 @@ var makePreviewHtml = function () {
|
||||
}
|
||||
|
||||
var prevTime = new Date().getTime();
|
||||
// Handle gollum file code insertion syntax.
|
||||
text = text.replace(/^[ \t]*``` ?([^:\n\r]+:[^`\n\r]+)```/gm, '``$1``');
|
||||
text = md_to_html( text );
|
||||
|
||||
// Calculate the processing time of the HTML creation.
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/gollum.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/_styles.css" media="all">
|
||||
{{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
|
||||
<title>{{title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -30,11 +30,7 @@
|
||||
<input type="checkbox" name="versions[]" value="{{id}}">
|
||||
</td>
|
||||
<td class="author">
|
||||
<a href="javascript:void(0)">
|
||||
<img src="https://secure.gravatar.com/avatar/{{gravatar}}?s=16"
|
||||
alt="avatar: {{author}}" class="mini-gravatar">
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
{{>author_template}}
|
||||
</td>
|
||||
<td class="commit-name">
|
||||
<span class="time-elapsed">{{date}}:</span>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<a href="javascript:void(0)">
|
||||
<img src="https://secure.gravatar.com/avatar/{{gravatar}}?s=16"
|
||||
alt="avatar: {{author}}" class="mini-gravatar"/>
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
@@ -0,0 +1,5 @@
|
||||
<a href="javascript:void(0)">
|
||||
<img src="{{base_url}}/images/man_24.png" alt="avatar: {{author}}"
|
||||
class="mini-gravatar identicon" data-identicon="{{identicon}}"/>
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
@@ -0,0 +1,3 @@
|
||||
<a href="javascript:void(0)">
|
||||
<span class="username">{{author}}</span>
|
||||
</a>
|
||||
@@ -19,6 +19,9 @@
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/gollum.dialog.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/gollum.placeholder.js"></script>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/editor/gollum.editor.js"></script>
|
||||
{{#use_identicon}}
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/identicon_canvas.js"></script>
|
||||
{{/use_identicon}}
|
||||
{{#mathjax}}
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
|
||||
@@ -19,8 +19,47 @@ module Precious
|
||||
:selected => @page.version.id == v.id,
|
||||
:author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
|
||||
:message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
|
||||
:date => v.committed_date.strftime("%B %d, %Y"),
|
||||
:gravatar => Digest::MD5.hexdigest(v.author.email) }
|
||||
:date => v.authored_date.strftime("%B %d, %Y"),
|
||||
:gravatar => Digest::MD5.hexdigest(v.author.email),
|
||||
:identicon => self._identicon_code(v.author.email),
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
# http://stackoverflow.com/questions/9445760/bit-shifting-in-ruby
|
||||
def left_shift int, shift
|
||||
r = ((int & 0xFF) << (shift & 0x1F)) & 0xFFFFFFFF
|
||||
# 1>>31, 2**32
|
||||
(r & 2147483648) == 0 ? r : r - 4294967296
|
||||
end
|
||||
|
||||
def string_to_code string
|
||||
# sha bytes
|
||||
b = [Digest::SHA1.hexdigest(string)[0,20]].pack('H*').bytes.to_a
|
||||
# Thanks donpark's IdenticonUtil.java for this.
|
||||
# Match the following Java code
|
||||
# ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) |
|
||||
# ((b[2] & 0xFF) << 8) | (b[3] & 0xFF)
|
||||
|
||||
return left_shift(b[0], 24) |
|
||||
left_shift(b[1], 16) |
|
||||
left_shift(b[2], 8) |
|
||||
b[3] & 0xFF
|
||||
end
|
||||
|
||||
def _identicon_code(blob)
|
||||
string_to_code blob + @request.host
|
||||
end
|
||||
|
||||
def use_identicon
|
||||
@page.wiki.user_icons == 'identicon'
|
||||
end
|
||||
|
||||
def partial(name)
|
||||
if name == :author_template
|
||||
self.class.partial("history_authors/#{@page.wiki.user_icons}")
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@ module Precious
|
||||
def base_url
|
||||
@base_url
|
||||
end
|
||||
|
||||
def css # custom css
|
||||
@css
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,8 +89,8 @@ module Precious
|
||||
@mathjax
|
||||
end
|
||||
|
||||
def css # custom css
|
||||
@css
|
||||
def use_identicon
|
||||
@page.wiki.user_icons == 'identicon'
|
||||
end
|
||||
|
||||
# Access to embedded metadata.
|
||||
|
||||
+13
-9
@@ -395,12 +395,12 @@ module Gollum
|
||||
# name - The String absolute or relative path of the file.
|
||||
#
|
||||
# Returns the Gollum::File or nil if none was found.
|
||||
def find_file(name)
|
||||
def find_file(name, version=@version)
|
||||
if name =~ /^\//
|
||||
@wiki.file(name[1..-1], @version)
|
||||
@wiki.file(name[1..-1], version)
|
||||
else
|
||||
path = @dir == '.' ? name : ::File.join(@dir, name)
|
||||
@wiki.file(path, @version)
|
||||
@wiki.file(path, version)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -435,6 +435,10 @@ module Gollum
|
||||
#
|
||||
# Gitcode - fetch code from github search path and replace the contents
|
||||
# to a code-block that gets run the next parse.
|
||||
# Acceptable formats:
|
||||
# ```language:local-file.ext```
|
||||
# ```language:/abs/other-file.ext```
|
||||
# ```language:github/gollum/master/somefile.txt```
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
@@ -445,12 +449,12 @@ module Gollum
|
||||
uri = $2 || ''
|
||||
# Detect local file.
|
||||
if uri[0..6] != 'github/'
|
||||
if uri[0..0] != '/' # relative file
|
||||
contents = @wiki.page(uri).formatted_data
|
||||
else # use full path
|
||||
contents = @wiki.paged( extract_name( clean_url( uri ) ),
|
||||
'/' + clean_url( extract_path( uri ) ) ).formatted_data
|
||||
end
|
||||
if file = self.find_file(uri, @wiki.ref)
|
||||
contents = file.raw_data
|
||||
else
|
||||
# How do we communicate a render error?
|
||||
next "File not found: #{Rack::Utils::escape_html(uri)}"
|
||||
end
|
||||
else
|
||||
contents = Gollum::Gitcode.new(uri).contents
|
||||
end
|
||||
|
||||
@@ -105,7 +105,7 @@ module Gollum
|
||||
attr_reader :transformers
|
||||
|
||||
# Gets or sets a String prefix which is added to ID attributes.
|
||||
# Default: 'wiki-'
|
||||
# Default: ''
|
||||
attr_accessor :id_prefix
|
||||
|
||||
# Gets a Hash describing HTML attributes that Sanitize should add.
|
||||
@@ -128,7 +128,7 @@ module Gollum
|
||||
@add_attributes = {}
|
||||
@remove_contents = REMOVE_CONTENTS.dup
|
||||
@allow_comments = false
|
||||
@id_prefix = 'wiki-'
|
||||
@id_prefix = ''
|
||||
yield self if block_given?
|
||||
end
|
||||
|
||||
|
||||
+12
-3
@@ -163,6 +163,8 @@ module Gollum
|
||||
# :ref - String the repository ref to retrieve pages from
|
||||
# :ws_subs - Array of chars to sub for ws in filenames.
|
||||
# :mathjax - Set to false to disable mathjax.
|
||||
# :user_icons - Enable user icons on the history page. [gravatar, identicon, none].
|
||||
# Default: none
|
||||
# :show_all - Show all files in file view, not just valid pages.
|
||||
# Default: false
|
||||
# :collapse_tree - Start with collapsed file view. Default: false
|
||||
@@ -201,6 +203,9 @@ module Gollum
|
||||
@collapse_tree = options.fetch :collapse_tree, false
|
||||
@css = options.fetch :css, false
|
||||
@h1_title = options.fetch :h1_title, false
|
||||
|
||||
@user_icons = ['gravatar', 'identicon'].include?( options[:user_icons] ) ?
|
||||
options[:user_icons] : 'none'
|
||||
end
|
||||
|
||||
# Public: check whether the wiki's git repo exists on the filesystem.
|
||||
@@ -277,10 +282,11 @@ module Gollum
|
||||
# :committer - Optional Gollum::Committer instance. If provided,
|
||||
# assume that this operation is part of batch of
|
||||
# updates and the commit happens later.
|
||||
#
|
||||
# dir - The String subdirectory of the Gollum::Page without any
|
||||
# prefix or suffix slashes (e.g. "foo/bar").
|
||||
# Returns the String SHA1 of the newly written version, or the
|
||||
# Gollum::Committer instance if this is part of a batch update.
|
||||
def write_page(name, format, data, commit = {})
|
||||
def write_page(name, format, data, commit = {}, dir = '')
|
||||
multi_commit = false
|
||||
|
||||
committer = if obj = commit[:committer]
|
||||
@@ -292,7 +298,7 @@ module Gollum
|
||||
|
||||
filename = Gollum::Page.cname(name)
|
||||
|
||||
committer.add_to_index('', filename, format, data)
|
||||
committer.add_to_index(dir, filename, format, data)
|
||||
|
||||
committer.after_commit do |index, sha|
|
||||
@access.refresh
|
||||
@@ -609,6 +615,9 @@ module Gollum
|
||||
# Toggles mathjax.
|
||||
attr_reader :mathjax
|
||||
|
||||
# Toggles user icons. Default: 'none'
|
||||
attr_reader :user_icons
|
||||
|
||||
# Toggles showing all files in files view. Default is false.
|
||||
# When false, only valid pages in the git repo are displayed.
|
||||
attr_reader :show_all
|
||||
|
||||
@@ -30,3 +30,23 @@ http://www.thecssninja.com/css/css-tree-menu
|
||||
http://www.thecssninja.com/demo/license.txt
|
||||
|
||||
lib/gollum/frontend/public/css/_styles.css
|
||||
|
||||
---
|
||||
|
||||
Default profile image (man_24.png) is used under the CC BY-SA 3.0 Unported license.
|
||||
|
||||
CC BY-SA 3.0 Unported
|
||||
http://blog.twg.ca/2010/11/retina-display-icon-set/
|
||||
http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
|
||||
|
||||
lib/gollum/frontend/public/images/man_24.png
|
||||
|
||||
---
|
||||
|
||||
The canvas_identicon code is used under the MIT license.
|
||||
|
||||
https://github.com/donpark/identicon/blob/master/identicon-canvas/identicon_canvas.js
|
||||
https://github.com/donpark/identicon/blob/master/README
|
||||
|
||||
lib/gollum/frontend/public/gollum/javascript/identicon_canvas.js
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ require 'rubygems'
|
||||
require 'rack/test'
|
||||
require 'test/unit'
|
||||
require 'shoulda'
|
||||
require 'mocha'
|
||||
require 'mocha/setup'
|
||||
require 'fileutils'
|
||||
|
||||
dir = File.dirname(File.expand_path(__FILE__))
|
||||
|
||||
+1
-8
@@ -185,8 +185,6 @@ context "Frontend" do
|
||||
post "/create", :content => 'abc', :page => name,
|
||||
:format => 'markdown', :message => 'def'
|
||||
|
||||
follow_redirect!
|
||||
|
||||
assert last_response.ok?
|
||||
|
||||
@wiki.clear_cache
|
||||
@@ -385,16 +383,11 @@ context "Frontend with lotr" do
|
||||
end
|
||||
|
||||
test "create pages within sub-directories using page file dir" do
|
||||
Precious::App.set(:wiki_options, { :page_file_dir => 'wiki' })
|
||||
|
||||
post "/create", :content => 'one two', :page => 'base',
|
||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
:path => 'wiki/Mordor', :format => 'markdown', :message => 'oooh, scary'
|
||||
assert_equal 'http://example.org/wiki/Mordor/base', last_response.headers['Location']
|
||||
get "/wiki/Mordor/base"
|
||||
|
||||
# Reset page_file_dir after request but before matching.
|
||||
Precious::App.set(:wiki_options, { :page_file_dir => nil })
|
||||
|
||||
assert_match /one two/, last_response.body
|
||||
end
|
||||
|
||||
|
||||
@@ -34,6 +34,66 @@ context "gitcode" do
|
||||
assert_equal g.contents, %{<ol class=\"tree\">\n <li class=\"file\">\n <a href=\"0\"><span class=\"icon\"></span>0</a>\n </li>\n</ol>\n}
|
||||
end
|
||||
|
||||
test "gitcode relative local file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("file-exists.py", "import sys\n\nprint sys.maxint\n")
|
||||
index.commit("Add file-exists.py")
|
||||
|
||||
@wiki.clear_cache
|
||||
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span>\n\n<span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">maxint</span>\n</pre></div>\n\n<p>b</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode relative local file in subdir" do
|
||||
index = @wiki.repo.index
|
||||
index.add("foo/file-exists.py", "import sys\n\nprint sys.maxint\n")
|
||||
index.commit("Add file-exists.py")
|
||||
|
||||
@wiki.write_page("Pippin", :markdown, "a\n```python:file-exists.py```\nb", commit_details, 'foo')
|
||||
|
||||
page = @wiki.paged('Pippin', 'foo')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span>\n\n<span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">maxint</span>\n</pre></div>\n\n<p>b</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode relative no file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:no-file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\nFile not found: no-file-exists.py\nb</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode absolute local file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:/monkey/file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
|
||||
index = @wiki.repo.index
|
||||
index.add("monkey/file-exists.py", "import sys\n\nprint sys.platform\n")
|
||||
index.commit("Add monkey/file-exists.py")
|
||||
@wiki.clear_cache
|
||||
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span>\n\n<span class="k">print</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span>\n</pre></div>\n\n<p>b</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode absolute no file" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:/monkey/no-file-exists.py```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\nFile not found: /monkey/no-file-exists.py\nb</p>}, output
|
||||
end
|
||||
|
||||
test "gitcode error generates santized html" do
|
||||
@wiki.write_page("Bilbo Baggins", :markdown, "a\n```python:<script>foo</script>```\nb", commit_details)
|
||||
page = @wiki.page('Bilbo Baggins')
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\nFile not found: <script>foo</script>\nb</p>}, output
|
||||
end
|
||||
|
||||
teardown do
|
||||
@cleanup.call
|
||||
end
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
require File.expand_path '../../lib/gollum/frontend/views/history', __FILE__
|
||||
|
||||
context "Precious::Views::History" do
|
||||
setup do
|
||||
@history = Precious::Views::History.new
|
||||
end
|
||||
|
||||
test "string_to_code" do
|
||||
# Result must match the following Java code.
|
||||
=begin
|
||||
public static void main(String[] args) throws Exception {
|
||||
final String s = "code@example.com";
|
||||
final byte[] b = MessageDigest.getInstance("SHA1").digest(s.toString().getBytes("UTF-8"));
|
||||
final int c = ((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16)
|
||||
| ((b[2] & 0xFF) << 8) | (b[3] & 0xFF);
|
||||
// 143327882
|
||||
System.out.println(c);
|
||||
}
|
||||
=end
|
||||
actual = @history.string_to_code 'code@example.com'
|
||||
assert_equal 143327882, actual
|
||||
end
|
||||
end
|
||||
+4
-13
@@ -582,24 +582,13 @@ np.array([[2,2],[1,3]],np.float)
|
||||
assert_match /\(\[\[/, rendered, "#{markup_class} parses out wiki links\n#{rendered}"
|
||||
end
|
||||
|
||||
test "embed code is escaped" do
|
||||
@wiki.write_page("script", :markdown, "a <script></script> b", commit_details)
|
||||
@wiki.write_page("page", :markdown, "```html:script```", commit_details)
|
||||
|
||||
output_script = @wiki.page("script").formatted_data
|
||||
output_page = @wiki.page("page").formatted_data
|
||||
|
||||
assert_equal %Q{<p>a b</p>}, output_script
|
||||
assert_equal %Q{<div class=\"highlight\"><pre><span class=\"nt\"><p></span>a b<span class=\"nt\"></p></span>\n</pre></div>}, output_page
|
||||
end
|
||||
|
||||
test "embed code page absolute link" do
|
||||
@wiki.write_page("base", :markdown, "a\n!base\b", commit_details)
|
||||
@wiki.write_page("a", :markdown, "a\n```html:/base```\b", commit_details)
|
||||
|
||||
page = @wiki.page("a")
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
||||
assert_equal %Q{<p>a\nFile not found: /base</p>}, output
|
||||
end
|
||||
|
||||
test "embed code page relative link" do
|
||||
@@ -608,7 +597,7 @@ np.array([[2,2],[1,3]],np.float)
|
||||
|
||||
page = @wiki.page("a")
|
||||
output = page.formatted_data
|
||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
||||
assert_equal %Q{<p>a\nFile not found: base</p>}, output
|
||||
end
|
||||
|
||||
test "code block in unsupported language" do
|
||||
@@ -783,6 +772,7 @@ end
|
||||
]
|
||||
end
|
||||
|
||||
if ENV['ASCIIDOC']
|
||||
#########################################################################
|
||||
# Asciidoc
|
||||
#########################################################################
|
||||
@@ -794,6 +784,7 @@ end
|
||||
test "internal links with asciidoc" do
|
||||
compare("= Book Title\n\n[[anid]]\n== Heading", '<div class="sect1"><h2 id="wiki-anid">Heading<a class="anchor" id="Heading" href="#Heading"></a></h2><div class="sectionbody"></div></div>', 'asciidoc')
|
||||
end
|
||||
end
|
||||
|
||||
#########################################################################
|
||||
#
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
class WikiFactory
|
||||
def self.create p
|
||||
def self.create p, opt={}
|
||||
path = testpath "examples/test.git"
|
||||
Grit::Repo.init_bare(path)
|
||||
Gollum::Wiki.default_options = {:universal_toc => false}
|
||||
Gollum::Wiki.default_options = {:universal_toc => false}.merge(opt)
|
||||
cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) }
|
||||
wiki = Gollum::Wiki.new(path)
|
||||
# set 'wiki-' prefix on ids for tests
|
||||
wiki.sanitization.id_prefix = 'wiki-'
|
||||
return wiki, path, cleanup
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user