GithubHelp home page GithubHelp logo

gollum-lib's Introduction

gollum lib -- A wiki built on top of Git

Gem Version Ruby Build Cutting Edge Dependency Status

DESCRIPTION

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 and uses TomDoc for inline documentation.

SYSTEM REQUIREMENTS

  • Ruby 2.4.0+
  • Unix like operating system (OS X, Ubuntu, Debian, and more)
  • Will not work on Windows with the default rugged adapter, but works via JRuby.

INSTALLATION

The best way to install Gollum-lib is with RubyGems:

$ [sudo] gem install gollum-lib

If you're installing from source, you can use Bundler to pick up all the gems:

$ 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.

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 for all of Gollum's formats and syntactic options.

API DOCUMENTATION

Initialize the Gollum::Repo object:

# 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")
# => <Gollum::Wiki>

By default, internal wiki links are all absolute from the root. To specify a different base path, you can specify the :base_path option:

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:

page = wiki.page('/page name') # Finds pages in the root directory of the wiki that are named 'page name' with a valid extension.
# => <Gollum::Page>

page = wiki.page('page name') # For convenience, you can leave out the '/' in front. Paths are assumed to be relative to '/'.
# => <Gollum::Page>

page = wiki.page('page name.md') # You can also specifiy the extension explicitly to disambiguate between pages with the same name, but different formats.
# => <Gollum::Page>

page.raw_data
# => "# My wiki page"

page.formatted_data
# => "<h1>My wiki page</h1>"

page.format
# => :markdown

vsn = page.version
# => <Gollum::Git::Commit>

vsn.id
# => '3ca43e12377ea1e32ea5c9ce5992ec8bf266e3e5'

Get the footer (if any) for a given page:

page.footer
# => <Gollum::Page>

Get the header (if any) for a given page:

page.header
# => <Gollum::Page>

Get a list of versions for a given page:

vsns = wiki.page('page-name').versions
# => [<Gollum::Git::Commit, <Gollum::Git::Commit, <Gollum::Git::Commit>]

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:

wiki.page('page name', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')

Get the latest version of a given static file:

file = wiki.file('asset.js')
# => <Gollum::File>

file.raw_data
# => "alert('hello');"

file.version
# => <Gollum::Git::Commit>

Get a specific version of a given static file:

wiki.file('asset.js', '5ec521178e0eec4dc39741a8978a2ba6616d0f0a')

Get an in-memory Page preview (useful for generating previews for web interfaces):

preview = wiki.preview_page("My Page", "# Contents", :markdown)
preview.formatted_data
# => "<h1>Contents</h1>"

Methods that write to the repository require a Hash of commit data that takes the following form:

commit = { :message => 'commit message',
           :name => 'Tom Preston-Werner',
           :email => '[email protected]' }

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 if no subdirectory is specified.

wiki.write_page('Subdirectory/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.

page = wiki.page('Page Name')
wiki.update_page(page, page.name, page.format, 'Page contents', commit)

To delete a page and commit the change:

wiki.delete_page(page, commit)

Register or unregister a hook to be called after a page commit:

Gollum::Hook.register(:post_commit, :hook_id) do |committer, sha1|
  # Your code here
end

Gollum::Hook.unregister(:post_commit, :hook_id)

Register or unregister a hook to be called after the wiki is initialized:

Gollum::Hook.register(:post_wiki_initialize, :hook_id) do |wiki|
  # Your code here
end

Gollum::Hook.unregister(:post_wiki_initialize, :hook_id)

A combination of both hooks can be used to pull from a remote after :post_wiki_initialize and push to a remote after :post_commit which in effect keeps the remote in sync both ways. Keep in mind that it may not be possible to resolve all conflicts automatically.

WINDOWS FILENAME VALIDATION

Note that filenames on windows must not contain any of the following characters \ / : * ? " < > |. See this support article for details.

CONTRIBUTE

If you'd like to hack on Gollum-lib, start by forking the repo on GitHub:

http://github.com/gollum/gollum-lib

To get all of the dependencies, install the gem first. The best way to get your changes merged back into core is as follows:

  1. Clone down your fork
  2. Create a thoughtfully named topic branch to contain your change
  3. Hack away
  4. Add tests and make sure everything still passes by running rake
  5. If you are adding new functionality, document it in the README
  6. Do not change the version number, I will do that on my end
  7. If necessary, rebase your commits into logical chunks, without errors
  8. Push the branch up to GitHub
  9. Send a pull request to the gollum/gollum-lib project.

RELEASING

Gollum-lib uses Semantic Versioning. Having x.y.z :

For z releases:

$ rake bump
$ rake release

For x.y releases:

$ rake gemspec
$ rake release

BUILDING THE GEM FROM MASTER

$ 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

$ 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.

$ 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's People

Contributors

arr2036 avatar atmos avatar atrost avatar bartkamphorst avatar blmarket avatar bootstraponline avatar cpence avatar david-macmahon avatar dazoakley avatar dekimsey avatar dometto avatar henrikh avatar jhominal avatar jip149 avatar josacar avatar josh avatar keithduncan avatar kristi avatar mojombo avatar mpalmer avatar mrjoy avatar pipex avatar rgroux avatar simonista avatar sunny avatar technoweenie avatar timtim123456 avatar trans avatar vmg avatar zoramite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gollum-lib's Issues

AsciiDoc h3 headers are broken

First off, sorry for the onslaught of AsciiDoc-related Issues...

Asciidoctor includes backwards compatibility with old AsciiDoc headers. Unfortunately, kramdown-style code blocks use conflicting syntax, so this will break rendering.

Header
~~~~~~ // should become an h3 header

(Even more fun, I just discovered that using kramdown-style code block syntax inside of GFM code blocks breaks GitHub comments. -.-)

I propose simply turning off kramdown-style code blocks when @markup.format == :asciidoc. Any objections?

Webrick Error if using pygments and a lexer is not found

If pygments is installed and a page contains a code block that specifies a lexer that does not exist, the page will not load and will throw an exception:

2015-05-22 08:32:31 - MentosError - Traceback (most recent call last):
  File "/var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/mentos.py", line 303, in start
    res = self.get_data(method, lexer, args, kwargs, text)
  File "/var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/mentos.py", line 171, in get_data
    res = self.highlight_text(text, lexer, formatter_name, args, _convert_keys(opts))
  File "/var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/mentos.py", line 122, in highlight_text
    lexer = self.return_lexer(lexer, args, kwargs, code)
  File "/var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/mentos.py", line 79, in return_lexer
    return lexers.get_lexer_by_name(lexer, **inputs)
  File "/var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/vendor/pygments-main/pygments/lexers/__init__.py", line 98, in get_lexer_by_name
    raise ClassNotFound('no lexer for alias %r found' % _alias)
ClassNotFound: no lexer for alias 'markdown' found
:
        /var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/popen.rb:405:in `header_to_json'
        /var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/popen.rb:287:in `handle_header_and_return'
        /var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/popen.rb:262:in `block in mentos'
        /usr/lib/ruby/1.9.1/timeout.rb:69:in `timeout'
        /var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/popen.rb:233:in `mentos'
        /var/lib/gems/1.9.1/gems/pygments.rb-0.6.3/lib/pygments/popen.rb:215:in `highlight'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/filter/code.rb:80:in `block in process'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/filter/code.rb:71:in `each'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/filter/code.rb:71:in `process'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/markup.rb:120:in `block in process_chain'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/markup.rb:119:in `each'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/markup.rb:119:in `process_chain'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/markup.rb:159:in `render'
        /var/lib/gems/1.9.1/gems/gollum-lib-4.0.3/lib/gollum-lib/page.rb:225:in `formatted_data'
        /var/lib/gems/1.9.1/gems/gollum-4.0.0/lib/gollum/app.rb:492:in `show_page_or_file'
        /var/lib/gems/1.9.1/gems/gollum-4.0.0/lib/gollum/app.rb:480:in `block in <class:App>'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1610:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1610:in `block in compile!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:974:in `[]'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:974:in `block (3 levels) in route!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:993:in `route_eval'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:974:in `block (2 levels) in route!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1014:in `block in process_route'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1012:in `catch'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1012:in `process_route'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:972:in `block in route!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:971:in `each'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:971:in `route!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1084:in `block in dispatch!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `block in invoke'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `catch'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `invoke'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1081:in `dispatch!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:906:in `block in call!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `block in invoke'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `catch'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `invoke'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:906:in `call!'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:894:in `call'
        /var/lib/gems/1.9.1/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
        /var/lib/gems/1.9.1/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
        /var/lib/gems/1.9.1/gems/omniauth-1.2.2/lib/omniauth/builder.rb:59:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        /var/lib/gems/1.9.1/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:225:in `context'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/session/abstract/id.rb:220:in `call'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/nulllogger.rb:9:in `call'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/head.rb:13:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/show_exceptions.rb:21:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:181:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:2021:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1486:in `block in call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1795:in `synchronize'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1486:in `call'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/handler/webrick.rb:89:in `service'
        /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
        /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
        /usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
[2015-05-22 08:32:31] ERROR ArgumentError: invalid byte sequence in US-ASCII
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/utils.rb:241:in `gsub'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/utils.rb:241:in `escape_html'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/showexceptions.rb:103:in `h'
        (erb):169:in `block (2 levels) in pretty'
        (erb):168:in `each'
        (erb):168:in `block in pretty'
        (erb):155:in `each'
        (erb):155:in `pretty'
        /usr/lib/ruby/1.9.1/erb.rb:838:in `eval'
        /usr/lib/ruby/1.9.1/erb.rb:838:in `result'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/showexceptions.rb:97:in `pretty'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/show_exceptions.rb:30:in `rescue in call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/show_exceptions.rb:21:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:181:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:2021:in `call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1486:in `block in call'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1795:in `synchronize'
        /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1486:in `call'
        /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/handler/webrick.rb:89:in `service'
        /usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
        /usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
        /usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

Found this when investigating gollum/gollum#1015

gollum-rails to join gollum organisation

I would have written to a person (since it's not really an issue of gollum-lib) but don't know to whom.
So i'm using this as a sort of message board, sorry.

Florian (nirnanaaa) has what seems the most "live" gollum rails. It is more like a library though.
He also has a gollum_redmine though, that off course being redmine focused.

Together we were going to make his gollum_rails a "modern" rails engine by folding some of the redmine code and writing new engine related stuff.

Now it looks like gollum-lib is in the process of extracting the backend of gollum, and gollum will be "just"
a sinatra front end.

So i was wondering, since we are doing this rails front-end, it could be under the gollum organization.
Since organizations have good access control, we could be restricted to the rails part for starters.
But since we'd all be working on similar things, joining the organization would make sense to me.

Torsten

Clear separation of gollum-lib, adapter specs and adapters

Hey @dometto ,

i just delved into how things work on the lowest level of Gollum (gollum-lib and the underlying git layer) and I'd like to ask your opinion on the current situation.

To me, it seems (but I may be wrong) overly complicated/confusing and (again :( ) a bit of a mess, especially because of the following:

  1. Some bits seem to be defined in gollum-lib and some others in the git layer and both pieces are used in the other...
  2. Currently, there are 2 adapters working with gollum (with a third on the way), both of which seem to conform to adapter_specs.

In my opinion:

  • Things like Gollum::BlobEntry should be moved from gollum-lib to adapter_specs (gollum-lib should require and use an adapter, just like it is now, but all git-related types and methods should be defined there),
  • adapter_specs seems overly complicated and should be rewritten (but I may be wrong on this one),
  • I imagine it would be a lot better if adapter_specs defined fully documented communication between underlying git layer and gollum-lib (types and module methods), instead of some "vague descriptions" (if possible, of course). In other words:
    • gollum-lib would only reference methods and instance variables defined in adapter_specs and its types,
    • all methods of adapter_specs should only define arguments and return objects of types predefined in adapter_specs (or primitive types),
    • all methods that require custom implementation should have their skeleton defined (and documented) in adapter_specs.

I think that this way:

  • the separation would work so much better,
  • tuning and updating the API would be so much easier,
  • development of new adapters would be so much easier (if only by having part of the code included from adapter_specs or forking it directly).

While the current solution may not be as bad as I picture it and I may be the one having problems here, has anyone given any consideration to the above in the past?

I don't mean to offend or criticize anyone and especially you, so don't take it personally please, but I'm actually very surprised you (all of you) got Gollum working like this. The way I see Gollum, so much of it adds so much complexity for further development/maintenance and makes the developers (including me, as it would seem) spend so much more time in the process :(...

AsciiDoc link/include paths are relative from repo root

Because all pages are rendered from the root of the git repository Gollum is serving from, AsciiDoc relative link and include paths don't function as they should.

An easy fix is to wrap this line in a chdir block like this:

Dir.chdir(@markup.dir) do
  data = GitHub::Markup.render(@markup.name, data)
end

I'm not sure if that would break any other markup language's rendering, though. Thoughts on whether this should be implemented for all languages, just AsciiDoc, or not at all?

Tables not getting rendered correctly

While developing a redmine plugin for my gollum_rails plugin I found out that tables are not getting displayed correctly:

I have the following markdown part:

   Name  |  Nummer    
   ------ | -------      
   Test |   1234
   Test2  |    345  

which renders correctly here on github:

Name Nummer
Test 1234
Test2 345

But if i render this through formatted_data, I get this result:

<p>Name  |  Nummer<br>
   ------ | -------<br>
   Test |  1234
   Test2  |  345    </p>

Everything else is rendered correctly.

Redcarpet and gollum_rails are installed.

Is there a way to pass arguments to the render? Redcarpet e.g. has the option :tables => true

Am I doing anything wrong or have I missed a part?

Thanks,

nirnanaaa

Filter::TOC untransparently removing <p> tags

I was experimenting with gollum-lib under JRuby, and noticed test failures of the following kind:
"<pre class=\"highlight\">'hi'</pre>" expected to be HTML equivalent to "<p><pre class=\"highlight\">'hi'</pre>\n</p>"
The <p> tags in the output are somehow getting stripped on MRI. I finally managed to trace this to this point in the filter chain, in Filter::TOC. On MRI nokogiri, that line effectively changes data of the form "<p>***</p>" to "<p></p>***. The remaining "<p></p>" are then removed at the end of the filter chain processing. On JRuby, this is not happening because of a nokogiri issue.

Regardless of the prospects of getting the tests passing on JRuby, this raises some questions:

  • Is the way we are now stripping the <p> tags actually expected behavior by nokogiri? Is it happening by design or good luck?
  • If the <p>'s need to be stripped, surely the TOC filter is a bad place to do it. It took me a long time to figure out where this was happening. Filter::TOC is now obscurely performing a function which is essential to the passing of the tests, but totally unrelated to its stated purpose of filtering [TOC].

Release 1.0.4 breaks semantic versioning

Commit eeb0a4a updated the dependency on nokogiri to version 1.6.0, which requires Ruby >= 1.9.2. Dropping support for Ruby 1.8 seems like too big of a change for either a minor or patch version increment.

Also, the README is out of date (not to mention the README for gollum itself).

write_page() throws an Encoding::CompatibilityError for chinese characters

Hey,

I am trying to fix an issue, where the page name is something chinese: ไฝ ๆ˜ฏๆˆ‘็š„ไธญๅ…ณๆ˜Ÿ. Saving the page via:

class B

  def self.test(wiki, name)

    canonicalized_filename = Gollum::Page.canonicalize_filename(name)
    format = :markdown
    content = "abc"
    commit = {
      name: "nirnanaaa",
      email: "[email protected]",
      message: "created abc"
    }
    path_name = "/"

    wiki.write_page(canonicalized_filename, format, content, commit, path_name)
  end
end

wiki = User.wiki
 => #<Gollum::Wiki:70304539248780 /Volumes/Documents/GollumRails4Test/demoapp.git>

2.1.2 :003 > name = "ไฝ ๆ˜ฏๆˆ‘็š„ไธญๅ…ณๆ˜Ÿ"

2.1.2 :003 > B.test(wiki)
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:176:in `%'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:176:in `block in write_tree'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:171:in `each'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:171:in `write_tree'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:123:in `commit'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gollum-lib-3.0.0/lib/gollum-lib/committer.rb:170:in `commit'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gollum-lib-3.0.0/lib/gollum-lib/wiki.rb:340:in `write_page'
    from /Volumes/Documents/chin.rb:24:in `test'
    from (irb):3
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/console.rb:90:in `start'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/console.rb:9:in `start'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
... 3 levels...
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/commands/rails.rb:6:in `call'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/command_wrapper.rb:38:in `call'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:180:in `block in serve'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:153:in `fork'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:153:in `serve'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/nirnanaaa/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/nirnanaaa/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'2.1.2 :004 >

I have then edited the file gitlab-grit/lib/grit/index.rb at line 176 and changing the [tmode, obj.name, sha] to [tmode, obj.name, sha.force_encoding("UTF-8")] works, but is not a good practice.

Some tests:

  • Create a page with the filename in english and the content in englisch - WORKS
  • Create a page with the filename in english and the content in chinese - WORKS
  • Create a page with the filename in chinese and the content in english - DOES NOT WORK

After trying to create the page with write_page once, each single of those tests in the current session will fail:

2.1.2 :007 >   name = "testpage"
 => "testpage"
2.1.2 :008 > B.test(wiki, name)
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:176:in `%'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:176:in `block in write_tree'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:171:in `each'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:171:in `write_tree'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gitlab-grit-2.6.12/lib/grit/index.rb:123:in `commit'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gollum-lib-3.0.0/lib/gollum-lib/committer.rb:170:in `commit'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/gollum-lib-3.0.0/lib/gollum-lib/wiki.rb:340:in `write_page'
    from /Volumes/Documents/chin.rb:24:in `test'
    from (irb):3
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/console.rb:90:in `start'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/console.rb:9:in `start'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
... 3 levels...
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/commands/rails.rb:6:in `call'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/command_wrapper.rb:38:in `call'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:180:in `block in serve'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:153:in `fork'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:153:in `serve'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
    from /Users/nirnanaaa/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/nirnanaaa/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/nirnanaaa/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'2.1.2 :004 >

Debugging things a little further I found the following:

    now_tree.contents.each do |obj|
        sha = [obj.id].pack("H*")
        k = obj.name
        k += '/' if (obj.class == Grit::Tree)
        tmode = obj.mode.to_i.to_s  ## remove zero-padding
        debugger
        tree_contents[k] = "%s %s\0%s" % [tmode, obj.name, sha]
      end if

(rdb:1) tmode.encoding
#<Encoding:US-ASCII>
(rdb:1) tmode
"100644"
(rdb:1) obj.name.encoding
#<Encoding:UTF-8>
(rdb:1) obj.name
"ไฝ ๆ˜ฏๆˆ‘็š„ไธญๅ…ณๆ˜Ÿ.md"
(rdb:1) sha.encoding
#<Encoding:ASCII-8BIT>

the emergence of Chinese, and then throws the Exception.

Hope someone can help.

Thanks a lot

bugfix version bump?

There are a few small things that were fixed ages ago but I keep running into via the gem. (Today, I debugged only to find that #82 already had a fix pulled in from May.)

4.0 doesn't look imminent, maybe we can get a 3.0.1?

Patch to re-enable metadata

For a patch to re-enable metadata, please see:

https://gist.github.com/anonymous/5675858

This is a simplistic Hash parser, but it works for basic metadata purposes which seems better than having no metadata support at all. The following examples show how to set a page title using metadata.

All on one line:

<!-- --- title: My Fantastic Page -->

Or split across multiple lines:

<!-- ---
title: My Fantastic Page
-->

Notes:

  1. Only one key/value pair per line. Multiple lines must be used for multiple key/value pairs (though I'm not aware of support for any keys other than "title").
  2. Keys and values cannot contain embedded newlines.
  3. The patch does not HTML-sanitize the key or value portion of the metadata. Presumably metadata is not solely for inclusion in HTML, so only the user of the metadata will know whether it needs to be sanitized in any way.

Crop large anchor ID's

This is an example of a generated anchor ID on the wiki I'm working on:

Manual/prefs#preferences_editor-preferences_smart-editing_configuring-word-or-character-wrap

It's veeery long, too long. Could this be handled more intelligently? eg. it seems to be including all parent headers in the anchor, this seems unnecessary. Additionally it would be nice if we could force a max length for these anchors, and have it crop if the max length is reached.

I understand the main reason for this is to ensure the anchor is unique, but you could also generate a hash based on the current information used and append this.

Far as I'm aware these hashes don't affect SEO, so there should be no concerns there.

Gollum org icon

Gollum's organization is using a default icon. It'd be nice to have a real icon.

Security Contact

Hi,

this is kind of a "meta" issue, but I was wondering where I can
disclose a security issue in gollum? Due to the severity of the issue
I don't want to just put it in this public issue tracker.

thx,

joernchen

`rc` branch breaks gollum test

Running the gollum tests against the rc branch of gollum-lib results in one failure in test_app.rb, test "UTF-8 headers href preserved":

Expected /<h2><a class="anchor" id="\u1112\u1161\u11AB\u1100\u1173\u11AF" href="#\u1112\u1161\u11AB\u1100\u1173\u11AF"><i class="fa fa-link"><\/i><\/a>\u1112\u1161\u11AB\u1100\u1173\u11AF<\/h2>/
to match
"<!DOCTYPE html>\n<html>\n<head>\n 
[...]
 <h2><a class=\"anchor\" id=\"_แ„’แ…กแ†ซแ„€แ…ณแ†ฏ\" href=\"#_แ„’แ…กแ†ซแ„€แ…ณแ†ฏ\"><i class=\"fa fa-link\"></i></a>แ„’แ…กแ†ซแ„€แ…ณแ†ฏ</h2>\n\n    </div>\n
 [...]

Wikis allow git pushes with illegal filenames

moved from: gollum/gollum#881

I've been using GitLab, and it uses Gollum for the wikis. Gollum is quite picky about the slugs (URLs) of its pages. The slugs get generated automatically from filenames in its underlying Git repository. Right now a user can do the following:

create a wiki;
download the wiki via Git;
create a file 'a&b.markdown';
git push;
go to the wiki pages index for the project.
The result will be a 500 due to a 'routing error', which seems to be the fault of the '&'.

This seems to be an issue with Gollum and not GitLab, because Gollum is allowing the creation of a file with an illegal filename.

Add an after commit hook for updating repo

I've been setting Gollum up on a little Debian box here so it can be used as a shared wiki resource. I'd like it to be able to accept wiki amends through either the web interface (a single centrally served one, not a localhost instance each), or through individual markdown edits and git commits.

For the web service to keep in sync though, I need it to do a pull/push on commit - I understand that this might create merge conflicts if someone else is editing that page at the same time, but I think the risk of that is low at the moment, and I can live with it.

I've created this gist of how I've hacked it to work at the moment:

https://gist.github.com/urlsangel/5411081

I also need some way for the server to pull the latest whenever a new session is started.

I'm a Ruby noob so am feeling my way along in this - any thoughts on what the best way to do this would be?

Better Search

At the moment search returns page names and number of matches, this makes finding what you're looking for still rather painful. It would be much better if it could return the actual matched content.

I understand this is probably a challenge because you don't want to be returning the raw source to the end user, and if you cut out a line it may not parse properly if you want to attempt to convert it to html. It's a challenge but imo it's one that'll need to be overcome.

Standardise the reporting of rendering errors

The new macro syntax added by #51 introduces a number of places where rendering errors can occur and need to be reported cleanly without affecting rendering of the rest of the page. Ideally this behaviour should be standardised across the whole wiki so errors occurring from other parts of the rendering stack can be similarly reported.

Improve assert_html_equal

assert_html_equal was added to do a semantic comparison of two HTML documents in such a way that the comparison wouldn't be affected by whitespace. There are apparently some issues with it, necessitating workarounds i.e. 8f07a5b 9821bf2. It is important that this method is improved and the workarounds removed as it is heavily used in markup tests.

AsciiDoc includes don't work in ---- code blocks

As an example, this won't render correctly:

----
include::other-file.asciidoc[]
----

The problem is that Gollum parses AsciiDoc code blocks before rendering with Asciidoctor. This is done so that Gollum can apply syntax highlighting to the code blocks, but Asciidoctor can handle that itself.

The solution that I have found involves removing the line I linked to and overloading github-markup's AsciiDoc markup function to use pygments syntax highlighting. (I also use the :safe => :safe option to make include work at all, but that's a security vulnerability that needs to be looked at more carefully.) Then I change template.css to accept Asciidoctor's custom pygments class names (it prefixes each class with 'tok-').

Any opinions on how to implement a better fix? I can submit a PR if this seems like a reasonable solution.

Custom Tags in Gollum ??

I'd like to add new tags to Gollum. For example, the tag '<$ text $>' should return TEXT (just the upcased string...).

Is there a simple way for me to define a custom tag? From my reading, it looks like I'll have to monkey-patch Gollum::Markup. Is there a better/cleaner way to add a custom tag?

Thanks in advance, Andy

Empty H1 element causes the TOC code to raise a NilClass exception

When rendering the following (ill-formed) markdown, an exception is raised in the TOC generation code. This occurs because the h1 element has no children (the heading has no text). This can be reproduced by pasting this markdown into an page and clicking preview. The [[_TOC_]] tag is not being used within the markdown.

An empty <h1></h1> element will cause the TOC code to raise and exception 

=======
NoMethodError - undefined method `before' for nil:NilClass:
    [...]/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:52:in `before'
    [...]/gollum-lib-3.0.0/lib/gollum-lib/filter/toc.rb:31:in `block in process'
    [...]/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:237:in `block in each'
    [...]/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `upto'
    [...]/nokogiri-1.6.1/lib/nokogiri/xml/node_set.rb:236:in `each'
    [...]/gollum-lib-3.0.0/lib/gollum-lib/filter/toc.rb:12:in `process'
    [...]/gollum-lib-3.0.0/lib/gollum-lib/markup.rb:116:in `block in process_chain'
    [...]/gollum-lib-3.0.0/lib/gollum-lib/markup.rb:115:in `each'
    [...]/gollum-lib-3.0.0/lib/gollum-lib/markup.rb:115:in `process_chain'
    [...]/gollum-lib-3.0.0/lib/gollum-lib/markup.rb:155:in `render'
    [...]/gollum-lib-3.0.0/lib/gollum-lib/page.rb:219:in `formatted_data'
    [...]/gollum-3.0.0/lib/gollum/app.rb:334:in `block in <class:App>'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
    [...]/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
    [...]/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
    [...]/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
    [...]/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    [...]/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    [...]/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
    [...]/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
    [...]/rack-1.5.2/lib/rack/head.rb:11:in `call'
    [...]/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
    [...]/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
    [...]/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
    [...]/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
    [...]/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
    [...]/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
    [...]/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'

Replace pygments.rb (which depends on posix-spawn and python)?

Hi there -

The pygments.rb wrapper gem introduces a dependency in gollum-lib on posix-spawn (and Python). Are there any principled objections against replacing pygments.rb with something like Rouge?

Another option would be to move highlighting to gollum and handle it client-side. But the move to Rouge seems like it would be straightforward. Any thoughts?

Rails 4.2.0 Compatibility

Hello,

I am trying to integrate the gollum-lib gem with a Rails 4.2.0 app.
Unfortunately I am facing 2 problems :

Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Bundler could not find compatible versions for gem "mime-types":
  In Gemfile:
    gollum-lib (>= 0) ruby depends on
      grit (~> 2.5.0) ruby depends on
        mime-types (~> 1.15) ruby

    rails (= 4.2.0) ruby depends on
      actionmailer (= 4.2.0) ruby depends on
        mail (>= 2.5.4, ~> 2.5) ruby depends on
          mime-types (2.4.3)

Bundler could not find compatible versions for gem "nokogiri":
  In Gemfile:
    gollum-lib (>= 0) ruby depends on
      nokogiri (~> 1.5.6) ruby

    jquery-rails (>= 0) ruby depends on
      rails-dom-testing (~> 1.0) ruby depends on
        nokogiri (1.6.6.2)

My working project is new, here is the Gemfile :

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Wiki
gem 'gollum-lib'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

Best regards,

gollum-lib 2.0.0 breaks [[__TOC__]]

This is relative to this bug:

gollum/gollum#814

gollum 2.7.0 broke adding the table of contents to the sidebar and I bisected it to the change to gollum-lib 2.0.0. I've since bisected gollum-lib itself and the commit that introduced it was this one:

https://github.com/anchor/gollum-lib/commit/6073b85ef0d9a71e9525b8446aaeb2850d5fc173

Here's the code I used to test this:

#!/usr/bin/env ruby

require "./gollum-lib/lib/gollum-lib.rb"

wiki = Gollum::Wiki.new("MyWikiPath")
page = wiki.page('_Sidebar')
puts page.formatted_data

_Sidebar is a _Sidebar.md file containing just:

[[_TOC_]]

When working properly the output of the script is:

<p>[[_TOC_]]</p>

otherwise it's just an empty line.

Allow serving wiki from subdirectory

Instead of base_path argument which just modifies the links, would it be possible to introduce an argument that would change directory which gollum-lib considers as root?

It would be very convenient, e.g. for gollum#937.

Macros cannot be nested

I am not sure if this is supposed to be supported or not, but macros cannot be nested (that is, contained within other macros). For example, a file contains the following snippet:

<<Note("There is an example config file located <<SMBLink('here','\\some\server\subdir')>>")>>

I expect the SMBLink macro to be computed (which returns <a class='externallink' href='file://///some/server/subdir' title='here' target='_blank'>here</a>) and added inside of the Note macro.

Instead, it seems that gollum either absorbs the nested macro or fails at parsing it, because it renders something along the lines of

<div style='font: normal 1em/1.5 sans-serif; background-color: rgb(222, 243, 254); border: 1px solid rgb(197, 215, 224); color: black; padding: 5px 5px 5px 45px; margin: 1ex 0pt; min-height: 35px;'>
         <div style='float: left; margin-left: -40px;'><img alt='Note' title='Note' src='/uploads/hgm_images/note.png' width='35' border='0' height='35'></div>
         <div><b>NOTE</b><br>There is an example config file located &gt;</div>
 </div>

Expected Result:

<div style='font: normal 1em/1.5 sans-serif; background-color: rgb(222, 243, 254); border: 1px solid rgb(197, 215, 224); color: black; padding: 5px 5px 5px 45px; margin: 1ex 0pt; min-height: 35px;'>
         <div style='float: left; margin-left: -40px;'><img alt='Note' title='Note' src='/uploads/hgm_images/note.png' width='35' border='0' height='35'></div>
         <div><b>NOTE</b><br>There is an example config file located <a class='externallink' href='file://///some/server/subdir' title='here' target='_blank'>here</a></div>
 </div>

'write_page' creates page with directory in it's name, but 'page' does not find it.

Gitlab creates page using code:

write_page(title, format, content, commit)

Where my title was sub-page/sub-sub-page. This created file sub-page/sub-sub-page.markdown in repository.

After this gitlab tries to find that page using:

paged(title)

but gets nil.

I think that reason for this is that in gollum-lib/page.rb:find_page_in_tree we match name (title here) to filename (not full path) here:

next unless page_match(name, entry.name)

I think it's useless to have dir argument in Gollum methods. I think gollum should supports namespaces/directories using path in name argument.

Automatically detect directory in page name

As per discussion in #10. The separate directory parameter in various methods should be removed and automatically detected in the page name. This will need to be done sympathetically so as to minimise the impact on existing code.

req: version bump

Looks like gollum-lib hasn't been released in some time. Given the changes (#50, #41), I think this qualifies as a major version bump.

Filenames with colons break search page

Steps to repro:

  • Add a page with a ':' in the filename
  • Add some content to the page
  • Search for a term that will cause the page with ':' to be returned

Note that the result list that's built is broken.

undefined method `before' for nil:NilClass

I got an error with gollum-lib 3.0.0:
NoMethodError - undefined method `before' for nil:NilClass
in gollum-lib/filter/toc.rb:33

This is the case for elements like <h1></h1>. It seems that h_name should be checked if it is empty.

Test failing on Arch Linux / Ruby 2.2.0

While investigating #152 and #153 , I found a test from master was failing on my arch box, but not on my ubuntu box. At the request of @dometto, I am opening a separate issue.

[nathan@nathan-arch gollum-lib]$ bundle exec rake test
/usr/bin/ruby -I"lib:lib:test:."  "/usr/lib/ruby/2.2.0/rake/rake_test_loader.rb" "test/**/test_*.rb" 
Loaded suite /usr/lib/ruby/2.2.0/rake/rake_test_loader
Started
.....................................................................................................................................................
...................F
=====================================================================================================================================================
Failure: test_push_and_pull(Pushing_and_pulling)
/home/nathan/projects/gollum-lib/test/test_hook.rb:93:in `block (2 levels) in <top (required)>'
<false> expected but was
<true>

diff:
? false
? tru  
=====================================================================================================================================================
.................................................................................................

Finished in 3.552655921 seconds.
-----------------------------------------------------------------------------------------------------------------------------------------------------
266 tests, 603 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
99.6241% passed
-----------------------------------------------------------------------------------------------------------------------------------------------------
74.87 tests/s, 169.73 assertions/s
rake aborted!
Command failed with status (1): [ruby -I"lib:lib:test:."  "/usr/lib/ruby/2.2.0/rake/rake_test_loader.rb" "test/**/test_*.rb" ]

Tasks: TOP => test
(See full trace by running task with --trace)

Code block not correctly escaped when using pygments

Putting

```bash
sudo patch -p1 < ~/auth.patch
```

in a markdown file causes the remainder of the document to be rendered inside of a <pre> tag. Removing the < character from the code block corrects the problem. This problem is not encountered if pygments.rb is not installed.

no such file to load -- "remote_code"

gollum-lib, when built from a gem crashes with:

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- /home/notes/gollum-install/gems/gems/gollum-lib-0.0.1/lib/gollum-lib/remote_code (LoadError)
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/notes/gollum-install/gems/gems/gollum-lib-0.0.1/lib/gollum-lib/markup.rb:8
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/notes/gollum-install/gems/gems/gollum-lib-0.0.1/lib/gollum-lib.rb:22
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from /home/notes/gollum-install/gems/gems/gollum-2.4.11/lib/gollum/app.rb:4
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from /home/notes/notes-repository/config.ru:3
        from gollum.fcgi:30:in `load'
        from gollum.fcgi:30

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.