Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 25d30aee64 | |||
| 8af92da23c | |||
| 324ff0a17c | |||
| cfb372e5e2 | |||
| 6513c732ba | |||
| c4ea869223 | |||
| 5387267675 | |||
| 8e4c3cc562 | |||
| 8b6b0699e5 | |||
| 229bff1658 | |||
| 7a59d37350 | |||
| d06b1e7883 | |||
| c8a284db9d | |||
| c7d6aceff4 | |||
| 7ea45d5e89 | |||
| 48c4aafb15 | |||
| ff302ed842 | |||
| 20a2424b83 | |||
| de0f34a27a | |||
| d0992cce3f | |||
| 15feeb3614 | |||
| fc0a879e52 | |||
| 9b675146a2 | |||
| 4d0bdcc8c0 | |||
| 0abdb67687 | |||
| d1fb98cf1b | |||
| 5eac24eacb | |||
| 3fd16daeca | |||
| d9b38c3b73 | |||
| 0a5176c1ee | |||
| b836b0e273 | |||
| 9a41e2a65d | |||
| cb1b74ed7b | |||
| e25e5d9768 | |||
| 9f3766952f | |||
| cb4471b07f | |||
| 9fa7eac41f | |||
| 94fa985550 | |||
| 1c498ead35 | |||
| 5abc983172 | |||
| 7a0d4919b0 | |||
| d5e9183877 | |||
| 9b39a51e9f | |||
| bec7eabd1c | |||
| cd3791087f |
@@ -1,6 +1,7 @@
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1.0
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install libicu-dev
|
||||
@@ -7,7 +7,7 @@ gollum -- A wiki built on top of Git
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Gollum is a simple wiki system built on top of Git that powers GitHub Wikis.
|
||||
Gollum is a simple wiki system built on top of Git.
|
||||
|
||||
Gollum wikis are simply Git repositories that adhere to a specific format.
|
||||
Gollum pages may be written in a variety of formats and can be edited in a
|
||||
@@ -23,7 +23,7 @@ Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
|
||||
## SYSTEM REQUIREMENTS
|
||||
|
||||
- Python 2.5+ (2.7.3 recommended)
|
||||
- Ruby 1.8.7+ (1.9.3 recommended)
|
||||
- Ruby 1.9.3+ (1.9.3 recommended)
|
||||
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
||||
- Will not work on Windows (because of [grit](https://github.com/github/grit))
|
||||
|
||||
@@ -91,6 +91,32 @@ utility, you can run it like so:
|
||||
$ gollum --help
|
||||
```
|
||||
|
||||
This will show you the options you can pass as arguments to the `gollum` command:
|
||||
|
||||
```bash
|
||||
Options:
|
||||
--port [PORT] Bind port (default 4567).
|
||||
--host [HOST] Hostname or IP address to listen on (default 0.0.0.0).
|
||||
--version Display current version.
|
||||
--config [CONFIG] Path to additional configuration file
|
||||
--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.
|
||||
--gollum-path [PATH] Specify the gollum path.
|
||||
--ref [REF] Specify the repository ref to use (default: master).
|
||||
--no-live-preview Disables livepreview.
|
||||
--live-preview Enables livepreview.
|
||||
--allow-uploads Allows file uploads.
|
||||
--mathjax Enables mathjax.
|
||||
--user-icons [SOURCE] Set the history user icons. Valid values: gravatar, identicon, none. Default: none.
|
||||
--show-all Shows all files in file view. By default only valid pages are shown.
|
||||
--collapse-tree Collapse file view tree. By default, expanded tree is shown.
|
||||
--h1-title Sets page title to value of first h1
|
||||
```
|
||||
|
||||
Note that the gollum server will not run on Windows because of [an issue](https://github.com/rtomayko/posix-spawn/issues/9) with posix-spawn (which is used by Grit).
|
||||
|
||||
### RACK
|
||||
|
||||
+7
-1
@@ -56,6 +56,10 @@ opts = OptionParser.new do |opts|
|
||||
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
|
||||
@@ -80,8 +84,9 @@ opts = OptionParser.new do |opts|
|
||||
wiki_options[:live_preview] = true
|
||||
end
|
||||
|
||||
opts.on("--allow-uploads", "Allows file uploads.") 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[:allow_uploads] = true
|
||||
wiki_options[:per_page_uploads] = true if mode == :page
|
||||
end
|
||||
|
||||
opts.on("--mathjax", "Enables mathjax.") do
|
||||
@@ -168,6 +173,7 @@ else
|
||||
require 'gollum/app'
|
||||
Precious::App.set(:gollum_path, gollum_path)
|
||||
Precious::App.set(:wiki_options, wiki_options)
|
||||
Precious::App.settings.mustache[:templates] = wiki_options[:template_dir] if wiki_options[:template_dir]
|
||||
|
||||
if cfg = options['config']
|
||||
# If the path begins with a '/' it will be considered an absolute path,
|
||||
|
||||
+19
-18
@@ -2,31 +2,32 @@ Sanitization Rules
|
||||
==================
|
||||
|
||||
Gollum uses the [Sanitize](http://wonko.com/post/sanitize) gem for HTML
|
||||
sanitization.
|
||||
sanitization. Below you find the default allowed tags, attributes, and protocols, as well as directions to customize these settings.
|
||||
|
||||
See `lib/gollum.rb` for actual 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
|
||||
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
|
||||
|
||||
abbr, accept, accept-charset, accesskey, action, align, alt, axis, border,
|
||||
cellpadding, cellspacing, char, charoff, charset, checked, cite, class, clear,
|
||||
cols, colspan, color, compact, coords, datetime, dir, disabled, enctype, for,
|
||||
frame, headers, height, href, hreflang, hspace, id, ismap, label, lang,
|
||||
longdesc, maxlength, media, method, multiple, name, nohref, noshade, nowrap,
|
||||
prompt, readonly, rel, rev, rows, rowspan, rules, scope, selected, shape,
|
||||
size, span, src, start, summary, tabindex, target, title, type, usemap,
|
||||
valign, value, vspace, width
|
||||
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
|
||||
img src: http, https
|
||||
* 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})
|
||||
```
|
||||
|
||||
+6
-5
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
||||
s.required_ruby_version = ">= 1.9"
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '2.5.2'
|
||||
s.date = '2013-11-02'
|
||||
s.version = '2.7.0'
|
||||
s.date = '2014-02-20'
|
||||
s.rubyforge_project = 'gollum'
|
||||
s.license = 'MIT'
|
||||
|
||||
@@ -24,14 +24,14 @@ Gem::Specification.new do |s|
|
||||
s.rdoc_options = ["--charset=UTF-8"]
|
||||
s.extra_rdoc_files = %w[README.md LICENSE]
|
||||
|
||||
s.add_dependency 'gollum-lib', '~> 1.0.9'
|
||||
s.add_dependency 'gollum-lib', '~> 2.0'
|
||||
s.add_dependency 'github-markdown', '~> 0.5.5'
|
||||
s.add_dependency 'sinatra', '~> 1.4.3'
|
||||
s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.3'
|
||||
s.add_dependency 'mustache', ['>= 0.99.4', '< 1.0.0']
|
||||
s.add_dependency 'useragent', '~> 0.8.2'
|
||||
|
||||
s.add_development_dependency 'rack-test', '~> 0.6.2'
|
||||
s.add_development_dependency 'shoulda', ['>= 3.4.0', '< 3.5.0']
|
||||
s.add_development_dependency 'shoulda', '~> 3.4.0'
|
||||
s.add_development_dependency 'minitest-reporters', '~> 0.14.16'
|
||||
|
||||
# = MANIFEST =
|
||||
@@ -53,6 +53,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/public/gollum/css/editor.css
|
||||
lib/gollum/public/gollum/css/gollum.css
|
||||
lib/gollum/public/gollum/css/ie7.css
|
||||
lib/gollum/public/gollum/css/print.css
|
||||
lib/gollum/public/gollum/css/template.css
|
||||
lib/gollum/public/gollum/images/dirty-shade.png
|
||||
lib/gollum/public/gollum/images/fileview/document.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 = '2.5.2'
|
||||
VERSION = '2.7.0'
|
||||
|
||||
def self.assets_path
|
||||
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
||||
|
||||
+24
-11
@@ -163,7 +163,7 @@ module Precious
|
||||
tempfile = params[:file][:tempfile]
|
||||
end
|
||||
|
||||
dir = 'uploads'
|
||||
dir = wiki.per_page_uploads ? params[:upload_dest] : 'uploads'
|
||||
ext = ::File.extname(fullname)
|
||||
format = ext.split('.').last || 'txt'
|
||||
filename = ::File.basename(fullname, ext)
|
||||
@@ -173,7 +173,7 @@ module Precious
|
||||
head = wiki.repo.head
|
||||
|
||||
options = {
|
||||
:message => "Uploaded file to uploads/#{reponame}",
|
||||
:message => "Uploaded file to #{dir}/#{reponame}",
|
||||
:parent => wiki.repo.head.commit,
|
||||
}
|
||||
author = session['gollum.author']
|
||||
@@ -189,7 +189,7 @@ module Precious
|
||||
committer.update_working_dir(dir, filename, format)
|
||||
end
|
||||
committer.commit
|
||||
redirect to('/')
|
||||
redirect to(request.referer)
|
||||
rescue Gollum::DuplicatePageError => e
|
||||
@message = "Duplicate page: #{e.message}"
|
||||
mustache :error
|
||||
@@ -255,7 +255,9 @@ module Precious
|
||||
name = wikip.name
|
||||
wiki = wikip.wiki
|
||||
page = wikip.page
|
||||
wiki.delete_page(page, { :message => "Destroyed #{name} (#{page.format})" })
|
||||
unless page.nil?
|
||||
wiki.delete_page(page, { :message => "Destroyed #{name} (#{page.format})" })
|
||||
end
|
||||
|
||||
redirect to('/')
|
||||
end
|
||||
@@ -289,6 +291,8 @@ module Precious
|
||||
format = params[:format].intern
|
||||
wiki = wiki_new
|
||||
|
||||
path.gsub!(/^\//, '')
|
||||
|
||||
begin
|
||||
wiki.write_page(name, format, params[:content], commit_message, path)
|
||||
|
||||
@@ -300,15 +304,14 @@ module Precious
|
||||
end
|
||||
end
|
||||
|
||||
post '/revert/:page/*' do
|
||||
wikip = wiki_page(params[:page])
|
||||
post '/revert/*/:sha1/:sha2' do
|
||||
wikip = wiki_page(params[:splat].first)
|
||||
@path = wikip.path
|
||||
@name = wikip.name
|
||||
wiki = wikip.wiki
|
||||
@page = wiki.paged(@name,@path)
|
||||
shas = params[:splat].first.split("/")
|
||||
sha1 = shas.shift
|
||||
sha2 = shas.shift
|
||||
sha1 = params[:sha1]
|
||||
sha2 = params[:sha2]
|
||||
|
||||
commit = commit_message
|
||||
commit[:message] = "Revert commit #{sha1.chars.take(7).join}"
|
||||
@@ -340,8 +343,12 @@ module Precious
|
||||
get '/history/*' do
|
||||
@page = wiki_page(params[:splat].first).page
|
||||
@page_num = [params[:page].to_i, 1].max
|
||||
@versions = @page.versions :page => @page_num
|
||||
mustache :history
|
||||
unless @page.nil?
|
||||
@versions = @page.versions :page => @page_num
|
||||
mustache :history
|
||||
else
|
||||
redirect to("/")
|
||||
end
|
||||
end
|
||||
|
||||
post '/compare/*' do
|
||||
@@ -387,6 +394,7 @@ module Precious
|
||||
@page = page
|
||||
@name = name
|
||||
@content = page.formatted_data
|
||||
@version = version
|
||||
mustache :page
|
||||
else
|
||||
halt 404
|
||||
@@ -445,9 +453,14 @@ module Precious
|
||||
@page = page
|
||||
@name = name
|
||||
@content = page.formatted_data
|
||||
@upload_dest = settings.wiki_options[:allow_uploads] ?
|
||||
(settings.wiki_options[:per_page_uploads] ?
|
||||
"#{path}/#{@name}".sub(/^\/\//, '') : 'uploads'
|
||||
) : ''
|
||||
|
||||
# Extensions and layout data
|
||||
@editable = true
|
||||
@page_exists = !page.versions.empty?
|
||||
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
||||
@mathjax = wiki.mathjax
|
||||
@h1_title = wiki.h1_title
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
/*
|
||||
print.css
|
||||
Removes the action buttons at the top and
|
||||
the delete link at the bottom for better printing.
|
||||
*/
|
||||
|
||||
ul.actions {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#delete-link {
|
||||
display: none;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ a.absent {
|
||||
.markdown-body table tr th,
|
||||
.markdown-body table tr td {
|
||||
border: 1px solid #ccc;
|
||||
text-align: left;
|
||||
text-align: none;
|
||||
margin: 0;
|
||||
padding: 6px 13px;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,8 @@
|
||||
|
||||
html += '<form method=post enctype="multipart/form-data" ' +
|
||||
'action="' + action + '" ' + 'id="' + id + '">';
|
||||
html += '<input type="hidden" name="upload_dest" value="' +
|
||||
uploadDest + '">';
|
||||
html += '<input type=file name="' + name + '">';
|
||||
html += '</form>';
|
||||
|
||||
@@ -179,6 +181,7 @@
|
||||
duration: 200,
|
||||
complete: function() {
|
||||
$('#gollum-dialog-dialog').removeClass('active');
|
||||
$('#gollum-dialog-dialog').css('display', 'none');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -155,7 +155,8 @@ $(document).ready(function() {
|
||||
fields: [
|
||||
{
|
||||
type: 'file',
|
||||
context: 'Your uploaded file will be accessible at /uploads/[filename]'
|
||||
context: 'Your uploaded file will be accessible at<br>/'+uploadDest+'/[filename]',
|
||||
action: baseUrl + '/uploadFile'
|
||||
}
|
||||
],
|
||||
OK: function( res ) {
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/editor.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/print.css" media="print">
|
||||
{{#css}}<link rel="stylesheet" type="text/css" href="{{base_url}}/custom.css" media="all">{{/css}}
|
||||
{{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
|
||||
|
||||
<!--[if IE 7]>
|
||||
<link rel="stylesheet" type="text/css" href="{{base_url}}/css/ie7.css" media="all">
|
||||
@@ -16,6 +18,7 @@
|
||||
var baseUrl = '{{base_url}}';
|
||||
{{#page}}
|
||||
var pageFullPath = '{{url_path_display}}';
|
||||
var uploadDest = '{{upload_dest}}';
|
||||
{{/page}}
|
||||
</script>
|
||||
<script type="text/javascript" src="{{base_url}}/javascript/jquery-1.7.2.min.js"></script>
|
||||
|
||||
@@ -30,8 +30,11 @@ Mousetrap.bind(['e'], function( e ) {
|
||||
<li class="minibutton"><a href="{{base_url}}/edit/{{escaped_url_path}}"
|
||||
class="action-edit-page">Edit</a></li>
|
||||
{{/editable}}
|
||||
{{#page_exists}}
|
||||
<li class="minibutton jaws">
|
||||
<li class="minibutton"><a href="{{base_url}}/history/{{escaped_url_path}}"
|
||||
class="action-page-history">History</a></li>
|
||||
{{/page_exists}}
|
||||
</ul>
|
||||
</div>
|
||||
<div id="wiki-content">
|
||||
|
||||
@@ -35,13 +35,25 @@ module Precious
|
||||
first.authored_date.strftime(DATE_FORMAT)
|
||||
end
|
||||
|
||||
def noindex
|
||||
@version ? true : false
|
||||
end
|
||||
|
||||
def editable
|
||||
@editable
|
||||
end
|
||||
|
||||
def page_exists
|
||||
@page_exists
|
||||
end
|
||||
|
||||
def allow_uploads
|
||||
@allow_uploads
|
||||
end
|
||||
|
||||
def upload_dest
|
||||
@upload_dest
|
||||
end
|
||||
|
||||
def has_header
|
||||
@header = (@page.header || false) if @header.nil?
|
||||
|
||||
+14
-1
@@ -429,7 +429,7 @@ context "Frontend" do
|
||||
assert_equal "INITIAL", page2.raw_data.strip
|
||||
end
|
||||
=end
|
||||
|
||||
=begin
|
||||
test "cannot revert conflicting commit" do
|
||||
page1 = @wiki.page('A')
|
||||
|
||||
@@ -440,6 +440,7 @@ context "Frontend" do
|
||||
page2 = @wiki.page('A')
|
||||
assert_equal page1.version.sha, page2.version.sha
|
||||
end
|
||||
=end
|
||||
=begin
|
||||
# redirects are now handled by class MapGollum in bin/gollum
|
||||
# they should be set in config.ru
|
||||
@@ -522,6 +523,18 @@ context "Frontend" do
|
||||
assert_match /スイカ/, last_response.body
|
||||
end
|
||||
|
||||
test "add noindex tags to history pages" do
|
||||
get "A"
|
||||
|
||||
assert last_response.ok?
|
||||
assert_no_match /meta name="robots" content="noindex, nofollow"/, last_response.body
|
||||
|
||||
get "A/fc66539528eb96f21b2bbdbf557788fe8a1196ac"
|
||||
|
||||
assert last_response.ok?
|
||||
assert_match /meta name="robots" content="noindex, nofollow"/, last_response.body
|
||||
end
|
||||
|
||||
def app
|
||||
Precious::App
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user