Merge branch 'rc' into master

Conflicts:
	bin/gollum
This commit is contained in:
Dawa Ometto
2016-08-07 21:36:13 +02:00
20 changed files with 585 additions and 374 deletions
+1 -1
View File
@@ -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
+91
View File
@@ -0,0 +1,91 @@
# Contributing to Gollum
Thanks for your interest 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
```
-3
View File
@@ -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.
+122 -185
View File
@@ -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,230 +7,167 @@ 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.
1. [Syntax/capability overview for pages](https://github.com/gollum/gollum/wiki).
2. [Known limitations](https://github.com/gollum/gollum/wiki/Known-limitations).
3. [Troubleshoot guide](https://github.com/gollum/gollum/wiki/Troubleshoot-guide).
4. [Security overview](https://github.com/gollum/gollum/wiki/Security).
Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
[TomDoc](http://tomdoc.org/) for inline documentation.
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
- 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) | almost<sup>1</sup> |
## 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 [Support Windows via JRuby - Meta Issue](https://github.com/gollum/gollum/issues/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`
* [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:
```bash
$ gollum
```
1. Navigate to your git repository (wiki) via the command line.
2. Run: `gollum`.
3. Open `http://localhost:4567` in your browser.
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:
This will start up a web server (WEBrick) running Gollum with a web interface, where you can view and edit your wiki.
```bash
$ gollum --help
```
### Running from source
This will show you the options you can pass as arguments to the `gollum` command:
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 <path-to-wiki>` instead.
5. Open `http://localhost:4567` in your browser.
```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.
```
### Rack
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).
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
### Rack, with an authentication server
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.
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).
```ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'gollum/app'
### Docker
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
```
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).
Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key.
### Service
## CONFIG FILE
Gollum can also be ran as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service).
Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gollum/gollum/blob/master/config.rb) for an example.
## CONFIGURATION
## CUSTOM CSS/JS
Gollum comes with the following command line options:
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.
| Option | Arguments | Description |
| ----------------- | --------- | ----------- |
| --host | [HOST] | Specify the hostname or IP address to listen on. Default: `0.0.0.0`.<sup>1</sup> |
| --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`. |
| --adapter | [ADAPTER] | Launch Gollum using a specific git adapter. Default: `grit`.<sup>2</sup> |
| --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 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.<sup>3,5</sup> |
| --js | none | Tell Gollum to inject custom JS into each page. Uses `custom.js` from repository root.<sup>3,5</sup> |
| --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. |
| --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.<sup>4</sup> |
| --mathjax | none | Enables MathJax (renders mathematical equations). By default, uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.<sup>5</sup> |
| --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 `<h1>` 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. |
| --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. |
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.
**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](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.
## API DOCUMENTATION
### Config file
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.
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.
## 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/).
x.y.z
For z releases:
```bash
$ 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
```
**All of the mentioned alterations work both for Gollum's config file (`config.rb`) and Rack's config file (`config.ru`).**
+153 -108
View File
@@ -2,132 +2,169 @@
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
help = <<HELP
Gollum is a multi-format Wiki Engine/API/Frontend.
Basic Command Line Usage:
gollum [OPTIONS] [PATH]
PATH The path to the Gollum repository (default .).
Options:
HELP
require 'optparse'
require 'rubygems'
require 'gollum'
require 'cgi'
exec = {}
options = { 'port' => 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 <git-repo> 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 '<git-repo>' to be bare. This is only necessary when using the grit adapter.") do
wiki_options[:repo_is_bare] = true
end
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
base_path.sub!(/^\/+/, '')
opts.on("--no-edit", "Restricts editing capability through frontend.") do
# 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 <<MSG
Warning: your base-path has been sanitized:
- original: '#{base_path_original}'
- sanitized: '#{base_path}'
MSG
end
# and finally, let others enjoy our hard work:
wiki_options[:base_path] = base_path
end
opts.on("--page-file-dir [PATH]", "Specify the subdirectory for all pages. Default: repository root.",
"Example: setting this to 'pages' will make Gollum serve only pages at '<git-repo>/pages/*'.") do |path|
wiki_options[:page_file_dir] = path
end
opts.on("--css", "Inject custom CSS into each page. The '<git-repo>/custom.css' file is used (must be committed).") do
wiki_options[:css] = true
end
opts.on("--js", "Inject custom JavaScript into each page. The '<git-repo>/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
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 '<git-repo>/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 '<h1>' 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 '<git-repo>/mathjax.config.js' file.") do |file|
wiki_options[:mathjax_config] = file || 'mathjax.config.js'
end
opts.on("--plantuml-url [URL]", "Sets the PlantUML server endpoint.") do |url|
wiki_options[:plantuml_url] = url
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
@@ -140,11 +177,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:
@@ -181,8 +216,11 @@ if options['irb']
config.url = wiki_options[:plantuml_url]
end
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 %( # => <Gollum::Page>)
puts
@@ -192,7 +230,9 @@ if options['irb']
puts %( page.formatted_data)
puts %( # => "<h1>My wiki page</h1>")
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}"
@@ -204,7 +244,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
@@ -220,21 +260,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
@@ -242,7 +286,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
+9 -26
View File
@@ -1,28 +1,11 @@
# 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" }
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 ...
+12
View File
@@ -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 ...
+79
View File
@@ -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
-33
View File
@@ -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})
```
+9 -6
View File
@@ -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 = '2016-05-19'
s.rubyforge_project = 'gollum'
s.license = 'MIT'
@@ -25,17 +25,19 @@ 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_dependency 'gemojione', '~> 2'
s.add_development_dependency 'rack-test', '~> 0.6.2'
s.add_development_dependency 'shoulda', '~> 3.5.0'
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 =
s.files = %w[
@@ -46,10 +48,11 @@ Gem::Specification.new do |s|
Rakefile
bin/gollum
config.rb
config.ru
contrib/openrc/conf.d/gollum
contrib/openrc/init.d/gollum
contrib/systemd/gollum@.service
docs/sanitization.md
contrib/sysv-debian/init.d/gollum
gollum.gemspec
lib/gollum.rb
lib/gollum/app.rb
+1 -1
View File
@@ -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__))
+39 -4
View File
@@ -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.
@@ -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)
@@ -95,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
@@ -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
@@ -164,6 +172,8 @@ module Precious
end
post '/uploadFile' do
forbid unless @allow_editing
wiki = wiki_new
unless wiki.allow_uploads
@@ -176,9 +186,10 @@ 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'
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)
@@ -211,7 +222,22 @@ 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
forbid unless @allow_editing
wikip = wiki_page(params[:splat].first)
halt 500 if wikip.nil?
wiki = wikip.wiki
@@ -248,6 +274,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
@@ -307,6 +335,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
@@ -326,6 +356,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
@@ -349,6 +381,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])
@@ -357,6 +391,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
@@ -494,7 +529,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
+13
View File
@@ -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
+16 -1
View File
@@ -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 */ }
+6
View File
@@ -849,3 +849,9 @@ ul.actions {
.clearfloats {
clear: both;
}
.emoji {
width: 20px;
height: 20px;
vertical-align: -18%;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@@ -211,6 +211,11 @@ var MarkDownHelp = [
{
menuName: 'Escaping',
data: '<p>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 (<code>\\</code>). Markdown will ignore the character directly after a backslash.'
},
{
menuName: 'Emoji',
data: '<p>See the <a href="http://emojione.com/demo/" target="_blank">EmojiOne demo</a> 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:).'
}
]
}
+1 -1
View File
@@ -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
+2 -4
View File
@@ -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
+26 -1
View File
@@ -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 => 'りんご',
@@ -694,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