Compare commits
69 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 02fd12339f | |||
| 9048d6a03d | |||
| 93f6b0373a | |||
| 43d3271b4e | |||
| 66d09b76c7 | |||
| 90043a66cb | |||
| 317ccef7c8 | |||
| 771ca331e9 | |||
| 7ada448bce | |||
| c2258c449e | |||
| 612267d322 | |||
| 6de0914788 | |||
| e4f702d1e2 | |||
| 2f864c5e15 | |||
| 7139590798 | |||
| 0870655455 | |||
| ba24a7bb8c | |||
| f32d7465a2 | |||
| e202698bf1 | |||
| 11c2bf7dae | |||
| 53cf0e1148 | |||
| 2d1e49e3f2 | |||
| 199161f611 | |||
| ece5c775f1 | |||
| 3121c43b71 | |||
| 51e8caf369 | |||
| e7e7937678 | |||
| a0f5a60ea0 | |||
| af29c6e441 | |||
| 00dfecb1c7 | |||
| cc249bef15 | |||
| 9a2231804d | |||
| 1edcf15bcd | |||
| 0190e08763 | |||
| d3cc5a69c4 | |||
| 07ca53a778 | |||
| 6910b6d024 | |||
| f02c934ad7 | |||
| 236680aab9 | |||
| 6316f97c06 | |||
| 14830af306 | |||
| b620decde7 | |||
| b08ca620a0 | |||
| 66a2bb0393 | |||
| 0675844d97 | |||
| 148eda2990 | |||
| 330f7b4002 | |||
| def0fc8866 | |||
| fa1bcf9608 | |||
| 5a5e56a47b | |||
| e64f40eaa3 | |||
| 3f3d86ad4c | |||
| 91833dd72e | |||
| c049f7c11f | |||
| 6bd2f3bff5 | |||
| 8c3c519679 | |||
| 4e5002a31e | |||
| 5a53c58b04 | |||
| a61d1e3d10 | |||
| 1a50f99189 | |||
| 6caacbf388 | |||
| f876aa7d0f | |||
| 31e1281600 | |||
| 90072a9332 | |||
| bacd2893b9 | |||
| 7362fd859b | |||
| 3811fb46b3 | |||
| 9cc02982be | |||
| 1cceb7d4b4 |
@@ -30,3 +30,11 @@ gollum text
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
|
||||
# Make github-linguist ignore files that aren't our own
|
||||
|
||||
lib/gollum/public/gollum/* linguist-vendored
|
||||
lib/gollum/public/gollum/javascript/gollum* linguist-vendored=false
|
||||
lib/gollum/public/gollum/javascript/*/gollum* linguist-vendored=false
|
||||
lib/gollum/public/gollum/css linguist-vendored=false
|
||||
|
||||
|
||||
+5
-3
@@ -1,10 +1,12 @@
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1.0
|
||||
- 2.1.1
|
||||
- 2.2.2
|
||||
- jruby-19mode
|
||||
- 2.3.0
|
||||
- 2.4.0
|
||||
- jruby-9.1.8.0
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install libicu-dev
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
# 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).
|
||||
|
||||
Security vulnerabilities can be reported directly to the maintainers using these GPG keys:
|
||||
|
||||
* [@dometto](https://pgp.mit.edu/pks/lookup?op=vindex&search=0xD637E455CD3E27BF)
|
||||
|
||||
Lastly, please **consider helping out** by opening a Pull Request!
|
||||
|
||||
## Triaging Issues [](https://www.codetriage.com/gollum/gollum)
|
||||
|
||||
You can triage issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to gollum on CodeTriage](https://www.codetriage.com/gollum/gollum).
|
||||
|
||||
|
||||
## 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
|
||||
```
|
||||
+18
@@ -1,3 +1,21 @@
|
||||
# 4.1.4 /2018-01-10
|
||||
|
||||
* Depend on new version of gollum-lib that relies on a patched version of sanitize, which solves a vulnerability (CVE-2018-3740). See https://github.com/gollum/gollum-lib/pull/296.
|
||||
|
||||
# 4.1.3 /2018-17-09
|
||||
|
||||
* Solves a vulnerability in the File view and All Pages view that would allow XSS.
|
||||
|
||||
# 4.1.2 /2017-08-07
|
||||
|
||||
* Lock to a newer version of gollum-lib to avoid installing an outdated and vulnerable dependency (nokogiri) on ruby 2.0. See https://github.com/gollum/gollum-lib/pull/279. Note: this breaks semantic versioning so those using outdated rubies will discover the problem on update.
|
||||
|
||||
# 4.1.0 /2017-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))
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
**Note**: we are currently working on version 5.0 of gollum in an attempt to make it, better, faster, and easier to maintain. We will **not** be fixing issues with previous versions of gollum (4.x), except for security issues.
|
||||
|
||||
Please submit only issues that are present in the `5.x` branch of this project. When submitting issues with `5.x`, please include the output of `gollum --versions` in your ticket.
|
||||
|
||||
Please read [these guidelines](https://github.com/gollum/gollum/blob/master/CONTRIBUTING.md) before submitting your issue, and for info on reporting vulnerabilities.
|
||||
|
||||
Finally: we need your help! Please consider chipping in by submitting a PR rather than just by reporting your issue.
|
||||
@@ -3,7 +3,7 @@ gollum -- A git-based Wiki
|
||||
|
||||
[](http://badge.fury.io/rb/gollum)
|
||||
[](https://travis-ci.org/gollum/gollum)
|
||||
[](https://gemnasium.com/gollum/gollum)
|
||||
[](https://www.codetriage.com/gollum/gollum)
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
@@ -23,13 +23,19 @@ For more information on Gollum's capabilities and pitfalls:
|
||||
3. [Troubleshoot guide](https://github.com/gollum/gollum/wiki/Troubleshoot-guide).
|
||||
4. [Security overview](https://github.com/gollum/gollum/wiki/Security).
|
||||
|
||||
### 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
|
||||
|
||||
| Operating System | Ruby | Adapters | Supported |
|
||||
| Operating System | Ruby | Adapters | Supported |
|
||||
| ---------------- | -------------- | ------------------ | --------- |
|
||||
| Unix/Linux-like | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | yes |
|
||||
| Unix/Linux-like | Ruby (MRI) 2.1.0+ | all except [RJGit](https://github.com/repotag/rjgit) | yes |
|
||||
| Unix/Linux-like | [JRuby](https://github.com/jruby/jruby) (1.9.3+ compatible) | [RJGit](https://github.com/repotag/rjgit) | yes |
|
||||
| Windows | Ruby 1.9.3+ | all except [RJGit](https://github.com/repotag/rjgit) | no |
|
||||
| Windows | Ruby (MRI) 2.1.0+ | 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> |
|
||||
|
||||
**Notes:**
|
||||
@@ -67,7 +73,7 @@ Installation examples for individual systems can be seen [here](https://github.c
|
||||
```
|
||||
* And install:
|
||||
```
|
||||
[sudo] gem install --no-ri --no-rdoc pkg/gollum*.gem
|
||||
[sudo] gem install --no-document pkg/gollum*.gem
|
||||
```
|
||||
|
||||
### Markups
|
||||
@@ -79,7 +85,6 @@ Gollum presently ships with support for the following markups:
|
||||
Since all markups are rendered by the [github-markup](https://github.com/github/markup) gem, you can easily add support for other markups by additional installation:
|
||||
* [AsciiDoc](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/) -- `[sudo] gem install asciidoctor`
|
||||
* [Creole](http://www.wikicreole.org/wiki/CheatSheet) -- `[sudo] gem install creole`
|
||||
* [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) -- `[sudo] gem install github-markdown`
|
||||
* [MediaWiki](http://www.mediawiki.org/wiki/Help:Formatting) -- `[sudo] gem install wikicloth`
|
||||
* [Org](http://orgmode.org/worg/dev/org-syntax.html) -- `[sudo] gem install org-ruby`
|
||||
* [Pod](http://perldoc.perl.org/perlpod.html) -- requires Perl >= 5.10 (the `perl` command must be available on your command line)
|
||||
@@ -98,14 +103,17 @@ Simply:
|
||||
2. Run: `gollum`.
|
||||
3. Open `http://localhost:4567` in your browser.
|
||||
|
||||
If you wish to run from source, simply:
|
||||
|
||||
1. Navigate to your git repository (wiki) via the command line.
|
||||
2. Run: `bundle exec bin/gollum`
|
||||
3. Open `http://localhost:4567` in your browser.
|
||||
|
||||
This will start up a web server (WEBrick) running Gollum with a web interface, where you can view and edit your wiki.
|
||||
|
||||
### Running from source
|
||||
|
||||
1. `git clone https://github.com/gollum/gollum`
|
||||
2. `cd gollum`
|
||||
3. `[sudo] bundle install` (may not always be necessary).
|
||||
4. `bundle exec bin/gollum`
|
||||
* Like that, gollum assumes the target wiki (git repository) is the project repository itself. If it's not, execute `bundle exec bin/gollum <path-to-wiki>` instead.
|
||||
5. Open `http://localhost:4567` in your browser.
|
||||
|
||||
### Rack
|
||||
|
||||
Gollum can also be ran with any [rack-compatible web server](https://github.com/rack/rack#supported-web-servers). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack).
|
||||
@@ -138,6 +146,7 @@ Gollum comes with the following command line options:
|
||||
| --page-file-dir | [PATH] | Specify the subdirectory for all pages. If set, Gollum will only serve pages from this directory and its subdirectories. Default: repository root. |
|
||||
| --css | none | Tell Gollum to inject custom CSS into each page. Uses `custom.css` from repository root.<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. |
|
||||
@@ -166,70 +175,3 @@ Gollum comes with the following command line options:
|
||||
When `--config` option is used, certain inner parts of Gollum can be customized. This is used throughout our wiki for certain user-level alterations, among which [customizing supported markups](https://github.com/gollum/gollum/wiki/Formats-and-extensions) will probably stand out.
|
||||
|
||||
**All of the mentioned alterations work both for Gollum's config file (`config.rb`) and Rack's config file (`config.ru`).**
|
||||
|
||||
## HOW TO CONTRIBUTE
|
||||
|
||||
1. Fork and clone Gollum.
|
||||
2. Create a thoughtfully named topic branch to contain your changes.
|
||||
3. If you haven't installed dependencies yet, navigate to your clone and execute:
|
||||
```
|
||||
[sudo] bundle install
|
||||
```
|
||||
4. Hack away.
|
||||
5. Add your own tests and make sure they're all still passing.
|
||||
6. If some of your changes deserve a mention on Gollum's home page, edit the README accordingly.
|
||||
7. If necessary, rebase your commits into logical chunks, without errors.
|
||||
8. Push the branch to your fork on GitHub.
|
||||
9. Create a pull request for Gollum.
|
||||
|
||||
**Notes:**
|
||||
* Do not change Gollum's version numbers, we will do that on our own.
|
||||
|
||||
### Running tests
|
||||
|
||||
1. Install [Bundler](http://bundler.io/).
|
||||
2. Navigate to the cloned source of Gollum.
|
||||
3. Install dependencies:
|
||||
```
|
||||
[sudo] bundle install
|
||||
```
|
||||
4. Run the tests:
|
||||
```
|
||||
bundle exec rake test
|
||||
```
|
||||
|
||||
### Working with test repositories
|
||||
|
||||
An example of how to add a test file to the bare repository lotr.git.
|
||||
|
||||
```
|
||||
mkdir tmp
|
||||
cd tmp
|
||||
git clone ../lotr.git/
|
||||
git log
|
||||
echo "test" > test.md
|
||||
git add .
|
||||
git commit -am "Add test"
|
||||
git push ../lotr.git/ master
|
||||
```
|
||||
|
||||
## RELEASING
|
||||
|
||||
Gollum uses [Semantic Versioning](http://semver.org/).
|
||||
|
||||
x.y.z
|
||||
|
||||
For z releases:
|
||||
|
||||
```
|
||||
rake bump
|
||||
rake release
|
||||
```
|
||||
|
||||
For x.y releases:
|
||||
|
||||
```
|
||||
# First update VERSION in lib/gollum.rb and then:
|
||||
rake gemspec
|
||||
rake release
|
||||
```
|
||||
|
||||
+21
-5
@@ -71,10 +71,8 @@ opts = OptionParser.new do |opts|
|
||||
"Example: setting this to '/wiki' will make the wiki accessible under 'http://localhost:4567/wiki/'.") do |base_path|
|
||||
|
||||
# first trim a leading slash, if any
|
||||
if base_path.start_with?("/")
|
||||
base_path = base_path[1..-1]
|
||||
end
|
||||
|
||||
base_path.sub!(/^\/+/, '')
|
||||
|
||||
# make a backup of the option and sanitize it
|
||||
base_path_original = base_path.dup
|
||||
base_path = CGI.escape(base_path)
|
||||
@@ -101,6 +99,9 @@ MSG
|
||||
opts.on("--js", "Inject custom JavaScript into each page. The '<git-repo>/custom.js' file is used (must be committed).") do
|
||||
wiki_options[:js] = true
|
||||
end
|
||||
opts.on("--emoji", "Parse and interpret emoji tags (e.g. :heart:).") do
|
||||
wiki_options[:emoji] = true
|
||||
end
|
||||
opts.on("--no-edit", "Disable the feature of editing pages.") do
|
||||
wiki_options[:allow_editing] = false
|
||||
end
|
||||
@@ -144,6 +145,9 @@ MSG
|
||||
"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
|
||||
@@ -161,7 +165,6 @@ MSG
|
||||
end
|
||||
|
||||
opts.separator ""
|
||||
|
||||
end
|
||||
|
||||
# Read command line options into `options` hash
|
||||
@@ -207,6 +210,12 @@ if options[:irb]
|
||||
if !wiki.exist? then
|
||||
raise Gollum::InvalidGitRepositoryError
|
||||
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
|
||||
puts
|
||||
puts "Loaded Gollum wiki at:"
|
||||
puts "#{File.expand_path(gollum_path).inspect}"
|
||||
@@ -242,6 +251,13 @@ else
|
||||
require cfg
|
||||
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]
|
||||
|
||||
if base_path.nil?
|
||||
|
||||
+10
-6
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = '>= 1.9'
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '4.0.1'
|
||||
s.date = '2015-09-20'
|
||||
s.version = '4.1.4'
|
||||
s.date = '2018-10-01'
|
||||
s.rubyforge_project = 'gollum'
|
||||
s.license = 'MIT'
|
||||
|
||||
@@ -24,24 +24,27 @@ Gem::Specification.new do |s|
|
||||
s.rdoc_options = ['--charset=UTF-8']
|
||||
s.extra_rdoc_files = %w[README.md LICENSE]
|
||||
|
||||
s.add_dependency 'gollum-lib', '~> 4.0', '>= 4.0.1'
|
||||
s.add_dependency 'kramdown', '~> 1.8.0'
|
||||
s.add_dependency 'gollum-lib', '~> 4.2', '>= 4.2.10'
|
||||
s.add_dependency 'kramdown', '~> 1.9.0'
|
||||
s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4'
|
||||
s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
|
||||
s.add_dependency 'useragent', '~> 0.14.0'
|
||||
s.add_dependency 'useragent', '~> 0.16.2'
|
||||
s.add_dependency 'gemojione', '~> 3.2'
|
||||
|
||||
s.add_development_dependency 'rack-test', '~> 0.6.2'
|
||||
s.add_development_dependency 'shoulda', '~> 3.5.0'
|
||||
s.add_development_dependency 'minitest-reporters', '~> 0.14.16'
|
||||
s.add_development_dependency 'twitter_cldr', '~> 3.2.0'
|
||||
s.add_development_dependency 'mocha', '~> 1.1.0'
|
||||
s.add_development_dependency 'test-unit', '~> 3.1.0' if RUBY_VERSION =~ /^2.2/
|
||||
s.add_development_dependency 'test-unit', '~> 3.1.0'
|
||||
s.add_development_dependency 'webrick', '~> 1.3.1'
|
||||
|
||||
# = MANIFEST =
|
||||
s.files = %w[
|
||||
CONTRIBUTING.md
|
||||
Gemfile
|
||||
HISTORY.md
|
||||
ISSUE_TEMPLATE.md
|
||||
LICENSE
|
||||
README.md
|
||||
Rakefile
|
||||
@@ -73,6 +76,7 @@ Gem::Specification.new do |s|
|
||||
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.png
|
||||
lib/gollum/public/gollum/images/fileview/trashcan.png
|
||||
lib/gollum/public/gollum/images/icon-sprite.png
|
||||
lib/gollum/public/gollum/images/man_24.png
|
||||
lib/gollum/public/gollum/images/para.png
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ require File.expand_path('../gollum/uri_encode_component', __FILE__)
|
||||
$KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8'
|
||||
|
||||
module Gollum
|
||||
VERSION = '4.0.1'
|
||||
VERSION = '4.1.4'
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
||||
|
||||
+44
-9
@@ -49,7 +49,7 @@ module Precious
|
||||
class App < Sinatra::Base
|
||||
register Mustache::Sinatra
|
||||
include Precious::Helpers
|
||||
|
||||
|
||||
dir = File.dirname(File.expand_path(__FILE__))
|
||||
|
||||
# Detect unsupported browsers.
|
||||
@@ -59,6 +59,7 @@ module Precious
|
||||
Browser.new('Internet Explorer', '10.0'),
|
||||
Browser.new('Chrome', '7.0'),
|
||||
Browser.new('Firefox', '4.0'),
|
||||
Browser.new('Safari', '9.0')
|
||||
]
|
||||
|
||||
def supported_useragent?(user_agent)
|
||||
@@ -95,7 +96,6 @@ module Precious
|
||||
before do
|
||||
settings.wiki_options[:allow_editing] = settings.wiki_options.fetch(:allow_editing, true)
|
||||
@allow_editing = settings.wiki_options[:allow_editing]
|
||||
forbid unless @allow_editing || request.request_method == "GET"
|
||||
Precious::App.set(:mustache, {:templates => settings.wiki_options[:template_dir]}) if settings.wiki_options[:template_dir]
|
||||
@base_url = url('/', false).chomp('/')
|
||||
@page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||
@@ -130,6 +130,14 @@ module Precious
|
||||
Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
||||
end
|
||||
|
||||
get '/emoji/:name' do
|
||||
begin
|
||||
[200, {'Content-Type' => 'image/png'}, emoji(params['name'])]
|
||||
rescue ArgumentError
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
get '/data/*' do
|
||||
if page = wiki_page(params[:splat].first).page
|
||||
page.raw_data
|
||||
@@ -164,6 +172,8 @@ module Precious
|
||||
end
|
||||
|
||||
post '/uploadFile' do
|
||||
forbid unless @allow_editing
|
||||
|
||||
wiki = wiki_new
|
||||
|
||||
unless wiki.allow_uploads
|
||||
@@ -179,7 +189,7 @@ module Precious
|
||||
halt 500 unless tempfile.is_a? Tempfile
|
||||
|
||||
# Remove page file dir prefix from upload path if necessary -- committer handles this itself
|
||||
dir = wiki.per_page_uploads ? params[:upload_dest].match(/^(#{wiki.page_file_dir}\/+)?(.*)/)[2] : 'uploads'
|
||||
dir = wiki.per_page_uploads ? params[:upload_dest] : ::File.join([wiki.page_file_dir, 'uploads'].compact)
|
||||
ext = ::File.extname(fullname)
|
||||
format = ext.split('.').last || 'txt'
|
||||
filename = ::File.basename(fullname, ext)
|
||||
@@ -212,7 +222,22 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
post '/deleteFile/*' do
|
||||
forbid unless @allow_editing
|
||||
wiki = wiki_new
|
||||
filepath = params[:splat].first
|
||||
unless filepath.nil?
|
||||
commit = commit_message
|
||||
commit[:message] = "Deleted #{filepath}"
|
||||
wiki.delete_file(filepath, commit)
|
||||
end
|
||||
|
||||
redirect to('/fileview')
|
||||
end
|
||||
|
||||
post '/rename/*' do
|
||||
forbid unless @allow_editing
|
||||
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
halt 500 if wikip.nil?
|
||||
wiki = wikip.wiki
|
||||
@@ -249,6 +274,8 @@ module Precious
|
||||
end
|
||||
|
||||
post '/edit/*' do
|
||||
forbid unless @allow_editing
|
||||
|
||||
path = '/' + clean_url(sanitize_empty_params(params[:path])).to_s
|
||||
page_name = CGI.unescape(params[:page])
|
||||
wiki = wiki_new
|
||||
@@ -308,6 +335,8 @@ module Precious
|
||||
end
|
||||
|
||||
post '/create' do
|
||||
forbid unless @allow_editing
|
||||
|
||||
name = params[:page].to_url
|
||||
path = sanitize_empty_params(params[:path]) || ''
|
||||
format = params[:format].intern
|
||||
@@ -319,7 +348,7 @@ module Precious
|
||||
wiki.write_page(name, format, params[:content], commit_message, path)
|
||||
|
||||
page_dir = settings.wiki_options[:page_file_dir].to_s
|
||||
redirect to("/#{clean_url(::File.join(page_dir, path, encodeURIComponent(name)))}")
|
||||
redirect to("/#{clean_url(::File.join(encodeURIComponent(page_dir), encodeURIComponent(path), encodeURIComponent(name)))}")
|
||||
rescue Gollum::DuplicatePageError => e
|
||||
@message = "Duplicate page: #{e.message}"
|
||||
mustache :error
|
||||
@@ -327,6 +356,8 @@ module Precious
|
||||
end
|
||||
|
||||
post '/revert/*/:sha1/:sha2' do
|
||||
forbid unless @allow_editing
|
||||
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
@path = wikip.path
|
||||
@name = wikip.name
|
||||
@@ -350,6 +381,8 @@ module Precious
|
||||
end
|
||||
|
||||
post '/preview' do
|
||||
forbid unless @allow_editing
|
||||
|
||||
wiki = wiki_new
|
||||
@name = params[:page] || "Preview"
|
||||
@page = wiki.preview_page(@name, params[:content], params[:format])
|
||||
@@ -358,6 +391,7 @@ module Precious
|
||||
@mathjax = wiki.mathjax
|
||||
@h1_title = wiki.h1_title
|
||||
@editable = false
|
||||
@bar_side = wiki.bar_side
|
||||
@allow_uploads = wiki.allow_uploads
|
||||
mustache :page
|
||||
end
|
||||
@@ -430,6 +464,7 @@ module Precious
|
||||
@name = name
|
||||
@content = page.formatted_data
|
||||
@version = version
|
||||
@bar_side = wikip.wiki.bar_side
|
||||
mustache :page
|
||||
elsif file = wikip.wiki.file("#{file_path}", version, true)
|
||||
show_file(file)
|
||||
@@ -455,11 +490,11 @@ module Precious
|
||||
}x do |path|
|
||||
@path = extract_path(path) if path
|
||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => @path })
|
||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
@results = wiki.pages
|
||||
@results += wiki.files if settings.wiki_options[:show_all]
|
||||
@wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||
@results = @wiki.pages
|
||||
@results += @wiki.files if settings.wiki_options[:show_all]
|
||||
@results = @results.sort_by { |p| p.name.downcase } # Sort Results alphabetically, fixes 922
|
||||
@ref = wiki.ref
|
||||
@ref = @wiki.ref
|
||||
mustache :pages
|
||||
end
|
||||
|
||||
@@ -495,7 +530,7 @@ module Precious
|
||||
|
||||
# Extensions and layout data
|
||||
@editable = true
|
||||
@page_exists = !page.versions.empty?
|
||||
@page_exists = !page.last_version.nil?
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@mathjax = wiki.mathjax
|
||||
@h1_title = wiki.h1_title
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
# ~*~ encoding: utf-8 ~*~
|
||||
require 'gemojione'
|
||||
|
||||
module Precious
|
||||
module Helpers
|
||||
|
||||
EMOJI_PATHNAME = Pathname.new(Gemojione.images_path).freeze
|
||||
|
||||
# Extract the path string that Gollum::Wiki expects
|
||||
def extract_path(file_path)
|
||||
return nil if file_path.nil?
|
||||
@@ -51,5 +56,13 @@ module Precious
|
||||
return mustache :error
|
||||
end
|
||||
|
||||
def emoji(name)
|
||||
if emoji = Gemojione.index.find_by_name(name)
|
||||
IO.read(EMOJI_PATHNAME.join("#{emoji['unicode']}.png"))
|
||||
else
|
||||
fail ArgumentError, "emoji `#{name}' not found"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -85,6 +85,22 @@ ol.tree
|
||||
margin-right: 7px;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
li.file form
|
||||
{
|
||||
vertical-align:middle;
|
||||
display: inline-block;
|
||||
}
|
||||
li.file form button
|
||||
{
|
||||
vertical-align:middle;
|
||||
height: 20px;
|
||||
padding-left: 36px;
|
||||
padding-right: 10px;
|
||||
border: 0px solid #000000;
|
||||
background: url("../images/fileview/trashcan.png") no-repeat 16px center;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
li.file a[href *= '.pdf'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href *= '.html'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
li.file a[href $= '.css'] span.icon { background: url(../images/fileview/document.png) 0 0 no-repeat; }
|
||||
@@ -125,4 +141,3 @@ ol.tree
|
||||
}
|
||||
li input:checked + ol > li { display: block; margin: 0 0 0.125em; /* 2px */}
|
||||
li input:checked + ol > li:last-child { margin: 0 0 0.063em; /* 1px */ }
|
||||
|
||||
|
||||
@@ -849,3 +849,9 @@ ul.actions {
|
||||
.clearfloats {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.emoji {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
vertical-align: -18%;
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -211,6 +211,11 @@ var MarkDownHelp = [
|
||||
{
|
||||
menuName: 'Escaping',
|
||||
data: '<p>If you want to use a special Markdown character in your document (such as displaying literal asterisks), you can escape the character with the backslash (<code>\\</code>). Markdown will ignore the character directly after a backslash.'
|
||||
},
|
||||
|
||||
{
|
||||
menuName: 'Emoji',
|
||||
data: '<p>See the <a href="http://emojione.com/demo/" target="_blank">EmojiOne demo</a> for all available emoji. To include one, wrap the emoji name in colons and use underscores instead of spaces (e.g. :heart: or :point_up:).'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -22,15 +22,13 @@ module Precious
|
||||
end
|
||||
|
||||
def author
|
||||
page_versions = @page.versions
|
||||
first = page_versions ? page_versions.first : false
|
||||
first = page.last_version
|
||||
return DEFAULT_AUTHOR unless first
|
||||
first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name
|
||||
end
|
||||
|
||||
def date
|
||||
page_versions = @page.versions
|
||||
first = page_versions ? page_versions.first : false
|
||||
first = page.last_version
|
||||
return Time.now.strftime(DATE_FORMAT) unless first
|
||||
first.authored_date.strftime(DATE_FORMAT)
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
breadcrumb.join(" / ")
|
||||
@wiki.sanitizer.clean(breadcrumb.join(" / "))
|
||||
else
|
||||
"Home"
|
||||
end
|
||||
@@ -36,7 +36,8 @@ module Precious
|
||||
|
||||
# 1012: Folders and Pages need to be separated
|
||||
@results.each do |page|
|
||||
page_path = page.path.sub(/^#{@path}\//, '')
|
||||
page_path = page.path
|
||||
page_path = page_path.sub(/^#{Regexp.escape(@path)}\//, '') unless @path.nil?
|
||||
|
||||
if page_path.include?('/')
|
||||
folder = page_path.split('/').first
|
||||
@@ -59,7 +60,7 @@ module Precious
|
||||
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
|
||||
@wiki.sanitizer.clean(result)
|
||||
else
|
||||
""
|
||||
end
|
||||
|
||||
@@ -30,6 +30,11 @@ context "Frontend" do
|
||||
# and in file names saved to disk
|
||||
# urls are not case sensitive
|
||||
assert_equal 'Title-Space', 'Title Space'.to_url
|
||||
end
|
||||
|
||||
test "translation" do
|
||||
# we transliterate only when adapter is grit
|
||||
return if defined?(Gollum::GIT_ADAPTER) && Gollum::GIT_ADAPTER != 'grit'
|
||||
|
||||
# ascii only file names prevent UTF8 issues
|
||||
# when using git repos across operating systems
|
||||
@@ -707,6 +712,18 @@ context "Frontend with lotr" do
|
||||
assert_match /not so big smelly creatures/, last_response.body
|
||||
end
|
||||
|
||||
test "existing emoji" do
|
||||
get "/emoji/heart"
|
||||
assert_equal 200, last_response.status
|
||||
assert_equal 'image/png', last_response.headers['Content-Type']
|
||||
assert_equal [137, 80, 78, 71, 13, 10, 26, 10], last_response.body.each_byte.to_a[0..7]
|
||||
end
|
||||
|
||||
test "missing emoji" do
|
||||
get "/emoji/oggy_was_here"
|
||||
assert_equal 404, last_response.status
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
|
||||
@@ -2,6 +2,18 @@
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
|
||||
require File.expand_path '../../lib/gollum/views/pages', __FILE__
|
||||
|
||||
class FakeSane
|
||||
def clean(data)
|
||||
data
|
||||
end
|
||||
end
|
||||
|
||||
class FakeWiki
|
||||
def sanitizer
|
||||
FakeSane.new
|
||||
end
|
||||
end
|
||||
|
||||
FakePageResult = Struct.new(:path) do
|
||||
def name
|
||||
File.basename(path, File.extname(path)).gsub("-", " ")
|
||||
@@ -27,6 +39,7 @@ end
|
||||
context "Precious::Views::Pages" do
|
||||
setup do
|
||||
@page = Precious::Views::Pages.new
|
||||
@page.instance_variable_set("@wiki", FakeWiki.new)
|
||||
end
|
||||
|
||||
test "breadcrumb" do
|
||||
|
||||
@@ -90,8 +90,11 @@ context "Frontend Unicode support" do
|
||||
end
|
||||
|
||||
test 'transliteration' do
|
||||
# we transliterate only when adapter is grit
|
||||
return if defined?(Gollum::GIT_ADAPTER) && Gollum::GIT_ADAPTER != 'grit'
|
||||
|
||||
# TODO: Remove to_url once write_page changes are merged.
|
||||
@wiki.write_page('ééééé'.to_url, :markdown, '한글 text', { :name => '', :email => '' })
|
||||
@wiki.write_page('ééééé'.to_url, :markdown, '한글 text', commit_details)
|
||||
page = @wiki.page('eeeee')
|
||||
assert_equal '한글 text', utf8(page.raw_data)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user