Compare commits

...

95 Commits

Author SHA1 Message Date
Dawa Ometto ece5c775f1 Release 4.1.0 2017-03-09 17:34:37 +01:00
Dawa Ometto 3121c43b71 Merge pull request #1180 from bogado/issue#1179
Fix page list for files that have regexp special chars.
2017-03-09 16:22:40 +01:00
Bart Kamphorst 51e8caf369 Merge pull request #1191 from polyzen/patch-1
readme: Use --document in place of deprecated options
2017-02-16 16:05:35 +01:00
Daniel M. Capella e7e7937678 readme: Use --document in place of deprecated options 2017-02-02 14:26:32 -05:00
Dawa Ometto 00dfecb1c7 Merge pull request #1185 from connorshea/ruby-24
Test on Ruby 2.4
2017-01-20 23:30:24 +01:00
Dawa Ometto cc249bef15 Merge pull request #1182 from bjoernalbers/master
Add another video to README.
2017-01-19 15:14:11 +01:00
Connor Shea 9a2231804d Test on Ruby 2.4 2017-01-14 19:10:17 -05:00
Björn Albers 1edcf15bcd Add another video to README. 2017-01-10 18:26:56 +01:00
Victor Bogado 0190e08763 Fix page list for files that have regexp special chars.
The page list collection logic was using the filename without any
scaping to create a regexp. This not only breaks for some names it might
even be a security problem by introducing bad regular expression as
filenames.
2017-01-01 19:55:18 -08:00
Dawa Ometto d3cc5a69c4 Merge branch 'rc' 2016-08-07 21:36:51 +02:00
Dawa Ometto 07ca53a778 Merge branch 'rc' into master
Conflicts:
	bin/gollum
2016-08-07 21:36:13 +02:00
Dawa Ometto 6910b6d024 Merge pull request #1143 from astorije/patch-1
Fix compare page not accessible in no-edit mode. Resolves #1140.
2016-08-07 20:17:34 +02:00
Bart Kamphorst f02c934ad7 Merge pull request #1154 from maarten/#855-delete-files
Fixes #855 Adds file deletion fuctionality.
2016-08-07 19:46:55 +02:00
Maarten Engelen 236680aab9 Add file deletion functionality
Adds route for file deletion
Add styles and images for this
2016-08-07 17:18:36 +02:00
Dawa Ometto 6316f97c06 Update CONTRIBUTING.md 2016-08-07 12:50:48 +02:00
Dawa Ometto 14830af306 Update CONTRIBUTING.md 2016-08-07 12:50:18 +02:00
Dawa Ometto b620decde7 Add contributing guidelines 2016-08-07 12:48:07 +02:00
Bart Kamphorst b08ca620a0 Merge pull request #1148 from astorije/patch-2
Remove deprecated github-markdown markup
2016-07-11 21:44:02 +02:00
Jérémie Astori 66a2bb0393 Remove deprecated github-markdown markup
From [RubyGems](https://rubygems.org/gems/github-markdown/versions/0.6.9):

> THIS GEM IS NOT MAINTAINED AND NOT SUPPORTED.

Also, the GitHub repository, maintained by GitHub, was removed.

The link is now a redirect, it doesn't point to the GFM page anymore.
2016-07-11 12:19:43 -04:00
Jérémie Astori 0675844d97 Fix compare page not accessible in no-edit mode
Permission checking was spread across `post` action handlers instead of inside the `before` to normalize between `get` and `post` action handlers and be more explicit.
2016-06-27 13:50:47 -04:00
Dawa Ometto 148eda2990 Merge pull request #1136 from gollum/503-safari-live
Add Safari to livepreview-enabled browsers. Fixes #503
2016-06-16 13:28:46 +02:00
Dawa Ometto 330f7b4002 Add Safari to livepreview-enabled browsers. Fixes #503 2016-06-16 12:58:22 +02:00
Dawa Ometto def0fc8866 Merge pull request #1126 from svoop/emoji
Support for emoji
2016-06-09 16:43:52 +02:00
Sven Schwyn fa1bcf9608 Add support for emojione 2016-05-19 20:33:25 +02:00
Bart Kamphorst 5a5e56a47b Merge pull request #1111 from jhominal/master
Unconditionally add 'test-unit' dependency.
2016-02-24 02:28:24 +01:00
Jean Hominal e64f40eaa3 Unconditionally add 'test-unit' dependency.
Fixes #1110
2016-02-23 22:52:07 +01:00
Dawa Ometto 3f3d86ad4c Merge pull request #1091 from jhominal/master
Use `last_version` instead of `versions` when possible. Fixes #1087.
2016-02-21 22:51:40 +01:00
Jean Hominal 91833dd72e Use last_version instead of versions when possible. Fixes #1087.
Use Gollum::Page#last_version instead of Gollum::Page#versions in the
cases identified in #1087:
 * In Precious::App#show_page_or_file
 * In Precious::Views::Page#author
 * In Precious::Views::Page#date
2016-02-14 23:15:38 +01:00
Bart Kamphorst c049f7c11f Merge pull request #1106 from gollum/youtube_demo_vids
Adds links to youtube videos in README.
2016-01-14 17:01:28 +01:00
Bart Kamphorst 6bd2f3bff5 Drop 1.9.3 testing on Travis, add 2.3.0. 2016-01-10 15:28:23 +01:00
Bart Kamphorst 8c3c519679 Adds links to youtube videos in README. 2016-01-10 11:49:34 +01:00
Dawa Ometto 4e5002a31e Merge pull request #1098 from andrehjr/gh-1066-sanitize-basepath
Sanitize basepath options when adding with more than one / at the start Fixes #1066.
2015-12-30 18:39:30 +01:00
André Luis Leal Cardoso Junior 5a53c58b04 Sanitize basepath options when adding with more than one / at the start. Fixes #1066 2015-12-05 23:23:22 -02:00
Bart Kamphorst a61d1e3d10 Merge pull request #1094 from repotag/master
Update kramdown and useragent dependencies.
2015-11-30 11:26:51 +01:00
Bart Kamphorst 1a50f99189 Merge branch 'master' of https://github.com/gollum/gollum 2015-11-30 00:28:30 +01:00
Bart Kamphorst 6caacbf388 Update kramdown and useragent dependencies. 2015-11-30 00:28:01 +01:00
Dawa Ometto f876aa7d0f Merge pull request #1077 from mpnowacki/renaming
fixed file renaming issues with page_file_dir
2015-11-02 11:42:50 +01:00
Dawa Ometto 31e1281600 Merge pull request #1086 from ngyuki/fix-preview-sidebar
Fix position of sidebar in preview
2015-11-02 11:42:25 +01:00
ngyuki 90072a9332 Fix position of sidebar in preview 2015-11-02 12:45:30 +09:00
Dawa Ometto bacd2893b9 Merge pull request #1084 from SkyCrawl/master
Fixing the vague "running from source" description in README
2015-10-25 13:20:17 +01:00
SkyCrawl 7362fd859b Fixing the "running" section 2015-10-25 13:12:36 +01:00
mpnowacki 3811fb46b3 fixed file renaming issues with page_file_dir. This will only work with appropriate changes in gollum-lib 2015-10-04 11:34:25 +02:00
Dawa Ometto ab42c0c0df Release 4.0.1 2015-09-20 14:48:32 +02:00
Bart Kamphorst de5aed2f6a Merge pull request #1069 from repotag/master
Added security check.
2015-09-20 14:31:14 +02:00
Bart Kamphorst ce68a88293 Added security check. 2015-09-20 13:53:02 +02:00
Dawa Ometto 288f75929d Merge pull request #1065 from n-st/sysv-init-script
Added init script for Debian's SysV-style init system
2015-09-16 12:52:38 +02:00
Dawa Ometto 8528dd0c7f Merge pull request #1067 from SkyCrawl/master
Fixing the link to Windows support meta issue
2015-09-14 17:55:18 +02:00
SkyCrawl e0f35eceab Fixing the link to Windows support meta issue 2015-09-14 17:31:25 +02:00
Dawa Ometto 7e36517a79 Merge pull request #1054 from SkyCrawl/master
Config files restored + BIN enhancements + BIN/README sync
2015-09-14 12:40:22 +02:00
Dawa Ometto 69327766bb Merge pull request #1061 from rgroux/gollum-with-cas-sso
README add link to wiki about CAS SSO
2015-09-14 12:38:35 +02:00
Nils Steinger 9ecf8a61ba Added init script for Debian's SysV-style init system
Adapted from the OpenRC init script in contrib/openrc/init.d/gollum.
2015-09-14 05:03:06 +02:00
Richard Groux 2323506c82 Update README.md 2015-09-10 18:14:59 +02:00
Bart Kamphorst caa1a55e7a Merge pull request #1062 from mortonfox/patch-1
Fix github-markup link in readme.
2015-08-26 09:49:56 +02:00
Morton Fox 2ce44c157a Fix github-markup link 2015-08-25 23:48:53 -04:00
rgroux e17778190d README add link to wiki about CAS SSO 2015-08-25 17:06:36 +02:00
SkyCrawl d1d81a0043 Syncing BIN with README + fixes & enhancements 2015-08-23 14:44:18 +02:00
SkyCrawl ddb5ced3d5 Updating gemspec to reflect recent changes 2015-08-23 14:43:46 +02:00
Bart Kamphorst 9cebe655fd Merge pull request #1060 from mchill/custom-template
Fix custom.x path when page-file-dir is not set
2015-08-21 14:11:02 +02:00
Matt Hill 51b5a11a54 Fix custom.x path when page-file-dir is not set 2015-08-20 23:19:25 -04:00
Bart Kamphorst f3405851a7 Merge pull request #1055 from repotag/webrick_fix
Add webrick as development dependency. Fixes #1053.
2015-08-14 11:42:17 +02:00
Bart Kamphorst 5b6870d610 Add webrick as development dependency. Fixes #1053. 2015-08-14 11:06:17 +02:00
SkyCrawl c3dceaff5c Adding reference to the "Troubleshoot" wiki page 2015-08-12 22:26:59 +02:00
SkyCrawl 0a9b35c039 Restoring config files to repo root 2015-08-12 22:26:20 +02:00
Dawa Ometto dc32997f45 Merge pull request #1051 from SkyCrawl/master
Docs update
2015-08-09 20:30:21 +02:00
SkyCrawl 67c64c17d5 README makeover 2015-08-09 19:22:16 +02:00
Dawa Ometto 9cc02982be Merge pull request #973 from hsanson/add-plantuml-opt
Add option to configure PlantUML endpoint
2015-08-09 19:15:02 +02:00
SkyCrawl b4c70a62a9 Removing Home.md due to being a mere lorem ipsum 2015-08-08 15:21:30 +02:00
SkyCrawl c9d5921f4e Moving docs/sanitization.md to the wiki 2015-08-08 15:21:00 +02:00
SkyCrawl 0f47a4de5d Removing config.rb due to being pointless 2015-08-08 15:20:35 +02:00
Dawa Ometto 0ba5e4d3c7 Merge pull request #1047 from benubird/custom-template
Changed layout template, to handle custom.x with page-file-dir
2015-08-05 14:51:51 +02:00
Joshua Swanson 73e61dbcff Changed layout template, to correctly handle custom.js when --page-file-dir is set 2015-08-05 13:26:19 +01:00
Bart Kamphorst ba142e3b19 Merge pull request #1038 from rgroux/development
upgrade/update a number of dependencies.
2015-07-27 22:14:55 +02:00
GROUX Richard f651a401e8 deps(update): test with ruby 2.2.2
need to add `test-unit` gem when using ruby >= 2.2.0
2015-07-27 13:49:03 +02:00
GROUX Richard 3301252fb2 deps(update): twitter_cldr update to > 3.2
Changelog is
[there](https://github.com/twitter/twitter-cldr-rb/blob/master/History.txt)
2015-07-27 13:20:50 +02:00
GROUX Richard fe77e2b0d3 deps(update): upgrade the mocha version to 1.1
Changelog is
[there](https://github.com/freerange/mocha/blob/master/RELEASE.md)
2015-07-27 13:16:29 +02:00
GROUX Richard d586567c3b deps(update): upgrade the useragent version to 0.14 2015-07-27 13:15:50 +02:00
GROUX Richard 211178d39e deps(update): upgrade the kramdown version to 1.8
Changelog of kramdown is [there](http://kramdown.gettalong.org/news.html)
2015-07-27 13:12:48 +02:00
Dawa Ometto d8354faa49 Merge pull request #1035 from rgroux/search
Search default query to ''
2015-07-26 20:23:09 +02:00
GROUX Richard f9e5c05046 Fix search without querry
App crash when we try to get /search

Add an empty querry '' as default
2015-07-21 19:35:45 +02:00
Dawa Ometto 596afe9451 Merge pull request #1034 from mehulkar/patch-1
Fix a typo in the readme
2015-07-16 23:35:51 +02:00
Mehul Kar f7b5de986a Fix a typo in the readme 2015-07-16 13:57:11 -07:00
Bart Kamphorst ee9262472b Merge pull request #1032 from techwiz24/iss1030-ie-cache
Fix #1030: Disable AJAX Cach in Live Editor
2015-07-12 19:09:04 +02:00
Nathan Lowe 8a6a8db730 Fix #1030: Disable AJAX Cach in Live Editor
Internet Explorer caches all AJAX get requests and decides when to expire
them in the cache. This commit disables caching on the GET request to
/data/<PAGE NAME>, which fixes IE displaying old page data when using the
live editor.

See http://www.dashbay.com/2011/05/internet-explorer-caches-ajax/ and
https://stackoverflow.com/questions/4303829/how-to-prevent-a-jquery-ajax-request-from-caching-in-internet-explorer
2015-07-03 17:28:43 -04:00
Bart Kamphorst 3642370f11 Merge pull request #1014 from techwiz24/iss/1012-pages-view
Fix #1012: /Pages View should list folders first, then files, all alphabetically.
2015-05-21 02:15:57 +02:00
Nathan Lowe 2db2cfb81c Update test coverage to account for #1012
The existing 'files_folders' test only covered the /Mordor subdirectory,
which does not include a diverse enough set of pages and folders to account
for the new rendering logic.

This test uses the results from the root of the lotr.git example repository
as it exists at this point in time. The mock '@results' are not passed as a
sorted array in order to test the sorting logic.

The existing 'files_folders' test has been renamed to 'files_folders from subdir'
because the 'files_folders' function should be tested in a situation when
viewing /pages from a subdirectory to ensure proper functionality.
2015-05-20 18:58:24 -04:00
Nathan Lowe 279b028c5e Fix #1012: /Pages should render Folders First, then files, alphabetically 2015-05-20 18:58:10 -04:00
Dawa Ometto f268827a2e Merge pull request #995 from tfogo/html-cleanup
Remove extraneous li tags
2015-04-26 19:05:00 +02:00
Dawa Ometto d8bc065057 Merge pull request #1003 from akston/readme_typo
Fix typo in README
2015-04-26 19:04:26 +02:00
Conor Schaub 6301bbbb66 Fix typo in README 2015-04-25 15:32:30 -07:00
Dawa Ometto 3ad65eaef8 Update README.md 2015-04-11 11:53:59 +02:00
Dawa Ometto 3d1bc7949d Update README.md 2015-04-11 11:43:40 +02:00
Dawa Ometto 26e092fd20 Update HISTORY.md 2015-04-11 11:42:21 +02:00
Dawa Ometto be7ddec1b0 Update README.md 2015-04-11 11:40:43 +02:00
Tim Fogarty 93af289d3b Remove extraneous li tags 2015-04-06 02:40:02 -04:00
Horacio Sanson 1cceb7d4b4 Add option to configure PlantUML endpoint 2015-02-05 01:10:12 +09:00
26 changed files with 664 additions and 394 deletions
+3 -1
View File
@@ -1,8 +1,10 @@
rvm: rvm:
- 1.9.3
- 2.0.0 - 2.0.0
- 2.1.0 - 2.1.0
- 2.1.1 - 2.1.1
- 2.2.2
- 2.3.0
- 2.4.0
- jruby-19mode - jruby-19mode
before_install: before_install:
- sudo apt-get update - 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
```
+10
View File
@@ -1,3 +1,13 @@
# 4.1.0 /2016-03-09
* Added file deletion functionality to file view
* Various performance improvements
* Emoji support
# 4.0.0 /2015-04-11
* Now compatible with JRuby (via the [rjgit](https://github.com/repotag/rjgit) [adapter](https://github.com/repotag/gollum-lib_rjgit_adapter))
# 3.1.1 /2014-12-04 # 3.1.1 /2014-12-04
* Security fix for [remote code execution issue](https://github.com/gollum/gollum/issues/913). Please update! * Security fix for [remote code execution issue](https://github.com/gollum/gollum/issues/913). Please update!
-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.
+127 -184
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) [![Gem Version](https://badge.fury.io/rb/gollum.svg)](http://badge.fury.io/rb/gollum)
@@ -7,228 +7,171 @@ gollum -- A wiki built on top of Git
## DESCRIPTION ## DESCRIPTION
Gollum is a simple wiki system built on top of Git. 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 wikis are simply Git repositories that adhere to a specific format. 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 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:
* With your favorite text editor or IDE (changes will be visible after committing). For more information on Gollum's capabilities and pitfalls:
* With the built-in web interface.
* With the Gollum Ruby API.
Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses 1. [Syntax/capability overview for pages](https://github.com/gollum/gollum/wiki).
[TomDoc](http://tomdoc.org/) for inline documentation. 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).
### Videos
* [Quick impression of gollum](https://www.youtube.com/watch?v=gj1qqK3Oku8)
* [Gollum overview and simple markdown tutorial (german with english subtitles)](https://www.youtube.com/watch?v=wfWgDRmcbU4)
* [Advanced features in action](https://www.youtube.com/watch?v=EauxgxsLDC4)
## SYSTEM REQUIREMENTS ## SYSTEM REQUIREMENTS
- Python 2.5+ (2.7.3 recommended) | Operating System | Ruby | Adapters | Supported |
- Ruby 1.9.3+ (1.9.3 recommended) | ---------------- | -------------- | ------------------ | --------- |
- Unix like operating system (OS X, Ubuntu, Debian, and more) | Unix/Linux-like | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | yes |
- Will not work on Windows (because of [grit](https://github.com/github/grit)) | 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. 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).
A better solution with more security is being tracked in [#665](https://github.com/gollum/gollum/issues/665).
## INSTALLATION ## 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 1. Ruby is best installed either via [RVM](https://rvm.io/) or a package manager of choice.
$ [sudo] gem install gollum 2. Gollum is best installed via RubyGems:
``` ```
You may first need to install some additional [development packages](https://github.com/gollum/gollum/wiki/Installation) for your OS. [sudo] gem install gollum
```
If you're installing from source, you can use [Bundler][bundler] to pick up all the Installation examples for individual systems can be seen [here](https://github.com/gollum/gollum/wiki/Installation).
gems:
```bash **Notes:**
$ bundle install * 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-document pkg/gollum*.gem
```
In order to use the various formats that Gollum supports, you will need to ### Markups
separately install the necessary dependencies for each format. You only need
to install the dependencies for the formats that you plan to use.
* [AsciiDoc](http://asciidoctor.org) -- `gem install asciidoctor` Gollum presently ships with support for the following markups:
* [Creole](http://www.wikicreole.org/) -- `gem install creole` * [Markdown](http://daringfireball.net/projects/markdown/syntax)
* [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.
* [RDoc](http://rdoc.sourceforge.net/) * [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/ 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`
## SYNTAX * [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`
Gollum supports a variety of formats and extensions (Markdown, MediaWiki, Textile, …). * [Pod](http://perldoc.perl.org/perlpod.html) -- requires Perl >= 5.10 (the `perl` command must be available on your command line)
On top of these formats Gollum lets you insert headers, footers, links, image, math and more. * 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)
Check out the [Gollum Wiki](https://github.com/gollum/gollum/wiki) for all of Gollum's formats and syntactic options. * 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 ## RUNNING
To view and edit your Gollum repository locally via the built in web Simply:
interface, simply install the Gollum gem, navigate to your repository via the
command line, and run the executable:
```bash 1. Navigate to your git repository (wiki) via the command line.
$ gollum 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 This will start up a web server (WEBrick) running Gollum with a web interface, where you can view and edit your wiki.
and edit your wiki at http://localhost:4567. To get help on the command line
utility, you can run it like so:
```bash ### Running from source
$ gollum --help
```
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 ### Rack
Options:
--port [PORT] Bind port (default 4567).
--host [HOST] Hostname or IP address to listen on (default 0.0.0.0).
--version Display current version.
--config [CONFIG] Path to additional configuration file.
--adapter [ADAPTER] Git adapter to use in the backend. Defaults to grit.
--irb Start an irb process with gollum loaded for the current wiki.
--css Inject custom css. Uses custom.css from root repository.
--js Inject custom js. Uses custom.js from root repository.
--template-dir [PATH] Specify custom template directory.
--page-file-dir [PATH] Specify the sub directory for all page files (default: repository root).
--base-path [PATH] Specify the base path for the served pages (default: /) Example: --base-path wiki yields the home page accessible at http://localhost:4567/wiki/.
--gollum-path [PATH] Specify the path to the git repository to be served.
--ref [REF] Specify the repository ref to use (default: master).
--bare Specify that the repository is bare (only necessary when using the grit adapter).
--no-edit Restricts editing capability through frontend.
--no-live-preview Disables livepreview.
--live-preview Enables livepreview.
--allow-uploads [MODE] Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page).
--mathjax Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default.
--mathjax-config [SOURCE] Inject custom mathjax config file. Uses mathjax.config.js from root repository by default.
--user-icons [SOURCE] Set the history user icons. Valid values: gravatar, identicon, none. Default: none.
--show-all Shows all files in file view. By default only valid pages are shown.
--collapse-tree Collapse file view tree. By default, expanded tree is shown.
--h1-title Sets page title to value of first h1.
```
Note that the gollum server will not run on Windows because of [an issue](https://github.com/rtomayko/posix-spawn/issues/9) with posix-spawn (which is used by Grit). 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 placing configuring a config.ru 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).
file. This allows you to utilize any Rack middleware like Rack::Auth, OmniAuth, etc. See below for an example of a `config.ru`. You can define all the [options available on the command line](#running) by configuring the app's `:wiki_options` hash. See [here](https://github.com/gollum/gollum/wiki/Using-Gollum-with-Rack) for the names of the options corresponding to the command line switches.
```ruby ### Docker
#!/usr/bin/env ruby
require 'rubygems'
require 'gollum/app'
gollum_path = File.expand_path(File.dirname(__FILE__)) # CHANGE THIS TO POINT TO YOUR OWN WIKI REPO 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).
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:default_markup, :markdown) # set your favorite markup language
Precious::App.set(:wiki_options, {:universal_toc => false})
run Precious::App
```
Your Rack middleware can pass author details to Gollum in a Hash in the session under the 'gollum.author' key. ### 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 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.
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.
**All of the mentioned alterations work both for Gollum's config file (`config.rb`) and Rack's config file (`config.ru`).**
## 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
```
+169 -107
View File
@@ -2,128 +2,169 @@
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib]) $:.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 'optparse'
require 'rubygems' require 'rubygems'
require 'gollum' require 'gollum'
require 'cgi'
exec = {} exec = {}
options = { 'port' => 4567, 'bind' => '0.0.0.0' } options = {
:port => 4567,
:bind => '0.0.0.0',
}
wiki_options = { wiki_options = {
:live_preview => false, :live_preview => false,
:allow_uploads => false, :allow_uploads => false,
:allow_editing => true, :allow_editing => true,
} }
opts = OptionParser.new do |opts| opts = OptionParser.new do |opts|
opts.banner = help # define program name (although this defaults to the name of the file, just in case...)
opts.program_name = "gollum"
opts.on("--port [PORT]", "Bind port (default 4567).") do |port|
options['port'] = port.to_i # 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 end
opts.on("-p", "--port [PORT]", "Specify the port to bind Gollum with. Default: '4567'.") do |port|
opts.on("--host [HOST]", "Hostname or IP address to listen on (default 0.0.0.0).") do |host| begin
options['bind'] = host # 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 end
opts.on("-c", "--config [FILE]", "Specify path to the Gollum's configuration file.") do |file|
opts.on("--version", "Display current version.") do options[:config] = file
puts "Gollum " + Gollum::VERSION
exit 0
end end
opts.on("-r", "--ref [REF]", "Specify the branch to serve. Default: 'master'.") do |ref|
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|
wiki_options[:ref] = ref wiki_options[:ref] = ref
end end
opts.on("-a", "--adapter [ADAPTER]", "Launch Gollum using a specific git adapter. Default: 'grit'.") do |adapter|
opts.on("--bare", "Specify that the repository is bare (only necessary when using the grit adapter).") do 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 wiki_options[:repo_is_bare] = true
end 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 wiki_options[:allow_editing] = false
end end
opts.on("--live-preview", "Enable the live preview feature in page editor.") do
opts.on("--no-live-preview", "Disables livepreview.") do
wiki_options[:live_preview] = false
end
opts.on("--live-preview", "Enables livepreview.") do
wiki_options[:live_preview] = true wiki_options[:live_preview] = true
end end
opts.on("--no-live-preview", "Disable the live preview feature in page editor.") do
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| 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[:allow_uploads] = true
wiki_options[:per_page_uploads] = true if mode == :page wiki_options[:per_page_uploads] = true if mode == :page
end end
opts.on("--mathjax", "Enable MathJax (renders mathematical equations).",
opts.on("--mathjax", "Enables mathjax for rendering mathematical equations. Uses the TeX-AMS-MML_HTMLorMML config with the autoload-all extension by default.") do "By default, uses the 'TeX-AMS-MML_HTMLorMML' config with the 'autoload-all' extension.") do
wiki_options[:mathjax] = true wiki_options[:mathjax] = true
end end
opts.on("--irb", "Launch Gollum in 'console mode', with a predefined API.") do
opts.on("--mathjax-config [SOURCE]", "Inject custom mathjax config file. Uses mathjax.config.js from root repository by default") do |source| options[:irb] = true
wiki_options[:mathjax_config] = source || 'mathjax.config.js'
end end
opts.on("--user-icons [SOURCE]", "Set the history user icons. Valid values: gravatar, identicon, none. Default: none.") do |source| opts.separator ""
wiki_options[:user_icons] = source opts.separator " Minor:"
end
opts.on("--h1-title", "Use the first '<h1>' as page title.") do
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
wiki_options[:h1_title] = true wiki_options[:h1_title] = true
end 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 end
# Read command line options into `options` hash # Read command line options into `options` hash
@@ -136,11 +177,9 @@ rescue OptionParser::InvalidOption
end end
# --gollum-path wins over ARGV[0] # --gollum-path wins over ARGV[0]
gollum_path = wiki_options[:gollum_path] ? gollum_path = ARGV[0] || Dir.pwd
wiki_options[:gollum_path] :
ARGV[0] || Dir.pwd
if options['irb'] if options[:irb]
require 'irb' require 'irb'
# http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/ # http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/
module IRB # :nodoc: module IRB # :nodoc:
@@ -171,8 +210,17 @@ if options['irb']
if !wiki.exist? then if !wiki.exist? then
raise Gollum::InvalidGitRepositoryError raise Gollum::InvalidGitRepositoryError
end end
puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}." if wiki_options[:plantuml_url]
Gollum::Filter::PlantUML.configure do |config|
puts "Using #{wiki_options[:plantuml_url]} as PlantUML endpoint"
config.url = wiki_options[:plantuml_url]
end
end
puts 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 %( page = wiki.page('page-name'))
puts %( # => <Gollum::Page>) puts %( # => <Gollum::Page>)
puts puts
@@ -182,7 +230,9 @@ if options['irb']
puts %( page.formatted_data) puts %( page.formatted_data)
puts %( # => "<h1>My wiki page</h1>") puts %( # => "<h1>My wiki page</h1>")
puts 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) IRB.start_session(binding)
rescue Gollum::InvalidGitRepositoryError, Gollum::NoSuchPathError rescue Gollum::InvalidGitRepositoryError, Gollum::NoSuchPathError
puts "Invalid Gollum wiki at #{File.expand_path(gollum_path).inspect}" puts "Invalid Gollum wiki at #{File.expand_path(gollum_path).inspect}"
@@ -194,30 +244,41 @@ else
Precious::App.set(:wiki_options, wiki_options) Precious::App.set(:wiki_options, wiki_options)
Precious::App.settings.mustache[:templates] = wiki_options[:template_dir] if wiki_options[:template_dir] 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, # If the path begins with a '/' it will be considered an absolute path,
# otherwise it will be relative to the CWD # otherwise it will be relative to the CWD
cfg = File.join(Dir.getwd, cfg) unless cfg.slice(0) == File::SEPARATOR cfg = File.join(Dir.getwd, cfg) unless cfg.slice(0) == File::SEPARATOR
require cfg require cfg
end end
if wiki_options[:plantuml_url]
Gollum::Filter::PlantUML.configure do |config|
puts "Using #{wiki_options[:plantuml_url]} as PlantUML endpoint"
config.url = wiki_options[:plantuml_url]
end
end
base_path = wiki_options[:base_path] base_path = wiki_options[:base_path]
if wiki_options[:base_path].nil? if base_path.nil?
Precious::App.run!(options) Precious::App.run!(options)
else else
require 'rack' require 'rack'
class MapGollum class MapGollum
def initialize base_path def initialize(base_path)
@mg = Rack::Builder.new do @mg = Rack::Builder.new do
map '/' do
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
end
map "/#{base_path}" do map "/#{base_path}" do
run Precious::App run Precious::App
end end
map '/' do
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
end
map '/*' do
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
end
end end
end end
@@ -225,7 +286,8 @@ else
@mg.call(env) @mg.call(env)
end end
end end
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead. # 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
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 =begin
Valid formats are: This file can be used to (e.g.):
{ :markdown => "Markdown", - alter certain inner parts of Gollum,
:textile => "Textile", - extend it with your stuff.
:rdoc => "RDoc",
:org => "Org-mode", It is especially useful for customizing supported formats/markups. For more information and examples:
:creole => "Creole", - https://github.com/gollum/gollum#config-file
:rest => "reStructuredText",
:asciidoc => "AsciiDoc",
:mediawiki => "MediaWiki",
:pod => "Pod" }
=end =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})
```
+13 -7
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9' s.required_ruby_version = '>= 1.9'
s.name = 'gollum' s.name = 'gollum'
s.version = '4.0.0' s.version = '4.1.0'
s.date = '2015-04-11' s.date = '2017-03-09'
s.rubyforge_project = 'gollum' s.rubyforge_project = 'gollum'
s.license = 'MIT' s.license = 'MIT'
@@ -25,19 +25,23 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w[README.md LICENSE] s.extra_rdoc_files = %w[README.md LICENSE]
s.add_dependency 'gollum-lib', '~> 4.0', '>= 4.0.1' s.add_dependency 'gollum-lib', '~> 4.0', '>= 4.0.1'
s.add_dependency 'kramdown', '~> 1.6.0' s.add_dependency 'kramdown', '~> 1.9.0'
s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4' s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4'
s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0'] s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
s.add_dependency 'useragent', '~> 0.10.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 'rack-test', '~> 0.6.2'
s.add_development_dependency 'shoulda', '~> 3.5.0' s.add_development_dependency 'shoulda', '~> 3.5.0'
s.add_development_dependency 'minitest-reporters', '~> 0.14.16' s.add_development_dependency 'minitest-reporters', '~> 0.14.16'
s.add_development_dependency 'twitter_cldr', '~> 2.4.2' s.add_development_dependency 'twitter_cldr', '~> 3.2.0'
s.add_development_dependency 'mocha', '~> 1.0.0' s.add_development_dependency 'mocha', '~> 1.1.0'
s.add_development_dependency 'test-unit', '~> 3.1.0'
s.add_development_dependency 'webrick', '~> 1.3.1'
# = MANIFEST = # = MANIFEST =
s.files = %w[ s.files = %w[
CONTRIBUTING.md
Gemfile Gemfile
HISTORY.md HISTORY.md
LICENSE LICENSE
@@ -45,10 +49,11 @@ Gem::Specification.new do |s|
Rakefile Rakefile
bin/gollum bin/gollum
config.rb config.rb
config.ru
contrib/openrc/conf.d/gollum contrib/openrc/conf.d/gollum
contrib/openrc/init.d/gollum contrib/openrc/init.d/gollum
contrib/systemd/gollum@.service contrib/systemd/gollum@.service
docs/sanitization.md contrib/sysv-debian/init.d/gollum
gollum.gemspec gollum.gemspec
lib/gollum.rb lib/gollum.rb
lib/gollum/app.rb lib/gollum/app.rb
@@ -70,6 +75,7 @@ Gem::Specification.new do |s|
lib/gollum/public/gollum/images/fileview/folder-horizontal.png lib/gollum/public/gollum/images/fileview/folder-horizontal.png
lib/gollum/public/gollum/images/fileview/toggle-small-expand.png lib/gollum/public/gollum/images/fileview/toggle-small-expand.png
lib/gollum/public/gollum/images/fileview/toggle-small.png lib/gollum/public/gollum/images/fileview/toggle-small.png
lib/gollum/public/gollum/images/fileview/trashcan.png
lib/gollum/public/gollum/images/icon-sprite.png lib/gollum/public/gollum/images/icon-sprite.png
lib/gollum/public/gollum/images/man_24.png lib/gollum/public/gollum/images/man_24.png
lib/gollum/public/gollum/images/para.png lib/gollum/public/gollum/images/para.png
+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' $KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8'
module Gollum module Gollum
VERSION = '4.0.0' VERSION = '4.1.0'
def self.assets_path def self.assets_path
::File.expand_path('gollum/public', ::File.dirname(__FILE__)) ::File.expand_path('gollum/public', ::File.dirname(__FILE__))
+42 -7
View File
@@ -49,7 +49,7 @@ module Precious
class App < Sinatra::Base class App < Sinatra::Base
register Mustache::Sinatra register Mustache::Sinatra
include Precious::Helpers include Precious::Helpers
dir = File.dirname(File.expand_path(__FILE__)) dir = File.dirname(File.expand_path(__FILE__))
# Detect unsupported browsers. # Detect unsupported browsers.
@@ -59,6 +59,7 @@ module Precious
Browser.new('Internet Explorer', '10.0'), Browser.new('Internet Explorer', '10.0'),
Browser.new('Chrome', '7.0'), Browser.new('Chrome', '7.0'),
Browser.new('Firefox', '4.0'), Browser.new('Firefox', '4.0'),
Browser.new('Safari', '9.0')
] ]
def supported_useragent?(user_agent) def supported_useragent?(user_agent)
@@ -95,9 +96,9 @@ module Precious
before do before do
settings.wiki_options[:allow_editing] = settings.wiki_options.fetch(:allow_editing, true) settings.wiki_options[:allow_editing] = settings.wiki_options.fetch(:allow_editing, true)
@allow_editing = settings.wiki_options[:allow_editing] @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] Precious::App.set(:mustache, {:templates => settings.wiki_options[:template_dir]}) if settings.wiki_options[:template_dir]
@base_url = url('/', false).chomp('/') @base_url = url('/', false).chomp('/')
@page_dir = settings.wiki_options[:page_file_dir].to_s
# above will detect base_path when it's used with map in a config.ru # above will detect base_path when it's used with map in a config.ru
settings.wiki_options.merge!({ :base_path => @base_url }) settings.wiki_options.merge!({ :base_path => @base_url })
@css = settings.wiki_options[:css] @css = settings.wiki_options[:css]
@@ -106,8 +107,7 @@ module Precious
end end
get '/' do get '/' do
page_dir = settings.wiki_options[:page_file_dir].to_s redirect clean_url(::File.join(@base_url, @page_dir, wiki_new.index_page))
redirect clean_url(::File.join(@base_url, page_dir, wiki_new.index_page))
end end
# path is set to name if path is nil. # path is set to name if path is nil.
@@ -130,6 +130,14 @@ module Precious
Gollum::Wiki.new(settings.gollum_path, settings.wiki_options) Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
end end
get '/emoji/:name' do
begin
[200, {'Content-Type' => 'image/png'}, emoji(params['name'])]
rescue ArgumentError
not_found
end
end
get '/data/*' do get '/data/*' do
if page = wiki_page(params[:splat].first).page if page = wiki_page(params[:splat].first).page
page.raw_data page.raw_data
@@ -164,6 +172,8 @@ module Precious
end end
post '/uploadFile' do post '/uploadFile' do
forbid unless @allow_editing
wiki = wiki_new wiki = wiki_new
unless wiki.allow_uploads unless wiki.allow_uploads
@@ -176,9 +186,10 @@ module Precious
fullname = params[:file][:filename] fullname = params[:file][:filename]
tempfile = params[:file][:tempfile] tempfile = params[:file][:tempfile]
end end
halt 500 unless tempfile.is_a? Tempfile
# Remove page file dir prefix from upload path if necessary -- committer handles this itself # 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) ext = ::File.extname(fullname)
format = ext.split('.').last || 'txt' format = ext.split('.').last || 'txt'
filename = ::File.basename(fullname, ext) filename = ::File.basename(fullname, ext)
@@ -211,7 +222,22 @@ module Precious
end end
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 post '/rename/*' do
forbid unless @allow_editing
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
halt 500 if wikip.nil? halt 500 if wikip.nil?
wiki = wikip.wiki wiki = wikip.wiki
@@ -248,6 +274,8 @@ module Precious
end end
post '/edit/*' do post '/edit/*' do
forbid unless @allow_editing
path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s
page_name = CGI.unescape(params[:page]) page_name = CGI.unescape(params[:page])
wiki = wiki_new wiki = wiki_new
@@ -307,6 +335,8 @@ module Precious
end end
post '/create' do post '/create' do
forbid unless @allow_editing
name = params[:page].to_url name = params[:page].to_url
path = sanitize_empty_params(params[:path]) || '' path = sanitize_empty_params(params[:path]) || ''
format = params[:format].intern format = params[:format].intern
@@ -326,6 +356,8 @@ module Precious
end end
post '/revert/*/:sha1/:sha2' do post '/revert/*/:sha1/:sha2' do
forbid unless @allow_editing
wikip = wiki_page(params[:splat].first) wikip = wiki_page(params[:splat].first)
@path = wikip.path @path = wikip.path
@name = wikip.name @name = wikip.name
@@ -349,6 +381,8 @@ module Precious
end end
post '/preview' do post '/preview' do
forbid unless @allow_editing
wiki = wiki_new wiki = wiki_new
@name = params[:page] || "Preview" @name = params[:page] || "Preview"
@page = wiki.preview_page(@name, params[:content], params[:format]) @page = wiki.preview_page(@name, params[:content], params[:format])
@@ -357,6 +391,7 @@ module Precious
@mathjax = wiki.mathjax @mathjax = wiki.mathjax
@h1_title = wiki.h1_title @h1_title = wiki.h1_title
@editable = false @editable = false
@bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads @allow_uploads = wiki.allow_uploads
mustache :page mustache :page
end end
@@ -438,7 +473,7 @@ module Precious
end end
get '/search' do get '/search' do
@query = params[:q] @query = params[:q] || ''
wiki = wiki_new wiki = wiki_new
# Sort wiki search results by count (desc) and then by name (asc) # Sort wiki search results by count (desc) and then by name (asc)
@results = wiki.search(@query).sort { |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse @results = wiki.search(@query).sort { |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
@@ -494,7 +529,7 @@ module Precious
# Extensions and layout data # Extensions and layout data
@editable = true @editable = true
@page_exists = !page.versions.empty? @page_exists = !page.last_version.nil?
@toc_content = wiki.universal_toc ? @page.toc_data : nil @toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax @mathjax = wiki.mathjax
@h1_title = wiki.h1_title @h1_title = wiki.h1_title
+13
View File
@@ -1,6 +1,11 @@
# ~*~ encoding: utf-8 ~*~ # ~*~ encoding: utf-8 ~*~
require 'gemojione'
module Precious module Precious
module Helpers module Helpers
EMOJI_PATHNAME = Pathname.new(Gemojione.index.images_path).freeze
# Extract the path string that Gollum::Wiki expects # Extract the path string that Gollum::Wiki expects
def extract_path(file_path) def extract_path(file_path)
return nil if file_path.nil? return nil if file_path.nil?
@@ -51,5 +56,13 @@ module Precious
return mustache :error return mustache :error
end 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
end end
+16 -1
View File
@@ -85,6 +85,22 @@ ol.tree
margin-right: 7px; margin-right: 7px;
vertical-align: text-top; 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 *= '.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 *= '.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; } 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 { display: block; margin: 0 0 0.125em; /* 2px */}
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ } li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
+6
View File
@@ -849,3 +849,9 @@ ul.actions {
.clearfloats { .clearfloats {
clear: both; 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', 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.' 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:).'
} }
] ]
} }
@@ -394,6 +394,7 @@ var applyTimeout = function () {
jQuery.ajax( { jQuery.ajax( {
type: 'GET', type: 'GET',
url: baseUrl + '/data/' + path + key_no_leading_slash( 'page' ), url: baseUrl + '/data/' + path + key_no_leading_slash( 'page' ),
cache: false,
success: function( data ) { success: function( data ) {
editorSession.setValue( data ); editorSession.setValue( data );
} }
+2 -2
View File
@@ -10,7 +10,7 @@
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all"> <link rel="stylesheet" type="text/css" href="{{base_url}}/css/dialog.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all"> <link rel="stylesheet" type="text/css" href="{{base_url}}/css/template.css" media="all">
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/print.css" media="print"> <link rel="stylesheet" type="text/css" href="{{base_url}}/css/print.css" media="print">
{{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}} {{#css}}<link rel="stylesheet" type="text/css" href="{{custom_path}}/custom.css" media="all">{{/css}}
{{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}} {{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
<!--[if IE 7]> <!--[if IE 7]>
@@ -55,7 +55,7 @@
(d.head || d.getElementsByTagName('head')[0]).appendChild(j); (d.head || d.getElementsByTagName('head')[0]).appendChild(j);
}(document)); }(document));
</script>{{/mathjax}} </script>{{/mathjax}}
{{#js}}<script type="text/javascript" src="{{base_url}}/custom.js"></script>{{/js}} {{#js}}<script type="text/javascript" src="{{custom_path}}/custom.js"></script>{{/js}}
<title>{{title}}</title> <title>{{title}}</title>
</head> </head>
-2
View File
@@ -41,10 +41,8 @@ Mousetrap.bind(['e'], function( e ) {
{{/editable}} {{/editable}}
{{/allow_editing}} {{/allow_editing}}
{{#page_exists}} {{#page_exists}}
<li class="minibutton jaws">
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}" <li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
class="action-page-history">History</a></li> class="action-page-history">History</a></li>
<li class="minibutton jaws">
<li class="minibutton"><a href="{{base_url}}/latest_changes" <li class="minibutton"><a href="{{base_url}}/latest_changes"
class="action-page-history">Latest Changes</a></li> class="action-page-history">Latest Changes</a></li>
{{/page_exists}} {{/page_exists}}
+8
View File
@@ -20,10 +20,18 @@ module Precious
!@path.nil? !@path.nil?
end end
def page_dir
@page_dir
end
def base_url def base_url
@base_url @base_url
end end
def custom_path
"#{@base_url}#{@page_dir.empty? ? '' : '/'}#{@page_dir}"
end
def css # custom css def css # custom css
@css @css
end end
+2 -4
View File
@@ -22,15 +22,13 @@ module Precious
end end
def author def author
page_versions = @page.versions first = page.last_version
first = page_versions ? page_versions.first : false
return DEFAULT_AUTHOR unless first return DEFAULT_AUTHOR unless first
first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name
end end
def date def date
page_versions = @page.versions first = page.last_version
first = page_versions ? page_versions.first : false
return Time.now.strftime(DATE_FORMAT) unless first return Time.now.strftime(DATE_FORMAT) unless first
first.authored_date.strftime(DATE_FORMAT) first.authored_date.strftime(DATE_FORMAT)
end end
+18 -11
View File
@@ -31,29 +31,36 @@ module Precious
def files_folders def files_folders
if has_results if has_results
folder_links = [] folders = {}
page_files = {}
@results.map { |page| # 1012: Folders and Pages need to be separated
page_path = page.path.sub(/^#{@path}\//, '') @results.each do |page|
page_path = page.path
page_path = page_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil?
if page_path.include?('/') if page_path.include?('/')
folder = page_path.split('/').first folder = page_path.split('/').first
folder_path = @path ? "#{@path}/#{folder}" : folder folder_path = @path ? "#{@path}/#{folder}" : folder
folder_link = %{<li><a href="#{@base_url}/pages/#{folder_path}/" class="folder">#{folder}</a></li>} folder_link = %{<li><a href="#{@base_url}/pages/#{folder_path}/" class="folder">#{folder}</a></li>}
unless folder_links.include?(folder_link) folders[folder] = folder_link unless folders.key?(folder)
folder_links << folder_link
folder_link
end
elsif page_path != ".gitkeep" elsif page_path != ".gitkeep"
if defined? page.format if defined? page.format
%{<li><a href="#{@base_url}/#{page.escaped_url_path}" class="file">#{page.name}</a></li>} page_link = %{<li><a href="#{@base_url}/#{page.escaped_url_path}" class="file">#{page.name}</a></li>}
page_files[page.name] = page_link
else else
%{<li><a href="#{@base_url}/#{page.escaped_url_path}#{page.name}" class="file">#{page.name}</a></li>} page_link = %{<li><a href="#{@base_url}/#{page.escaped_url_path}#{page.name}" class="file">#{page.name}</a></li>}
page_files[page.name] = page_link
end end
end end
}.compact.join("\n") end
# 1012: All Pages should be rendered as Folders first, then Pages, each sorted alphabetically
result = Hash[folders.sort_by{| key, value | key.downcase} ].values.join("\n") + "\n"
result += Hash[page_files.sort_by{ | key, value | key.downcase } ].values.join("\n")
result
else else
"" ""
end end
+27 -2
View File
@@ -64,7 +64,7 @@ context "Frontend" do
end end
def nfd utf8 def nfd utf8
TwitterCldr::Normalization::NFD.normalize utf8 TwitterCldr::Normalization.normalize(utf8, using: :nfd)
end end
test "UTF-8 headers href preserved" do test "UTF-8 headers href preserved" do
@@ -513,10 +513,23 @@ context "Frontend" do
{ :name => 'user1', :email => 'user1' }); { :name => 'user1', :email => 'user1' });
get page get page
assert_match /custom.js/, last_response.body assert_match /"\/custom.js"/, last_response.body
Precious::App.set(:wiki_options, { :js => nil }) Precious::App.set(:wiki_options, { :js => nil })
end 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 test "show edit page with header and footer and sidebar of multibyte" do
post "/create", post "/create",
:content => 'りんご', :content => 'りんご',
@@ -694,6 +707,18 @@ context "Frontend with lotr" do
assert_match /not so big smelly creatures/, last_response.body assert_match /not so big smelly creatures/, last_response.body
end 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 def app
Precious::App Precious::App
end end
+10 -3
View File
@@ -39,12 +39,19 @@ context "Precious::Views::Pages" do
assert_equal 'Home', @page.breadcrumb assert_equal 'Home', @page.breadcrumb
end end
test "files_folders" do test "folders first" do
@page.instance_variable_set("@base_url", "")
results = [FakePageResult.new("Gondor/Bromir.md"), FakePageResult.new("Hobbit.md"), FakePageResult.new("Home.md"), FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakePageResult.new("Mordor/todo.md"), FakePageResult.new("Rivendell/Elrond.md"), FakePageResult.new("My-Precious.md"), FakePageResult.new("Zamin.md"), FakePageResult.new("Samwise-Gamgee.md"), FakePageResult.new("roast-mutton.md"), FakePageResult.new("Bilbo-Baggins.md")]
@page.instance_variable_set("@results", results)
assert_equal %{<li><a href="/pages/Gondor/" class="folder">Gondor</a></li>\n<li><a href="/pages/Mordor/" class="folder">Mordor</a></li>\n<li><a href="/pages/Rivendell/" class="folder">Rivendell</a></li>\n<li><a href="/Bilbo-Baggins" class="file">Bilbo Baggins</a></li>\n<li><a href="/Hobbit" class="file">Hobbit</a></li>\n<li><a href="/Home" class="file">Home</a></li>\n<li><a href="/My-Precious" class="file">My Precious</a></li>\n<li><a href="/roast-mutton" class="file">roast mutton</a></li>\n<li><a href="/Samwise-Gamgee" class="file">Samwise Gamgee</a></li>\n<li><a href="/Zamin" class="file">Zamin</a></li>}, @page.files_folders
end
test "files_folders from subdir" do
@page.instance_variable_set("@path", "Mordor") @page.instance_variable_set("@path", "Mordor")
@page.instance_variable_set("@base_url", "") @page.instance_variable_set("@base_url", "")
results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakeFileResult.new("Mordor/.gitkeep")] results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakeFileResult.new("Mordor/.gitkeep")]
@page.instance_variable_set("@results", results) @page.instance_variable_set("@results", results)
assert_equal %{<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href="/Mordor/Aragorn.pdf" class="file">Aragorn.pdf</a></li>\n<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders assert_equal %{<li><a href="/pages/Mordor/Orc/" class="folder">Orc</a></li>\n<li><a href="/Mordor/Aragorn.pdf" class="file">Aragorn.pdf</a></li>\n<li><a href="/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>}, @page.files_folders
end end
test "base url" do test "base url" do
@@ -53,6 +60,6 @@ context "Precious::Views::Pages" do
@page.instance_variable_set("@base_url", "/wiki") @page.instance_variable_set("@base_url", "/wiki")
results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakePageResult.new("Mordor/.gitkeep")] results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakePageResult.new("Mordor/.gitkeep")]
@page.instance_variable_set("@results", results) @page.instance_variable_set("@results", results)
assert_equal %{<li><a href="/wiki/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>\n<li><a href=\"/wiki/Mordor/Aragorn.pdf\" class=\"file\">Aragorn.pdf</a></li>\n<li><a href="/wiki/pages/Mordor/Orc/" class="folder">Orc</a></li>}, @page.files_folders assert_equal %{<li><a href="/wiki/pages/Mordor/Orc/" class="folder">Orc</a></li>\n<li><a href="/wiki/Mordor/Aragorn.pdf" class="file">Aragorn.pdf</a></li>\n<li><a href="/wiki/Mordor/Eye-Of-Sauron" class="file">Eye Of Sauron</a></li>}, @page.files_folders
end end
end end