Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9c714e7687 | |||
| 6c3523d61c | |||
| 183840b793 | |||
| 4e2856aa64 | |||
| 4627a39165 | |||
| c87cbe83d2 | |||
| f05282badf | |||
| 957879346e | |||
| 87e64f67f3 | |||
| 43840d246d | |||
| 4aeb9af8a7 | |||
| b37acb8bc6 | |||
| 433865e927 | |||
| 5428161e0f |
@@ -1,8 +1,4 @@
|
|||||||
rvm:
|
rvm:
|
||||||
- 1.8.7
|
|
||||||
- 1.9.3
|
- 1.9.3
|
||||||
notifications:
|
|
||||||
email:
|
|
||||||
- code@bootstraponline.com
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update
|
- sudo apt-get update
|
||||||
|
|||||||
+12
-1
@@ -19,7 +19,10 @@ require 'gollum'
|
|||||||
|
|
||||||
exec = {}
|
exec = {}
|
||||||
options = { 'port' => 4567, 'bind' => '0.0.0.0' }
|
options = { 'port' => 4567, 'bind' => '0.0.0.0' }
|
||||||
wiki_options = {}
|
wiki_options = {
|
||||||
|
:live_preview => false,
|
||||||
|
:allow_uploads => false,
|
||||||
|
}
|
||||||
|
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |opts|
|
||||||
opts.banner = help
|
opts.banner = help
|
||||||
@@ -73,6 +76,14 @@ opts = OptionParser.new do |opts|
|
|||||||
wiki_options[:live_preview] = false
|
wiki_options[:live_preview] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("--live-preview", "Enables livepreview.") do
|
||||||
|
wiki_options[:live_preview] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("--allow-uploads", "Allows file uploads.") do
|
||||||
|
wiki_options[:allow_uploads] = true
|
||||||
|
end
|
||||||
|
|
||||||
opts.on("--mathjax", "Enables mathjax.") do
|
opts.on("--mathjax", "Enables mathjax.") do
|
||||||
wiki_options[:mathjax] = true
|
wiki_options[:mathjax] = true
|
||||||
end
|
end
|
||||||
|
|||||||
+4
-4
@@ -2,11 +2,11 @@ Gem::Specification.new do |s|
|
|||||||
s.specification_version = 2 if s.respond_to? :specification_version=
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.rubygems_version = '1.3.5'
|
s.rubygems_version = '1.3.5'
|
||||||
s.required_ruby_version = ">= 1.8.7"
|
s.required_ruby_version = ">= 1.9"
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '2.4.14'
|
s.version = '2.5.0'
|
||||||
s.date = '2013-06-15'
|
s.date = '2013-07-21'
|
||||||
s.rubyforge_project = 'gollum'
|
s.rubyforge_project = 'gollum'
|
||||||
s.license = 'MIT'
|
s.license = 'MIT'
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|||||||
s.rdoc_options = ["--charset=UTF-8"]
|
s.rdoc_options = ["--charset=UTF-8"]
|
||||||
s.extra_rdoc_files = %w[README.md LICENSE]
|
s.extra_rdoc_files = %w[README.md LICENSE]
|
||||||
|
|
||||||
s.add_dependency 'gollum-lib', '~> 1.0.2'
|
s.add_dependency 'gollum-lib', '~> 1.0.4'
|
||||||
s.add_dependency 'sinatra', '~> 1.4.2'
|
s.add_dependency 'sinatra', '~> 1.4.2'
|
||||||
s.add_dependency 'mustache', ['>= 0.99.4', '< 1.0.0']
|
s.add_dependency 'mustache', ['>= 0.99.4', '< 1.0.0']
|
||||||
s.add_dependency 'useragent', '~> 0.6.0'
|
s.add_dependency 'useragent', '~> 0.6.0'
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ require File.expand_path('../gollum/uri_encode_component', __FILE__)
|
|||||||
$KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
|
$KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '2.4.14'
|
VERSION = '2.5.0'
|
||||||
|
|
||||||
def self.assets_path
|
def self.assets_path
|
||||||
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
||||||
|
|||||||
+60
-3
@@ -13,6 +13,10 @@ require 'gollum/views/has_page'
|
|||||||
|
|
||||||
require File.expand_path '../helpers', __FILE__
|
require File.expand_path '../helpers', __FILE__
|
||||||
|
|
||||||
|
#required to upload bigger binary files
|
||||||
|
Grit::Git.git_timeout = 120 # timeout in secs
|
||||||
|
Grit::Git.git_max_size = 190 * 10**6 # size in bytes (10^6=1 MB)
|
||||||
|
|
||||||
# Fix to_url
|
# Fix to_url
|
||||||
class String
|
class String
|
||||||
alias :upstream_to_url :to_url
|
alias :upstream_to_url :to_url
|
||||||
@@ -146,6 +150,53 @@ module Precious
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post '/uploadFile' do
|
||||||
|
wiki = wiki_new
|
||||||
|
|
||||||
|
unless wiki.allow_uploads
|
||||||
|
@message = "File uploads are disabled"
|
||||||
|
mustache :error
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:file]
|
||||||
|
fullname = params[:file][:filename]
|
||||||
|
tempfile = params[:file][:tempfile]
|
||||||
|
end
|
||||||
|
|
||||||
|
dir = 'uploads'
|
||||||
|
ext = ::File.extname(fullname)
|
||||||
|
format = ext.split('.').last || 'txt'
|
||||||
|
filename = ::File.basename(fullname, ext)
|
||||||
|
contents = ::File.read(tempfile)
|
||||||
|
reponame = filename + '.' + format
|
||||||
|
|
||||||
|
head = wiki.repo.head
|
||||||
|
|
||||||
|
options = {
|
||||||
|
:message => "Uploaded file to uploads/#{reponame}",
|
||||||
|
:parent => wiki.repo.head.commit,
|
||||||
|
}
|
||||||
|
author = session['gollum.author']
|
||||||
|
unless author.nil?
|
||||||
|
options.merge! author
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
committer = Gollum::Committer.new(wiki, options)
|
||||||
|
committer.add_to_index(dir, filename, format, contents)
|
||||||
|
committer.after_commit do |committer, sha|
|
||||||
|
wiki.clear_cache
|
||||||
|
committer.update_working_dir(dir, filename, format)
|
||||||
|
end
|
||||||
|
committer.commit
|
||||||
|
redirect to('/')
|
||||||
|
rescue Gollum::DuplicatePageError => e
|
||||||
|
@message = "Duplicate page: #{e.message}"
|
||||||
|
mustache :error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
post '/rename/*' do
|
post '/rename/*' do
|
||||||
wikip = wiki_page(params[:splat].first)
|
wikip = wiki_page(params[:splat].first)
|
||||||
halt 500 if wikip.nil?
|
halt 500 if wikip.nil?
|
||||||
@@ -283,6 +334,7 @@ module Precious
|
|||||||
@mathjax = wiki.mathjax
|
@mathjax = wiki.mathjax
|
||||||
@h1_title = wiki.h1_title
|
@h1_title = wiki.h1_title
|
||||||
@editable = false
|
@editable = false
|
||||||
|
@allow_uploads = wiki.allow_uploads
|
||||||
mustache :page
|
mustache :page
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -401,11 +453,16 @@ module Precious
|
|||||||
@mathjax = wiki.mathjax
|
@mathjax = wiki.mathjax
|
||||||
@h1_title = wiki.h1_title
|
@h1_title = wiki.h1_title
|
||||||
@bar_side = wiki.bar_side
|
@bar_side = wiki.bar_side
|
||||||
|
@allow_uploads = wiki.allow_uploads
|
||||||
|
|
||||||
mustache :page
|
mustache :page
|
||||||
elsif file = wiki.file(fullpath)
|
elsif file = wiki.file(fullpath, wiki.ref, true)
|
||||||
content_type file.mime_type
|
if file.on_disk?
|
||||||
file.raw_data
|
send_file file.on_disk_path, :disposition => 'inline'
|
||||||
|
else
|
||||||
|
content_type file.mime_type
|
||||||
|
file.raw_data
|
||||||
|
end
|
||||||
else
|
else
|
||||||
page_path = [path, name].compact.join('/')
|
page_path = [path, name].compact.join('/')
|
||||||
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
|
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
|
||||||
|
|||||||
@@ -37,11 +37,14 @@
|
|||||||
fieldMarkup += '<div class="field">';
|
fieldMarkup += '<div class="field">';
|
||||||
switch ( fieldArray[i].type ) {
|
switch ( fieldArray[i].type ) {
|
||||||
|
|
||||||
// only text is supported for now
|
|
||||||
case 'text':
|
case 'text':
|
||||||
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
|
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'file':
|
||||||
|
fieldMarkup += Dialog.createFieldFile( fieldArray[i] );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -60,7 +63,7 @@
|
|||||||
if ( fieldAttributes.name ) {
|
if ( fieldAttributes.name ) {
|
||||||
html += '<label';
|
html += '<label';
|
||||||
if ( fieldAttributes.id ) {
|
if ( fieldAttributes.id ) {
|
||||||
html += ' for="' + fieldAttributes.name + '"';
|
html += ' for="gollum-dialog-dialog-generated-field-' + fieldAttributes.id + '"';
|
||||||
}
|
}
|
||||||
html += '>' + fieldAttributes.name + '</label>';
|
html += '>' + fieldAttributes.name + '</label>';
|
||||||
}
|
}
|
||||||
@@ -86,6 +89,22 @@
|
|||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createFieldFile: function( fieldAttributes ) {
|
||||||
|
// Not actually a field, but an embedded form.
|
||||||
|
var html = '';
|
||||||
|
|
||||||
|
var id = fieldAttributes.id || 'upload';
|
||||||
|
var name = fieldAttributes.name || 'file';
|
||||||
|
var action = fieldAttributes.action || 'uploadFile';
|
||||||
|
|
||||||
|
html += '<form method=post enctype="multipart/form-data" ' +
|
||||||
|
'action="' + action + '" ' + 'id="' + id + '">';
|
||||||
|
html += '<input type=file name="' + name + '">';
|
||||||
|
html += '</form>';
|
||||||
|
|
||||||
|
return html;
|
||||||
|
},
|
||||||
|
|
||||||
createMarkup: function( title, body ) {
|
createMarkup: function( title, body ) {
|
||||||
Dialog.markupCreated = true;
|
Dialog.markupCreated = true;
|
||||||
if ($.facebox) {
|
if ($.facebox) {
|
||||||
|
|||||||
@@ -145,6 +145,25 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($('#minibutton-upload-page').length) {
|
||||||
|
$('#minibutton-upload-page').parent().removeClass('jaws');
|
||||||
|
$('#minibutton-upload-page').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
$.GollumDialog.init({
|
||||||
|
title: 'Upload File',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: 'file'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
OK: function( res ) {
|
||||||
|
$('#upload').submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if ($('#minibutton-rename-page').length) {
|
if ($('#minibutton-rename-page').length) {
|
||||||
$('#minibutton-rename-page').parent().removeClass('jaws');
|
$('#minibutton-rename-page').parent().removeClass('jaws');
|
||||||
$('#minibutton-rename-page').click(function(e) {
|
$('#minibutton-rename-page').click(function(e) {
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ Mousetrap.bind(['e'], function( e ) {
|
|||||||
class="action-fileview">Files</a></li>
|
class="action-fileview">Files</a></li>
|
||||||
<li class="minibutton jaws">
|
<li class="minibutton jaws">
|
||||||
<a href="#" id="minibutton-new-page">New</a></li>
|
<a href="#" id="minibutton-new-page">New</a></li>
|
||||||
|
{{#allow_uploads}}
|
||||||
|
<li class="minibutton jaws">
|
||||||
|
<a href="#" id="minibutton-upload-page">Upload</a></li>
|
||||||
|
{{/allow_uploads}}
|
||||||
{{#editable}}
|
{{#editable}}
|
||||||
<li class="minibutton jaws">
|
<li class="minibutton jaws">
|
||||||
<a href="#" id="minibutton-rename-page">Rename</a></li>
|
<a href="#" id="minibutton-rename-page">Rename</a></li>
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ module Precious
|
|||||||
@editable
|
@editable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allow_uploads
|
||||||
|
@allow_uploads
|
||||||
|
end
|
||||||
|
|
||||||
def has_header
|
def has_header
|
||||||
@header = (@page.header || false) if @header.nil?
|
@header = (@page.header || false) if @header.nil?
|
||||||
!!@header
|
!!@header
|
||||||
|
|||||||
@@ -578,6 +578,12 @@ context "Frontend with lotr" do
|
|||||||
assert_match /Bilbo Baggins/, last_response.body
|
assert_match /Bilbo Baggins/, last_response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "streaming files to browser" do
|
||||||
|
get "/Data.csv"
|
||||||
|
assert last_response.ok?
|
||||||
|
assert last_response.headers.include? 'Content-Disposition'
|
||||||
|
end
|
||||||
|
|
||||||
# base path requires 'map' in a config.ru to work correctly.
|
# base path requires 'map' in a config.ru to work correctly.
|
||||||
test "create pages within sub-directories using base path" do
|
test "create pages within sub-directories using base path" do
|
||||||
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
Precious::App.set(:wiki_options, { :base_path => 'wiki' })
|
||||||
|
|||||||
Reference in New Issue
Block a user