gollum 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTU3NGE1YmMzZGU5ZTgyNmI4YWI1MDlmOTY3OTAwYTY3YWQ0ZDE4MA==
4
+ MWQ1MDI5NWIyNDczYzI4OTJmNzM4MDE2YTQwY2QwMzhhYmYyODU1YQ==
5
5
  data.tar.gz: !binary |-
6
- OGI4ODg5MTJlYzgzYmQ4ZmY5MTM0Y2I5NzFjOWMxNDI0NzVhN2IyOA==
6
+ NzIwMWEzNDBjM2U1NDRlYWY5YTUyNzUxMTI5YzM3ZjdiYzdiMTYwMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTg5ODBkMzhjYmY0MzgyOWQ2NmU4NDg5MzRhNjUxMTk3MDdiZDFlZmVhZTcw
10
- YmQ0Nzc2ZjU2OTI3MDIxMDNjMmI2NzhmNjZmZWM3NmU3ODIwOTRlZjdjYTNj
11
- N2ZlZTcxYTY3M2ViMmJlM2MzMGI0OTQ1ZGI2YTQzY2E2ZjU5ZjE=
9
+ MDlkZjc3YzY4Y2FlYzk5OTllMTQ4YjMwZDZmYTg4ODRmN2YzNTY3YTI0MjRl
10
+ YThkMWFiYjc1NjFlMjhiOTMyODM3Y2JmZTgwZTE4ZDBiOWQxNmFiNTA3NDlj
11
+ YzliMWRkMWRiOWRjNGJkZGE1M2MxYWI0Zjc5ZDlhODJkOTJmYTQ=
12
12
  data.tar.gz: !binary |-
13
- ZmExYjgwZjc0ZmUzOWIzMzIzYzBjMjQ2NGYyZDNiY2MwM2RmNWFmNjg2M2I5
14
- YmFmZTdkZTg4NTk2YWE1ODc0NTgwODkxNjUzN2NhZGM5OWMyOTk0NTRiZTQ4
15
- NjZiOTdhYzVjMGQ5YWVmOTk1ODI5OTNlY2Q0MTQ4YjQ2NzNjOTU=
13
+ YjFlYTZmMDBkNTM0ZTg3ZDQ0MmUzYTc5M2RiYmRmNmNmYzM1MTZmNDliNTNi
14
+ ZTQ4N2UyMmNiZDI5ZDQ1N2Y4MTAxYmIyN2MwMzYwMjQ0MzRhYjUwMGFhOTVm
15
+ ZGY0NWY2NDVjMGVlYzcwYjE5OWZmODZjNTNlZGQ0OTljYjJkMDY=
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 4.0.0 /2015-04-11
2
+
3
+ * Now compatible with JRuby (via the [rjgit](https://github.com/repotag/rjgit) [adapter](https://github.com/repotag/gollum-lib_rjgit_adapter))
4
+
1
5
  # 3.1.1 /2014-12-04
2
6
 
3
7
  * Security fix for [remote code execution issue](https://github.com/gollum/gollum/issues/913). Please update!
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- gollum -- A wiki built on top of Git
1
+ gollum -- A git-based Wiki
2
2
  ====================================
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/gollum.svg)](http://badge.fury.io/rb/gollum)
@@ -7,178 +7,211 @@ gollum -- A wiki built on top of Git
7
7
 
8
8
  ## DESCRIPTION
9
9
 
10
- Gollum is a simple wiki system built on top of Git.
10
+ 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:
11
+ * 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.
12
+ * Gollum pages:
13
+ * May be written in a variety of [markups](#markups).
14
+ * Can be edited with your favourite system editor or IDE (changes will be visible after committing) or with the built-in web interface.
15
+ * Can be displayed in all versions (commits).
11
16
 
12
- Gollum wikis are simply Git repositories that adhere to a specific format.
13
- Gollum pages may be written in a variety of formats and can be edited in a
14
- number of ways depending on your needs. You can edit your wiki locally:
17
+ 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.
15
18
 
16
- * With your favorite text editor or IDE (changes will be visible after committing).
17
- * With the built-in web interface.
18
- * With the Gollum Ruby API.
19
+ For more information on Gollum's capabilities and pitfalls:
19
20
 
20
- Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
21
- [TomDoc](http://tomdoc.org/) for inline documentation.
21
+ 1. [Syntax/capability overview for pages](https://github.com/gollum/gollum/wiki).
22
+ 2. [Known limitations](https://github.com/gollum/gollum/wiki/Known-limitations).
23
+ 3. [Troubleshoot guide](https://github.com/gollum/gollum/wiki/Troubleshoot-guide).
24
+ 4. [Security overview](https://github.com/gollum/gollum/wiki/Security).
22
25
 
23
26
  ## SYSTEM REQUIREMENTS
24
27
 
25
- - Python 2.5+ (2.7.3 recommended)
26
- - Ruby 1.9.3+ (1.9.3 recommended)
27
- - Unix like operating system (OS X, Ubuntu, Debian, and more)
28
- - Will not work on Windows (because of [grit](https://github.com/github/grit))
28
+ | Operating System | Ruby | Adapters | Supported |
29
+ | ---------------- | -------------- | ------------------ | --------- |
30
+ | Unix/Linux-like | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | yes |
31
+ | Unix/Linux-like | [JRuby](https://github.com/jruby/jruby) (1.9.3+ compatible) | [RJGit](https://github.com/repotag/rjgit) | yes |
32
+ | Windows | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | no |
33
+ | Windows | [JRuby](https://github.com/jruby/jruby) (1.9.3+ compatible) | [RJGit](https://github.com/repotag/rjgit) | almost<sup>1</sup> |
29
34
 
30
- ## SECURITY
35
+ **Notes:**
31
36
 
32
- Don't enable `--custom-css`, `--custom-js` or `--mathjax-config` unless you trust every user who has the ability to edit the wiki.
33
- A better solution with more security is being tracked in [#665](https://github.com/gollum/gollum/issues/665).
37
+ 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).
34
38
 
35
39
  ## INSTALLATION
36
40
 
37
- The best way to install Gollum is with RubyGems:
38
-
39
- ```bash
40
- $ [sudo] gem install gollum
41
- ```
42
- You may first need to install some additional [development packages](https://github.com/gollum/gollum/wiki/Installation) for your OS.
43
-
44
- If you're installing from source, you can use [Bundler][bundler] to pick up all the
45
- gems:
46
-
47
- ```bash
48
- $ bundle install
49
- ```
50
-
51
- In order to use the various formats that Gollum supports, you will need to
52
- separately install the necessary dependencies for each format. You only need
53
- to install the dependencies for the formats that you plan to use.
54
-
55
- * [AsciiDoc](http://asciidoctor.org) -- `gem install asciidoctor`
56
- * [Creole](http://www.wikicreole.org/) -- `gem install creole`
57
- * [Markdown](http://daringfireball.net/projects/markdown/) -- `gem install redcarpet`
58
- * [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `gem install github-markdown`
59
- * [Org](http://orgmode.org/) -- `gem install org-ruby`
60
- * [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.
41
+ Varies depending on operating system, package manager and Ruby installation. Generally, you should first install Ruby and then Gollum.
42
+
43
+ 1. Ruby is best installed either via [RVM](https://rvm.io/) or a package manager of choice.
44
+ 2. Gollum is best installed via RubyGems:
45
+ ```
46
+ [sudo] gem install gollum
47
+ ```
48
+
49
+ Installation examples for individual systems can be seen [here](https://github.com/gollum/gollum/wiki/Installation).
50
+
51
+ **Notes:**
52
+ * 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.
53
+ * If you're installing from source:
54
+ * Optionally uninstall any previous versions of Gollum:
55
+ ```
56
+ [sudo] gem uninstall -aIx gollum
57
+ ```
58
+ * Install [Bundler](http://bundler.io/).
59
+ * Navigate to the cloned source of Gollum.
60
+ * Install dependencies:
61
+ ```
62
+ [sudo] bundle install
63
+ ```
64
+ * Build:
65
+ ```
66
+ rake build
67
+ ```
68
+ * And install:
69
+ ```
70
+ [sudo] gem install --no-ri --no-rdoc pkg/gollum*.gem
71
+ ```
72
+
73
+ ### Markups
74
+
75
+ Gollum presently ships with support for the following markups:
76
+ * [Markdown](http://daringfireball.net/projects/markdown/syntax)
61
77
  * [RDoc](http://rdoc.sourceforge.net/)
62
- * [ReStructuredText](http://docutils.sourceforge.net/rst.html) -- `easy_install docutils`
63
- * [Textile](http://en.wikipedia.org/wiki/Textile_(markup_language)) -- `gem install RedCloth`
64
- * [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `gem install wikicloth`
65
78
 
66
- [bundler]: http://gembundler.com/
79
+ 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:
80
+ * [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `[sudo] gem install asciidoctor`
81
+ * [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `[sudo] gem install creole`
82
+ * [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `[sudo] gem install github-markdown`
83
+ * [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `[sudo] gem install wikicloth`
84
+ * [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `[sudo] gem install org-ruby`
85
+ * [Pod](http://perldoc.perl.org/perlpod.html) -- requires Perl >= 5.10 (the `perl` command must be available on your command line)
86
+ * Lower versions should install `Pod::Simple` from CPAN.
87
+ * [ReStructuredText](http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html) -- requires python >= 2 (the `python2` command must be available on your command line)
88
+ * 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.
89
+ * [Textile](http://redcloth.org/hobix.com/textile/quick.html) -- `[sudo] gem install RedCloth`
67
90
 
91
+ 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.
68
92
 
69
- ## SYNTAX
93
+ ## RUNNING
70
94
 
71
- Gollum supports a variety of formats and extensions (Markdown, MediaWiki, Textile, …).
72
- On top of these formats Gollum lets you insert headers, footers, links, image, math and more.
95
+ Simply:
73
96
 
74
- Check out the [Gollum Wiki](https://github.com/gollum/gollum/wiki) for all of Gollum's formats and syntactic options.
97
+ 1. Navigate to your git repository (wiki) via the command line.
98
+ 2. Run: `gollum`.
99
+ 3. Open `http://localhost:4567` in your browser.
75
100
 
101
+ If you wish to run from source, simply:
76
102
 
77
- ## RUNNING
103
+ 1. Navigate to your git repository (wiki) via the command line.
104
+ 2. Run: `bundle exec bin/gollum`
105
+ 3. Open `http://localhost:4567` in your browser.
78
106
 
79
- To view and edit your Gollum repository locally via the built in web
80
- interface, simply install the Gollum gem, navigate to your repository via the
81
- command line, and run the executable:
107
+ This will start up a web server (WEBrick) running Gollum with a web interface, where you can view and edit your wiki.
82
108
 
83
- ```bash
84
- $ gollum
85
- ```
109
+ ### Rack
86
110
 
87
- This will start up a web server running the Gollum frontend and you can view
88
- and edit your wiki at http://localhost:4567. To get help on the command line
89
- utility, you can run it like so:
111
+ 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).
90
112
 
91
- ```bash
92
- $ gollum --help
93
- ```
113
+ ### Rack, with an authentication server
94
114
 
95
- This will show you the options you can pass as arguments to the `gollum` command:
96
-
97
- ```bash
98
- Options:
99
- --port [PORT] Bind port (default 4567).
100
- --host [HOST] Hostname or IP address to listen on (default 0.0.0.0).
101
- --version Display current version.
102
- --config [CONFIG] Path to additional configuration file.
103
- --adapter [ADAPTER] Git adapter to use in the backend. Defaults to grit.
104
- --irb Start an irb process with gollum loaded for the current wiki.
105
- --css Inject custom css. Uses custom.css from root repository.
106
- --js Inject custom js. Uses custom.js from root repository.
107
- --template-dir [PATH] Specify custom template directory.
108
- --page-file-dir [PATH] Specify the sub directory for all page files (default: repository root).
109
- --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/.
110
- --gollum-path [PATH] Specify the path to the git repository to be served.
111
- --ref [REF] Specify the repository ref to use (default: master).
112
- --bare Specify that the repository is bare (only necessary when using the grit adapter).
113
- --no-edit Restricts editing capability through frontend.
114
- --no-live-preview Disables livepreview.
115
- --live-preview Enables livepreview.
116
- --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).
117
- --mathjax Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default.
118
- --mathjax-config [SOURCE] Inject custom mathjax config file. Uses mathjax.config.js from root repository by default.
119
- --user-icons [SOURCE] Set the history user icons. Valid values: gravatar, identicon, none. Default: none.
120
- --show-all Shows all files in file view. By default only valid pages are shown.
121
- --collapse-tree Collapse file view tree. By default, expanded tree is shown.
122
- --h1-title Sets page title to value of first h1.
123
- ```
115
+ 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).
124
116
 
125
- 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).
117
+ ### Docker
126
118
 
127
- ### RACK
119
+ 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).
128
120
 
129
- You can also run gollum with any rack-compatible server by placing configuring a config.ru
130
- 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.
121
+ ### Service
131
122
 
132
- ```ruby
133
- #!/usr/bin/env ruby
134
- require 'rubygems'
135
- require 'gollum/app'
123
+ Gollum can also be ran as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service).
136
124
 
137
- gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO
138
- Precious::App.set(:gollum_path, gollum_path)
139
- Precious::App.set(:default_markup, :markdown) # set your favorite markup language
140
- Precious::App.set(:wiki_options, {:universal_toc => false})
141
- run Precious::App
142
- ```
125
+ ## CONFIGURATION
143
126
 
144
- Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key.
127
+ Gollum comes with the following command line options:
145
128
 
146
- ## CONFIG FILE
129
+ | Option | Arguments | Description |
130
+ | ----------------- | --------- | ----------- |
131
+ | --host | [HOST] | Specify the hostname or IP address to listen on. Default: `0.0.0.0`.<sup>1</sup> |
132
+ | --port | [PORT] | Specify the port to bind Gollum with. Default: `4567`. |
133
+ | --config | [FILE] | Specify path to Gollum's configuration file. |
134
+ | --ref | [REF] | Specify the git branch to serve. Default: `master`. |
135
+ | --adapter | [ADAPTER] | Launch Gollum using a specific git adapter. Default: `grit`.<sup>2</sup> |
136
+ | --bare | none | Tell Gollum that the git repository should be treated as bare. This is only necessary when using the default grit adapter. |
137
+ | --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: `/`. |
138
+ | --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. |
139
+ | --css | none | Tell Gollum to inject custom CSS into each page. Uses `custom.css` from repository root.<sup>3,5</sup> |
140
+ | --js | none | Tell Gollum to inject custom JS into each page. Uses `custom.js` from repository root.<sup>3,5</sup> |
141
+ | --no-edit | none | Disable the feature of editing pages. |
142
+ | --live-preview | none | Enable the live preview feature in page editor. |
143
+ | --no-live-preview | none | Disable the live preview feature in page editor. |
144
+ | --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> |
145
+ | --mathjax | none | Enables MathJax (renders mathematical equations). By default, uses the `TeX-AMS-MML_HTMLorMML` config with the `autoload-all` extension.<sup>5</sup> |
146
+ | --irb | none | Launch Gollum in "console mode", with a [predefined API](https://github.com/gollum/gollum-lib/). |
147
+ | --h1-title | none | Tell Gollum to use the first `<h1>` as page title. |
148
+ | --show-all | none | Tell Gollum to also show files in the file view. By default, only valid pages are shown. |
149
+ | --collapse-tree | none | Tell Gollum to collapse the file tree, when the file view is opened. By default, the tree is expanded. |
150
+ | --user-icons | [MODE] | Tell Gollum to use specific user icons for history view. Can be set to `gravatar`, `identicon` or `none`. Default: `none`. |
151
+ | --mathjax-config | [FILE] | Specify path to a custom MathJax configuration. If not specified, uses the `mathjax.config.js` file from repository root. |
152
+ | --template-dir | [PATH] | Specify custom mustache template directory. |
153
+ | --help | none | Display the list of options on the command line. |
154
+ | --version | none | Display the current version of Gollum. |
147
155
 
148
- Gollum optionally takes a `--config file`. See [config.rb](https://github.com/gollum/gollum/blob/master/config.rb) for an example.
156
+ **Notes:**
149
157
 
150
- ## CUSTOM CSS/JS
158
+ 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`.
159
+ 2. Before using `--adapter`, you should probably read [this](https://github.com/gollum/gollum/wiki/Git-adapters) first.
160
+ 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.
161
+ 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).
162
+ 5. Read the relevant [Security note](https://github.com/gollum/gollum/wiki/Security#custom-cssjs--mathjax-config) before using these.
151
163
 
152
- 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.
164
+ ### Config file
153
165
 
154
- 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.
166
+ 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.
155
167
 
168
+ **All of the mentioned alterations work both for Gollum's config file (`config.rb`) and Rack's config file (`config.ru`).**
156
169
 
157
- ## API DOCUMENTATION
170
+ ## HOW TO CONTRIBUTE
158
171
 
159
- The [Gollum API](https://github.com/gollum/gollum-lib/) allows you to retrieve
160
- raw or formatted wiki content from a Git repository, write new content to the
161
- repository, and collect various meta data about the wiki as a whole.
172
+ 1. Fork and clone Gollum.
173
+ 2. Create a thoughtfully named topic branch to contain your changes.
174
+ 3. If you haven't installed dependencies yet, navigate to your clone and execute:
175
+ ```
176
+ [sudo] bundle install
177
+ ```
178
+ 4. Hack away.
179
+ 5. Add your own tests and make sure they're all still passing.
180
+ 6. If some of your changes deserve a mention on Gollum's home page, edit the README accordingly.
181
+ 7. If necessary, rebase your commits into logical chunks, without errors.
182
+ 8. Push the branch to your fork on GitHub.
183
+ 9. Create a pull request for Gollum.
162
184
 
185
+ **Notes:**
186
+ * Do not change Gollum's version numbers, we will do that on our own.
163
187
 
164
- ## CONTRIBUTE
188
+ ### Running tests
165
189
 
166
- If you'd like to hack on Gollum, start by forking the repo on GitHub:
190
+ 1. Install [Bundler](http://bundler.io/).
191
+ 2. Navigate to the cloned source of Gollum.
192
+ 3. Install dependencies:
193
+ ```
194
+ [sudo] bundle install
195
+ ```
196
+ 4. Run the tests:
197
+ ```
198
+ bundle exec rake test
199
+ ```
167
200
 
168
- http://github.com/gollum/gollum
201
+ ### Working with test repositories
169
202
 
170
- To get all of the dependencies, install the gem first. The best way to get
171
- your changes merged back into core is as follows:
203
+ An example of how to add a test file to the bare repository lotr.git.
172
204
 
173
- 1. Clone down your fork
174
- 1. Create a thoughtfully named topic branch to contain your change
175
- 1. Hack away
176
- 1. Add tests and make sure everything still passes by running `rake`
177
- 1. If you are adding new functionality, document it in the README
178
- 1. Do not change the version number, I will do that on my end
179
- 1. If necessary, rebase your commits into logical chunks, without errors
180
- 1. Push the branch up to GitHub
181
- 1. Send a pull request to the gollum/gollum project.
205
+ ```
206
+ mkdir tmp
207
+ cd tmp
208
+ git clone ../lotr.git/
209
+ git log
210
+ echo "test" > test.md
211
+ git add .
212
+ git commit -am "Add test"
213
+ git push ../lotr.git/ master
214
+ ```
182
215
 
183
216
  ## RELEASING
184
217
 
@@ -188,47 +221,15 @@ Gollum uses [Semantic Versioning](http://semver.org/).
188
221
 
189
222
  For z releases:
190
223
 
191
- ```bash
192
- $ rake bump
193
- $ rake release
194
224
  ```
195
-
196
- For x.y releases:
197
-
198
- ```bash
199
- Update VERSION in lib/gollum.rb
200
- $ rake gemspec
201
- $ rake release
225
+ rake bump
226
+ rake release
202
227
  ```
203
228
 
204
- ## BUILDING THE GEM FROM MASTER
205
-
206
- ```bash
207
- $ gem uninstall -aIx gollum
208
- $ git clone https://github.com/gollum/gollum.git
209
- $ cd gollum
210
- gollum$ rake build
211
- gollum$ gem install --no-ri --no-rdoc pkg/gollum*.gem
212
- ```
213
-
214
- ## RUN THE TESTS
229
+ For x.y releases:
215
230
 
216
- ```bash
217
- $ bundle install
218
- $ bundle exec rake test
219
231
  ```
220
-
221
- ## WORK WITH TEST REPOS
222
-
223
- An example of how to add a test file to the bare repository lotr.git.
224
-
225
- ```bash
226
- $ mkdir tmp; cd tmp
227
- $ git clone ../lotr.git/ .
228
- Cloning into '.'...
229
- done.
230
- $ git log
231
- $ echo "test" > test.md
232
- $ git add . ; git commit -am "Add test"
233
- $ git push ../lotr.git/ master
232
+ # First update VERSION in lib/gollum.rb and then:
233
+ rake gemspec
234
+ rake release
234
235
  ```
data/bin/gollum CHANGED
@@ -2,128 +2,166 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
- help = <<HELP
6
- Gollum is a multi-format Wiki Engine/API/Frontend.
7
-
8
- Basic Command Line Usage:
9
- gollum [OPTIONS] [PATH]
10
-
11
- PATH The path to the Gollum repository (default .).
12
-
13
- Options:
14
- HELP
15
-
16
5
  require 'optparse'
17
6
  require 'rubygems'
18
7
  require 'gollum'
8
+ require 'cgi'
19
9
 
20
10
  exec = {}
21
- options = { 'port' => 4567, 'bind' => '0.0.0.0' }
11
+ options = {
12
+ :port => 4567,
13
+ :bind => '0.0.0.0',
14
+ }
22
15
  wiki_options = {
23
- :live_preview => false,
24
- :allow_uploads => false,
25
- :allow_editing => true,
16
+ :live_preview => false,
17
+ :allow_uploads => false,
18
+ :allow_editing => true,
26
19
  }
27
20
 
28
21
  opts = OptionParser.new do |opts|
29
- opts.banner = help
30
-
31
- opts.on("--port [PORT]", "Bind port (default 4567).") do |port|
32
- options['port'] = port.to_i
22
+ # define program name (although this defaults to the name of the file, just in case...)
23
+ opts.program_name = "gollum"
24
+
25
+ # set basic info for the "--help" command (options will be appended automatically from the below definitions)
26
+ opts.banner = '
27
+ Gollum is a multi-format Wiki Engine/API/Frontend.
28
+
29
+ Usage:
30
+ gollum [options] [git-repo]
31
+
32
+ Arguments:
33
+ [git-repo] Path to the git repository being served. If not specified, current working directory is used.
34
+
35
+ Notes:
36
+ Paths for all options are relative to <git-repo> unless absolute.
37
+ This message is only a basic description. For more information, please visit:
38
+ https://github.com/gollum/gollum
39
+
40
+ OPTIONS'
41
+
42
+ # define gollum options
43
+ opts.separator ""
44
+ opts.separator " Major:"
45
+
46
+ opts.on("-h", "--host [HOST]", "Specify the hostname or IP address to listen on. Default: '0.0.0.0'.") do |host|
47
+ options[:bind] = host
33
48
  end
34
-
35
- opts.on("--host [HOST]", "Hostname or IP address to listen on (default 0.0.0.0).") do |host|
36
- options['bind'] = host
49
+ opts.on("-p", "--port [PORT]", "Specify the port to bind Gollum with. Default: '4567'.") do |port|
50
+ begin
51
+ # don't use "port.to_i" here... it doesn't raise errors which might result in a nice confusion later on
52
+ options[:port] = Integer(port)
53
+ rescue ArgumentError
54
+ puts "Error: '#{port}' is not a valid port number."
55
+ exit 1
56
+ end
37
57
  end
38
-
39
- opts.on("--version", "Display current version.") do
40
- puts "Gollum " + Gollum::VERSION
41
- exit 0
58
+ opts.on("-c", "--config [FILE]", "Specify path to the Gollum's configuration file.") do |file|
59
+ options[:config] = file
42
60
  end
43
-
44
- opts.on("--config [CONFIG]", "Path to additional configuration file") do |config|
45
- options['config'] = config
61
+ opts.on("-r", "--ref [REF]", "Specify the branch to serve. Default: 'master'.") do |ref|
62
+ wiki_options[:ref] = ref
46
63
  end
47
-
48
- opts.on("--adapter [ADAPTER]", "Git adapter to use in the backend. Defaults to grit.") do |adapter|
64
+ opts.on("-a", "--adapter [ADAPTER]", "Launch Gollum using a specific git adapter. Default: 'grit'.") do |adapter|
49
65
  Gollum::GIT_ADAPTER = adapter
50
66
  end
51
-
52
- opts.on("--irb", "Start an irb process with gollum loaded for the current wiki.") do
53
- options['irb'] = true
54
- end
55
-
56
- opts.on("--css", "Inject custom css. Uses custom.css from root repository") do
57
- wiki_options[:css] = true
58
- end
59
-
60
- opts.on("--js", "Inject custom js. Uses custom.js from root repository") do
61
- wiki_options[:js] = true
67
+ opts.on("--bare", "Declare '<git-repo>' to be bare. This is only necessary when using the grit adapter.") do
68
+ wiki_options[:repo_is_bare] = true
62
69
  end
63
-
64
- opts.on("--template-dir [PATH]", "Specify custom template directory") do |path|
65
- wiki_options[:template_dir] = path
70
+ opts.on("-b", "--base-path [PATH]", "Specify the leading portion of all Gollum URLs (path info). Default: '/'.",
71
+ "Example: setting this to '/wiki' will make the wiki accessible under 'http://localhost:4567/wiki/'.") do |base_path|
72
+
73
+ # first trim a leading slash, if any
74
+ if base_path.start_with?("/")
75
+ base_path = base_path[1..-1]
76
+ end
77
+
78
+ # make a backup of the option and sanitize it
79
+ base_path_original = base_path.dup
80
+ base_path = CGI.escape(base_path)
81
+
82
+ # then let the user know if we changed the URL
83
+ unless base_path_original == base_path
84
+ puts <<MSG
85
+ Warning: your base-path has been sanitized:
86
+ - original: '#{base_path_original}'
87
+ - sanitized: '#{base_path}'
88
+ MSG
89
+ end
90
+
91
+ # and finally, let others enjoy our hard work:
92
+ wiki_options[:base_path] = base_path
66
93
  end
67
-
68
- opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
94
+ opts.on("--page-file-dir [PATH]", "Specify the subdirectory for all pages. Default: repository root.",
95
+ "Example: setting this to 'pages' will make Gollum serve only pages at '<git-repo>/pages/*'.") do |path|
69
96
  wiki_options[:page_file_dir] = path
70
97
  end
71
-
72
- 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|
73
- wiki_options[:base_path] = path
74
- end
75
-
76
- opts.on("--gollum-path [PATH]", "Specify the path to the git repository to be served.") do |path|
77
- wiki_options[:gollum_path] = path
78
- end
79
-
80
- opts.on("--ref [REF]", "Specify the repository ref to use (default: master).") do |ref|
81
- wiki_options[:ref] = ref
98
+ opts.on("--css", "Inject custom CSS into each page. The '<git-repo>/custom.css' file is used (must be committed).") do
99
+ wiki_options[:css] = true
82
100
  end
83
-
84
- opts.on("--bare", "Specify that the repository is bare (only necessary when using the grit adapter).") do
85
- wiki_options[:repo_is_bare] = true
101
+ opts.on("--js", "Inject custom JavaScript into each page. The '<git-repo>/custom.js' file is used (must be committed).") do
102
+ wiki_options[:js] = true
86
103
  end
87
-
88
- opts.on("--no-edit", "Restricts editing capability through frontend.") do
104
+ opts.on("--no-edit", "Disable the feature of editing pages.") do
89
105
  wiki_options[:allow_editing] = false
90
106
  end
91
-
92
- opts.on("--no-live-preview", "Disables livepreview.") do
93
- wiki_options[:live_preview] = false
94
- end
95
-
96
- opts.on("--live-preview", "Enables livepreview.") do
107
+ opts.on("--live-preview", "Enable the live preview feature in page editor.") do
97
108
  wiki_options[:live_preview] = true
98
109
  end
99
-
100
- 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|
110
+ opts.on("--no-live-preview", "Disable the live preview feature in page editor.") do
111
+ wiki_options[:live_preview] = false
112
+ end
113
+ opts.on("--allow-uploads [MODE]", [:dir, :page], "Enable file uploads.",
114
+ "If set to 'dir', Gollum will store all uploads in the '<git-repo>/uploads/' directory.",
115
+ "If set to 'page', Gollum will store each upload at the currently edited page.") do |mode|
101
116
  wiki_options[:allow_uploads] = true
102
117
  wiki_options[:per_page_uploads] = true if mode == :page
103
118
  end
104
-
105
- opts.on("--mathjax", "Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default.") do
119
+ opts.on("--mathjax", "Enable MathJax (renders mathematical equations).",
120
+ "By default, uses the 'TeX-AMS-MML_HTMLorMML' config with the 'autoload-all' extension.") do
106
121
  wiki_options[:mathjax] = true
107
122
  end
108
-
109
- opts.on("--mathjax-config [SOURCE]", "Inject custom mathjax config file. Uses mathjax.config.js from root repository by default") do |source|
110
- wiki_options[:mathjax_config] = source || 'mathjax.config.js'
123
+ opts.on("--irb", "Launch Gollum in 'console mode', with a predefined API.") do
124
+ options[:irb] = true
111
125
  end
112
-
113
- opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source|
114
- wiki_options[:user_icons] = source
126
+
127
+ opts.separator ""
128
+ opts.separator " Minor:"
129
+
130
+ opts.on("--h1-title", "Use the first '<h1>' as page title.") do
131
+ wiki_options[:h1_title] = true
115
132
  end
116
-
117
- opts.on("--show-all", "Shows all files in file view. By default only valid pages are shown.") do
133
+ opts.on("--show-all", "Also show files in the file view. By default, only valid pages are shown.") do
118
134
  wiki_options[:show_all] = true
119
135
  end
120
-
121
- opts.on("--collapse-tree", "Collapse file view tree. By default, expanded tree is shown.") do
136
+ opts.on("--collapse-tree", "Collapse the tree, when file view is opened. By default, the tree is expanded.") do
122
137
  wiki_options[:collapse_tree] = true
123
138
  end
124
- opts.on("--h1-title", "Sets page title to value of first h1") do
125
- wiki_options[:h1_title] = true
139
+ opts.on("--user-icons [MODE]", [:gravatar, :identicon, :none], "Use specific user-icons for history view.",
140
+ "Can be set to 'gravatar', 'identicon' or 'none'. Default: 'none'.") do |mode|
141
+ wiki_options[:user_icons] = mode
126
142
  end
143
+ opts.on("--mathjax-config [FILE]", "Specify path to a custom MathJax configuration.",
144
+ "If not specified, uses the '<git-repo>/mathjax.config.js' file.") do |file|
145
+ wiki_options[:mathjax_config] = file || 'mathjax.config.js'
146
+ end
147
+ opts.on("--template-dir [PATH]", "Specify custom mustache template directory.") do |path|
148
+ wiki_options[:template_dir] = path
149
+ end
150
+
151
+ opts.separator ""
152
+ opts.separator " Common:"
153
+
154
+ opts.on("--help", "Display this message.") do
155
+ puts opts
156
+ exit 0
157
+ end
158
+ opts.on("--version", "Display the current version of Gollum.") do
159
+ puts "Gollum " + Gollum::VERSION
160
+ exit 0
161
+ end
162
+
163
+ opts.separator ""
164
+
127
165
  end
128
166
 
129
167
  # Read command line options into `options` hash
@@ -136,11 +174,9 @@ rescue OptionParser::InvalidOption
136
174
  end
137
175
 
138
176
  # --gollum-path wins over ARGV[0]
139
- gollum_path = wiki_options[:gollum_path] ?
140
- wiki_options[:gollum_path] :
141
- ARGV[0] || Dir.pwd
177
+ gollum_path = ARGV[0] || Dir.pwd
142
178
 
143
- if options['irb']
179
+ if options[:irb]
144
180
  require 'irb'
145
181
  # http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/
146
182
  module IRB # :nodoc:
@@ -171,8 +207,11 @@ if options['irb']
171
207
  if !wiki.exist? then
172
208
  raise Gollum::InvalidGitRepositoryError
173
209
  end
174
- puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}."
175
210
  puts
211
+ puts "Loaded Gollum wiki at:"
212
+ puts "#{File.expand_path(gollum_path).inspect}"
213
+ puts
214
+ puts "Example API calls:"
176
215
  puts %( page = wiki.page('page-name'))
177
216
  puts %( # => <Gollum::Page>)
178
217
  puts
@@ -182,7 +221,9 @@ if options['irb']
182
221
  puts %( page.formatted_data)
183
222
  puts %( # => "<h1>My wiki page</h1>")
184
223
  puts
185
- puts "Check out the Gollum README for more."
224
+ puts "Full API documentation at:"
225
+ puts "https://github.com/gollum/gollum-lib"
226
+ puts
186
227
  IRB.start_session(binding)
187
228
  rescue Gollum::InvalidGitRepositoryError, Gollum::NoSuchPathError
188
229
  puts "Invalid Gollum wiki at #{File.expand_path(gollum_path).inspect}"
@@ -194,7 +235,7 @@ else
194
235
  Precious::App.set(:wiki_options, wiki_options)
195
236
  Precious::App.settings.mustache[:templates] = wiki_options[:template_dir] if wiki_options[:template_dir]
196
237
 
197
- if cfg = options['config']
238
+ if cfg = options[:config]
198
239
  # If the path begins with a '/' it will be considered an absolute path,
199
240
  # otherwise it will be relative to the CWD
200
241
  cfg = File.join(Dir.getwd, cfg) unless cfg.slice(0) == File::SEPARATOR
@@ -203,21 +244,25 @@ else
203
244
 
204
245
  base_path = wiki_options[:base_path]
205
246
 
206
- if wiki_options[:base_path].nil?
247
+ if base_path.nil?
207
248
  Precious::App.run!(options)
208
249
  else
209
250
  require 'rack'
210
251
 
211
252
  class MapGollum
212
- def initialize base_path
253
+ def initialize(base_path)
213
254
  @mg = Rack::Builder.new do
255
+
256
+ map "/#{base_path}" do
257
+ run Precious::App
258
+ end
214
259
  map '/' do
215
260
  run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
216
261
  end
217
-
218
- map "/#{base_path}" do
219
- run Precious::App
262
+ map '/*' do
263
+ run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
220
264
  end
265
+
221
266
  end
222
267
  end
223
268
 
@@ -225,7 +270,8 @@ else
225
270
  @mg.call(env)
226
271
  end
227
272
  end
273
+
228
274
  # Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
229
- Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start
275
+ Rack::Server.new(:app => MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start
230
276
  end
231
277
  end
data/config.rb CHANGED
@@ -1,28 +1,11 @@
1
- # Example gollum config
2
- # gollum ../wiki --config config.rb
3
- #
4
- # or run from source with
5
- #
6
- # bundle exec bin/gollum ../wiki/ --config config.rb
1
+ =begin
2
+ This file can be used to (e.g.):
3
+ - alter certain inner parts of Gollum,
4
+ - extend it with your stuff.
7
5
 
8
- # Remove const to avoid
9
- # warning: already initialized constant FORMAT_NAMES
10
- #
11
- # only remove if it's defined.
12
- # constant Gollum::Page::FORMAT_NAMES not defined (NameError)
13
- Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES
14
- # limit to one format
15
- Gollum::Page::FORMAT_NAMES = { :markdown => "Markdown" }
6
+ It is especially useful for customizing supported formats/markups. For more information and examples:
7
+ - https://github.com/gollum/gollum#config-file
16
8
 
17
- =begin
18
- Valid formats are:
19
- { :markdown => "Markdown",
20
- :textile => "Textile",
21
- :rdoc => "RDoc",
22
- :org => "Org-mode",
23
- :creole => "Creole",
24
- :rest => "reStructuredText",
25
- :asciidoc => "AsciiDoc",
26
- :mediawiki => "MediaWiki",
27
- :pod => "Pod" }
28
9
  =end
10
+
11
+ # enter your Ruby code here ...
@@ -0,0 +1,12 @@
1
+ =begin
2
+ You should use this file, if you wish to:
3
+ - launch Gollum as a Rack app,
4
+ - alter certain startup behaviour of Gollum.
5
+
6
+ For more information and examples:
7
+ - https://github.com/gollum/gollum/wiki/Gollum-via-Rack
8
+ - https://github.com/gollum/gollum#config-file
9
+
10
+ =end
11
+
12
+ # enter your Ruby code here ...
@@ -0,0 +1,79 @@
1
+ #!/bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: gollum
4
+ # Required-Start: $local_fs $remote_fs $network $syslog
5
+ # Required-Stop: $local_fs $remote_fs $network $syslog
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # X-Interactive: true
9
+ # Short-Description: Start/stop gollum wiki
10
+ ### END INIT INFO
11
+
12
+ # Distributed under the terms of the MIT License
13
+
14
+ set -e
15
+
16
+ # Edit these settings to your liking:
17
+ GOLLUM_USER=gollum
18
+ GOLLUM_BASE=/var/lib/gollum/.git
19
+ GOLLUM_OPTS="--bare"
20
+
21
+ NAME=gollum
22
+ PID=/var/run/${NAME}.pid
23
+ EXEC=/usr/local/bin/gollum
24
+ LOG=/var/log/gollum.log
25
+
26
+ . /lib/lsb/init-functions
27
+
28
+ start ()
29
+ {
30
+ # Change log file to be owned by GOLLUM_USER
31
+ touch "${LOG}"
32
+ chown "${GOLLUM_USER}" "${LOG}"
33
+
34
+ log_daemon_msg "Starting Gollum"
35
+ start-stop-daemon --start \
36
+ --name "${NAME}" \
37
+ --user "${GOLLUM_USER}" \
38
+ --chuid "${GOLLUM_USER}" \
39
+ --pidfile "${PID}" \
40
+ --make-pidfile --background \
41
+ --startas /bin/sh -- -c "exec ${EXEC} $GOLLUM_OPTS \"$GOLLUM_BASE\" > \"${LOG}\" 2>&1"
42
+ log_end_msg $?
43
+ }
44
+
45
+ stop ()
46
+ {
47
+ log_daemon_msg "Stopping Gollum"
48
+ start-stop-daemon --stop \
49
+ --user "${GOLLUM_USER}" \
50
+ --signal INT \
51
+ --pidfile "${PID}" \
52
+ --retry 10
53
+ log_end_msg $?
54
+ }
55
+
56
+ status ()
57
+ {
58
+ status_of_proc -p $PID $EXEC $NAME
59
+ }
60
+
61
+ case $1 in
62
+ start)
63
+ start
64
+ ;;
65
+ stop)
66
+ stop
67
+ ;;
68
+ restart)
69
+ stop
70
+ start
71
+ ;;
72
+ status)
73
+ status
74
+ ;;
75
+ *)
76
+ log_success_msg "Usage: $0 {start|stop|restart|status}"
77
+ exit 1
78
+ ;;
79
+ esac
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.required_ruby_version = '>= 1.9'
6
6
 
7
7
  s.name = 'gollum'
8
- s.version = '4.0.0'
9
- s.date = '2015-04-11'
8
+ s.version = '4.0.1'
9
+ s.date = '2015-09-20'
10
10
  s.rubyforge_project = 'gollum'
11
11
  s.license = 'MIT'
12
12
 
@@ -25,16 +25,18 @@ Gem::Specification.new do |s|
25
25
  s.extra_rdoc_files = %w[README.md LICENSE]
26
26
 
27
27
  s.add_dependency 'gollum-lib', '~> 4.0', '>= 4.0.1'
28
- s.add_dependency 'kramdown', '~> 1.6.0'
28
+ s.add_dependency 'kramdown', '~> 1.8.0'
29
29
  s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4'
30
30
  s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
31
- s.add_dependency 'useragent', '~> 0.10.0'
31
+ s.add_dependency 'useragent', '~> 0.14.0'
32
32
 
33
33
  s.add_development_dependency 'rack-test', '~> 0.6.2'
34
34
  s.add_development_dependency 'shoulda', '~> 3.5.0'
35
35
  s.add_development_dependency 'minitest-reporters', '~> 0.14.16'
36
- s.add_development_dependency 'twitter_cldr', '~> 2.4.2'
37
- s.add_development_dependency 'mocha', '~> 1.0.0'
36
+ s.add_development_dependency 'twitter_cldr', '~> 3.2.0'
37
+ s.add_development_dependency 'mocha', '~> 1.1.0'
38
+ s.add_development_dependency 'test-unit', '~> 3.1.0' if RUBY_VERSION =~ /^2.2/
39
+ s.add_development_dependency 'webrick', '~> 1.3.1'
38
40
 
39
41
  # = MANIFEST =
40
42
  s.files = %w[
@@ -45,10 +47,11 @@ Gem::Specification.new do |s|
45
47
  Rakefile
46
48
  bin/gollum
47
49
  config.rb
50
+ config.ru
48
51
  contrib/openrc/conf.d/gollum
49
52
  contrib/openrc/init.d/gollum
50
53
  contrib/systemd/gollum@.service
51
- docs/sanitization.md
54
+ contrib/sysv-debian/init.d/gollum
52
55
  gollum.gemspec
53
56
  lib/gollum.rb
54
57
  lib/gollum/app.rb
@@ -16,7 +16,7 @@ require File.expand_path('../gollum/uri_encode_component', __FILE__)
16
16
  $KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8'
17
17
 
18
18
  module Gollum
19
- VERSION = '4.0.0'
19
+ VERSION = '4.0.1'
20
20
 
21
21
  def self.assets_path
22
22
  ::File.expand_path('gollum/public', ::File.dirname(__FILE__))
@@ -98,6 +98,7 @@ module Precious
98
98
  forbid unless @allow_editing || request.request_method == "GET"
99
99
  Precious::App.set(:mustache, {:templates => settings.wiki_options[:template_dir]}) if settings.wiki_options[:template_dir]
100
100
  @base_url = url('/', false).chomp('/')
101
+ @page_dir = settings.wiki_options[:page_file_dir].to_s
101
102
  # above will detect base_path when it's used with map in a config.ru
102
103
  settings.wiki_options.merge!({ :base_path => @base_url })
103
104
  @css = settings.wiki_options[:css]
@@ -106,8 +107,7 @@ module Precious
106
107
  end
107
108
 
108
109
  get '/' do
109
- page_dir = settings.wiki_options[:page_file_dir].to_s
110
- redirect clean_url(::File.join(@base_url, page_dir, wiki_new.index_page))
110
+ redirect clean_url(::File.join(@base_url, @page_dir, wiki_new.index_page))
111
111
  end
112
112
 
113
113
  # path is set to name if path is nil.
@@ -176,6 +176,7 @@ module Precious
176
176
  fullname = params[:file][:filename]
177
177
  tempfile = params[:file][:tempfile]
178
178
  end
179
+ halt 500 unless tempfile.is_a? Tempfile
179
180
 
180
181
  # Remove page file dir prefix from upload path if necessary -- committer handles this itself
181
182
  dir = wiki.per_page_uploads ? params[:upload_dest].match(/^(#{wiki.page_file_dir}\/+)?(.*)/)[2] : 'uploads'
@@ -438,7 +439,7 @@ module Precious
438
439
  end
439
440
 
440
441
  get '/search' do
441
- @query = params[:q]
442
+ @query = params[:q] || ''
442
443
  wiki = wiki_new
443
444
  # Sort wiki search results by count (desc) and then by name (asc)
444
445
  @results = wiki.search(@query).sort { |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
@@ -394,6 +394,7 @@ var applyTimeout = function () {
394
394
  jQuery.ajax( {
395
395
  type: 'GET',
396
396
  url: baseUrl + '/data/' + path + key_no_leading_slash( 'page' ),
397
+ cache: false,
397
398
  success: function( data ) {
398
399
  editorSession.setValue( data );
399
400
  }
@@ -10,7 +10,7 @@
10
10
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all">
11
11
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
12
12
  <link rel="stylesheet" type="text/css" href="{{base_url}}/css/print.css" media="print">
13
- {{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
13
+ {{#css}}<link rel="stylesheet" type="text/css" href="{{custom_path}}/custom.css" media="all">{{/css}}
14
14
  {{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
15
15
 
16
16
  <!--[if IE 7]>
@@ -55,7 +55,7 @@
55
55
  (d.head || d.getElementsByTagName('head')[0]).appendChild(j);
56
56
  }(document));
57
57
  </script>{{/mathjax}}
58
- {{#js}}<script type="text/javascript" src="{{base_url}}/custom.js"></script>{{/js}}
58
+ {{#js}}<script type="text/javascript" src="{{custom_path}}/custom.js"></script>{{/js}}
59
59
 
60
60
  <title>{{title}}</title>
61
61
  </head>
@@ -41,10 +41,8 @@ Mousetrap.bind(['e'], function( e ) {
41
41
  {{/editable}}
42
42
  {{/allow_editing}}
43
43
  {{#page_exists}}
44
- <li class="minibutton jaws">
45
44
  <li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
46
45
  class="action-page-history">History</a></li>
47
- <li class="minibutton jaws">
48
46
  <li class="minibutton"><a href="{{base_url}}/latest_changes"
49
47
  class="action-page-history">Latest Changes</a></li>
50
48
  {{/page_exists}}
@@ -20,10 +20,18 @@ module Precious
20
20
  !@path.nil?
21
21
  end
22
22
 
23
+ def page_dir
24
+ @page_dir
25
+ end
26
+
23
27
  def base_url
24
28
  @base_url
25
29
  end
26
30
 
31
+ def custom_path
32
+ "#{@base_url}#{@page_dir.empty? ? '' : '/'}#{@page_dir}"
33
+ end
34
+
27
35
  def css # custom css
28
36
  @css
29
37
  end
@@ -31,9 +31,11 @@ module Precious
31
31
 
32
32
  def files_folders
33
33
  if has_results
34
- folder_links = []
34
+ folders = {}
35
+ page_files = {}
35
36
 
36
- @results.map { |page|
37
+ # 1012: Folders and Pages need to be separated
38
+ @results.each do |page|
37
39
  page_path = page.path.sub(/^#{@path}\//, '')
38
40
 
39
41
  if page_path.include?('/')
@@ -41,19 +43,23 @@ module Precious
41
43
  folder_path = @path ? "#{@path}/#{folder}" : folder
42
44
  folder_link = %{<li><a href="#{@base_url}/pages/#{folder_path}/" class="folder">#{folder}</a></li>}
43
45
 
44
- unless folder_links.include?(folder_link)
45
- folder_links << folder_link
46
-
47
- folder_link
48
- end
46
+ folders[folder] = folder_link unless folders.key?(folder)
49
47
  elsif page_path != ".gitkeep"
50
48
  if defined? page.format
51
- %{<li><a href="#{@base_url}/#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
49
+ page_link = %{<li><a href="#{@base_url}/#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
50
+ page_files[page.name] = page_link
52
51
  else
53
- %{<li><a href="#{@base_url}/#{page.escaped_url_path}#{page.name}" class="file">#{page.name}</a></li>}
52
+ page_link = %{<li><a href="#{@base_url}/#{page.escaped_url_path}#{page.name}" class="file">#{page.name}</a></li>}
53
+ page_files[page.name] = page_link
54
54
  end
55
55
  end
56
- }.compact.join("\n")
56
+ end
57
+
58
+ # 1012: All Pages should be rendered as Folders first, then Pages, each sorted alphabetically
59
+ result = Hash[folders.sort_by{| key, value | key.downcase} ].values.join("\n") + "\n"
60
+ result += Hash[page_files.sort_by{ | key, value | key.downcase } ].values.join("\n")
61
+
62
+ result
57
63
  else
58
64
  ""
59
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gollum
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-11 00:00:00.000000000 Z
12
+ date: 2015-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gollum-lib
@@ -37,14 +37,14 @@ dependencies:
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 1.6.0
40
+ version: 1.8.0
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.0
47
+ version: 1.8.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: sinatra
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -91,14 +91,14 @@ dependencies:
91
91
  requirements:
92
92
  - - ~>
93
93
  - !ruby/object:Gem::Version
94
- version: 0.10.0
94
+ version: 0.14.0
95
95
  type: :runtime
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 0.10.0
101
+ version: 0.14.0
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rack-test
104
104
  requirement: !ruby/object:Gem::Requirement
@@ -147,28 +147,42 @@ dependencies:
147
147
  requirements:
148
148
  - - ~>
149
149
  - !ruby/object:Gem::Version
150
- version: 2.4.2
150
+ version: 3.2.0
151
151
  type: :development
152
152
  prerelease: false
153
153
  version_requirements: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - ~>
156
156
  - !ruby/object:Gem::Version
157
- version: 2.4.2
157
+ version: 3.2.0
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: mocha
160
160
  requirement: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - ~>
163
163
  - !ruby/object:Gem::Version
164
- version: 1.0.0
164
+ version: 1.1.0
165
165
  type: :development
166
166
  prerelease: false
167
167
  version_requirements: !ruby/object:Gem::Requirement
168
168
  requirements:
169
169
  - - ~>
170
170
  - !ruby/object:Gem::Version
171
- version: 1.0.0
171
+ version: 1.1.0
172
+ - !ruby/object:Gem::Dependency
173
+ name: webrick
174
+ requirement: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ~>
177
+ - !ruby/object:Gem::Version
178
+ version: 1.3.1
179
+ type: :development
180
+ prerelease: false
181
+ version_requirements: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ~>
184
+ - !ruby/object:Gem::Version
185
+ version: 1.3.1
172
186
  description: A simple, Git-powered wiki with a sweet API and local frontend.
173
187
  email: tom@github.com
174
188
  executables:
@@ -185,10 +199,11 @@ files:
185
199
  - Rakefile
186
200
  - bin/gollum
187
201
  - config.rb
202
+ - config.ru
188
203
  - contrib/openrc/conf.d/gollum
189
204
  - contrib/openrc/init.d/gollum
190
205
  - contrib/systemd/gollum@.service
191
- - docs/sanitization.md
206
+ - contrib/sysv-debian/init.d/gollum
192
207
  - gollum.gemspec
193
208
  - lib/gollum.rb
194
209
  - lib/gollum/app.rb
@@ -1,33 +0,0 @@
1
- Sanitization Rules
2
- ==================
3
-
4
- Gollum uses the [Sanitize](http://wonko.com/post/sanitize) gem for HTML
5
- sanitization. Below you find the default allowed tags, attributes, and protocols, as well as directions to customize these settings.
6
-
7
- # Default Settings
8
-
9
- ## ALLOWED TAGS
10
-
11
- 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
12
-
13
- ## ALLOWED ATTRIBUTES
14
-
15
- 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
16
-
17
- ## ALLOWED PROTOCOLS
18
-
19
- * a href: http, https, mailto, ftp, irc, apt, :relative
20
- * img src: http, https, :relative
21
- * form action: http, https, :relative
22
-
23
- # Customizing
24
-
25
- To customize these settings, edit your `config.rb` file along the following lines (be sure to run gollum with the `--config` option):
26
-
27
- ```ruby
28
- sanitizer = Gollum::Sanitization.new
29
- sanitizer.protocols['a']['href'].concat ['ssh', 'vnc'] # Protocols
30
- sanitizer.elements.concat ['customtag1', 'customtag2'] # Tags
31
- sanitizer.attributes['a'].push 'target' # Attributes
32
- Precious::App.set(:wiki_options, {:sanitization => sanitizer})
33
- ```