Compare commits

...

80 Commits

Author SHA1 Message Date
Daniel Kimsey 25d30aee64 Release 2.7.0 2014-02-20 11:10:00 -05:00
Daniel Kimsey 8af92da23c Update version of gollum-lib to 2.0.0 2014-02-20 11:07:59 -05:00
Sunny Ripert 324ff0a17c Merge pull request #802 from ExocTBlid/master
Printing CSS
2014-02-04 14:05:15 -08:00
Blomquist, Ethan cfb372e5e2 Another minor update... 2014-02-03 10:53:37 -07:00
Blomquist, Ethan 6513c732ba Minor update to the delete link for printing. 2014-02-03 10:50:13 -07:00
Blomquist, Ethan c4ea869223 Added print.css to remove action buttons and delete link for better print format. 2014-02-03 10:45:06 -07:00
Dawa Ometto 5387267675 Merge pull request #800 from budziq/delete_crash
Fixes crash if "delete page" was selected in preview of page that being created
2014-02-01 10:01:57 -08:00
Dawa Ometto 8e4c3cc562 Merge pull request #801 from budziq/history_crash_clean
fixes crash when selected "history" in preview of page being created
2014-02-01 09:58:42 -08:00
Michał Budzyński 8b6b0699e5 fixes crash when selected "history" in preview of page being created
- history button is hidden in newly created page preview as it makes no sense
- redirect to '/' if page does not exist yet
2014-01-31 02:43:03 +01:00
Michał Budzyński 229bff1658 Fixes crash if "delete page" was selected in preview of page that being created 2014-01-31 02:10:15 +01:00
Jamie Oliver 7a59d37350 Merge pull request #794 from github/ungithub-upstream
Status of GitHub Wikis
2014-01-28 11:12:20 -08:00
Dawa Ometto d06b1e7883 Merge pull request #787 from akretion/fix-upload-path
fixes bug #786 per_page_uploads: incorrect file path if page is inside some directory
2014-01-25 02:12:55 -08:00
Akretion BOT c8a284db9d fixes bug #786 per_page_uploads: incorrect file path if page is inside some directory 2014-01-25 04:53:19 +01:00
Dawa Ometto c7d6aceff4 Update sanitization.md 2014-01-23 19:33:25 +01:00
Dawa Ometto 7ea45d5e89 Update sanitization.md
Document customization of sanitation settings; see https://github.com/gollum/gollum/issues/759
2014-01-23 19:29:20 +01:00
Brandon Keepers 48c4aafb15 Remove reference to GitHub in readme
:(
2014-01-21 09:40:41 -08:00
Bart Kamphorst ff302ed842 Fixes alignment of tables (issue #700).
Fixes https://github.com/gollum/gollum/issues/700 .
2014-01-21 16:55:05 +01:00
Dawa Ometto 20a2424b83 Merge pull request #793 from repotag/flag_for_per_page_uploads
Add optional 'mode' argument to --allow-uploads flag, allowing user to toggle per_page_uploads.
2014-01-21 03:34:43 -08:00
Dawa Ometto de0f34a27a Add optional 'mode' argument to --allow-uploads flag, allowing user to toggle per_page_uploads. 2014-01-21 12:14:47 +01:00
Sunny Ripert d0992cce3f Merge pull request #790 from akretion/better-redirect-after-upload
fixes #788 better redirect after file upload
2014-01-20 03:13:13 -08:00
Akretion BOT 15feeb3614 fixes #788 better redirect after file upload 2014-01-19 23:24:01 +01:00
Jamie Oliver fc0a879e52 Support Ruby 2.1.0. Closes #784 2014-01-11 14:42:35 +00:00
Daniel Kimsey 9b675146a2 Merge pull request #782 from Joe8Bit/master
Update README.md to show options
2014-01-10 07:26:25 -08:00
Joe Pettersson 4d0bdcc8c0 Update README.md to show options 2014-01-10 13:47:15 +00:00
bootstraponline 0abdb67687 Merge pull request #781 from anchor/per-page-uploads
Implement the ability to store uploads on a per-page basis
2014-01-04 19:11:07 -08:00
Matt Palmer d1fb98cf1b Merge remote-tracking branch 'upstream/master' into per-page-uploads
Conflicts:
	lib/gollum/public/gollum/javascript/gollum.js
2014-01-03 17:49:53 +11:00
Matt Palmer 5eac24eacb Implement the ability to store uploads on a per-page basis
Storing all uploaded files in a single directory kinda sucks when you've got
a largish wiki, or the possibility of filename collisions.  With this patch,
though, you can set `:per_page_uploads => true` in your wiki settings and
have the file uploaded to a directory named for the page you were on when
you clicked 'Upload'.
2014-01-03 15:34:24 +11:00
bootstraponline 3fd16daeca Release 2.6.0 2014-01-02 23:32:41 -05:00
bootstraponline d9b38c3b73 Use baseUrl for /uploadFile
Thanks @mpalmer
https://github.com/gollum/gollum/pull/780
2014-01-02 23:03:33 -05:00
bootstraponline 0a5176c1ee Merge pull request #780 from peterkeen/upload-base-path
Base upload button action on home page url
2014-01-02 19:50:35 -08:00
Pete Keen b836b0e273 Base upload button action on home page url 2014-01-01 17:05:32 -05:00
bootstraponline 9a41e2a65d Merge pull request #772 from zorun/master
Prevent indexing of old versions of a page (fixes #768)
2014-01-01 09:05:07 -08:00
bootstraponline cb1b74ed7b Merge pull request #776 from eucher/first_slash_in_create
First slash in create
2014-01-01 09:02:58 -08:00
bootstraponline e25e5d9768 Merge pull request #779 from anchor/semantic-versioning
Fix version specifiers
2014-01-01 09:02:14 -08:00
Matt Palmer 9f3766952f Fix version specifiers
Adjusted the version specs on the two gems that explicitly state they are
SemVer compliant, and fixed up the one dependency that correctly *could* have
used ~> but didn't.
2013-12-31 15:18:15 +11:00
bootstraponline cb4471b07f Merge pull request #778 from jhogendorn/baddialog
Fixes dialog hiding so it doesnt block the UI
2013-12-08 08:55:28 -08:00
Joshua Hogendorn 9fa7eac41f Fixes dialog hiding so it doesnt block the UI 2013-12-08 20:15:59 +10:00
zorun 94fa985550 Add a test for issue #772 2013-12-06 02:46:15 +01:00
Evgeni Cherdancev 1c498ead35 gsub before begin 2013-11-28 12:32:08 +07:00
Evgeni Cherdancev 5abc983172 write_page first slash fix 2013-11-28 12:26:06 +07:00
zorun 7a0d4919b0 Prevent indexing of old versions of a page (fixes #768) 2013-11-22 12:49:42 +01:00
bootstraponline d5e9183877 Merge pull request #762 from pdenes/add_template_dir_option
add option to specify custom template directory
2013-11-11 14:25:27 -08:00
bootstraponline 9b39a51e9f Merge pull request #758 from samer/master
Fix revert for pages in directories
2013-11-11 14:25:10 -08:00
pdenes bec7eabd1c add option to specify custom template directory 2013-11-06 21:46:54 +00:00
Samer N cd3791087f Fix revert for pages in directories, as seen in issue #736 2013-11-04 13:03:31 +02:00
Jamie Oliver 714985e377 Release 2.5.2 2013-11-02 11:31:21 +00:00
Jamie Oliver 76c37dce96 Upgrade gollum-lib 2013-11-02 11:21:39 +00:00
bootstraponline 5a9af40058 Release 2.5.1 2013-10-15 07:20:13 -04:00
bootstraponline e871ff35b7 Merge pull request #753 from bootstraponline/master
Update gemspec
2013-10-15 04:19:41 -07:00
bootstraponline ecc6c32933 Update gemspec 2013-10-15 07:11:36 -04:00
bootstraponline 831cf61a08 Merge pull request #747 from invenia/master
Created OpenRC init script.
2013-10-12 12:18:22 -07:00
Curtis Vogt cc1231dece Added MIT license to init script header. 2013-09-30 13:52:34 +00:00
bootstraponline bb3d1a165b Merge pull request #751 from 1gor/patch-1
Added dependency 'github-markdown'
2013-09-29 09:29:23 -07:00
1gor 3da0426c54 Added dependency 'github-markdown' 2013-09-29 10:49:11 +06:00
Curtis Vogt e01aa25be3 Added basic logging to OpenRC script. 2013-09-27 17:02:16 +00:00
Abhijit Menon-Sen ee2f9d8dcb Merge pull request #748 from singlebrook/upload_instructions
Add some instructions to upload dialog
2013-09-27 07:30:40 -07:00
Leon Miller-Out 4d8677965c Add instructions for how to access file post-upload 2013-09-27 10:16:35 -04:00
Leon Miller-Out 72729d5510 Whitespace 2013-09-27 10:16:35 -04:00
Curtis Vogt 0b57e70c87 Removed explictly set license in OpenRC init script. 2013-09-27 14:09:00 +00:00
Curtis Vogt 033d6489f8 Created OpenRC init script. 2013-09-26 16:28:19 +00:00
Abhijit Menon-Sen 8608007337 Merge pull request #743 from singlebrook/upload_action_path
Use correct path for uploadFile action even when current page is in a folder.
2013-09-17 21:32:33 -07:00
Leon Miller-Out 665e493570 Use correct path for uploadFile action even when looking at a page in a folder 2013-09-17 12:36:53 -04:00
bootstraponline eb1e2f60f3 Fix #740 2013-09-12 08:49:27 -04:00
bootstraponline dc637f0a9b Merge pull request #734 from repotag/no_grit
No grit
2013-08-11 08:07:33 -07:00
Dawa Ometto f81634728d Replaced grit calls to new calls in gollum-lib 1.06 (set_git_timeout and set_git_max_filsize). Removed grit dependency from tests, using cp of empty.git instead. Replaced Grit exceptions with equivalents in the Gollum module. 2013-08-11 13:19:43 +02:00
bootstraponline 440cd5ebc0 Merge pull request #735 from ngyuki/fix-edit-for-multibyte
Fix `Encoding::CompatibilityError` of edit view.
2013-08-10 11:27:14 -07:00
Jamie Oliver 1cd7d0f205 Use display path in rename dialog. Fixes #703 2013-08-10 11:41:15 +01:00
ngyuki a69d62911c Fix editing of the sidebar with multi-byte characters. 2013-08-09 14:45:19 +09:00
ngyuki 395e9bd006 Add test for editing the sidebar, including multi-byte characters. 2013-08-09 14:41:52 +09:00
Jamie Oliver 90e20810d5 Do not force downcase on URLs. Fixes #621 2013-08-04 18:27:32 +01:00
bootstraponline 9c714e7687 Release 2.5.0 2013-07-21 07:22:46 -04:00
bootstraponline 6c3523d61c Merge pull request #725 from amenonsen/upload
Add a file Upload button
2013-07-21 04:19:58 -07:00
Abhijit Menon-Sen 183840b793 Add file upload functionality
Adds an :allow_uploads wiki option, an --allow-uploads flag to
bin/gollum, an "Upload" button with a file upload dialog, and a
handler to commit uploaded files into the repository.

:allow_uploads defaults to false, to prevent unauthenticated users
from uploading arbitrary files into the repository (albeit only in
the uploads directory).

This code is based on the patch from @l3iggs at
https://github.com/gollum/gollum/issues/694, but the handling on the
backend is completely rewritten to use the Committer infrastructure.
2013-07-21 16:28:15 +05:30
bootstraponline 4e2856aa64 Update gollum-lib to 1.0.4 2013-07-20 19:24:26 -04:00
Abhijit Menon-Sen 4627a39165 Merge pull request #727 from amenonsen/no-live-preview
Disable live preview by default, because it's broken (closes #718)
2013-07-18 05:39:48 -07:00
bootstraponline c87cbe83d2 Fix #709
Require Ruby >= 1.9
2013-07-18 08:17:17 -04:00
bootstraponline f05282badf Drop 1.8.7 support on Travis (It's broken)
Don't email me on fail
2013-07-18 08:16:01 -04:00
Abhijit Menon-Sen 957879346e Merge pull request #726 from amenonsen/fixes
Trivial fix: set label.for to the input's id
2013-07-17 18:53:37 -07:00
Abhijit Menon-Sen 87e64f67f3 A tiny patch to disable live preview (#718) 2013-07-17 14:24:36 +05:30
Abhijit Menon-Sen 43840d246d Trivial fix: set label.for to the input's id 2013-07-17 13:31:46 +05:30
21 changed files with 341 additions and 72 deletions
+3 -4
View File
@@ -1,8 +1,7 @@
rvm:
- 1.8.7
- 1.9.3
notifications:
email:
- code@bootstraponline.com
- 2.0.0
- 2.1.0
before_install:
- sudo apt-get update
- sudo apt-get install libicu-dev
+28 -2
View File
@@ -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
+20 -3
View File
@@ -19,7 +19,10 @@ require 'gollum'
exec = {}
options = { 'port' => 4567, 'bind' => '0.0.0.0' }
wiki_options = {}
wiki_options = {
:live_preview => false,
:allow_uploads => false,
}
opts = OptionParser.new do |opts|
opts.banner = help
@@ -53,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
@@ -73,6 +80,15 @@ opts = OptionParser.new do |opts|
wiki_options[:live_preview] = false
end
opts.on("--live-preview", "Enables livepreview.") do
wiki_options[:live_preview] = true
end
opts.on("--allow-uploads [MODE]", [:dir, :page], "Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page).") do |mode|
wiki_options[:allow_uploads] = true
wiki_options[:per_page_uploads] = true if mode == :page
end
opts.on("--mathjax", "Enables mathjax.") do
wiki_options[:mathjax] = true
end
@@ -135,7 +151,7 @@ if options['irb']
begin
require 'gollum-lib'
wiki = Gollum::Wiki.new(gollum_path, wiki_options)
if !wiki.exist? then raise Grit::InvalidGitRepositoryError end
if !wiki.exist? then raise Gollum::InvalidGitRepositoryError end
puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}."
puts
puts %( page = wiki.page('page-name'))
@@ -149,7 +165,7 @@ if options['irb']
puts
puts "Check out the Gollum README for more."
IRB.start_session(binding)
rescue Grit::InvalidGitRepositoryError, Grit::NoSuchPathError
rescue Gollum::InvalidGitRepositoryError, Gollum::NoSuchPathError
puts "Invalid Gollum wiki at #{File.expand_path(gollum_path).inspect}"
exit 0
end
@@ -157,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
View File
@@ -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})
```
+11 -7
View File
@@ -2,11 +2,11 @@ Gem::Specification.new do |s|
s.specification_version = 2 if s.respond_to? :specification_version=
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.rubygems_version = '1.3.5'
s.required_ruby_version = ">= 1.8.7"
s.required_ruby_version = ">= 1.9"
s.name = 'gollum'
s.version = '2.4.15'
s.date = '2013-06-18'
s.version = '2.7.0'
s.date = '2014-02-20'
s.rubyforge_project = 'gollum'
s.license = 'MIT'
@@ -24,13 +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.3'
s.add_dependency 'sinatra', '~> 1.4.2'
s.add_dependency 'gollum-lib', '~> 2.0'
s.add_dependency 'github-markdown', '~> 0.5.5'
s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.3'
s.add_dependency 'mustache', ['>= 0.99.4', '< 1.0.0']
s.add_dependency 'useragent', '~> 0.6.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 =
@@ -52,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
@@ -529,6 +531,8 @@ Gem::Specification.new do |s|
licenses/css_tree_menu_thecssninja/license.txt
licenses/licenses.txt
licenses/unity_asset_pool/COPYRIGHT
openrc/conf.d/gollum
openrc/init.d/gollum
templates/formatting.html
templates/helper_wiki.rb
]
+1 -2
View File
@@ -5,7 +5,6 @@ require 'digest/sha1'
require 'ostruct'
# external
require 'grit'
require 'github/markup'
require 'sanitize'
@@ -17,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.4.15'
VERSION = '2.7.0'
def self.assets_path
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
+76 -11
View File
@@ -13,13 +13,17 @@ require 'gollum/views/has_page'
require File.expand_path '../helpers', __FILE__
#required to upload bigger binary files
Gollum::set_git_timeout(120)
Gollum::set_git_max_filesize(190 * 10**6)
# Fix to_url
class String
alias :upstream_to_url :to_url
# _Header => header which causes errors
def to_url
return nil if self.nil?
upstream_to_url :exclude => ['_Header', '_Footer', '_Sidebar']
upstream_to_url :exclude => ['_Header', '_Footer', '_Sidebar'], :force_downcase => false
end
end
@@ -137,8 +141,7 @@ module Precious
else
@page = page
@page.version = wiki.repo.log(wiki.ref, @page.path).first
raw_data = page.raw_data
@content = raw_data.respond_to?(:force_encoding) ? raw_data.force_encoding('UTF-8') : raw_data
@content = page.text_data
mustache :edit
end
else
@@ -146,6 +149,53 @@ module Precious
end
end
post '/uploadFile' do
wiki = wiki_new
unless wiki.allow_uploads
@message = "File uploads are disabled"
mustache :error
return
end
if params[:file]
fullname = params[:file][:filename]
tempfile = params[:file][:tempfile]
end
dir = wiki.per_page_uploads ? params[:upload_dest] : 'uploads'
ext = ::File.extname(fullname)
format = ext.split('.').last || 'txt'
filename = ::File.basename(fullname, ext)
contents = ::File.read(tempfile)
reponame = filename + '.' + format
head = wiki.repo.head
options = {
:message => "Uploaded file to #{dir}/#{reponame}",
:parent => wiki.repo.head.commit,
}
author = session['gollum.author']
unless author.nil?
options.merge! author
end
begin
committer = Gollum::Committer.new(wiki, options)
committer.add_to_index(dir, filename, format, contents)
committer.after_commit do |committer, sha|
wiki.clear_cache
committer.update_working_dir(dir, filename, format)
end
committer.commit
redirect to(request.referer)
rescue Gollum::DuplicatePageError => e
@message = "Duplicate page: #{e.message}"
mustache :error
end
end
post '/rename/*' do
wikip = wiki_page(params[:splat].first)
halt 500 if wikip.nil?
@@ -205,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
@@ -239,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)
@@ -250,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}"
@@ -283,14 +336,19 @@ module Precious
@mathjax = wiki.mathjax
@h1_title = wiki.h1_title
@editable = false
@allow_uploads = wiki.allow_uploads
mustache :page
end
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
@@ -336,6 +394,7 @@ module Precious
@page = page
@name = name
@content = page.formatted_data
@version = version
mustache :page
else
halt 404
@@ -394,13 +453,19 @@ 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
@bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads
mustache :page
elsif file = wiki.file(fullpath, wiki.ref, true)
+14
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
@@ -37,11 +37,14 @@
fieldMarkup += '<div class="field">';
switch ( fieldArray[i].type ) {
// only text is supported for now
case 'text':
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
break;
case 'file':
fieldMarkup += Dialog.createFieldFile( fieldArray[i] );
break;
default:
break;
@@ -60,7 +63,7 @@
if ( fieldAttributes.name ) {
html += '<label';
if ( fieldAttributes.id ) {
html += ' for="' + fieldAttributes.name + '"';
html += ' for="gollum-dialog-dialog-generated-field-' + fieldAttributes.id + '"';
}
html += '>' + fieldAttributes.name + '</label>';
}
@@ -86,6 +89,28 @@
return html;
},
createFieldFile: function( fieldAttributes ) {
// Not actually a field, but an embedded form.
var html = '';
var id = fieldAttributes.id || 'upload';
var name = fieldAttributes.name || 'file';
var action = fieldAttributes.action || '/uploadFile';
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>';
if( fieldAttributes.context ){
html += '<span class="context">' + fieldAttributes.context + '</span>';
}
return html;
},
createMarkup: function( title, body ) {
Dialog.markupCreated = true;
if ($.facebox) {
@@ -156,6 +181,7 @@
duration: 200,
complete: function() {
$('#gollum-dialog-dialog').removeClass('active');
$('#gollum-dialog-dialog').css('display', 'none');
}
});
}
+23 -2
View File
@@ -145,6 +145,27 @@ $(document).ready(function() {
}
}
if ($('#minibutton-upload-page').length) {
$('#minibutton-upload-page').parent().removeClass('jaws');
$('#minibutton-upload-page').click(function(e) {
e.preventDefault();
$.GollumDialog.init({
title: 'Upload File',
fields: [
{
type: 'file',
context: 'Your uploaded file will be accessible at<br>/'+uploadDest+'/[filename]',
action: baseUrl + '/uploadFile'
}
],
OK: function( res ) {
$('#upload').submit();
}
});
});
}
if ($('#minibutton-rename-page').length) {
$('#minibutton-rename-page').parent().removeClass('jaws');
$('#minibutton-rename-page').click(function(e) {
@@ -152,7 +173,7 @@ $(document).ready(function() {
var path = pagePath();
var oldName = pageName();
var context_blurb =
var context_blurb =
"Renamed page will be under " +
"<span class='path'>" + htmlEscape('/' + path) + "</span>" +
" unless an absolute path is given."
@@ -206,7 +227,7 @@ $(document).ready(function() {
// For consistency remove the trailing /
path = path.replace(/\/$/,'')
}
var context_blurb =
var context_blurb =
"Page will be created under " +
"<span class='path'>" + htmlEscape('/' + path) + "</span>" +
" unless an absolute path is given."
+4 -1
View File
@@ -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">
@@ -15,7 +17,8 @@
<script>
var baseUrl = '{{base_url}}';
{{#page}}
var pageFullPath = '{{url_path}}';
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>
+7
View File
@@ -20,14 +20,21 @@ Mousetrap.bind(['e'], function( e ) {
class="action-fileview">Files</a></li>
<li class="minibutton jaws">
<a href="#" id="minibutton-new-page">New</a></li>
{{#allow_uploads}}
<li class="minibutton jaws">
<a href="#" id="minibutton-upload-page">Upload</a></li>
{{/allow_uploads}}
{{#editable}}
<li class="minibutton jaws">
<a href="#" id="minibutton-rename-page">Rename</a></li>
<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">
+1 -1
View File
@@ -34,7 +34,7 @@
# component must be String
def encodeURIComponent(componentString)
URI::URIEncodeComponent(componentString)
::URI::URIEncodeComponent(componentString)
end
# define charCodeAt on String
+3 -3
View File
@@ -22,7 +22,7 @@ module Precious
def header
if @header.nil?
if page = @page.header
@header = page.raw_data
@header = page.text_data
else
@header = false
end
@@ -33,7 +33,7 @@ module Precious
def footer
if @footer.nil?
if page = @page.footer
@footer = page.raw_data
@footer = page.text_data
else
@footer = false
end
@@ -44,7 +44,7 @@ module Precious
def sidebar
if @sidebar.nil?
if page = @page.sidebar
@sidebar = page.raw_data
@sidebar = page.text_data
else
@sidebar = false
end
+16
View File
@@ -35,10 +35,26 @@ 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?
!!@header
+3
View File
@@ -0,0 +1,3 @@
GOLLUM_USER=gollum
GOLLUM_BASE=/home/gollum/wiki
GOLLUM_OPTS="--config /home/gollum/config.rb"
+36
View File
@@ -0,0 +1,36 @@
#!/sbin/runscript
# Distributed under the terms of the MIT License
NAME=gollum
PID=/var/run/${NAME}.pid
EXEC=/usr/local/bin/gollum
LOG=/var/log/gollum.log
depend() {
need net
}
start() {
# Change log file to be owned by GOLLUM_USER
touch "${LOG}"
chown "${GOLLUM_USER}" "${LOG}"
ebegin "Starting Gollum"
start-stop-daemon --start \
--name "${NAME}" \
--user "${GOLLUM_USER}" \
--pidfile "${PID}" \
--make-pidfile --background \
--stderr "${LOG}" \
--exec "${EXEC}" -- $GOLLUM_OPTS "$GOLLUM_BASE"
eend $?
}
stop() {
ebegin "Stopping Gollum"
start-stop-daemon --stop \
--name "${NAME}" \
--user "${GOLLUM_USER}" \
--pidfile "${PID}"
eend $?
}
+3 -2
View File
@@ -1,7 +1,8 @@
class WikiFactory
def self.create p
path = testpath "examples/test.git"
Grit::Repo.init_bare(@path)
examples = testpath "examples"
path = File.join(examples, "test.git")
FileUtils.cp_r File.join(examples, "empty.git"), path, :remove_destination => true
Gollum::Wiki.default_options = {:universal_toc => false}
cleanup = Proc.new { FileUtils.rm_r File.join(File.dirname(__FILE__), *%w[examples test.git]) }
Gollum::Wiki.new(@path), @path, cleanup
+40 -9
View File
@@ -29,13 +29,13 @@ context "Frontend" do
# spaces are converted to dashes in URLs
# and in file names saved to disk
# urls are not case sensitive
assert_equal 'title-space', 'Title Space'.to_url
assert_equal 'Title-Space', 'Title Space'.to_url
# ascii only file names prevent UTF8 issues
# when using git repos across operating systems
# as this test demonstrates, translation is not
# great
assert_equal 'm-plus-f', 'μ†ℱ'.to_url
assert_equal 'm-plus-F', 'μ†ℱ'.to_url
end
test "utf-8 kcode" do
@@ -253,7 +253,7 @@ context "Frontend" do
test "creates pages with escaped characters in title" do
post "/create", :content => 'abc', :page => 'Title with spaces',
:format => 'markdown', :message => 'foo'
assert_equal 'http://example.org/title-with-spaces', last_response.headers['Location']
assert_equal 'http://example.org/Title-with-spaces', last_response.headers['Location']
get "/Title-with-spaces"
assert_match /abc/, last_response.body
end
@@ -278,7 +278,7 @@ context "Frontend" do
post "/create", :content => 'abc', :page => 'Home', :path => '/foo/',
:format => 'markdown', :message => 'foo'
assert_equal "http://example.org/foo/home", last_response.headers['Location']
assert_equal "http://example.org/foo/Home", last_response.headers['Location']
follow_redirect!
assert last_response.ok?
@@ -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
@@ -504,6 +505,36 @@ context "Frontend" do
Precious::App.set(:wiki_options, { :js => nil })
end
test "show edit page with header and footer and sidebar of multibyte" do
post "/create",
:content => 'りんご',
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
post "/edit/Multibyte",
:content => 'りんご', :header => 'みかん', :footer => 'バナナ', :sidebar => 'スイカ',
:page => 'Multibyte', :format => :markdown, :message => 'mesg'
get "edit/Multibyte"
assert last_response.ok?
assert_match /りんご/, last_response.body
assert_match /みかん/, last_response.body
assert_match /バナナ/, last_response.body
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
@@ -612,13 +643,13 @@ context "Frontend with lotr" do
test "create pages within sub-directories" do
post "/create", :content => 'big smelly creatures', :page => 'Orc',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
get "/Mordor/Orc"
assert_match /big smelly creatures/, last_response.body
post "/create", :content => 'really big smelly creatures', :page => 'Uruk Hai',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, very scary'
assert_equal 'http://example.org/Mordor/uruk-hai', last_response.headers['Location']
assert_equal 'http://example.org/Mordor/Uruk-Hai', last_response.headers['Location']
get "/Mordor/Uruk-Hai"
assert_match /really big smelly creatures/, last_response.body
end
@@ -627,11 +658,11 @@ context "Frontend with lotr" do
post "/create", :content => 'big smelly creatures', :page => 'Orc',
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
:page => 'Orc', :path => 'Mordor', :message => 'minor edit'
assert_equal 'http://example.org/Mordor/orc', last_response.headers['Location']
assert_equal 'http://example.org/Mordor/Orc', last_response.headers['Location']
get "/Mordor/Orc"
assert_match /not so big smelly creatures/, last_response.body
+4 -4
View File
@@ -4,9 +4,9 @@ require File.expand_path '../../lib/gollum/views/page', __FILE__
context "Precious::Views::Page" do
setup do
@path = testpath("examples/test.git")
FileUtils.rm_rf(@path)
@repo = Grit::Repo.init_bare(@path)
examples = testpath "examples"
@path = File.join(examples, "test.git")
FileUtils.cp_r File.join(examples, "empty.git"), @path, :remove_destination => true
@wiki = Gollum::Wiki.new(@path)
end
@@ -43,4 +43,4 @@ context "Precious::Views::Page" do
actual = @view.title
assert_equal 'H1', title
end
end
end