[DRE-commits] [ruby-gollum-lib] 06/08: New upstream version 4.2.1+debian

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Mon Oct 31 07:48:39 UTC 2016


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository ruby-gollum-lib.

commit a29cf8a8e3912eab20bce3a1717b9f0294f17e1c
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date:   Mon Oct 31 12:13:26 2016 +0530

    New upstream version 4.2.1+debian
---
 HISTORY.md                     |  5 ++++
 debian/changelog               |  2 +-
 gemspec.rb                     |  4 +--
 lib/gollum-lib.rb              |  1 +
 lib/gollum-lib/file.rb         |  1 -
 lib/gollum-lib/filter/code.rb  | 21 +++++++++-------
 lib/gollum-lib/page.rb         | 57 +++++++++++++++++++++---------------------
 lib/gollum-lib/sanitization.rb |  2 +-
 lib/gollum-lib/version.rb      |  2 +-
 9 files changed, 51 insertions(+), 44 deletions(-)

diff --git a/HISTORY.md b/HISTORY.md
index 7c8828c..96356b0 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,3 +1,8 @@
+# v4.2.1
+
+* Performances improvements
+* Dependency updates
+
 # v4.2.0
 
 * Changes since v4.1.0:
diff --git a/debian/changelog b/debian/changelog
index 67742fc..b27d3e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-ruby-gollum-lib (4.2.1+debian-2) unstable; urgency=medium
+ruby-gollum-lib (4.2.1+debian-1) unstable; urgency=medium
 
   * Remove gollum-lib_java.gemspec from orig.tar.gz (fix autopkgtest)
   * Use github-markup >= 1.5 (switch to gitlab-markup)
diff --git a/gemspec.rb b/gemspec.rb
index 02f2d70..cb342f7 100644
--- a/gemspec.rb
+++ b/gemspec.rb
@@ -8,7 +8,7 @@ def specification(version, default_adapter, platform = nil)
     s.name              = 'gollum-lib'
     s.version           = version
     s.platform          = platform if platform
-    s.date              = '2016-02-21'
+    s.date              = '2016-07-13'
     s.rubyforge_project = 'gollum-lib'
     s.license           = 'MIT'
 
@@ -25,7 +25,7 @@ def specification(version, default_adapter, platform = nil)
     s.extra_rdoc_files = %w(README.md LICENSE)
 
     s.add_dependency *default_adapter
-    s.add_dependency 'rouge', '~> 1.10'
+    s.add_dependency 'rouge', '~> 2.0'
     s.add_dependency 'nokogiri', '~> 1.6.4'
     s.add_dependency 'stringex', '~> 2.5.1'
     s.add_dependency 'sanitize', '~> 2.1.0'
diff --git a/lib/gollum-lib.rb b/lib/gollum-lib.rb
index 95e4011..0498564 100644
--- a/lib/gollum-lib.rb
+++ b/lib/gollum-lib.rb
@@ -3,6 +3,7 @@
 require 'digest/md5'
 require 'digest/sha1'
 require 'ostruct'
+require 'pathname'
 
 DEFAULT_ADAPTER = RUBY_PLATFORM == 'java' ? 'rjgit_adapter' : 'grit_adapter'
 
diff --git a/lib/gollum-lib/file.rb b/lib/gollum-lib/file.rb
index 597b22d..07a8c6c 100644
--- a/lib/gollum-lib/file.rb
+++ b/lib/gollum-lib/file.rb
@@ -1,5 +1,4 @@
 # ~*~ encoding: utf-8 ~*~
-require 'pathname'
 
 module Gollum
   class File
diff --git a/lib/gollum-lib/filter/code.rb b/lib/gollum-lib/filter/code.rb
index 9236814..f530d43 100644
--- a/lib/gollum-lib/filter/code.rb
+++ b/lib/gollum-lib/filter/code.rb
@@ -83,16 +83,19 @@ class Gollum::Filter::Code < Gollum::Filter
       else # Rouge
         begin
           # if `lang` was not defined then assume plaintext
-          # if `lang` is defined but cannot be found then wrap it and escape it
-          lang ||= 'plaintext'
-          if Rouge::Lexer.find(lang).nil?
-            lexer     = Rouge::Lexers::PlainText.new
-            formatter = Rouge::Formatters::HTML.new(:wrap => false)
-            hl_code   = formatter.format(lexer.lex(code))
-            hl_code   = "<pre class='highlight'><span class='err'>#{CGI.escapeHTML(hl_code)}</span></pre>"
-          else
-            hl_code = Rouge.highlight(code, lang, 'html')
+          lexer = Rouge::Lexer.find_fancy(lang || 'plaintext')
+          formatter = Rouge::Formatters::HTML.new
+          wrap_template = '<pre class="highlight"><code>%s</code></pre>'
+
+          # if `lang` is defined but cannot be found then wrap it with an error
+          if lexer.nil?
+            lexer = Rouge::Lexers::PlainText
+            wrap_template = '<pre class="highlight"><span class="err">%s</span></pre>'
           end
+
+          formatted = formatter.format(lexer.lex(code))
+
+          hl_code = Kernel.sprintf(wrap_template, formatted)
         rescue
           hl_code = code
         end
diff --git a/lib/gollum-lib/page.rb b/lib/gollum-lib/page.rb
index 8ffd1bd..85fde6d 100644
--- a/lib/gollum-lib/page.rb
+++ b/lib/gollum-lib/page.rb
@@ -4,7 +4,9 @@ module Gollum
     include Pagination
 
     Wiki.page_class = self
-
+    
+    SUBPAGENAMES = [:header, :footer, :sidebar]
+    
     # Sets a Boolean determing whether this page is a historical version.
     #
     # Returns nothing.
@@ -85,7 +87,7 @@ module Gollum
     # Returns a newly initialized Gollum::Page.
     def initialize(wiki)
       @wiki           = wiki
-      @blob           = @header = @footer = @sidebar = nil
+      @blob           = nil
       @formatted_data = nil
       @doc            = nil
       @parent_page    = nil
@@ -300,21 +302,24 @@ module Gollum
     #
     # Returns the header Page or nil if none exists.
     def header
-      @header ||= find_sub_page(:header)
+      find_sub_pages unless defined?(@header)
+      @header
     end
 
     # Public: The footer Page.
     #
     # Returns the footer Page or nil if none exists.
     def footer
-      @footer ||= find_sub_page(:footer)
+      find_sub_pages unless defined?(@footer)
+      @footer
     end
 
     # Public: The sidebar Page.
     #
     # Returns the sidebar Page or nil if none exists.
     def sidebar
-      @sidebar ||= find_sub_page(:sidebar)
+      find_sub_pages unless defined?(@sidebar)
+      @sidebar
     end
 
     # Gets a Boolean determining whether this page is a historical version.
@@ -461,39 +466,33 @@ module Gollum
       false
     end
 
-    # Loads a sub page.  Sub page names (footers, headers, sidebars) are prefixed with
+
+    # Loads sub pages. Sub page names (footers, headers, sidebars) are prefixed with
     # an underscore to distinguish them from other Pages. If there is not one within
     # the current directory, starts walking up the directory tree to try and find one
     # within parent directories.
-    #
-    # name - String page name.
-    #
-    # Returns the Page or nil if none exists.
-    def find_sub_page(name)
-      return nil unless self.version
-      return nil if self.filename =~ /^_/
-      name = "_#{name.to_s.capitalize}"
-      return nil if page_match(name, self.filename)
-
-      dirs = self.path.split('/')
-      dirs.pop
-      map = @wiki.tree_map_for(@wiki.ref, true)
-      while !dirs.empty?
-        if (page = find_page_in_tree(map, name, dirs.join('/')))
-          page.parent_page = self
-          return page
+    def find_sub_pages(subpagenames = SUBPAGENAMES, map = nil)
+      subpagenames.each{|subpagename| instance_variable_set("@#{subpagename}", nil)}
+      return nil if self.filename =~ /^_/ || ! self.version
+      
+      map ||= @wiki.tree_map_for(@wiki.ref, true)
+      valid_names = subpagenames.map(&:capitalize).join("|")
+      while entry = map.shift do
+        next unless entry.name =~ /^_(#{valid_names})/
+        sub_page_type = ::File.basename(entry.name.downcase.tr('_', ''), ::File.extname(entry.name))
+        next if instance_variable_get("@#{sub_page_type}")
+        ::Pathname.new(::File.join('.', ::File.dirname(self.path))).ascend do |dir|
+          if ::File.join(dir, entry.name) == ::File.join('.', ::Pathname.new(entry.path))
+            instance_variable_set("@#{sub_page_type}", entry.page(@wiki, @version) )
+            break
+          end
         end
-        dirs.pop
-      end
-
-      if (page = find_page_in_tree(map, name, ''))
-        page.parent_page = self
       end
-      page
     end
 
     def inspect
       %(#<#{self.class.name}:#{object_id} #{name} (#{format}) @wiki=#{@wiki.repo.path.inspect}>)
     end
+    
   end
 end
diff --git a/lib/gollum-lib/sanitization.rb b/lib/gollum-lib/sanitization.rb
index 351c840..e7fed2c 100644
--- a/lib/gollum-lib/sanitization.rb
+++ b/lib/gollum-lib/sanitization.rb
@@ -12,7 +12,7 @@ module Gollum
         'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'dir',
         'div', 'dl', 'dt', 'em', 'fieldset', 'font', 'form', 'h1',
         'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'input',
-        'ins', 'kbd', 'label', 'legend', 'li', 'map', 'menu',
+        'ins', 'kbd', 'label', 'legend', 'li', 'map', 'mark', 'menu',
         'ol', 'optgroup', 'option', 'p', 'pre', 'q', 's', 'samp',
         'select', 'small', 'span', 'strike', 'strong', 'sub',
         'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th',
diff --git a/lib/gollum-lib/version.rb b/lib/gollum-lib/version.rb
index 33d1e28..db8ced3 100644
--- a/lib/gollum-lib/version.rb
+++ b/lib/gollum-lib/version.rb
@@ -1,5 +1,5 @@
 module Gollum
   module Lib
-    VERSION = '4.2.0'
+    VERSION = '4.2.1'
   end
 end
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-gollum-lib.git



More information about the Pkg-ruby-extras-commits mailing list