From 0f47a4de5d21b9e1edfc0a4b19efb6d69457d04e Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Sat, 8 Aug 2015 15:20:35 +0200 Subject: [PATCH 01/34] Removing config.rb due to being pointless --- config.rb | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 config.rb diff --git a/config.rb b/config.rb deleted file mode 100644 index 3f28df94..00000000 --- a/config.rb +++ /dev/null @@ -1,28 +0,0 @@ -# Example gollum config -# gollum ../wiki --config config.rb -# -# or run from source with -# -# bundle exec bin/gollum ../wiki/ --config config.rb - -# Remove const to avoid -# warning: already initialized constant FORMAT_NAMES -# -# only remove if it's defined. -# constant Gollum::Page::FORMAT_NAMES not defined (NameError) -Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES -# limit to one format -Gollum::Page::FORMAT_NAMES = { :markdown => "Markdown" } - -=begin -Valid formats are: -{ :markdown => "Markdown", - :textile => "Textile", - :rdoc => "RDoc", - :org => "Org-mode", - :creole => "Creole", - :rest => "reStructuredText", - :asciidoc => "AsciiDoc", - :mediawiki => "MediaWiki", - :pod => "Pod" } -=end From c9d5921f4efe5fc48933cb86756227b86d3b402d Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Sat, 8 Aug 2015 15:21:00 +0200 Subject: [PATCH 02/34] Moving docs/sanitization.md to the wiki --- docs/sanitization.md | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 docs/sanitization.md diff --git a/docs/sanitization.md b/docs/sanitization.md deleted file mode 100644 index e23c5dba..00000000 --- a/docs/sanitization.md +++ /dev/null @@ -1,33 +0,0 @@ -Sanitization Rules -================== - -Gollum uses the [Sanitize](http://wonko.com/post/sanitize) gem for HTML -sanitization. Below you find the default allowed tags, attributes, and protocols, as well as directions to customize these settings. - -# Default Settings - -## ALLOWED TAGS - -a, abbr, acronym, address, area, b, big, blockquote, br, button, caption, center, cite, code, col, colgroup, dd, del, dfn, dir, div, dl, dt, em, fieldset, font, form, h1, h2, h3, h4, h5, h6, hr, i, img, input, ins, kbd, label, legend, li, map, menu, ol, optgroup, option, p, pre, q, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var - -## ALLOWED ATTRIBUTES - -a href, abbr, accept, accept-charset, accesskey, action, align, alt, axis, border, cellpadding, cellspacing, char, charoff, class, charset, checked, cite, clear, cols, colspan, color, compact, coords, datetime, dir, disabled, enctype, for, frame, headers, height, hreflang, hspace, id, img src, ismap, label, lang, longdesc, maxlength, media, method, multiple, name, nohref, noshade, nowrap, prompt, readonly, rel, rev, rows, rowspan, rules, scope, selected, shape, size, span, start, summary, tabindex, target, title, type, usemap, valign, value, vspace, width - -## ALLOWED PROTOCOLS - -* a href: http, https, mailto, ftp, irc, apt, :relative -* img src: http, https, :relative -* form action: http, https, :relative - -# Customizing - -To customize these settings, edit your `config.rb` file along the following lines (be sure to run gollum with the `--config` option): - -```ruby -sanitizer = Gollum::Sanitization.new -sanitizer.protocols['a']['href'].concat ['ssh', 'vnc'] # Protocols -sanitizer.elements.concat ['customtag1', 'customtag2'] # Tags -sanitizer.attributes['a'].push 'target' # Attributes -Precious::App.set(:wiki_options, {:sanitization => sanitizer}) -``` From b4c70a62a9815df082d7c1486754db9055f2a4c6 Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Sat, 8 Aug 2015 15:21:30 +0200 Subject: [PATCH 03/34] Removing Home.md due to being a mere lorem ipsum --- Home.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Home.md diff --git a/Home.md b/Home.md deleted file mode 100644 index 6edf0edb..00000000 --- a/Home.md +++ /dev/null @@ -1,3 +0,0 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vulputate tincidunt sollicitudin. Quisque sit amet leo sed nunc eleifend rhoncus in consectetur leo. Vivamus posuere semper convallis. Duis malesuada lacus sed erat lobortis tincidunt mattis ligula consectetur. Sed aliquam vulputate eros at euismod. Aenean egestas lorem ligula, quis faucibus turpis. Curabitur a eros in ipsum gravida ornare. Sed elementum enim vel mi scelerisque dapibus. Nulla id libero ligula, quis tempus sem. Morbi nec felis tortor, ac cursus risus. Mauris elementum tortor id lacus eleifend non lobortis tellus pharetra. Etiam posuere cursus vestibulum. $x \lt y$ - -Morbi tincidunt dolor vel massa dictum volutpat. Vestibulum quis nibh metus, id tincidunt nisl. Vivamus eget sem ac risus eleifend rhoncus at eu nisl. Nunc elit massa, vulputate ac gravida eget, condimentum quis justo. Integer scelerisque, libero vel consequat ultricies, eros libero sagittis libero, pellentesque bibendum quam massa ut orci. Maecenas sit amet urna eget quam aliquam posuere. Nulla facilisi. Duis imperdiet augue sit amet metus ornare et hendrerit dui feugiat. Aenean a lacus neque. Sed eu enim tincidunt dolor pharetra porttitor. Vestibulum ut felis dui, rutrum iaculis orci. Duis eu bibendum tortor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse mollis sagittis purus sit amet sollicitudin. Phasellus vel interdum erat. \ No newline at end of file From 67c64c17d52ba7f6949665400f4a1fb571fd225a Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Sun, 9 Aug 2015 19:22:16 +0200 Subject: [PATCH 04/34] README makeover --- README.md | 371 +++++++++++++++++++++++++++--------------------------- 1 file changed, 183 insertions(+), 188 deletions(-) diff --git a/README.md b/README.md index 7e04c898..8022b102 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -gollum -- A wiki built on top of Git +gollum -- A git-based Wiki ==================================== [![Gem Version](https://badge.fury.io/rb/gollum.svg)](http://badge.fury.io/rb/gollum) @@ -7,181 +7,208 @@ gollum -- A wiki built on top of Git ## DESCRIPTION -**New: Gollum is now [compatible with JRuby](https://github.com/gollum/gollum/wiki/Git-adapters#rjgit-java). Just run `gem install gollum` to install.** +Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a git repository (either bare or regular) of a specific nature: +* A Gollum repository's contents are human-editable, unless the repository is bare. Pages are unique text files which 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](#markups). + * Can be edited with your favourite system editor or IDE (changes will be visible after committing) or with the built-in web interface. + * Can be displayed in all versions (commits). -Gollum is a simple wiki system built on top of Git. +Gollum can be launched either as a webserver (with the web interface) or in "console mode", where you can use a predefined API to query and manipulate the repository. For more information, see the [Running](#running) and [Configuration](#configuration) sections. -Gollum wikis are simply Git repositories that adhere to a specific format. -Gollum pages may be written in a variety of formats and can be edited in a -number of ways depending on your needs. You can edit your wiki locally: +For more information on Gollum's capabilities and pitfalls: -* With your favorite text editor or IDE (changes will be visible after committing). -* With the built-in web interface. -* With the Gollum Ruby API. - -Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses -[TomDoc](http://tomdoc.org/) for inline documentation. +1. [Syntax/capability overview for pages](https://github.com/gollum/gollum/wiki). +2. [Known limitations](https://github.com/gollum/gollum/wiki/Known-limitations). +3. [Security overview](https://github.com/gollum/gollum/wiki/Security). ## SYSTEM REQUIREMENTS -- Python 2.5+ (2.7.3 recommended) -- Ruby 1.9.3+ (1.9.3 recommended) (JRuby compatible!) -- Unix like operating system (OS X, Ubuntu, Debian, and more) -- Will not work on Windows with the default [grit](https://github.com/github/grit) adapter, but might work via JRuby (please let us know!) +| Operating System | Ruby | Adapters | Supported | +| ---------------- | -------------- | ------------------ | --------- | +| Unix/Linux-like | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | yes | +| Unix/Linux-like | [JRuby](https://github.com/jruby/jruby) (1.9.3+ compatible) | [RJGit](https://github.com/repotag/rjgit) | yes | +| Windows | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | no | +| Windows | [JRuby](https://github.com/jruby/jruby) (1.9.3+ compatible) | [RJGit](https://github.com/repotag/rjgit) | almost1 | -## SECURITY +**Notes:** -Don't enable `--custom-css`, `--custom-js` or `--mathjax-config` unless you trust every user who has the ability to edit the wiki. -A better solution with more security is being tracked in [#665](https://github.com/gollum/gollum/issues/665). +1. There are still some bugs and this setup is not ready for production yet. You can track the progress at #1044. ## INSTALLATION -The best way to install Gollum is with RubyGems: +Varies depending on operating system, package manager and Ruby installation. Generally, you should first install Ruby and then Gollum. -```bash -$ [sudo] gem install gollum -``` -You may first need to install some additional [development packages](https://github.com/gollum/gollum/wiki/Installation) for your OS. +1. Ruby is best installed either via [RVM](https://rvm.io/) or a package manager of choice. +2. Gollum is best installed via RubyGems: + ``` + [sudo] gem install gollum + ``` -If you're installing from source, you can use [Bundler][bundler] to pick up all the -gems: +Installation examples for individual systems can be seen [here](https://github.com/gollum/gollum/wiki/Installation). -```bash -$ bundle install -``` +**Notes:** +* Whichever Ruby implementation you're using, Gollum ships with the appropriate default git adapter. So the above installation procedure is common for both MRI and JRuby. +* If you're installing from source: + * Optionally uninstall any previous versions of Gollum: + ``` + [sudo] gem uninstall -aIx gollum + ``` + * Install [Bundler](http://bundler.io/). + * Navigate to the cloned source of Gollum. + * Install dependencies: + ``` + [sudo] bundle install + ``` + * Build: + ``` + rake build + ``` + * And install: + ``` + [sudo] gem install --no-ri --no-rdoc pkg/gollum*.gem + ``` -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. +### Markups -* [AsciiDoc](http://asciidoctor.org) -- `gem install asciidoctor` -* [Creole](http://www.wikicreole.org/) -- `gem install creole` -* [Markdown](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet` -* [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `gem install github-markdown` -* [Org](http://orgmode.org/) -- `gem install org-ruby` -* [Pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::HTML` comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN. +Gollum presently ships with support for the following markups: +* [Markdown](http://daringfireball.net/projects/markdown/syntax) * [RDoc](http://rdoc.sourceforge.net/) -* [ReStructuredText](http://docutils.sourceforge.net/rst.html) -- `easy_install docutils` -* [Textile](http://en.wikipedia.org/wiki/Textile_(markup_language)) -- `gem install RedCloth` -* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth` -[bundler]: http://gembundler.com/ - - -## SYNTAX - -Gollum supports a variety of formats and extensions (Markdown, MediaWiki, Textile, …). -On top of these formats Gollum lets you insert headers, footers, links, image, math and more. - -Check out the [Gollum Wiki](https://github.com/gollum/gollum/wiki) for all of Gollum's formats and syntactic options. +Since all markups are rendered by the [github-markup](https://github/com/github/markup) gem, you can easily add support for other markups by additional installation: +* [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `[sudo] gem install asciidoctor` +* [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `[sudo] gem install creole` +* [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `[sudo] gem install github-markdown` +* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `[sudo] gem install wikicloth` +* [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `[sudo] gem install org-ruby` +* [Pod](http://perldoc.perl.org/perlpod.html) -- requires Perl >= 5.10 (the `perl` command must be available on your command line) + * Lower versions should install `Pod::Simple` from CPAN. +* [ReStructuredText](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html) -- requires python >= 2 (the `python2` command must be available on your command line) + * Note that Gollum will also need you to install `docutils` for your Python 2. Installation procedure can, again, vary depending on operating system and package manager. +* [Textile](http://redcloth.org/hobix.com/textile/quick.html) -- `[sudo] gem install RedCloth` +By default, Gollum ships with the `kramdown` gem to render Markdown. However, you can use any [Markdown renderer supported by github-markup](https://github.com/github/markup/blob/master/lib/github/markup/markdown.rb). The thing to remember is that the first installed renderer from the list will be used. So, for example, `redcarpet` will NOT be used if `github/markdown` is installed. ## RUNNING -To view and edit your Gollum repository locally via the built in web -interface, simply install the Gollum gem, navigate to your repository via the -command line, and run the executable: +Simply: + +1. Navigate to your git repository (wiki) via the command line. +2. Run: `gollum`. +3. Open `http://localhost:4567` in your browser. + +If you wish to run from source, simply: + +1. Navigate to your git repository (wiki) via the command line. +2. Run: `bundle exec bin/gollum` +3. Open `http://localhost:4567` in your browser. + +This will start up a web server (WEBrick) running Gollum with a web interface, where you can view and edit your wiki. + +### Rack + +Gollum can also be ran with any [rack-compatible web server](https://github.com/rack/rack#supported-web-servers). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack). + +### Docker + +Gollum can also be ran via [Docker](https://www.docker.com/). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Docker). + +### Service + +Gollum can also be ran as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service). + +## CONFIGURATION + +Gollum comes with the following command line options: + +| 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`. | +| --gollum-path | [PATH] | Specify path to the Gollum git repository. Default: current working directory. | +| --config | [CONFIG] | Path to the 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. This is only necessary when using the default grit adapter. | +| --base-path | [PATH] | Specify the leading portion of all page URLs. Default: `/`. For example, if set to `wiki`, all pages will be accessible under `http://localhost:4567/wiki/` by default. | +| --page-file-dir | [PATH] | Specify the subdirectory for all pages. If set, Gollum will only serve pages from this directory. Default: repository root. | +| --css | none | Tell Gollum to inject custom CSS into each page. Uses `custom.css` from repository root.2,4 | +| --js | none | Tell Gollum to inject custom JS into each page. Uses `custom.js` from repository root.2,4 | +| --no-edit | none | Disables the feature of editing pages. | +| --live-preview | none | Enables the live preview feature in page editor. | +| --no-live-preview | none | Disables the live preview feature in page editor. | +| --allow-uploads | [MODE] | Enables file uploads. If set to `dir`, Gollum will store all uploads in the `/uploads/` directory. If set to `page`, Gollum will store each upload at the same location as the page that is currently being edited.3 | +| --template-dir | [PATH] | Specify custom mustache template directory. | +| --show-all | none | Tell Gollum to also show files in the file view. By default, only valid pages are shown. | +| --collapse-tree | none | Tell Gollum to collapse the file tree, when the file view is opened. By default, the tree is expanded. | +| --mathjax | none | Enables MathJax (renders mathematical equations). By default, uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.4 | +| --mathjax-config | [PATH] | Specify path for custom MathJax config. By default, uses `mathjax.config.js` from repository root. | +| --h1-title | none | Tell Gollum to use the first `

` as page title. | +| --adapter | [ADAPTER] | Tell Gollum to use a specific git adapter. Default: `grit`.5 | +| --user-icons | [MODE] | Tell Gollum to use specific user icons. Can be set to `gravatar`, `identicon` or `none`. Default: `none`. | +| --irb | none | Tell Gollum to launch in console mode, with [this API](https://github.com/gollum/gollum-lib/) being available. | +| --help | none | Display the list of options no the command line. | +| --version | none | Display the current version of Gollum. | + +**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. 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. +3. Files can be uploaded simply by dragging and dropping them onto the editor's text area (this is, however exclusive to the default editor, not the live preview editor). +4. Read the relevant [Security note](https://github.com/gollum/gollum/wiki/Security#custom-cssjs--mathjax-config) before using these. +5. Before using `--adapter`, you should probably read [this](https://github.com/gollum/gollum/wiki/Git-adapters) first. + +### 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](https://github.com/gollum/gollum/wiki/Formats-and-extensions) will probably stand out. + +**All of the mentioned alterations work both for Gollum's config file (`config.rb`) and Rack's config file (`config.ru`).** + +## HOW TO CONTRIBUTE + +1. Fork and clone Gollum. +2. Create a thoughtfully named topic branch to contain your changes. +3. If you haven't installed dependencies yet, navigate to your clone and execute: + ``` + [sudo] bundle install + ``` +4. Hack away. +5. Add your own tests and make sure they're all still passing. +6. If some of your changes deserve a mention on Gollum's home page, edit the README accordingly. +7. If necessary, rebase your commits into logical chunks, without errors. +8. Push the branch to your fork on GitHub. +9. Create a pull request for Gollum. + +**Notes:** +* Do not change Gollum's version numbers, we will do that on our own. + +### Running tests + +1. Install [Bundler](http://bundler.io/). +2. Navigate to the cloned source of Gollum. +3. Install dependencies: + ``` + [sudo] bundle install + ``` +4. Run the tests: + ``` + bundle exec rake test + ``` + +### Working with test repositories + +An example of how to add a test file to the bare repository lotr.git. -```bash -$ gollum ``` - -This will start up a web server running the Gollum frontend and you can view -and edit your wiki at http://localhost:4567. To get help on the command line -utility, you can run it like so: - -```bash -$ gollum --help +mkdir tmp +cd tmp +git clone ../lotr.git/ +git log +echo "test" > test.md +git add . +git commit -am "Add test" +git push ../lotr.git/ master ``` -This will show you the options you can pass as arguments to the `gollum` command: - -```bash -Options: - --port [PORT] Bind port (default 4567). - --host [HOST] Hostname or IP address to listen on (default 0.0.0.0). - --version Display current version. - --config [CONFIG] Path to additional configuration file. - --adapter [ADAPTER] Git adapter to use in the backend. Defaults to grit. - --irb Start an irb process with gollum loaded for the current wiki. - --css Inject custom css. Uses custom.css from root repository. - --js Inject custom js. Uses custom.js from root repository. - --template-dir [PATH] Specify custom template directory. - --page-file-dir [PATH] Specify the sub directory for all page files (default: repository root). - --base-path [PATH] Specify the base path for the served pages (default: /) Example: --base-path wiki yields the home page accessible at http://localhost:4567/wiki/. - --gollum-path [PATH] Specify the path to the git repository to be served. - --ref [REF] Specify the repository ref to use (default: master). - --bare Specify that the repository is bare (only necessary when using the grit adapter). - --no-edit Restricts editing capability through frontend. - --no-live-preview Disables livepreview. - --live-preview Enables livepreview. - --allow-uploads [MODE] Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page). - --mathjax Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default. - --mathjax-config [SOURCE] Inject custom mathjax config file. Uses mathjax.config.js from root repository by default. - --user-icons [SOURCE] Set the history user icons. Valid values: gravatar, identicon, none. Default: none. - --show-all Shows all files in file view. By default only valid pages are shown. - --collapse-tree Collapse file view tree. By default, expanded tree is shown. - --h1-title Sets page title to value of first h1. -``` - -Note that the gollum server will not run on Windows because of [an issue](https://github.com/rtomayko/posix-spawn/issues/9) with posix-spawn (which is used by Grit). - -### RACK - -You can also run gollum with any rack-compatible server by configuring a `config.ru` -file. This allows you to utilize any Rack middleware like Rack::Auth, OmniAuth, etc. See below for an example of a `config.ru`. You can define all the [options available on the command line](#running) by configuring the app's `:wiki_options` hash. See [here](https://github.com/gollum/gollum/wiki/Using-Gollum-with-Rack) for the names of the options corresponding to the command line switches. - -```ruby -#!/usr/bin/env ruby -require 'rubygems' -require 'gollum/app' - -gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO -Precious::App.set(:gollum_path, gollum_path) -Precious::App.set(:default_markup, :markdown) # set your favorite markup language -Precious::App.set(:wiki_options, {:universal_toc => false}) -run Precious::App -``` - -Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key. - -## CONFIG FILE - -Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gollum/gollum/blob/master/config.rb) for an example. - -## CUSTOM CSS/JS - -The `--css` flag will inject `custom.css` from the root of your git repository into each page. `custom.css` must be commited to git or you will get a 302 redirect to the create page. - -The `--js` flag will inject `custom.js` from the root of your git repository into each page. `custom.js` must be commited to git or you will get a 302 redirect to the create page. - - -## API DOCUMENTATION - -The [Gollum API](https://github.com/gollum/gollum-lib/) 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. - - -## CONTRIBUTE - -If you'd like to hack on Gollum, start by forking the repo on GitHub: - -http://github.com/gollum/gollum - -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 -1. Create a thoughtfully named topic branch to contain your change -1. Hack away -1. Add tests and make sure everything still passes by running `rake` -1. If you are adding new functionality, document it in the README -1. Do not change the version number, I will do that on my end -1. If necessary, rebase your commits into logical chunks, without errors -1. Push the branch up to GitHub -1. Send a pull request to the gollum/gollum project. - ## RELEASING Gollum uses [Semantic Versioning](http://semver.org/). @@ -190,47 +217,15 @@ Gollum uses [Semantic Versioning](http://semver.org/). For z releases: -```bash -$ rake bump -$ rake release +``` +rake bump +rake release ``` For x.y releases: -```bash -Update VERSION in lib/gollum.rb -$ rake gemspec -$ rake release ``` - -## BUILDING THE GEM FROM MASTER - -```bash -$ gem uninstall -aIx gollum -$ git clone https://github.com/gollum/gollum.git -$ cd gollum -gollum$ rake build -gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem -``` - -## RUN THE TESTS - -```bash -$ bundle install -$ bundle exec rake test -``` - -## WORK WITH TEST REPOS - -An example of how to add a test file to the bare repository lotr.git. - -```bash -$ mkdir tmp; cd tmp -$ git clone ../lotr.git/ . -Cloning into '.'... -done. -$ git log -$ echo "test" > test.md -$ git add . ; git commit -am "Add test" -$ git push ../lotr.git/ master +# First update VERSION in lib/gollum.rb and then: +rake gemspec +rake release ``` From 0a9b35c0392980e7a0aecbe7107e318aef32f3f9 Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Wed, 12 Aug 2015 22:26:20 +0200 Subject: [PATCH 05/34] Restoring config files to repo root --- config.rb | 11 +++++++++++ config.ru | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 config.rb create mode 100644 config.ru diff --git a/config.rb b/config.rb new file mode 100644 index 00000000..9c0a2150 --- /dev/null +++ b/config.rb @@ -0,0 +1,11 @@ +=begin +This file can be used to (e.g.): +- alter certain inner parts of Gollum, +- extend it with your stuff. + +It is especially useful for customizing supported formats/markups. For more information and examples: +- https://github.com/gollum/gollum#config-file + +=end + +# enter your Ruby code here ... diff --git a/config.ru b/config.ru new file mode 100644 index 00000000..48f605a4 --- /dev/null +++ b/config.ru @@ -0,0 +1,12 @@ +=begin +You should use this file, if you wish to: +- launch Gollum as a Rack app, +- alter certain startup behaviour of Gollum. + +For more information and examples: +- https://github.com/gollum/gollum/wiki/Gollum-via-Rack +- https://github.com/gollum/gollum#config-file + +=end + +# enter your Ruby code here ... From c3dceaff5cc729499f9bb14a68f048642aeba82d Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Wed, 12 Aug 2015 22:26:59 +0200 Subject: [PATCH 06/34] Adding reference to the "Troubleshoot" wiki page --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8022b102..65f0b52a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ For more information on Gollum's capabilities and pitfalls: 1. [Syntax/capability overview for pages](https://github.com/gollum/gollum/wiki). 2. [Known limitations](https://github.com/gollum/gollum/wiki/Known-limitations). -3. [Security overview](https://github.com/gollum/gollum/wiki/Security). +3. [Troubleshoot guide](https://github.com/gollum/gollum/wiki/Troubleshoot-guide). +4. [Security overview](https://github.com/gollum/gollum/wiki/Security). ## SYSTEM REQUIREMENTS From 5b6870d61052e1d6ee5832d040b2ad611690a359 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Fri, 14 Aug 2015 11:06:17 +0200 Subject: [PATCH 07/34] Add webrick as development dependency. Fixes #1053. --- gollum.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/gollum.gemspec b/gollum.gemspec index ecfb4818..770cb2f6 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -36,6 +36,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'twitter_cldr', '~> 3.2.0' s.add_development_dependency 'mocha', '~> 1.1.0' s.add_development_dependency 'test-unit', '~> 3.1.0' if RUBY_VERSION =~ /^2.2/ + s.add_development_dependency 'webrick', '~> 1.3.1' # = MANIFEST = s.files = %w[ From 51b5a11a54e799bf8d7b2911e651cc7e7b440c21 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 20 Aug 2015 23:19:25 -0400 Subject: [PATCH 08/34] Fix custom.x path when page-file-dir is not set --- lib/gollum/views/layout.rb | 2 +- test/test_app.rb | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/gollum/views/layout.rb b/lib/gollum/views/layout.rb index d6de7393..e2d14166 100644 --- a/lib/gollum/views/layout.rb +++ b/lib/gollum/views/layout.rb @@ -29,7 +29,7 @@ module Precious end def custom_path - "#{@base_url}#{@page_dir.nil? ? '' : '/'}#{@page_dir}" + "#{@base_url}#{@page_dir.empty? ? '' : '/'}#{@page_dir}" end def css # custom css diff --git a/test/test_app.rb b/test/test_app.rb index 454d4de3..6f1b7294 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -513,10 +513,23 @@ context "Frontend" do { :name => 'user1', :email => 'user1' }); get page - assert_match /custom.js/, last_response.body + assert_match /"\/custom.js"/, last_response.body Precious::App.set(:wiki_options, { :js => nil }) end + test "change custom.css path if page-file-dir is set" do + Precious::App.set(:wiki_options, { :css => true, :page_file_dir => 'docs'}) + page = 'docs/yaycustom' + text = 'customized!' + + @wiki.write_page(page, :markdown, text, + { :name => 'user1', :email => 'user1' }); + + get page + assert_match /"\/docs\/custom.css"/, last_response.body + Precious::App.set(:wiki_options, { :css => nil, :page_file_dir => nil }) + end + test "show edit page with header and footer and sidebar of multibyte" do post "/create", :content => 'りんご', From ddb5ced3d576cb30ecdf1f8ba4f2b22464b82afe Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Sun, 23 Aug 2015 14:43:46 +0200 Subject: [PATCH 09/34] Updating gemspec to reflect recent changes --- gollum.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gollum.gemspec b/gollum.gemspec index ecfb4818..baaeb8ee 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -45,11 +45,11 @@ Gem::Specification.new do |s| README.md Rakefile bin/gollum + config.ru config.rb contrib/openrc/conf.d/gollum contrib/openrc/init.d/gollum contrib/systemd/gollum@.service - docs/sanitization.md gollum.gemspec lib/gollum.rb lib/gollum/app.rb From d1d81a0043a388c2c45b4b2808e03973f2895d69 Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Sun, 23 Aug 2015 14:44:18 +0200 Subject: [PATCH 10/34] Syncing BIN with README + fixes & enhancements --- README.md | 43 +++++---- bin/gollum | 262 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 175 insertions(+), 130 deletions(-) diff --git a/README.md b/README.md index 65f0b52a..4225da23 100644 --- a/README.md +++ b/README.md @@ -126,37 +126,36 @@ Gollum comes with the following command line options: | ----------------- | --------- | ----------- | | --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`. | -| --gollum-path | [PATH] | Specify path to the Gollum git repository. Default: current working directory. | -| --config | [CONFIG] | Path to the configuration file. | +| --config | [FILE] | Specify path to Gollum's configuration file. | | --ref | [REF] | Specify the git branch to serve. Default: `master`. | +| --adapter | [ADAPTER] | Launch Gollum using a specific git adapter. Default: `grit`.2 | | --bare | none | Tell Gollum that the git repository should be treated as bare. This is only necessary when using the default grit adapter. | -| --base-path | [PATH] | Specify the leading portion of all page URLs. Default: `/`. For example, if set to `wiki`, all pages will be accessible under `http://localhost:4567/wiki/` by default. | -| --page-file-dir | [PATH] | Specify the subdirectory for all pages. If set, Gollum will only serve pages from this directory. Default: repository root. | -| --css | none | Tell Gollum to inject custom CSS into each page. Uses `custom.css` from repository root.2,4 | -| --js | none | Tell Gollum to inject custom JS into each page. Uses `custom.js` from repository root.2,4 | -| --no-edit | none | Disables the feature of editing pages. | -| --live-preview | none | Enables the live preview feature in page editor. | -| --no-live-preview | none | Disables the live preview feature in page editor. | -| --allow-uploads | [MODE] | Enables file uploads. If set to `dir`, Gollum will store all uploads in the `/uploads/` directory. If set to `page`, Gollum will store each upload at the same location as the page that is currently being edited.3 | -| --template-dir | [PATH] | Specify custom mustache template directory. | +| --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. | +| --css | none | Tell Gollum to inject custom CSS into each page. Uses `custom.css` from repository root.3,5 | +| --js | none | Tell Gollum to inject custom JS into each page. Uses `custom.js` from repository root.3,5 | +| --no-edit | none | Disable the feature of editing pages. | +| --live-preview | none | Enable the live preview feature in page editor. | +| --no-live-preview | none | Disable the live preview feature in page editor. | +| --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 | +| --mathjax | none | Enables MathJax (renders mathematical equations). By default, uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.5 | +| --irb | none | Launch Gollum in "console mode", with a [predefined API](https://github.com/gollum/gollum-lib/). | +| --h1-title | none | Tell Gollum to use the first `

` as page title. | | --show-all | none | Tell Gollum to also show files in the file view. By default, only valid pages are shown. | | --collapse-tree | none | Tell Gollum to collapse the file tree, when the file view is opened. By default, the tree is expanded. | -| --mathjax | none | Enables MathJax (renders mathematical equations). By default, uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.4 | -| --mathjax-config | [PATH] | Specify path for custom MathJax config. By default, uses `mathjax.config.js` from repository root. | -| --h1-title | none | Tell Gollum to use the first `

` as page title. | -| --adapter | [ADAPTER] | Tell Gollum to use a specific git adapter. Default: `grit`.5 | -| --user-icons | [MODE] | Tell Gollum to use specific user icons. Can be set to `gravatar`, `identicon` or `none`. Default: `none`. | -| --irb | none | Tell Gollum to launch in console mode, with [this API](https://github.com/gollum/gollum-lib/) being available. | -| --help | none | Display the list of options no the command line. | +| --user-icons | [MODE] | Tell Gollum to use specific user icons for history view. Can be set to `gravatar`, `identicon` or `none`. Default: `none`. | +| --mathjax-config | [FILE] | Specify path to a custom MathJax configuration. If not specified, uses the `mathjax.config.js` file from repository root. | +| --template-dir | [PATH] | Specify custom mustache template directory. | +| --help | none | Display the list of options on the command line. | | --version | none | Display the current version of Gollum. | **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. 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. -3. Files can be uploaded simply by dragging and dropping them onto the editor's text area (this is, however exclusive to the default editor, not the live preview editor). -4. Read the relevant [Security note](https://github.com/gollum/gollum/wiki/Security#custom-cssjs--mathjax-config) before using these. -5. Before using `--adapter`, you should probably read [this](https://github.com/gollum/gollum/wiki/Git-adapters) first. +2. Before using `--adapter`, you should probably read [this](https://github.com/gollum/gollum/wiki/Git-adapters) 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 (this is, however exclusive to the default editor, not the live preview editor). +5. Read the relevant [Security note](https://github.com/gollum/gollum/wiki/Security#custom-cssjs--mathjax-config) before using these. ### Config file diff --git a/bin/gollum b/bin/gollum index 7e1a6e63..95086016 100755 --- a/bin/gollum +++ b/bin/gollum @@ -2,128 +2,166 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) -help = < 4567, 'bind' => '0.0.0.0' } +options = { + :port => 4567, + :bind => '0.0.0.0', +} wiki_options = { - :live_preview => false, - :allow_uploads => false, - :allow_editing => true, + :live_preview => false, + :allow_uploads => false, + :allow_editing => true, } opts = OptionParser.new do |opts| - opts.banner = help - - opts.on("--port [PORT]", "Bind port (default 4567).") do |port| - options['port'] = port.to_i + # define program name (although this defaults to the name of the file, just in case...) + opts.program_name = "gollum" + + # set basic info for the "--help" command (options will be appended automatically from the below definitions) + opts.banner = ' + Gollum is a multi-format Wiki Engine/API/Frontend. + + Usage: + gollum [options] [git-repo] + + Arguments: + [git-repo] Path to the git repository being served. If not specified, current working directory is used. + + Notes: + Paths for all options are relative to unless absolute. + This message is only a basic description. For more information, please visit: + https://github.com/gollum/gollum + + OPTIONS' + + # define gollum options + opts.separator "" + opts.separator " Major:" + + opts.on("-h", "--host [HOST]", "Specify the hostname or IP address to listen on. Default: '0.0.0.0'.") do |host| + options[:bind] = host end - - opts.on("--host [HOST]", "Hostname or IP address to listen on (default 0.0.0.0).") do |host| - options['bind'] = host + opts.on("-p", "--port [PORT]", "Specify the port to bind Gollum with. Default: '4567'.") do |port| + begin + # don't use "port.to_i" here... it doesn't raise errors which might result in a nice confusion later on + options[:port] = Integer(port) + rescue ArgumentError + puts "Error: '#{port}' is not a valid port number." + exit 1 + end end - - opts.on("--version", "Display current version.") do - puts "Gollum " + Gollum::VERSION - exit 0 + opts.on("-c", "--config [FILE]", "Specify path to the Gollum's configuration file.") do |file| + options[:config] = file end - - opts.on("--config [CONFIG]", "Path to additional configuration file") do |config| - options['config'] = config - end - - opts.on("--adapter [ADAPTER]", "Git adapter to use in the backend. Defaults to grit.") do |adapter| - Gollum::GIT_ADAPTER = adapter - end - - opts.on("--irb", "Start an irb process with gollum loaded for the current wiki.") do - options['irb'] = true - end - - opts.on("--css", "Inject custom css. Uses custom.css from root repository") do - wiki_options[:css] = true - end - - opts.on("--js", "Inject custom js. Uses custom.js from root repository") do - wiki_options[:js] = true - end - - opts.on("--template-dir [PATH]", "Specify custom template directory") do |path| - wiki_options[:template_dir] = path - end - - opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path| - wiki_options[:page_file_dir] = path - end - - opts.on("--base-path [PATH]", "Specify the base path for the served pages (default: /) Example: --base-path wiki yields the home page accessible at http://localhost:4567/wiki/.") do |path| - wiki_options[:base_path] = path - end - - opts.on("--gollum-path [PATH]", "Specify the path to the git repository to be served.") do |path| - wiki_options[:gollum_path] = path - end - - opts.on("--ref [REF]", "Specify the repository ref to use (default: master).") do |ref| + opts.on("-r", "--ref [REF]", "Specify the branch to serve. Default: 'master'.") do |ref| wiki_options[:ref] = ref end - - opts.on("--bare", "Specify that the repository is bare (only necessary when using the grit adapter).") do + opts.on("-a", "--adapter [ADAPTER]", "Launch Gollum using a specific git adapter. Default: 'grit'.") do |adapter| + Gollum::GIT_ADAPTER = adapter + end + opts.on("--bare", "Declare '' to be bare. This is only necessary when using the grit adapter.") do wiki_options[:repo_is_bare] = true end - - opts.on("--no-edit", "Restricts editing capability through frontend.") do + opts.on("-b", "--base-path [PATH]", "Specify the leading portion of all Gollum URLs (path info). Default: '/'.", + "Example: setting this to '/wiki' will make the wiki accessible under 'http://localhost:4567/wiki/'.") do |base_path| + + # first trim a leading slash, if any + if base_path.start_with?("/") + base_path = base_path[1..-1] + end + + # make a backup of the option and sanitize it + base_path_original = base_path.dup + base_path = CGI.escape(base_path) + + # then let the user know if we changed the URL + unless base_path_original == base_path + puts </pages/*'.") do |path| + wiki_options[:page_file_dir] = path + end + opts.on("--css", "Inject custom CSS into each page. The '/custom.css' file is used (must be committed).") do + wiki_options[:css] = true + end + opts.on("--js", "Inject custom JavaScript into each page. The '/custom.js' file is used (must be committed).") do + wiki_options[:js] = true + end + opts.on("--no-edit", "Disable the feature of editing pages.") do wiki_options[:allow_editing] = false end - - opts.on("--no-live-preview", "Disables livepreview.") do - wiki_options[:live_preview] = false - end - - opts.on("--live-preview", "Enables livepreview.") do + opts.on("--live-preview", "Enable the live preview feature in page editor.") do wiki_options[:live_preview] = true end - - opts.on("--allow-uploads [MODE]", [:dir, :page], "Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page).") do |mode| + opts.on("--no-live-preview", "Disable the live preview feature in page editor.") do + wiki_options[:live_preview] = false + end + opts.on("--allow-uploads [MODE]", [:dir, :page], "Enable file uploads.", + "If set to 'dir', Gollum will store all uploads in the '/uploads/' directory.", + "If set to 'page', Gollum will store each upload at the currently edited page.") do |mode| wiki_options[:allow_uploads] = true wiki_options[:per_page_uploads] = true if mode == :page end - - opts.on("--mathjax", "Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default.") do + opts.on("--mathjax", "Enable MathJax (renders mathematical equations).", + "By default, uses the 'TeX-AMS-MML_HTMLorMML' config with the 'autoload-all' extension.") do wiki_options[:mathjax] = true end - - opts.on("--mathjax-config [SOURCE]", "Inject custom mathjax config file. Uses mathjax.config.js from root repository by default") do |source| - wiki_options[:mathjax_config] = source || 'mathjax.config.js' + opts.on("--irb", "Launch Gollum in 'console mode', with a predefined API.") do + options[:irb] = true end - - opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source| - wiki_options[:user_icons] = source - end - - opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do - wiki_options[:show_all] = true - end - - opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do - wiki_options[:collapse_tree] = true - end - opts.on("--h1-title", "Sets page title to value of first h1") do + + opts.separator "" + opts.separator " Minor:" + + opts.on("--h1-title", "Use the first '

' as page title.") do wiki_options[:h1_title] = true end + opts.on("--show-all", "Also show files in the file view. By default, only valid pages are shown.") do + wiki_options[:show_all] = true + end + opts.on("--collapse-tree", "Collapse the tree, when file view is opened. By default, the tree is expanded.") do + wiki_options[:collapse_tree] = true + end + opts.on("--user-icons [MODE]", [:gravatar, :identicon, :none], "Use specific user-icons for history view.", + "Can be set to 'gravatar', 'identicon' or 'none'. Default: 'none'.") do |mode| + wiki_options[:user_icons] = mode + end + opts.on("--mathjax-config [FILE]", "Specify path to a custom MathJax configuration.", + "If not specified, uses the '/mathjax.config.js' file.") do |file| + wiki_options[:mathjax_config] = file || 'mathjax.config.js' + end + opts.on("--template-dir [PATH]", "Specify custom mustache template directory.") do |path| + wiki_options[:template_dir] = path + end + + opts.separator "" + opts.separator " Common:" + + opts.on("--help", "Display this message.") do + puts opts + exit 0 + end + opts.on("--version", "Display the current version of Gollum.") do + puts "Gollum " + Gollum::VERSION + exit 0 + end + + opts.separator "" + end # Read command line options into `options` hash @@ -136,11 +174,9 @@ rescue OptionParser::InvalidOption end # --gollum-path wins over ARGV[0] -gollum_path = wiki_options[:gollum_path] ? - wiki_options[:gollum_path] : - ARGV[0] || Dir.pwd +gollum_path = ARGV[0] || Dir.pwd -if options['irb'] +if options[:irb] require 'irb' # http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/ module IRB # :nodoc: @@ -171,8 +207,11 @@ if options['irb'] if !wiki.exist? then raise Gollum::InvalidGitRepositoryError end - puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}." puts + puts "Loaded Gollum wiki at:" + puts "#{File.expand_path(gollum_path).inspect}" + puts + puts "Example API calls:" puts %( page = wiki.page('page-name')) puts %( # => ) puts @@ -182,7 +221,9 @@ if options['irb'] puts %( page.formatted_data) puts %( # => "

My wiki page

") puts - puts "Check out the Gollum README for more." + puts "Full API documentation at:" + puts "https://github.com/gollum/gollum-lib" + puts IRB.start_session(binding) rescue Gollum::InvalidGitRepositoryError, Gollum::NoSuchPathError puts "Invalid Gollum wiki at #{File.expand_path(gollum_path).inspect}" @@ -194,7 +235,7 @@ else Precious::App.set(:wiki_options, wiki_options) Precious::App.settings.mustache[:templates] = wiki_options[:template_dir] if wiki_options[:template_dir] - if cfg = options['config'] + if cfg = options[:config] # If the path begins with a '/' it will be considered an absolute path, # otherwise it will be relative to the CWD cfg = File.join(Dir.getwd, cfg) unless cfg.slice(0) == File::SEPARATOR @@ -203,21 +244,25 @@ else base_path = wiki_options[:base_path] - if wiki_options[:base_path].nil? + if base_path.nil? Precious::App.run!(options) else require 'rack' class MapGollum - def initialize base_path + def initialize(base_path) @mg = Rack::Builder.new do - map '/' do - run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] } - end - + map "/#{base_path}" do run Precious::App end + map '/' do + run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] } + end + map '/*' do + run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] } + end + end end @@ -225,7 +270,8 @@ else @mg.call(env) end end + # Rack::Handler does not work with Ctrl + C. Use Rack::Server instead. - Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start + Rack::Server.new(:app => MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start end end From e17778190d3d4ee33ea570147d100621658128ab Mon Sep 17 00:00:00 2001 From: rgroux Date: Tue, 25 Aug 2015 17:06:36 +0200 Subject: [PATCH 11/34] README add link to wiki about CAS SSO --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8022b102..0f57fdfe 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ For more information on Gollum's capabilities and pitfalls: 1. [Syntax/capability overview for pages](https://github.com/gollum/gollum/wiki). 2. [Known limitations](https://github.com/gollum/gollum/wiki/Known-limitations). 3. [Security overview](https://github.com/gollum/gollum/wiki/Security). +4. [Gollum with CAS SSO](https://github.com/gollum/gollum/wiki/Gollum-via-Rack-and-CAS-SSO) ## SYSTEM REQUIREMENTS From 2ce44c157a63d3871e83c72abcb901253911454a Mon Sep 17 00:00:00 2001 From: Morton Fox Date: Tue, 25 Aug 2015 23:48:53 -0400 Subject: [PATCH 12/34] Fix github-markup link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8022b102..f63ce726 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ Gollum presently ships with support for the following markups: * [Markdown](http://daringfireball.net/projects/markdown/syntax) * [RDoc](http://rdoc.sourceforge.net/) -Since all markups are rendered by the [github-markup](https://github/com/github/markup) gem, you can easily add support for other markups by additional installation: +Since all markups are rendered by the [github-markup](https://github.com/github/markup) gem, you can easily add support for other markups by additional installation: * [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `[sudo] gem install asciidoctor` * [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `[sudo] gem install creole` * [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `[sudo] gem install github-markdown` From 2323506c823d9ce7d4e66a523d29aa941ced2b41 Mon Sep 17 00:00:00 2001 From: Richard Groux Date: Thu, 10 Sep 2015 18:14:59 +0200 Subject: [PATCH 13/34] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f57fdfe..b1f35772 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ For more information on Gollum's capabilities and pitfalls: 1. [Syntax/capability overview for pages](https://github.com/gollum/gollum/wiki). 2. [Known limitations](https://github.com/gollum/gollum/wiki/Known-limitations). 3. [Security overview](https://github.com/gollum/gollum/wiki/Security). -4. [Gollum with CAS SSO](https://github.com/gollum/gollum/wiki/Gollum-via-Rack-and-CAS-SSO) ## SYSTEM REQUIREMENTS @@ -110,6 +109,10 @@ This will start up a web server (WEBrick) running Gollum with a web interface, w Gollum can also be ran with any [rack-compatible web server](https://github.com/rack/rack#supported-web-servers). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack). +### Rack, with an authentication server + +Gollum can also be ran 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](https://github.com/gollum/gollum/wiki/Gollum-via-Rack-and-CAS-SSO). + ### Docker Gollum can also be ran via [Docker](https://www.docker.com/). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Docker). From 9ecf8a61baebafbca7c7485f30061fc90113c47e Mon Sep 17 00:00:00 2001 From: Nils Steinger Date: Mon, 14 Sep 2015 05:00:59 +0200 Subject: [PATCH 14/34] Added init script for Debian's SysV-style init system Adapted from the OpenRC init script in contrib/openrc/init.d/gollum. --- contrib/sysv-debian/init.d/gollum | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 contrib/sysv-debian/init.d/gollum diff --git a/contrib/sysv-debian/init.d/gollum b/contrib/sysv-debian/init.d/gollum new file mode 100755 index 00000000..b6bac7ba --- /dev/null +++ b/contrib/sysv-debian/init.d/gollum @@ -0,0 +1,79 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: gollum +# Required-Start: $local_fs $remote_fs $network $syslog +# Required-Stop: $local_fs $remote_fs $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# X-Interactive: true +# Short-Description: Start/stop gollum wiki +### END INIT INFO + +# Distributed under the terms of the MIT License + +set -e + +# Edit these settings to your liking: +GOLLUM_USER=gollum +GOLLUM_BASE=/var/lib/gollum/.git +GOLLUM_OPTS="--bare" + +NAME=gollum +PID=/var/run/${NAME}.pid +EXEC=/usr/local/bin/gollum +LOG=/var/log/gollum.log + +. /lib/lsb/init-functions + +start () +{ + # Change log file to be owned by GOLLUM_USER + touch "${LOG}" + chown "${GOLLUM_USER}" "${LOG}" + + log_daemon_msg "Starting Gollum" + start-stop-daemon --start \ + --name "${NAME}" \ + --user "${GOLLUM_USER}" \ + --chuid "${GOLLUM_USER}" \ + --pidfile "${PID}" \ + --make-pidfile --background \ + --startas /bin/sh -- -c "exec ${EXEC} $GOLLUM_OPTS \"$GOLLUM_BASE\" > \"${LOG}\" 2>&1" + log_end_msg $? +} + +stop () +{ + log_daemon_msg "Stopping Gollum" + start-stop-daemon --stop \ + --user "${GOLLUM_USER}" \ + --signal INT \ + --pidfile "${PID}" \ + --retry 10 + log_end_msg $? +} + +status () +{ + status_of_proc -p $PID $EXEC $NAME +} + +case $1 in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status + ;; + *) + log_success_msg "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac From e0f35eceab7d880e9b0ce8aa922c8c9e986e1f78 Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Mon, 14 Sep 2015 17:31:25 +0200 Subject: [PATCH 15/34] Fixing the link to Windows support meta issue --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 27e07fae..b0d81691 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ For more information on Gollum's capabilities and pitfalls: **Notes:** -1. There are still some bugs and this setup is not ready for production yet. You can track the progress at #1044. +1. There are still some bugs and this setup is not ready for production yet. You can track the progress at [Support Windows via JRuby - Meta Issue](https://github.com/gollum/gollum/issues/1044). ## INSTALLATION From ce68a88293ce3b18c261312392ad33a88bb69ea1 Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sun, 20 Sep 2015 13:53:02 +0200 Subject: [PATCH 16/34] Added security check. --- lib/gollum/app.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 12e47541..3fde8bf2 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -176,6 +176,7 @@ module Precious fullname = params[:file][:filename] tempfile = params[:file][:tempfile] end + halt 500 unless tempfile.is_a? Tempfile # Remove page file dir prefix from upload path if necessary -- committer handles this itself dir = wiki.per_page_uploads ? params[:upload_dest].match(/^(#{wiki.page_file_dir}\/+)?(.*)/)[2] : 'uploads' From ab42c0c0dfc9879f73312ad2c804875b510a414c Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Sun, 20 Sep 2015 14:48:32 +0200 Subject: [PATCH 17/34] Release 4.0.1 --- gollum.gemspec | 7 ++++--- lib/gollum.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gollum.gemspec b/gollum.gemspec index 2b1c6394..9e739ca7 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -5,8 +5,8 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 1.9' s.name = 'gollum' - s.version = '4.0.0' - s.date = '2015-04-11' + s.version = '4.0.1' + s.date = '2015-09-20' s.rubyforge_project = 'gollum' s.license = 'MIT' @@ -46,11 +46,12 @@ Gem::Specification.new do |s| README.md Rakefile bin/gollum - config.ru config.rb + config.ru contrib/openrc/conf.d/gollum contrib/openrc/init.d/gollum contrib/systemd/gollum@.service + contrib/sysv-debian/init.d/gollum gollum.gemspec lib/gollum.rb lib/gollum/app.rb diff --git a/lib/gollum.rb b/lib/gollum.rb index 55b81ca6..ca342ac9 100644 --- a/lib/gollum.rb +++ b/lib/gollum.rb @@ -16,7 +16,7 @@ require File.expand_path('../gollum/uri_encode_component', __FILE__) $KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8' module Gollum - VERSION = '4.0.0' + VERSION = '4.0.1' def self.assets_path ::File.expand_path('gollum/public', ::File.dirname(__FILE__)) From 3811fb46b3e7997e3228538c64bb8a9e57486c06 Mon Sep 17 00:00:00 2001 From: mpnowacki Date: Sun, 4 Oct 2015 11:34:25 +0200 Subject: [PATCH 18/34] fixed file renaming issues with page_file_dir. This will only work with appropriate changes in gollum-lib --- lib/gollum/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 3fde8bf2..116bc592 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -179,7 +179,7 @@ module Precious halt 500 unless tempfile.is_a? Tempfile # Remove page file dir prefix from upload path if necessary -- committer handles this itself - dir = wiki.per_page_uploads ? params[:upload_dest].match(/^(#{wiki.page_file_dir}\/+)?(.*)/)[2] : 'uploads' + dir = wiki.per_page_uploads ? params[:upload_dest] : ::File.join([wiki.page_file_dir, 'uploads'].compact) ext = ::File.extname(fullname) format = ext.split('.').last || 'txt' filename = ::File.basename(fullname, ext) From 7362fd859b0120ab8d0a499422ab3eb89f52688b Mon Sep 17 00:00:00 2001 From: SkyCrawl Date: Sun, 25 Oct 2015 13:12:36 +0100 Subject: [PATCH 19/34] Fixing the "running" section --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b0d81691..59f246a3 100644 --- a/README.md +++ b/README.md @@ -98,14 +98,17 @@ Simply: 2. Run: `gollum`. 3. Open `http://localhost:4567` in your browser. -If you wish to run from source, simply: - -1. Navigate to your git repository (wiki) via the command line. -2. Run: `bundle exec bin/gollum` -3. Open `http://localhost:4567` in your browser. - This will start up a web server (WEBrick) running Gollum with a web interface, where you can view and edit your wiki. +### Running from source + +1. `git clone https://github.com/gollum/gollum` +2. `cd gollum` +3. `[sudo] bundle install` (may not always be necessary). +4. `bundle exec bin/gollum` + * Like that, gollum assumes the target wiki (git repository) is the project repository itself. If it's not, execute `bundle exec bin/gollum ` instead. +5. Open `http://localhost:4567` in your browser. + ### Rack Gollum can also be ran with any [rack-compatible web server](https://github.com/rack/rack#supported-web-servers). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack). From 90072a93327665da4d54e3b7e17569d2c743af4e Mon Sep 17 00:00:00 2001 From: ngyuki Date: Tue, 25 Nov 2014 23:01:50 +0900 Subject: [PATCH 20/34] Fix position of sidebar in preview --- lib/gollum/app.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 3fde8bf2..31022732 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -358,6 +358,7 @@ module Precious @mathjax = wiki.mathjax @h1_title = wiki.h1_title @editable = false + @bar_side = wiki.bar_side @allow_uploads = wiki.allow_uploads mustache :page end From 6caacbf38810a05387a3b5b912548cba31b2157c Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Mon, 30 Nov 2015 00:28:01 +0100 Subject: [PATCH 21/34] Update kramdown and useragent dependencies. --- gollum.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gollum.gemspec b/gollum.gemspec index 9e739ca7..40b808c6 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -25,10 +25,10 @@ Gem::Specification.new do |s| s.extra_rdoc_files = %w[README.md LICENSE] s.add_dependency 'gollum-lib', '~> 4.0', '>= 4.0.1' - s.add_dependency 'kramdown', '~> 1.8.0' + s.add_dependency 'kramdown', '~> 1.9.0' s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4' s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0'] - s.add_dependency 'useragent', '~> 0.14.0' + s.add_dependency 'useragent', '~> 0.16.2' s.add_development_dependency 'rack-test', '~> 0.6.2' s.add_development_dependency 'shoulda', '~> 3.5.0' From 5a53c58b048cf48671b64515083cf42eccb7dd03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Luis=20Leal=20Cardoso=20Junior?= Date: Sat, 5 Dec 2015 23:23:22 -0200 Subject: [PATCH 22/34] Sanitize basepath options when adding with more than one / at the start. Fixes #1066 --- bin/gollum | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/gollum b/bin/gollum index 95086016..2513536a 100755 --- a/bin/gollum +++ b/bin/gollum @@ -71,10 +71,8 @@ opts = OptionParser.new do |opts| "Example: setting this to '/wiki' will make the wiki accessible under 'http://localhost:4567/wiki/'.") do |base_path| # first trim a leading slash, if any - if base_path.start_with?("/") - base_path = base_path[1..-1] - end - + base_path.sub!(/^\/+/, '') + # make a backup of the option and sanitize it base_path_original = base_path.dup base_path = CGI.escape(base_path) From 8c3c519679ecd5fd9948cb2f12cc9a09cf5b31fd Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sun, 10 Jan 2016 11:49:34 +0100 Subject: [PATCH 23/34] Adds links to youtube videos in README. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 59f246a3..7e41ad54 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ For more information on Gollum's capabilities and pitfalls: 3. [Troubleshoot guide](https://github.com/gollum/gollum/wiki/Troubleshoot-guide). 4. [Security overview](https://github.com/gollum/gollum/wiki/Security). +For a quick impression of gollum, see [this video](https://www.youtube.com/watch?v=gj1qqK3Oku8). To see more advanced features in action, see [this video](https://www.youtube.com/watch?v=EauxgxsLDC4) here (installation with docker). + ## SYSTEM REQUIREMENTS | Operating System | Ruby | Adapters | Supported | From 6bd2f3bff533c4abb8c4304c877881bdf8474cfd Mon Sep 17 00:00:00 2001 From: Bart Kamphorst Date: Sun, 10 Jan 2016 15:28:23 +0100 Subject: [PATCH 24/34] Drop 1.9.3 testing on Travis, add 2.3.0. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e559dcb5..18e4b577 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ rvm: - - 1.9.3 - 2.0.0 - 2.1.0 - 2.1.1 - 2.2.2 + - 2.3.0 - jruby-19mode before_install: - sudo apt-get update From 91833dd72ef33bf4504d34faa519fc0351c06a19 Mon Sep 17 00:00:00 2001 From: Jean Hominal Date: Thu, 26 Nov 2015 08:24:17 +0100 Subject: [PATCH 25/34] Use `last_version` instead of `versions` when possible. Fixes #1087. Use Gollum::Page#last_version instead of Gollum::Page#versions in the cases identified in #1087: * In Precious::App#show_page_or_file * In Precious::Views::Page#author * In Precious::Views::Page#date --- lib/gollum/app.rb | 2 +- lib/gollum/views/page.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index e7deaaf0..d4498185 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -496,7 +496,7 @@ module Precious # Extensions and layout data @editable = true - @page_exists = !page.versions.empty? + @page_exists = !page.last_version.nil? @toc_content = wiki.universal_toc ? @page.toc_data : nil @mathjax = wiki.mathjax @h1_title = wiki.h1_title diff --git a/lib/gollum/views/page.rb b/lib/gollum/views/page.rb index 6f635d17..e903f734 100644 --- a/lib/gollum/views/page.rb +++ b/lib/gollum/views/page.rb @@ -22,15 +22,13 @@ module Precious end def author - page_versions = @page.versions - first = page_versions ? page_versions.first : false + first = page.last_version return DEFAULT_AUTHOR unless first first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name end def date - page_versions = @page.versions - first = page_versions ? page_versions.first : false + first = page.last_version return Time.now.strftime(DATE_FORMAT) unless first first.authored_date.strftime(DATE_FORMAT) end From e64f40eaa329f8accb54d91da5aa25bb193a2be9 Mon Sep 17 00:00:00 2001 From: Jean Hominal Date: Tue, 23 Feb 2016 22:52:07 +0100 Subject: [PATCH 26/34] Unconditionally add 'test-unit' dependency. Fixes #1110 --- gollum.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gollum.gemspec b/gollum.gemspec index 40b808c6..3be441f4 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -35,7 +35,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'minitest-reporters', '~> 0.14.16' s.add_development_dependency 'twitter_cldr', '~> 3.2.0' s.add_development_dependency 'mocha', '~> 1.1.0' - s.add_development_dependency 'test-unit', '~> 3.1.0' if RUBY_VERSION =~ /^2.2/ + s.add_development_dependency 'test-unit', '~> 3.1.0' s.add_development_dependency 'webrick', '~> 1.3.1' # = MANIFEST = From fa1bcf9608fc132b903e522f18e9f0bb8abee33e Mon Sep 17 00:00:00 2001 From: Sven Schwyn Date: Fri, 15 Apr 2016 10:45:51 +0200 Subject: [PATCH 27/34] Add support for emojione --- README.md | 3 ++- bin/gollum | 3 +++ gollum.gemspec | 3 ++- lib/gollum/app.rb | 10 +++++++++- lib/gollum/helpers.rb | 13 +++++++++++++ lib/gollum/public/gollum/css/gollum.css | 6 ++++++ .../gollum/javascript/editor/langs/markdown.js | 5 +++++ test/test_app.rb | 12 ++++++++++++ 8 files changed, 52 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7e41ad54..9bbc8de2 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ For a quick impression of gollum, see [this video](https://www.youtube.com/watch ## SYSTEM REQUIREMENTS -| Operating System | Ruby | Adapters | Supported | +| Operating System | Ruby | Adapters | Supported | | ---------------- | -------------- | ------------------ | --------- | | Unix/Linux-like | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | yes | | Unix/Linux-like | [JRuby](https://github.com/jruby/jruby) (1.9.3+ compatible) | [RJGit](https://github.com/repotag/rjgit) | yes | @@ -143,6 +143,7 @@ Gollum comes with the following command line options: | --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. | | --css | none | Tell Gollum to inject custom CSS into each page. Uses `custom.css` from repository root.3,5 | | --js | none | Tell Gollum to inject custom JS into each page. Uses `custom.js` from repository root.3,5 | +| --emoji | none | Parse and interpret emoji tags (e.g. :heart:). | | --no-edit | none | Disable the feature of editing pages. | | --live-preview | none | Enable the live preview feature in page editor. | | --no-live-preview | none | Disable the live preview feature in page editor. | diff --git a/bin/gollum b/bin/gollum index 2513536a..b47875ef 100755 --- a/bin/gollum +++ b/bin/gollum @@ -99,6 +99,9 @@ MSG opts.on("--js", "Inject custom JavaScript into each page. The '/custom.js' file is used (must be committed).") do wiki_options[:js] = true end + opts.on("--emoji", "Parse and interpret emoji tags (e.g. :heart:).") do + wiki_options[:emoji] = true + end opts.on("--no-edit", "Disable the feature of editing pages.") do wiki_options[:allow_editing] = false end diff --git a/gollum.gemspec b/gollum.gemspec index 3be441f4..84be9fe6 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -6,7 +6,7 @@ Gem::Specification.new do |s| s.name = 'gollum' s.version = '4.0.1' - s.date = '2015-09-20' + s.date = '2016-05-19' s.rubyforge_project = 'gollum' s.license = 'MIT' @@ -29,6 +29,7 @@ Gem::Specification.new do |s| s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4' s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0'] s.add_dependency 'useragent', '~> 0.16.2' + s.add_dependency 'gemojione', '~> 2' s.add_development_dependency 'rack-test', '~> 0.6.2' s.add_development_dependency 'shoulda', '~> 3.5.0' diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index d4498185..3843d18c 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -49,7 +49,7 @@ module Precious class App < Sinatra::Base register Mustache::Sinatra include Precious::Helpers - + dir = File.dirname(File.expand_path(__FILE__)) # Detect unsupported browsers. @@ -130,6 +130,14 @@ module Precious Gollum::Wiki.new(settings.gollum_path, settings.wiki_options) end + get '/emoji/:name' do + begin + [200, {'Content-Type' => 'image/png'}, emoji(params['name'])] + rescue ArgumentError + not_found + end + end + get '/data/*' do if page = wiki_page(params[:splat].first).page page.raw_data diff --git a/lib/gollum/helpers.rb b/lib/gollum/helpers.rb index 3e057f3e..d140b932 100644 --- a/lib/gollum/helpers.rb +++ b/lib/gollum/helpers.rb @@ -1,6 +1,11 @@ # ~*~ encoding: utf-8 ~*~ +require 'gemojione' + module Precious module Helpers + + EMOJI_PATHNAME = Pathname.new(Gemojione.index.images_path).freeze + # Extract the path string that Gollum::Wiki expects def extract_path(file_path) return nil if file_path.nil? @@ -51,5 +56,13 @@ module Precious return mustache :error end + def emoji(name) + if emoji = Gemojione.index.find_by_name(name) + IO.read(EMOJI_PATHNAME.join("#{emoji['unicode']}.png")) + else + fail ArgumentError, "emoji `#{name}' not found" + end + end + end end diff --git a/lib/gollum/public/gollum/css/gollum.css b/lib/gollum/public/gollum/css/gollum.css index cd577b78..de90e47d 100755 --- a/lib/gollum/public/gollum/css/gollum.css +++ b/lib/gollum/public/gollum/css/gollum.css @@ -849,3 +849,9 @@ ul.actions { .clearfloats { clear: both; } + +.emoji { + width: 20px; + height: 20px; + vertical-align: -18%; +} diff --git a/lib/gollum/public/gollum/javascript/editor/langs/markdown.js b/lib/gollum/public/gollum/javascript/editor/langs/markdown.js index 851b7381..b1f917eb 100644 --- a/lib/gollum/public/gollum/javascript/editor/langs/markdown.js +++ b/lib/gollum/public/gollum/javascript/editor/langs/markdown.js @@ -211,6 +211,11 @@ var MarkDownHelp = [ { menuName: 'Escaping', data: '

If you want to use a special Markdown character in your document (such as displaying literal asterisks), you can escape the character with the backslash (\\). Markdown will ignore the character directly after a backslash.' + }, + + { + menuName: 'Emoji', + data: '

See the EmojiOne demo for all available emoji. To include one, wrap the emoji name in colons and use underscores instead of spaces (e.g. :heart: or :point_up:).' } ] } diff --git a/test/test_app.rb b/test/test_app.rb index 6f1b7294..32ba29ea 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -707,6 +707,18 @@ context "Frontend with lotr" do assert_match /not so big smelly creatures/, last_response.body end + test "existing emoji" do + get "/emoji/heart" + assert_equal 200, last_response.status + assert_equal 'image/png', last_response.headers['Content-Type'] + assert_equal [137, 80, 78, 71, 13, 10, 26, 10], last_response.body.each_byte.to_a[0..7] + end + + test "missing emoji" do + get "/emoji/oggy_was_here" + assert_equal 404, last_response.status + end + def app Precious::App end From 330f7b40022162c2b8b32ff5e7e2d448c8437aa4 Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Thu, 16 Jun 2016 12:58:22 +0200 Subject: [PATCH 28/34] Add Safari to livepreview-enabled browsers. Fixes #503 --- lib/gollum/app.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 3843d18c..9e060f8d 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -59,6 +59,7 @@ module Precious Browser.new('Internet Explorer', '10.0'), Browser.new('Chrome', '7.0'), Browser.new('Firefox', '4.0'), + Browser.new('Safari', '9.0') ] def supported_useragent?(user_agent) From 0675844d97a14a788d81a9b99efa373c339dbfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 27 Jun 2016 13:50:47 -0400 Subject: [PATCH 29/34] Fix compare page not accessible in no-edit mode Permission checking was spread across `post` action handlers instead of inside the `before` to normalize between `get` and `post` action handlers and be more explicit. --- lib/gollum/app.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 9e060f8d..4d002aee 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -96,7 +96,6 @@ module Precious before do settings.wiki_options[:allow_editing] = settings.wiki_options.fetch(:allow_editing, true) @allow_editing = settings.wiki_options[:allow_editing] - forbid unless @allow_editing || request.request_method == "GET" Precious::App.set(:mustache, {:templates => settings.wiki_options[:template_dir]}) if settings.wiki_options[:template_dir] @base_url = url('/', false).chomp('/') @page_dir = settings.wiki_options[:page_file_dir].to_s @@ -173,6 +172,8 @@ module Precious end post '/uploadFile' do + forbid unless @allow_editing + wiki = wiki_new unless wiki.allow_uploads @@ -222,6 +223,8 @@ module Precious end post '/rename/*' do + forbid unless @allow_editing + wikip = wiki_page(params[:splat].first) halt 500 if wikip.nil? wiki = wikip.wiki @@ -258,6 +261,8 @@ module Precious end post '/edit/*' do + forbid unless @allow_editing + path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s page_name = CGI.unescape(params[:page]) wiki = wiki_new @@ -317,6 +322,8 @@ module Precious end post '/create' do + forbid unless @allow_editing + name = params[:page].to_url path = sanitize_empty_params(params[:path]) || '' format = params[:format].intern @@ -336,6 +343,8 @@ module Precious end post '/revert/*/:sha1/:sha2' do + forbid unless @allow_editing + wikip = wiki_page(params[:splat].first) @path = wikip.path @name = wikip.name @@ -359,6 +368,8 @@ module Precious end post '/preview' do + forbid unless @allow_editing + wiki = wiki_new @name = params[:page] || "Preview" @page = wiki.preview_page(@name, params[:content], params[:format]) From 66a2bb0393b16e3bd8464ab6e9a8418e45134afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 11 Jul 2016 12:19:43 -0400 Subject: [PATCH 30/34] Remove deprecated github-markdown markup From [RubyGems](https://rubygems.org/gems/github-markdown/versions/0.6.9): > THIS GEM IS NOT MAINTAINED AND NOT SUPPORTED. Also, the GitHub repository, maintained by GitHub, was removed. The link is now a redirect, it doesn't point to the GFM page anymore. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9bbc8de2..ed647555 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,6 @@ Gollum presently ships with support for the following markups: Since all markups are rendered by the [github-markup](https://github.com/github/markup) gem, you can easily add support for other markups by additional installation: * [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `[sudo] gem install asciidoctor` * [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `[sudo] gem install creole` -* [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `[sudo] gem install github-markdown` * [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `[sudo] gem install wikicloth` * [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `[sudo] gem install org-ruby` * [Pod](http://perldoc.perl.org/perlpod.html) -- requires Perl >= 5.10 (the `perl` command must be available on your command line) From b620decde75fa8422c447d849dcc04d37a362446 Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Sun, 7 Aug 2016 12:48:07 +0200 Subject: [PATCH 31/34] Add contributing guidelines --- CONTRIBUTING.md | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 67 ------------------------------------ 2 files changed, 91 insertions(+), 67 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..73edc588 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,91 @@ +# Contributing to Gollum === + +Thanks for your interset in the gollum project! + +## Submitting an Issue + +Please note that the issue tracker is meant for: + +1. Bug reports. +2. Feature requests. + +If your have problems using or installing the software which stem from bugs in the software or a lack of documentation, we are always happy to help out! However, **for ordinary usage questions, please consider asking elsewhere**, for instance on [StackOverflow](http://stackoverflow.com/questions/tagged/gollum-wiki). + +Gollum supports [custom macros](https://github.com/gollum/gollum/wiki#macros) for the creation of additional wiki markup tags. Please **do not** use this tracker to request macros specific to your situation. However, if you have or are working on a macro that you think may be useful to more users, you can share it as a GitHub [gist](https://gist.github.com) and link to it in the [wiki](https://github.com/gollum/gollum/wiki/Custom-macros). + +Before submitting an issue, **please carefully look through the following places** to make sure your problem is not already addressed: + +1. The issue tracker. +1. The [README](https://github.com/gollum/gollum/blob/master/README.md). +1. The project's [wiki](https://github.com/gollum/gollum/wiki). + +Lastly, please **consider helping out** by opening a Pull Request! + +## Opening a Pull Request + +Pull Requests fixing bugs, implementing new features, or updating documentation and dependencies are all very welcome! If you would like to help out with the project, you can pick an open issue from the issue tracker. We're more than happy to help you get started! Here's how you can proceed: + +1. Fork and clone Gollum. +2. Create a thoughtfully named topic branch to contain your changes. +3. If you haven't installed dependencies yet, navigate to your clone and execute: + ``` + [sudo] bundle install + ``` +4. Hack away. +5. Add your own tests and make sure they're all still passing. +6. If some of your changes deserve a mention on Gollum's home page, edit the README accordingly. +7. If necessary, rebase your commits into logical chunks, without errors. +8. Push the branch to your fork on GitHub. +9. Create a pull request for Gollum. + +**Notes:** +* Do not change Gollum's version numbers, we will do that on our own. + +### Running tests + +1. Install [Bundler](http://bundler.io/). +2. Navigate to the cloned source of Gollum. +3. Install dependencies: + ``` + [sudo] bundle install + ``` +4. Run the tests: + ``` + bundle exec rake test + ``` + +### Working with test repositories + +An example of how to add a test file to the bare repository lotr.git. + +``` +mkdir tmp +cd tmp +git clone ../lotr.git/ +git log +echo "test" > test.md +git add . +git commit -am "Add test" +git push ../lotr.git/ master +``` + +## Releasing the gem + +Gollum uses [Semantic Versioning](http://semver.org/). + + x.y.z + +For z releases: + +``` +rake bump +rake release +``` + +For x.y releases: + +``` +# First update VERSION in lib/gollum.rb and then: +rake gemspec +rake release +``` \ No newline at end of file diff --git a/README.md b/README.md index ed647555..5523d98f 100644 --- a/README.md +++ b/README.md @@ -171,70 +171,3 @@ Gollum comes with the following command line options: 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](https://github.com/gollum/gollum/wiki/Formats-and-extensions) will probably stand out. **All of the mentioned alterations work both for Gollum's config file (`config.rb`) and Rack's config file (`config.ru`).** - -## HOW TO CONTRIBUTE - -1. Fork and clone Gollum. -2. Create a thoughtfully named topic branch to contain your changes. -3. If you haven't installed dependencies yet, navigate to your clone and execute: - ``` - [sudo] bundle install - ``` -4. Hack away. -5. Add your own tests and make sure they're all still passing. -6. If some of your changes deserve a mention on Gollum's home page, edit the README accordingly. -7. If necessary, rebase your commits into logical chunks, without errors. -8. Push the branch to your fork on GitHub. -9. Create a pull request for Gollum. - -**Notes:** -* Do not change Gollum's version numbers, we will do that on our own. - -### Running tests - -1. Install [Bundler](http://bundler.io/). -2. Navigate to the cloned source of Gollum. -3. Install dependencies: - ``` - [sudo] bundle install - ``` -4. Run the tests: - ``` - bundle exec rake test - ``` - -### Working with test repositories - -An example of how to add a test file to the bare repository lotr.git. - -``` -mkdir tmp -cd tmp -git clone ../lotr.git/ -git log -echo "test" > test.md -git add . -git commit -am "Add test" -git push ../lotr.git/ master -``` - -## RELEASING - -Gollum uses [Semantic Versioning](http://semver.org/). - - x.y.z - -For z releases: - -``` -rake bump -rake release -``` - -For x.y releases: - -``` -# First update VERSION in lib/gollum.rb and then: -rake gemspec -rake release -``` From 14830af30642947f5825308bb9f672d324d35490 Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Sun, 7 Aug 2016 12:50:18 +0200 Subject: [PATCH 32/34] Update CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 73edc588..e1d68fe6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to Gollum === +# Contributing to Gollum Thanks for your interset in the gollum project! @@ -88,4 +88,4 @@ For x.y releases: # First update VERSION in lib/gollum.rb and then: rake gemspec rake release -``` \ No newline at end of file +``` From 6316f97c0637562ab7096412ae96edbacb45e834 Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Sun, 7 Aug 2016 12:50:48 +0200 Subject: [PATCH 33/34] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e1d68fe6..c5496dbe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing to Gollum -Thanks for your interset in the gollum project! +Thanks for your interest in the gollum project! ## Submitting an Issue From 236680aab992d2e063fb3506494808cdd3c34005 Mon Sep 17 00:00:00 2001 From: Maarten Engelen Date: Sun, 7 Aug 2016 17:18:36 +0200 Subject: [PATCH 34/34] Add file deletion functionality Adds route for file deletion Add styles and images for this --- lib/gollum/app.rb | 13 +++++++++++++ lib/gollum/public/gollum/css/_styles.css | 17 ++++++++++++++++- .../public/gollum/images/fileview/trashcan.png | Bin 0 -> 1522 bytes 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 lib/gollum/public/gollum/images/fileview/trashcan.png diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 9e060f8d..8acf7605 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -221,6 +221,19 @@ module Precious end end + post '/deleteFile/*' do + forbid unless @allow_editing + wiki = wiki_new + filepath = params[:splat].first + unless filepath.nil? + commit = commit_message + commit[:message] = "Deleted #{filepath}" + wiki.delete_file(filepath, commit) + end + + redirect to('/fileview') + end + post '/rename/*' do wikip = wiki_page(params[:splat].first) halt 500 if wikip.nil? diff --git a/lib/gollum/public/gollum/css/_styles.css b/lib/gollum/public/gollum/css/_styles.css index c058fa2b..a9d79f56 100644 --- a/lib/gollum/public/gollum/css/_styles.css +++ b/lib/gollum/public/gollum/css/_styles.css @@ -85,6 +85,22 @@ ol.tree margin-right: 7px; vertical-align: text-top; } + li.file form + { + vertical-align:middle; + display: inline-block; + } + li.file form button + { + vertical-align:middle; + height: 20px; + padding-left: 36px; + padding-right: 10px; + border: 0px solid #000000; + background: url("../images/fileview/trashcan.png") no-repeat 16px center; + cursor: pointer; + } + } li.file a[href *= '.pdf'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; } li.file a[href *= '.html'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; } li.file a[href $= '.css'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; } @@ -125,4 +141,3 @@ ol.tree } li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */} li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ } - diff --git a/lib/gollum/public/gollum/images/fileview/trashcan.png b/lib/gollum/public/gollum/images/fileview/trashcan.png new file mode 100644 index 0000000000000000000000000000000000000000..1749e6e2b739e5c79321827da4dc65b9f83d6048 GIT binary patch literal 1522 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z81_llpi<;HsXMd|v6mX?-X(Gs7c7{+3kj2o|M`E)8SrADBDCn&MGAmMZB3v?o0Sfkop_z?7Rta>C&iOg{ zMZpD$$*CZRfwdqBp{oX46N$?jBnc#qDalsFrAb+-$t6g!1&lLr+ILD!*GCez(Z{OV z2AC48eDhN>(<)sOOH%EO3=GY54J>pG%tH*#tPCuyER1dR(bOQh03_pFl$uzQUlfv` zpJNC1MJ|Y|V5|p>Z*+O6RvUd#E<(yxkSq%p1?E{hE}%|W{-F6CoBijhF45?cyQ6Kuu3NygyK>(Ch5yC4WDdy695l2! z5T|8auFkml2J;2()TY_FM7kJT%&l6~4Y8p3C^ zd1f4tiaEd@qb->`b*bvw1)X0w#S=Kx5@gyO#c!|*9i4T9W#5XD#<1yXD>hHijsKB# zL#>ce^4+7Bcb&vA>_R=_&WwTQ=NlljeTlF<#)m zjdRxl_Zh9?FB&db=mjJ@|8J7(>dH7TKgn+P8^;&T-Uc57a}RdUITX=e$B}$1ty0H# g!&zmk^))y7pIRTYT