Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ce6b0ac095 | |||
| 420bb06988 | |||
| 20566f8acf | |||
| 1d5f69704a | |||
| 0da664299e | |||
| 6e8fb2b457 | |||
| d1c72a4ff3 | |||
| 0bf05392e4 | |||
| 7ecef0c045 | |||
| 33ca329253 | |||
| 01fa4770cb | |||
| b76257c49c | |||
| e2fbf22f38 | |||
| 134432d029 | |||
| 8d4d6e80b8 | |||
| 85e6ef3dca | |||
| 60f1467229 | |||
| 1757242382 | |||
| 55df7bb9c4 | |||
| 686b8acd38 | |||
| a5f9df6170 | |||
| 27f61a870a | |||
| a48e8d1c5c | |||
| b80f74bccd | |||
| 1e768734ef | |||
| 11c9cabeb3 | |||
| 3a14ab92f0 | |||
| 62d5f52398 | |||
| 2b4848566c | |||
| 7c825e877c | |||
| 8417c277e6 | |||
| 9cef423908 | |||
| e73c84490e | |||
| 6cfc807db0 | |||
| be366f8103 | |||
| 2d13bd796f | |||
| 523f8f80ca |
+2
-2
@@ -65,8 +65,8 @@ opts = OptionParser.new do |opts|
|
|||||||
wiki_options[:live_preview] = false
|
wiki_options[:live_preview] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("--no-mathjax", "Disables mathjax.") do
|
opts.on("--mathjax", "Enables mathjax.") do
|
||||||
options['mathjax'] = false
|
options['mathjax'] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = ">= 1.8.7"
|
s.required_ruby_version = ">= 1.8.7"
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '2.1.3'
|
s.version = '2.1.7'
|
||||||
s.date = '2012-08-13'
|
s.date = '2012-08-25'
|
||||||
s.rubyforge_project = 'gollum'
|
s.rubyforge_project = 'gollum'
|
||||||
|
|
||||||
s.summary = "A simple, Git-powered wiki."
|
s.summary = "A simple, Git-powered wiki."
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ require File.expand_path('../gollum/tex', __FILE__)
|
|||||||
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '2.1.3'
|
VERSION = '2.1.7'
|
||||||
|
|
||||||
def self.assets_path
|
def self.assets_path
|
||||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||||
|
|||||||
+25
-16
@@ -90,19 +90,26 @@ module Precious
|
|||||||
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
|
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Removes all slashes from the start of string.
|
||||||
|
def clean_url url
|
||||||
|
return url if url.nil?
|
||||||
|
url.gsub('%2F','/').gsub(/^\/+/,'')
|
||||||
|
end
|
||||||
|
|
||||||
# path is set to name if path is nil.
|
# path is set to name if path is nil.
|
||||||
# if path is 'a/b' and a and b are dirs, then
|
# if path is 'a/b' and a and b are dirs, then
|
||||||
# path must have a trailing slash 'a/b/' or
|
# path must have a trailing slash 'a/b/' or
|
||||||
# extract_path will trim path to 'a'
|
# extract_path will trim path to 'a'
|
||||||
# name, path, version
|
# name, path, version
|
||||||
def wiki_page( name, path = nil, version = nil)
|
def wiki_page(name, path = nil, version = nil, exact = true)
|
||||||
path = name if path.nil?
|
path = name if path.nil?
|
||||||
name = extract_name(name)
|
name = extract_name(name)
|
||||||
path = extract_path(path)
|
path = extract_path(path)
|
||||||
|
path = '/' if exact && path.nil?
|
||||||
|
|
||||||
wiki = wiki_new
|
wiki = wiki_new
|
||||||
|
|
||||||
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, version),
|
OpenStruct.new(:wiki => wiki, :page => wiki.paged(name, path, exact, version),
|
||||||
:name => name, :path => path)
|
:name => name, :path => path)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -136,19 +143,19 @@ module Precious
|
|||||||
mustache :edit
|
mustache :edit
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
redirect to("/create/#{CGI.escape(@name)}")
|
redirect to("/create/#{encodeURIComponent(@name)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/edit/*' do
|
post '/edit/*' do
|
||||||
wikip = wiki_page(CGI.unescape(params[:page]), sanitize_empty_params(params[:path]))
|
path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s
|
||||||
path = wikip.path
|
page_name = CGI.unescape(params[:page])
|
||||||
wiki = wikip.wiki
|
wiki = wiki_new
|
||||||
page = wikip.page
|
page = wiki.paged(page_name, path, exact = true)
|
||||||
rename = params[:rename].to_url if params[:rename]
|
rename = params[:rename].to_url if params[:rename]
|
||||||
name = rename || page.name
|
name = rename || page.name
|
||||||
committer = Gollum::Committer.new(wiki, commit_message)
|
committer = Gollum::Committer.new(wiki, commit_message)
|
||||||
commit = {:committer => committer}
|
commit = {:committer => committer}
|
||||||
|
|
||||||
update_wiki_page(wiki, page, params[:content], commit, name, params[:format])
|
update_wiki_page(wiki, page, params[:content], commit, name, params[:format])
|
||||||
update_wiki_page(wiki, page.header, params[:header], commit) if params[:header]
|
update_wiki_page(wiki, page.header, params[:header], commit) if params[:header]
|
||||||
@@ -172,7 +179,7 @@ module Precious
|
|||||||
end
|
end
|
||||||
|
|
||||||
get '/create/*' do
|
get '/create/*' do
|
||||||
wikip = wiki_page(params[:splat].first)
|
wikip = wiki_page(params[:splat].first.gsub('+', '-'))
|
||||||
@name = wikip.name.to_url
|
@name = wikip.name.to_url
|
||||||
@path = wikip.path
|
@path = wikip.path
|
||||||
|
|
||||||
@@ -187,6 +194,7 @@ module Precious
|
|||||||
post '/create' do
|
post '/create' do
|
||||||
name = params[:page].to_url
|
name = params[:page].to_url
|
||||||
path = sanitize_empty_params(params[:path])
|
path = sanitize_empty_params(params[:path])
|
||||||
|
path = '' if path.nil?
|
||||||
format = params[:format].intern
|
format = params[:format].intern
|
||||||
|
|
||||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||||
@@ -195,8 +203,7 @@ module Precious
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
wiki.write_page(name, format, params[:content], commit_message)
|
wiki.write_page(name, format, params[:content], commit_message)
|
||||||
page = wiki.page(name)
|
redirect to("/#{clean_url(CGI.escape(::File.join(path,name)))}")
|
||||||
redirect to("/#{page.escaped_url_path}") unless page.nil?
|
|
||||||
rescue Gollum::DuplicatePageError => e
|
rescue Gollum::DuplicatePageError => e
|
||||||
@message = "Duplicate page: #{e.message}"
|
@message = "Duplicate page: #{e.message}"
|
||||||
mustache :error
|
mustache :error
|
||||||
@@ -341,7 +348,9 @@ module Precious
|
|||||||
path = extract_path(fullpath)
|
path = extract_path(fullpath)
|
||||||
wiki = wiki_new
|
wiki = wiki_new
|
||||||
|
|
||||||
if page = wiki.paged(name, path)
|
path = '/' if path.nil?
|
||||||
|
|
||||||
|
if page = wiki.paged(name, path, exact = true)
|
||||||
@page = page
|
@page = page
|
||||||
@name = name
|
@name = name
|
||||||
@editable = true
|
@editable = true
|
||||||
@@ -354,7 +363,7 @@ module Precious
|
|||||||
file.raw_data
|
file.raw_data
|
||||||
else
|
else
|
||||||
page_path = [path, name].compact.join('/')
|
page_path = [path, name].compact.join('/')
|
||||||
redirect to("/create/#{CGI.escape(page_path).gsub('%2F','/')}")
|
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ $(document).ready(function() {
|
|||||||
var ok = confirm($(this).data('confirm'));
|
var ok = confirm($(this).data('confirm'));
|
||||||
if ( ok ) {
|
if ( ok ) {
|
||||||
var loc = window.location;
|
var loc = window.location;
|
||||||
loc = baseUrl + '/delete' + loc.pathname
|
loc = baseUrl + '/delete' + loc.pathname.replace(baseUrl,'');
|
||||||
window.location = loc;
|
window.location = loc;
|
||||||
}
|
}
|
||||||
// Don't navigate on cancel.
|
// Don't navigate on cancel.
|
||||||
@@ -141,7 +141,7 @@ $(document).ready(function() {
|
|||||||
url: baseUrl + '/edit/' + oldName,
|
url: baseUrl + '/edit/' + oldName,
|
||||||
data: { path: path, rename: newName, page: oldName, message: msg },
|
data: { path: path, rename: newName, page: oldName, message: msg },
|
||||||
success: function() {
|
success: function() {
|
||||||
window.location = baseUrl + encodeURIComponent(newName);
|
window.location = baseUrl + '/' + encodeURIComponent(newName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -154,14 +154,6 @@ $(document).ready(function() {
|
|||||||
$('#minibutton-new-page').click(function(e) {
|
$('#minibutton-new-page').click(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var path = location.pathname;
|
|
||||||
// ensure there's more than one slash in pathname.
|
|
||||||
if (path.split('/').length > 2) {
|
|
||||||
path = path.substr(0, path.lastIndexOf('/') + 1);
|
|
||||||
} else {
|
|
||||||
path = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$.GollumDialog.init({
|
$.GollumDialog.init({
|
||||||
title: 'Create New Page',
|
title: 'Create New Page',
|
||||||
fields: [
|
fields: [
|
||||||
@@ -169,7 +161,7 @@ $(document).ready(function() {
|
|||||||
id: 'name',
|
id: 'name',
|
||||||
name: 'Page Name',
|
name: 'Page Name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
defaultValue: path || ''
|
defaultValue: ''
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
OK: function( res ) {
|
OK: function( res ) {
|
||||||
@@ -177,7 +169,7 @@ $(document).ready(function() {
|
|||||||
if ( res['name'] ) {
|
if ( res['name'] ) {
|
||||||
name = res['name'];
|
name = res['name'];
|
||||||
}
|
}
|
||||||
window.location = baseUrl + encodeURIComponent(name);
|
window.location = baseUrl + '/' + encodeURIComponent(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#editor .ace_sb {
|
||||||
|
overflow-y: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
#darkness {
|
#darkness {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -49,7 +53,7 @@ so editor doesn't display in the background. */
|
|||||||
#contentframe {
|
#contentframe {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
width: 80%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#previewframe {
|
#previewframe {
|
||||||
@@ -63,14 +67,35 @@ so editor doesn't display in the background. */
|
|||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.editor_bg {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background: black;
|
||||||
|
width: 50%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolpanel_bg {
|
||||||
|
position: fixed;
|
||||||
|
background: #666;
|
||||||
|
top: 0;
|
||||||
|
height: 30px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 5px 0;
|
||||||
|
margin: 0;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* -- Start from notepag.es -- */
|
/* -- Start from notepag.es -- */
|
||||||
.toolpanel {
|
.toolpanel {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background: #666;
|
background: #666;
|
||||||
top: 0;
|
top: 0;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
right: 20px;
|
width: 50%;
|
||||||
width: 80px;
|
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
<a id='toggle' class='edit' href='javascript:void(0)' onclick='jsm.toggleLeftRight();'><img src='images/lr_24.png' alt='Toggle left to right' title='Toggle left to right'></a>
|
<a id='toggle' class='edit' href='javascript:void(0)' onclick='jsm.toggleLeftRight();'><img src='images/lr_24.png' alt='Toggle left to right' title='Toggle left to right'></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class='editor_bg'></div>
|
||||||
|
<div class='toolpanel_bg'></div>
|
||||||
|
|
||||||
<div id='commenttoolpanel' class='toolpanel edit' style='width: 500px; right: 0px; '>
|
<div id='commenttoolpanel' class='toolpanel edit' style='width: 500px; right: 0px; '>
|
||||||
<a id='savecommentconfirm' class='edit'><img src='images/savecomment_24.png' alt='Confirm save with comment' title='Confirm save with comment'></a>
|
<a id='savecommentconfirm' class='edit'><img src='images/savecomment_24.png' alt='Confirm save with comment' title='Confirm save with comment'></a>
|
||||||
<a id='commentcancel' class='edit'><img src='images/cancel_24.png' alt='Cancel save with comment' title='Cancel save with comment'></a>
|
<a id='commentcancel' class='edit'><img src='images/cancel_24.png' alt='Cancel save with comment' title='Cancel save with comment'></a>
|
||||||
@@ -36,11 +39,11 @@ var require = {
|
|||||||
<script src='js/sundown.js'></script>
|
<script src='js/sundown.js'></script>
|
||||||
<script src='js/md_sundown.js'></script>
|
<script src='js/md_sundown.js'></script>
|
||||||
<script src='js/livepreview.js'></script>
|
<script src='js/livepreview.js'></script>
|
||||||
<script>(function(d,j){
|
<!--<script>(function(d,j){
|
||||||
j = d.createElement('script');
|
j = d.createElement('script');
|
||||||
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
|
j.src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML';
|
||||||
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
|
(d.head || d.getElementsByTagName('head')[0]).appendChild(j);
|
||||||
}(document));
|
}(document));
|
||||||
</script>
|
</script>-->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -97,15 +97,23 @@ $.save = function( commitMessage ) {
|
|||||||
var markdown = 'markdown';
|
var markdown = 'markdown';
|
||||||
var txt = editorSession.getValue();
|
var txt = editorSession.getValue();
|
||||||
var msg = defaultCommitMessage();
|
var msg = defaultCommitMessage();
|
||||||
var newLocation = location.protocol + '//' + location.host + baseUrl;
|
var newLocation = baseUrl;
|
||||||
|
|
||||||
|
function clean( str ) {
|
||||||
|
return str.replace(/^\/+/g, '/');
|
||||||
|
}
|
||||||
|
|
||||||
// 'a%2Fb' => a/b
|
// 'a%2Fb' => a/b
|
||||||
if (pathName) {
|
if ( pathName ) {
|
||||||
newLocation += '/' + unescape(pathName);
|
pathName = unescape( pathName );
|
||||||
|
newLocation += '/' + pathName;
|
||||||
pathName = pathName + '/'; // pathName must end with /
|
pathName = pathName + '/'; // pathName must end with /
|
||||||
|
|
||||||
|
pathName = clean( pathName );
|
||||||
}
|
}
|
||||||
|
|
||||||
newLocation += '/' + pageName;
|
newLocation += '/' + pageName;
|
||||||
|
newLocation = clean( newLocation );
|
||||||
|
|
||||||
// if &create=true then handle create instead of edit.
|
// if &create=true then handle create instead of edit.
|
||||||
if ( create ) {
|
if ( create ) {
|
||||||
@@ -397,7 +405,8 @@ var applyTimeout = function () {
|
|||||||
var heightHalf = height / 2;
|
var heightHalf = height / 2;
|
||||||
|
|
||||||
// height minus 50 so the end of document text doesn't flow off the page.
|
// height minus 50 so the end of document text doesn't flow off the page.
|
||||||
var editorContainerStyle = 'width:' + widthHalf + 'px;' +
|
// + 15 for scroll bar
|
||||||
|
var editorContainerStyle = 'width:' + (widthHalf + 15) + 'px;' +
|
||||||
'height:' + (height - 50) + 'px;' +
|
'height:' + (height - 50) + 'px;' +
|
||||||
'left:' + (leftRight === false ? widthHalf + 'px;' : '0px;') +
|
'left:' + (leftRight === false ? widthHalf + 'px;' : '0px;') +
|
||||||
'top:' + '40px;'; // use 40px for tool menu
|
'top:' + '40px;'; // use 40px for tool menu
|
||||||
@@ -408,12 +417,12 @@ var applyTimeout = function () {
|
|||||||
var previewStyle = 'width:' + (widthHalf - 2 - 10) + 'px;' +
|
var previewStyle = 'width:' + (widthHalf - 2 - 10) + 'px;' +
|
||||||
'height:' + height + 'px;' +
|
'height:' + height + 'px;' +
|
||||||
'left:' + (leftRight === false ? '10px;' : widthHalf + 'px;') +
|
'left:' + (leftRight === false ? '10px;' : widthHalf + 'px;') +
|
||||||
'top:' + '0px;';
|
// preview panel top is equal to height of comment tool panel (40px) + 1
|
||||||
|
'top:41px;';
|
||||||
cssSet( preview, previewStyle );
|
cssSet( preview, previewStyle );
|
||||||
|
|
||||||
// Resize tool panel
|
// Resize tool panel
|
||||||
var toolPanelStyle = 'width:' + widthHalf + 'px;' +
|
var toolPanelStyle = 'width:50%;';
|
||||||
'left:' + (leftRight === false ? widthHalf + 'px;' : '0px;');
|
|
||||||
cssSet( toolPanel, toolPanelStyle );
|
cssSet( toolPanel, toolPanelStyle );
|
||||||
|
|
||||||
// Resize comment related elements.
|
// Resize comment related elements.
|
||||||
@@ -428,10 +437,12 @@ var applyTimeout = function () {
|
|||||||
cssSet( commentEditorContainer, commentEditorContainerStyle );
|
cssSet( commentEditorContainer, commentEditorContainerStyle );
|
||||||
commentEditor.resize();
|
commentEditor.resize();
|
||||||
|
|
||||||
|
var commentToolPanelHeight = height / 4 - 40;
|
||||||
|
|
||||||
// In top subtract height (40px) of comment tool panel.
|
// In top subtract height (40px) of comment tool panel.
|
||||||
var commentToolPanelStyle = 'width:' + widthHalf + 'px;' +
|
var commentToolPanelStyle = 'width:' + widthHalf + 'px;' +
|
||||||
'left:' + widthFourth + 'px;' +
|
'left:' + widthFourth + 'px;' +
|
||||||
'top:' + (height / 4 - 40) + 'px;' +
|
'top:' + commentToolPanelHeight + 'px;' +
|
||||||
commentHidden;
|
commentHidden;
|
||||||
cssSet( commentToolPanel, commentToolPanelStyle );
|
cssSet( commentToolPanel, commentToolPanelStyle );
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# ~*~ encoding: utf-8 ~*~
|
||||||
=begin
|
=begin
|
||||||
Copyright 2006-2008 the V8 project authors. All rights reserved.
|
Copyright 2006-2008 the V8 project authors. All rights reserved.
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@@ -39,7 +40,12 @@ end
|
|||||||
# define charCodeAt on String
|
# define charCodeAt on String
|
||||||
class String
|
class String
|
||||||
def charCodeAt(k)
|
def charCodeAt(k)
|
||||||
return self[k].ord
|
# use scan, nil check, and unpack instead of ord for 1.8
|
||||||
|
# 1.9 can simply use self[k].ord
|
||||||
|
# http://stackoverflow.com/questions/7793177/split-utf8-string-regardless-of-ruby-version
|
||||||
|
c = self.scan(/./mu)[k]
|
||||||
|
return nil if c.nil?
|
||||||
|
c.unpack('U')[0]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -147,6 +153,7 @@ def Encode(uri, unescape)
|
|||||||
k = -1;
|
k = -1;
|
||||||
while ((k+=1) < uriLength) do
|
while ((k+=1) < uriLength) do
|
||||||
cc1 = uri.charCodeAt(k);
|
cc1 = uri.charCodeAt(k);
|
||||||
|
next if cc1.nil?
|
||||||
if (self.send(unescape, cc1))
|
if (self.send(unescape, cc1))
|
||||||
result[index] = cc1;
|
result[index] = cc1;
|
||||||
index += 1
|
index += 1
|
||||||
@@ -163,10 +170,11 @@ def Encode(uri, unescape)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# use .compact to get rid of nils from charCodeAt
|
||||||
# return %StringFromCharCodeArray(result);
|
# return %StringFromCharCodeArray(result);
|
||||||
# 'c' = 8 bit signed char
|
# 'c' = 8 bit signed char
|
||||||
# http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-pack
|
# http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-pack
|
||||||
return result.pack 'c*'
|
return result.compact.pack 'c*'
|
||||||
end
|
end
|
||||||
end # class << self
|
end # class << self
|
||||||
end # module
|
end # module
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ module Precious
|
|||||||
def breadcrumb
|
def breadcrumb
|
||||||
if @path
|
if @path
|
||||||
path = Pathname.new(@path)
|
path = Pathname.new(@path)
|
||||||
breadcrumb = [%{<a href="#{@base_url}pages/">Home</a>}]
|
breadcrumb = [%{<a href="#{@base_url}/pages/">Home</a>}]
|
||||||
path.descend do |crumb|
|
path.descend do |crumb|
|
||||||
title = crumb.basename
|
title = crumb.basename
|
||||||
|
|
||||||
if title == path.basename
|
if title == path.basename
|
||||||
breadcrumb << title
|
breadcrumb << title
|
||||||
else
|
else
|
||||||
breadcrumb << %{<a href="#{@base_url}pages/#{crumb}/">#{title}</a>}
|
breadcrumb << %{<a href="#{@base_url}/pages/#{crumb}/">#{title}</a>}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ module Precious
|
|||||||
if page_path.include?('/')
|
if page_path.include?('/')
|
||||||
folder = page_path.split('/').first
|
folder = page_path.split('/').first
|
||||||
folder_path = @path ? "#{@path}/#{folder}" : folder
|
folder_path = @path ? "#{@path}/#{folder}" : folder
|
||||||
folder_link = %{<li><a href="#{@base_url}pages/#{folder_path}/" class="folder">#{folder}</a></li>}
|
folder_link = %{<li><a href="#{@base_url}/pages/#{folder_path}/" class="folder">#{folder}</a></li>}
|
||||||
|
|
||||||
unless folder_links.include?(folder_link)
|
unless folder_links.include?(folder_link)
|
||||||
folder_links << folder_link
|
folder_links << folder_link
|
||||||
@@ -47,7 +47,7 @@ module Precious
|
|||||||
folder_link
|
folder_link
|
||||||
end
|
end
|
||||||
elsif page_path != ".gitkeep"
|
elsif page_path != ".gitkeep"
|
||||||
%{<li><a href="#{@base_url}#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
|
%{<li><a href="#{@base_url}/#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
|
||||||
end
|
end
|
||||||
}.compact.join("\n")
|
}.compact.join("\n")
|
||||||
else
|
else
|
||||||
|
|||||||
+18
-6
@@ -87,14 +87,15 @@ module Gollum
|
|||||||
def process_headers(doc)
|
def process_headers(doc)
|
||||||
toc = nil
|
toc = nil
|
||||||
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
|
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
|
||||||
id = CGI::escape(h.content.gsub(' ','-'))
|
id = encodeURIComponent(h.content.gsub(' ','-'))
|
||||||
level = h.name.gsub(/[hH]/,'').to_i
|
level = h.name.gsub(/[hH]/,'').to_i
|
||||||
|
|
||||||
# Add anchors
|
# Add anchors
|
||||||
anchor = Nokogiri::XML::Node.new('a', doc)
|
anchor = Nokogiri::XML::Node.new('a', doc)
|
||||||
anchor['class'] = 'anchor'
|
anchor['class'] = 'anchor'
|
||||||
anchor['id'] = id
|
anchor['id'] = id
|
||||||
anchor['href'] = '#' + id
|
# % -> %25 so anchors work on Firefox. See issue #475
|
||||||
|
anchor['href'] = '#' + id.gsub('%', '%25')
|
||||||
h.add_child(anchor)
|
h.add_child(anchor)
|
||||||
|
|
||||||
# Build TOC
|
# Build TOC
|
||||||
@@ -112,7 +113,8 @@ module Gollum
|
|||||||
tail_level -= 1
|
tail_level -= 1
|
||||||
end
|
end
|
||||||
node = Nokogiri::XML::Node.new('li', doc)
|
node = Nokogiri::XML::Node.new('li', doc)
|
||||||
node.add_child("<a href='##{id}'>#{h.content}</a>")
|
# % -> %25 so anchors work on Firefox. See issue #475
|
||||||
|
node.add_child("<a href='##{id.gsub('%', '%25')}'>#{h.content}</a>")
|
||||||
tail.add_child(node)
|
tail.add_child(node)
|
||||||
end
|
end
|
||||||
toc = toc.to_xhtml if toc != nil
|
toc = toc.to_xhtml if toc != nil
|
||||||
@@ -226,7 +228,7 @@ module Gollum
|
|||||||
if is_preformatted?(data, id)
|
if is_preformatted?(data, id)
|
||||||
data.gsub!(id, "[[#{tag}]]")
|
data.gsub!(id, "[[#{tag}]]")
|
||||||
else
|
else
|
||||||
data.gsub!(id, process_tag(tag))
|
data.gsub!(id, process_tag(tag).gsub('%2F', '/'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
data
|
data
|
||||||
@@ -439,13 +441,23 @@ module Gollum
|
|||||||
# Find a page from a given cname. If the page has an anchor (#) and has
|
# Find a page from a given cname. If the page has an anchor (#) and has
|
||||||
# no match, strip the anchor and try again.
|
# no match, strip the anchor and try again.
|
||||||
#
|
#
|
||||||
# cname - The String canonical page name.
|
# cname - The String canonical page name including path.
|
||||||
#
|
#
|
||||||
# Returns a Gollum::Page instance if a page is found, or an Array of
|
# Returns a Gollum::Page instance if a page is found, or an Array of
|
||||||
# [Gollum::Page, String extra] if a page without the extra anchor data
|
# [Gollum::Page, String extra] if a page without the extra anchor data
|
||||||
# is found.
|
# is found.
|
||||||
def find_page_from_name(cname)
|
def find_page_from_name(cname)
|
||||||
if page = @wiki.page(cname)
|
slash = cname.rindex('/')
|
||||||
|
|
||||||
|
unless slash.nil?
|
||||||
|
name = cname[slash+1..-1]
|
||||||
|
path = cname[0..slash]
|
||||||
|
page = @wiki.paged(name, path)
|
||||||
|
else
|
||||||
|
page = @wiki.paged(cname, '/')
|
||||||
|
end
|
||||||
|
|
||||||
|
if page
|
||||||
return page
|
return page
|
||||||
end
|
end
|
||||||
if pos = cname.index('#')
|
if pos = cname.index('#')
|
||||||
|
|||||||
+6
-4
@@ -327,7 +327,7 @@ module Gollum
|
|||||||
# Returns the String canonical name.
|
# Returns the String canonical name.
|
||||||
def self.cname(name, char_white_sub = '-', char_other_sub = '-')
|
def self.cname(name, char_white_sub = '-', char_other_sub = '-')
|
||||||
name.respond_to?(:gsub) ?
|
name.respond_to?(:gsub) ?
|
||||||
name.gsub(%r{\s},char_white_sub).gsub(%r{[/<>+]}, char_other_sub) :
|
name.gsub(%r{\s},char_white_sub).gsub(%r{[<>+]}, char_other_sub) :
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -372,9 +372,9 @@ module Gollum
|
|||||||
# version - The String version ID to find.
|
# version - The String version ID to find.
|
||||||
#
|
#
|
||||||
# Returns a Gollum::Page or nil if the page could not be found.
|
# Returns a Gollum::Page or nil if the page could not be found.
|
||||||
def find(name, version, dir = nil)
|
def find(name, version, dir = nil, exact = false)
|
||||||
map = @wiki.tree_map_for(version.to_s)
|
map = @wiki.tree_map_for(version.to_s)
|
||||||
if page = find_page_in_tree(map, name, dir)
|
if page = find_page_in_tree(map, name, dir, exact)
|
||||||
page.version = version.is_a?(Grit::Commit) ?
|
page.version = version.is_a?(Grit::Commit) ?
|
||||||
version : @wiki.commit_for(version)
|
version : @wiki.commit_for(version)
|
||||||
page.historical = page.version.to_s == version.to_s
|
page.historical = page.version.to_s == version.to_s
|
||||||
@@ -391,12 +391,14 @@ module Gollum
|
|||||||
# to be in. The string should
|
# to be in. The string should
|
||||||
#
|
#
|
||||||
# Returns a Gollum::Page or nil if the page could not be found.
|
# Returns a Gollum::Page or nil if the page could not be found.
|
||||||
def find_page_in_tree(map, name, checked_dir = nil)
|
def find_page_in_tree(map, name, checked_dir = nil, exact = false)
|
||||||
return nil if !map || name.to_s.empty?
|
return nil if !map || name.to_s.empty?
|
||||||
if checked_dir = BlobEntry.normalize_dir(checked_dir)
|
if checked_dir = BlobEntry.normalize_dir(checked_dir)
|
||||||
checked_dir.downcase!
|
checked_dir.downcase!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
checked_dir = '' if exact && checked_dir.nil?
|
||||||
|
|
||||||
map.each do |entry|
|
map.each do |entry|
|
||||||
next if entry.name.to_s.empty?
|
next if entry.name.to_s.empty?
|
||||||
next unless checked_dir.nil? || entry.dir.downcase == checked_dir
|
next unless checked_dir.nil? || entry.dir.downcase == checked_dir
|
||||||
|
|||||||
+5
-5
@@ -179,7 +179,7 @@ module Gollum
|
|||||||
self.class.history_sanitization
|
self.class.history_sanitization
|
||||||
@live_preview = options.fetch(:live_preview, true)
|
@live_preview = options.fetch(:live_preview, true)
|
||||||
@universal_toc = options.fetch(:universal_toc, false)
|
@universal_toc = options.fetch(:universal_toc, false)
|
||||||
@mathjax = options[:mathjax] || true
|
@mathjax = options[:mathjax] || false
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: check whether the wiki's git repo exists on the filesystem.
|
# Public: check whether the wiki's git repo exists on the filesystem.
|
||||||
@@ -196,9 +196,9 @@ module Gollum
|
|||||||
# dir - The directory String relative to the repo.
|
# dir - The directory String relative to the repo.
|
||||||
#
|
#
|
||||||
# Returns a Gollum::Page or nil if no matching page was found.
|
# Returns a Gollum::Page or nil if no matching page was found.
|
||||||
def page(name, version = @ref, dir = nil)
|
def page(name, version = @ref, dir = nil, exact = false)
|
||||||
version = @ref if version.nil?
|
version = @ref if version.nil?
|
||||||
@page_class.new(self).find(name, version, dir)
|
@page_class.new(self).find(name, version, dir, exact)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Convenience method instead of calling page(name, nil, dir).
|
# Public: Convenience method instead of calling page(name, nil, dir).
|
||||||
@@ -208,8 +208,8 @@ module Gollum
|
|||||||
# dir - The directory String relative to the repo.
|
# dir - The directory String relative to the repo.
|
||||||
#
|
#
|
||||||
# Returns a Gollum::Page or nil if no matching page was found.
|
# Returns a Gollum::Page or nil if no matching page was found.
|
||||||
def paged(name, dir = nil, version = @ref)
|
def paged(name, dir = nil, exact = false, version = @ref)
|
||||||
page(name, version, dir)
|
page(name, version, dir, exact)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Get the static file for a given name.
|
# Public: Get the static file for a given name.
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ context "Frontend" do
|
|||||||
assert_not_equal page_1.version.sha, page_2.version.sha
|
assert_not_equal page_1.version.sha, page_2.version.sha
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "edit page with slash" do
|
||||||
|
page_1 = @wiki.page('A')
|
||||||
|
post "/edit/A", :content => 'abc', :page => 'A', :path => '/////',
|
||||||
|
:format => page_1.format, :message => 'def'
|
||||||
|
follow_redirect!
|
||||||
|
assert last_response.ok?
|
||||||
|
end
|
||||||
|
|
||||||
test "edits page header footer and sidebar" do
|
test "edits page header footer and sidebar" do
|
||||||
commits = @wiki.repo.commits('master').size
|
commits = @wiki.repo.commits('master').size
|
||||||
page_1 = @wiki.page('A')
|
page_1 = @wiki.page('A')
|
||||||
@@ -176,6 +184,7 @@ context "Frontend" do
|
|||||||
name = "A"
|
name = "A"
|
||||||
post "/create", :content => 'abc', :page => name,
|
post "/create", :content => 'abc', :page => name,
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
|
follow_redirect!
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
@@ -212,6 +221,8 @@ context "Frontend" do
|
|||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
# Grit is broken.
|
||||||
test "reverts single commit" do
|
test "reverts single commit" do
|
||||||
page1 = @wiki.page('B')
|
page1 = @wiki.page('B')
|
||||||
|
|
||||||
@@ -237,6 +248,7 @@ context "Frontend" do
|
|||||||
assert_not_equal page1.version.sha, page2.version.sha
|
assert_not_equal page1.version.sha, page2.version.sha
|
||||||
assert_equal "INITIAL", page2.raw_data.strip
|
assert_equal "INITIAL", page2.raw_data.strip
|
||||||
end
|
end
|
||||||
|
=end
|
||||||
|
|
||||||
test "cannot revert conflicting commit" do
|
test "cannot revert conflicting commit" do
|
||||||
page1 = @wiki.page('A')
|
page1 = @wiki.page('A')
|
||||||
|
|||||||
+2
-1
@@ -99,7 +99,8 @@ context "Page" do
|
|||||||
test "cname" do
|
test "cname" do
|
||||||
assert_equal "Foo", Gollum::Page.cname("Foo")
|
assert_equal "Foo", Gollum::Page.cname("Foo")
|
||||||
assert_equal "Foo-Bar", Gollum::Page.cname("Foo Bar")
|
assert_equal "Foo-Bar", Gollum::Page.cname("Foo Bar")
|
||||||
assert_equal "Foo---Bar", Gollum::Page.cname("Foo / Bar")
|
# / is now a directory delimiter so it must be preserved
|
||||||
|
assert_equal "Foo-/-Bar", Gollum::Page.cname("Foo / Bar")
|
||||||
assert_equal "José", Gollum::Page.cname("José")
|
assert_equal "José", Gollum::Page.cname("José")
|
||||||
assert_equal "モルドール", Gollum::Page.cname("モルドール")
|
assert_equal "モルドール", Gollum::Page.cname("モルドール")
|
||||||
end
|
end
|
||||||
|
|||||||
+11
-2
@@ -19,7 +19,7 @@ context "Precious::Views::Pages" do
|
|||||||
|
|
||||||
test "breadcrumb" do
|
test "breadcrumb" do
|
||||||
@page.instance_variable_set("@path", "Mordor/Eye-Of-Sauron/Saruman")
|
@page.instance_variable_set("@path", "Mordor/Eye-Of-Sauron/Saruman")
|
||||||
@page.instance_variable_set("@base_url", "/")
|
@page.instance_variable_set("@base_url", "")
|
||||||
assert_equal '<a href="/pages/">Home</a> / <a href="/pages/Mordor/">Mordor</a> / <a href="/pages/Mordor/Eye-Of-Sauron/">Eye-Of-Sauron</a> / Saruman', @page.breadcrumb
|
assert_equal '<a href="/pages/">Home</a> / <a href="/pages/Mordor/">Mordor</a> / <a href="/pages/Mordor/Eye-Of-Sauron/">Eye-Of-Sauron</a> / Saruman', @page.breadcrumb
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -29,9 +29,18 @@ context "Precious::Views::Pages" do
|
|||||||
|
|
||||||
test "files_folders" do
|
test "files_folders" do
|
||||||
@page.instance_variable_set("@path", "Mordor")
|
@page.instance_variable_set("@path", "Mordor")
|
||||||
@page.instance_variable_set("@base_url", "/")
|
@page.instance_variable_set("@base_url", "")
|
||||||
results = [FakeResult.new("Mordor/Eye-Of-Sauron.md"), FakeResult.new("Mordor/Orc/Saruman.md"), FakeResult.new("Mordor/.gitkeep")]
|
results = [FakeResult.new("Mordor/Eye-Of-Sauron.md"), FakeResult.new("Mordor/Orc/Saruman.md"), FakeResult.new("Mordor/.gitkeep")]
|
||||||
@page.instance_variable_set("@results", results)
|
@page.instance_variable_set("@results", results)
|
||||||
assert_equal %{<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
assert_equal %{<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "base url" do
|
||||||
|
# based on test "files_folders"
|
||||||
|
@page.instance_variable_set("@path", "Mordor")
|
||||||
|
@page.instance_variable_set("@base_url", "/wiki")
|
||||||
|
results = [FakeResult.new("Mordor/Eye-Of-Sauron.md"), FakeResult.new("Mordor/Orc/Saruman.md"), FakeResult.new("Mordor/.gitkeep")]
|
||||||
|
@page.instance_variable_set("@results", results)
|
||||||
|
assert_equal %{<li><a href="/wiki/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/wiki/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+22
-1
@@ -15,12 +15,33 @@ context "Unicode Support" do
|
|||||||
FileUtils.rm_rf(@path)
|
FileUtils.rm_rf(@path)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "create and read non-latin page" do
|
test "uri encode" do
|
||||||
|
c = '한글'
|
||||||
|
assert_equal '%ED%95%9C%EA%B8%80', encodeURIComponent(c)
|
||||||
|
assert_equal '%ED%95%9C%EA%B8%80', CGI::escape(c)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create and read non-latin page with anchor" do
|
||||||
@wiki.write_page("test", :markdown, "# 한글")
|
@wiki.write_page("test", :markdown, "# 한글")
|
||||||
|
|
||||||
page = @wiki.page("test")
|
page = @wiki.page("test")
|
||||||
assert_equal Gollum::Page, page.class
|
assert_equal Gollum::Page, page.class
|
||||||
assert_equal "# 한글", utf8(page.raw_data)
|
assert_equal "# 한글", utf8(page.raw_data)
|
||||||
|
|
||||||
|
# markup.rb
|
||||||
|
# #简介
|
||||||
|
# href.gsub('%', '%25') so the anchor works in Firefox.
|
||||||
|
# <a href="#%25ED%2595%259C%25EA%25B8%2580" id="%ED%95%9C%EA%B8%80" class="anchor"></a>
|
||||||
|
doc = Nokogiri::HTML page.formatted_data
|
||||||
|
h1s = doc / :h1
|
||||||
|
h1 = h1s.first
|
||||||
|
anchors = h1 / :a
|
||||||
|
assert_equal 1, h1s.size
|
||||||
|
assert_equal 1, anchors.size
|
||||||
|
assert_equal '#%25ED%2595%259C%25EA%25B8%2580', anchors[0]['href']
|
||||||
|
assert_equal '%ED%95%9C%EA%B8%80', anchors[0]['id']
|
||||||
|
assert_equal 'anchor', anchors[0]['class']
|
||||||
|
assert_equal '', anchors[0].text
|
||||||
end
|
end
|
||||||
|
|
||||||
test "unicode with existing format rules" do
|
test "unicode with existing format rules" do
|
||||||
|
|||||||
Reference in New Issue
Block a user