lib/gollum-site/site.rb in gollum-site-0.1.7 vs lib/gollum-site/site.rb in gollum-site-0.1.8

- old
+ new

@@ -8,13 +8,11 @@ attr_reader :layouts attr_reader :pages def initialize(path, options = {}) @wiki = Gollum::Wiki.new(path, { - # markup_class should work after v1.1.0 of Gollum - # need to change class name in markup.rb - #:markup_class => Gollum::SiteMarkup, + :markup_class => Gollum::SiteMarkup, :page_class => Gollum::SitePage, :base_path => options[:base_path], :sanitization => false, :history_sanitization => false }) @@ -79,11 +77,11 @@ cwd = Dir.pwd # need to change directories for git ls-files -o Dir.chdir(@wiki.repo.git.work_tree) deleted = @wiki.repo.git.native(:ls_files, ls_opts_del).split("\0") working = @wiki.repo.git.native(:ls_files, ls_opts).split("\0") work_tree = (working - deleted).map do |path| - path = @wiki.decode_git_path(path) + path = decode_git_path(path) OpenStruct.new(:path => path, :data => IO.read(path)) end Dir.chdir(cwd) # change back to original directory return work_tree else @@ -141,8 +139,22 @@ end end def to_liquid { "pages" => @pages } + end + + # Decode octal sequences (\NNN) in tree path names. + # + # path - String path name. + # + # Returns a decoded String. + def decode_git_path(path) + if path[0] == ?" && path[-1] == ?" + path = path[1...-1] + path.gsub!(/\\\d{3}/) { |m| m[1..-1].to_i(8).chr } + end + path.gsub!(/\\[rn"\\]/) { |m| eval(%("#{m.to_s}")) } + path end end end