gollum-lib-v4.2.7.10.gitlab.1/000775 000000 000000 00000000000 13737324223 015562 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/.gitattributes000664 000000 000000 00000001236 13737324223 020457 0ustar00rootroot000000 000000 # https://help.github.com/articles/dealing-with-line-endings # # For Mac & Linux # git config --global core.autocrlf input # # For windows # git config --global core.autocrlf true # # Set default behaviour, in case users don't have core.autocrlf set. * text=auto # Explicitly declare text files we want to always be normalized and converted # to native line endings on checkout. *.txt text *.md text *.rb text *.js text *.html text *.yml text *.mustache text *.css text Rakefile text Gemfile text LICENSE text COPYRIGHT text gollum text .gitattributes text .gitignore text # Denote all files that are truly binary and should not be modified. *.png binary *.jpg binary gollum-lib-v4.2.7.10.gitlab.1/.gitignore000664 000000 000000 00000000121 13737324223 017544 0ustar00rootroot000000 000000 coverage pkg .DS_Store .bundle *.gem *.swp .gitattributes .gitignore .travis.yml gollum-lib-v4.2.7.10.gitlab.1/.gitlab-ci.yml000664 000000 000000 00000000773 13737324223 020225 0ustar00rootroot000000 000000 image: registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.6-golang-1.13-git-2.24 include: - template: Code-Quality.gitlab-ci.yml .test: before_script: - apt-get update -qq && apt-get install -y -qq idn libidn11 libidn11-dev - ruby -v - which ruby - gem install bundler --no-document - bundle install --jobs $(nproc) script: - bundle exec rake test test-rugged: extends: .test test-grit: extends: .test allow_failure: true variables: GOLLUM_ADAPTER: grit gollum-lib-v4.2.7.10.gitlab.1/CHANGELOG000664 000000 000000 00000000530 13737324223 016772 0ustar00rootroot000000 000000 v4.2.7.10.gitlab.1 - Drop JRuby support - Upgrade gitlab-gollum-rugged_adapter to support Rugged 1.x - Don't expand filesystem paths (backport from https://github.com/gollum/gollum-lib/pull/385) v4.2.7.9 - Add adoc file support v4.2.7.8 - Use rugged adapter - Don't sanitize page titles v1.1.0 - Removed pygments.rb dependency gollum-lib-v4.2.7.10.gitlab.1/Gemfile000664 000000 000000 00000000103 13737324223 017047 0ustar00rootroot000000 000000 source 'https://rubygems.org' gemspec :name => 'gitlab-gollum-lib' gollum-lib-v4.2.7.10.gitlab.1/Gemfile.lock000664 000000 000000 00000006721 13737324223 020012 0ustar00rootroot000000 000000 PATH remote: . specs: gitlab-gollum-lib (4.2.7.10.gitlab.1) gemojione (~> 3.2) github-markup (~> 1.6) gitlab-gollum-rugged_adapter (~> 0.4.4.3.gitlab.1) nokogiri (>= 1.6.1, < 2.0) rouge (~> 3.1) sanitize (~> 4.6.4) stringex (~> 2.6) GEM remote: https://rubygems.org/ specs: RedCloth (4.2.9) activesupport (4.0.13) i18n (~> 0.6, >= 0.6.9) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) ansi (1.5.0) builder (3.2.4) camertron-eprun (1.1.1) celluloid (0.16.0) timers (~> 4.0.0) cldr-plurals-runtime-rb (1.0.1) coderay (1.1.3) concurrent-ruby (1.1.7) crass (1.0.6) expression_parser (0.9.0) ffi (1.13.1) formatador (0.2.5) gemojione (3.3.0) json github-markup (1.7.0) gitlab-gollum-rugged_adapter (0.4.4.3.gitlab.1) mime-types (>= 1.15) rugged (~> 1.0) guard (2.8.2) formatador (>= 0.2.4) listen (~> 2.7) lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) guard-minitest (2.3.2) guard (~> 2.0) minitest (>= 3.0) hashie (4.1.0) hitimes (2.0.0) i18n (0.9.5) concurrent-ruby (~> 1.0) json (2.3.1) kramdown (1.6.0) listen (2.10.1) celluloid (~> 0.16.0) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) lumberjack (1.2.8) metaclass (0.0.4) method_source (0.8.2) mime-types (3.3.1) mime-types-data (~> 3.2015) mime-types-data (3.2020.0512) mini_portile2 (2.4.0) minitest (4.7.5) minitest-reporters (0.14.24) ansi builder minitest (>= 2.12, < 5.0) powerbar mocha (1.1.0) metaclass (~> 0.0.1) multi_json (1.15.0) nokogiri (1.10.10) mini_portile2 (~> 2.4.0) nokogiri-diff (0.2.0) nokogiri (~> 1.5) tdiff (~> 0.3, >= 0.3.2) nokogumbo (1.5.0) nokogiri org-ruby (0.9.12) rubypants (~> 0.2) power_assert (1.2.0) powerbar (2.0.1) hashie (>= 1.1.0) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) rake (10.4.2) rb-fchange (0.0.6) ffi rb-fsevent (0.9.8) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) rb-readline (0.5.5) rinku (2.0.6) rouge (3.23.0) rubypants (0.7.1) rugged (1.0.1) sanitize (4.6.6) crass (~> 1.0.2) nokogiri (>= 1.4.4) nokogumbo (~> 1.4) shoulda (3.5.0) shoulda-context (~> 1.0, >= 1.0.1) shoulda-matchers (>= 1.4.1, < 3.0) shoulda-context (1.2.2) shoulda-matchers (2.8.0) activesupport (>= 3.0.0) slop (3.6.0) stringex (2.8.5) tdiff (0.3.4) test-unit (3.1.9) power_assert thor (1.0.1) thread_safe (0.3.6) timers (4.0.4) hitimes twitter_cldr (3.1.2) camertron-eprun cldr-plurals-runtime-rb (~> 1.0.0) json tzinfo tzinfo (0.3.57) wikicloth (0.8.1) builder expression_parser rinku PLATFORMS ruby DEPENDENCIES RedCloth (~> 4.2.9) gitlab-gollum-lib! guard (~> 2.8.2) guard-minitest (~> 2.3.2) kramdown (~> 1.6.0) minitest-reporters (~> 0.14.16) mocha (~> 1.1.0) nokogiri-diff (~> 0.2.0) org-ruby (~> 0.9.9) pry (~> 0.10.1) rake (~> 10.4.0) rb-fchange (~> 0.0.6) rb-fsevent (~> 0.9.4) rb-inotify (~> 0.9.3) rb-readline (~> 0.5.1) shoulda (~> 3.5.0) test-unit (~> 3.1.5) twitter_cldr (~> 3.1.0) wikicloth (= 0.8.1) BUNDLED WITH 2.1.4 gollum-lib-v4.2.7.10.gitlab.1/Guardfile000664 000000 000000 00000000345 13737324223 017411 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ guard 'minitest' do # with Minitest::Unit watch(%r|^test/(.*)\/?test_(.*)\.rb|) watch(%r|^lib/(.*/)?([^/]+)\.rb|) { |m| "test/test_#{m[2]}.rb" } watch(%r|^test/helper\.rb|) { "test" } end gollum-lib-v4.2.7.10.gitlab.1/HISTORY.md000664 000000 000000 00000001057 13737324223 017250 0ustar00rootroot000000 000000 # v4.2.1 * Performances improvements * Dependency updates # v4.2.0 * Changes since v4.1.0: ** Various performance improvements ** Dependency updates ** Bugfixes ** New Macro for listing contents of (sub)directories: `Navigation()` ** Table of Contents now supports setting max heading level # v4.0.2 /2015-0119 * Bugfixes # v4.0.1 /2014-12-04 * Security fix for [remote code execution issue](https://github.com/gollum/gollum/issues/913). Please update! # v0.0.1 / 2013-03-19 * First release, extrated from https://github.com/gollum/gollum gollum-lib-v4.2.7.10.gitlab.1/Home.md000664 000000 000000 00000002653 13737324223 017002 0ustar00rootroot000000 000000 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vulputate tincidunt sollicitudin. Quisque sit amet leo sed nunc eleifend rhoncus in consectetur leo. Vivamus posuere semper convallis. Duis malesuada lacus sed erat lobortis tincidunt mattis ligula consectetur. Sed aliquam vulputate eros at euismod. Aenean egestas lorem ligula, quis faucibus turpis. Curabitur a eros in ipsum gravida ornare. Sed elementum enim vel mi scelerisque dapibus. Nulla id libero ligula, quis tempus sem. Morbi nec felis tortor, ac cursus risus. Mauris elementum tortor id lacus eleifend non lobortis tellus pharetra. Etiam posuere cursus vestibulum. $x \lt y$ Morbi tincidunt dolor vel massa dictum volutpat. Vestibulum quis nibh metus, id tincidunt nisl. Vivamus eget sem ac risus eleifend rhoncus at eu nisl. Nunc elit massa, vulputate ac gravida eget, condimentum quis justo. Integer scelerisque, libero vel consequat ultricies, eros libero sagittis libero, pellentesque bibendum quam massa ut orci. Maecenas sit amet urna eget quam aliquam posuere. Nulla facilisi. Duis imperdiet augue sit amet metus ornare et hendrerit dui feugiat. Aenean a lacus neque. Sed eu enim tincidunt dolor pharetra porttitor. Vestibulum ut felis dui, rutrum iaculis orci. Duis eu bibendum tortor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse mollis sagittis purus sit amet sollicitudin. Phasellus vel interdum erat. gollum-lib-v4.2.7.10.gitlab.1/LICENSE000664 000000 000000 00000002100 13737324223 016560 0ustar00rootroot000000 000000 (The MIT License) Copyright (c) Tom Preston-Werner, Rick Olson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gollum-lib-v4.2.7.10.gitlab.1/README.md000664 000000 000000 00000015603 13737324223 017046 0ustar00rootroot000000 000000 gollum lib -- A wiki built on top of Git. ======================================== [![pipeline status](https://gitlab.com/gitlab-org/gollum-lib/badges/master/pipeline.svg)](https://gitlab.com/gitlab-org/gollum-lib/-/commits/master) [![Gem Version](https://badge.fury.io/rb/gitlab-gollum-lib.svg)](http://badge.fury.io/rb/gitlab-gollum-lib) ## This is a fork It is made for the GitLab application and used in the [Gitaly](https://gitlab.com/gitlab-org/gitaly) project. For use outside of GitLab, refer to the upstream [`gollum-lib`](https://github.com/gollum/gollum-lib) gem. ## DESCRIPTION [Gollum](https://github.com/gollum/gollum) is a simple wiki system built on top of Git that powers GitHub Wikis. Gollum-lib is the Ruby API that allows you to retrieve raw or formatted wiki content from a Git repository, write new content to the repository, and collect various meta data about the wiki as a whole. Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and uses [TomDoc](http://tomdoc.org/) for inline documentation. ## SYSTEM REQUIREMENTS - Ruby 2.4+ - Unix like operating system (OS X, Ubuntu, Debian, and more) - By default the [Rugged adapter](https://gitlab.com/gitlab-org/gitlab-gollum-rugged_adapter) is used for MRI. - Will not work on Windows. ## INSTALLATION The best way to install Gollum-lib is with RubyGems: ```bash $ [sudo] gem install gitlab-gollum-lib ``` If you're installing from source, you can use [Bundler][bundler] to pick up all the gems: ```bash $ bundle install ``` In order to use the various formats that Gollum supports, you will need to separately install the necessary dependencies for each format. You only need to install the dependencies for the formats that you plan to use. * [AsciiDoc](http://www.methods.co.nz/asciidoc/) -- `gem install asciidoctor` * [Creole](http://wikicreole.org/) -- `gem install creole` * [Markdown](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet` * [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `gem install github-markdown` * [Org](http://orgmode.org/) -- `gem install org-ruby` * [Pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML` comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN. * [RDoc](http://rdoc.sourceforge.net/) * [ReStructuredText](http://docutils.sourceforge.net/rst.html) -- `easy_install docutils` * [Textile](http://www.textism.com/tools/textile/) -- `gem install RedCloth` * [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` [bundler]: http://gembundler.com/ ## SYNTAX Gollum supports a variety of formats and extensions (Markdown, MediaWiki, Textile, …). On top of these formats Gollum lets you insert headers, footers, links, image, math and more. Check out the [Gollum Wiki](https://github.com/gollum/gollum/wiki) for all of Gollum's formats and syntactic options. ## API DOCUMENTATION Initialize the `Gollum::Repo` object: ```ruby # Require rubygems if necessary require 'rubygems' # Require the Gollum library require 'gollum-lib' # Create a new Gollum::Wiki object by initializing it with the path to the # Git repository. wiki = Gollum::Wiki.new("my-gollum-repo.git") # => ``` By default, internal wiki links are all absolute from the root. To specify a different base path, you can specify the `:base_path` option: ```ruby wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki") ``` Note that `base_path` just modifies the links. Get the latest version of the given human or canonical page name: ```ruby page = wiki.page('page-name') # => page.raw_data # => "# My wiki page" page.formatted_data # => "

My wiki page

" page.format # => :markdown vsn = page.version # => vsn.id # => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5' ``` Get the footer (if any) for a given page: ```ruby page.footer # => ``` Get the header (if any) for a given page: ```ruby page.header # => ``` Get a list of versions for a given page: ```ruby vsns = wiki.page('page-name').versions # => [] vsns.first.id # => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5' vsns.first.authored_date # => Sun Mar 28 19:11:21 -0700 2010 ``` Get a specific version of a given canonical page file: ```ruby wiki.page('page-name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a') ``` Get the latest version of a given static file: ```ruby file = wiki.file('asset.js') # => file.raw_data # => "alert('hello');" file.version # => ``` Get a specific version of a given static file: ```ruby wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a') ``` Get an in-memory Page preview (useful for generating previews for web interfaces): ```ruby preview = wiki.preview_page("My Page", "# Contents", :markdown) preview.formatted_data # => "

Contents

" ``` Methods that write to the repository require a Hash of commit data that takes the following form: ```ruby commit = { :message => 'commit message', :name => 'Tom Preston-Werner', :email => 'tom@github.com' } ``` Write a new version of a page (the file will be created if it does not already exist) and commit the change. The file will be written at the repo root. ```ruby wiki.write_page('Page Name', :markdown, 'Page contents', commit) ``` Update an existing page. If the format is different than the page's current format, the file name will be changed to reflect the new format. ```ruby page = wiki.page('Page Name') wiki.update_page(page, page.name, page.format, 'Page contents', commit) ``` To delete a page and commit the change: ```ruby wiki.delete_page(page, commit) ``` Register or unregister a hook to be called after a page commit: ```ruby Gollum::Hook.register(:post_commit, :hook_id) do |committer, sha1| # Your code here end Gollum::Hook.unregister(:post_commit, :hook_id) ``` ## WINDOWS FILENAME VALIDATION Note that filenames on windows must not contain any of the following characters `\ / : * ? " < > |`. See [this support article](http://support.microsoft.com/kb/177506) for details. ## RELEASING Gollum-lib uses [Semantic Versioning](http://semver.org/). Having `x.y.z` : For z releases: ```bash $ rake bump $ rake release ``` For x.y releases: ```bash $ rake gemspec $ rake release ``` ## BUILDING THE GEM FROM MASTER ```bash $ gem uninstall -aIx gollum-lib $ git clone https://github.com/gollum/gollum-lib.git $ cd gollum-lib gollum-lib$ rake build gollum-lib$ rake install ``` ## RUN THE TESTS ```bash $ bundle install $ bundle exec rake test ``` ## WORK WITH TEST REPOS An example of how to add a test file to the bare repository `lotr.git`. ```bash $ mkdir tmp; cd tmp $ git clone ../lotr.git/ . Cloning into '.'... done. $ git log $ echo "test" > test.md $ git add . ; git commit -am "Add test" $ git push ../lotr.git/ master ``` gollum-lib-v4.2.7.10.gitlab.1/Rakefile000664 000000 000000 00000010736 13737324223 017236 0ustar00rootroot000000 000000 require 'rubygems' require 'rake' require 'date' ############################################################################# # # Helper functions # ############################################################################# def name "gollum-lib" end def version line = File.read("lib/gollum-lib/version.rb")[/^\s*VERSION\s*=\s*.*/] line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] end # assumes x.y.z all digit version def next_version # x.y.z v = version.split '.' # bump z v[-1] = v[-1].to_i + 1 v.join '.' end def bump_version old_file = File.read("lib/gollum-lib/version.rb") old_version_line = old_file[/^\s*VERSION\s*=\s*.*/] new_version = next_version # replace first match of old version with new version old_file.sub!(old_version_line, " VERSION = '#{new_version}'") File.write("lib/gollum-lib/version.rb", old_file) new_version end def date Date.today.to_s end def rubyforge_project name end def gemspec_file "gemspec.rb" end def gemspecs ["#{name}.gemspec"] end def gem_files ["#{name}-#{version}.gem"] end def replace_header(head, header_name) head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"} end ############################################################################# # # Standard tasks # ############################################################################# task :default => :test require 'rake/testtask' Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' << '.' test.pattern = 'test/**/test_*.rb' test.verbose = true end desc "Generate RCov test coverage and open in your browser" task :coverage do require 'rcov' sh "rm -fr coverage" sh "rcov test/test_*.rb" sh "open coverage/index.html" end desc "Open an irb session preloaded with this library" task :console do sh "irb -rubygems -r ./lib/#{name}.rb" end ############################################################################# # # Custom tasks (add your own tasks here) # ############################################################################# desc "Update version number and gemspec" task :bump do puts "Updated version to #{bump_version}" # Execute does not invoke dependencies. # Manually invoke gemspec then validate. Rake::Task[:gemspec].execute Rake::Task[:validate].execute end desc "Build and install" task :install => :build do sh "gem install --local --no-ri --no-rdoc pkg/#{name}-#{version}.gem" end ############################################################################# # # Packaging tasks # ############################################################################# desc 'Create a release build' task :release => :build do unless `git branch` =~ /^\* master$/ puts "You must be on the master branch to release!" exit! end sh "git commit --allow-empty -a -m 'Release #{version}'" sh "git pull --rebase origin master" sh "git tag v#{version}" sh "git push origin master" sh "git push origin v#{version}" sh "gem push pkg/#{name}-#{version}.gem" end desc 'Publish to rubygems. Same as release' task :publish => :release desc 'Build gem' task :build => :gemspec do sh "mkdir -p pkg" gemspecs.each do |gemspec| sh "gem build #{gemspec}" end gem_files.each do |gem_file| sh "mv #{gem_file} pkg" end end desc 'Update gemspec' task :gemspec => :validate do # read spec file and split out manifest section spec = File.read(gemspec_file) head, _manifest, tail = spec.split(" # = MANIFEST =\n") # replace name version and date replace_header(head, :name) replace_header(head, :date) #comment this out if your rubyforge_project has a different name replace_header(head, :rubyforge_project) # determine file list from git ls-files files = `git ls-files`. split("\n"). sort. reject { |file| file =~ /^\./ }. reject { |file| file =~ /^(rdoc|pkg|test|Home\.md|\.gitattributes|Guardfile)/ }. map { |file| " #{file}" }. join("\n") # piece file back together and write manifest = " s.files = %w(\n#{files}\n )\n" spec = [head, manifest, tail].join(" # = MANIFEST =\n") File.open(gemspec_file, 'w') { |io| io.write(spec) } puts "Updated #{gemspec_file}" end desc 'Validate lib files and version file' task :validate do libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"] unless libfiles.empty? puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir." exit! end unless Dir['VERSION*'].empty? puts "A `VERSION` file at root level violates Gem best practices." exit! end end gollum-lib-v4.2.7.10.gitlab.1/docs/000775 000000 000000 00000000000 13737324223 016512 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/docs/sanitization.md000664 000000 000000 00000002422 13737324223 021550 0ustar00rootroot000000 000000 Sanitization Rules ================== Gollum uses the [Sanitize](http://wonko.com/post/sanitize) gem for HTML sanitization. See `lib/gollum-lib/sanitization.rb` for actual settings. ## ALLOWED TAGS a, abbr, acronym, address, area, b, big, blockquote, br, button, caption, center, cite, 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, ol, optgroup, option, p, pre, q, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var ## ALLOWED ATTRIBUTES abbr, accept, accept-charset, accesskey, action, align, alt, axis, border, cellpadding, cellspacing, char, charoff, charset, checked, cite, class, clear, cols, colspan, color, compact, coords, datetime, dir, disabled, enctype, for, frame, headers, height, href, hreflang, hspace, id, ismap, label, lang, longdesc, maxlength, media, method, multiple, name, nohref, noshade, nowrap, prompt, readonly, rel, rev, rows, rowspan, rules, scope, selected, shape, size, span, src, start, summary, tabindex, target, title, type, usemap, valign, value, vspace, width ## ALLOWED PROTOCOLS a href: http, https, mailto, ftp, irc, apt img src: http, https form action: http, https gollum-lib-v4.2.7.10.gitlab.1/gemspec.rb000664 000000 000000 00000010134 13737324223 017531 0ustar00rootroot000000 000000 def specification(version, default_adapter, platform = nil) Proc.new do |s| s.specification_version = 2 if s.respond_to? :specification_version= s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version= s.rubygems_version = '0.0.1' s.required_ruby_version = '>= 1.9' s.name = 'gitlab-gollum-lib' s.version = version s.platform = platform if platform s.license = 'MIT' s.summary = 'A simple, Git-powered wiki.' s.description = 'A simple, Git-powered wiki with a sweet API and local frontend.' s.authors = ['Tom Preston-Werner', 'Rick Olson'] s.email = 'dmitriy.zaporozhets@gmail.com' s.homepage = 'https://gitlab.com/gitlab-org/gollum-lib' s.require_paths = %w(lib) s.rdoc_options = ['--charset=UTF-8'] s.extra_rdoc_files = %w(README.md LICENSE) s.add_dependency *default_adapter s.add_dependency 'rouge', '~> 3.1' if RUBY_VERSION < '2.1' s.add_dependency 'nokogiri', '~> 1.6.1' else s.add_dependency 'nokogiri', '>= 1.6.1', '< 2.0' end s.add_dependency 'stringex', '~> 2.6' s.add_dependency 'sanitize', '~> 4.6.4' s.add_dependency 'github-markup', '~> 1.6' s.add_dependency 'gemojione', '~> 3.2' s.add_development_dependency 'org-ruby', '~> 0.9.9' s.add_development_dependency 'kramdown', '~> 1.6.0' s.add_development_dependency 'RedCloth', '~> 4.2.9' s.add_development_dependency 'mocha', '~> 1.1.0' s.add_development_dependency 'shoulda', '~> 3.5.0' # 0.8.2 is incompatible with the latest twitter-text gem, this is fixed in master # https://github.com/nricciar/wikicloth/commit/60e863239452924ea60c91ba1fe07d37f1e13801 s.add_development_dependency 'wikicloth', '0.8.1' s.add_development_dependency 'rake', '~> 10.4.0' s.add_development_dependency 'pry', '~> 0.10.1' # required by pry s.add_development_dependency 'rb-readline', '~> 0.5.1' # updating minitest-reporters requires a new minitest which fails with gollum's tests. s.add_development_dependency 'test-unit', '~> 3.1.5' s.add_development_dependency 'minitest-reporters', '~> 0.14.16' s.add_development_dependency 'nokogiri-diff', '~> 0.2.0' # required by guard s.add_development_dependency 'guard', '~> 2.8.2' s.add_development_dependency 'guard-minitest', '~> 2.3.2' s.add_development_dependency 'rb-inotify', '~> 0.9.3' s.add_development_dependency 'rb-fsevent', '~> 0.9.4' s.add_development_dependency 'rb-fchange', '~> 0.0.6' s.add_development_dependency 'twitter_cldr', '~> 3.1.0' s.files = %w( Gemfile HISTORY.md CHANGELOG LICENSE README.md Rakefile docs/sanitization.md gemspec.rb gollum-lib.gemspec lib/gollum-lib.rb lib/gollum-lib/blob_entry.rb lib/gollum-lib/committer.rb lib/gollum-lib/file.rb lib/gollum-lib/file_view.rb lib/gollum-lib/filter.rb lib/gollum-lib/filter/code.rb lib/gollum-lib/filter/emoji.rb lib/gollum-lib/filter/macro.rb lib/gollum-lib/filter/metadata.rb lib/gollum-lib/filter/plain_text.rb lib/gollum-lib/filter/plantuml.rb lib/gollum-lib/filter/remote_code.rb lib/gollum-lib/filter/render.rb lib/gollum-lib/filter/sanitize.rb lib/gollum-lib/filter/tags.rb lib/gollum-lib/filter/toc.rb lib/gollum-lib/filter/wsd.rb lib/gollum-lib/sorters/wiki_sorter.rb lib/gollum-lib/git_access.rb lib/gollum-lib/gitcode.rb lib/gollum-lib/helpers.rb lib/gollum-lib/hook.rb lib/gollum-lib/macro.rb lib/gollum-lib/macro/all_pages.rb lib/gollum-lib/macro/global_toc.rb lib/gollum-lib/macro/navigation.rb lib/gollum-lib/macro/series.rb lib/gollum-lib/markup.rb lib/gollum-lib/markups.rb lib/gollum-lib/page.rb lib/gollum-lib/pagination.rb lib/gollum-lib/sanitization.rb lib/gollum-lib/version.rb lib/gollum-lib/wiki.rb licenses/licenses.txt ) s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ } end end gollum-lib-v4.2.7.10.gitlab.1/gollum-lib.gemspec000664 000000 000000 00000000602 13737324223 021170 0ustar00rootroot000000 000000 require File.join(File.dirname(__FILE__), 'gemspec.rb') require File.join(File.dirname(__FILE__), 'lib', 'gollum-lib', 'version.rb') if ENV['GOLLUM_ADAPTER'] == 'grit' default_adapter = ['gollum-grit_adapter', '~> 1.0'] else default_adapter = ['gitlab-gollum-rugged_adapter', '~> 0.4.4.3.gitlab.1'] end Gem::Specification.new &specification(Gollum::Lib::VERSION, default_adapter) gollum-lib-v4.2.7.10.gitlab.1/lib/000775 000000 000000 00000000000 13737324223 016330 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib.rb000664 000000 000000 00000004227 13737324223 020725 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ # stdlib require 'digest/md5' require 'digest/sha1' require 'ostruct' require 'pathname' DEFAULT_ADAPTER = if ENV['GOLLUM_ADAPTER'] == 'grit' 'grit_adapter' else 'rugged_adapter' end if defined?(Gollum::GIT_ADAPTER) require "#{Gollum::GIT_ADAPTER.downcase}_adapter" else require DEFAULT_ADAPTER end # external require 'github/markup' require 'sanitize' require 'gemojione' # internal require File.expand_path('../gollum-lib/git_access', __FILE__) require File.expand_path('../gollum-lib/hook', __FILE__) require File.expand_path('../gollum-lib/committer', __FILE__) require File.expand_path('../gollum-lib/pagination', __FILE__) require File.expand_path('../gollum-lib/blob_entry', __FILE__) require File.expand_path('../gollum-lib/wiki', __FILE__) require File.expand_path('../gollum-lib/page', __FILE__) require File.expand_path('../gollum-lib/macro', __FILE__) require File.expand_path('../gollum-lib/file', __FILE__) require File.expand_path('../gollum-lib/file_view', __FILE__) require File.expand_path('../gollum-lib/markup', __FILE__) require File.expand_path('../gollum-lib/markups', __FILE__) require File.expand_path('../gollum-lib/sanitization', __FILE__) require File.expand_path('../gollum-lib/filter', __FILE__) require File.expand_path('../gollum-lib/sorters/wiki_sorter', __FILE__) # Set ruby to UTF-8 mode # This is required for Ruby 1.8.7 which gollum still supports. $KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8' module Gollum def self.assets_path ::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__)) end class Error < StandardError; end class DuplicatePageError < Error attr_accessor :dir attr_accessor :existing_path attr_accessor :attempted_path def initialize(dir, existing, attempted, message = nil) @dir = dir @existing_path = existing @attempted_path = attempted super(message || "Cannot write #{@dir}/#{@attempted_path}, found #{@dir}/#{@existing_path}.") end end class InvalidGitRepositoryError < StandardError; end class NoSuchPathError < StandardError; end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/000775 000000 000000 00000000000 13737324223 020373 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/blob_entry.rb000664 000000 000000 00000005451 13737324223 023064 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum class BlobEntry # Gets the String SHA for this blob. attr_reader :sha # Gets the full path String for this blob. attr_reader :path # Gets the Fixnum size of this blob. attr_reader :size # Gets the Fixnum mode of this blob. attr_reader :mode def initialize(sha, path, size = nil, mode = nil) @sha = sha @path = path @size = size @mode = mode @dir = @name = @blob = nil end # Gets the normalized directory path String for this blob. def dir @dir ||= self.class.normalize_dir(::File.dirname(@path)) end # Gets the file base name String for this blob. def name @name ||= ::File.basename(@path) end # Gets a Gollum::Git::Blob instance for this blob. # # repo - Gollum::Git::Repo instance for the Gollum::Git::Blob. # # Returns an unbaked Gollum::Git::Blob instance. def blob(repo) @blob ||= Gollum::Git::Blob.create(repo, :id => @sha, :name => name, :size => @size, :mode => @mode) end # Gets a Page instance for this blob. # # wiki - Gollum::Wiki instance for the Gollum::Page # # Returns a Gollum::Page instance. def page(wiki, commit) blob = self.blob(wiki.repo) page = wiki.page_class.new(wiki).populate(blob, self.dir) page.version = commit page end # Gets a File instance for this blob. # # wiki - Gollum::Wiki instance for the Gollum::File # # Returns a Gollum::File instance. def file(wiki, commit) blob = self.blob(wiki.repo) file = wiki.file_class.new(wiki).populate(blob, self.dir) file.version = commit file end def inspect %(#) end # Normalizes a given directory name for searching through tree paths. # Ensures that a directory begins with a slash, or # # normalize_dir("") # => "" # normalize_dir(".") # => "" # normalize_dir("foo") # => "/foo" # normalize_dir("/foo/") # => "/foo" # normalize_dir("/") # => "" # normalize_dir("c:/") # => "" # # dir - String directory name. # # Returns a normalized String directory name, or nil if no directory # is given. def self.normalize_dir(dir) return unless dir dir = dir.dup # Remove '.' and '..' path segments dir.gsub!(%r{(\A|/)\.{1,2}(/|\z)}, '/') # Remove repeated slashes dir.gsub!(%r{//+}, '/') # Remove Windows drive letters, trailing slashes, and keep one leading slash dir.sub!(%r{\A([a-z]:)?/*(.*?)/*\z}i, '/\2') # Return empty string for paths that point to the toplevel return '' if dir == '/' dir end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/committer.rb000664 000000 000000 00000020045 13737324223 022724 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum # Responsible for handling the commit process for a Wiki. It sets up the # Git index, provides methods for modifying the tree, and stores callbacks # to be fired after the commit has been made. This is specifically # designed to handle multiple updated pages in a single commit. class Committer # Gets the instance of the Gollum::Wiki that is being updated. attr_reader :wiki # Gets a Hash of commit options. attr_reader :options # Initializes the Committer. # # wiki - The Gollum::Wiki instance that is being updated. # options - The commit Hash details: # :message - The String commit message. # :name - The String author full name. # :email - The String email address. # :parent - Optional Gollum::Git::Commit parent to this update. # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, # assume that this operation is part of batch of # updates and the commit happens later. # # Returns the Committer instance. def initialize(wiki, options = {}) @wiki = wiki @options = options @callbacks = [] after_commit { |*args| Hook.execute(:post_commit, *args) } end # Public: References the Git index for this commit. # # Returns a Gollum::Git::Index. def index @index ||= begin idx = @wiki.repo.index if (tree = options[:tree]) idx.read_tree(tree) elsif (parent = parents.first) idx.read_tree(parent.tree.id) end idx end end # Public: The committer for this commit. # # Returns a Gollum::Git::Actor. def actor @actor ||= begin @options[:name] = @wiki.default_committer_name if @options[:name].nil? @options[:email] = @wiki.default_committer_email if @options[:email].nil? Gollum::Git::Actor.new(@options[:name], @options[:email]) end end # Public: The parent commits to this pending commit. # # Returns an array of Gollum::Git::Commit instances. def parents @parents ||= begin arr = [@options[:parent] || @wiki.repo.commit(@wiki.ref)] arr.flatten! arr.compact! arr end end # Adds a page to the given Index. # # dir - The String subdirectory of the Gollum::Page without any # prefix or suffix slashes (e.g. "foo/bar"). # name - The String Gollum::Page filename_stripped. # format - The Symbol Gollum::Page format. # data - The String wiki data to store in the tree map. # allow_same_ext - A Boolean determining if the tree map allows the same # filename with the same extension. # # Raises Gollum::DuplicatePageError if a matching filename already exists. # This way, pages are not inadvertently overwritten. # # Returns nothing (modifies the Index in place). def add_to_index(dir, name, format, data, allow_same_ext = false) # spaces must be dashes dir.gsub!(' ', '-') name.gsub!(' ', '-') path = @wiki.page_file_name(name, format) dir = '/' if dir.strip.empty? fullpath = ::File.join(*[dir, path]) fullpath = fullpath[1..-1] if fullpath =~ /^\// if index.current_tree && (tree = index.current_tree / (@wiki.page_file_dir || '/')) tree = tree / dir unless tree.nil? end if tree downpath = path.downcase.sub(/\.\w+$/, '') tree.blobs.each do |blob| next if page_path_scheduled_for_deletion?(index.tree, fullpath) existing_file = blob.name.downcase.sub(/\.\w+$/, '') existing_file_ext = ::File.extname(blob.name).sub(/^\./, '') new_file_ext = ::File.extname(path).sub(/^\./, '') if downpath == existing_file && !(allow_same_ext && new_file_ext == existing_file_ext) raise DuplicatePageError.new(dir, blob.name, path) end end end fullpath = fullpath.force_encoding('ascii-8bit') if fullpath.respond_to?(:force_encoding) begin data = @wiki.normalize(data) rescue ArgumentError => err # Swallow errors that arise from data being binary raise err unless err.message.include?('invalid byte sequence') end index.add(fullpath, data) end # Update the given file in the repository's working directory if there # is a working directory present. # # dir - The String directory in which the file lives. # name - The String name of the page or the stripped filename # (should be pre-canonicalized if required). # format - The Symbol format of the page. # # Returns nothing. def update_working_dir(dir, name, format) unless @wiki.repo.bare if @wiki.page_file_dir && dir !~ /^#{@wiki.page_file_dir}/ dir = dir.size.zero? ? @wiki.page_file_dir : ::File.join(@wiki.page_file_dir, dir) end path = if dir == '' @wiki.page_file_name(name, format) else ::File.join(dir, @wiki.page_file_name(name, format)) end path = path.force_encoding('ascii-8bit') if path.respond_to?(:force_encoding) Dir.chdir(::File.join(@wiki.repo.path, '..')) do if file_path_scheduled_for_deletion?(index.tree, path) @wiki.repo.git.rm(path, :force => true) else @wiki.repo.git.checkout(path, 'HEAD') end end end end # Writes the commit to Git and runs the after_commit callbacks. # # Returns the String SHA1 of the new commit. def commit(update_ref = true) head = update_ref ? @wiki.ref : nil sha1 = index.commit(@options[:message], parents, actor, nil, head) @callbacks.each do |cb| cb.call(self, sha1) end sha1 end # Adds a callback to be fired after a commit. # # block - A block that expects this Committer instance and the created # commit's SHA1 as the arguments. # # Returns nothing. def after_commit(&block) @callbacks << block end # Determine if a given page (regardless of format) is scheduled to be # deleted in the next commit for the given Index. # # map - The Hash map: # key - The String directory or filename. # val - The Hash submap or the String contents of the file. # path - The String path of the page file. This may include the format # extension in which case it will be ignored. # # Returns the Boolean response. def page_path_scheduled_for_deletion?(map, path) parts = path.split('/') if parts.size == 1 deletions = map.keys.select { |k| !map[k] } downfile = parts.first.downcase.sub(/\.\w+$/, '') deletions.any? { |d| d.downcase.sub(/\.\w+$/, '') == downfile } else part = parts.shift if (rest = map[part]) page_path_scheduled_for_deletion?(rest, parts.join('/')) else false end end end # Determine if a given file is scheduled to be deleted in the next commit # for the given Index. # # map - The Hash map: # key - The String directory or filename. # val - The Hash submap or the String contents of the file. # path - The String path of the file including extension. # # Returns the Boolean response. def file_path_scheduled_for_deletion?(map, path) parts = path.split('/') if parts.size == 1 deletions = map.keys.select { |k| !map[k] } deletions.any? { |d| d == parts.first } else part = parts.shift if (rest = map[part]) file_path_scheduled_for_deletion?(rest, parts.join('/')) else false end end end # Proxies methods t def method_missing(name, *args) index.send(name, *args) end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/file.rb000664 000000 000000 00000010444 13737324223 021642 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum class File Wiki.file_class = self # Public: Initialize a file. # # wiki - The Gollum::Wiki in question. # # Returns a newly initialized Gollum::File. def initialize(wiki) @wiki = wiki @blob = nil @path = nil @on_disk = false @on_disk_path = nil end # Public: The url path required to reach this page within the repo. # # Returns the String url_path def url_path path = self.path path = path.sub(/\/[^\/]+$/, '/') if path.include?('/') path end # Public: The url_path, but CGI escaped. # # Returns the String url_path def escaped_url_path CGI.escape(self.url_path).gsub('%2F', '/') end # Public: The on-disk filename of the file. # # Returns the String name. def name return @path if on_disk? @blob && @blob.name end alias filename name # Public: The raw contents of the page. # # Returns the String data. def raw_data return IO.read(@on_disk_path) if on_disk? return nil unless @blob if !@wiki.repo.bare && @blob.is_symlink new_path = @blob.symlink_target(::File.join(@wiki.repo.path, '..', self.path)) return IO.read(new_path) if new_path end @blob.data end # Public: Is this an on-disk file reference? # # Returns true if this is a pointer to an on-disk file def on_disk? @on_disk end # Public: The path to this file on disk # # Returns nil if on_disk? is false. def on_disk_path @on_disk_path end # Public: The Gollum::Git::Commit version of the file. attr_accessor :version # Public: The String path of the file. attr_reader :path # Public: The String mime type of the file. def mime_type @blob && @blob.mime_type end # Populate the File with information from the Blob. # # blob - The Gollum::Git::Blob that contains the info. # path - The String directory path of the file. # # Returns the populated Gollum::File. def populate(blob, path = nil) @blob = blob @path = "#{path}/#{blob.name}"[1..-1] @on_disk = false @on_disk_path = nil self end ######################################################################### # # Internal Methods # ######################################################################### # Return the file path to this file on disk, if available. # # Returns nil if the file isn't available on disk. This can occur if the # repo is bare, if the commit isn't the HEAD, or if there are problems # resolving symbolic links. def get_disk_reference(name, commit) return false if @wiki.repo.bare return false if commit.sha != @wiki.repo.head.commit.sha # This will try to resolve symbolic links, as well pathname = Pathname.new(::File.join(@wiki.repo.path, '..', BlobEntry.normalize_dir(name))) if pathname.symlink? source = ::File.readlink(pathname.to_path) realpath = ::File.join(::File.dirname(pathname.to_path), source) return false unless realpath && ::File.exist?(realpath) @on_disk_path = realpath.to_s else @on_disk_path = pathname.to_path end true end # Find a file in the given Gollum repo. # # name - The full String path. # version - The String version ID to find. # try_on_disk - If true, try to return just a reference to a file # that exists on the disk. # # Returns a Gollum::File or nil if the file could not be found. Note # that if you specify try_on_disk=true, you may or may not get a file # for which on_disk? is actually true. def find(name, version, try_on_disk = false) checked = name.downcase map = @wiki.tree_map_for(version) commit = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version) if (result = map.detect { |entry| entry.path.downcase == checked }) @path = name @version = commit if try_on_disk && get_disk_reference(name, commit) @on_disk = true else @blob = result.blob(@wiki.repo) end self end end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/file_view.rb000664 000000 000000 00000011024 13737324223 022667 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum # FileView requires that: # - All files in root dir are processed first # - Then all the folders are sorted and processed class FileView # common use cases: # set pages to wiki.pages and show_all to false # set pages to wiki.pages + wiki.files and show_all to true def initialize(pages, options = {}) @pages = pages @show_all = options[:show_all] || false @checked = options[:collapse_tree] ? '' : "checked" end def enclose_tree(string) %Q(
    \n) + string + %Q(
) end def new_page(page) name = page.name url, valid_page = url_for_page page %Q(
  • #{name}#{valid_page ? "" : delete_file(url, valid_page)}
  • ) end def delete_file(url, valid_page) %Q(
    ) end def new_folder(folder_path) new_sub_folder folder_path end def new_sub_folder(path) <<-HTML
    1. HTML end def end_folder "
  • \n" end def url_for_page(page) url = '' valid_page_name = false if @show_all # Remove ext for valid pages. filename = page.filename valid_page_name = Page::valid_page_name?(filename) filename = valid_page_name ? filename.chomp(::File.extname(filename)) : filename url = ::File.join(::File.dirname(page.path), filename) else url = ::File.join(::File.dirname(page.path), page.filename_stripped) end url = url[2..-1] if url[0, 2] == './' return url, valid_page_name end def render_files html = '' count = @pages.size folder_start = -1 # Process all pages until folders start count.times do |index| page = @pages[index] path = page.path unless path.include? '/' # Page processed (not contained in a folder) html += new_page page else # Folders start at the next index folder_start = index break # Pages finished, move on to folders end end # If there are no folders, then we're done. return enclose_tree(html) if folder_start <= -1 # Handle special case of only one folder. if (count - folder_start == 1) page = @pages[folder_start] html += <<-HTML
    1. #{new_page page}
  • HTML return enclose_tree html end sorted_folders = [] (folder_start).upto count - 1 do |index| sorted_folders += [[@pages[index].path, index]] end # http://stackoverflow.com/questions/3482814/sorting-list-of-string-paths-in-vb-net sorted_folders.sort! do |first, second| a = first[0] b = second[0] # use :: operator because gollum defines its own conflicting File class dir_compare = ::File.dirname(a) <=> ::File.dirname(b) # Sort based on directory name unless they're equal (0) in # which case sort based on file name. if dir_compare == 0 ::File.basename(a) <=> ::File.basename(b) else dir_compare end end # keep track of folder depth, 0 = at root. cwd_array = [] changed = false # process rest of folders (0...sorted_folders.size).each do |i| page = @pages[sorted_folders[i][1]] path = page.path folder = ::File.dirname path tmp_array = folder.split '/' (0...tmp_array.size).each do |index| if cwd_array[index].nil? || changed html += new_sub_folder tmp_array[index] next end if cwd_array[index] != tmp_array[index] changed = true (cwd_array.size - index).times do html += end_folder end html += new_sub_folder tmp_array[index] end end html += new_page page cwd_array = tmp_array changed = false end # return the completed html enclose_tree html end # end render_files end # end FileView class end # end Gollum module gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter.rb000664 000000 000000 00000005531 13737324223 022211 0ustar00rootroot000000 000000 # A "filter", in Gollum-speak, is an object which extracts tokens from an # input stream of an arbitrary markup language, then replaces them with a # final form in a rendered form of the same document. Filters are composed # into a "filter chain", which forms the order in which filters are applied # in both the extraction and processing phases (processing happens in the # reverse order to extraction). A single instance of a filter class is used # for both the extraction and processing, so you can store internal state # from the extraction phase for use in the processing phase. # # Any class which is to be used as a filter must have an `initialize` method # which takes a single mandatory argument (the instance of the `Markup` # class we're being called from), and must implement two methods: `extract` # and `process`, both of which must take a string as input and return a # (possibly modified) form of that string as output. # # An example rendering session: consider a filter chain with three filters # in it, :A, :B, and :C (filter chains are specified as symbols, which are # taken to be class names within the Gollum::Filter namespace). An # equivalent of the following will take place: # # a = Gollum::Filter.const_get(:A).new # b = Gollum::Filter.const_get(:B).new # c = Gollum::Filter.const_get(:C).new # # data = "" # # data = a.extract(data) # data = b.extract(data) # data = c.extract(data) # # data = c.process(data) # data = b.process(data) # data = a.process(data) # # # `data` now contains the rendered document, ready for processing # # Note how the extraction steps go in the order of the filter chain, while # the processing steps go in the reverse order. There hasn't (yet) been a # case where that is a huge problem. # # If your particular filter doesn't need to do something with either the # original markup or rendered forms, you can simply define the relevant # method to be a pass-through (`def extract(d) d; end`), but you *must* # define both methods yourself. # module Gollum class Filter include Gollum::Helpers # Setup the object. Sets `@markup` to be the instance of Gollum::Markup that # is running this filter chain, and sets `@map` to be an empty hash (for use # in your extract/process operations). def initialize(markup) @markup = markup @map = {} end def extract(_d) raise RuntimeError, "#{self.class} has not implemented ##extract!" end def process(_d) raise RuntimeError, "#{self.class} has not implemented ##process!" end protected # Render a (presumably) non-fatal error as HTML # def html_error(message) "

    #{message}

    " end end end # Load all standard filters Dir[File.expand_path('../filter/*.rb', __FILE__)].each { |f| require f } gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/000775 000000 000000 00000000000 13737324223 021660 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/code.rb000664 000000 000000 00000011261 13737324223 023120 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ # Code # # Render a block of code using the Rouge syntax-highlighter. class Gollum::Filter::Code < Gollum::Filter def extract(data) case @markup.format when :txt return data when :asciidoc data.gsub!(/^(\[source,([^\r\n]*)\]\n)?----\n(.+?)\n----$/m) do cache_codeblock(Regexp.last_match[2], Regexp.last_match[3]) end when :org org_headers = %r{([ \t]*#\+HEADER[S]?:[^\r\n]*\n)*} org_name = %r{([ \t]*#\+NAME:[^\r\n]*\n)?} org_lang = %r{[ ]*([^\n \r]*)[ ]*[^\r\n]*} org_begin = %r{[ \t]*#\+BEGIN_SRC#{org_lang}\n} org_end = %r{\n[ \t]*#\+END_SRC[ \t]*} data.gsub!(/^#{org_headers}#{org_name}#{org_begin}(.+?)#{org_end}$/mi) do cache_codeblock(Regexp.last_match[3], Regexp.last_match[4]) end when :markdown data.gsub!(/^([ \t]*)(~~~+) ?([^\r\n]+)?\r?\n(.+?)\r?\n\1(~~~+)[ \t\r]*$/m) do m_indent = Regexp.last_match[1] m_start = Regexp.last_match[2] # ~~~ m_lang = Regexp.last_match[3] m_code = Regexp.last_match[4] m_end = Regexp.last_match[5] # ~~~ # start and finish tilde fence must be the same length next '' if m_start.length != m_end.length lang = m_lang ? m_lang.strip : nil if lang lang = lang.match(/\.([^}\s]+)/) lang = lang[1] unless lang.nil? end "#{m_indent}#{cache_codeblock(lang, m_code, m_indent)}" end end data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```[ \t]*\r?$/m) do "#{Regexp.last_match[1]}#{cache_codeblock(Regexp.last_match[2].to_s.strip, Regexp.last_match[3], Regexp.last_match[1])}" # print the SHA1 ID with the proper indentation end data end # Process all code from the codemap and replace the placeholders with the # final HTML. # # data - The String data (with placeholders). # encoding - Encoding Constant or String. # # Returns the marked up String data. def process(data) return data if data.nil? || data.size.zero? || @map.size.zero? blocks = [] @map.each do |_id, spec| next if spec[:output] # cached code = spec[:code] remove_leading_space(code, /^#{spec[:indent]}/m) remove_leading_space(code, /^( |\t)/m) blocks << [spec[:lang], code] end highlighted = [] blocks.each do |lang, code| encoding = @markup.encoding || 'utf-8' if defined? Pygments # Set the default lexer to 'text' to prevent #153 and #154 lang = lang || 'text' lexer = Pygments::Lexer[(lang)] || Pygments::Lexer['text'] # must set startinline to true for php to be highlighted without { :encoding => encoding.to_s, :startinline => true }) else # Rouge begin # if `lang` was not defined then assume plaintext lexer = Rouge::Lexer.find_fancy(lang || 'plaintext') formatter = Rouge::Formatters::HTML.new wrap_template = '
    %s
    ' # if `lang` is defined but cannot be found then wrap it with an error if lexer.nil? lexer = Rouge::Lexers::PlainText wrap_template = '
    %s
    ' end formatted = formatter.format(lexer.lex(code)) hl_code = Kernel.sprintf(wrap_template, formatted) rescue hl_code = code end end highlighted << hl_code end @map.each do |id, spec| body = spec[:output] || begin if (body = highlighted.shift.to_s).size > 0 @markup.update_cache(:code, id, body) body else "
    #{CGI.escapeHTML(spec[:code])}
    " end end # Removes paragraph tags surrounding
     blocks, see issue https://github.com/gollum/gollum-lib/issues/97
          data.gsub!(/(

    #{id}<\/p>|#{id})/) { body } end data end private # Remove the leading space from a code block. Leading space # is only removed if every single line in the block has leading # whitespace. # # code - The code block to remove spaces from # regex - A regex to match whitespace def remove_leading_space(code, regex) if code.lines.all? { |line| line =~ /\A\r?\n\Z/ || line =~ regex } code.gsub!(regex) { '' } end end def cache_codeblock(language, code, indent = "") language = language.to_s.empty? ? nil : language id = Digest::SHA1.hexdigest("#{language}.#{code}") cached = @markup.check_cache(:code, id) @map[id] = cached ? { :output => cached } : { :lang => language, :code => code, :indent => indent } id end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/emoji.rb000664 000000 000000 00000001252 13737324223 023310 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ # Emoji # # Render emoji such as :smile: class Gollum::Filter::Emoji < Gollum::Filter EXTRACT_PATTERN = %r{ (?[\w-]+): (?!\]{^2}) }ix PROCESS_PATTERN = %r{ =EEMMOOJJII= (?[\w-]+) =IIJJOOMMEE= }ix def extract(data) data.gsub! EXTRACT_PATTERN do emoji_exists?($~[:name]) ? "=EEMMOOJJII=#{$~[:name]}=IIJJOOMMEE=" : $& end data end def process(data) data.gsub! PROCESS_PATTERN, %q(\k<name>) data end private def emoji_exists?(name) @index ||= Gemojione::Index.new !!@index.find_by_name(name) end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/macro.rb000664 000000 000000 00000002773 13737324223 023317 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ # Replace specified tokens with dynamically generated content. class Gollum::Filter::Macro < Gollum::Filter def extract(data) quoted_arg = %r{".*?"} unquoted_arg = %r{[^,)]+} named_arg = %r{[a-z0-9_]+=".*?"} arg = %r{(?:#{quoted_arg}|#{unquoted_arg}|#{named_arg})} arg_list = %r{(\s*|#{arg}(?:\s*,\s*#{arg})*)} data.gsub(/('?)\<\<\s*([A-Z][A-Za-z0-9]*)\s*\(#{arg_list}\)\s*\>\>/) do next CGI.escape_html($&[1..-1]) unless Regexp.last_match[1].empty? id = Digest::SHA1.hexdigest(Regexp.last_match[2] + Regexp.last_match[3]) macro = Regexp.last_match[2] argstr = Regexp.last_match[3] args = [] opts = {} argstr.scan(/,?\s*(#{arg})\s*/) do |arguments| # Stabstabstab argument = arguments.first if argument =~ /^([a-z0-9_]+)="(.*?)"/ opts[Regexp.last_match[1]] = Regexp.last_match[2] elsif argument =~ /^"(.*)"$/ args << Regexp.last_match[1] else args << argument end end args << opts unless opts.empty? @map[id] = { :macro => macro, :args => args } id end end def process(data) @map.each do |id, spec| macro = spec[:macro] args = spec[:args] data.gsub!(id) do begin Gollum::Macro.instance(macro, @markup.wiki, @markup.page).render(*args) rescue StandardError => e "!!!Macro Error: #{e.message}!!!" end end end data end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/metadata.rb000664 000000 000000 00000002060 13737324223 023763 0ustar00rootroot000000 000000 # Extract metadata for data and build metadata table. Metadata consists of # key/value pairs in "key:value" format found between markers. Each # key/value pair must be on its own line. Internal whitespace in keys and # values is preserved, but external whitespace is ignored. # # Because ri and ruby 1.8.7 are awesome, the markers can't # be included in this documentation without triggering # `Unhandled special: Special: type=17` # Please read the source code for the exact markers class Gollum::Filter::Metadata < Gollum::Filter def extract(data) # The markers are `` data.gsub(/\<\!--+\s+---(.*?)--+\>/m) do @markup.metadata ||= {} # Split untrusted input on newlines, then remove bits that look like # HTML elements before parsing each line. Regexp.last_match[1].split("\n").each do |line| line.gsub!(/<[^>]*>/, '') k, v = line.split(':', 2) @markup.metadata[k.strip] = (v ? v.strip : '') if k end '' end end def process(data) data end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/plain_text.rb000664 000000 000000 00000000462 13737324223 024356 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ # Plain Text # # Render plain text documents in a

     block without any special markup.
    
    class Gollum::Filter::PlainText < Gollum::Filter
    
      def extract(data)
        @markup.format == :txt ? "
    #{CGI.escapeHTML(data)}
    " : data end def process(data) data end endgollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/plantuml.rb000664 000000 000000 00000010614 13737324223 024043 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require 'net/http' require 'uri' require 'open-uri' require 'zlib' # PlantUML Diagrams # # This filter replaces PlantUML blocks with HTML img tags. These img tags # point to a PlantUML web service that converts the UML text blocks into nice # diagrams. # # For this to work you must have your own PlantUML server running somewhere. # Just follow the instructions on the github page to run your own server: # # https://github.com/plantuml/plantuml-server # # Once you start you own plantuml server you need to configure this filter to # point to it: # # Gollum::Filter::PlantUML.configure do |config| # config.url = "http://localhost:8080/plantuml/png" # end # # Then in your wiki pages simply add PlantUML blocks anywhere you want a # diagram: # # @startuml # Alice -> Bob: Authentication Request # Bob --> Alice: Authentication Response # Alice -> Bob: Another authentication Request # Alice <-- Bob: another authentication Response # @enduml # # To learn more about how to create cool PlantUML diagrams check the examples # at: http://plantuml.sourceforge.net/ # class Gollum::Filter::PlantUML < Gollum::Filter DEFAULT_URL = "http://localhost:8080/plantuml/png" # Configuration class used to change the behaviour of the PlatnUML filter. # # url: PlantUML server URL (e.g. http://localhost:8080) # test: Set to true when running tests to skip the server check. # class Configuration attr_accessor :url, :test, :verify_ssl def initialize @url = DEFAULT_URL @verify_ssl = true @test = false end end class << self attr_writer :configuration end def self.configuration @configuration ||= Configuration.new end def self.configure yield(configuration) end # Extract all sequence diagram blocks into the map and replace with # placeholders. def extract(data) return data if @markup.format == :txt data.gsub(/(@startuml\r?\n.+?\r?\n@enduml\r?$)/m) do id = Digest::SHA1.hexdigest($1) @map[id] = { :code => $1 } id end end # Process all diagrams from the map and replace the placeholders with # the final HTML. def process(data) @map.each do |id, spec| data.gsub!(id) do render_plantuml(id, spec[:code]) end end data end private def server_url PlantUML::configuration.url end def test? PlantUML::configuration.test end def verify_ssl? PlantUML::configuration.verify_ssl end def render_plantuml(id, code) if check_server plantuml_url = gen_url(code) "" else html_error("Sorry, unable to render PlantUML diagram at this time") end end # Compression code used to generate PlantUML URLs. Taken directly from the # Transcoder class in the PlantUML java code. def gen_url(text) result = "" compressedData = Zlib::Deflate.deflate(text) compressedData.chars.each_slice(3) do |bytes| #print bytes[0], ' ' , bytes[1] , ' ' , bytes[2] b1 = bytes[0].nil? ? 0 : (bytes[0].ord & 0xFF) b2 = bytes[1].nil? ? 0 : (bytes[1].ord & 0xFF) b3 = bytes[2].nil? ? 0 : (bytes[2].ord & 0xFF) result += append3bytes(b1, b2, b3) end "#{server_url}/#{result}" end def encode6bit(b) if b < 10 return ('0'.ord + b).chr end b = b - 10 if b < 26 return ('A'.ord + b).chr end b = b - 26 if b < 26 return ('a'.ord + b).chr end b = b - 26 if b == 0 return '-' end if b == 1 return '_' end return '?' end def append3bytes(b1, b2, b3) c1 = b1 >> 2 c2 = ((b1 & 0x3) << 4) | (b2 >> 4) c3 = ((b2 & 0xF) << 2) | (b3 >> 6) c4 = b3 & 0x3F return encode6bit(c1 & 0x3F).chr + encode6bit(c2 & 0x3F).chr + encode6bit(c3 & 0x3F).chr + encode6bit(c4 & 0x3F).chr end # Make a call to the PlantUML server with the simplest diagram possible to # check if the server is available or not. def check_server return true if test? check_url = "#{server_url}/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000" uri = URI.parse(check_url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless verify_ssl? response = http.request_get(uri.request_uri) return response.is_a?(Net::HTTPSuccess) rescue return false end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/remote_code.rb000664 000000 000000 00000003677 13737324223 024507 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require 'net/http' require 'net/https' # ruby 1.8.7 fix, remove at upgrade require 'uri' require 'open-uri' # Remote code - fetch code from url and replace the contents to a # code-block that gets run the next parse. # Acceptable formats: # ```language:local-file.ext``` # ```language:/abs/other-file.ext``` # ```language:https://example.com/somefile.txt``` # class Gollum::Filter::RemoteCode < Gollum::Filter def extract(data) return data if @markup.format == :txt data.gsub(/^[ \t]*``` ?([^:\n\r]+):((http)?[^`\n\r]+)```/) do language = Regexp.last_match[1] uri = Regexp.last_match[2] protocol = Regexp.last_match[3] # Detect local file if protocol.nil? if (file = @markup.find_file(uri, @markup.wiki.ref)) contents = file.raw_data else # How do we communicate a render error? next html_error("File not found: #{CGI::escapeHTML(uri)}") end else contents = req(uri) end "```#{language}\n#{contents}\n```\n" end end def process(data) data end private def req(uri, cut = 1) uri = URI(uri) return "Too many redirects or retries" if cut >= 10 http = Net::HTTP.new uri.host, uri.port http.use_ssl = true resp = http.get uri.path, { 'Accept' => 'text/plain', 'Cache-Control' => 'no-cache', 'Connection' => 'keep-alive', 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0' } code = resp.code.to_i return resp.body if code == 200 return "Not Found" if code == 404 return "Unhandled Response Code #{code}" unless code == 304 or not resp.header['location'].nil? loc = URI.parse resp.header['location'] uri2 = loc.relative? ? (uri + loc) : loc # overloads (+) req uri2, (cut + 1) end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/render.rb000664 000000 000000 00000000627 13737324223 023471 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ class Gollum::Filter::Render < Gollum::Filter def extract(data) begin data = GitHub::Markup.render(@markup.name, data) if data.nil? raise "There was an error converting #{@markup.name} to HTML." end rescue Object => e data = html_error("Failed to render page: #{e.message}") end data end def process(data) data end endgollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/sanitize.rb000664 000000 000000 00000000517 13737324223 024036 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ class Gollum::Filter::Sanitize < Gollum::Filter def extract(data) data end def process(data) if @markup.sanitize doc = Nokogiri::HTML::DocumentFragment.parse(data) doc = @markup.sanitize.clean_node!(doc) doc.to_xml(@markup.to_xml_opts) else data end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/tags.rb000664 000000 000000 00000023054 13737324223 023147 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ # Render all tags (things in double-square-brackets). This one's a biggie. class Gollum::Filter::Tags < Gollum::Filter # Extract all tags into the tagmap and replace with placeholders. def extract(data) return data if @markup.format == :txt || @markup.format == :asciidoc data.gsub!(/(.?)\[\[(.+?)\]\]([^\[]?)/m) do if Regexp.last_match[1] == "'" && Regexp.last_match[3] != "'" "[[#{Regexp.last_match[2]}]]#{Regexp.last_match[3]}" elsif Regexp.last_match[2].include?('][') if Regexp.last_match[2][0..4] == 'file:' pre = Regexp.last_match[1] post = Regexp.last_match[3] parts = Regexp.last_match[2].split('][') parts[0][0..4] = "" link = "#{parts[1]}|#{parts[0].sub(/\.org/, '')}" id = register_tag(link) "#{pre}#{id}#{post}" else Regexp.last_match[0] end else id = register_tag(Regexp.last_match[2]) "#{Regexp.last_match[1]}#{id}#{Regexp.last_match[3]}" end end data end def register_tag(tag) id = "TAG#{Digest::SHA1.hexdigest(tag)}TAG" @map[id] = tag id end # Process all text nodes from the doc and replace the placeholders with the # final markup. def process(rendered_data) doc = Nokogiri::HTML::DocumentFragment.parse(rendered_data) doc.traverse do |node| if node.text? then content = node.content content.gsub!(/TAG[a-f0-9]+TAG/) do |id| if (tag = @map[id]) then if is_preformatted?(node) then "[[#{tag}]]" else process_tag(tag).gsub('%2f', '/') end end end node.replace(content) if content != node.content end end doc.to_html end private PREFORMATTED_TAGS = %w(code tt) def is_preformatted?(node) node && (PREFORMATTED_TAGS.include?(node.name) || node.ancestors.any? { |a| PREFORMATTED_TAGS.include?(a.name) }) end # Process a single tag into its final HTML form. # # tag - The String tag contents (the stuff inside the double # brackets). # # Returns the String HTML version of the tag. def process_tag(tag) if tag =~ /^_TOC_/ %{[[#{tag}]]} elsif tag =~ /^_$/ %{
    } elsif (html = process_include_tag(tag)) html elsif (html = process_image_tag(tag)) html elsif (html = process_external_link_tag(tag)) html elsif (html = process_file_link_tag(tag)) html else process_page_link_tag(tag) end end # Attempt to process the tag as an include tag # # tag - The String tag contents (the stuff inside the double brackets). # # Returns the String HTML if the tag is a valid image tag or nil # if it is not. # def process_include_tag(tag) return unless /^include:/.match(tag) page_name = tag[8..-1] resolved_page_name = ::File.expand_path(page_name, "/"+@markup.dir) if @markup.include_levels > 0 page = find_page_from_name(resolved_page_name) if page page.formatted_data(@markup.encoding, @markup.include_levels-1) else html_error("Cannot include #{process_page_link_tag(resolved_page_name)} - does not exist yet") end else html_error("Too many levels of included pages, will not include #{process_page_link_tag(resolved_page_name)}") end end # Attempt to process the tag as an image tag. # # tag - The String tag contents (the stuff inside the double brackets). # # Returns the String HTML if the tag is a valid image tag or nil # if it is not. def process_image_tag(tag) parts = tag.split('|') return if parts.size.zero? name = parts[0].strip if (file = @markup.find_file(name)) path = ::File.join @markup.wiki.base_path, file.path elsif name =~ /^https?:\/\/.+(jpg|png|gif|svg|bmp)$/i path = name elsif name =~ /.+(jpg|png|gif|svg|bmp)$/i # If is image, file not found and no link, then populate with empty String # We can than add an image not found alt attribute for this later path = "" end if path opts = parse_image_tag_options(tag) containered = false classes = [] # applied to whatever the outermost container is attrs = [] # applied to the image align = opts['align'] if opts['float'] containered = true align ||= 'left' if %w{left right}.include?(align) classes << "float-#{align}" end elsif %w{top texttop middle absmiddle bottom absbottom baseline}.include?(align) attrs << %{align="#{align}"} elsif align if %w{left center right}.include?(align) containered = true classes << "align-#{align}" end end if (width = opts['width']) if width =~ /^\d+(\.\d+)?(em|px)$/ attrs << %{width="#{width}"} end end if (height = opts['height']) if height =~ /^\d+(\.\d+)?(em|px)$/ attrs << %{height="#{height}"} end end if path != "" && (alt = opts['alt']) attrs << %{alt="#{alt}"} elsif path == "" attrs << %{alt="Image not found"} end attr_string = attrs.size > 0 ? attrs.join(' ') + ' ' : '' if opts['frame'] || containered classes << 'frame' if opts['frame'] %{} + %{} + %{} + (alt ? %{#{alt}} : '') + %{} + %{} else %{} end end end # Parse any options present on the image tag and extract them into a # Hash of option names and values. # # tag - The String tag contents (the stuff inside the double brackets). # # Returns the options Hash: # key - The String option name. # val - The String option value or true if it is a binary option. def parse_image_tag_options(tag) tag.split('|')[1..-1].inject({}) do |memo, attr| parts = attr.split('=').map { |x| x.strip } memo[parts[0]] = (parts.size == 1 ? true : parts[1]) memo end end # Return the String HTML if the tag is a valid external link tag or # nil if it is not. def process_external_link_tag(tag) parts = tag.split('|') parts.reverse! if @markup.reverse_links? return if parts.size.zero? if parts.size == 1 url = parts[0].strip else name, url = *parts.compact.map(&:strip) end accepted_protocols = @markup.wiki.sanitization.protocols['a']['href'].dup if accepted_protocols.include?(:relative) accepted_protocols.select!{|protocol| protocol != :relative} regexp = %r{^((#{accepted_protocols.join("|")}):)?(//)} else regexp = %r{^((#{accepted_protocols.join("|")}):)} end if url =~ regexp if name.nil? %{#{url}} else %{#{name}} end else nil end end # Attempt to process the tag as a file link tag. # # tag - The String tag contents (the stuff inside the double # brackets). # # Returns the String HTML if the tag is a valid file link tag or nil # if it is not. def process_file_link_tag(tag) parts = tag.split('|') return if parts.size.zero? name = parts[0].strip path = parts[1] && parts[1].strip if path && file = @markup.find_file(path) path = ::File.join @markup.wiki.base_path, file.path else path = nil end if name && path && file %{#{name}} elsif name && path %{#{name}} else nil end end # Attempt to process the tag as a page link tag. # # tag - The String tag contents (the stuff inside the double # brackets). # # Returns the String HTML if the tag is a valid page link tag or nil # if it is not. def process_page_link_tag(tag) parts = tag.split('|') parts.reverse! if @markup.reverse_links? name, page_name = *parts.compact.map(&:strip) cname = @markup.wiki.page_class.cname(page_name || name) presence = "absent" link_name = cname page, extra = find_page_from_name(cname) if page link_name = @markup.wiki.page_class.cname(page.name) presence = "present" end link = ::File.join(@markup.wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name)) # //page is invalid # strip all duplicate forward slashes using helpers.rb trim_leading_slash # //page => /page link = trim_leading_slash link %{#{name}} end # Find a page from a given cname. If the page has an anchor (#) and has # no match, strip the anchor and try again. # # cname - The String canonical page name including path. # # Returns a Gollum::Page instance if a page is found, or an Array of # [Gollum::Page, String extra] if a page without the extra anchor data # is found. def find_page_from_name(cname) slash = cname.rindex('/') unless slash.nil? name = cname[slash+1..-1] path = cname[0..slash] page = @markup.wiki.paged(name, path) else page = @markup.wiki.paged(cname, '/') || @markup.wiki.page(cname) end if page return page end if (pos = cname.index('#')) [@markup.wiki.page(cname[0...pos]), cname[pos..-1]] end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/toc.rb000664 000000 000000 00000010141 13737324223 022767 0ustar00rootroot000000 000000 # Inserts header anchors and creates TOC class Gollum::Filter::TOC < Gollum::Filter def extract(data) data end def process(data) @doc = Nokogiri::HTML::DocumentFragment.parse(data) @toc_doc = nil @anchor_names = {} @current_ancestors = [] toc_str = '' if @markup.sub_page && @markup.parent_page toc_str = @markup.parent_page.toc_data else @doc.css('h1,h2,h3,h4,h5,h6').each_with_index do |header, i| next if header.content.empty? # omit the first H1 (the page title) from the TOC if so configured next if (i == 0 && header.name =~ /[Hh]1/) && @markup.wiki && @markup.wiki.h1_title anchor_name = generate_anchor_name(header) add_anchor_to_header header, anchor_name add_entry_to_toc header, anchor_name end if not @toc_doc.nil? toc_str = @toc_doc.to_xml(@markup.to_xml_opts) end data = @doc.to_xml(@markup.to_xml_opts) end @markup.toc = toc_str data.gsub!(/\[\[_TOC_(.*?)\]\]/) do levels = nil levels_match = Regexp.last_match[1].match /\|\s*levels\s*=\s*(\d+)/ if levels_match levels = levels_match[1].to_i end if levels.nil? || toc_str.empty? toc_str else @toc_doc ||= Nokogiri::HTML::DocumentFragment.parse(toc_str) toc_clone = @toc_doc.clone toc_clone.traverse do |e| if e.name == 'ul' and e.ancestors('ul').length > levels - 1 e.remove end end toc_clone.to_xml(@markup.to_xml_opts) end end data end private # Generates the anchor name from the given header element # removing all non alphanumeric characters, replacing them # with single dashes. # # Generates heading ancestry prefixing the headings # ancestor names to the generated name. # # Prefixes duplicate anchors with an index def generate_anchor_name(header) name = header.content level = header.name.gsub(/[hH]/, '').to_i # normalize the header name name.gsub!(/[^\d\w\u00C0-\u1FFF\u2C00-\uD7FF]/, "-") name.gsub!(/-+/, "-") name.gsub!(/^-/, "") name.gsub!(/-$/, "") name.downcase! @current_ancestors[level - 1] = name @current_ancestors = @current_ancestors.take(level) anchor_name = @current_ancestors.compact.join("_") # Ensure duplicate anchors have a unique prefix or the toc will break index = increment_anchor_index(anchor_name) anchor_name = "#{index}-#{anchor_name}" unless index.zero? # if the index is zero this name is unique anchor_name end # Creates an anchor element with the given name and adds it before # the given header element. def add_anchor_to_header(header, name) anchor_element = %Q() header.children.before anchor_element # Add anchor element before the header end # Adds an entry to the TOC for the given header. The generated entry # is a link to the given anchor name def add_entry_to_toc(header, name) @toc_doc ||= Nokogiri::XML::DocumentFragment.parse('
    Table of Contents
    ') @tail ||= @toc_doc.child @tail_level ||= 0 level = header.name.gsub(/[hH]/, '').to_i if @tail_level < level while @tail_level < level list = Nokogiri::XML::Node.new('ul', @doc) @tail.add_child(list) @tail = list.add_child(Nokogiri::XML::Node.new('li', @doc)) @tail_level += 1 end else while @tail_level > level @tail = @tail.parent.parent @tail_level -= 1 end @tail = @tail.parent.add_child(Nokogiri::XML::Node.new('li', @doc)) end # % -> %25 so anchors work on Firefox. See issue #475 @tail.add_child(%Q{#{header.content}}) end # Increments the number of anchors with the given name # and returns the current index def increment_anchor_index(name) @anchor_names = {} if @anchor_names.nil? @anchor_names[name].nil? ? @anchor_names[name] = 0 : @anchor_names[name] += 1 end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/filter/wsd.rb000664 000000 000000 00000003077 13737324223 023011 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require 'net/http' require 'uri' require 'open-uri' # Web Sequence Diagrams # # Render an inline web sequence diagram by sending the WSD code through the # online renderer available from www.websequencediagrams.com. # class Gollum::Filter::WSD < Gollum::Filter WSD_URL = "http://www.websequencediagrams.com/index.php" # Extract all sequence diagram blocks into the map and replace with # placeholders. def extract(data) return data if @markup.format == :txt data.gsub(/^\{\{\{\{\{\{ ?(.+?)\r?\n(.+?)\r?\n\}\}\}\}\}\}\r?$/m) do id = Digest::SHA1.hexdigest(Regexp.last_match[2]) @map[id] = { :style => Regexp.last_match[1], :code => Regexp.last_match[2] } id end end # Process all diagrams from the map and replace the placeholders with # the final HTML. # # data - The String data (with placeholders). # # Returns the marked up String data. def process(data) @map.each do |id, spec| data.gsub!(id) do render_wsd(spec[:code], spec[:style]) end end data end private # Render the sequence diagram on the remote server. # # Returns an tag to the rendered image, or an HTML error. def render_wsd(code, style) response = Net::HTTP.post_form(URI.parse(WSD_URL), 'style' => style, 'message' => code) if response.body =~ /img: "(.+)"/ url = "//www.websequencediagrams.com/#{Regexp.last_match[1]}" "" else puts response.body html_error("Sorry, unable to render sequence diagram at this time.") end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/git_access.rb000664 000000 000000 00000015220 13737324223 023024 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum # Controls all access to the Git objects from Gollum. Extend this class to # add custom caching for special cases. class GitAccess # Initializes the GitAccess instance. # # path - The String path to the Git repository that holds the # Gollum site. # page_file_dir - String the directory in which all page files reside # # Returns this instance. def initialize(path, page_file_dir = nil, bare = nil) @page_file_dir = page_file_dir @path = path @repo = Gollum::Git::Repo.new(path, { :is_bare => bare }) clear end # Public: Determines whether the Git repository exists on disk. # # Returns true if it exists, or false. def exist? @repo.git.exist? end # Public: Converts a given Git reference to a SHA, using the cache if # available. # # ref - a String Git reference (ex: "master") # # Returns a String, or nil if the ref isn't found. def ref_to_sha(ref) ref = ref.to_s return if ref.empty? sha = if sha?(ref) ref else get_cache(:ref, ref) { ref_to_sha!(ref) } end.to_s sha.empty? ? nil : sha end # Public: Gets a recursive list of Git blobs for the whole tree at the # given commit. # # ref - A String Git reference or Git SHA to a commit. # # Returns an Array of BlobEntry instances. def tree(ref) if (sha = ref_to_sha(ref)) get_cache(:tree, sha) { tree!(sha) } else [] end end # Public: Fetches the contents of the Git blob at the given SHA. # # sha - A String Git SHA. # # Returns the String content of the blob. def blob(sha) cat_file!(sha) end # Public: Looks up the Git commit using the given Git SHA or ref. # # ref - A String Git SHA or ref. # # Returns a Gollum::Git::Commit. def commit(ref) if sha?(ref) get_cache(:commit, ref) { commit!(ref) } else if (sha = get_cache(:ref, ref)) commit(sha) else if (cm = commit!(ref)) set_cache(:ref, ref, cm.id) set_cache(:commit, cm.id, cm) end end end end # Public: Clears all of the cached data that this GitAccess is tracking. # # Returns nothing. def clear @ref_map = {} @tree_map = {} @commit_map = {} end # Public: Refreshes just the cached Git reference data. This should # be called after every Gollum update. # # Returns nothing. def refresh @ref_map.clear end ######################################################################### # # Internal Methods # ######################################################################### # Gets the String path to the Git repository. attr_reader :path # Gets the Gollum::Git::Repo instance for the Git repository. attr_reader :repo # Gets a Hash cache of refs to commit SHAs. # # {"master" => "abc123", ...} # attr_reader :ref_map # Gets a Hash cache of commit SHAs to a recursive tree of blobs. # # {"abc123" => [, ]} # attr_reader :tree_map # Gets a Hash cache of commit SHAs to the Gollum::Git::Commit instance. # # {"abcd123" => } # attr_reader :commit_map # Checks to see if the given String is a 40 character hex SHA. # # str - Possible String SHA. # # Returns true if the String is a SHA, or false. def sha?(str) !!(str =~ /^[0-9a-f]{40}$/) end # Looks up the Git SHA for the given Git ref. # # ref - String Git ref. # # Returns a String SHA. def ref_to_sha!(ref) commit = @repo.commit(ref) commit ? commit.id : nil end # Looks up the Git blobs for a given commit. # # sha - String commit SHA. # # Returns an Array of BlobEntry instances. def tree!(sha) tree = @repo.lstree(sha, { :recursive => true }) items = [] tree.each do |entry| if entry[:type] == 'blob' items << BlobEntry.new(entry[:sha], entry[:path], entry[:size], entry[:mode].to_i(8)) end end if (dir = @page_file_dir) regex = /^#{dir}\// items.select { |i| i.path =~ regex } else items end end def files_sorted_by_created_at(ref) @repo.files_sorted_by_created_at(ref) end # Reads the content from the Git db at the given SHA. # # sha - The String SHA. # # Returns the String content of the Git object. def cat_file!(sha) @repo.git.cat_file({ :p => true }, sha) end # Reads a Git commit. # # sha - The string SHA of the Git commit. # # Returns a Gollum::Git::Commit. def commit!(sha) @repo.commit(sha) end # Attempts to get the given data from a cache. If it doesn't exist, it'll # pass the results of the yielded block to the cache for future accesses. # # name - The cache prefix used in building the full cache key. # key - The unique cache key suffix, usually a String Git SHA. # # Yields a block to pass to the cache. # Returns the cached result. def get_cache(name, key) cache = instance_variable_get("@#{name}_map") value = cache[key] if value.nil? && block_given? set_cache(name, key, value = yield) end value == :_nil ? nil : value end # Writes some data to the internal cache. # # name - The cache prefix used in building the full cache key. # key - The unique cache key suffix, usually a String Git SHA. # value - The value to write to the cache. # # Returns nothing. def set_cache(name, key, value) cache = instance_variable_get("@#{name}_map") cache[key] = value || :_nil end # Parses a line of output from the `ls-tree` command. # # line - A String line of output: # "100644 blob 839c2291b30495b9a882c17d08254d3c90d8fb53 Home.md" # # Returns an Array of BlobEntry instances. def parse_tree_line(line) mode, _type, sha, size, *name = line.split(/\s+/) BlobEntry.new(sha, name.join(' '), size.to_i, mode.to_i(8)) 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}")) } path end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/gitcode.rb000664 000000 000000 00000003022 13737324223 022333 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require 'net/http' require 'net/https' # ruby 1.8.7 fix, remove at upgrade require 'uri' require 'open-uri' module Gollum class Gitcode def initialize(path) raise(ArgumentError, 'path is nil or empty') if path.nil? or path.empty? @uri = URI::HTTP.build({ :path => self.unchomp(path), :host => 'raw.github.com', :scheme => 'https', :port => 443 }) end def contents @contents ||= self.req @uri end def unchomp(p) return p if p.nil? p[0] == '/' ? p : ('/' + p) end def req(uri, cut = 1) return "Too many redirects or retries" if cut >= 10 http = Net::HTTP.new uri.host, uri.port http.use_ssl = true resp = http.get uri.path, { 'Accept' => 'text/plain', 'Cache-Control' => 'no-cache', 'Connection' => 'keep-alive', 'Host' => uri.host, 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0' } code = resp.code.to_i return resp.body if code == 200 return "Not Found" if code == 404 return "Unhandled Response Code #{code}" unless code == 304 or not resp.header['location'].nil? loc = URI.parse resp.header['location'] uri2 = loc.relative?() ? (uri + loc) : loc # overloads (+) return req uri2, (cut + 1) end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/helpers.rb000664 000000 000000 00000000354 13737324223 022364 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum module Helpers def trim_leading_slash(url) return url if url.nil? url.gsub!('%2F', '/') return '/' + url.gsub(/^\/+/, '') if url[0, 1] == '/' url end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/hook.rb000664 000000 000000 00000001262 13737324223 021661 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum class Hook @hooks = {} class << self def register(type, id, &block) type_hooks = @hooks[type] ||= {} type_hooks[id] = block end def unregister(type, id) type_hooks = @hooks[type] if type_hooks type_hooks.delete(id) @hooks.delete(type) if type_hooks.empty? end end def get(type, id) @hooks.fetch(type, {})[id] end def execute(type, *args) type_hooks = @hooks[type] if type_hooks type_hooks.each_value do |block| block.call(*args) end end end end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/macro.rb000664 000000 000000 00000002126 13737324223 022022 0ustar00rootroot000000 000000 module Gollum class Macro # Find the macro named, create an instance of that, and return it def self.instance(macro_name, wiki, page) begin self.const_get(macro_name).new(wiki, page) rescue NameError Unknown_Macro.new(macro_name) end end def initialize(wiki, page) @wiki = wiki @page = page end def render(*_args) raise ArgumentError, "#{self.class} does not implement #render. "+ "This is a bug in #{self.class}." end protected def html_error(s) "

    #{s}

    " end # The special class we reserve for only the finest of screwups. The # underscore is to make sure nobody can define a real, callable macro # with the same name, because that would be... exciting. class Unknown_Macro < Macro def initialize(macro_name) @macro_name = macro_name end def render(*_args) "!!!Unknown macro: #{@macro_name}!!!" end end end end Dir[File.expand_path('../macro/*.rb', __FILE__)].each { |f| require f } gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/macro/000775 000000 000000 00000000000 13737324223 021474 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/macro/all_pages.rb000664 000000 000000 00000000362 13737324223 023751 0ustar00rootroot000000 000000 module Gollum class Macro class AllPages < Gollum::Macro def render if @wiki.pages.size > 0 '
      ' + @wiki.pages.map { |p| "
    • #{p.name}
    • " }.join + '
    ' end end end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/macro/global_toc.rb000664 000000 000000 00000000624 13737324223 024130 0ustar00rootroot000000 000000 module Gollum class Macro class GlobalTOC < Gollum::Macro def render(title = "Global Table of Contents") if @wiki.pages.size > 0 result = '' end "
    #{title}
    #{result}
    " end end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/macro/navigation.rb000664 000000 000000 00000001335 13737324223 024162 0ustar00rootroot000000 000000 module Gollum class Macro class Navigation < Gollum::Macro def render(title = "Navigate in the TOC", toc_root_path = ::File.dirname(@page.path), full_path = false) if @wiki.pages.size > 0 list_items = @wiki.pages.map do |page| if page.url_path.start_with?(toc_root_path) path_display = full_path ? page.url_path_display : page.url_path_display.sub(toc_root_path.gsub("-", " "), "").sub(/^\//,'') "
  • #{path_display}
  • " end end result = "
      #{list_items.join}
    " end "
    #{title}
    #{result}
    " end end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/macro/series.rb000664 000000 000000 00000003465 13737324223 023323 0ustar00rootroot000000 000000 module Gollum class Macro class Series < Gollum::Macro def render(series_prefix = "") raise "This page's name does not match the prefix '#{series_prefix}'" unless @page.name =~ /^#{series_prefix}/ render_links(*find_series(series_prefix)) end def render_links(previous_page, next_page) result = "Previous: #{previous_page.name}" if previous_page result = "#{result}#{result ? ' | ' : ''}Next: #{next_page.name}" if next_page wrap_result(result) end def wrap_result(result) result.nil? ? "" : "
    #{result}
    " end def find_series(series_prefix = "") dir = @wiki.pages.select {|page| ::File.dirname(page.path) == ::File.dirname(@page.path)} dir.select! {|page| page.name =~ /\A#{series_prefix}/ } unless series_prefix.empty? dir.sort_by! {|page| page.name} self_index = dir.find_index {|page| page.name == @page.name} if self_index > 0 return dir[self_index-1], dir[self_index+1] else return nil, dir[self_index+1] end end end class SeriesStart < Gollum::Macro::Series def render_links(previous_page, next_page) result = "Next: #{next_page.name}" if next_page wrap_result(result) end end class SeriesEnd < Gollum::Macro::Series def render_links(previous_page, next_page) result = "Previous: #{previous_page.name}" if previous_page wrap_result(result) end end end endgollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/markup.rb000664 000000 000000 00000013231 13737324223 022217 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require 'digest/sha1' require 'cgi' require 'rouge' require 'base64' require File.expand_path '../helpers', __FILE__ # Use pygments if it's installed begin require 'pygments' Pygments.start rescue Exception end module Gollum class Markup include Helpers @formats = {} class << self # Only use the formats that are specified in config.rb def formats if defined? Gollum::Page::FORMAT_NAMES @formats.select { |_, value| Gollum::Page::FORMAT_NAMES.values.include? value[:name] } else @formats end end # Register a file extension and associated markup type # # ext - The file extension # name - The name of the markup type # options - Hash of options: # regexp - Regexp to match against. # Defaults to exact match of ext. # # If given a block, that block will be registered with GitHub::Markup to # render any matching pages def register(ext, name, options = {}, &block) @formats[ext] = { :name => name, :regexp => options.fetch(:regexp, Regexp.new(ext.to_s)), :reverse_links => options.fetch(:reverse_links, false) } end end attr_accessor :toc attr_accessor :metadata attr_reader :encoding attr_reader :sanitize attr_reader :format attr_reader :wiki attr_reader :page attr_reader :parent_page attr_reader :sub_page attr_reader :name attr_reader :include_levels attr_reader :to_xml_opts attr_reader :dir # Initialize a new Markup object. # # page - The Gollum::Page. # # Returns a new Gollum::Markup object, ready for rendering. def initialize(page) if page @wiki = page.wiki @name = page.filename @data = page.text_data @version = page.version.id if page.version @format = page.format @sub_page = page.sub_page @parent_page = page.parent_page @page = page @dir = ::File.dirname(page.path) end @metadata = nil @to_xml_opts = { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML ^ 1, :indent => 0, :encoding => 'UTF-8' } end def reverse_links? self.class.formats[@format][:reverse_links] end # Render data using default chain in the target format. # # data - the data to render # format - format to use as a symbol # name - name using the extension of the format # # Returns the processed data def render_default(data, format=:markdown, name='render_default.md') # set instance vars so we're able to render data without a wiki or page. @format = format @name = name chain = [:Metadata, :PlainText, :Emoji, :TOC, :RemoteCode, :Code, :Sanitize, :WSD, :Tags, :Render] filter_chain = chain.map do |r| Gollum::Filter.const_get(r).new(self) end process_chain data, filter_chain end # Process the filter chain # # data - the data to send through the chain # filter_chain - the chain to process # # Returns the formatted data def process_chain(data, filter_chain) # First we extract the data through the chain... filter_chain.each do |filter| data = filter.extract(data) end # Then we process the data through the chain *backwards* filter_chain.reverse.each do |filter| data = filter.process(data) end # Finally, a little bit of cleanup, just because data.gsub!(/

    <\/p>/) do '' end data end # Render the content with Gollum wiki syntax on top of the file's own # markup language. # # no_follow - Boolean that determines if rel="nofollow" is added to all # tags. # encoding - Encoding Constant or String. # # Returns the formatted String content. def render(no_follow = false, encoding = nil, include_levels = 10) @sanitize = no_follow ? @wiki.history_sanitizer : @wiki.sanitizer @encoding = encoding @include_levels = include_levels data = @data.dup filter_chain = @wiki.filter_chain.map do |r| Gollum::Filter.const_get(r).new(self) end # Since the last 'extract' action in our chain *should* be the markup # to HTML converter, we now have HTML which we can parse and yield, for # anyone who wants it if block_given? yield Nokogiri::HTML::DocumentFragment.parse(data) end process_chain data, filter_chain end # Find the given file in the repo. # # name - The String absolute or relative path of the file. # # Returns the Gollum::File or nil if none was found. def find_file(name, version=@version) if name =~ /^\// @wiki.file(name[1..-1], version) else path = @dir == '.' ? name : ::File.join(@dir, name) @wiki.file(path, version) end end # Hook for getting the formatted value of extracted tag data. # # type - Symbol value identifying what type of data is being extracted. # id - String SHA1 hash of original extracted tag data. # # Returns the String cached formatted data, or nil. def check_cache(type, id) end # Hook for caching the formatted value of extracted tag data. # # type - Symbol value identifying what type of data is being extracted. # id - String SHA1 hash of original extracted tag data. # data - The String formatted value to be cached. # # Returns nothing. def update_cache(type, id, data) end end MarkupGFM = Markup end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/markups.rb000664 000000 000000 00000001413 13737324223 022401 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum class Markup GitHub::Markup::Markdown::MARKDOWN_GEMS['kramdown'] = proc { |content| Kramdown::Document.new(content, :auto_ids => false, :input => "markdown").to_html } register(:markdown, "Markdown", :regexp => /md|mkdn?|mdown|markdown/) register(:textile, "Textile") register(:rdoc, "RDoc") register(:org, "Org-mode") register(:creole, "Creole", :reverse_links => true) register(:rest, "reStructuredText", :regexp => /re?st(\.txt)?/) register(:asciidoc, "AsciiDoc", :regexp => /adoc|asciidoc/) register(:mediawiki, "MediaWiki", :regexp => /(media)?wiki/, :reverse_links => true) register(:pod, "Pod") register(:txt, "Plain Text") end endgollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/page.rb000664 000000 000000 00000034701 13737324223 021641 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum class Page include Pagination Wiki.page_class = self SUBPAGENAMES = [:header, :footer, :sidebar] # Sets a Boolean determing whether this page is a historical version. # # Returns nothing. attr_writer :historical # Parent page if this is a sub page # # Returns a Page attr_accessor :parent_page # Checks a filename against the registered markup extensions # # filename - String filename, like "Home.md" # # Returns e.g. ["Home", :markdown], or [] if the extension is unregistered def self.parse_filename(filename) return [] unless filename =~ /^(.+)\.([a-zA-Z]\w*)$/i pref, ext = Regexp.last_match[1], Regexp.last_match[2] Gollum::Markup.formats.each_pair do |name, format| return [pref, name] if ext =~ format[:regexp] end [] end # Checks if a filename has a valid, registered extension # # filename - String filename, like "Home.md". # # Returns the matching String basename of the file without the extension. def self.valid_filename?(filename) self.parse_filename(filename).first end # Checks if a filename has a valid extension understood by GitHub::Markup. # Also, checks if the filename has no "_" in the front (such as # _Footer.md). # # filename - String filename, like "Home.md". # # Returns the matching String basename of the file without the extension. def self.valid_page_name?(filename) match = valid_filename?(filename) filename =~ /^_/ ? false : match end # Public: The format of a given filename. # # filename - The String filename. # # Returns the Symbol format of the page; one of the registered format types def self.format_for(filename) self.parse_filename(filename).last end # Reusable filter to turn a filename (without path) into a canonical name. # Strips extension, converts dashes to spaces. # # Returns the filtered String. def self.canonicalize_filename(filename) strip_filename(filename).gsub('-', ' ') end # Reusable filter to strip extension and path from filename # # filename - The string path or filename to strip # # Returns the stripped String. def self.strip_filename(filename) ::File.basename(filename, ::File.extname(filename)) end # Public: Initialize a page. # # wiki - The Gollum::Wiki in question. # # Returns a newly initialized Gollum::Page. def initialize(wiki) @wiki = wiki @blob = nil @formatted_data = nil @doc = nil @parent_page = nil end # Public: The on-disk filename of the page including extension. # # Returns the String name. def filename @blob && @blob.name end # Public: The on-disk filename of the page with extension stripped. # # Returns the String name. def filename_stripped self.class.strip_filename(filename) end # Public: The canonical page name without extension, and dashes converted # to spaces. # # Returns the String name. def name self.class.canonicalize_filename(filename) end alias_method :title, :name # Public: Determines if this is a sub-page # Sub-pages have filenames beginning with an underscore # # Returns true or false. def sub_page filename =~ /^_/ end # Public: The path of the page within the repo. # # Returns the String path. attr_reader :path # Public: The url path required to reach this page within the repo. # # Returns the String url_path def url_path path = if self.path.include?('/') self.path.sub(/\/[^\/]+$/, '/') else '' end path << Page.cname(self.name, '-', '-') path end # Public: The display form of the url path required to reach this page within the repo. # # Returns the String url_path def url_path_display url_path.gsub("-", " ") end # Public: Defines title for page.rb # # Returns the String title def url_path_title metadata_title || url_path_display end # Public: Metadata title # # Set with in page content # # Returns the String title or nil if not defined def metadata_title if metadata title = metadata['title'] return title unless title.nil? end nil end # Public: The url_path, but CGI escaped. # # Returns the String url_path def escaped_url_path CGI.escape(self.url_path).gsub('%2F', '/') end # Public: The raw contents of the page. # # Returns the String data. def raw_data return nil unless @blob if !@wiki.repo.bare && @blob.is_symlink new_path = @blob.symlink_target(::File.join(@wiki.repo.path, '..', self.path)) return IO.read(new_path) if new_path end @blob.data end # Public: A text data encoded in specified encoding. # # encoding - An Encoding or nil # # Returns a character encoding aware String. def text_data(encoding=nil) if raw_data.respond_to?(:encoding) raw_data.force_encoding(encoding || Encoding::UTF_8) else raw_data end end # Public: The formatted contents of the page. # # encoding - Encoding Constant or String. # # Returns the String data. def formatted_data(encoding = nil, include_levels = 10, &block) return nil unless @blob if @formatted_data && @doc then yield @doc if block_given? else @formatted_data = markup_class.render(historical?, encoding, include_levels) do |doc| @doc = doc yield doc if block_given? end end @formatted_data end # Public: The table of contents of the page. # # formatted_data - page already marked up in html. # # Returns the String data. def toc_data return @parent_page.toc_data if @parent_page and @sub_page formatted_data if markup_class.toc == nil markup_class.toc end # Public: Embedded metadata. # # Returns Hash of metadata. def metadata formatted_data if markup_class.metadata == nil markup_class.metadata end # Public: The format of the page. # # Returns the Symbol format of the page; one of the registered format types def format self.class.format_for(@blob.name) end # Gets the Gollum::Markup instance that will render this page's content. # # Returns a Gollum::Markup instance. def markup_class @markup_class ||= @wiki.markup_classes[format].new(self) end # Public: The current version of the page. # # Returns the Gollum::Git::Commit. attr_reader :version # Public: All of the versions that have touched the Page. # # options - The options Hash: # :page - The Integer page number (default: 1). # :per_page - The Integer max count of items to return. # :follow - Follow's a file across renames, slower. (default: false) # # Returns an Array of Gollum::Git::Commit. def versions(options = {}) @wiki.repo.git.versions_for_path(@path, @wiki.ref, log_pagination_options(options)) end # Public: The last version that has touched the Page. Can be nil. # # Returns Gollum::Git::Commit, or nil. def last_version return @last_version if defined? @last_version @last_version = @wiki.repo.git.versions_for_path(@path, @wiki.ref, {:max_count => 1}).first end # Public: The first 7 characters of the current version. # # Returns the first 7 characters of the current version. def version_short version.to_s[0, 7] end # Public: The header Page. # # Returns the header Page or nil if none exists. def header find_sub_pages unless defined?(@header) @header end # Public: The footer Page. # # Returns the footer Page or nil if none exists. def footer find_sub_pages unless defined?(@footer) @footer end # Public: The sidebar Page. # # Returns the sidebar Page or nil if none exists. def sidebar find_sub_pages unless defined?(@sidebar) @sidebar end # Gets a Boolean determining whether this page is a historical version. # Historical pages are pulled using exact SHA hashes and format all links # with rel="nofollow" # # Returns true if the page is pulled from a named branch or tag, or false. def historical? !!@historical end ######################################################################### # # Class Methods # ######################################################################### # Convert a human page name into a canonical page name. # # name - The String human page name. # char_white_sub - Substitution for whitespace # char_other_sub - Substitution for other special chars # # Examples # # Page.cname("Bilbo Baggins") # # => 'Bilbo-Baggins' # # Page.cname("Bilbo Baggins",'_') # # => 'Bilbo_Baggins' # # Returns the String canonical name. def self.cname(name, char_white_sub = '-', char_other_sub = '-') name.respond_to?(:gsub) ? name.gsub(%r(\s), char_white_sub).gsub(%r([<>+]), char_other_sub) : '' end # Convert a format Symbol into an extension String. # # format - The format Symbol. # # Returns the String extension (no leading period). def self.format_to_ext(format) format == :markdown ? "md" : format.to_s end ######################################################################### # # Internal Methods # ######################################################################### # The underlying wiki repo. # # Returns the Gollum::Wiki containing the page. attr_reader :wiki # Set the Gollum::Git::Commit version of the page. # # Returns nothing. attr_writer :version # Find a page in the given Gollum repo. # # name - The human or canonical String page name to find. # version - The String version ID to find. # # Returns a Gollum::Page or nil if the page could not be found. def find(name, version, dir = nil, exact = false) map = @wiki.tree_map_for(version.to_s) if (page = find_page_in_tree(map, name, dir, exact)) page.version = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version) page.historical = page.version.to_s == version.to_s page end rescue Gollum::Git::NoSuchShaFound end # Find a page in a given tree. # # map - The Array tree map from Wiki#tree_map. # name - The canonical String page name. # checked_dir - Optional String of the directory a matching page needs # to be in. The string should # # Returns a Gollum::Page or nil if the page could not be found. def find_page_in_tree(map, name, checked_dir = nil, exact = false) return nil if !map || name.to_s.empty? checked_dir = BlobEntry.normalize_dir(checked_dir) checked_dir = '' if exact && checked_dir.nil? name = ::File.join(checked_dir, name) if checked_dir map.each do |entry| next if entry.name.to_s.empty? path = checked_dir ? ::File.join(entry.dir, entry.name) : entry.name next unless page_match(name, path) return entry.page(@wiki, @version) end return nil # nothing was found end # Populate the Page with information from the Blob. # # blob - The Gollum::Git::Blob that contains the info. # path - The String directory path of the page file. # # Returns the populated Gollum::Page. def populate(blob, path=nil) @blob = blob @path = "#{path}/#{blob.name}"[1..-1] self end # The full directory path for the given tree. # # treemap - The Hash treemap containing parentage information. # tree - The Gollum::Git::Tree for which to compute the path. # # Returns the String path. def tree_path(treemap, tree) if (ptree = treemap[tree]) tree_path(treemap, ptree) + '/' + tree.name else '' end end # Compare the canonicalized versions of the two names. # # name - The human or canonical String page name. # path - the String path on disk (including file extension). # # Returns a Boolean. def page_match(name, path) if (match = self.class.valid_filename?(path)) @wiki.ws_subs.each do |sub| return true if Page.cname(name).downcase == Page.cname(match, sub).downcase end end false end # 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. 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("|") # From Ruby 2.2 onwards map.select! could be used map = map.select{|entry| entry.name =~ /^_(#{valid_names})/ } return if map.empty? subpagenames.each do |subpagename| dir = ::Pathname.new(self.path) while dir = dir.parent do subpageblob = map.find do |blob_entry| filename = "_#{subpagename.to_s.capitalize}" searchpath = dir == Pathname.new('.') ? Pathname.new(filename) : dir + filename entrypath = ::Pathname.new(blob_entry.path) # Ignore extentions entrypath = entrypath.dirname + entrypath.basename(entrypath.extname) entrypath == searchpath end if subpageblob subpage = subpageblob.page(@wiki, @version) subpage.parent_page = self instance_variable_set("@#{subpagename}", subpage) break end break if dir == Pathname.new('.') end end end def inspect %(#<#{self.class.name}:#{object_id} #{name} (#{format}) @wiki=#{@wiki.repo.path.inspect}>) end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/pagination.rb000664 000000 000000 00000003651 13737324223 023056 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum module Pagination def self.included(klass) klass.extend ClassMethods class << klass # Default Integer max count of items to return in git commands. attr_accessor :per_page end klass.per_page = 30 end module ClassMethods # Turns a page number into an offset number for the git skip option. # # page - Integer page number. # # Returns an Integer. def page_to_skip(page) ([1, page.to_i].max - 1) * per_page end # Fills in git-specific options for the log command using simple # pagination options. # # options - Hash of options: # page - Optional Integer page number (default: 1) # per_page - Optional Integer max count of items to return. # Defaults to #per_class class method. # # Returns Hash with :max_count and :skip keys. def log_pagination_options(options = {}) skip = page_to_skip(options.delete(:page)) options[:max_count] = [options.delete(:per_page).to_i, per_page].max options[:skip] = skip if skip > 0 options end end # Turns a page number into an offset number for the git skip option. # # page - Integer page number. # # Returns an Integer. def page_to_skip(page) self.class.page_to_skip(page) end # Fills in git-specific options for the log command using simple # pagination options. # # options - Hash of options: # page - Optional Integer page number (default: 1) # per_page - Optional Integer max count of items to return. # Defaults to #per_class class method. # # Returns Hash with :max_count and :skip keys. def log_pagination_options(options = {}) self.class.log_pagination_options(options) end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/sanitization.rb000664 000000 000000 00000013626 13737324223 023444 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum # Encapsulate sanitization options. # # This class does not yet support all options of Sanitize library. # See http://github.com/rgrove/sanitize/. class Sanitization # Default whitelisted elements. ELEMENTS = [ 'a', 'abbr', 'acronym', 'address', 'area', 'b', 'big', 'blockquote', 'br', 'button', 'caption', 'center', 'cite', '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', 'mark', 'menu', 'ol', 'optgroup', 'option', 'p', 'pre', 'q', 's', 'samp', 'select', 'small', 'span', 'strike', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var' ].freeze # Default whitelisted attributes. ATTRIBUTES = { 'a' => ['href'], 'img' => ['src'], :all => ['abbr', 'accept', 'accept-charset', 'accesskey', 'action', 'align', 'alt', 'axis', 'border', 'cellpadding', 'cellspacing', 'char', 'charoff', 'class', 'charset', 'checked', 'cite', 'clear', 'cols', 'colspan', 'color', 'compact', 'coords', 'datetime', 'dir', 'disabled', 'enctype', 'for', 'frame', 'headers', 'height', 'hreflang', 'hspace', 'id', 'ismap', 'label', 'lang', 'longdesc', 'maxlength', 'media', 'method', 'multiple', 'name', 'nohref', 'noshade', 'nowrap', 'prompt', 'readonly', 'rel', 'rev', 'rows', 'rowspan', 'rules', 'scope', 'selected', 'shape', 'size', 'span', 'start', 'summary', 'tabindex', 'target', 'title', 'type', 'usemap', 'valign', 'value', 'vspace', 'width'] }.freeze # Default whitelisted protocols for URLs. PROTOCOLS = { 'a' => { 'href' => ['http', 'https', 'mailto', 'ftp', 'irc', 'apt', :relative] }, 'img' => { 'src' => ['http', 'https', :relative] }, 'form' => { 'action' => ['http', 'https', :relative] } }.freeze ADD_ATTRIBUTES = lambda do |env, node| if (add = env[:config][:add_attributes][node.name]) add.each do |key, value| node[key] = value end end end # Default elements whose contents will be removed in addition # to the elements themselve REMOVE_CONTENTS = [ 'script', 'style' ].freeze # Default transformers to force @id attributes with 'wiki-' prefix TRANSFORMERS = [ lambda do |env| node = env[:node] return if env[:is_whitelisted] || !node.element? prefix = env[:config][:id_prefix] found_attrs = %w(id name).select do |key| if (value = node[key]) node[key] = value.gsub(/\A(#{prefix})?/, prefix) end end if found_attrs.size > 0 ADD_ATTRIBUTES.call(env, node) {} end end, lambda do |env| node = env[:node] return unless (value = node['href']) prefix = env[:config][:id_prefix] node['href'] = value.gsub(/\A\#(#{prefix})?/, '#'+prefix) ADD_ATTRIBUTES.call(env, node) {} end ].freeze # Gets an Array of whitelisted HTML elements. Default: ELEMENTS. attr_reader :elements # Gets a Hash describing which attributes are allowed in which HTML # elements. Default: ATTRIBUTES. attr_reader :attributes # Gets a Hash describing which URI protocols are allowed in HTML # attributes. Default: PROTOCOLS attr_reader :protocols # Gets a Hash describing which URI protocols are allowed in HTML # attributes. Default: TRANSFORMERS attr_reader :transformers # Gets or sets a String prefix which is added to ID attributes. # Default: '' attr_accessor :id_prefix # Gets a Hash describing HTML attributes that Sanitize should add. # Default: {} attr_reader :add_attributes # Gets an Array of element names whose contents will be removed in addition # to the elements themselves. Default: REMOVE_CONTENTS attr_reader :remove_contents # Sets a boolean determining whether Sanitize allows HTML comments in the # output. Default: false. attr_writer :allow_comments def initialize @elements = ELEMENTS.dup @attributes = ATTRIBUTES.dup @protocols = PROTOCOLS.dup @transformers = TRANSFORMERS.dup @add_attributes = {} @remove_contents = REMOVE_CONTENTS.dup @allow_comments = false @id_prefix = '' yield self if block_given? end # Determines if Sanitize should allow HTML comments. # # Returns True if comments are allowed, or False. def allow_comments? !!@allow_comments end # Modifies the current Sanitization instance to sanitize older revisions # of pages. # # Returns a Sanitization instance. def history_sanitization self.class.new do |sanitize| sanitize.add_attributes['a'] = { 'rel' => 'nofollow' } end end # Builds a Hash of options suitable for Sanitize.clean. # # Returns a Hash. def to_hash { :elements => elements, :attributes => attributes, :protocols => protocols, :add_attributes => add_attributes, :remove_contents => remove_contents, :allow_comments => allow_comments?, :transformers => transformers, :id_prefix => id_prefix } end # Builds a Sanitize instance from the current options. # # Returns a Sanitize instance. def to_sanitize Sanitize.new(to_hash) end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/sorters/000775 000000 000000 00000000000 13737324223 022074 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/sorters/wiki_sorter.rb000664 000000 000000 00000002212 13737324223 024757 0ustar00rootroot000000 000000 module Gollum module Sorters class WikiSorter SORT_CREATED_AT = "created_at".freeze attr_reader :sort, :direction_desc, :limit def initialize(sort, direction_desc, limit) @sort = sort @direction_desc = direction_desc @limit = limit end def call(sha, access, blobs) if sort == SORT_CREATED_AT by_created_at(sha, access, blobs) else by_title(blobs) end end private def by_created_at(sha, access, blobs) blobs_by_path = blobs.each_with_object({}) do |entry, hash| hash[entry.path] = entry end filenames = access.files_sorted_by_created_at(sha) iterator = direction_desc ? filenames.each : filenames.reverse_each iterator.with_object([]) do |filename, blobs| blob = blobs_by_path[filename] next unless blob blobs << blob break blobs if limit && blobs.size == limit end end def by_title(blobs) blobs = blobs.reverse if direction_desc blobs = blobs.take(limit) if limit blobs end end end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/version.rb000664 000000 000000 00000000107 13737324223 022403 0ustar00rootroot000000 000000 module Gollum module Lib VERSION = '4.2.7.10.gitlab.1' end end gollum-lib-v4.2.7.10.gitlab.1/lib/gollum-lib/wiki.rb000664 000000 000000 00000100536 13737324223 021670 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ module Gollum class Wiki include Pagination class << self # Sets the page class used by all instances of this Wiki. attr_writer :page_class # Sets the file class used by all instances of this Wiki. attr_writer :file_class # Sets the markup class used by all instances of this Wiki. attr_writer :markup_classes # Sets the default ref for the wiki. attr_writer :default_ref # Sets the default name for commits. attr_writer :default_committer_name # Sets the default email for commits. attr_writer :default_committer_email # Array of chars to substitute whitespace for when trying to locate file in git repo. attr_writer :default_ws_subs # Sets sanitization options. Set to false to deactivate # sanitization altogether. attr_writer :sanitization # Sets sanitization options. Set to false to deactivate # sanitization altogether. attr_writer :history_sanitization # Hash for setting different default wiki options # These defaults can be overridden by options passed directly to initialize() attr_writer :default_options # Gets the page class used by all instances of this Wiki. # Default: Gollum::Page. def page_class @page_class || if superclass.respond_to?(:page_class) superclass.page_class else ::Gollum::Page end end # Gets the file class used by all instances of this Wiki. # Default: Gollum::File. def file_class @file_class || if superclass.respond_to?(:file_class) superclass.file_class else ::Gollum::File end end # Gets the markup class used by all instances of this Wiki. # Default: Gollum::Markup def markup_classes @markup_classes ||= if superclass.respond_to?(:markup_classes) superclass.markup_classes else Hash.new(::Gollum::Markup) end end # Gets the default markup class used by all instances of this Wiki. # Kept for backwards compatibility until Gollum v2.x def markup_class(language=:default) markup_classes[language] end # Sets the default markup class used by all instances of this Wiki. # Kept for backwards compatibility until Gollum v2.x def markup_class=(default) @markup_classes = Hash.new(default).update(markup_classes) default end alias_method :default_markup_class, :markup_class alias_method :default_markup_class=, :markup_class= # Gets the default sanitization options for current pages used by # instances of this Wiki. def sanitization if @sanitization.nil? @sanitization = Sanitization.new end @sanitization end # Gets the default sanitization options for older page revisions used by # instances of this Wiki. def history_sanitization if @history_sanitization.nil? @history_sanitization = sanitization ? sanitization.history_sanitization : false end @history_sanitization end def default_ref @default_ref || 'master' end def default_committer_name @default_committer_name || 'Anonymous' end def default_committer_email @default_committer_email || 'anon@anon.com' end def default_ws_subs @default_ws_subs || ['_', '-'] end def default_options @default_options || {} end end # The String base path to prefix to internal links. For example, when set # to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults # to "/". attr_reader :base_path # Gets the sanitization options for current pages used by this Wiki. attr_reader :sanitization # Gets the sanitization options for older page revisions used by this Wiki. attr_reader :history_sanitization # Gets the String ref in which all page files reside. attr_reader :ref # Gets the String directory in which all page files reside. attr_reader :page_file_dir # Gets the Array of chars to sub for ws in filenames. attr_reader :ws_subs # Gets the boolean live preview value. attr_reader :live_preview # Injects custom css from custom.css in root repo. # Defaults to false attr_reader :css # Sets page title to value of first h1 # Defaults to false attr_reader :h1_title # Gets the custom index page for / and subdirs (e.g. foo/) attr_reader :index_page # Gets side on which the sidebar should be shown attr_reader :bar_side # An array of symbols which refer to classes under Gollum::Filter, # each of which is an element in the "filtering chain". See # the documentation for Gollum::Filter for more on how this chain # works, and what filter classes need to implement. attr_reader :filter_chain # Public: Initialize a new Gollum Repo. # # path - The String path to the Git repository that holds the Gollum # site. # options - Optional Hash: # :universal_toc - Table of contents on all pages. Default: false # :live_preview - Livepreview editing for markdown files. Default: true # :base_path - String base path for all Wiki links. # Default: "/" # :page_class - The page Class. Default: Gollum::Page # :file_class - The file Class. Default: Gollum::File # :markup_classes - A hash containing the markup Classes for each # document type. Default: { Gollum::Markup } # :sanitization - An instance of Sanitization. # :page_file_dir - String the directory in which all page files reside # :ref - String the repository ref to retrieve pages from # :ws_subs - Array of chars to sub for ws in filenames. # :mathjax - Set to false to disable mathjax. # :user_icons - Enable user icons on the history page. [gravatar, identicon, none]. # Default: none # :show_all - Show all files in file view, not just valid pages. # Default: false # :collapse_tree - Start with collapsed file view. Default: false # :css - Include the custom.css file from the repo. # :emoji - Parse and interpret emoji tags (e.g. :heart:). # :h1_title - Concatenate all h1's on a page to form the # page title. # :index_page - The default page to retrieve or create if the # a directory is accessed. # :bar_side - Where the sidebar should be displayed, may be: # - :left # - :right # :allow_uploads - Set to true to allow file uploads. # :per_page_uploads - Whether uploads should be stored in a central # 'uploads' directory, or in a directory named for # the page they were uploaded to. # :filter_chain - Override the default filter chain with your own. # # Returns a fresh Gollum::Repo. def initialize(path, options = {}) options = self.class.default_options.merge(options) if path.is_a?(GitAccess) options[:access] = path path = path.path end # Use .fetch instead of || # # o = { :a => false } # o[:a] || true # => true # o.fetch :a, true # => false @path = path @repo_is_bare = options.fetch :repo_is_bare, nil @page_file_dir = options.fetch :page_file_dir, nil @access = options.fetch :access, GitAccess.new(path, @page_file_dir, @repo_is_bare) @base_path = options.fetch :base_path, "/" @page_class = options.fetch :page_class, self.class.page_class @file_class = options.fetch :file_class, self.class.file_class @markup_classes = options.fetch :markup_classes, self.class.markup_classes @repo = @access.repo @ref = options.fetch :ref, self.class.default_ref @sanitization = options.fetch :sanitization, self.class.sanitization @ws_subs = options.fetch :ws_subs, self.class.default_ws_subs @history_sanitization = options.fetch :history_sanitization, self.class.history_sanitization @live_preview = options.fetch :live_preview, true @universal_toc = options.fetch :universal_toc, false @mathjax = options.fetch :mathjax, false @show_all = options.fetch :show_all, false @collapse_tree = options.fetch :collapse_tree, false @css = options.fetch :css, false @emoji = options.fetch :emoji, false @h1_title = options.fetch :h1_title, false @index_page = options.fetch :index_page, 'Home' @bar_side = options.fetch :sidebar, :right @user_icons = ['gravatar', 'identicon'].include?(options[:user_icons]) ? options[:user_icons] : 'none' @allow_uploads = options.fetch :allow_uploads, false @per_page_uploads = options.fetch :per_page_uploads, false @filter_chain = options.fetch :filter_chain, [:Metadata, :PlainText, :TOC, :RemoteCode, :Code, :Macro, :Emoji, :Sanitize, :WSD, :PlantUML, :Tags, :Render] @filter_chain.delete(:Emoji) unless options.fetch :emoji, false end # Public: check whether the wiki's git repo exists on the filesystem. # # Returns true if the repo exists, and false if it does not. def exist? @access.exist? end # Public: Get the formatted page for a given page name, version, and dir. # # name - The human or canonical String page name of the wiki page. # version - The String version ID to find (default: @ref). # dir - The directory String relative to the repo. # # Returns a Gollum::Page or nil if no matching page was found. def page(name, version = @ref, dir = nil, exact = false) version = @ref if version.nil? @page_class.new(self).find(name, version, dir, exact) end # Public: Convenience method instead of calling page(name, nil, dir). # # name - The human or canonical String page name of the wiki page. # version - The String version ID to find (default: @ref). # dir - The directory String relative to the repo. # # Returns a Gollum::Page or nil if no matching page was found. def paged(name, dir = nil, exact = false, version = @ref) page(name, version, dir, exact) end # Public: Get the static file for a given name. # # name - The full String pathname to the file. # version - The String version ID to find (default: @ref). # try_on_disk - If true, try to return just a reference to a file # that exists on the disk. # # Returns a Gollum::File or nil if no matching file was found. Note # that if you specify try_on_disk=true, you may or may not get a file # for which on_disk? is actually true. def file(name, version = @ref, try_on_disk = false) @file_class.new(self).find(name, version, try_on_disk) end # Public: Create an in-memory Page with the given data and format. This # is useful for previewing what content will look like before committing # it to the repository. # # name - The String name of the page. # format - The Symbol format of the page. # data - The new String contents of the page. # # Returns the in-memory Gollum::Page. def preview_page(name, data, format) page = @page_class.new(self) ext = @page_class.format_to_ext(format.to_sym) name = @page_class.cname(name) + '.' + ext blob = OpenStruct.new(:name => name, :data => data, :is_symlink => false) page.populate(blob) page.version = @access.commit(@ref) page end # Public: Write a new version of a page to the Gollum repo root. # # name - The String name of the page. # format - The Symbol format of the page. # data - The new String contents of the page. # commit - The commit Hash details: # :message - The String commit message. # :name - The String author full name. # :email - The String email address. # :parent - Optional Gollum::Git::Commit parent to this update. # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, # assume that this operation is part of batch of # updates and the commit happens later. # dir - The String subdirectory of the Gollum::Page without any # prefix or suffix slashes (e.g. "foo/bar"). # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. def write_page(name, format, data, commit = {}, dir = '') # spaces must be dashes sanitized_name = name.gsub(' ', '-') sanitized_dir = dir.gsub(' ', '-') sanitized_dir = ::File.join([@page_file_dir, sanitized_dir].compact) multi_commit = !!commit[:committer] committer = multi_commit ? commit[:committer] : Committer.new(self, commit) committer.add_to_index(sanitized_dir, sanitized_name, format, data) committer.after_commit do |index, _sha| @access.refresh index.update_working_dir(sanitized_dir, sanitized_name, format) end multi_commit ? committer : committer.commit end # Public: Rename an existing page without altering content. # # page - The Gollum::Page to update. # rename - The String extension-less full path of the page (leading '/' is ignored). # commit - The commit Hash details: # :message - The String commit message. # :name - The String author full name. # :email - The String email address. # :parent - Optional Gollum::Git::Commit parent to this update. # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, # assume that this operation is part of batch of # updates and the commit happens later. # # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. # Returns false if the operation is a NOOP. def rename_page(page, rename, commit = {}) return false if page.nil? return false if rename.nil? || rename.empty? (target_dir, target_name) = ::File.split(rename.gsub(' ', '-')) (source_dir, source_name) = ::File.split(page.path) source_name = page.filename_stripped # File.split gives us relative paths with ".", commiter.add_to_index doesn't like that. target_dir = '' if target_dir == '.' source_dir = '' if source_dir == '.' target_dir = target_dir.gsub(/^\//, '') # rubocop:disable Style/RegexpLiteral # if the rename is a NOOP, abort if source_dir == target_dir && source_name == target_name return false end multi_commit = !!commit[:committer] committer = multi_commit ? commit[:committer] : Committer.new(self, commit) # This piece only works for multi_commit # If we are in a commit batch and one of the previous operations # has updated the page, any information we ask to the page can be outdated. # Therefore, we should ask first to the current committer tree to see if # there is any updated change. raw_data = raw_data_in_committer(committer, source_dir, page.filename) || raw_data_in_committer(committer, source_dir, "#{target_name}.#{Page.format_to_ext(page.format)}") || page.raw_data committer.delete(page.path) committer.add_to_index(target_dir, target_name, page.format, raw_data) committer.after_commit do |index, _sha| @access.refresh index.update_working_dir(source_dir, source_name, page.format) index.update_working_dir(target_dir, target_name, page.format) end multi_commit ? committer : committer.commit end # Public: Update an existing page with new content. The location of the # page inside the repository will not change. If the given format is # different than the current format of the page, the filename will be # changed to reflect the new format. # # page - The Gollum::Page to update. # name - The String extension-less name of the page. # format - The Symbol format of the page. # data - The new String contents of the page. # commit - The commit Hash details: # :message - The String commit message. # :name - The String author full name. # :email - The String email address. # :parent - Optional Gollum::Git::Commit parent to this update. # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, # assume that this operation is part of batch of # updates and the commit happens later. # # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. def update_page(page, name, format, data, commit = {}) name = name ? ::File.basename(name) : page.name format ||= page.format dir = ::File.dirname(page.path) dir = '' if dir == '.' filename = (rename = page.name != name) ? name.gsub(' ', '-') : page.filename_stripped multi_commit = !!commit[:committer] committer = multi_commit ? commit[:committer] : Committer.new(self, commit) if !rename && page.format == format committer.add(page.path, normalize(data)) else committer.delete(page.path) committer.add_to_index(dir, filename, format, data) end committer.after_commit do |index, _sha| @access.refresh index.update_working_dir(dir, page.filename_stripped, page.format) index.update_working_dir(dir, filename, format) end multi_commit ? committer : committer.commit end # Public: Delete a page. # # page - The Gollum::Page to delete. # commit - The commit Hash details: # :message - The String commit message. # :name - The String author full name. # :email - The String email address. # :parent - Optional Gollum::Git::Commit parent to this update. # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, # assume that this operation is part of batch of # updates and the commit happens later. # # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. def delete_page(page, commit) multi_commit = !!commit[:committer] committer = multi_commit ? commit[:committer] : Committer.new(self, commit) committer.delete(page.path) committer.after_commit do |index, _sha| dir = ::File.dirname(page.path) dir = '' if dir == '.' @access.refresh index.update_working_dir(dir, page.filename_stripped, page.format) end multi_commit ? committer : committer.commit end # Public: Delete a file. # # path - The path to the file to delete # commit - The commit Hash details: # :message - The String commit message. # :name - The String author full name. # :email - The String email address. # :parent - Optional Gollum::Git::Commit parent to this update. # :tree - Optional String SHA of the tree to create the # index from. # :committer - Optional Gollum::Committer instance. If provided, # assume that this operation is part of batch of # updates and the commit happens later. # # Returns the String SHA1 of the newly written version, or the # Gollum::Committer instance if this is part of a batch update. def delete_file(path, commit) dir = ::File.dirname(path) ext = ::File.extname(path) format = ext.split('.').last || 'txt' filename = ::File.basename(path, ext) multi_commit = !!commit[:committer] committer = multi_commit ? commit[:committer] : Committer.new(self, commit) committer.delete(path) committer.after_commit do |index, _sha| dir = '' if dir == '.' @access.refresh index.update_working_dir(dir, filename, format) end multi_commit ? committer : committer.commit end # Public: Lists all pages for this wiki. # # treeish - The String commit ID or ref to find (default: @ref) # # Returns an Array of Gollum::Page instances. def pages(treeish = nil, limit: nil, sort: nil, direction_desc: false) sha = @access.ref_to_sha(treeish || ref) return [] unless sha commit = @access.commit(sha) blobs = tree_map_for(sha).select do |entry| @page_class.valid_page_name?(entry.name) end sorter = Gollum::Sorters::WikiSorter.new(sort, direction_desc, limit) sorter.call(sha, @access, blobs).map { |blob| blob.page(self, commit) } end # Public: Lists all non-page files for this wiki. # # treeish - The String commit ID or ref to find (default: @ref) # # Returns an Array of Gollum::File instances. def files(treeish = nil) file_list(treeish || @ref) end # Public: Returns the number of pages accessible from a commit # # ref - A String ref that is either a commit SHA or references one. # # Returns a Fixnum def size(ref = nil) tree_map_for(ref || @ref).inject(0) do |num, entry| num + (@page_class.valid_page_name?(entry.name) ? 1 : 0) end rescue Gollum::Git::NoSuchShaFound 0 end # Public: Search all pages for this wiki. # # query - The string to search for # # Returns an Array with Objects of page name and count of matches def search(query) options = {:path => page_file_dir, :ref => ref} results = {} @repo.git.grep(query, options).each do |hit| name = hit[:name] count = hit[:count] # Remove ext only from known extensions. # test.pdf => test.pdf, test.md => test file_name = Page::valid_page_name?(name) ? name.chomp(::File.extname(name)) : name results[file_name] = count.to_i end # Use git ls-files '*query*' to search for file names. Grep only searches file content. # Spaces are converted to dashes when saving pages to disk. @repo.git.ls_files(query.gsub(' ','-'), options).each do |path| # Remove ext only from known extensions. file_name = Page::valid_page_name?(path) ? path.chomp(::File.extname(path)) : path # If there's not already a result for file_name then # the value is nil and nil.to_i is 0. results[file_name] = results[file_name].to_i + 1; end results.map do |key, val| { :count => val, :name => key } end end # Public: All of the versions that have touched the Page. # # options - The options Hash: # :page - The Integer page number (default: 1). # :per_page - The Integer max count of items to return. # # Returns an Array of Gollum::Git::Commit. def log(options = {}) @repo.log(@ref, nil, log_pagination_options(options)) end # Returns the latest changes in the wiki (globally) # # options - The options Hash: # :max_count - The Integer number of items to return. # # Returns an Array of Gollum::Git::Commit. def latest_changes(options={}) options[:max_count] = 10 unless options[:max_count] @repo.log(@ref, nil, options) end # Public: Refreshes just the cached Git reference data. This should # be called after every Gollum update. # # Returns nothing. def clear_cache @access.refresh end # Public: Creates a Sanitize instance using the Wiki's sanitization # options. # # Returns a Sanitize instance. def sanitizer if (options = sanitization) @sanitizer ||= options.to_sanitize end end # Public: Creates a Sanitize instance using the Wiki's history sanitization # options. # # Returns a Sanitize instance. def history_sanitizer if (options = history_sanitization) @history_sanitizer ||= options.to_sanitize end end # Public: Add an additional link to the filter chain. # # name - A symbol which represents the name of a class under the # Gollum::Render namespace to insert into the chain. # # loc - A "location specifier" -- that is, where to put the new # filter in the chain. This can be one of `:first`, `:last`, # `:before => :SomeElement`, or `:after => :SomeElement`, where # `:SomeElement` (if specified) is a symbol already in the # filter chain. A `:before` or `:after` which references a # filter that doesn't exist will cause `ArgumentError` to be # raised. # # Returns nothing. def add_filter(name, loc) unless name.is_a? Symbol raise ArgumentError, "Invalid filter name #{name.inspect} (must be a symbol)" end case loc when :first @filter_chain.unshift(name) when :last @filter_chain.push(name) when Hash if loc.length != 1 raise ArgumentError, "Invalid location specifier" end if ([:before, :after] && loc.keys).empty? raise ArgumentError, "Invalid location specifier" end next_to = loc.values.first relative = loc.keys.first i = @filter_chain.index(next_to) if i.nil? raise ArgumentError, "Unknown filter #{next_to.inspect}" end i += 1 if relative == :after @filter_chain.insert(i, name) else raise ArgumentError, "Invalid location specifier" end end # Remove the named filter from the filter chain. # # Returns nothing. Raises `ArgumentError` if the named filter doesn't # exist in the chain. def remove_filter(name) unless name.is_a? Symbol raise ArgumentError, "Invalid filter name #{name.inspect} (must be a symbol)" end unless @filter_chain.delete(name) raise ArgumentError, "#{name.inspect} not found in filter chain" end end ######################################################################### # # Internal Methods # ######################################################################### # The Gollum::Git::Repo associated with the wiki. # # Returns the Gollum::Git::Repo. attr_reader :repo # The String path to the Git repository that holds the Gollum site. # # Returns the String path. attr_reader :path # Gets the page class used by all instances of this Wiki. attr_reader :page_class # Gets the file class used by all instances of this Wiki. attr_reader :file_class # Gets the markup class used by all instances of this Wiki. attr_reader :markup_classes # Toggles display of universal table of contents attr_reader :universal_toc # Toggles mathjax. attr_reader :mathjax # Toggles user icons. Default: 'none' attr_reader :user_icons # Toggles showing all files in files view. Default is false. # When false, only valid pages in the git repo are displayed. attr_reader :show_all # Start with collapsed file view. Default: false attr_reader :collapse_tree # Toggles file upload functionality. attr_reader :allow_uploads # Toggles whether uploaded files go into 'uploads', or a directory # named after the page they were uploaded to. attr_reader :per_page_uploads # Normalize the data. # # data - The String data to be normalized. # # Returns the normalized data String. def normalize(data) data.gsub(/\r/, '') end # Assemble a Page's filename from its name and format. # # name - The String name of the page (should be pre-canonicalized). # format - The Symbol format of the page. # # Returns the String filename. def page_file_name(name, format) name + '.' + @page_class.format_to_ext(format) end # Fill an array with a list of pages. # # ref - A String ref that is either a commit SHA or references one. # # Returns a flat Array of Gollum::Page instances. def tree_list(ref, limit: nil) if (sha = @access.ref_to_sha(ref)) commit = @access.commit(sha) tree_map_for(sha).inject([]) do |list, entry| next list unless @page_class.valid_page_name?(entry.name) list << entry.page(self, commit) break list if limit && list.size >= limit list end else [] end end # Fill an array with a list of files. # # ref - A String ref that is either a commit SHA or references one. # # Returns a flat Array of Gollum::File instances. def file_list(ref) if (sha = @access.ref_to_sha(ref)) commit = @access.commit(sha) tree_map_for(sha).inject([]) do |list, entry| next list if entry.name.start_with?('_') next list if @page_class.valid_page_name?(entry.name) list << entry.file(self, commit) end else [] end end # Gets the default name for commits. # # Returns the String name. def default_committer_name @default_committer_name ||= \ @repo.config['user.name'] || self.class.default_committer_name end # Gets the default email for commits. # # Returns the String email address. def default_committer_email email = @repo.config['user.email'] email = email.delete('<>') if email @default_committer_email ||= email || self.class.default_committer_email end # Gets the commit object for the given ref or sha. # # ref - A string ref or SHA pointing to a valid commit. # # Returns a Gollum::Git::Commit instance. def commit_for(ref) @access.commit(ref) rescue Gollum::Git::NoSuchShaFound end # Finds a full listing of files and their blob SHA for a given ref. Each # listing is cached based on its actual commit SHA. # # ref - A String ref that is either a commit SHA or references one. # ignore_page_file_dir - Boolean, if true, searches all files within the git repo, regardless of dir/subdir # # Returns an Array of BlobEntry instances. def tree_map_for(ref, ignore_page_file_dir=false) if ignore_page_file_dir && !@page_file_dir.nil? @root_access ||= GitAccess.new(path, nil, @repo_is_bare) @root_access.tree(ref) else @access.tree(ref) end rescue Gollum::Git::NoSuchShaFound [] end def inspect %(#<#{self.class.name}:#{object_id} #{@repo.path}>) end private def raw_data_in_committer(committer, dir, filename) data = nil [*dir.split(::File::SEPARATOR), filename].each do |key| data = data ? data[key] : committer.tree[key] break unless data end data end end end gollum-lib-v4.2.7.10.gitlab.1/licenses/000775 000000 000000 00000000000 13737324223 017367 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/licenses/licenses.txt000664 000000 000000 00000000623 13737324223 021736 0ustar00rootroot000000 000000 For gollum code, everything should fall under the existing MIT License. Alternative permissive licenses (such as BSD) for 3rd party dependencies are acceptable. For image assets in Gollum, CC BY or CC BY-SA is fine. Anything released under a copyleft license (for example GPL, AGPL, LGPL, MPL, EPL, etc.) is not permitted in gollum. Public domain, CC BY or CC BY-SA for code in gollum is not permitted. gollum-lib-v4.2.7.10.gitlab.1/test/000775 000000 000000 00000000000 13737324223 016541 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/assertions.rb000664 000000 000000 00000002177 13737324223 021267 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require 'nokogiri' require 'nokogiri/diff' def normalize_html(text) text.strip! text.gsub!(/\s\s+/,' ') text.gsub!(/\p{Pi}|\p{Pf}|&quot;/u,'"') text.gsub!("\u2026",'...') text end def assert_html_equal(expected, actual, msg = nil) msg = build_message(msg, "? expected to be HTML equivalent to ?.", expected, actual) assert_block(msg) do expected_doc = Nokogiri::HTML(expected) {|config| config.noblanks} actual_doc = Nokogiri::HTML(actual) {|config| config.noblanks} expected_doc.search('//text()').each {|node| node.content = normalize_html node.content} actual_doc.search('//text()').each {|node| node.content = normalize_html node.content} ignore_changes = {"+" => Regexp.union(/^\s*id=".*"\s*$/), "-" => nil} expected_doc.diff(actual_doc) do |change, node| if change != ' ' && !node.blank? then break unless node.to_html =~ ignore_changes[change] end end end end def assert_max_seconds(max_seconds, name = "an operation") start = Time.now yield assert (Time.now - start) < max_seconds, "#{name} took more than #{max_seconds} seconds" end gollum-lib-v4.2.7.10.gitlab.1/test/examples/000775 000000 000000 00000000000 13737324223 020357 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/000775 000000 000000 00000000000 13737324223 022277 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/HEAD000664 000000 000000 00000000027 13737324223 022722 0ustar00rootroot000000 000000 ref: refs/heads/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/config000664 000000 000000 00000000125 13737324223 023465 0ustar00rootroot000000 000000 [core] repositoryformatversion = 0 filemode = true bare = true ignorecase = true gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/description000664 000000 000000 00000000111 13737324223 024536 0ustar00rootroot000000 000000 Unnamed repository; edit this file 'description' to name the repository. gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/000775 000000 000000 00000000000 13737324223 023422 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/applypatch-msg.sample000775 000000 000000 00000000704 13737324223 027562 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script to check the commit log message taken by # applypatch from an e-mail message. # # The hook should exit with non-zero status after issuing an # appropriate message if it wants to stop the commit. The hook is # allowed to edit the commit message file. # # To enable this hook, rename this file to "applypatch-msg". . git-sh-setup test -x "$GIT_DIR/hooks/commit-msg" && exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} : gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/commit-msg.sample000775 000000 000000 00000001600 13737324223 026701 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script to check the commit log message. # Called by "git commit" with one argument, the name of the file # that has the commit message. The hook should exit with non-zero # status after issuing an appropriate message if it wants to stop the # commit. The hook is allowed to edit the commit message file. # # To enable this hook, rename this file to "commit-msg". # Uncomment the below to add a Signed-off-by line to the message. # Doing this in a hook is a bad idea in general, but the prepare-commit-msg # hook is more suited to it. # # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" # This example catches duplicate Signed-off-by lines. test "" = "$(grep '^Signed-off-by: ' "$1" | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { echo >&2 Duplicate Signed-off-by lines. exit 1 } gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/post-commit.sample000775 000000 000000 00000000240 13737324223 027077 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script that is called after a successful # commit is made. # # To enable this hook, rename this file to "post-commit". : Nothing gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/post-receive.sample000775 000000 000000 00000001050 13737324223 027231 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script for the "post-receive" event. # # The "post-receive" script is run after receive-pack has accepted a pack # and the repository has been updated. It is passed arguments in through # stdin in the form # # For example: # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master # # see contrib/hooks/ for a sample, or uncomment the next line and # rename the file to "post-receive". #. /usr/share/doc/git-core/contrib/hooks/post-receive-email gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/post-update.sample000775 000000 000000 00000000275 13737324223 027101 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script to prepare a packed repository for use over # dumb transports. # # To enable this hook, rename this file to "post-update". exec git update-server-info gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/pre-applypatch.sample000775 000000 000000 00000000616 13737324223 027564 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script to verify what is about to be committed # by applypatch from an e-mail message. # # The hook should exit with non-zero status after issuing an # appropriate message if it wants to stop the commit. # # To enable this hook, rename this file to "pre-applypatch". . git-sh-setup test -x "$GIT_DIR/hooks/pre-commit" && exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} : gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/pre-commit.sample000775 000000 000000 00000003052 13737324223 026704 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # # To enable this hook, rename this file to "pre-commit". if git rev-parse --verify HEAD >/dev/null 2>&1 then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi # If you want to allow non-ascii filenames set this variable to true. allownonascii=$(git config hooks.allownonascii) # Cross platform projects tend to avoid non-ascii filenames; prevent # them from being added to the repository. We exploit the fact that the # printable range starts at the space character and ends with tilde. if [ "$allownonascii" != "true" ] && # Note that the use of brackets around a tr range is ok here, (it's # even required, for portability to Solaris 10's /usr/bin/tr), since # the square bracket bytes happen to fall in the designated range. test "$(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0')" then echo "Error: Attempt to add a non-ascii file name." echo echo "This can cause problems if you want to work" echo "with people on other platforms." echo echo "To be portable it is advisable to rename the file ..." echo echo "If you know what you are doing you can disable this" echo "check using:" echo echo " git config hooks.allownonascii true" echo exit 1 fi exec git diff-index --check --cached $against -- gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/pre-rebase.sample000775 000000 000000 00000011527 13737324223 026663 0ustar00rootroot000000 000000 #!/bin/sh # # Copyright (c) 2006, 2008 Junio C Hamano # # The "pre-rebase" hook is run just before "git rebase" starts doing # its job, and can prevent the command from running by exiting with # non-zero status. # # The hook is called with the following parameters: # # $1 -- the upstream the series was forked from. # $2 -- the branch being rebased (or empty when rebasing the current branch). # # This sample shows how to prevent topic branches that are already # merged to 'next' branch from getting rebased, because allowing it # would result in rebasing already published history. publish=next basebranch="$1" if test "$#" = 2 then topic="refs/heads/$2" else topic=`git symbolic-ref HEAD` || exit 0 ;# we do not interrupt rebasing detached HEAD fi case "$topic" in refs/heads/??/*) ;; *) exit 0 ;# we do not interrupt others. ;; esac # Now we are dealing with a topic branch being rebased # on top of master. Is it OK to rebase it? # Does the topic really exist? git show-ref -q "$topic" || { echo >&2 "No such branch $topic" exit 1 } # Is topic fully merged to master? not_in_master=`git rev-list --pretty=oneline ^master "$topic"` if test -z "$not_in_master" then echo >&2 "$topic is fully merged to master; better remove it." exit 1 ;# we could allow it, but there is no point. fi # Is topic ever merged to next? If so you should not be rebasing it. only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` only_next_2=`git rev-list ^master ${publish} | sort` if test "$only_next_1" = "$only_next_2" then not_in_topic=`git rev-list "^$topic" master` if test -z "$not_in_topic" then echo >&2 "$topic is already up-to-date with master" exit 1 ;# we could allow it, but there is no point. else exit 0 fi else not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` /usr/bin/perl -e ' my $topic = $ARGV[0]; my $msg = "* $topic has commits already merged to public branch:\n"; my (%not_in_next) = map { /^([0-9a-f]+) /; ($1 => 1); } split(/\n/, $ARGV[1]); for my $elem (map { /^([0-9a-f]+) (.*)$/; [$1 => $2]; } split(/\n/, $ARGV[2])) { if (!exists $not_in_next{$elem->[0]}) { if ($msg) { print STDERR $msg; undef $msg; } print STDERR " $elem->[1]\n"; } } ' "$topic" "$not_in_next" "$not_in_master" exit 1 fi exit 0 ################################################################ This sample hook safeguards topic branches that have been published from being rewound. The workflow assumed here is: * Once a topic branch forks from "master", "master" is never merged into it again (either directly or indirectly). * Once a topic branch is fully cooked and merged into "master", it is deleted. If you need to build on top of it to correct earlier mistakes, a new topic branch is created by forking at the tip of the "master". This is not strictly necessary, but it makes it easier to keep your history simple. * Whenever you need to test or publish your changes to topic branches, merge them into "next" branch. The script, being an example, hardcodes the publish branch name to be "next", but it is trivial to make it configurable via $GIT_DIR/config mechanism. With this workflow, you would want to know: (1) ... if a topic branch has ever been merged to "next". Young topic branches can have stupid mistakes you would rather clean up before publishing, and things that have not been merged into other branches can be easily rebased without affecting other people. But once it is published, you would not want to rewind it. (2) ... if a topic branch has been fully merged to "master". Then you can delete it. More importantly, you should not build on top of it -- other people may already want to change things related to the topic as patches against your "master", so if you need further changes, it is better to fork the topic (perhaps with the same name) afresh from the tip of "master". Let's look at this example: o---o---o---o---o---o---o---o---o---o "next" / / / / / a---a---b A / / / / / / / / c---c---c---c B / / / / \ / / / / b---b C \ / / / / / \ / ---o---o---o---o---o---o---o---o---o---o---o "master" A, B and C are topic branches. * A has one fix since it was merged up to "next". * B has finished. It has been fully merged up to "master" and "next", and is ready to be deleted. * C has not merged to "next" at all. We would want to allow C to be rebased, refuse A, and encourage B to be deleted. To compute (1): git rev-list ^master ^topic next git rev-list ^master next if these match, topic has not merged in next at all. To compute (2): git rev-list master..topic if this is empty, it is fully merged to "master". gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/prepare-commit-msg.sample000775 000000 000000 00000002327 13737324223 030344 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script to prepare the commit log message. # Called by "git commit" with the name of the file that has the # commit message, followed by the description of the commit # message's source. The hook's purpose is to edit the commit # message file. If the hook fails with a non-zero status, # the commit is aborted. # # To enable this hook, rename this file to "prepare-commit-msg". # This hook includes three examples. The first comments out the # "Conflicts:" part of a merge commit. # # The second includes the output of "git diff --name-status -r" # into the message, just before the "git status" output. It is # commented because it doesn't cope with --amend or with squashed # commits. # # The third example adds a Signed-off-by line to the message, that can # still be edited. This is rarely a good idea. case "$2,$3" in merge,) /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; # ,|template,) # /usr/bin/perl -i.bak -pe ' # print "\n" . `git diff --cached --name-status -r` # if /^#/ && $first++ == 0' "$1" ;; *) ;; esac # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/hooks/update.sample000775 000000 000000 00000007033 13737324223 026115 0ustar00rootroot000000 000000 #!/bin/sh # # An example hook script to blocks unannotated tags from entering. # Called by "git receive-pack" with arguments: refname sha1-old sha1-new # # To enable this hook, rename this file to "update". # # Config # ------ # hooks.allowunannotated # This boolean sets whether unannotated tags will be allowed into the # repository. By default they won't be. # hooks.allowdeletetag # This boolean sets whether deleting tags will be allowed in the # repository. By default they won't be. # hooks.allowmodifytag # This boolean sets whether a tag may be modified after creation. By default # it won't be. # hooks.allowdeletebranch # This boolean sets whether deleting branches will be allowed in the # repository. By default they won't be. # hooks.denycreatebranch # This boolean sets whether remotely creating branches will be denied # in the repository. By default this is allowed. # # --- Command line refname="$1" oldrev="$2" newrev="$3" # --- Safety check if [ -z "$GIT_DIR" ]; then echo "Don't run this script from the command line." >&2 echo " (if you want, you could supply GIT_DIR then run" >&2 echo " $0 )" >&2 exit 1 fi if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then echo "Usage: $0 " >&2 exit 1 fi # --- Config allowunannotated=$(git config --bool hooks.allowunannotated) allowdeletebranch=$(git config --bool hooks.allowdeletebranch) denycreatebranch=$(git config --bool hooks.denycreatebranch) allowdeletetag=$(git config --bool hooks.allowdeletetag) allowmodifytag=$(git config --bool hooks.allowmodifytag) # check for no description projectdesc=$(sed -e '1q' "$GIT_DIR/description") case "$projectdesc" in "Unnamed repository"* | "") echo "*** Project description file hasn't been set" >&2 exit 1 ;; esac # --- Check types # if $newrev is 0000...0000, it's a commit to delete a ref. zero="0000000000000000000000000000000000000000" if [ "$newrev" = "$zero" ]; then newrev_type=delete else newrev_type=$(git cat-file -t $newrev) fi case "$refname","$newrev_type" in refs/tags/*,commit) # un-annotated tag short_refname=${refname##refs/tags/} if [ "$allowunannotated" != "true" ]; then echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 exit 1 fi ;; refs/tags/*,delete) # delete tag if [ "$allowdeletetag" != "true" ]; then echo "*** Deleting a tag is not allowed in this repository" >&2 exit 1 fi ;; refs/tags/*,tag) # annotated tag if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 then echo "*** Tag '$refname' already exists." >&2 echo "*** Modifying a tag is not allowed in this repository." >&2 exit 1 fi ;; refs/heads/*,commit) # branch if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then echo "*** Creating a branch is not allowed in this repository" >&2 exit 1 fi ;; refs/heads/*,delete) # delete branch if [ "$allowdeletebranch" != "true" ]; then echo "*** Deleting a branch is not allowed in this repository" >&2 exit 1 fi ;; refs/remotes/*,commit) # tracking branch ;; refs/remotes/*,delete) # delete tracking branch if [ "$allowdeletebranch" != "true" ]; then echo "*** Deleting a tracking branch is not allowed in this repository" >&2 exit 1 fi ;; *) # Anything else (is there anything else?) echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 exit 1 ;; esac # --- Finished exit 0 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/info/000775 000000 000000 00000000000 13737324223 023232 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/info/exclude000664 000000 000000 00000000360 13737324223 024605 0ustar00rootroot000000 000000 # git ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/objects/000775 000000 000000 00000000000 13737324223 023730 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/objects/info/000775 000000 000000 00000000000 13737324223 024663 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/objects/info/.gitkeep000664 000000 000000 00000000000 13737324223 026302 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/objects/pack/000775 000000 000000 00000000000 13737324223 024646 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/objects/pack/.gitkeep000664 000000 000000 00000000000 13737324223 026265 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/refs/000775 000000 000000 00000000000 13737324223 023236 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/refs/heads/000775 000000 000000 00000000000 13737324223 024322 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/empty.git/refs/heads/.gitkeep000664 000000 000000 00000000000 13737324223 025741 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/000775 000000 000000 00000000000 13737324223 022121 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/COMMIT_EDITMSG000664 000000 000000 00000000035 13737324223 024206 0ustar00rootroot000000 000000 Test out whitespace with Sam gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/HEAD000664 000000 000000 00000000027 13737324223 022544 0ustar00rootroot000000 000000 ref: refs/heads/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/ORIG_HEAD000664 000000 000000 00000000051 13737324223 023361 0ustar00rootroot000000 000000 a8ad3c09dd842a3517085bfadd37718856dee813 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/config000664 000000 000000 00000000436 13737324223 023314 0ustar00rootroot000000 000000 [core] repositoryformatversion = 0 filemode = true bare = true logallrefupdates = true ignorecase = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = /Users/rick/p/gollum/test/examples/lotr.git [branch "master"] remote = origin merge = refs/heads/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/description000664 000000 000000 00000000111 13737324223 024360 0ustar00rootroot000000 000000 Unnamed repository; edit this file 'description' to name the repository. gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/index000664 000000 000000 00000001760 13737324223 023157 0ustar00rootroot000000 000000 DIRC NdNdu_,jӃEaP/Z~HBilbo-Baggins.mdNdNdu`/ô>kz6T.Data.csvNdNduauSD +A) ٔe Home.textileNdNduc Ǔk ؃zۂQ@囶uMordor/Eye-Of-Sauron.mdNdNdud+eexm2Mordor/_Footer.mdNdNdue+eexm2Mordor/_Sidebar.mdNdNduf%qC##@j*g<@OMordor/eye.jpgNdNdug )4mL/;?hDMordor/todo.txtNdNduhVaL Q49hMy-Precious.mdNeGNeGu4Yv;-uDbо.{Samwise Gamgee.mediawikiNdNdui2E 0sK _Footer.mdNdNduj2E 0sK _Sidebar.mdUG;oJ4t\n58~gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/info/000775 000000 000000 00000000000 13737324223 023054 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/info/exclude000664 000000 000000 00000000360 13737324223 024427 0ustar00rootroot000000 000000 # git ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/logs/000775 000000 000000 00000000000 13737324223 023065 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/logs/HEAD000664 000000 000000 00000003145 13737324223 023514 0ustar00rootroot000000 000000 0000000000000000000000000000000000000000 60f12f4254f58801b9ee7db7bca5fa8aeefaa56b rick 1291341857 -0800 clone: from /Users/rick/p/gollum/test/examples/lotr.git 60f12f4254f58801b9ee7db7bca5fa8aeefaa56b a8ad3c09dd842a3517085bfadd37718856dee813 rick 1291341922 -0800 commit: add sidebars a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell 1309107565 +0200 commit: Test out whitespace with Sam 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi 1336983525 -0700 push b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi 1336984025 -0700 push b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley 1341830099 +0100 push cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley 1341830833 +0100 push 629aa678272b017a4d136d35e77ac94d80b08dc2 7d6aeab8b84c895f21f6c66b84a457b0fced9693 Daniel Kimsey 1352501984 -0500 push 7d6aeab8b84c895f21f6c66b84a457b0fced9693 563cc3701db990caf63e4ce9c3697a062890ca48 James Dabbs 1361843315 -0500 push 563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence 1363478075 -0400 push 874f597a5659b4c3b153674ea04e406ff393975e a3e857e03ecc69a99f1dd72dc3f7e0c47602a05a Horacio Sanson 1422324032 +0900 push gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/logs/refs/000775 000000 000000 00000000000 13737324223 024024 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/logs/refs/heads/000775 000000 000000 00000000000 13737324223 025110 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/logs/refs/heads/master000664 000000 000000 00000003145 13737324223 026331 0ustar00rootroot000000 000000 0000000000000000000000000000000000000000 60f12f4254f58801b9ee7db7bca5fa8aeefaa56b rick 1291341857 -0800 clone: from /Users/rick/p/gollum/test/examples/lotr.git 60f12f4254f58801b9ee7db7bca5fa8aeefaa56b a8ad3c09dd842a3517085bfadd37718856dee813 rick 1291341922 -0800 commit: add sidebars a8ad3c09dd842a3517085bfadd37718856dee813 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 Arran Cudbard-Bell 1309107565 +0200 commit: Test out whitespace with Sam 1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3 b16b3d9fad9d78e5a669e7f33d94c96da374eccd kristi 1336983525 -0700 push b16b3d9fad9d78e5a669e7f33d94c96da374eccd b0de6e794dfdc7ef3400e894225bfe23308aae5c kristi 1336984025 -0700 push b0de6e794dfdc7ef3400e894225bfe23308aae5c cfea406f5f77afc7fb673a43e97721234385b1bd Darren Oakley 1341830099 +0100 push cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc2 Darren Oakley 1341830833 +0100 push 629aa678272b017a4d136d35e77ac94d80b08dc2 7d6aeab8b84c895f21f6c66b84a457b0fced9693 Daniel Kimsey 1352501984 -0500 push 7d6aeab8b84c895f21f6c66b84a457b0fced9693 563cc3701db990caf63e4ce9c3697a062890ca48 James Dabbs 1361843315 -0500 push 563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence 1363478075 -0400 push 874f597a5659b4c3b153674ea04e406ff393975e a3e857e03ecc69a99f1dd72dc3f7e0c47602a05a Horacio Sanson 1422324032 +0900 push gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/000775 000000 000000 00000000000 13737324223 023552 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/00/000775 000000 000000 00000000000 13737324223 023771 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/00/f27bad829ca2202dd876132c2bff7328368524000664 000000 000000 00000000040 13737324223 030677 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR04cpIuJLO+M_gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/06/000775 000000 000000 00000000000 13737324223 023777 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/06/131480411710c92a82fe2d1e76932c70feb2e5000664 000000 000000 00000000352 13737324223 030617 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU026c040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXj0U)I KL*Hg(tV>Ȣ )Ju f.g⎍LQSAF TsTFǥ{k8F ~g<忞А궞v2rP{Ej)E%̏8uexffNvzY,`)gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/27/000775 000000 000000 00000000000 13737324223 024002 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/27/680b0fce1abfbc528e7aa53d92645852d52eb6000664 000000 000000 00000000572 13737324223 031220 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU016d040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXM @=?/%!cВyrO֥z/⑟WZQ`]N~sJ* "A'sVj Q\9+xsVKM%9AEə`w&bn؏D[&?-1*(,5/%5'ލIÐS7}*F[YXɰ,rsuR$ ދ-w/I-ڛ[F*ں|A$6}0U)U3dngQI'6#*83%5)agollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/2c/000775 000000 000000 00000000000 13737324223 024056 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/2c/b9156ad383914561a8502fc70f5a1d887e48ad000664 000000 000000 00000000613 13737324223 031003 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xA0 9WXÀ4ۑ8 0CUmqdقK{/G{ѹWGi U8&V*/Rל 0> L8RLpXGy<+8qi2/d \_ 8ϝŏLv: eU=&Fwc3Lf':$Ne2ܖB4$~ >8'UDžn|RE [,pFOph5*zXYx ů+6Y;{.Y)YuŒ޴e%ϳ._&8Qd߆=6!% fuf5].7֛y948( ߼3:gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/3b/000775 000000 000000 00000000000 13737324223 024056 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/3b/dadf74d9fa9a24a69f746cb4914bcc521ff7c7000664 000000 000000 00000001263 13737324223 031454 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x}TMo1弿b^@j*-*hzz'VWx6- yͼ7[[_wZZCUӤ.'2E-S i-b'8m6F'em;9#)H4qaxfA 99R~JxI֑X0 y^3 ]yB ն! Eμ t-"8zt[&㈹bke:3)}^.y$l @yİ!+MGg0crnUaS3Y\![0K &o}2ZE-) .#Aueb)U^y4D#=[(iSML,w_n^w1l 7 Ǵ̎fYIG&2v6HMI ۭT8 9_7^C* " iZioѰܔT\Kgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/4e/000775 000000 000000 00000000000 13737324223 024062 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/4e/023f460ce466e154ca09d8774c79ad5a53fc15000664 000000 000000 00000000066 13737324223 031063 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU06g040031Qp)KMa}nmC9+k/w}dmgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/54/000775 000000 000000 00000000000 13737324223 024002 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/54/508a71fad5151d39ba6f7ff768e1e3d3c7392a000664 000000 000000 00000000573 13737324223 031154 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU016d040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXM @=?/%!cВyrO֥z/⑟WZQ`]N~sJ* "A'sVj Q\9+xsVKM%9AEə`w&bn؏D[&?-1*(,5/%5'd{&ya~Ɖ۠'g*'榧妦d&gfg2,\fݤ{%I¾bzEzKR@뾇 .mP<{r_3LGjb DU -k#|mTɯ͈ LIMJi֧gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/56/000775 000000 000000 00000000000 13737324223 024004 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/56/3cc3701db990caf63e4ce9c3697a062890ca48000664 000000 000000 00000000265 13737324223 031071 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xAn!sDQ吓~&XvKŻ@J.6,` 91lX"J.rѕ Dr>d*ÉK9uy?_}޾X4%Dx^k5qk:zݦL3'0y8v_0Q[gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/5d/000775 000000 000000 00000000000 13737324223 024062 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/5d/cac289a8603188d2c5caf481dcba2985126aaa000664 000000 000000 00000000346 13737324223 031270 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU026f040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXj0ХJ'zwL}ǕRއè4p#^?<2k%sec8Q*|vipb;z{bT\gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/6e/000775 000000 000000 00000000000 13737324223 024064 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/6e/48abfc56565574859e081ee58eae655d48cf71000664 000000 000000 00000000150 13737324223 031115 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU045f040031Qp/,Ma2z+o~3xT*ϒ>m ɸI(A3p0U)Ug&%4 Agollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/71/000775 000000 000000 00000000000 13737324223 024001 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/71/4323c104239440a5c66ab12a67ed07a83c404f000664 000000 000000 00000022563 13737324223 030614 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xUT臐AnIif萎iqhR))i?ߺrk^뜵-\,iyW(@2hh//^˗ظDoI@rJJjjj7t tT TT)*&&113],7 @y(hy/5 _E/iy0,0܈yC~h0Ya㐾321 WPTRYY;8zxz} @S32 Ke[Zۺ{~ ;7;=; "o,BAO Z B)-L 7":P,b|'$8 kQo;/%h(Fvxi (P]!ğ}nMNd& S=T:i%[E:)x|e@*xڷm npavb0GK3 Jx6'#8RyձIXX"MWwT SnDŽæ= R5wt^#a>10]B~bb4ߧ!KP3^zQWcFjVHӾ 09e!ymnui-1..+>cv@&Ѕ& WSb8d̮ E!޲FFJ0-04|jK`嫖ͭ1h,  %px7YNԶP ko$dPsXfz47sN ͱ:cGs blrl%u6I@HiT쭹Th$IX*3VKF*K 17|1!"*m4wo~Iavc-#zouFgRU -(3qEC!/CEuRN*T"BF+`COGsIްHB"*{}|+Fr+˵g-Gc ,mDeCMsBqjk˳+}Sу9{Ծ#yzZQy.byxyK󅥌-u;\㩺}b0iJf%0JɭSh{xQem |Lw}&j<+?}F`MUkC60P / pa([w/H2~So{"u]„0嚻4^WL6rC _5x917,)o&w4~h>LѸ4[?*JՋY'gioi6O6U5,|A~eLUH (]fퟚ3;}S3Y]/w×܎F 쑫z9p,@eS^ؤeDvhj9z6s8[WQU}PրۙW53BJ{7͍ZM. [(u UeFQ(,a#H=eKlNnF1e2Ȑ=Mec_g~C}*̾{Aį]}]4&1Z%ݓgHn2a|v;9-ONtCf&'}q($? ,Dq.|aii n1çxd:yi71#ivVU{*d08?^MP,6ϙE3c\n0Q!Ϲ ^E)x :fY%}1atg~hPË f2l*Y'_YK;!h[v\C58>K5[*J|GL}u-p2/Ԁv>X>EJ.<{n'ZZWc[)c`~R1T?XMP9TF!b uW<Or7zqu1g)%ShK2I1_¨+gu7,b(Zji YrF^^c=Be<` ,ܡiWYSj6@F_JFdž44ic,m\L3Bc%J2u5>kǵ47Fl$e_Hh- m6P;ҩI )g 3U mmi`_$ɟEMh5C;5SvDcƱw =A?ɉBq5\ )_/-p$| gA p-&W1o_ʪOC }>o?t=V%V~π.1ۇrެss3ֶ!ԎQ|͘S./I+m\ߋ0}vA 8ǘvS@z7S1(_26WIC!`1~k dwQ66Wrr)[&yq".4j]W e;nBxե!liԱֿ\3tYR- +e.@)dZLc=:lcٿiiEi {GNdv1WMұb9/Wދ7ˤ$8;,XI |9E9,ZUY}-ZÂxԿ|@ u'J 'S.AjEgSAbScCҧ˒T_TEW5" t„ۋ.LRT?!C{ɨ]0aI3'AqDy(m4_ȍ+u% (?W;TW:0o.=faO)UV2.s|rC`Z꣙ӌT_[ǀt g/TΝl C2V^vk #erw@!T<ļ28s,!s+UfzhB]A?7]b'w@?QL]u!Uwq0_&4S^Nĥ$!\]`ԥ0[9eRK0gS OrJF@2ZS1yu۽۠&!vS(z@ وA]%3Ja^J7 ?$-fCQkLQ5~n{l)Z' ѕϔ&Z#{0}z)gχړ8WP(uOcubLG5mLϱTFlABw5Ū?OcZJMZZÀJ3Ohrt! dd+3euQ⽬fkUIоF'g@$ p=c :X]eObr)"/Uv~RF9\WY1YXY'؏ r/th+1<]"5l^Pܟ(4J;}հ^|I~(ça/FҊUk) .("mr>8 ^ lKc7{LkToyHxCBpG,p[+#k_B@르E;-j&ML%]Td/q8^0~ }a9Vd8cnt#ah"fa)QA:֪N$}B҇{O}RbJM{%l dkdh7ML ݂1N8_)"F=."2[Akk6hY3kՍklZF׎50 Gaͅ8kSCl^-ϵi&m0Y EΑ+oW{Ğs5? %NHo 3Q#yfN ˊS={+q}̜s^^}D${Q-n5(ڄt_yGٞ~ !blap<9b'jW )ؔD= H+247%mI]f06%}C-`Xmߝ$s5)o ذ՟yFrHs1\;Pe5UCxyN>V//Q•!Ձ:{~wL^-$w# /oYjn|Mgj;);u4$cevg2--t:P{<"i?*֤U|n2gDjnwxa=l{)2,*ovp/m]{^A -:~,gufґw=Whϧz>=n4Uv넫LI@f*7nJ|&R_JL yɤl.{oMnmIF+3J a ?ڔ%#݂q\JnA^|F wSx+g8ShpRކvYŝ- N]8ȓsONC갑7[c_tThI+WRoטEh)?ߑ0IQVpb9)X͇gk" T+6cGMPH0kw8$ӿC7 ?^æo)KD_JbL68*1Qzg(Ujϐv+cZpp⏥=t}qw5󇍫~\{oz%>-[c=L VJL7q)_q\׽h=frf*D X@ V:BP =Y1 i1?'fLZ ?j" [ M% -V6O[Z(zӮ L5uP` H6lc68 (P\yF ۛR\:wy 9Kl '2/F'tFKzp]@% g۱Qqnߊuul\"TЗL_򘻆4 ]mXDGK~L K mm\/FfJQ [ ~,Ԍ X%]Эz;.KNT蝱~h;4y ;c51Y%8<X;}F~D":qg3Y067ϕ m26<+KX[H7Щʦ  C (Q/ržvﷶPu"ٲJbN J)-}!n\LI'w#GE!`pUj;>OC EtSrYTBl*]+KF'' [m8#a}/Je '{$$obAl&]mYS㯙q^LB獀p8$sPc9 B@)| ,-Ad|Ng $.t,QtN1p4KZZHHøyf0<)qg"/ڱ-feᢾ쬈kho*L S ڽ,ߗ?r2?>u|fe?7?M!=b,+ZtCs cy6 CB'p6CVæ}S26tt `x ]U|.א~>г㯽پW[3H ӹ|Z \bE Yx쇊Yv :ljԍ :p'z-̫bT^ӳS~V^n]eE Q7K1É5ڷ-fsU5` 2{A R948h4.kw*ޣriWxlH]7mz҄-mעSZ0|g3CdCCsP?hH۾-^H j__1ށyR1-R7µA,!_.O(N)˧MX(1k9|1)fP,yW7 wVsL/5sloQ'{OA>5WEhv̜VmRZp蠕c|kHjwPF)p հVX,a(.t+hONz@†-E76NjZOOZπ҇g \/QqXvMX_1"AqxSπ~K~Jw̛|;-9[˪!Dh*q0ŊbLbı+%G]fɢAl\dJ[ZgY>]x˗q d֪Ǫ+0ܖ|ڡS b^/M1test/examples/lotr.git/objects/7d/981cd984ad589e3cf00d8122170c6f7d685979000664 000000 000000 00000000027 13737324223 030757 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR`OJ,)&gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/84/000775 000000 000000 00000000000 13737324223 024005 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/84/0ec5b1ba1320e8ec443f28f99566f615d5af10000664 000000 000000 00000000361 13737324223 031055 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU027b040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXj4>ɍWzZbɝc!}RYOymu&2⒄DŽP H;j&4']&nhԭIYЕ#iiݠ|S$ S(O51@98އ4PӅ4HHLK]+$uFMS8!LNXZ€RE6M{,ؘEv5x95ܣk$Ul:riA=I`띘)Xx$i,י iǘQC *ޙ:FxG90)m/_SdN`"[o*|#5YlǾ$x N|jAIos\kXcnw4LvDy @ӌv.'dp1n]FztMLtest/examples/lotr.git/objects/94/9a9cc3119b9c98817f375e976d2bb5e2a42809000664 000000 000000 00000000233 13737324223 030753 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x[ 0)rKݼ@Dd76h[~ LY it8,ɚ rZDA,-)[21:'^sHM9D9y6E#Ek^U2彷m4yq"\nKjYjˣJ{ŕHΜ&uDgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/96/000775 000000 000000 00000000000 13737324223 024010 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/96/97dc65e095658bbd1b8e8678e08881e86d32f1000664 000000 000000 00000000071 13737324223 030767 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR01fK-VHy% ř9 ZZ9ZZ y% E)E\gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/99/000775 000000 000000 00000000000 13737324223 024013 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/99/49601deb167a35ca444311d7372864f3e8e1b8000664 000000 000000 00000000635 13737324223 030654 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU01d040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXM @=?/%!cВyrO֥z/⑟WZQ`]N~sJ* "A'sVj Q\9+xsVKM%9AEə`w&bn؏D[&?-UZWPu&LjW%+DҁXY`vF2=H0w?ćmPs3SsSSrSS233En.nҽY$a{1"P=n%E}sˈuCWU[6(=#51v͖l>6*fDVTg&%4 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/9b/000775 000000 000000 00000000000 13737324223 024064 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/9b/e95b960ac388d4e7db55f610f828e9c31344e6000664 000000 000000 00000000032 13737324223 031101 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR04`PVp/,1Hgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/a3/000775 000000 000000 00000000000 13737324223 024055 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/a3/1ca2a7c352c92531a8b99815d15843b259e814000664 000000 000000 00000000245 13737324223 030634 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU04b040031QpLO N,-MaFs@9O^?6-?$j;vkx"#LUpfJjR"!ezY Y8,=Q+- I%)z%% \4Lr}Y_>8FNtest/examples/lotr.git/objects/a3/e857e03ecc69a99f1dd72dc3f7e0c47602a05a000664 000000 000000 00000000265 13737324223 031302 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xMN!]s7&1Fw.4115|h=@sUJv 7c.Ƣ'$:!(BF겣8.>0D3XRl18(϶S%ޤݏkݶk?KzJt41ְ6nuZفfcI/4p  zSRgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/a6/000775 000000 000000 00000000000 13737324223 024060 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/a6/59b3763b822dd97544621fd0beef162ea37b14000664 000000 000000 00000000507 13737324223 031060 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xRMK1b eTPO%4;6Yh-;[mK!LGt)cH]M,ǧp(@e#4SP> OʳShAgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/a8/000775 000000 000000 00000000000 13737324223 024062 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/a8/ad3c09dd842a3517085bfadd37718856dee813000664 000000 000000 00000000234 13737324223 031144 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xA @Qל hf(PH*Xb۟筵:xY ]D8ILGyڃk`sIs1 Ig,[׽槾˺}G4h>CPG= Z8QoF;gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/aa/000775 000000 000000 00000000000 13737324223 024133 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/aa/b61fe89d56f8614c0a8151da34f939dcedfa68000664 000000 000000 00000000053 13737324223 031370 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR02gKU(KW(W(*IU(HUHQ Hgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/b0/000775 000000 000000 00000000000 13737324223 024053 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/b0/de6e794dfdc7ef3400e894225bfe23308aae5c000664 000000 000000 00000000251 13737324223 031355 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xAj1 {+,6xe5vˮ74000.0@/0c"inIXNnm@BQp&ŒjBBgΙ{!uݾ mǦϥQ d~O޻};t֠`+wG.Ggollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/b1/000775 000000 000000 00000000000 13737324223 024054 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/b1/6b3d9fad9d78e5a669e7f33d94c96da374eccd000664 000000 000000 00000000232 13737324223 031470 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xa !F)@Uƙ B'࣭:l0_8/ IqR0G+0Ft7P!^Y7Egollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/bc/000775 000000 000000 00000000000 13737324223 024136 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/bc/4b5fc0ce2c2ba3acef6647e4f67256ee45ab60000664 000000 000000 00000000440 13737324223 031503 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU062a040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXj\L~Zy+8-?$7X=tUXunIlޓ4+]gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/e9/000775 000000 000000 00000000000 13737324223 024067 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/e9/3bd39f016ef671a0c6be4945ed8efeee7de78d000664 000000 000000 00000000777 13737324223 031565 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU0`040031QpIuJLO+Ma)uykQuk @%$Q7<_/NMZs Z/Em RVsx|i}Um_j6=?/%!cВyrO֥z/Z摟YrçMs)(_a֪#?7U$$3'. ڻ5Wf4TmE xO28rVʭJrP|+uR3Kja?}oWTePfJJNj^Q Cՙ0]mohp[K*/)5(l%7RY6$gD3AߏCY`vF2=H0w?ćmPӂs3SsSSrSS233En.nҽY$a{1"P=n%E|sˈuCWU[6(=#51v͖l>6*fDVTg&%4 Vvgollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/ec/000775 000000 000000 00000000000 13737324223 024141 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/ec/da3205bee14520aab5a7bb307392064b938e83000664 000000 000000 00000000046 13737324223 031110 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR02b/JQOS(HUK/V( gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/f4/000775 000000 000000 00000000000 13737324223 024063 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/f4/84ebb1f40f8eb20d1bcd8d1d71934d2b8ae961000664 000000 000000 00000000441 13737324223 031351 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU062a040031QpIuJLO+Ma)uykQukj]Ko1-q+ZBXjxF9UV̪=Ęe({ĢpI3ĺYy1Ia=hn4&Hhl Gچ].3+tЖVN Ѡ jh^ c貜l.+ݺJכ}t`gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/info/000775 000000 000000 00000000000 13737324223 024505 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/info/packs000664 000000 000000 00000000066 13737324223 025533 0ustar00rootroot000000 000000 P pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/objects/pack/000775 000000 000000 00000000000 13737324223 024470 5ustar00rootroot000000 000000 test/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.idx000664 000000 000000 00000004074 13737324223 034004 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1tOc !!!!""########$%%%%%gmm5o?跍RXu]rh )4mL/;?hD{;كsMY(t*Y0f <ϡq[JbtJ:n20JKQhЛ짹"9 .>;E {}TAV:Iqj1xo縏 JDufkꭗG&''r_,jӃEaP/Z~H7% ,̪Rށkz6T.Ѧvl rS=YW|#cMp͉1yU;q׵[&pqk^gk~AS7ٮ, KJrJ}<<2E 0sKwK M2sG(_ o73m$^َf"o>/Sx-SD +A) ٔe-z[9-ԭx gT'*9cVY  pCڪ2Qm?:Dŏ;i8> a.0xck@3'?%Gfnr/ 7V<ն2[!O\5I\ 23b14l4'355Q4G,4~4A T22 *2 4l4 32-15cgvj@/GVh^uo2pfntest/examples/lotr.git/objects/pack/pack-dcbeaf3f6ff6c5eb08ea2b0a2d83626e8763546b.pack000664 000000 000000 00000032612 13737324223 034135 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1PACK%xQ 0 "PlK:Owۥ8x=ur&Ii9*# gB2rSɽR`%.C|ֱWtcwp.omwIi;5}h˺/ڎ8P;޻L lGx; 1> 3 x : Zy3>XVddX#֘mk*gO0L3ac)tiJyWp/7;8N.YE ;4hZ}osj`E}Gx 1{V&I@< H6P:r%[W2]FW|*"S 񉃷 BmALQIZ;YdbLm>8kg!bIHxI 1@}NQh!l0 +N$McF xQ 0 "dlx. ] WnMeZ$9r2 8Q(o];܌wmxmlpv׮/UMHLb־>jo>q:s x340031QpIuJLO+Ma)uykQuk !j]Ko1-q+ZBXj~ɟHp]G19@{IX}ǑpRY>BZUc>$Cӄ^|BqybixV /=սu#+?SN;P 3b{<϶dVrG8ёy߆=zCfcf5].Q0 ֛oy٫Nb&l,!??Ru hs鏿xs,*.KMI02su3܊S<x 0[AhU6f1BbozppoYhF:->Z1SBd 4i0 IѲH*.񺟌E5kjl{k~'x340031QpLO N,-MaFs@9O^?62U/ Y Dz6je_aURWRQuONS$G^u\o*ƷxVMo@W Yi= (U$jG?vR#Xgfyo,;f+z/Aդ$Pje(>䘆@Uu}}rCÉ߮VUCSKlӱoVCs4@xUT臐AnIif萎iqhR))i?ߺrk^뜵>^++Par0ABoVZc]]V|~L kmM(y^.;YPʅh@Wb#1:$߫Q/gESnwR|T AB@F\F~TA3'B7>QUŻ0;bДb)2M' Xp.l>نl?;֨croA{8A}/ ,UD(Vt}9:% abDZ%T@|VS>Wk ZB$܅%Yڈʆl/:x^.rUUnXeLT W\OgducԳeH:?%P c%O*FIT! |.%*&-'>gWs}uG-]]  p򼗒 B K[Fqy`biu]*R/^ZꗳHLU\R!4qx6;.iQD p~=V (QBOD7QYb>-14%7Ɋc{+ש`Gdqlw4ǔVo}wnSu#a<K`[1I0&=})է2< @21SM& #yV~>ߍ#5,ֆ,mFa_% fQ\ߵ_d/d+,D-ƻ a5wki.0| m0S]jqfi)s coXR*L3Lj,i0}qY}i?~THp 38({ Ol'mAkXn'c ʘ^Q\;Ͳ?5gw#*Jf^j/g7#W?r$BlYN)>FI9(Iհsl*p413jf~;o2\~WַPjˌtIPY)>8G;,zTٜob»$ e|!{6(fǾΰT}5_2aahLc-JO1jA'r8%VKe8:@uws4[$1LhOPNI~ VA HYp׷]4ЫҎbOunbF3VU?)ӢtKT` q*~ 83Xl42m; uI7ş37) g6`5BxsRR@u}lJ&pcDoP+> i+.eThNƿwB<ъjԫq<}k+U&ґ\3'j-'?b/Zd^Xy||<]x=>"/@9nϧzc Q2dl%CbcfcZV]ŁSɴzu0ghӊɬb dcr.t;^-IoI7 vIpwXpyJCFkvw&` JKwڎT * ȋmNX~_<]'׎07\^DД;6KGImy$eLZ;gy#|i1w{|F'ߦ[~'dI#'O'8V[zQΥGkpҩдFB77AuvBMAsԺ5׭J.LOv390yRyמ=RQCU{:H9MDy"Tgg&|rrY*Z(\=7-?x<6O0v!4N(]b+,k >ĦƂهO%l)jDN3 %3]>5Nf5CVHQa’&gN ⰉxQڒiWTJ?8Q~wBt`0s92\z& žRRe]W#D?8 ؇G3Y#6QK @ Ψ5_;:dr3[V5#F^]#G2 O;61$Bx A ҉ye.q2YCVnvzc8n$NL1~ xkB`ȿ?Mh KI,+CKaR}!ѡs!RˤNaϦ$䔌d MQEc{1AMC7atqP5Rc,(@jY3/ѯлJg@¼*:to&cI[.ķ4k0}:R#X{Ot+E1)M"G cIaV$SΞ'qQß֋$Ř`/C5kcB jU!~ƴ u-3yeV)gFU-}BLAVf{Y֪24}%N΀I{#t&|SE#_b+rV3>c ڱnO  t)^zW>cxCEjؽV۹?)$Phvhayz\id&Y 3x܍Qhی[؍.!igJv7 v]3 3$#|]"Vg]՗˻0北\T ǵ SUJg $~hٙ7Up¤Ϫx=_x| ⡷C-Rb^}gdk}Е֓U=XW}AQO _6/Rpq\PE:`8}p&| ؖxn4.'֨$|ۇ0LkD=YBិ WG׬䅀Ki%/wP[MK9,^%q`Dhr8ȺqF9ID8"SÑuʣU:<1SU)QI7]Ŕ}'i'כJɻKˋx Ȝf%o<əcpȿS=.+j J?aHg^G6ap^5y627q"D^u s *)c6xF}zV9ԽRЉI dP.9Z~kP- >=8=OBBxr?OԮLRv)z$WWehnJ-ے+`>mK8)ZAP۾; ?y;$jI:*a >ʗ_kRߨasٛ?ZJ'\bL w+j 'F 79/x~@uO8ůyTtp(d 3U o{YͶƦd^γ,+ ^(?a?PS,&Ru!~죸8[*à2k939\_4!^Eun?xɒum&~~̻R`4ٱx?u|/b}P &y4F }^_W+S BOu<e"V?(bw[H)$G(_޲0wS& wJWiIƸ'wdoeZ\ ZtxD$~TIܴeHփ8m/>=$m{S(yb]g4 |eXUj9^R oZu^Y@#!'Kzv=dO}z:Ճ,iF W̮Un݄.LLu \I/AJCI\ޚ;Wgt{#ց/~) KFr$fWζ$:p /8 ;7[RE?irqߑ'-PCy\!3cݴJ]IuۭMg 8 s=Ƴw< ZT{EUoN2+c[bFR0]X8k]C"'jTY%'M`;eSj%O2-Fe.C-vw6B)Amw3Usz{٩M߅"O?$c`Kc9>Ȕ݄k4lH}dMS6ls&t7}<띺hil,hmLHsՕ $>:)lށ5&'혌t8Ӟ*\/g|za#oƨ㵛ВV8ޮ1QRX#`BrsSVϾDH"tW|m.qrac&Vp5H'/n4;"3}M;$Ro6ZٙlRqTc 86"Q o !VlǴJ9gK{P*<%dkW&Na(oK\}*\ [GW{֙:n6RpK73{,D{TBS7uދzb^c$~N;d~DrVOJÛJ@Zx-וD?ћ̜li98ٕO?T'mnP׳K WP@|՞!AU~K0XF2cƿ\âxȌ\Sl9"KI*O5.mn1Gwڸ^͔@r XAluK T[#vV]4څ;c'wvFciN'#w jcJ%qxP;w +$+Et2(04g:`l*+o+dmx"Vbs򱶐nSM@P^})02om-j}9*֟EejŜ"RZ6:DNO )`=C6ӹRyѤ$Vь#F܇bA`RSxBK*Vcu,+cǶaf/0rI~=ʎv}NF2$C2& w*} j7h hu%"C-UVLCONA;YpFJ4i_1)jod,OHHkŞӧV[M c|w_3)0ǽ(#%pI\ݡrN]A)D SWXZɬd3]q5#EIpu]XVZ6bXh>,g͑qS|a1ytQoi-SD^|c[ $ E}3KYqU{EY/ϫ]#e}2~vCo~ޫ$/Czz)XV77dWA5qwlv HO(l0M|el/0]!}`g_{}fs  4i\:=uը=Hu@OZlWlg#B'ԻˊU}o$fcRko[:;";&k AAeUGh2ݕbU rhp7h] U&G'RؐnZ6 [~E?,afȆ$֑ }[S1" Db&) c[n‹km#X8C]vi_PFcSOOQ!bZrIcR2Ynlp_j=DFNi5|j(K씙9`~^A+EǸ6&SLAfa!X6:3Q\V&, [:ol>"}N<Cd_F#&3 -h-cD _x$#ܟ0c3# cڕ7w&ZrBUC yeXXyy;j.tk%ޯ(nՈ59L%Ywi$ ݳ/P?V9xVU/,IU(NM.S"׼b.w ڶx/JQOS(HUK/V(XvVxϸqBc`tX&{,8S j hx340031QpLO N,-Mal(4!=5ML*Hg(tV>Ȣ۬/+ax;.RCY2U?m#O̒lOXxyU;q׵[&gx340031QpLO N,-Ma{M+Ҁ-m ͧ w62U/ Y Dz6je_aURWRQuONS$G^u\j(xSVpLUOSN,-&xϸqB+7}#?Q"ęj g;x+`<1L $=xϸqB/su+T׆I9 l3* ?xe%G~RRfDh/=  L۸q-+ hi]x8qB wx]0JKQhЛǑq&~9x340031QpLO N,-Ma{M+Ҁ-m ͧ w8PhvxX6!`bVhx4xb< vj@/gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/packed-refs000664 000000 000000 00000000136 13737324223 024230 0ustar00rootroot000000 000000 # pack-refs with: peeled 60f12f4254f58801b9ee7db7bca5fa8aeefaa56b refs/remotes/origin/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/refs/000775 000000 000000 00000000000 13737324223 023060 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/refs/heads/000775 000000 000000 00000000000 13737324223 024144 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/refs/heads/master000664 000000 000000 00000000051 13737324223 025356 0ustar00rootroot000000 000000 a3e857e03ecc69a99f1dd72dc3f7e0c47602a05a gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/refs/remotes/000775 000000 000000 00000000000 13737324223 024536 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/refs/remotes/origin/000775 000000 000000 00000000000 13737324223 026025 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/lotr.git/refs/remotes/origin/HEAD000664 000000 000000 00000000040 13737324223 026443 0ustar00rootroot000000 000000 ref: refs/remotes/origin/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/000775 000000 000000 00000000000 13737324223 023712 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/COMMIT_EDITMSG000664 000000 000000 00000000017 13737324223 025777 0ustar00rootroot000000 000000 initial commit gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/HEAD000664 000000 000000 00000000027 13737324223 024335 0ustar00rootroot000000 000000 ref: refs/heads/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/config000664 000000 000000 00000000157 13737324223 025105 0ustar00rootroot000000 000000 [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/description000664 000000 000000 00000000111 13737324223 026151 0ustar00rootroot000000 000000 Unnamed repository; edit this file 'description' to name the repository. gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/index000664 000000 000000 00000000270 13737324223 024743 0ustar00rootroot000000 000000 DIRCM4M4WY}kI $-bar.mdM4M4%|d,T?->V> docs/foo.md[Xؘy1Pgollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/info/000775 000000 000000 00000000000 13737324223 024645 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/info/exclude000664 000000 000000 00000000360 13737324223 026220 0ustar00rootroot000000 000000 # git ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/logs/000775 000000 000000 00000000000 13737324223 024656 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/logs/HEAD000664 000000 000000 00000000242 13737324223 025300 0ustar00rootroot000000 000000 0000000000000000000000000000000000000000 22b404803c966dd92865614d86ff22ca12e50c1e rick 1295287591 -0800 commit (initial): initial commit gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/logs/refs/000775 000000 000000 00000000000 13737324223 025615 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/logs/refs/heads/000775 000000 000000 00000000000 13737324223 026701 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/logs/refs/heads/master000664 000000 000000 00000000242 13737324223 030115 0ustar00rootroot000000 000000 0000000000000000000000000000000000000000 22b404803c966dd92865614d86ff22ca12e50c1e rick 1295287591 -0800 commit (initial): initial commit gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/objects/000775 000000 000000 00000000000 13737324223 025343 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/objects/0c/000775 000000 000000 00000000000 13737324223 025645 5ustar00rootroot000000 000000 test/examples/page_file_dir.git/objects/0c/7d27db1f575263efdcab3dc650f4502a2dbcbf000664 000000 000000 00000000063 13737324223 033263 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU06a040031QHMaP9qAȇS gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/objects/22/000775 000000 000000 00000000000 13737324223 025566 5ustar00rootroot000000 000000 test/examples/page_file_dir.git/objects/22/b404803c966dd92865614d86ff22ca12e50c1e000664 000000 000000 00000000175 13737324223 032506 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xQ !@s5*jc;*DoWFk,ޞdˋ%\H't5_RF)VdTz6&L./XLJ3ݟ-~)Mt&x:hzwN; J9gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/objects/25/000775 000000 000000 00000000000 13737324223 025571 5ustar00rootroot000000 000000 test/examples/page_file_dir.git/objects/25/7cc5642cb1a054f08cc83f2d943e56fd3ebe99000664 000000 000000 00000000023 13737324223 033013 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR0aHUBgollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/objects/57/000775 000000 000000 00000000000 13737324223 025576 5ustar00rootroot000000 000000 test/examples/page_file_dir.git/objects/57/16ca5987cbf97d6bb54920bea6adde242d87e6000664 000000 000000 00000000023 13737324223 033103 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR0aHJ,!3gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/objects/5b/000775 000000 000000 00000000000 13737324223 025651 5ustar00rootroot000000 000000 test/examples/page_file_dir.git/objects/5b/43e14e0a15fb6f08feab1773d1c0991e9f71e2000664 000000 000000 00000000121 13737324223 032775 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU03e040031QHJ,Ma;~gmVO}Smfb ) <ÃYm{,Kgollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/refs/000775 000000 000000 00000000000 13737324223 024651 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/refs/heads/000775 000000 000000 00000000000 13737324223 025735 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/page_file_dir.git/refs/heads/master000664 000000 000000 00000000051 13737324223 027147 0ustar00rootroot000000 000000 22b404803c966dd92865614d86ff22ca12e50c1e gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/000775 000000 000000 00000000000 13737324223 022450 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/COMMIT_EDITMSG000664 000000 000000 00000000014 13737324223 024532 0ustar00rootroot000000 000000 Add header. gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/HEAD000664 000000 000000 00000000027 13737324223 023073 0ustar00rootroot000000 000000 ref: refs/heads/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/config000664 000000 000000 00000000512 13737324223 023636 0ustar00rootroot000000 000000 [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true [receive] denyCurrentBranch = ignore [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = /Users/rick/p/gollum/test/examples/revert.git [branch "master"] remote = origin merge = refs/heads/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/description000664 000000 000000 00000000111 13737324223 024707 0ustar00rootroot000000 000000 Unnamed repository; edit this file 'description' to name the repository. gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/index000664 000000 000000 00000000640 13737324223 023502 0ustar00rootroot000000 000000 DIRCM{3M{3ep@ch;A.mdM{3M{3eq{E@W0(^1,B.mdM{NM{Neji wn2I3 _Footer.mdO-o2O-o2NjYݡz@ _Header.mdM{IM{IexYWmÜbF, _Sidebar.md:&H\B;gkUTgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/info/000775 000000 000000 00000000000 13737324223 023403 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/info/exclude000664 000000 000000 00000000360 13737324223 024756 0ustar00rootroot000000 000000 # git ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/logs/000775 000000 000000 00000000000 13737324223 023414 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/logs/HEAD000664 000000 000000 00000001206 13737324223 024037 0ustar00rootroot000000 000000 0000000000000000000000000000000000000000 7c45b5f16ff3bae2a0063191ef832701214d4df5 rick 1291942707 -0800 clone: from /Users/rick/p/gollum/test/examples/revert.git 7c45b5f16ff3bae2a0063191ef832701214d4df5 f403b791119f8232b7cb0ba455c624ac6435f433 rick 1291942743 -0800 commit: add footer and sidebar f403b791119f8232b7cb0ba455c624ac6435f433 ed6c9f63b98acf73c25b5ffbb38da557d3682023 bootstraponline 1336421777 -0600 commit: Add header. ed6c9f63b98acf73c25b5ffbb38da557d3682023 084a558a1fb3cded23129e2dfad3a17d07d73fd3 Daniel Kimsey 1354899095 -0500 push gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/logs/refs/000775 000000 000000 00000000000 13737324223 024353 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/logs/refs/heads/000775 000000 000000 00000000000 13737324223 025437 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/logs/refs/heads/master000664 000000 000000 00000001206 13737324223 026654 0ustar00rootroot000000 000000 0000000000000000000000000000000000000000 7c45b5f16ff3bae2a0063191ef832701214d4df5 rick 1291942707 -0800 clone: from /Users/rick/p/gollum/test/examples/revert.git 7c45b5f16ff3bae2a0063191ef832701214d4df5 f403b791119f8232b7cb0ba455c624ac6435f433 rick 1291942743 -0800 commit: add footer and sidebar f403b791119f8232b7cb0ba455c624ac6435f433 ed6c9f63b98acf73c25b5ffbb38da557d3682023 bootstraponline 1336421777 -0600 commit: Add header. ed6c9f63b98acf73c25b5ffbb38da557d3682023 084a558a1fb3cded23129e2dfad3a17d07d73fd3 Daniel Kimsey 1354899095 -0500 push gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/000775 000000 000000 00000000000 13737324223 024101 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/08/000775 000000 000000 00000000000 13737324223 024330 5ustar00rootroot000000 000000 test/examples/revert.git/objects/08/4a558a1fb3cded23129e2dfad3a17d07d73fd3000664 000000 000000 00000000271 13737324223 031670 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xMj0) 4cPJ ]dy' 6<7U0Pgà QzXlK'bRf#*dVJLFC >D6 D9Gxcaק݄u"*aۋԦv[?Poxȳn'Sgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/10/000775 000000 000000 00000000000 13737324223 024321 5ustar00rootroot000000 000000 test/examples/revert.git/objects/10/2685c42018f802557f05db171f44443e8dacab000664 000000 000000 00000000250 13737324223 031224 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU04d040031QpMapؐ%4ayFk՗?n;Ut7XQtf/Px"̟ _/diܼ#51nj0܎Uϫ`3SRm 3#𜤹/6]CGgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/20/000775 000000 000000 00000000000 13737324223 024322 5ustar00rootroot000000 000000 test/examples/revert.git/objects/20/2ced67cea93c7b6bd2928aa1daef8d1d55a20d000664 000000 000000 00000000222 13737324223 032023 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x 0Pg,Pw@U.׋ FB7p "ڥ81e!J`B$oME8zѐc_1j !`1dM4VV=>hЗ)#r4wj3dL.zY_oP}g@xgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/41/000775 000000 000000 00000000000 13737324223 024325 5ustar00rootroot000000 000000 test/examples/revert.git/objects/41/76394bfa11222363c66ce7e84b5f154095b6d9000664 000000 000000 00000000212 13737324223 031166 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU041d040031QpMapؐ%4ayFk՗?n;Ut7XQtf/Px"̟ _/diܼ*83%5)lKEd$}}: k^6gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/46/000775 000000 000000 00000000000 13737324223 024332 5ustar00rootroot000000 000000 test/examples/revert.git/objects/46/3cabd49fa7daa55d786ab504afbb8c019bafb8000664 000000 000000 00000000061 13737324223 032112 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU06b040031QMaW!@cNFљq:0 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/6a/000775 000000 000000 00000000000 13737324223 024407 5ustar00rootroot000000 000000 test/examples/revert.git/objects/6a/69f92020f5df77af6e8813ff1232493383b708000664 000000 000000 00000000021 13737324223 031201 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR0bHnbgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/8e/000775 000000 000000 00000000000 13737324223 024415 5ustar00rootroot000000 000000 test/examples/revert.git/objects/8e/83f898e5e16ae400db59dda1017acad540f3aa000664 000000 000000 00000000026 13737324223 031673 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR0gHMLI-"Gjgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/b4/000775 000000 000000 00000000000 13737324223 024406 5ustar00rootroot000000 000000 test/examples/revert.git/objects/b4/785957bc986dc39c629de9fac9df46972c00fc000664 000000 000000 00000000021 13737324223 031605 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR0b(ogollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/ed/000775 000000 000000 00000000000 13737324223 024471 5ustar00rootroot000000 000000 test/examples/revert.git/objects/ed/6c9f63b98acf73c25b5ffbb38da557d3682023000664 000000 000000 00000000234 13737324223 031641 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xK @]s .`3ç1z- ڭo//m[6DE4e2F0΅ $ XJ,9CWŒsƚr\8{?ci]{t>ZwѷU?vmk֓P=_WQR"\O ziNgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/f4/000775 000000 000000 00000000000 13737324223 024412 5ustar00rootroot000000 000000 test/examples/revert.git/objects/f4/03b791119f8232b7cb0ba455c624ac6435f433000664 000000 000000 00000000242 13737324223 031225 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xAn! {@*l ,RU+L]"J'yB3i(} 1Ĺ "JEn}C6j2wz,[\%68Lms-rڼuf/7ZZx]ϗ]g7 %LLfyFj6;oe'/H"gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/ff/000775 000000 000000 00000000000 13737324223 024474 5ustar00rootroot000000 000000 test/examples/revert.git/objects/ff/3854dfc50af42e85bc4d45584555cdf95be43d000664 000000 000000 00000000304 13737324223 031644 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU020g040031QpMapؐ%4ayFk՗?n;Ut7XQtf/&@f巖VdmeYqPn%E 2*(|_>Cqv*3>zp;BƪSW> LIMJ"2|όsut?FSgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/info/000775 000000 000000 00000000000 13737324223 025034 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/info/packs000664 000000 000000 00000000066 13737324223 026062 0ustar00rootroot000000 000000 P pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/objects/pack/000775 000000 000000 00000000000 13737324223 025017 5ustar00rootroot000000 000000 test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.idx000664 000000 000000 00000002600 13737324223 034076 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1tOc 0*Te*1Ia@ch;Hlj1T&zS)[ |Eo1'!MM!MmfJ B~ Plӱ1\vljL5`hsR8hq$RC[$1A1W\߶R)9ky|O7ݜJo8\3BQlfS(+Uw{E@W0(^1, ӟXAы̃N0u18|\GsǏ< oGXA"K~Oh F XlL\test/examples/revert.git/objects/pack/pack-a561f8437234f74d0bacb9e0eebe52d207f5770d.pack000664 000000 000000 00000001664 13737324223 034241 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1PACK xQ !wO GgW=:3]:B/o" L 8!bf#b35Y&;x|Α 3BccQէVw]xZַRpS}lyl>7&:Q]/dz>J@c xK =OactZb bۗEOs3DŽ3;E b # <!r%N{29O3ֽ^oCxmWy,v5Xs/&Ne ;(m~Cp x] !wO gQ!=@tVjwC^љՙBEi"QA2Xj Xt;v^`s )Tu>YϘ.{Oyu2/%1oYi yP^)࿣ߦ}? x] 0 P/Rck %ٖ;|Fʉ2^Q1AbW1؛2m}ݪWnRDOG#]TnR2x340031QpMapؐ%4ayFk՗?n5;Ut7XQtf/}?x t pU{?x t p5 x340031QpMapؐ%4ayFk՗?n5;g\xѐQQr;ghՆ48x t Ux340031QpMaźSH."!rECFFA٣UVޜ>x t pUZx340031QpMa!rECFFA٣UVBpŽ,A"K~Ohgollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/packed-refs000664 000000 000000 00000000136 13737324223 024557 0ustar00rootroot000000 000000 # pack-refs with: peeled 7c45b5f16ff3bae2a0063191ef832701214d4df5 refs/remotes/origin/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/refs/000775 000000 000000 00000000000 13737324223 023407 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/refs/heads/000775 000000 000000 00000000000 13737324223 024473 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/refs/heads/master000664 000000 000000 00000000051 13737324223 025705 0ustar00rootroot000000 000000 084a558a1fb3cded23129e2dfad3a17d07d73fd3 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/refs/remotes/000775 000000 000000 00000000000 13737324223 025065 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/refs/remotes/origin/000775 000000 000000 00000000000 13737324223 026354 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/revert.git/refs/remotes/origin/HEAD000664 000000 000000 00000000040 13737324223 026772 0ustar00rootroot000000 000000 ref: refs/remotes/origin/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/000775 000000 000000 00000000000 13737324223 022441 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/HEAD000664 000000 000000 00000000027 13737324223 023064 0ustar00rootroot000000 000000 ref: refs/heads/master gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/config000664 000000 000000 00000000125 13737324223 023627 0ustar00rootroot000000 000000 [core] repositoryformatversion = 0 filemode = true bare = true ignorecase = true gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/description000664 000000 000000 00000000111 13737324223 024700 0ustar00rootroot000000 000000 Unnamed repository; edit this file 'description' to name the repository. gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/info/000775 000000 000000 00000000000 13737324223 023374 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/info/exclude000664 000000 000000 00000000360 13737324223 024747 0ustar00rootroot000000 000000 # git-ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/000775 000000 000000 00000000000 13737324223 024072 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/10/000775 000000 000000 00000000000 13737324223 024312 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/10/fa2ddc4e3b4009d8a453aace10bd6148c1ad00000664 000000 000000 00000000125 13737324223 031620 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU07a040031Q(,+(a?xڵ~G~;ș%-LajJ2SRrSڝ_/f˴{VZgollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/52/000775 000000 000000 00000000000 13737324223 024320 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/52/4b82874327ea7cbf730389964ba7cb3de966de000664 000000 000000 00000000070 13737324223 031421 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x-blob 37私は馳夫と呼ばれています K? gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/58/000775 000000 000000 00000000000 13737324223 024326 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/58/3fc201cb457fb3f1480f3e1e5999b119633835000664 000000 000000 00000000051 13737324223 031164 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xKOR02aki:;rjYӱ#M^5iZti; gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/87/000775 000000 000000 00000000000 13737324223 024330 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/87/bc1dd46ab3d3874d4e898d45dd512cc20a7cc8000664 000000 000000 00000000260 13737324223 031622 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xAj0E)ȒPJC4i${ YA-ދm`jJs{4@;iGO[SJ7Fr{̌g3=cҿ݉91wZFRv-8]ϗሸRش﯏ÄT[Ngollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/89/000775 000000 000000 00000000000 13737324223 024332 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/89/64ed1b4e21aa90e831763bbce9034bfda81b70000664 000000 000000 00000000251 13737324223 031524 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1xj1]+굂R`uXS?Aʙbe&˧B3H6R9G-Zm*Λz $R`NU\/F~6vn8gisBh.]}8 ,ly̏ޥ+vC.j1Jigollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/9f/000775 000000 000000 00000000000 13737324223 024410 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/9f/f6dd0660da5fba2d3374adb2b84fa653bb538b000664 000000 000000 00000000067 13737324223 031752 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU0`040031Q(.)LI-ManjwVUsӶ/Xxgollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/ac/000775 000000 000000 00000000000 13737324223 024455 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/ac/e97abf2b177815a1972d7db22f229f58c83309000664 000000 000000 00000000315 13737324223 031407 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x;n0S(bݕH" )3ʾftoV+frb$Z-kH#+=Jn4qlI;!2 R;r3VZ}n;; 7^Y57[ݙቛTrÔ%}"R9]$Sᔷr'^>gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/objects/b1/000775 000000 000000 00000000000 13737324223 024374 5ustar00rootroot000000 000000 test/examples/yubiwa.git/objects/b1/f443863a4816628807fbf86141ebef055dda34000664 000000 000000 00000000122 13737324223 031315 0ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1x+)JMU07f040031Q(,Ma?xڵ~G~;ș%-LaJJ2SR@ڝ_/f˴{.&Jgollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/refs/000775 000000 000000 00000000000 13737324223 023400 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/refs/heads/000775 000000 000000 00000000000 13737324223 024464 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/examples/yubiwa.git/refs/heads/master000664 000000 000000 00000000051 13737324223 025676 0ustar00rootroot000000 000000 8964ed1b4e21aa90e831763bbce9034bfda81b70 gollum-lib-v4.2.7.10.gitlab.1/test/file_view/000775 000000 000000 00000000000 13737324223 020512 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/file_view/1_file.txt000664 000000 000000 00000000427 13737324223 022415 0ustar00rootroot000000 000000

    1. 0
    gollum-lib-v4.2.7.10.gitlab.1/test/file_view/1_file_1_folder.txt000664 000000 000000 00000000636 13737324223 024172 0ustar00rootroot000000 000000
      1. 0
    gollum-lib-v4.2.7.10.gitlab.1/test/file_view/1_folder.txt000664 000000 000000 00000000630 13737324223 022745 0ustar00rootroot000000 000000
      1. folder0
    gollum-lib-v4.2.7.10.gitlab.1/test/file_view/2_files_2_folders.txt000664 000000 000000 00000001444 13737324223 024540 0ustar00rootroot000000 000000
      1. 0
      1. 1
    gollum-lib-v4.2.7.10.gitlab.1/test/file_view/2_files_2_folders_1_root.txt000664 000000 000000 00000002057 13737324223 026024 0ustar00rootroot000000 000000
    1. root
      1. 0
      1. 1
    gollum-lib-v4.2.7.10.gitlab.1/test/file_view/nested_folders.txt000664 000000 000000 00000003170 13737324223 024254 0ustar00rootroot000000 000000
          1. 0
          1. 1
      1. 2
    gollum-lib-v4.2.7.10.gitlab.1/test/filter/000775 000000 000000 00000000000 13737324223 020026 5ustar00rootroot000000 000000 gollum-lib-v4.2.7.10.gitlab.1/test/filter/test_emoji.rb000664 000000 000000 00000001266 13737324223 022522 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ path = File.join(File.dirname(__FILE__), "..", "helper") require File.expand_path(path) context "Gollum::Filter::Emoji" do setup do @filter = Gollum::Filter::Emoji.new(Gollum::Markup.new(nil)) end def filter(content) @filter.process(@filter.extract(content)) end test "processing emoji tags" do assert_equal filter(':heart:'), %q(heart) assert_equal filter(':point_up_tone3:'), %q(point_up_tone3) assert_equal filter(':oggy_was_here:'), ':oggy_was_here:' assert_equal filter('rake db:schema:dump'), 'rake db:schema:dump' end end gollum-lib-v4.2.7.10.gitlab.1/test/filter/test_tags.rb000664 000000 000000 00000002065 13737324223 022353 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ path = File.join(File.dirname(__FILE__), "..", "helper") require File.expand_path(path) context "Gollum::Filter::Tags" do setup do @path = cloned_testpath('examples/page_file_dir') @page_file_dir = 'docs' @wiki = Gollum::Wiki.new(@path, :page_file_dir => @page_file_dir) end teardown do FileUtils.rm_rf(@path) end test "tag processing time is not exponential in number of tags" do TAGCOUNT = 500 page_with_many_tags = (0..TAGCOUNT).map { |i| "[[#{i}]]"}.join page_name = "page with many tags" @wiki.write_page(page_name, :markdown, page_with_many_tags, commit_details) page = @wiki.page(page_name) markup = Gollum::Markup.new(page) filter = Gollum::Filter::Tags.new(markup) data_with_placeholders = filter.extract(page.raw_data) max_seconds = 2 assert_max_seconds(max_seconds, "tag processing for #{TAGCOUNT} tags") do data_processed = filter.process(data_with_placeholders) assert_equal page_with_many_tags, data_processed end end end gollum-lib-v4.2.7.10.gitlab.1/test/helper.rb000664 000000 000000 00000004452 13737324223 020352 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ # stdlib require 'test/unit' require 'fileutils' # external require 'rubygems' require 'shoulda' require 'mocha/setup' require 'minitest/reporters' require 'twitter_cldr' require 'tempfile' # markup begin require 'asciidoctor' rescue Exception end # internal require File.expand_path('../assertions', __FILE__) # Fix locale warnings require 'i18n' I18n.enforce_available_locales = false MiniTest::Reporters.use! dir = File.dirname(File.expand_path(__FILE__)) $LOAD_PATH.unshift(File.join(dir, '..', 'lib')) $LOAD_PATH.unshift(dir) module Gollum end Gollum::GIT_ADAPTER = ENV['GIT_ADAPTER'] if ENV['GIT_ADAPTER'] ENV['RACK_ENV'] = 'test' require 'gollum-lib' # Make sure we're in the test dir, the tests expect that to be the current # directory. TEST_DIR = File.join(File.dirname(__FILE__), *%w(.)) def testpath(path) File.join(TEST_DIR, path) end def cloned_testpath(path, bare = false) repo = File.expand_path(testpath(path)) path = File.dirname(repo) name = File.basename(Tempfile.new(self.class.name, path).path) cloned = File.join(path, name) bare = bare ? "--bare" : "" FileUtils.rm_rf(cloned) Dir.chdir(path) do %x{git clone #{bare} #{File.basename(repo)} #{name} 2>/dev/null} end cloned end def commit_details { :message => "Did something at #{Time.now}", :name => "Tom Preston-Werner", :email => "tom@github.com" } end def title_with_special_characters ' !@#$%^&*()[]{}=_+\'"\\|<>? ' end # test/spec/mini 3 # http://gist.github.com/25455 # chris@ozmm.org # file:lib/test/spec/mini.rb def context(*args, &block) return super unless (name = args.first) && block require 'test/unit' klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do def self.test(name, *tags, &block) return if tags.include?(:skip_grit) && ENV['GOLLUM_ADAPTER'] == 'grit' define_method("test_#{name.gsub(/\W/, '_')}", &block) if block end def self.xtest(*args) end def self.setup(&block) define_method(:setup, &block) end def self.teardown(&block) define_method(:teardown, &block) end end ( class << klass; self end).send(:define_method, :name) { name.gsub(/\W/, '_') } $contexts << klass klass.class_eval(&block) end $contexts = [] gollum-lib-v4.2.7.10.gitlab.1/test/test_committer.rb000664 000000 000000 00000010361 13737324223 022131 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), "helper")) context "Wiki" do setup do @wiki = Gollum::Wiki.new(testpath("examples/lotr.git")) end test "normalizes commit hash" do commit = { :message => 'abc' } name = @wiki.default_committer_name email = @wiki.default_committer_email committer = Gollum::Committer.new(@wiki, commit) assert_equal name, committer.actor.name assert_equal email, committer.actor.email commit[:name] = '' commit[:email] = '' committer = Gollum::Committer.new(@wiki, commit) assert_equal '', committer.actor.name assert_equal '', committer.actor.email commit[:name] = nil commit[:email] = nil committer = Gollum::Committer.new(@wiki, commit) assert_equal name, committer.actor.name assert_equal email, committer.actor.email commit[:name] = 'bob' commit[:email] = nil committer = Gollum::Committer.new(@wiki, commit) assert_equal 'bob', committer.actor.name assert_equal email, committer.actor.email commit[:name] = nil commit[:email] = 'foo@bar.com' committer = Gollum::Committer.new(@wiki, commit) assert_equal name, committer.actor.name assert_equal 'foo@bar.com', committer.actor.email end test "yield after_commit callback" do @path = cloned_testpath('examples/lotr.git') yielded = nil begin wiki = Gollum::Wiki.new(@path) committer = Gollum::Committer.new(wiki) committer.after_commit do |index, sha1| yielded = sha1 assert_equal committer, index end res = wiki.write_page("Gollum", :markdown, "# Gollum", :committer => committer) assert_equal committer, res sha1 = committer.commit assert_equal sha1, yielded ensure FileUtils.rm_rf(@path) end end test "post_commit hooks called after committing" do @path = cloned_testpath('examples/lotr.git') yielded = nil begin wiki = Gollum::Wiki.new(@path) committer = Gollum::Committer.new(wiki) Gollum::Hook.register(:post_commit, :hook) do |index, sha1| yielded = sha1 assert_equal committer, index end res = wiki.write_page("Gollum", :markdown, "# Gollum", :committer => committer) assert_equal committer, res sha1 = committer.commit assert_equal sha1, yielded ensure Gollum::Hook.unregister(:post_commit, :hook) FileUtils.rm_rf(@path) end end test "parents with default master ref" do ref = 'a3e857e03ecc69a99f1dd72dc3f7e0c47602a05a' committer = Gollum::Committer.new(@wiki) assert_equal ref, committer.parents.first.sha end test "parents with custom ref" do ref = '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b' @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), :ref => ref) committer = Gollum::Committer.new(@wiki) assert_equal ref, committer.parents.first.sha end test "update working directory with page file directory and subdirectory for a new page" do page_file_dir = "foo" dir = "/bar" name = "baz" format = :markdown @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), { :page_file_dir => page_file_dir }) @wiki.repo.stubs(:bare).returns(false) Gollum::Committer.any_instance.stubs(:add_to_index).returns(true) Gollum::Git::Index.any_instance.stubs(:commit).returns(true) @wiki.repo.git.expects(:checkout).with("#{page_file_dir}#{dir}/#{name}.md", "HEAD") @wiki.write_page(name, format, "foo bar baz", commit_details, dir) end test "update working directory with page file directory and subdirectory for an existing page" do page_file_dir = "Rivendell" name = "Elrond" format = :markdown @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), { :page_file_dir => page_file_dir }) @wiki.repo.stubs(:bare).returns(false) Gollum::Git::Index.any_instance.stubs(:commit).returns(true) page = @wiki.page(name) @wiki.repo.git.expects(:checkout).at_least(1).with("#{page_file_dir}/#{name}.md", "HEAD") @wiki.update_page(page, page.name, format, "# Elrond", commit_details()) end end gollum-lib-v4.2.7.10.gitlab.1/test/test_file.rb000664 000000 000000 00000003336 13737324223 021051 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ path = File.join(File.dirname(__FILE__), "helper") require File.expand_path(path) context "File" do setup do @wiki = Gollum::Wiki.new(testpath("examples/lotr.git")) end test "new file" do file = Gollum::File.new(@wiki) assert_nil file.raw_data end test "existing file" do commit = @wiki.repo.commits.first file = @wiki.file("Mordor/todo.txt") assert_equal "[ ] Write section on Ents\n", file.raw_data assert_equal 'todo.txt', file.name assert_equal commit.id, file.version.id assert_equal commit.author.name, file.version.author.name end test "accessing tree" do assert_nil @wiki.file("Mordor") end end context "File with checkout" do setup do @path = cloned_testpath("examples/lotr.git") @wiki = Gollum::Wiki.new(@path) end teardown do FileUtils.rm_rf(@path) end test "symbolic link" do file = @wiki.file("Data-Two.csv") assert_match(/^FirstName,LastName\n/, file.raw_data) end test "on disk file detection" do file = @wiki.file("Bilbo-Baggins.md", 'master', true) assert file.on_disk? end test "on disk file access" do file = @wiki.file("Bilbo-Baggins.md", 'master', true) path = file.on_disk_path assert ::File.exist?(path) assert_match(/^# Bilbo Baggins\n\nBilbo Baggins/, IO.read(path)) end test "symbolic link, with on-disk" do file = @wiki.file("Data-Two.csv", 'master', true) assert file.on_disk? assert_match(/Data\.csv$/, file.on_disk_path) assert_match(/^FirstName,LastName\n/, IO.read(file.on_disk_path)) end test "on disk file, with symlink, raw_data" do file = @wiki.file("Data-Two.csv") assert_match(/^FirstName,LastName\n/, file.raw_data) end end gollum-lib-v4.2.7.10.gitlab.1/test/test_file_view.rb000664 000000 000000 00000004411 13737324223 022076 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), 'helper')) require File.expand_path '../../lib/gollum-lib/file_view', __FILE__ class FakePage def initialize(filepath) @filepath = filepath end # From page.rb def filename_stripped ::File.basename(@filepath, ::File.extname(@filepath)) end def filename ::File.basename(@filepath) end def path return @filepath end # From page.rb def name self.class.canonicalize_filename @filepath end # From page.rb def self.strip_filename filename ::File.basename(filename, ::File.extname(filename)) end # From page.rb def self.canonicalize_filename filename strip_filename(filename).gsub('-', ' ') end end class FakePages def initialize(filepath_array) @array = filepath_array.map { |filepath| FakePage.new filepath } end def size @array.size end def [] index @array[index] end end def view(pages) Gollum::FileView.new(pages).render_files end def test_path @test_path ||= File.expand_path('../file_view/', __FILE__) + '/' end def read(file) File.read test_path + file + '.txt' end # For creating expected files. # write name, actual def write(file, content) File.open(test_path + file + '.txt', 'w') do |f| f.write content end end def check(name, pages_array) pages = FakePages.new pages_array expected = read name actual = view pages # Uncomment when updating tests # write name, actual assert_html_equal expected, actual end # Test Notes # root files must be before any folders. # Home.md => file at root folder # docs/sanitization.md => file within folder context 'file_view' do test 'one file' do check '1_file', ['0.md'] end test 'one folder' do check '1_folder', ['folder0/'] end test 'one file with one folder' do check '1_file_1_folder', ['folder0/0.md'] end test 'two files with two folders' do check '2_files_2_folders', ['folder0/0.md', 'folder1/1.md'] end test 'two files with two folders and one root file' do check '2_files_2_folders_1_root', ['root.md', 'folder0/0.md', 'folder1/1.md'] end test 'nested folders' do check 'nested_folders', ['folder0/folder1/folder2/0.md', 'folder0/folder1/folder3/1.md', 'folder4/2.md'] end end # context gollum-lib-v4.2.7.10.gitlab.1/test/test_git_access.rb000664 000000 000000 00000005023 13737324223 022231 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), "helper")) context "GitAccess" do setup do @access = Gollum::GitAccess.new(testpath("examples/lotr.git")) end test "#commit fills commit_map cache" do assert @access.commit_map.empty? actual = @access.repo.commits.first expected = @access.commit(actual.id) assert_equal actual.message, expected.message assert_equal actual.message, @access.commit_map[actual.id].message end test "#tree_map_for caches ref and tree" do assert @access.ref_map.empty? assert @access.tree_map.empty? @access.tree 'master' assert_equal({ "master" => "a3e857e03ecc69a99f1dd72dc3f7e0c47602a05a" }, @access.ref_map) @access.tree '1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3' map = @access.tree_map['1db89ebba7e2c14d93b94ff98cfa3708a4f0d4e3'] assert_equal 'Bilbo-Baggins.md', map[0].path assert_equal '', map[0].dir assert_equal map[0].path, map[0].name assert_equal 'Mordor/Eye-Of-Sauron.md', map[3].path assert_equal '/Mordor', map[3].dir assert_equal 'Eye-Of-Sauron.md', map[3].name end test "#tree_map_for only caches tree for commit" do assert @access.tree_map.empty? @access.tree '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b' assert @access.ref_map.empty? entry = @access.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'][0] assert_equal 'Bilbo-Baggins.md', entry.path end test "cannot access commit from invalid ref" do assert_nil @access.commit('foo') end test "cannot access sha from invalid ref" do assert_nil @access.ref_to_sha('foo') end test "cannot access tree from invalid ref" do assert_equal [], @access.tree('foo') end test "sets #mode for blob entries" do @access.tree '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b' file = @access.tree_map['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'][0] assert_equal 0100644, file.mode @access.tree '874f597a5659b4c3b153674ea04e406ff393975e' symlink = @access.tree_map['874f597a5659b4c3b153674ea04e406ff393975e'].find { |entry| entry.name == 'Data-Two.csv' } assert_not_nil symlink assert_equal 0120000, symlink.mode end test "#files_sorted_by_created_at", :skip_grit do files = [ "Mordor/_Footer.md", "My-Precious.md", "Mordor/eye.jpg", "Home.textile", "Mordor/todo.txt", "Mordor/Eye-Of-Sauron.md", "Data.csv", "Bilbo-Baggins.md", "_Footer.md" ] sha = '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b' assert_equal files, @access.files_sorted_by_created_at(sha) end end gollum-lib-v4.2.7.10.gitlab.1/test/test_hook.rb000664 000000 000000 00000006135 13737324223 021072 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ path = File.join(File.dirname(__FILE__), 'helper') require File.expand_path(path) context 'Hook' do test 'registering a hook' do begin hook = Proc.new {} Gollum::Hook.register(:test, :hook, &hook) assert_same hook, Gollum::Hook.get(:test, :hook) ensure Gollum::Hook.unregister(:test, :hook) end end test 'reregistering a hook' do begin hook1 = Proc.new {} hook2 = Proc.new {} Gollum::Hook.register(:test, :hook, &hook1) Gollum::Hook.register(:test, :hook, &hook2) assert_same hook2, Gollum::Hook.get(:test, :hook) ensure Gollum::Hook.unregister(:test, :hook) end end test 'unregistering a hook' do begin hook = Proc.new {} Gollum::Hook.register(:test, :hook, &hook) Gollum::Hook.unregister(:test, :hook) assert_nil Gollum::Hook.get(:test, :hook) ensure Gollum::Hook.unregister(:test, :hook) end end test 'unregistering a non-existent hook' do Gollum::Hook.unregister(:test, :hook) assert_nil Gollum::Hook.get(:test, :hook) end test 'executing hooks' do begin received_args1 = received_args2 = nil hook1 = Proc.new { |*args| received_args1 = args } hook2 = Proc.new { |*args| received_args2 = args } Gollum::Hook.register(:test, :hook1, &hook1) Gollum::Hook.register(:test, :hook2, &hook2) args = [1, '2', :three] Gollum::Hook.execute(:test, *args) assert_equal args, received_args1 assert_equal args, received_args2 ensure Gollum::Hook.unregister(:test, :hook1) Gollum::Hook.unregister(:test, :hook2) end end test 'executing non-existent hooks' do begin received_args = nil hook = Proc.new { |*args| received_args = args } Gollum::Hook.register(:test, :hook, &hook) args = [1, '2', :three] Gollum::Hook.execute(:test_non_existent, *args) assert_nil received_args ensure Gollum::Hook.unregister(:test, :hook) end end end context 'Pushing and pulling' do setup do @orig_path = cloned_testpath("examples/lotr.git", true) @origin = Gollum::Wiki.new(@orig_path, :repo_is_bare => true) @clone_path = cloned_testpath("examples/#{File.basename(@orig_path)}") @clone = Gollum::Wiki.new(@clone_path) end test 'push and pull' do assert_equal nil, @origin.page("Gollum") @clone.write_page("Gollum", :markdown, "# Gollum", {:message => "Wrote test page"}) @clone.repo.git.push("origin", "master") assert_equal "Wrote test page", @origin.repo.commits.first.message @origin.write_page("Gollum2", :markdown, "New content2", {:message => "Wrote second test page"}) @clone.repo.git.pull("origin", "master") # Rugged does not support high-level pull yet, so pull is implemented as a merge. Hence need to check for merge commit on rugged adapter. assert_equal ["Wrote second test page", "Merged branch refs/heads/master of origin."].include?(@clone.repo.head.commit.message), true end teardown do FileUtils.rm_rf(@orig_path) FileUtils.rm_rf(@clone_path) end endgollum-lib-v4.2.7.10.gitlab.1/test/test_macros.rb000664 000000 000000 00000012667 13737324223 021425 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path('../helper', __FILE__) require File.expand_path('../wiki_factory', __FILE__) class Gollum::Macro::ListArgs < Gollum::Macro def render(*args) args.map { |a| "@#{a}@" }.join("\n") end end class Gollum::Macro::ListNamedArgs < Gollum::Macro def render(opts) opts.map { |k,v| "@#{k} = #{v}@" }.join("\n") end end context "Macros" do setup do @wiki, @path, @teardown = WikiFactory.create 'examples/test.git' end teardown do @teardown.call end test "Macro's are escapable" do @wiki.write_page("MacroEscapeText", :markdown, "'<>", commit_details) assert_match "

    <<AllPages()>>

    ", @wiki.pages[0].formatted_data end test "Missing macro provides missing macro output" do @wiki.write_page("NonExistentPage", :markdown, "<>", commit_details) assert_match(/Unknown macro: NonExistentMacro/, @wiki.pages[0].formatted_data) end test "AllPages macro does something interesting" do @wiki.write_page("AllPagesMacroPage", :markdown, "<>", commit_details) assert_match(/
  • AllPagesMacroPage/, @wiki.pages[0].formatted_data) end test "GlobalTOC macro displays global table of contents" do @wiki.write_page("GlobalTOCMacroPage", :markdown, "<>", commit_details) assert_match /
    (.*)Pages in this Wiki(.*)
  • GlobalTOCMacroPage/, @wiki.pages[0].formatted_data end test "Series macro displays series links with and without series prefix" do @wiki.write_page("test-series1", :markdown, "<>", commit_details) testseries1 = @wiki.page("test-series1") @wiki.write_page("test-series2", :markdown, "<>", commit_details) testseries2 = @wiki.page("test-series2") # Now create pages that are alphanumerically earlier, but don't match the 'test' prefix @wiki.write_page("ta-series1", :markdown, "<>", commit_details) taseries1 = @wiki.page("ta-series1") @wiki.write_page("ta-series2", :markdown, "<>", commit_details) taseries2 = @wiki.page("ta-series2") assert_match /Next(.*)test-series2/, testseries1.formatted_data assert_no_match /Previous/, testseries1.formatted_data assert_match /Next(.*)ta-series2/, taseries1.formatted_data assert_match /Previous(.*)ta-series1/, taseries2.formatted_data assert_match /Previous(.*)test-series1/, testseries2.formatted_data @wiki.write_page("test-series3", :markdown, "<>", commit_details) testseries3 = @wiki.page("test-series3") @wiki.write_page("test-series4", :markdown, "<>", commit_details) testseries4 = @wiki.page("test-series4") assert_no_match /Previous/, testseries4.formatted_data end test "ListArgs with no args" do @wiki.write_page("ListArgsMacroPage", :markdown, "<>", commit_details) assert_no_match(/@/, @wiki.pages[0].formatted_data) end test "ListArgs with a single empty quoted arg" do @wiki.write_page("ListArgsMacroPage", :markdown, '<>', commit_details) assert_match(/@@/, @wiki.pages[0].formatted_data) end test "ListArgs with a single non-quoted arg" do @wiki.write_page("ListArgsMacroPage", :markdown, "<>", commit_details) assert_match(/@foo@/, @wiki.pages[0].formatted_data) end test "ListArgs with several single non-quoted args" do @wiki.write_page("ListArgsMacroPage", :markdown, "<>", commit_details) assert_match(/@foo@/, @wiki.pages[0].formatted_data) assert_match(/@bar@/, @wiki.pages[0].formatted_data) assert_match(/@baz@/, @wiki.pages[0].formatted_data) end test "ListArgs with a single quoted arg" do @wiki.write_page("ListArgsMacroPage", :markdown, '<>', commit_details) assert_match(/@foo, bar, and baz@/, @wiki.pages[0].formatted_data) end test "ListArgs with several quoted args" do @wiki.write_page("ListArgsMacroPage", :markdown, '<>', commit_details) assert_match(/@foo, bar, and baz@/, @wiki.pages[0].formatted_data) assert_match(/@wombat@/, @wiki.pages[0].formatted_data) assert_match(/@xyzzy@/, @wiki.pages[0].formatted_data) end test "ListArgs with quoted parens" do @wiki.write_page("ListArgsMacroPage", :markdown, '<>', commit_details) assert_match(/@foo@/, @wiki.pages[0].formatted_data) assert_match(/@\(bar\)@/, @wiki.pages[0].formatted_data) end test "ListArgs with a mix or arg styles" do @wiki.write_page("ListArgsMacroPage", :markdown, '<>', commit_details) assert_match(/@foo, bar, and baz@/, @wiki.pages[0].formatted_data) assert_match(/@wombat@/, @wiki.pages[0].formatted_data) assert_match(/@funny things@/, @wiki.pages[0].formatted_data) end test "Args parser doesn't overstep its boundaries" do @wiki.write_page("MultiMacroPage", :markdown, "<>\n\n<>", commit_details) assert_match(/@Foo@/, @wiki.pages[0].formatted_data) assert_match(/Unknown macro: NonExistentMacro/, @wiki.pages[0].formatted_data) end test "Args parser handles named args" do @wiki.write_page("ListNamedArgsPage", :markdown, "<>", commit_details) assert_match(/@xyzzy = Foo@/, @wiki.pages[0].formatted_data) end end gollum-lib-v4.2.7.10.gitlab.1/test/test_markup.rb000664 000000 000000 00000112473 13737324223 021434 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path("../helper", __FILE__) require File.expand_path("../wiki_factory", __FILE__) context "Markup" do setup do @wiki, @path, @teardown = WikiFactory.create 'examples/test.git' end teardown do @teardown.call end test "formats page from Wiki#pages" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details) assert @wiki.pages[0].formatted_data end # This test is to assume that Sanitize.clean doesn't raise Encoding::CompatibilityError on ruby 1.9 test "formats non ASCII-7 character page from Wiki#pages" do wiki = Gollum::Wiki.new(testpath("examples/yubiwa.git")) assert_nothing_raised(defined?(Encoding) && Encoding::CompatibilityError) do assert wiki.page("strider").formatted_data end end test "Gollum::Markup#render yields a DocumentFragment" do yielded = false @wiki.write_page("Yielded", :markdown, "abc", commit_details) page = @wiki.page("Yielded") markup = Gollum::Markup.new(page) markup.render do |doc| assert_kind_of Nokogiri::HTML::DocumentFragment, doc yielded = true end assert yielded end test "Gollum::Page#formatted_data yields a DocumentFragment" do yielded = false @wiki.write_page("Yielded", :markdown, "abc", commit_details) page = @wiki.page("Yielded") page.formatted_data do |doc| assert_kind_of Nokogiri::HTML::DocumentFragment, doc yielded = true end assert yielded, "Gollum::Page#formatted_data should yield a document" yielded = false page.formatted_data do yielded = true end assert yielded, "Gollum::Page#formatted_data should yield a document even when formatted_data is taken from cache" end test "Gollum::Markup#formats returns all formats by default" do assert Gollum::Markup.formats.keys.include?(:asciidoc) assert Gollum::Markup.formats.size > 1 end test "Gollum::Markup#formats should recognize adoc as an AsciiDoc file" do _, format = Gollum::Page.parse_filename("file.adoc") assert :asciidoc == format end test "Gollum::Markup#formats should recognize asciidoc as an AsciiDoc file" do _, format = Gollum::Page.parse_filename("file.asciidoc") assert :asciidoc == format end test "Gollum::Markup#formats is limited by Gollum::Page::FORMAT_NAMES" do begin Gollum::Page::FORMAT_NAMES = { :markdown => "Markdown" } assert Gollum::Markup.formats.keys.include?(:markdown) assert !Gollum::Markup.formats.keys.include?(:asciidoc) ensure Gollum::Page.send :remove_const, :FORMAT_NAMES end end ######################################################################### # # Links # ######################################################################### test "absolute link to non-existent page" do @wiki.write_page("linktest", :markdown, "[[/Page]]", commit_details) page = @wiki.page("linktest") doc = Nokogiri::HTML page.formatted_data paras = doc / :p para = paras.first anchors = para / :a assert_equal 1, paras.size assert_equal 1, anchors.size assert_equal 'internal absent', anchors[0]['class'] assert_equal '/Page', anchors[0]['href'] assert_equal '/Page', anchors[0].text end test "double page links no space" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details) # "

    a FooBar b

    " page = @wiki.page("Bilbo Baggins") doc = Nokogiri::HTML page.formatted_data paras = doc / :p para = paras.first anchors = para / :a assert_equal 1, paras.size assert_equal 2, anchors.size assert_equal 'internal absent', anchors[0]['class'] assert_equal 'internal absent', anchors[1]['class'] assert_equal '/Foo', anchors[0]['href'] assert_equal '/Bar', anchors[1]['href'] assert_equal 'Foo', anchors[0].text assert_equal 'Bar', anchors[1].text end test "double page links with space" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]] [[Bar]] b", commit_details) # "

    a Foo Bar b

    " page = @wiki.page("Bilbo Baggins") doc = Nokogiri::HTML page.formatted_data paras = doc / :p para = paras.first anchors = para / :a assert_equal 1, paras.size assert_equal 2, anchors.size assert_equal 'internal absent', anchors[0]['class'] assert_equal 'internal absent', anchors[1]['class'] assert_equal '/Foo', anchors[0]['href'] assert_equal '/Bar', anchors[1]['href'] assert_equal 'Foo', anchors[0].text assert_equal 'Bar', anchors[1].text end test "page link" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Bilbo Baggins]] b", commit_details) page = @wiki.page("Bilbo Baggins") output = page.formatted_data assert_match(/class="internal present"/, output) assert_match(/href="\/Bilbo-Baggins"/, output) assert_match(/\>Bilbo Baggins\J\. R\. R\. Tolkien\ path) @wiki.write_page(name, :markdown, "a [[#{name}]] b", commit_details) page = @wiki.page(name) output = page.formatted_data assert_match(/class="internal present"/, output) assert_match(/href="\/wiki\/Bilbo-Baggins-\d"/, output) assert_match(/\>Bilbo Baggins \d\a http://example.com b

    ", page.formatted_data end test "external page link with different text" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Words|http://example.com]] b", commit_details) page = @wiki.page("Bilbo Baggins") assert_html_equal "

    a Words b

    ", page.formatted_data end test "external page link with agnostic protocol" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Words|//example.com]] b", commit_details) page = @wiki.page("Bilbo Baggins") assert_html_equal "

    a Words b

    ", page.formatted_data end test "page link with different text" do @wiki.write_page("Potato", :markdown, "a [[Potato Heaad|Potato]] ", commit_details) page = @wiki.page("Potato") output = page.formatted_data assert_html_equal "

    aPotato Heaad

    ", output end test "page link with different text on mediawiki" do @wiki.write_page("Potato", :mediawiki, "a [[Potato|Potato Heaad]] ", commit_details) page = @wiki.page("Potato") output = page.formatted_data assert_html_equal "

    \na Potato Heaad

    ", output end test "wiki link within inline code block" do @wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details) page = @wiki.page("Potato") assert_html_equal "

    sed -i '' 's/[[:space:]]*$//'

    ", page.formatted_data end test "wiki link within org code block" do code = <<-org #+HEADERS: blah blah #+HEADER: blah #+NAME: org test block #+BEGIN_SRC bash some switches sed -i '' 's/[[:space:]]*$//' #+END_SRC org @wiki.write_page("Pipe", :org, code, commit_details) page = @wiki.page("Pipe") assert_html_equal "
    sed -i '' 's/[[:space:]]*$//'
    \n", page.formatted_data end test "regexp gsub! backref (#383)" do # bug only triggers on "```" syntax # not `code` page = 'test_rgx' @wiki.write_page(page, :markdown, (<<-'DATA' ``` rot13='tr '\''A-Za-z'\'' '\''N-ZA-Mn-za-m'\' ``` DATA ), commit_details) output = @wiki.page(page).formatted_data expected = %Q{
          
    rot13='tr '\\''A-Za-z'\\'' '\\''N-ZA-Mn-za-m'\\'
    \n
    } assert_html_equal expected, output end # Issue #568 test "tilde code blocks without a language" do page = 'test_rgx' @wiki.write_page(page, :markdown, %Q(~~~ 'hi' ~~~ ), commit_details) output = @wiki.page(page).formatted_data expected = %Q{
    'hi'
    } assert_html_equal expected, output end test "tilde code blocks #537" do page = 'test_rgx' @wiki.write_page(page, :markdown, %Q(~~~ {.ruby} 'hi' ~~~ ), commit_details) output = @wiki.page(page).formatted_data expected = %Q{
    'hi'
    } assert_html_equal expected, output end # Issue #537 test "tilde code blocks with more than one class" do page = 'test_rgx' @wiki.write_page(page, :markdown, %Q(~~~ {#hi .ruby .sauce} 'hi' ~~~ ), commit_details) output = @wiki.page(page).formatted_data expected = %Q{
    'hi'
    } assert_html_equal expected, output end # Issue #537 test "tilde code blocks with lots of tildes" do page = 'test_rgx' @wiki.write_page(page, :markdown, %Q(~~~~~~ {#hi .ruby .sauce} ~~ 'hi'~ ~~~~~~ ), commit_details) output = @wiki.page(page).formatted_data expected = %Q{
    ~~\n'hi'~
    } assert_html_equal expected, output end test "four space indented code block" do page = 'test_four' @wiki.write_page(page, :markdown, %( test test), commit_details) output = @wiki.page(page).formatted_data expected = %(
    test\ntest\n
    ) assert_html_equal expected, output end test "wiki link within code block" do @wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details) page = @wiki.page("Potato") assert_html_equal "
    sed -i '' 's/[[:space:]]*$//'\n
    ", page.formatted_data end test "piped wiki link within code block" do @wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details) page = @wiki.page("Potato") assert_html_equal "

    make a link [[home|sweet home]]

    ", page.formatted_data end ######################################################################### # # include: directive # ######################################################################### test "simple include: directive" do @wiki.write_page("page1", :textile, "hello\n[[include:page2]]\n", commit_details) @wiki.write_page("page2", :textile, "goodbye\n", commit_details) page1 = @wiki.page("page1") assert_html_equal("

    hello

    goodbye

    ", page1.formatted_data) end test "include: directive with infinite loop" do @wiki.write_page("page1", :textile, "hello\n[[include:page1]]\n", commit_details) page1 = @wiki.page("page1") assert_match("Too many levels", page1.formatted_data) end test "include: directive with missing file" do @wiki.write_page("page1", :textile, "hello\n[[include:page2]]\n", commit_details) page1 = @wiki.page("page1") assert_match("Cannot include", page1.formatted_data) end test "include: directive with javascript" do @wiki.write_page("page1", :textile, "hello\n[[include:page2]]\n", commit_details) @wiki.write_page("page2", :textile, "alert(99);", commit_details) page1 = @wiki.page("page1") assert_html_equal("

    hello
    \nalert(99);

    ", page1.formatted_data) end test "include: directive with sneaky javascript attempt" do @wiki.write_page("page1", :textile, "hello\n[[include:page2]][[include:page3]]\n", commit_details) @wiki.write_page("page2", :textile, "alert(99);", commit_details) page1 = @wiki.page("page1") assert_html_equal("

    hello

    <java

    script>alert(99);

    ", page1.formatted_data) end test "include directive with very long absolute path and relative include" do @wiki.write_page("page1", :textile, "hello\n[[include:/a/very/long/path/to/page2]]\n", commit_details) @wiki.write_page("/a/very/long/path/to/page2", :textile, "goodbye\n[[include:object]]", commit_details) @wiki.write_page("/a/very/long/path/to/object", :textile, "my love", commit_details) page1 = @wiki.page("page1") assert_html_equal("

    hello

    goodbye

    my love

    ", page1.formatted_data) end test "include directive with a relative include" do @wiki.write_page("page1", :textile, "hello\n[[include:/going/in/deep]]\n", commit_details) @wiki.write_page("/going/in/deep", :textile, "[[include:../shallow]]", commit_details) @wiki.write_page("/going/shallow", :textile, "found me", commit_details) page1 = @wiki.page("page1") assert_html_equal("

    hello

    found me

    ", page1.formatted_data) end test "relative include directive with a subtle infinite loop" do @wiki.write_page("page1", :textile, "hello\n[[include:../../page1]]\n", commit_details) page1 = @wiki.page("page1") assert_match("Too many levels", page1.formatted_data) end test "ugly include directives that should all be not found" do %w( /// ../../.. /./.!!./ ../../../etc/passwd con: /dev/null \0 \ \ \ \\\\\\\\ ).each_with_index do |ugly, n| name = "ugly#{n}" @wiki.write_page(name, :textile, "hello\n[[include:#{ugly}]]\n", commit_details) page1 = @wiki.page(name) assert_match("does not exist yet", page1.formatted_data) end end ######################################################################### # # Images # ######################################################################### test "image with http url" do ['http', 'https'].each do |scheme| name = "Bilbo Baggins #{scheme}" @wiki.write_page(name, :markdown, "a [[#{scheme}://example.com/bilbo.jpg]] b", commit_details) page = @wiki.page(name) output = page.formatted_data assert_html_equal %{

    a b

    }, output end end test "image with extension in caps with http url" do ['http', 'https'].each do |scheme| name = "Bilbo Baggins #{scheme}" @wiki.write_page(name, :markdown, "a [[#{scheme}://example.com/bilbo.JPG]] b", commit_details) page = @wiki.page(name) output = page.formatted_data assert_html_equal %{

    a b

    }, output end end test "image with absolute path" do @wiki = Gollum::Wiki.new(@path, :base_path => '/wiki') index = @wiki.repo.index index.add("alpha.jpg", "hi") index.commit("Add alpha.jpg") @wiki.write_page("Bilbo Baggins", :markdown, "a [[/alpha.jpg]] [[a | /alpha.jpg]] b", commit_details) page = @wiki.page("Bilbo Baggins") assert_html_equal %{

    a a b

    }, page.formatted_data end test "image with relative path on root" do @wiki = Gollum::Wiki.new(@path, :base_path => '/wiki') index = @wiki.repo.index index.add("alpha.jpg", "hi") index.add("Bilbo-Baggins.md", "a [[alpha.jpg]] [[a | alpha.jpg]] b") index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") assert_html_equal %Q{

    a a b

    }, page.formatted_data end test "image with relative path" do @wiki = Gollum::Wiki.new(@path, :base_path => '/wiki') index = @wiki.repo.index index.add("greek/alpha.jpg", "hi") index.add("greek/Bilbo-Baggins.md", "a [[alpha.jpg]] [[a | alpha.jpg]] b") index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") output = page.formatted_data assert_html_equal %{

    a a b

    }, output end test "image with absolute path on a preview" do @wiki = Gollum::Wiki.new(@path, :base_path => '/wiki') index = @wiki.repo.index index.add("alpha.jpg", "hi") index.commit("Add alpha.jpg") page = @wiki.preview_page("Test", "a [[/alpha.jpg]] b", :markdown) assert_html_equal %{

    a b

    }, page.formatted_data end test "image with relative path on a preview" do @wiki = Gollum::Wiki.new(@path, :base_path => '/wiki') index = @wiki.repo.index index.add("alpha.jpg", "hi") index.add("greek/alpha.jpg", "hi") index.commit("Add alpha.jpg") page = @wiki.preview_page("Test", "a [[alpha.jpg]] [[greek/alpha.jpg]] b", :markdown) assert_html_equal %{

    a b

    }, page.formatted_data end test "image with alt" do content = "a [[alpha.jpg|alt=Alpha Dog]] b" output = %{

    a\"Alphab

    } relative_image(content, output) end test "image with em or px dimension" do %w{em px}.each do |unit| %w{width height}.each do |dim| content = "a [[alpha.jpg|#{dim}=100#{unit}]] b" output = "

    ab

    " relative_image(content, output) end end end test "image with bogus dimension" do %w{width height}.each do |dim| content = "a [[alpha.jpg|#{dim}=100]] b" output = "

    ab

    " relative_image(content, output) end end test "image with vertical align" do %w{top texttop middle absmiddle bottom absbottom baseline}.each do |align| content = "a [[alpha.jpg|align=#{align}]] b" output = %Q{

    ab

    } relative_image(content, output) end end test "image with horizontal align" do %w{left center right}.each do |align| content = "a [[alpha.jpg|align=#{align}]] b" output = "

    ab

    " relative_image(content, output) end end test "image with float" do content = "a\n\n[[alpha.jpg|float]]\n\nb" output = "

    a

    b

    " relative_image(content, output) end test "image with float and align" do %w{left right}.each do |align| content = "a\n\n[[alpha.jpg|float|align=#{align}]]\n\nb" output = "

    a

    b

    " relative_image(content, output) end end test "image with frame" do content = "a\n\n[[alpha.jpg|frame]]\n\nb" output = "

    a

    b

    " relative_image(content, output) end test "absolute image with frame" do content = "a\n\n[[http://example.com/bilbo.jpg|frame]]\n\nb" output = "

    a

    b

    " relative_image(content, output) end test "image with frame and alt" do content = "a\n\n[[alpha.jpg|frame|alt=Alpha]]\n\nb" output = "

    a

    Alpha

    b

    " relative_image(content, output) end ######################################################################### # # File links # ######################################################################### test "file link with absolute path" do index = @wiki.repo.index index.add("alpha.jpg", "hi") index.commit("Add alpha.jpg") @wiki.write_page("Bilbo Baggins", :markdown, "a [[Alpha|/alpha.jpg]] b", commit_details) page = @wiki.page("Bilbo Baggins") output = Gollum::Markup.new(page).render assert_html_equal %{

    a Alpha b

    }, output end test "file link with relative path" do index = @wiki.repo.index index.add("greek/alpha.jpg", "hi") index.add("greek/Bilbo-Baggins.md", "a [[Alpha|alpha.jpg]] b") index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") output = Gollum::Markup.new(page).render assert_html_equal %{

    a Alpha b

    }, output end test "file link with external path" do index = @wiki.repo.index index.add("greek/Bilbo-Baggins.md", "a [[Alpha|http://example.com/alpha.jpg]] b") index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") assert_html_equal %{

    a Alpha b

    }, page.formatted_data end ######################################################################### # # Code # ######################################################################### test "regular code blocks" do content = "a\n\n```ruby\nx = 1\n```\n\nb" output = %Q{

    a

    \n\n
    x = 1
    \n\n

    b

    } index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render assert_html_equal output, rendered end test "code blocks with carriage returns" do content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb" output = %Q{

    a

    \n\n
    x = 1
    \n\n

    b

    } index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render assert_html_equal output, rendered end test "code blocks with two-space indent" do content = "a\n\n```ruby\n x = 1\n\n y = 2\n```\n\nb" output = "

    a

    \n\n
    " +
            "x = 1" +
            "\n\ny =" +
            " 2\n
    \n\n\n

    b

    " compare(content, output) end test "code blocks with one-tab indent" do content = "a\n\n```ruby\n\tx = 1\n\n\ty = 2\n```\n\nb" output = "

    a

    \n\n
    " +
            "x = 1" +
            "\n\ny =" +
            " 2\n
    \n\n\n

    b

    " compare(content, output) end test "code blocks with multibyte characters indent" do content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb" output = %Q{

    a

    \n\n
    s = 'やくしまるえつこ'
    \n\n

    b

    } index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add alpha.jpg") page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render(false, 'utf-8') assert_html_equal output, rendered end test "code blocks with ascii characters" do content = "a\n\n```\n├─foo\n```\n\nb" output = %(

    a

    ├─foo

    b

    ) compare(content, output) end test "code with wiki links" do content = <<-END booya ``` python np.array([[2,2],[1,3]],np.float) ``` END # rendered with Gollum::Markup _page, rendered = render_page(content) assert_markup_highlights_code Gollum::Markup, rendered end test "code with trailing whitespace" do content = <<-END shoop da woop ``` python np.array([[2,2],[1,3]],np.float) ``` END # rendered with Gollum::Markup _page, rendered = render_page(content) assert_markup_highlights_code Gollum::Markup, rendered end def assert_markup_highlights_code(markup_class, rendered) assert_match(/pre class="highlight"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}") assert_match(/span class="n"/, rendered, "#{markup_class} doesn't highlight code\n #{rendered}") assert_match(/\(\[\[/, rendered, "#{markup_class} parses out wiki links\n#{rendered}") end test "embed code page absolute link" do @wiki.write_page("base", :markdown, "a\n!base", commit_details) @wiki.write_page("a", :markdown, "a\n```html:/base```", commit_details) page = @wiki.page("a") output = page.formatted_data assert_html_equal %Q{

    a\n

    File not found: /base

    }, output end test "embed code page relative link" do @wiki.write_page("base", :markdown, "a\n!rel", commit_details) @wiki.write_page("a", :markdown, "a\n```html:base```", commit_details) page = @wiki.page("a") output = page.formatted_data assert_html_equal %Q{

    a\n

    File not found: base

    }, output end test "code block in unsupported language" do @wiki.write_page("a", :markdown, "a\n\n```nonexistent\ncode\n```", commit_details) page = @wiki.page("a") output = page.formatted_data assert_html_equal %Q{

    a\n

    code
    }, output end ######################################################################### # # Metadata Blocks # ######################################################################### test "metadata blocks" do content = "a\n\n\n\nb" output = "

    a

    \n\n

    b

    " result = { 'tags' => '[foo, bar]' } index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add metadata") page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render assert_html_equal output, rendered assert_equal result, page.metadata end test "metadata blocks with newline" do content = "a\n\n\n\nb" output = "

    a

    \n\n

    b

    " result = { 'tags' => '[foo, bar]' } index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add metadata") page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render assert_html_equal output, rendered assert_equal result, page.metadata end test "metadata stripping" do content = "a\n\n\n\nb" output = "

    a

    \n\n

    b

    " result = { 'foo' => %{alert('');} } index = @wiki.repo.index index.add("Bilbo-Baggins.md", content) index.commit("Add metadata") page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render assert_html_equal output, rendered assert_equal result, page.metadata end ######################################################################### # # Various # ######################################################################### test "strips javscript protocol urls" do content = "[Hack me](javascript:hacked=true)" output = "

    Hack me

    " compare(content, output) end test "allows apt uri schemes" do content = "[Hack me](apt:gettext)" output = "

    Hack me

    " compare(content, output) end test "removes style blocks completely" do content = "foobar" output = "

    foobar

    " compare(content, output) end test "removes script blocks completely" do content = "foobar" output = "

    foobar

    " compare(content, output) end test "escaped wiki link" do content = "a '[[Foo]], b" output = "

    a [[Foo]], b

    " compare(content, output) end test "quoted wiki link" do content = "a '[[Foo]]', b" output = "

    a 'Foo', b

    " compare(content, output, 'md', [ /class="internal absent"/, /href="\/Foo"/, /\>Foo\a Google b

    " compare(content, output, 'org') end test "org mode style double file links" do content = "a [[file:f.org][Google]] b" output = "

    a Google b

    " compare(content, output, 'org') end test "short double links" do content = "a [[b]] c" output = %(

    a b c

    ) compare(content, output, 'org') end test "double linked pipe" do content = "a [[|]] b" output = %(

    a b

    ) compare(content, output, 'org') end test "id with prefix ok" do content = "h2(example#wiki-foo). xxxx" output = "

    xxxx

    " compare(content, output, :textile) end test "id prefix added" do content = "h2(#foo). xxxx[1]\n\nfn1.footnote" output = "

    xxxx1\n

    \n

    1 footnote

    " compare(content, output, :textile) end test "name prefix added" do content = "abc\n\n__TOC__\n\n==Header==\n\nblah" compare content, '', :mediawiki, [ /id="wiki-toc"/, /href="#wiki-Header"/, /id="wiki-Header"/, /name="wiki-Header"/ ] end test "toc with h1_title does not include page title" do @wiki.instance_variable_set(:@h1_title, true) @wiki.write_page("H1Test", :markdown, "# This is the page title\n\n# Testing\n\nTest", commit_details) page = @wiki.page("H1Test") assert_html_equal page.toc_data, "
    Table of Contents
    " @wiki.instance_variable_set(:@h1_title, false) end test "identical headers in TOC have unique prefix" do content = <<-MARKDOWN __TOC__ # Summary # Summary MARKDOWN output = "

    TOC

    \n\n

    Summary

    \n\n

    Summary

    " compare(content, output, :markdown) end test "anchor names are normalized" do content = <<-MARKDOWN __TOC__ # Summary '"' stuff # Summary !@$#%^&*() stuff MARKDOWN output = "

    TOC

    \n\n

    Summary '\"' stuff

    \n\n

    Summary !@$#%^&*() stuff

    " compare(content, output, :markdown) end test 'anchor names contain the ancestor' do content = <<-MARKDOWN __TOC__ # Summary ## Horse MARKDOWN output = "

    TOC

    \n\n

    Summary

    \n\n

    Horse

    " compare(content, output, :markdown) end if defined?(Asciidoctor) ######################################################################### # Asciidoc ######################################################################### test "asciidoc syntax highlighting" do input = <<-ASCIIDOC [source,python] ---- ''' A multi-line comment.''' def sub_word(mo): ''' Single line comment.''' word = mo.group('word') # Inline comment if word in keywords[language]: return quote + word + quote else: return word ---- ASCIIDOC compare(input, nil, 'asciidoc', [/\\''' A multi-line\n comment.'''\<\/span\>/]) end test "asciidoc header" do compare("= Book Title\n\n== Heading", '

    Heading

    ', 'asciidoc') end test "internal links with asciidoc" do compare("= Book Title\n\n[[anid]]\n== Heading", '

    Heading

    ', 'asciidoc') end end ######################################################################### # Plain Text ######################################################################### test "plain text (.txt) is rendered within a
     block" do
        content = "In the Land of Mordor where the Shadows lie."
        output  = "
    In the Land of Mordor where the Shadows lie.
    " compare(content, output, "txt") end test "plain text (.txt) is rendered without code blocks" do content = "```ruby\nx = 1\n```\n" output = "
    ```ruby\nx = 1\n```\n
    " compare(content, output, "txt") end test "plain text (.txt) is rendered without markdown markup" do content = "# A basic header" output = "
    # A basic header
    " compare(content, output, "txt") end test "plain text (.txt) is rendered with meta data" do content = "a\n\n\n\nb" result = { 'tags' => '[foo, bar]' } index = @wiki.repo.index index.add("Bilbo-Baggins.txt", content) index.commit("Plain Text with metadata") page = @wiki.page("Bilbo Baggins") assert_equal result, page.metadata end test "plain text (.txt) is rendered with inline HTML escaped" do content = "Plain text
    with a HTML link" output = "
    Plain text <br/> with a <a href=\"http://example.com\">HTML link</a>
    " compare(content, output, "txt") end test 'static rendering and font awesome class' do uses_wiki = false markup = Gollum::Markup.new uses_wiki # must expect expected = "

    hi

    \n\n

    Table of Contents

    " actual = markup.render_default "#hi\n[[_TOC_]]" assert_html_equal expected, actual end ######################################################################### # # Helpers # ######################################################################### def render_page(content, ext = "md") index = @wiki.repo.index index.add("Bilbo-Baggins.#{ext}", content) index.commit("Add baggins") page = @wiki.page("Bilbo Baggins") [page, Gollum::Markup.new(page).render] end def compare(content, output, ext = "md", regexes = []) page, rendered = render_page(content, ext) if regexes.empty? assert_html_equal output, rendered else output = page.formatted_data regexes.each { |r| assert_match r, output } end end def relative_image(content, output) index = @wiki.repo.index index.add("greek/alpha.jpg", "hi") index.add("greek/Bilbo-Baggins.md", content) index.commit("Add alpha.jpg") @wiki.clear_cache page = @wiki.page("Bilbo Baggins") rendered = Gollum::Markup.new(page).render assert_html_equal output, rendered end end gollum-lib-v4.2.7.10.gitlab.1/test/test_page.rb000664 000000 000000 00000026701 13737324223 021047 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), "helper")) context "Page" do setup do @wiki = Gollum::Wiki.new(testpath("examples/lotr.git")) end test "new page" do page = Gollum::Page.new(@wiki) assert_nil page.raw_data assert_nil page.formatted_data end test "get existing page" do page = @wiki.page('Bilbo Baggins') assert_equal Gollum::Page, page.class assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/ expected = "

    Bilbo Baggins

    \n\n

    Bilbo Baggins is the protagonist of The Hobbit and also makes a few\nappearances in The Lord of the Rings, two of the most well-known of J. R. R.\nTolkien's fantasy writings. The story of The Hobbit featuring Bilbo is also\nretold from a different perspective in the Chapter The Quest of Erebor in\nUnfinished Tales.

    \n\n

    In Tolkien's narrative conceit, in which all the writings of Middle-earth are\n'really' translations from the fictitious volume of The Red Book of Westmarch,\nBilbo is the author of The Hobbit and translator of The Silmarillion.

    \n\n

    From http://en.wikipedia.org/wiki/Bilbo_Baggins.

    " actual = page.formatted_data assert_html_equal expected, actual assert_equal 'Bilbo-Baggins.md', page.path assert_equal :markdown, page.format assert_equal @wiki.repo.commits.first.id, page.version.id assert_not_nil page.last_version assert_equal page.versions.first.id, page.last_version.id assert page.last_version.stats.files.map{|file| file_path = file.first}.include? page.path end test "get existing page case insensitive" do assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('bilbo baggins').path end test "get existing page with hyphen" do assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('Bilbo-Baggins').path end test "get existing page with underscore" do assert_nil @wiki.page('Bilbo_Baggins') end test "get existing page where filename contains whitespace, with hypen" do assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise-Gamgee').path end test "get existing page where filename contains whitespace, with underscore" do assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise_Gamgee').path end test "get existing page where filename contains whitespace, with whitespace" do assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise Gamgee').path end test "get nested page" do page = @wiki.page('Eye Of Sauron') assert_equal 'Mordor/Eye-Of-Sauron.md', page.path end test "url_path" do page = @wiki.page('Bilbo Baggins') assert_equal 'Bilbo-Baggins', page.url_path end test "nested url_path" do page = @wiki.page('Eye Of Sauron') assert_equal 'Mordor/Eye-Of-Sauron', page.url_path end test "url_path_display" do page = @wiki.page('Bilbo Baggins') assert_equal 'Bilbo Baggins', page.url_path_display end test "page versions" do page = @wiki.page('Bilbo Baggins') assert_equal ["f25eccd98e9b667f9e22946f3e2f945378b8a72d", "5bc1aaec6149e854078f1d0f8b71933bbc6c2e43"], page.versions.map { |v| v.id } end test "page versions across renames" do page = @wiki.page 'My-Precious' assert_equal ['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b', '94523d7ae48aeba575099dd12926420d8fd0425d'], page.versions(:follow => true).map { |v| v.id } end test "page versions without renames" do page = @wiki.page 'My-Precious' assert_equal ['60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'], page.versions(:follow => false).map { |v| v.id } end test "specific page version" do page = @wiki.page('Bilbo Baggins', 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb') assert_equal 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb', page.version.id end test "no page match" do assert_nil @wiki.page('I do not exist') end test "no version match" do assert_nil @wiki.page('Bilbo Baggins', 'I do not exist') end test "no ext match" do assert_nil @wiki.page('Data') end test "cname" do assert_equal "Foo", Gollum::Page.cname("Foo") assert_equal "Foo-Bar", Gollum::Page.cname("Foo Bar") # / is now a directory delimiter so it must be preserved assert_equal "Foo-/-Bar", Gollum::Page.cname("Foo / Bar") assert_equal "José", Gollum::Page.cname("José") assert_equal "モルドール", Gollum::Page.cname("モルドール") end test "title from filename with normal contents" do page = @wiki.page('Bilbo Baggins') assert_equal 'Bilbo Baggins', page.title end test "title from filename with html contents" do page = @wiki.page('My Precious', '0ed8cbe0a25235bd867e65193c7d837c66b328ef') assert_equal 'My Precious', page.title end test "top level header" do header = @wiki.page('Home').header assert_equal "Hobbits\n", header.raw_data assert_equal "_Header.md", header.path end test "nested header" do header = @wiki.page('Eye Of Sauron').header assert_equal "Sauron\n", header.raw_data assert_equal "Mordor/_Header.md", header.path end test "header itself" do header = @wiki.page("_Header") assert_nil header.header assert_nil header.footer assert_nil header.sidebar end test "top level footer" do footer = @wiki.page('Home').footer assert_equal 'Lord of the Rings wiki', footer.raw_data assert_equal '_Footer.md', footer.path end test "nested footer" do footer = @wiki.page('Eye Of Sauron').footer assert_equal "Ones does not simply **walk** into Mordor!\n", footer.raw_data assert_equal "Mordor/_Footer.md", footer.path end test "footer itself" do footer = @wiki.page("_Footer") assert_nil footer.header assert_nil footer.footer assert_nil footer.sidebar end test "top level sidebar" do sidebar = @wiki.page('Home').sidebar assert_equal 'Lord of the Rings wiki', sidebar.raw_data assert_equal '_Sidebar.md', sidebar.path end test "nested sidebar" do sidebar = @wiki.page('Eye Of Sauron').sidebar assert_equal "Ones does not simply **walk** into Mordor!\n", sidebar.raw_data assert_equal "Mordor/_Sidebar.md", sidebar.path end test "sidebar itself" do sidebar = @wiki.page("_Sidebar") assert_nil sidebar.header assert_nil sidebar.footer assert_nil sidebar.sidebar end test "cannot convert non string to human readable page title" do assert_equal '', Gollum::Page.cname(nil) assert_equal '', Gollum::Page.cname(3) end test "normalize_dir" do assert_equal nil, Gollum::BlobEntry.normalize_dir(nil) # Toplevel paths assert_equal "", Gollum::BlobEntry.normalize_dir("") assert_equal "", Gollum::BlobEntry.normalize_dir(".") assert_equal "", Gollum::BlobEntry.normalize_dir("..") assert_equal "", Gollum::BlobEntry.normalize_dir("/") assert_equal "", Gollum::BlobEntry.normalize_dir("//") assert_equal "", Gollum::BlobEntry.normalize_dir("c:/") assert_equal "", Gollum::BlobEntry.normalize_dir("C:/") # Normalize slashes assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir("foo/bar") assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir("/foo/bar") assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir("/foo/bar/") assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir("//foo//bar//") assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir("c://foo//bar//") # Don't traverse paths assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir('foo/./bar') assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir('foo/../bar') assert_equal "/foo/bar", Gollum::BlobEntry.normalize_dir('../foo/../bar/..') # Don't expand tildes assert_equal "/~/foo", Gollum::BlobEntry.normalize_dir("~/foo") assert_equal "/~root/foo", Gollum::BlobEntry.normalize_dir("~root/foo") assert_equal "/~!/foo", Gollum::BlobEntry.normalize_dir("~!/foo") assert_equal "/foo/~", Gollum::BlobEntry.normalize_dir("foo/~") # Special values that are still valid paths assert_equal "/ ", Gollum::BlobEntry.normalize_dir(" ") assert_equal "/\t", Gollum::BlobEntry.normalize_dir("\t") assert_equal "/...", Gollum::BlobEntry.normalize_dir("...") end end context "with a checkout" do setup do @path = cloned_testpath("examples/lotr.git") @wiki = Gollum::Wiki.new(@path) end teardown do FileUtils.rm_rf(@path) end test "get existing page with symbolic link" do page = @wiki.page("Hobbit") assert_equal Gollum::Page, page.class assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/ expected = "

    Bilbo Baggins

    \n\n

    Bilbo Baggins is the protagonist of The Hobbit and also makes a few\nappearances in The Lord of the Rings, two of the most well-known of J. R. R.\nTolkien's fantasy writings. The story of The Hobbit featuring Bilbo is also\nretold from a different perspective in the Chapter The Quest of Erebor in\nUnfinished Tales.

    \n\n

    In Tolkien's narrative conceit, in which all the writings of Middle-earth are\n'really' translations from the fictitious volume of The Red Book of Westmarch,\nBilbo is the author of The Hobbit and translator of The Silmarillion.

    \n\n

    From http://en.wikipedia.org/wiki/Bilbo_Baggins.

    " actual = page.formatted_data assert_html_equal expected, actual assert_equal 'Hobbit.md', page.path assert_equal :markdown, page.format end end context "within a sub-directory" do setup do @wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), { :page_file_dir => 'Rivendell' }) end test "get existing page" do page = @wiki.page('Elrond') assert_equal Gollum::Page, page.class assert page.raw_data =~ /^# Elrond\n\nElrond/ assert_equal 'Rivendell/Elrond.md', page.path assert_equal :markdown, page.format assert_equal @wiki.repo.commits.first.id, page.version.id end test "should not get page from parent dir" do page = @wiki.page('Bilbo Baggins') assert_equal nil, page end test "should inherit header/footer/sidebar pages from parent directories" do page = @wiki.page('Elrond') assert page.sidebar.parent_page == page assert_equal Gollum::Page, page.sidebar.class assert_equal Gollum::Page, page.header.class assert_equal Gollum::Page, page.footer.class assert page.sidebar.raw_data =~ /^Lord of the Rings/ assert page.header.raw_data =~ /^Hobbits/ assert page.footer.raw_data =~ /^Lord of the Rings/ end test "get metadata on page" do page = @wiki.page('Elrond') assert_equal Gollum::Page, page.class assert_equal 'elf', page.metadata['race'] end end context "with custom markup engines" do setup do Gollum::Markup.register(:redacted, "Redacted", :regexp => /rd/) { |content| content.gsub(/\S/, '-') } @wiki = Gollum::Wiki.new(testpath("examples/lotr.git")) end test "should use the specified engine" do page = @wiki.page('Riddles') assert_equal :redacted, page.format assert page.raw_data.include? 'Time' assert page.raw_data =~ /^[\s\-]*$/ end end gollum-lib-v4.2.7.10.gitlab.1/test/test_plantuml.rb000664 000000 000000 00000003172 13737324223 021764 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), "helper")) context "Page" do setup do @wiki = Gollum::Wiki.new(testpath("examples/lotr.git")) end test "generate platuml img tags" do FIRST_URL = "http://localhost:8080/plantuml/png/U9o5a4qAmZ0GXVSvnT1zBb14IX75TK-GcX-2wGnCaeAtDwOjM1LSpdlVlFdfObASyXJ4e38JWZp2DVgWCxTmomciHsTOh1h8uf-CSXHQi9HHWqTWFnTaaIjneH3or49C50nOfaaiKdMRteUHe5VEUOpD3llm5lxCfDzvL-OXZ0_HK-dn30SflwcaxeMggHltCurDoen6hmlixTeogDSjQjwOKl-9IYGwWxhyzGa9rdHb" SECOND_URL = "http://localhost:8080/plantuml/png/U9npA2v9B2efpStXYdPFp4bCASfCpOa5iZDpTDD1V23RDQSeFm_4S3wyjYWbCGyadPYNafYJ5ilba9gN0jGC08cq6OO0" Gollum::Filter::PlantUML.configure do |config| config.test = true # Skip server checks config.url = "http://localhost:8080/plantuml/png" # Non existent server end page = @wiki.page('RingBearers') doc = Nokogiri::HTML page.formatted_data img_tags = doc.css('img') assert img_tags.size == 2 assert img_tags[0].attribute("src").to_s == FIRST_URL, img_tags[0].inspect assert img_tags[1].attribute("src").to_s == SECOND_URL, img_tags[1].inspect end test "generate errors when server unavailable" do Gollum::Filter::PlantUML.configure do |config| config.test = false # Ensure we check for server availability config.url = "http://localhost:0000/plantuml/png" # Non existent server end page = @wiki.page('RingBearers') doc = Nokogiri::HTML page.formatted_data img_tags = doc.css('img') error_tags = doc.css('.gollum-error') assert img_tags.size == 0 assert error_tags.size == 2 end end gollum-lib-v4.2.7.10.gitlab.1/test/test_unicode.rb000664 000000 000000 00000005273 13737324223 021562 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), "helper")) def utf8(str) str.respond_to?(:force_encoding) ? str.force_encoding('utf-8') : str end context "Unicode Support" do setup do @path = cloned_testpath("examples/revert.git") @wiki = Gollum::Wiki.new(@path) end teardown do FileUtils.rm_rf(@path) end test "create and read non-latin page with anchor 1" do @wiki.write_page("test", :markdown, "# 한글") page = @wiki.page("test") assert_equal Gollum::Page, page.class assert_equal "# 한글", utf8(page.raw_data) # markup.rb doc = Nokogiri::HTML page.formatted_data h1s = doc / :h1 h1 = h1s.first anchors = h1 / :a assert_equal 1, h1s.size assert_equal 1, anchors.size assert_equal '#한글', anchors[0]['href'] assert_equal '한글', anchors[0]['id'] assert_equal 'anchor', anchors[0]['class'] assert_equal '', anchors[0].text end def nfd(utf8) TwitterCldr::Normalization.normalize utf8 end def check_h1(text, page) @wiki.write_page(page, :markdown, "# " + text) # nokogiri will mix encodings # "\uD55C\uAE00" vs "한글" page = @wiki.page(page) assert_equal Gollum::Page, page.class expected = nfd('# ' + text) actual = nfd(utf8(page.raw_data)) assert_equal nfd(expected), nfd(actual) expected = nfd(%Q(

    #{text}

    )) actual = nfd(page.formatted_data) # UTF-8 headers should not be encoded. assert_html_equal expected, actual end test "create and read non-latin page with anchor 2" do # href="#한글" # href="#%ED%95%9C%EA%B8%80" check_h1 '한글', '1' # href="#Synhtèse" # href="#Synht%C3%A8se" check_h1 'Synhtèse', '2' end test "create and read non-latin page with anchor 3" do @wiki.write_page("test", :markdown, "# \"La\" faune d'édiacara") page = @wiki.page("test") assert_equal Gollum::Page, page.class assert_equal "# \"La\" faune d'édiacara", utf8(page.raw_data) # markup.rb test: ', ", É doc = Nokogiri::HTML page.formatted_data h1s = doc / :h1 h1 = h1s.first anchors = h1 / :a assert_equal 1, h1s.size assert_equal 1, anchors.size assert_equal %q(#la-faune-d-édiacara), anchors[0]['href'] assert_equal %q(la-faune-d-édiacara), anchors[0]['id'] assert_equal 'anchor', anchors[0]['class'] assert_equal '', anchors[0].text end test "unicode with existing format rules" do @wiki.write_page("test", :markdown, "# 한글") assert_equal @wiki.page("test").path, @wiki.page("test").path end end gollum-lib-v4.2.7.10.gitlab.1/test/test_wiki.rb000664 000000 000000 00000104044 13737324223 021073 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ require File.expand_path(File.join(File.dirname(__FILE__), "helper")) context "Wiki" do setup do @wiki = Gollum::Wiki.new(testpath("examples/lotr.git")) Gollum::Wiki.markup_classes = nil end test "#markup_class gets default markup" do assert_equal Gollum::Markup, Gollum::Wiki.markup_class end test "#default_markup_class= doesn't clobber alternate markups" do custom = Class.new(Gollum::Markup) custom_md = Class.new(Gollum::Markup) Gollum::Wiki.markup_classes = Hash.new Gollum::Markup Gollum::Wiki.markup_classes[:markdown] = custom_md Gollum::Wiki.default_markup_class = custom assert_equal custom, Gollum::Wiki.default_markup_class assert_equal custom, Gollum::Wiki.markup_classes[:orgmode] assert_equal custom_md, Gollum::Wiki.markup_classes[:markdown] end test "repo path" do assert_equal testpath("examples/lotr.git"), @wiki.path end test "git repo" do assert_equal Gollum::Git::Repo, @wiki.repo.class assert @wiki.exist? end test "shows paginated log with no page" do Gollum::Wiki.per_page = 3 commits = @wiki.repo.commits[0..2].map(&:id) assert_equal commits, @wiki.log.map { |c| c.id } end test "shows paginated log with 1st page" do Gollum::Wiki.per_page = 3 commits = @wiki.repo.commits[0..2].map(&:id) assert_equal commits, @wiki.log(:page => 1).map(&:id) end test "shows paginated log with next page" do Gollum::Wiki.per_page = 3 commits = @wiki.repo.commits[3..5].map(&:id) assert_equal commits, @wiki.log(:page => 2).map(&:id) end test "list pages" do pages = [ 'Bilbo-Baggins.md', 'Gondor/Boromir.md', 'Hobbit.md', 'Home.textile', 'Mordor/Eye-Of-Sauron.md', 'Mordor/todo.txt', 'My-Precious.md', 'RingBearers.md', 'Rivendell/Elrond.md', 'Samwise Gamgee.mediawiki' ] assert_equal pages, @wiki.pages.map(&:path) assert_equal pages.reverse, @wiki.pages(direction_desc: true).map(&:path) end test "list pages sorted by date with limit", :skip_grit do first_pages = ["Bilbo Baggins", "Eye Of Sauron", "todo", "Home", "My Precious", "Samwise Gamgee"] last_pages = ["RingBearers", "Hobbit", "Elrond", "Boromir", "Samwise Gamgee", "My Precious"] assert_equal first_pages, @wiki.pages(limit: 6, sort: "created_at").map(&:name) assert_equal last_pages, @wiki.pages(limit: 6, sort: "created_at", direction_desc: true).map(&:name) end test "list pages sorted by date with limit from a particular reference", :skip_grit do sha = '0ed8cbe0a25235bd867e65193c7d837c66b328ef' first_pages = ["Bilbo Baggins", "Eye Of Sauron", "todo", "Home", "My Precious"] last_pages = ["My Precious", "Home", "todo", "Eye Of Sauron", "Bilbo Baggins"] assert_equal first_pages, @wiki.pages(sha, limit: 6, sort: "created_at").map(&:name) assert_equal last_pages, @wiki.pages(sha, limit: 6, sort: "created_at", direction_desc: true).map(&:name) end test "list files" do files = @wiki.files assert_equal \ ['Data-Two.csv', 'Data.csv', 'Riddles.rd', 'eye.jpg'], files.map(&:filename).sort end test "counts pages" do assert_equal 10, @wiki.size end test "latest changes in repo" do assert_equal @wiki.latest_changes({:max_count => 1}).first.id, "a3e857e03ecc69a99f1dd72dc3f7e0c47602a05a" end test "text_data" do wiki = Gollum::Wiki.new(testpath("examples/yubiwa.git")) if String.instance_methods.include?(:encoding) utf8 = wiki.page("strider").text_data assert_equal Encoding::UTF_8, utf8.encoding sjis = wiki.page("sjis").text_data(Encoding::SHIFT_JIS) assert_equal Encoding::SHIFT_JIS, sjis.encoding else page = wiki.page("strider") assert_equal page.raw_data, page.text_data end end test "gets scoped page from specified directory" do @path = cloned_testpath('examples/lotr.git') begin wiki = Gollum::Wiki.new(@path) index = wiki.repo.index index.read_tree 'master' index.add('Foobar/Elrond.md', 'Baz') index.commit 'Add Foobar/Elrond.', [wiki.repo.head.commit], Gollum::Git::Actor.new('Tom Preston-Werner', 'tom@github.com') assert_equal 'Rivendell/Elrond.md', wiki.page('Elrond', nil, 'Rivendell').path # test paged as well. assert_equal 'Foobar/Elrond.md', wiki.paged('Elrond', 'Foobar').path ensure FileUtils.rm_rf(@path) end end end context "Wiki page previewing" do setup do @path = testpath("examples/lotr.git") Gollum::Wiki.default_options = { :universal_toc => false } @wiki = Gollum::Wiki.new(@path) end test "preview_page" do page = @wiki.preview_page("Test", "# Bilbo", :markdown) assert_equal "# Bilbo", page.raw_data assert_html_equal "

    Bilbo

    ", page.formatted_data assert_equal "Test.md", page.filename assert_equal "Test", page.name assert_equal @wiki.repo.commit(@wiki.ref).id, page.version.id assert_nil page.last_version assert page.versions.empty? end end context "Wiki TOC" do setup do @path = testpath("examples/lotr.git") options = { :universal_toc => true } @wiki = Gollum::Wiki.new(@path, options) end test "empty TOC" do page = @wiki.preview_page("Test", "[[_TOC_]] [[_TOC_|levels = 2]] Bilbo", :markdown) assert_html_equal "

    Bilbo

    ", page.formatted_data assert_empty page.toc_data end test "toc_generation" do page = @wiki.preview_page("Test", "# Bilbo", :markdown) assert_equal "# Bilbo", page.raw_data assert_html_equal "

    Bilbo

    ", page.formatted_data assert_html_equal %{
    Table of Contents
    }, page.toc_data end test "TOC with levels" do content = <<-MARKDOWN # Ecthelion ## Denethor ### Boromir ### Faramir MARKDOWN formatted = <<-HTML

    Ecthelion

    Denethor

    Boromir

    Faramir

    HTML page_level0 = @wiki.preview_page("Test", "[[_TOC_ | levels=0]] \n\n" + content, :markdown) toc_formatted_level0 = <<-HTML

    Table of Contents

    HTML assert_html_equal toc_formatted_level0 + formatted, page_level0.formatted_data page_level1 = @wiki.preview_page("Test", "[[_TOC_ | levels=1]] \n\n" + content, :markdown) toc_formatted_level1 = <<-HTML

    Table of Contents

    HTML assert_html_equal toc_formatted_level1 + formatted, page_level1.formatted_data page_level2 = @wiki.preview_page("Test", "[[_TOC_ |levels = 2]] \n\n" + content, :markdown) toc_formatted_level2 = <<-HTML

    Table of Contents

    HTML assert_html_equal toc_formatted_level2 + formatted, page_level2.formatted_data page_level3 = @wiki.preview_page("Test", "[[_TOC_ |levels = 3]] \n\n" + content, :markdown) page_level4 = @wiki.preview_page("Test", "[[_TOC_ |levels = 4]] \n\n" + content, :markdown) page_fulltoc = @wiki.preview_page("Test", "[[_TOC_]] \n\n" + content, :markdown) toc_formatted_full = <<-HTML

    Table of Contents

    HTML assert_html_equal toc_formatted_full + formatted, page_level3.formatted_data assert_html_equal toc_formatted_full + formatted, page_level3.formatted_data assert_html_equal toc_formatted_full + formatted, page_fulltoc.formatted_data end # Ensure ' creates valid links in TOC # Incorrect: # Correct: test "' in link" do page = @wiki.preview_page("Test", "# a'b", :markdown) assert_equal "# a'b", page.raw_data assert_html_equal "

    a'b

    ", page.formatted_data assert_html_equal %{
    Table of Contents
    }, page.toc_data end end context "Wiki TOC in _Sidebar.md" do setup do @path = testpath("examples/test.git") FileUtils.rm_rf(@path) Gollum::Git::Repo.init_bare(@path) options = { :universal_toc => true } @wiki = Class.new(Gollum::Wiki).new(@path, options) end test "_Sidebar.md with [[_TOC_]] renders TOC" do cd = commit_details @wiki.write_page("Gollum", :markdown, "# Gollum", cd) page = @wiki.page("Gollum") @wiki.write_page("_Sidebar", :markdown, "[[_TOC_]]", cd) sidebar = @wiki.page("_Sidebar") sidebar.parent_page = page assert_not_equal "\n", sidebar.formatted_data assert_html_equal "

    Table of Contents

    \n", sidebar.formatted_data end teardown do FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w(examples test.git))) end end context "Wiki page writing" do setup do @path = testpath("examples/test.git") FileUtils.rm_rf(@path) Gollum::Git::Repo.init_bare(@path) @wiki = Gollum::Wiki.new(@path) end test "write_page", :skip_grit do cd = commit_details @wiki.write_page("Gollum", :markdown, "# Gollum", cd) assert_equal 1, @wiki.repo.commits.size assert_equal cd[:message], @wiki.repo.commits.first.message assert_equal cd[:name], @wiki.repo.commits.first.author.name assert_equal cd[:email], @wiki.repo.commits.first.author.email cd2 = { :message => "Updating Bilbo", :author => "Samwise" } @wiki.write_page("Bilbo", :markdown, "# Bilbo", cd2) commits = @wiki.repo.commits first_commit = commits.first assert_equal 2, commits.size assert_equal cd2[:message], first_commit.message assert_equal cd2[:name], first_commit.author.name assert_equal cd2[:email], first_commit.author.email assert @wiki.page("Bilbo") assert @wiki.page("Gollum") end test "write page is not allowed to overwrite file" do @wiki.write_page("Abc-Def", :markdown, "# Gollum", commit_details) assert_raises Gollum::DuplicatePageError do @wiki.write_page("ABC DEF", :textile, "# Gollum", commit_details) end end test "write_page does not mutate input parameters" do name = "Hello There" @wiki.write_page(name, :markdown, 'content', commit_details) assert_equal name, "Hello There" end test "write_page replaces spaces with hyphens and keeps special characters" do @wiki.write_page(title_with_special_characters, :markdown, 'content', commit_details) page = @wiki.page(title_with_special_characters) assert_not_nil page assert_equal title_with_special_characters, page.title assert_equal "#{title_with_special_characters.gsub(' ', '-')}.md", page.path end test "update_page" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) page = @wiki.page("Gollum") @wiki.update_page(page, page.name, :markdown, "# Smeagol", { :message => "Leave now, and never come back!", :name => "Smeagol", :email => "smeagol@example.org" }) commits = @wiki.repo.commits # FIXME Grit commits ordering is not predictable. See #13. # The following line should be: first_commit = commits.first first_commit = commits.find { |c| c.author.name == "Smeagol" } assert_equal 2, commits.size assert_equal "# Smeagol", @wiki.page("Gollum").raw_data assert_equal "Leave now, and never come back!", first_commit.message assert_equal "Smeagol", first_commit.author.name assert_equal "smeagol@example.org", first_commit.author.email end test "update page is not allowed to overwrite file with name change" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) @wiki.write_page("Smeagel", :markdown, "# Smeagel", commit_details) page = @wiki.page("Gollum") assert_raises Gollum::DuplicatePageError do @wiki.update_page(page, 'Smeagel', :markdown, "h1. Gollum", commit_details) end end if $METADATA test "page title override with metadata" do @wiki.write_page("Gollum", :markdown, "", commit_details) page = @wiki.page("Gollum") assert_equal 'Over', page.url_path_title end end test "update page with format change" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) assert_equal :markdown, @wiki.page("Gollum").format page = @wiki.page("Gollum") @wiki.update_page(page, page.name, :textile, "h1. Gollum", commit_details) assert_equal 2, @wiki.repo.commits.size assert_equal :textile, @wiki.page("Gollum").format assert_equal "h1. Gollum", @wiki.page("Gollum").raw_data end test "update page with name change" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) assert_equal :markdown, @wiki.page("Gollum").format page = @wiki.page("Gollum") @wiki.update_page(page, 'Smeagol', :markdown, "h1. Gollum", commit_details) assert_equal 2, @wiki.repo.commits.size assert_equal "h1. Gollum", @wiki.page("Smeagol").raw_data end test "update page with name and format change" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) assert_equal :markdown, @wiki.page("Gollum").format page = @wiki.page("Gollum") @wiki.update_page(page, 'Smeagol', :textile, "h1. Gollum", commit_details) assert_equal 2, @wiki.repo.commits.size assert_equal :textile, @wiki.page("Smeagol").format assert_equal "h1. Gollum", @wiki.page("Smeagol").raw_data end test "update nested page with format change" do index = @wiki.repo.index index.add("lotr/Gollum.md", "# Gollum") index.commit("Add nested page") page = @wiki.page("Gollum") assert_equal :markdown, @wiki.page("Gollum").format @wiki.update_page(page, page.name, :textile, "h1. Gollum", commit_details) page = @wiki.page("Gollum") assert_equal "lotr/Gollum.textile", page.path assert_equal :textile, page.format assert_equal "h1. Gollum", page.raw_data end test "update_page replaces spaces with hyphens and keeps special characters" do @wiki.write_page('test', :markdown, 'test', commit_details) page = @wiki.page('test') @wiki.update_page(page, title_with_special_characters, :markdown, 'content', commit_details) page = @wiki.page(title_with_special_characters) assert_not_nil page assert_equal title_with_special_characters, page.title assert_equal "#{title_with_special_characters.gsub(' ', '-')}.md", page.path end test "delete root page" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) page = @wiki.page("Gollum") @wiki.delete_page(page, commit_details) assert_equal 2, @wiki.repo.commits.size assert_nil @wiki.page("Gollum") end test "delete nested page" do index = @wiki.repo.index index.add("greek/Bilbo-Baggins.md", "hi") index.add("Gollum.md", "hi") index.commit("Add alpha.jpg") page = @wiki.page("Bilbo-Baggins") assert page @wiki.delete_page(page, commit_details) assert_equal 2, @wiki.repo.commits.size assert_nil @wiki.page("Bilbo-Baggins") assert @wiki.page("Gollum") end teardown do FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w(examples test.git))) end end context "Wiki search" do setup do @path = testpath("examples/test.git") FileUtils.rm_rf(@path) Gollum::Git::Repo.init_bare(@path) @wiki = Class.new(Gollum::Wiki).new(@path) @wiki.write_page("bar", :markdown, "bar", commit_details) @wiki.write_page("filename:with:colons", :markdown, "# Filename with colons", commit_details) @wiki.write_page("foo", :markdown, "# File with query in contents and filename\nfoo", commit_details) end test "search results should be able to return a filename with an embedded colon" do results = @wiki.search("colons") assert_not_nil results assert_equal "filename:with:colons", results.first[:name] assert_equal 2, results.first[:count] end test "search results should make the content/filename search additive" do # There is a file that contains the word 'foo' and is called 'foo', so it should # have a count of 2, not 1... results = @wiki.search("foo") assert_equal 2, results.first[:count] end test "search results should not include files that do not match the query" do results = @wiki.search("foo") assert_equal 1, results.size assert_equal "foo", results.first[:name] end teardown do FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w(examples test.git))) end end context "Wiki page writing with whitespace (filename contains whitespace)" do setup do @path = cloned_testpath("examples/lotr.git") @wiki = Gollum::Wiki.new(@path) end test "update_page" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, page.name, :textile, "h1. Samwise Gamgee2", commit_details) assert_equal :textile, @wiki.page("Samwise Gamgee").format assert_equal "h1. Samwise Gamgee2", @wiki.page("Samwise Gamgee").raw_data assert_equal "Samwise-Gamgee.textile", @wiki.page("Samwise Gamgee").filename end test "update page with format change, verify non-canonicalization of filename, where filename contains Whitespace" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, page.name, :textile, "h1. Samwise Gamgee", commit_details) assert_equal :textile, @wiki.page("Samwise Gamgee").format assert_equal "h1. Samwise Gamgee", @wiki.page("Samwise Gamgee").raw_data assert_equal "Samwise-Gamgee.textile", @wiki.page("Samwise Gamgee").filename end test "update page with name change, verify canonicalization of filename, where filename contains Whitespace" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, 'Sam Gamgee', :textile, "h1. Samwise Gamgee", commit_details) assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename end test "update page with name and format change, verify canonicalization of filename, where filename contains Whitespace" do assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, 'Sam Gamgee', :textile, "h1. Samwise Gamgee", commit_details) assert_equal :textile, @wiki.page("Sam Gamgee").format assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename end teardown do FileUtils.rm_rf(@path) end end context "Wiki sync with working directory" do setup do @path = testpath('examples/wdtest') Gollum::Git::Repo.init(@path) @wiki = Gollum::Wiki.new(@path) end test "write a page" do @wiki.write_page("New Page", :markdown, "Hi", commit_details) assert_equal "Hi", File.read(File.join(@path, "New-Page.md")) end test "write a page in subdirectory" do @wiki.write_page("New Page", :markdown, "Hi", commit_details, "Subdirectory") assert_equal "Hi", File.read(File.join(@path, "Subdirectory", "New-Page.md")) end test "update a page with same name and format" do @wiki.write_page("New Page", :markdown, "Hi", commit_details) page = @wiki.page("New Page") @wiki.update_page(page, page.name, page.format, "Bye", commit_details) assert_equal "Bye", File.read(File.join(@path, "New-Page.md")) end test "update a page with different name and same format" do @wiki.write_page("New Page", :markdown, "Hi", commit_details) page = @wiki.page("New Page") @wiki.update_page(page, "New Page 2", page.format, "Bye", commit_details) assert_equal "Bye", File.read(File.join(@path, "New-Page-2.md")) assert !File.exist?(File.join(@path, "New-Page.md")) end test "update a page with same name and different format" do @wiki.write_page("New Page", :markdown, "Hi", commit_details) page = @wiki.page("New Page") @wiki.update_page(page, page.name, :textile, "Bye", commit_details) assert_equal "Bye", File.read(File.join(@path, "New-Page.textile")) assert !File.exist?(File.join(@path, "New-Page.md")) end test "update a page with different name and different format" do @wiki.write_page("New Page", :markdown, "Hi", commit_details) page = @wiki.page("New Page") @wiki.update_page(page, "New Page 2", :textile, "Bye", commit_details) assert_equal "Bye", File.read(File.join(@path, "New-Page-2.textile")) assert !File.exist?(File.join(@path, "New-Page.md")) end test "delete a page" do @wiki.write_page("New Page", :markdown, "Hi", commit_details) page = @wiki.page("New Page") @wiki.delete_page(page, commit_details) assert !File.exist?(File.join(@path, "New-Page.md")) end teardown do FileUtils.rm_r(@path) end end context "Wiki sync with working directory (filename contains whitespace)" do setup do @path = cloned_testpath("examples/lotr.git") @wiki = Gollum::Wiki.new(@path) end test "update a page with same name and format" do page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, page.name, page.format, "What we need is a few good taters.", commit_details) assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Samwise Gamgee.mediawiki")) end test "update a page with different name and same format" do page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, "Sam Gamgee", page.format, "What we need is a few good taters.", commit_details) assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Sam-Gamgee.mediawiki")) assert !File.exist?(File.join(@path, "Samwise Gamgee")) end test "update a page with same name and different format" do page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, page.name, :textile, "What we need is a few good taters.", commit_details) assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Samwise-Gamgee.textile")) assert !File.exist?(File.join(@path, "Samwise-Gamgee.mediawiki")) end test "update a page with different name and different format" do page = @wiki.page("Samwise Gamgee") @wiki.update_page(page, "Sam Gamgee", :textile, "What we need is a few good taters.", commit_details) assert_equal "What we need is a few good taters.", File.read(File.join(@path, "Sam-Gamgee.textile")) assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki")) end test "delete a page" do page = @wiki.page("Samwise Gamgee") @wiki.delete_page(page, commit_details) assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki")) end teardown do FileUtils.rm_r(@path) end end context "page_file_dir option" do setup do @path = cloned_testpath('examples/page_file_dir') @page_file_dir = 'docs' @wiki = Gollum::Wiki.new(@path, :page_file_dir => @page_file_dir) end test "write a page in sub directory" do @wiki.write_page("New Page", :markdown, "Hi", commit_details) assert_equal "Hi", File.read(File.join(@path, @page_file_dir, "New-Page.md")) assert !File.exist?(File.join(@path, "New-Page.md")) end test "edit a page in a sub directory" do page = @wiki.page('foo') @wiki.update_page(page, page.name, page.format, 'new contents', commit_details) end test "a file in page file dir should be found" do assert @wiki.page("foo") end test "a file out of page file dir should not be found" do assert !@wiki.page("bar") end test "search results should be restricted in page filer dir" do results = @wiki.search("foo") assert_equal 1, results.size assert_equal "docs/foo", results[0][:name] end teardown do FileUtils.rm_r(@path) end end context "Wiki page writing with different branch" do setup do @path = testpath("examples/test.git") FileUtils.rm_rf(@path) @repo = Gollum::Git::Repo.init_bare(@path) @wiki = Gollum::Wiki.new(@path) # We need an initial commit to create the master branch # before we can create new branches cd = commit_details @wiki.write_page("Gollum", :markdown, "# Gollum", cd) # Create our test branch and check it out @repo.update_ref("test", @repo.commits.first.id) @branch = Gollum::Wiki.new(@path, :ref => "test") end teardown do FileUtils.rm_rf(@path) end test "write_page" do @branch.write_page("Bilbo", :markdown, "# Bilbo", commit_details) assert @branch.page("Bilbo") assert @wiki.page("Gollum") assert_equal 1, @wiki.repo.commits.size assert_equal 1, @branch.repo.commits.size assert_equal nil, @wiki.page("Bilbo") end end context "Renames directory traversal" do setup do @path = cloned_testpath("examples/revert.git") @wiki = Gollum::Wiki.new(@path) end teardown do FileUtils.rm_rf(@path) end test "rename aborts on nil" do res = @wiki.rename_page(@wiki.page("some-super-fake-page"), "B", rename_commit_details) assert !res, "rename did not abort with non-existant page" res = @wiki.rename_page(@wiki.page("B"), "", rename_commit_details) assert !res, "rename did not abort with empty rename" res = @wiki.rename_page(@wiki.page("B"), nil, rename_commit_details) assert !res, "rename did not abort with nil rename" end test "rename page no-act" do # Make sure renames don't do anything if the name is the same even with blanks @wiki.write_page("page title", :markdown, "# page title content", commit_details) res = @wiki.rename_page(@wiki.page("page-title"), "page title", rename_commit_details) assert !res, "NOOP rename did not abort" end test "rename page without directories" do # Make sure renames work with relative paths. source = @wiki.page("B") # B.md => C.md assert @wiki.rename_page(source, "C", rename_commit_details) assert_renamed source, @wiki.page("C") end test "rename page containing space without directories" do # Make sure renames involving spaces work with relative paths. source = @wiki.page("B") # B.md => C D.md assert @wiki.rename_page(source, "C D", rename_commit_details) assert_renamed source, @wiki.page("C D") end test "rename page with subdirs" do # Make sure renames in subdirectories happen ok source = @wiki.paged("H", "G") # G/H.md => G/F.md assert @wiki.rename_page(source, "G/F", rename_commit_details) assert_renamed source, @wiki.paged("F", "G") end test "rename page containing space with subdir" do # Make sure renames involving spaces in subdirectories happen ok source = @wiki.paged("H", "G") # G/H.md => G/F H.md assert @wiki.rename_page(source, "G/F H", rename_commit_details) assert_renamed source, @wiki.paged("F H", "G") end test "rename page absolute path is still no-act" do # Make sure renames don't do anything if the name is the same. # B.md => B.md res = @wiki.rename_page(@wiki.page("B"), "/B", rename_commit_details) assert !res, "NOOP rename did not abort" end test "rename page absolute path NOOPs ok" do # Make sure renames don't do anything if the name is the same and we are in a subdirectory. source = @wiki.paged("H", "G") # G/H.md => G/H.md res = @wiki.rename_page(source, "/G/H", rename_commit_details) assert !res, "NOOP rename did not abort" end test "rename page absolute directory" do # Make sure renames work with absolute paths. source = @wiki.page("B") # B.md => C.md assert @wiki.rename_page(source, "/C", rename_commit_details) assert_renamed source, @wiki.page("C") end test "rename page with space absolute directory" do # Make sure renames involving spaces work with absolute paths. source = @wiki.page("B") # B.md => C D.md assert @wiki.rename_page(source, "/C D", rename_commit_details) assert_renamed source, @wiki.page("C D") end test "rename page absolute directory with subdirs" do # Make sure renames in subdirectories happen ok source = @wiki.paged("H", "G") # G/H.md => G/F.md assert @wiki.rename_page(source, "/G/F", rename_commit_details) assert_renamed source, @wiki.paged("F", "G") end test "rename page containing space absolute directory with subdir" do # Make sure renames involving spaces in subdirectories happen ok source = @wiki.paged("H", "G") # G/H.md => G/F H.md assert @wiki.rename_page(source, "/G/F H", rename_commit_details) assert_renamed source, @wiki.paged("F H", "G") end test "rename page relative directory with new dir creation" do # Make sure renames in subdirectories create more subdirectories ok source = @wiki.paged("H", "G") # G/H.md => G/K/F.md assert @wiki.rename_page(source, "K/F", rename_commit_details) new_page = @wiki.paged("F", "K") assert_not_nil new_page assert_renamed source, new_page end test "rename page relative directory with new dir creation containing space" do # Make sure renames involving spaces in subdirectories create more subdirectories ok source = @wiki.paged("H", "G") # G/H.md => G/K L/F.md assert @wiki.rename_page(source, "K L/F", rename_commit_details) new_page = @wiki.paged("F", "K L") assert_not_nil new_page assert_renamed source, new_page end test "rename page absolute directory with subdir creation" do # Make sure renames in subdirectories create more subdirectories ok source = @wiki.paged("H", "G") # G/H.md => G/K/F.md assert @wiki.rename_page(source, "/G/K/F", rename_commit_details) new_page = @wiki.paged("F", "G/K") assert_not_nil new_page assert_renamed source, new_page end test "rename page absolute directory with subdir creation containing space" do # Make sure renames involving spaces in subdirectories create more subdirectories ok source = @wiki.paged("H", "G") # G/H.md => G/K L/F.md assert @wiki.rename_page(source, "/G/K L/F", rename_commit_details) new_page = @wiki.paged("F", "G/K L") assert_not_nil new_page assert_renamed source, new_page end test "rename page with a name of an already existing page does not clobber that page" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) @wiki.write_page("Smeagel", :markdown, "# Smeagel", commit_details) page = @wiki.page("Gollum") assert_raises Gollum::DuplicatePageError do @wiki.rename_page(page, 'Smeagel', rename_commit_details) end end def assert_renamed(page_source, page_target) @wiki.clear_cache assert_nil @wiki.paged(page_source.name, page_source.path) assert_equal "INITIAL\n\nSPAM2\n", page_target.raw_data assert_equal "def", page_target.version.message assert_equal "Smeagol", page_target.version.author.name assert_equal "smeagol@example.org", page_target.version.author.email assert_not_equal page_source.version.sha, page_target.version.sha end def rename_commit_details { :message => "def", :name => "Smeagol", :email => "smeagol@example.org" } end end context "Wiki subclassing" do setup do @path = testpath("examples/test.git") FileUtils.rm_rf(@path) Gollum::Git::Repo.init_bare(@path) @wiki = Class.new(Gollum::Wiki).new(@path) end test "wiki page can be written by subclass" do details = commit_details @wiki.write_page("Gollum", :markdown, "# Gollum", details) page = @wiki.page("Gollum") first_commit = @wiki.repo.commits.first assert_equal 1, @wiki.repo.commits.size assert_equal details[:name], first_commit.author.name assert_equal details[:email], first_commit.author.email assert_equal details[:message], first_commit.message assert_equal "# Gollum", page.raw_data end test "wiki page can be updated by subclass" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) page = @wiki.page("Gollum") @wiki.update_page(page, page.name, :markdown, "# Smeagol", { :name => "Smeagol", :email => "smeagol@example.org", :message => "Leave now, and never come back!" }) page = @wiki.page("Gollum") first_commit = @wiki.repo.commits.find { |c| c.author.name == "Smeagol" } assert_equal 2, @wiki.repo.commits.size assert_equal "Smeagol", first_commit.author.name assert_equal "smeagol@example.org", first_commit.author.email assert_equal "Leave now, and never come back!", first_commit.message assert_equal "# Smeagol", page.raw_data end test "wiki page can be deleted by subclass" do @wiki.write_page("Gollum", :markdown, "# Gollum", commit_details) page = @wiki.page("Gollum") @wiki.delete_page(page, commit_details) page = @wiki.page("Gollum") assert_equal 2, @wiki.repo.commits.size assert_nil page end teardown do FileUtils.rm_r(File.join(File.dirname(__FILE__), *%w(examples test.git))) end end gollum-lib-v4.2.7.10.gitlab.1/test/wiki_factory.rb000664 000000 000000 00000001003 13737324223 021552 0ustar00rootroot000000 000000 # ~*~ encoding: utf-8 ~*~ class WikiFactory def self.create(p, opt = {}) path = testpath(p) Gollum::Git::Repo.init_bare(path) Gollum::Wiki.default_options = { :universal_toc => false }.merge(opt) cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w(examples test.git)) } wiki = Gollum::Wiki.new(path) # set 'wiki-' prefix on ids for tests wiki.sanitization.id_prefix = 'wiki-' return wiki, path, cleanup end end