gollum 2.2.3 → 2.2.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/README.md CHANGED
@@ -295,7 +295,7 @@ This is useful for writing about the link syntax in your wiki pages.
295
295
 
296
296
  Gollum has a special tag to insert a table of contents (new in v2.1)
297
297
 
298
- '[[_TOC_]]
298
+ [[_TOC_]]
299
299
 
300
300
  This tag is case sensitive, use all upper case. The TOC tag can be inserted
301
301
  into the `_Header`, `_Footer` or `_Sidebar` files too.
@@ -547,17 +547,14 @@ your changes merged back into core is as follows:
547
547
  1. Send a pull request to the github/gollum project.
548
548
 
549
549
  ## RELEASING
550
- For x.y releases:
551
- Update VERSION in lib/gollum.rb
552
- $ rake gemspec
553
-
554
550
  For z releases:
555
551
  $ rake bump
552
+ $ rake release
556
553
 
557
- $ git tag vX.Y.Z
558
- $ git push origin vX.Y.Z
559
- $ gem build gollum.gemspec
560
- $ gem push gollum-X.Y.Z.gem
554
+ For x.y releases:
555
+ Update VERSION in lib/gollum.rb
556
+ $ rake gemspec
557
+ $ rake release
561
558
 
562
559
  ## BUILDING THE GEM FROM MASTER
563
560
  $ gem uninstall -aIx gollum
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.2.3'
9
- s.date = '2012-10-10'
8
+ s.version = '2.2.4'
9
+ s.date = '2012-10-13'
10
10
  s.rubyforge_project = 'gollum'
11
11
 
12
12
  s.summary = "A simple, Git-powered wiki."
data/lib/gollum.rb CHANGED
@@ -23,7 +23,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
23
23
  require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
24
24
 
25
25
  module Gollum
26
- VERSION = '2.2.3'
26
+ VERSION = '2.2.4'
27
27
 
28
28
  def self.assets_path
29
29
  ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
@@ -23,5 +23,12 @@ module Precious
23
23
  return url if url.nil?
24
24
  url.gsub('%2F','/').gsub(/^\/+/,'')
25
25
  end
26
+
27
+ def trim_leading_slash url
28
+ return url if url.nil?
29
+ url.gsub!('%2F','/')
30
+ return '/' + url.gsub(/^\/+/,'') if url[0,1] == '/'
31
+ url
32
+ end
26
33
  end
27
34
  end
@@ -194,8 +194,8 @@ var previewSet = function( text ) {
194
194
  }
195
195
  };
196
196
 
197
- // 'c', 'c++', 'cpp' are github specific and transformed to c_cpp for Ace.
198
- // 'coffeescript' is transformed to 'coffee' for Ace.
197
+ // See pygmentsLanguageToAceMode for pygment to ace mode translations.
198
+ // TODO: Update languages and translation once Ace is upgraded to v1.0.
199
199
  var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee',
200
200
  'coffeescript', 'coldfusion', 'csharp', 'css', 'diff', 'golang',
201
201
  'groovy', 'haxe', 'html', 'java', 'javascript', 'json', 'latex',
@@ -244,6 +244,31 @@ function highlight( element, language ) {
244
244
  element.parentNode.parentNode.replaceChild( newDiv, element.parentNode );
245
245
  }
246
246
 
247
+ // Pygments and Ace have different names for languages.
248
+ function pygmentsLanguageToAceMode( declaredLanguage ) {
249
+ declaredLanguage = declaredLanguage.toLowerCase();
250
+
251
+ switch ( declaredLanguage ) {
252
+ case 'bash':
253
+ return 'sh';
254
+ case 'c':
255
+ case 'c++':
256
+ case 'cpp':
257
+ case 'objective-c':
258
+ return 'c_cpp';
259
+ case 'c#':
260
+ return 'csharp';
261
+ case 'coffeescript':
262
+ return 'coffee';
263
+ case 'html+erb':
264
+ return 'html'
265
+ }
266
+
267
+ // Assume language name is the same
268
+ // if it's not handled above.
269
+ return declaredLanguage;
270
+ }
271
+
247
272
  var makePreviewHtml = function () {
248
273
  var text = editorSession.getValue();
249
274
 
@@ -294,21 +319,7 @@ var makePreviewHtml = function () {
294
319
  // the syntax for code highlighting means all code, even one line, contains newlines.
295
320
  if ( txt.length > 1 && codeHTML.match( /\n/ ) ) {
296
321
  var declaredLanguage = element.className.toLowerCase();
297
- var aceMode = declaredLanguage;
298
-
299
- // GitHub supports 'c', 'c++', 'cpp'
300
- // which must trigger the 'c_cpp' mode in Ace.
301
- if ( declaredLanguage === 'c' ||
302
- declaredLanguage === 'c++' ||
303
- declaredLanguage === 'cpp' ) {
304
- aceMode = 'c_cpp';
305
- }
306
-
307
- // Pygments's name for CoffeeScript is 'coffeescript', but Ace
308
- // calls it 'coffee'.
309
- if ( declaredLanguage === 'coffeescript' ) {
310
- aceMode = 'coffee';
311
- }
322
+ var aceMode = pygmentsLanguageToAceMode( declaredLanguage );
312
323
 
313
324
  if ( $.inArray( declaredLanguage, languages ) === -1 ) {
314
325
  // Unsupported language.
data/lib/gollum/markup.rb CHANGED
@@ -122,7 +122,7 @@ module Gollum
122
122
  end
123
123
  node = Nokogiri::XML::Node.new('li', doc)
124
124
  # % -> %25 so anchors work on Firefox. See issue #475
125
- node.add_child("<a href='##{id.gsub('%', '%25')}'>#{h.content}</a>")
125
+ node.add_child(%Q{<a href="##{id.gsub("%", "%25")}">#{h.content}</a>})
126
126
  tail.add_child(node)
127
127
  end
128
128
  toc = toc.to_xhtml if toc != nil
@@ -407,6 +407,12 @@ module Gollum
407
407
  presence = "present"
408
408
  end
409
409
  link = ::File.join(@wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name))
410
+
411
+ # //page is invalid
412
+ # strip all duplicate forward slashes using helpers.rb trim_leading_slash
413
+ # //page => /page
414
+ link = trim_leading_slash link
415
+
410
416
  %{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
411
417
  end
412
418
  end
@@ -505,6 +511,28 @@ module Gollum
505
511
  #
506
512
  # Returns the placeholder'd String data.
507
513
  def extract_code(data)
514
+ data.gsub!(/^([ \t]*)~~~ ?([^\r\n]+)?\r?\n(.+?)\r?\n\1~~~\r?$/m) do
515
+ m_indent = $1
516
+ m_lang = $2
517
+ m_code = $3
518
+
519
+ lang = m_lang ? m_lang.strip : nil
520
+ id = Digest::SHA1.hexdigest("#{lang}.#{m_code}")
521
+ cached = check_cache(:code, id)
522
+
523
+ # extract lang from { .ruby } or { #stuff .ruby .indent }
524
+ # see http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
525
+
526
+ lang = lang.match(/\.([^}\s]+)/)
527
+ lang = lang[1] unless lang.nil?
528
+
529
+ @codemap[id] = cached ?
530
+ { :output => cached } :
531
+ { :lang => lang, :code => m_code, :indent => m_indent }
532
+
533
+ "#{m_indent}#{id}" # print the SHA1 ID with the proper indentation
534
+ end
535
+
508
536
  data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```\r?$/m) do
509
537
  lang = $2 ? $2.strip : nil
510
538
  id = Digest::SHA1.hexdigest("#{lang}.#{$3}")
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.2.3
4
+ version: 2.2.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-10 00:00:00.000000000 Z
13
+ date: 2012-10-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: grit