Giter Club home page Giter Club logo

gollum-lib's Introduction

gollum -- A git-based Wiki

Gem Version Build Status Open Source Helpers Cutting Edge Dependency Status Docker Pulls

See the wiki for extensive documentation, along with screenshots of Gollum's features.

DESCRIPTION

Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a git repository of a specific nature:

  • A Gollum repository's contents are human-editable text or markup files.

  • Pages may be organized into directories any way you choose.

  • Other content can also be included, for example images, PDFs and headers/footers for your pages.

  • Gollum pages:

    • May be written in a variety of markups.
    • Can be edited with your favourite editor (changes will be visible after committing) or with the built-in web interface.
    • Can be displayed in all versions, reverted, etc.
  • Gollum strives to be compatible with GitHub and GitLab wikis.

    • Just clone your GitHub/GitLab wiki and view and edit it locally!
  • Gollum supports advanced functionality like:

SYSTEM REQUIREMENTS

Gollum runs both on Unix-like systems and on Windows.

Gollum runs either using 'normal' Ruby (MRI) or JRuby (Ruby on the Java Virtual Machine). On Windows, Gollum runs only using JRuby (either from source, or prebuilt).

On MRI, Gollum uses the rugged git library, while on JRuby/Java it utilizes the rjgit and JGit libraries. See here for more info.

INSTALLATION

As a Ruby Gem

Ruby is best installed either via RVM or a package manager of choice. Then simply: gem install gollum

Installation examples for individual systems can be seen here.

To run, simply:

  1. Run: gollum /path/to/wiki where /path/to/wiki is an initialized Git repository.
  2. Open http://localhost:4567 in your browser.

Via Docker

See here for instructions on how to run Gollum via Docker.

As a web application resource (Java)

The latest Release of Gollum will always contain a downloadable gollum.war file that can be directly executed on any system with a working Java installation:

java -jar gollum.war -S gollum <your-gollum-arguments-here>

Misc

See below for information on running Gollum from source, as a Rack app, and more.

MARKUPS

Gollum allows using different markup languages on different wiki pages. It presently ships with support for the following markups:

You can easily activate support for other markups by installing additional renderers (any that are supported by github-markup):

  • AsciiDoc -- gem install asciidoctor
  • Creole -- gem install creole
  • MediaWiki -- gem install wikicloth
  • Org -- gem install org-ruby
  • Pod -- requires Perl >= 5.10 (the perl command must be available on your command line)
    • Lower versions should install Pod::Simple from CPAN.
  • ReStructuredText -- requires python >= 3
    • Note that Gollum will also need you to install docutils for python
  • Textile -- gem install RedCloth

Markdown flavors

By default, Gollum ships with the kramdown gem to render Markdown. However, you can use any Markdown renderer supported by github-markup. This includes CommonMark support via the commonmarker gem. The first installed renderer from the list will be used (e.g., redcarpet will NOT be used if github/markdown is installed). Just gem install the renderer of your choice.

See here for instructions on how to use custom rendering gems and set custom options.

RUNNING FROM SOURCE

  1. git clone https://github.com/gollum/gollum
  2. cd gollum
  3. [sudo] bundle install
  4. bundle exec bin/gollum
  5. Open http://localhost:4567 in your browser.

Rack

Gollum can also be run with any rack-compatible web server. More on that over here.

Rack, with an authentication server

Gollum can also be run alongside a CAS (Central Authentication Service) SSO (single sign-on) server. With a bit of tweaking, this adds basic user-support to Gollum. To see an example and an explanation, navigate over here.

Service

Gollum can also be run as a service. More on that over here.

ENVIRONMENT

Gollum uses the environment variable APP_ENV primarily to control how the underlying Sinatra app behaves:

  • development – reload the app on every request
  • production – load the app only once

CONFIGURATION

Gollum comes with the command line options listed below. Note that there are some additional 'minor' options to tweak Gollum's behaviour that do not have commandline options, but can be configured in config.rb.

Option Arguments Description
--host [HOST] Specify the hostname or IP address to listen on. Default: '0.0.0.0'.1
--port [PORT] Specify the port to bind Gollum with. Default: 4567.
--config [FILE] Specify path to Gollum's configuration file.
--ref [REF] Specify the git branch to serve. Default: master.
--bare none Tell Gollum that the git repository should be treated as bare.
--adapter [ADAPTER] Launch Gollum using a specific git adapter. Default: rugged.2
--base-path [PATH] Specify the leading portion of all Gollum URLs (path info). Setting this to /wiki will make the wiki accessible under http://localhost:4567/wiki/. Default: /.
--page-file-dir [PATH] Specify the subdirectory for all pages. If set, Gollum will only serve pages from this directory and its subdirectories. Default: repository root.
--static, --no-static none Use static assets. Defaults to false in development/test, true in production/staging.
--assets [PATH] Set the path to look for static assets.
--css none Tell Gollum to inject custom CSS into each page. Uses custom.css from wiki root.3
--js none Tell Gollum to inject custom JS into each page. Uses custom.js from wiki root.3
--no-edit none Disable the feature of editing pages.
--allow-uploads [MODE] Enable file uploads. If set to dir, Gollum will store all uploads in the /uploads/ directory in repository root. If set to page, Gollum will store each upload at the currently edited page.4
--math [RENDERER] Enable rendering of mathematical equations. Valid renderers: mathjax, katex. Default: katex. Add custom configuration for the renderer to math.config.js and commit it to the repo.
--critic-markup none Enable support for annotations using CriticMarkup.
--irb none Launch Gollum in "console mode", with a predefined API.
--h1-title none Tell Gollum to use the first <h1> as page title.
--no-display-metadata none Do not render metadata tables in pages.
--user-icons [MODE] Tell Gollum to use specific user icons for history view. Can be set to gravatar, identicon or none. Default: none.
--template-dir [PATH] Specify custom mustache template directory. Only overrides templates that exist in this directory.
--template-page none Use _Template in root as a template for new pages. Must be committed.
--emoji none Parse and interpret emoji tags (e.g. :heart:) except when the leading colon is backslashed (e.g. \:heart:).
--lenient-tag-lookup none Internal links resolve case-insensitively, will treat spaces as hyphens, and will match the first page found with a certain filename, anywhere in the repository. Provides compatibility with Gollum 4.x.
--help none Display the list of options on the command line.
--version none Display the current version of Gollum.
--versions none Display the current version of Gollum and auxiliary gems.

Notes:

  1. The 0.0.0.0 IP address allows remote access. Should you wish for Gollum to turn into a personal Wiki, use 127.0.0.1.
  2. Before using --adapter, you should probably read this first.
  3. When --css or --js is used, respective files must be committed to your git repository or you will get a 302 redirect to the create a page.
  4. Files can be uploaded simply by dragging and dropping them onto the editor's text area when --allow-uploads is used.

Config file

When --config option is used, certain inner parts of Gollum can be customized. This is used throughout our wiki for certain user-level alterations, among which customizing supported markups will probably stand out.

See here for documentation about settings configurable in config.rb.

All of the mentioned alterations and options work both for Gollum's config file (config.rb) and Rack's config file (config.ru).

CONTRIBUTING

Please consider helping out! See CONTRIBUTING for information on how to submit issues, and how to start hacking on gollum.

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

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.

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?

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

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?

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

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

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.

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

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?

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

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?

Gollum org icon

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

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

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.

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.

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.

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'

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.

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,

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?

`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
 [...]

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

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.

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.

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.

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 :(...

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

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>

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.

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.

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

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.

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.

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.

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)

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.