gollum 2.3.3 → 2.3.4

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/gollum.gemspec CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.required_ruby_version = ">= 1.8.7"
6
6
 
7
7
  s.name = 'gollum'
8
- s.version = '2.3.3'
9
- s.date = '2012-10-23'
8
+ s.version = '2.3.4'
9
+ s.date = '2012-10-28'
10
10
  s.rubyforge_project = 'gollum'
11
11
 
12
12
  s.summary = "A simple, Git-powered wiki."
@@ -41,6 +41,9 @@ Gem::Specification.new do |s|
41
41
  s.add_development_dependency('rack-test', '~> 0.6.2')
42
42
  s.add_development_dependency('wikicloth', '~> 0.8.0')
43
43
  s.add_development_dependency('rake', '~> 0.9')
44
+ s.add_development_dependency('pry', '~> 0.9.10')
45
+ # required by pry
46
+ s.add_development_dependency('rb-readline', '~> 0.4.2')
44
47
 
45
48
  # = MANIFEST =
46
49
  s.files = %w[
@@ -92,6 +95,7 @@ Gem::Specification.new do |s|
92
95
  lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
93
96
  lib/gollum/frontend/public/gollum/livepreview/css/custom.css
94
97
  lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png
98
+ lib/gollum/frontend/public/gollum/livepreview/images/globe_24.png
95
99
  lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png
96
100
  lib/gollum/frontend/public/gollum/livepreview/images/save_24.png
97
101
  lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png
data/lib/gollum.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  # stdlib
2
3
  require 'digest/md5'
3
4
  require 'ostruct'
@@ -22,7 +23,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
22
23
  require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
23
24
 
24
25
  module Gollum
25
- VERSION = '2.3.3'
26
+ VERSION = '2.3.4'
26
27
 
27
28
  def self.assets_path
28
29
  ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  class BlobEntry
3
4
  # Gets the String SHA for this blob.
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  # Responsible for handling the commit process for a Wiki. It sets up the
3
4
  # Git index, provides methods for modifying the tree, and stores callbacks
data/lib/gollum/file.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  class File
3
4
  Wiki.file_class = self
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  =begin
3
4
  FileView requires that:
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  require 'cgi'
2
3
  require 'sinatra'
3
4
  require 'gollum'
@@ -82,11 +83,12 @@ module Precious
82
83
 
83
84
  before do
84
85
  @base_url = url('/', false).chomp('/')
85
- settings.wiki_options.merge!({ :base_path => @base_url }) unless settings.wiki_options.has_key? :base_path
86
+ # above will detect base_path when it's used with map in a config.ru
87
+ settings.wiki_options.merge!({ :base_path => @base_url })
86
88
  end
87
89
 
88
90
  get '/' do
89
- redirect File.join(settings.wiki_options[:page_file_dir].to_s,settings.wiki_options[:base_path].to_s, 'Home')
91
+ redirect ::File.join(@base_url, 'Home')
90
92
  end
91
93
 
92
94
  # path is set to name if path is nil.
@@ -187,24 +189,20 @@ module Precious
187
189
 
188
190
  post '/create' do
189
191
  name = params[:page].to_url
190
- path = sanitize_empty_params(params[:path])
191
- path = '' if path.nil?
192
+ path = sanitize_empty_params(params[:path]) || ''
192
193
  format = params[:format].intern
193
194
 
194
- page_dir = File.join(settings.wiki_options[:page_file_dir].to_s,
195
- settings.wiki_options[:base_path].to_s)
196
- # Home is a special case.
197
- path = '' if name.downcase == 'home'
198
-
199
- page_dir = File.join(page_dir, path)
195
+ # ensure pages are created in page_file_dir
196
+ page_dir = settings.wiki_options[:page_file_dir].to_s
197
+ path = clean_url(::File.join(page_dir, path)) unless path.start_with?(page_dir)
200
198
 
201
199
  # write_page is not directory aware so use wiki_options to emulate dir support.
202
- wiki_options = settings.wiki_options.merge({ :page_file_dir => page_dir })
200
+ wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
203
201
  wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
204
202
 
205
203
  begin
206
204
  wiki.write_page(name, format, params[:content], commit_message)
207
- redirect to("/#{clean_url(CGI.escape(::File.join(page_dir,name)))}")
205
+ redirect to("/#{clean_url(::File.join(path,name))}")
208
206
  rescue Gollum::DuplicatePageError => e
209
207
  @message = "Duplicate page: #{e.message}"
210
208
  mustache :error
@@ -329,13 +327,15 @@ module Precious
329
327
  end
330
328
 
331
329
  get '/fileview' do
332
- wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
333
- show_all = settings.wiki_options[:show_all]
330
+ wiki = wiki_new
331
+ options = settings.wiki_options
332
+ content = wiki.pages
334
333
  # if showing all files include wiki.files
335
- # must pass wiki_options for both because
334
+ content += wiki.files if options[:show_all]
335
+
336
+ # must pass wiki_options to FileView
336
337
  # --show-all and --collapse-tree can be set.
337
- @results = show_all ? Gollum::FileView.new(wiki.pages + wiki.files, settings.wiki_options).render_files :
338
- Gollum::FileView.new(wiki.pages, settings.wiki_options).render_files
338
+ @results = Gollum::FileView.new(content, options).render_files
339
339
  @ref = wiki.ref
340
340
  mustache :file_view, { :layout => false }
341
341
  end
@@ -346,10 +346,11 @@ module Precious
346
346
 
347
347
  def show_page_or_file(fullpath)
348
348
  name = extract_name(fullpath)
349
- path = extract_path(fullpath)
349
+ path = extract_path(fullpath) || '/'
350
350
  wiki = wiki_new
351
351
 
352
- path = '/' if path.nil?
352
+ page_dir = settings.wiki_options[:page_file_dir].to_s
353
+ path = ::File.join(page_dir, path) unless path.start_with?(page_dir)
353
354
 
354
355
  if page = wiki.paged(name, path, exact = true)
355
356
  @page = page
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Precious
2
3
  module Helpers
3
4
  # Extract the path string that Gollum::Wiki expects
@@ -19,9 +20,10 @@ module Precious
19
20
  end
20
21
 
21
22
  # Remove all slashes from the start of string.
23
+ # Remove all double slashes
22
24
  def clean_url url
23
25
  return url if url.nil?
24
- url.gsub('%2F','/').gsub(/^\/+/,'')
26
+ url.gsub('%2F','/').gsub(/^\/+/,'').gsub('//','/')
25
27
  end
26
28
 
27
29
  def trim_leading_slash url
@@ -11,6 +11,7 @@
11
11
  <div id='previewframe'><div id='contentframe' class='markdown-body'></div></div>
12
12
  <!-- tool panel from notepage.es. save & savecomment icons from Retina Display Icon Set. -->
13
13
  <div id='toolpanel' class='toolpanel edit' style='width: 500px; right: 0px; visibility: hidden;'>
14
+ <a id='preview' class='edit'><img src='images/globe_24.png' alt='Preview' title='Preview'></a>
14
15
  <a id='save' class='edit'><img src='images/save_24.png' alt='Save' title='Save'></a>
15
16
  <a id='savecomment' class='edit'><img src='images/savecomment_24.png' alt='Save with comment' title='Save with comment'></a>
16
17
  <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>
@@ -87,6 +87,18 @@ defaultCommitMessage = function() {
87
87
  // Set comment using the default commit message.
88
88
  commentEditorSession.setValue( defaultCommitMessage() );
89
89
 
90
+ $.preview = function( previewWindow ) {
91
+ jQuery.ajax( {
92
+ type: 'POST',
93
+ url: baseUrl + '/preview',
94
+ data: { page: 'Preview: ' + pageName, format: 'markdown', content: editorSession.getValue() },
95
+ success: function( html ) {
96
+ previewWindow.document.write( html );
97
+ previewWindow.focus();
98
+ }
99
+ });
100
+ }
101
+
90
102
  $.save = function( commitMessage ) {
91
103
  win.onbeforeunload = null;
92
104
 
@@ -377,8 +389,16 @@ var applyTimeout = function () {
377
389
  });
378
390
  }
379
391
 
392
+ $( '#preview' ).click( function() {
393
+ $(this).target = "_blank";
394
+ // pass window into preview
395
+ $.preview( window.open() );
396
+ return false;
397
+ });
398
+
380
399
  $( '#save' ).click( function() {
381
400
  $.save();
401
+ return false;
382
402
  });
383
403
 
384
404
  // Hide dimmer, comment tool panel, and comment.
@@ -15,7 +15,10 @@ CC BY-SA 3.0 Unported
15
15
  http://blog.twg.ca/2010/11/retina-display-icon-set/
16
16
  http://creativecommons.org/licenses/by-sa/3.0/legalcode.txt
17
17
 
18
+ lib/gollum/frontend/public/images/savecomment_24.png
19
+ lib/gollum/frontend/public/images/cancel_24.png
18
20
  lib/gollum/frontend/public/images/save_24.png
21
+ lib/gollum/frontend/public/images/globe_24.png
19
22
 
20
23
  ---
21
24
 
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  # Controls all access to the Git objects from Gollum. Extend this class to
3
4
  # add custom caching for special cases.
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  require 'net/http'
2
3
  require 'net/https' # ruby 1.8.7 fix, remove at upgrade
3
4
  require 'uri'
data/lib/gollum/markup.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  require 'digest/sha1'
2
3
  require 'cgi'
3
4
  require 'pygments'
@@ -37,6 +38,7 @@ module Gollum
37
38
  @premap = {}
38
39
  @toc = nil
39
40
  @metadata = nil
41
+ @to_xml = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' }
40
42
  end
41
43
 
42
44
  # Render the content with Gollum wiki syntax on top of the file's own
@@ -74,13 +76,18 @@ module Gollum
74
76
  doc,toc = process_headers(doc)
75
77
  @toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
76
78
  yield doc if block_given?
77
- data = doc.to_xhtml
79
+ # nokogiri's save options are ored together. FORMAT has a value of 1 so ^ 1 removes it.
80
+ # formatting will create extra spaces in pre tags.
81
+ # https://github.com/sparklemotion/nokogiri/issues/782
82
+ # DEFAULT_HTML encodes unicode so XHTML is used for proper unicode support in href.
83
+ data = doc.to_xml( @to_xml )
78
84
 
79
85
  data = process_toc_tags(data)
80
86
  data = process_wsd(data)
81
87
  data.gsub!(/<p><\/p>/) do
82
88
  ''
83
89
  end
90
+
84
91
  data
85
92
  end
86
93
 
@@ -119,7 +126,7 @@ module Gollum
119
126
  node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
120
127
  tail.add_child(node)
121
128
  end
122
- toc = toc.to_xhtml if toc != nil
129
+ toc = toc.to_xml(@to_xml) if toc != nil
123
130
  [doc, toc]
124
131
  end
125
132
 
data/lib/gollum/page.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  class Page
3
4
  include Pagination
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  module Pagination
3
4
  def self.included(klass)
@@ -58,4 +59,4 @@ module Gollum
58
59
  self.class.log_pagination_options(options)
59
60
  end
60
61
  end
61
- end
62
+ end
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  # Encapsulate sanitization options.
3
4
  #
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  require 'net/http'
2
3
  require 'uri'
3
4
  require 'open-uri'
data/lib/gollum/wiki.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # ~*~ encoding: utf-8 ~*~
1
2
  module Gollum
2
3
  class Wiki
3
4
  include Pagination
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.3.3
4
+ version: 2.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-23 00:00:00.000000000 Z
13
+ date: 2012-10-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: grit
@@ -296,6 +296,38 @@ dependencies:
296
296
  - - ~>
297
297
  - !ruby/object:Gem::Version
298
298
  version: '0.9'
299
+ - !ruby/object:Gem::Dependency
300
+ name: pry
301
+ requirement: !ruby/object:Gem::Requirement
302
+ none: false
303
+ requirements:
304
+ - - ~>
305
+ - !ruby/object:Gem::Version
306
+ version: 0.9.10
307
+ type: :development
308
+ prerelease: false
309
+ version_requirements: !ruby/object:Gem::Requirement
310
+ none: false
311
+ requirements:
312
+ - - ~>
313
+ - !ruby/object:Gem::Version
314
+ version: 0.9.10
315
+ - !ruby/object:Gem::Dependency
316
+ name: rb-readline
317
+ requirement: !ruby/object:Gem::Requirement
318
+ none: false
319
+ requirements:
320
+ - - ~>
321
+ - !ruby/object:Gem::Version
322
+ version: 0.4.2
323
+ type: :development
324
+ prerelease: false
325
+ version_requirements: !ruby/object:Gem::Requirement
326
+ none: false
327
+ requirements:
328
+ - - ~>
329
+ - !ruby/object:Gem::Version
330
+ version: 0.4.2
299
331
  description: A simple, Git-powered wiki with a sweet API and local frontend.
300
332
  email: tom@github.com
301
333
  executables:
@@ -353,6 +385,7 @@ files:
353
385
  - lib/gollum/frontend/public/gollum/javascript/mousetrap.min.js
354
386
  - lib/gollum/frontend/public/gollum/livepreview/css/custom.css
355
387
  - lib/gollum/frontend/public/gollum/livepreview/images/cancel_24.png
388
+ - lib/gollum/frontend/public/gollum/livepreview/images/globe_24.png
356
389
  - lib/gollum/frontend/public/gollum/livepreview/images/lr_24.png
357
390
  - lib/gollum/frontend/public/gollum/livepreview/images/save_24.png
358
391
  - lib/gollum/frontend/public/gollum/livepreview/images/savecomment_24.png