gollum 2.4.15 → 2.5.0

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

Potentially problematic release.


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

data/bin/gollum CHANGED
@@ -19,7 +19,10 @@ require 'gollum'
19
19
 
20
20
  exec = {}
21
21
  options = { 'port' => 4567, 'bind' => '0.0.0.0' }
22
- wiki_options = {}
22
+ wiki_options = {
23
+ :live_preview => false,
24
+ :allow_uploads => false,
25
+ }
23
26
 
24
27
  opts = OptionParser.new do |opts|
25
28
  opts.banner = help
@@ -73,6 +76,14 @@ opts = OptionParser.new do |opts|
73
76
  wiki_options[:live_preview] = false
74
77
  end
75
78
 
79
+ opts.on("--live-preview", "Enables livepreview.") do
80
+ wiki_options[:live_preview] = true
81
+ end
82
+
83
+ opts.on("--allow-uploads", "Allows file uploads.") do
84
+ wiki_options[:allow_uploads] = true
85
+ end
86
+
76
87
  opts.on("--mathjax", "Enables mathjax.") do
77
88
  wiki_options[:mathjax] = true
78
89
  end
@@ -2,11 +2,11 @@ Gem::Specification.new do |s|
2
2
  s.specification_version = 2 if s.respond_to? :specification_version=
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
  s.rubygems_version = '1.3.5'
5
- s.required_ruby_version = ">= 1.8.7"
5
+ s.required_ruby_version = ">= 1.9"
6
6
 
7
7
  s.name = 'gollum'
8
- s.version = '2.4.15'
9
- s.date = '2013-06-18'
8
+ s.version = '2.5.0'
9
+ s.date = '2013-07-21'
10
10
  s.rubyforge_project = 'gollum'
11
11
  s.license = 'MIT'
12
12
 
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.rdoc_options = ["--charset=UTF-8"]
25
25
  s.extra_rdoc_files = %w[README.md LICENSE]
26
26
 
27
- s.add_dependency 'gollum-lib', '~> 1.0.3'
27
+ s.add_dependency 'gollum-lib', '~> 1.0.4'
28
28
  s.add_dependency 'sinatra', '~> 1.4.2'
29
29
  s.add_dependency 'mustache', ['>= 0.99.4', '< 1.0.0']
30
30
  s.add_dependency 'useragent', '~> 0.6.0'
@@ -17,7 +17,7 @@ require File.expand_path('../gollum/uri_encode_component', __FILE__)
17
17
  $KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
18
18
 
19
19
  module Gollum
20
- VERSION = '2.4.15'
20
+ VERSION = '2.5.0'
21
21
 
22
22
  def self.assets_path
23
23
  ::File.expand_path('gollum/public', ::File.dirname(__FILE__))
@@ -13,6 +13,10 @@ require 'gollum/views/has_page'
13
13
 
14
14
  require File.expand_path '../helpers', __FILE__
15
15
 
16
+ #required to upload bigger binary files
17
+ Grit::Git.git_timeout = 120 # timeout in secs
18
+ Grit::Git.git_max_size = 190 * 10**6 # size in bytes (10^6=1 MB)
19
+
16
20
  # Fix to_url
17
21
  class String
18
22
  alias :upstream_to_url :to_url
@@ -146,6 +150,53 @@ module Precious
146
150
  end
147
151
  end
148
152
 
153
+ post '/uploadFile' do
154
+ wiki = wiki_new
155
+
156
+ unless wiki.allow_uploads
157
+ @message = "File uploads are disabled"
158
+ mustache :error
159
+ return
160
+ end
161
+
162
+ if params[:file]
163
+ fullname = params[:file][:filename]
164
+ tempfile = params[:file][:tempfile]
165
+ end
166
+
167
+ dir = 'uploads'
168
+ ext = ::File.extname(fullname)
169
+ format = ext.split('.').last || 'txt'
170
+ filename = ::File.basename(fullname, ext)
171
+ contents = ::File.read(tempfile)
172
+ reponame = filename + '.' + format
173
+
174
+ head = wiki.repo.head
175
+
176
+ options = {
177
+ :message => "Uploaded file to uploads/#{reponame}",
178
+ :parent => wiki.repo.head.commit,
179
+ }
180
+ author = session['gollum.author']
181
+ unless author.nil?
182
+ options.merge! author
183
+ end
184
+
185
+ begin
186
+ committer = Gollum::Committer.new(wiki, options)
187
+ committer.add_to_index(dir, filename, format, contents)
188
+ committer.after_commit do |committer, sha|
189
+ wiki.clear_cache
190
+ committer.update_working_dir(dir, filename, format)
191
+ end
192
+ committer.commit
193
+ redirect to('/')
194
+ rescue Gollum::DuplicatePageError => e
195
+ @message = "Duplicate page: #{e.message}"
196
+ mustache :error
197
+ end
198
+ end
199
+
149
200
  post '/rename/*' do
150
201
  wikip = wiki_page(params[:splat].first)
151
202
  halt 500 if wikip.nil?
@@ -283,6 +334,7 @@ module Precious
283
334
  @mathjax = wiki.mathjax
284
335
  @h1_title = wiki.h1_title
285
336
  @editable = false
337
+ @allow_uploads = wiki.allow_uploads
286
338
  mustache :page
287
339
  end
288
340
 
@@ -401,6 +453,7 @@ module Precious
401
453
  @mathjax = wiki.mathjax
402
454
  @h1_title = wiki.h1_title
403
455
  @bar_side = wiki.bar_side
456
+ @allow_uploads = wiki.allow_uploads
404
457
 
405
458
  mustache :page
406
459
  elsif file = wiki.file(fullpath, wiki.ref, true)
@@ -37,11 +37,14 @@
37
37
  fieldMarkup += '<div class="field">';
38
38
  switch ( fieldArray[i].type ) {
39
39
 
40
- // only text is supported for now
41
40
  case 'text':
42
41
  fieldMarkup += Dialog.createFieldText( fieldArray[i] );
43
42
  break;
44
43
 
44
+ case 'file':
45
+ fieldMarkup += Dialog.createFieldFile( fieldArray[i] );
46
+ break;
47
+
45
48
  default:
46
49
  break;
47
50
 
@@ -60,7 +63,7 @@
60
63
  if ( fieldAttributes.name ) {
61
64
  html += '<label';
62
65
  if ( fieldAttributes.id ) {
63
- html += ' for="' + fieldAttributes.name + '"';
66
+ html += ' for="gollum-dialog-dialog-generated-field-' + fieldAttributes.id + '"';
64
67
  }
65
68
  html += '>' + fieldAttributes.name + '</label>';
66
69
  }
@@ -86,6 +89,22 @@
86
89
  return html;
87
90
  },
88
91
 
92
+ createFieldFile: function( fieldAttributes ) {
93
+ // Not actually a field, but an embedded form.
94
+ var html = '';
95
+
96
+ var id = fieldAttributes.id || 'upload';
97
+ var name = fieldAttributes.name || 'file';
98
+ var action = fieldAttributes.action || 'uploadFile';
99
+
100
+ html += '<form method=post enctype="multipart/form-data" ' +
101
+ 'action="' + action + '" ' + 'id="' + id + '">';
102
+ html += '<input type=file name="' + name + '">';
103
+ html += '</form>';
104
+
105
+ return html;
106
+ },
107
+
89
108
  createMarkup: function( title, body ) {
90
109
  Dialog.markupCreated = true;
91
110
  if ($.facebox) {
@@ -145,6 +145,25 @@ $(document).ready(function() {
145
145
  }
146
146
  }
147
147
 
148
+ if ($('#minibutton-upload-page').length) {
149
+ $('#minibutton-upload-page').parent().removeClass('jaws');
150
+ $('#minibutton-upload-page').click(function(e) {
151
+ e.preventDefault();
152
+
153
+ $.GollumDialog.init({
154
+ title: 'Upload File',
155
+ fields: [
156
+ {
157
+ type: 'file'
158
+ }
159
+ ],
160
+ OK: function( res ) {
161
+ $('#upload').submit();
162
+ }
163
+ });
164
+ });
165
+ }
166
+
148
167
  if ($('#minibutton-rename-page').length) {
149
168
  $('#minibutton-rename-page').parent().removeClass('jaws');
150
169
  $('#minibutton-rename-page').click(function(e) {
@@ -20,6 +20,10 @@ Mousetrap.bind(['e'], function( e ) {
20
20
  class="action-fileview">Files</a></li>
21
21
  <li class="minibutton jaws">
22
22
  <a href="#" id="minibutton-new-page">New</a></li>
23
+ {{#allow_uploads}}
24
+ <li class="minibutton jaws">
25
+ <a href="#" id="minibutton-upload-page">Upload</a></li>
26
+ {{/allow_uploads}}
23
27
  {{#editable}}
24
28
  <li class="minibutton jaws">
25
29
  <a href="#" id="minibutton-rename-page">Rename</a></li>
@@ -39,6 +39,10 @@ module Precious
39
39
  @editable
40
40
  end
41
41
 
42
+ def allow_uploads
43
+ @allow_uploads
44
+ end
45
+
42
46
  def has_header
43
47
  @header = (@page.header || false) if @header.nil?
44
48
  !!@header
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.15
4
+ version: 2.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-18 00:00:00.000000000 Z
13
+ date: 2013-07-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gollum-lib
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 1.0.3
22
+ version: 1.0.4
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,7 +27,7 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- version: 1.0.3
30
+ version: 1.0.4
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: sinatra
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -654,7 +654,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
654
654
  requirements:
655
655
  - - ! '>='
656
656
  - !ruby/object:Gem::Version
657
- version: 1.8.7
657
+ version: '1.9'
658
658
  required_rubygems_version: !ruby/object:Gem::Requirement
659
659
  none: false
660
660
  requirements: