Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 46cf9107e2 | |||
| 87aec65d37 | |||
| be72bcf353 |
@@ -1,6 +0,0 @@
|
|||||||
rvm:
|
|
||||||
- 1.8.7
|
|
||||||
- 1.9.2
|
|
||||||
- rbx-2.0
|
|
||||||
notifications:
|
|
||||||
disabled: true
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
source "http://rubygems.org"
|
source "http://rubygems.org"
|
||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
gem "rake", "~> 0.9.2"
|
|
||||||
|
|||||||
+1
-31
@@ -1,34 +1,4 @@
|
|||||||
# 1.3.1 / 2011-07-21
|
# HEAD
|
||||||
|
|
||||||
* Major Enhancements
|
|
||||||
* Allow prefixed ID attributes in headers to support internal linking
|
|
||||||
(#146).
|
|
||||||
* Markdown pages are rendered through Redcarpet by default (#176).
|
|
||||||
* Minor Enhancements
|
|
||||||
* Remove Edit button on Preview pages (#164).
|
|
||||||
* Simplify Wiki#inspect and Page#inspect.
|
|
||||||
* Bug Fixes
|
|
||||||
* Fixed broken preview functionality (#157).
|
|
||||||
* Fixed sidebar/footer rendering problems related to whitespace (#145).
|
|
||||||
|
|
||||||
# 1.3.0 / 2011-04-25
|
|
||||||
|
|
||||||
* Major Enhancements
|
|
||||||
* Listing of all Pages
|
|
||||||
* Support for running Gollum under a separate branch.
|
|
||||||
* Minor Enhancements
|
|
||||||
* Fix a security issue with rendering Mathjax.
|
|
||||||
|
|
||||||
# 1.2.0 / 2011-03-11
|
|
||||||
|
|
||||||
* Major Enhancements
|
|
||||||
* Major HTML/CSS/JS overhaul.
|
|
||||||
* Add Sidebars (similar to Footers).
|
|
||||||
* Add commit reverts.
|
|
||||||
* Minor Enhancements
|
|
||||||
* Optimization in source code highlighting, resulting in a huge
|
|
||||||
decrease in rendering time.
|
|
||||||
* Security fixes related to source code highlighting.
|
|
||||||
|
|
||||||
* Major Enhancements
|
* Major Enhancements
|
||||||
* Add Page sidebars, similar to Page footers.
|
* Add Page sidebars, similar to Page footers.
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ and `\]`. For example:
|
|||||||
Inline equations are delimited by `\(` and `\)`. These equations will appear
|
Inline equations are delimited by `\(` and `\)`. These equations will appear
|
||||||
inline with regular text. For example:
|
inline with regular text. For example:
|
||||||
|
|
||||||
The Pythagorean theorem is \( a^2 + b^2 = c^2 \).
|
The Pythagorean theorum is \( a^2 + b^2 = c^2 \).
|
||||||
|
|
||||||
Gollum uses [MathJax](http://www.mathjax.org/) to convert the TeX syntax into
|
Gollum uses [MathJax](http://www.mathjax.org/) to convert the TeX syntax into
|
||||||
output suitable for display in web browsers.
|
output suitable for display in web browsers.
|
||||||
|
|||||||
@@ -48,10 +48,6 @@ opts = OptionParser.new do |opts|
|
|||||||
opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
|
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
|
wiki_options[:page_file_dir] = path
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("--ref [REF]", "Specify the repository ref to use (default: master).") do |ref|
|
|
||||||
wiki_options[:ref] = ref
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Read command line options into `options` hash
|
# Read command line options into `options` hash
|
||||||
|
|||||||
+3
-6
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|||||||
s.rubygems_version = '1.3.5'
|
s.rubygems_version = '1.3.5'
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '1.3.1'
|
s.version = '1.2.1'
|
||||||
s.date = '2011-07-21'
|
s.date = '2011-04-25'
|
||||||
s.rubyforge_project = 'gollum'
|
s.rubyforge_project = 'gollum'
|
||||||
|
|
||||||
s.summary = "A simple, Git-powered wiki."
|
s.summary = "A simple, Git-powered wiki."
|
||||||
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|||||||
s.require_paths = %w[lib]
|
s.require_paths = %w[lib]
|
||||||
|
|
||||||
s.executables = ["gollum"]
|
s.executables = ["gollum"]
|
||||||
|
s.default_executable = 'gollum'
|
||||||
|
|
||||||
s.rdoc_options = ["--charset=UTF-8"]
|
s.rdoc_options = ["--charset=UTF-8"]
|
||||||
s.extra_rdoc_files = %w[README.md LICENSE]
|
s.extra_rdoc_files = %w[README.md LICENSE]
|
||||||
@@ -29,7 +30,6 @@ Gem::Specification.new do |s|
|
|||||||
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
|
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
|
||||||
s.add_dependency('sanitize', "~> 2.0.0")
|
s.add_dependency('sanitize', "~> 2.0.0")
|
||||||
s.add_dependency('nokogiri', "~> 1.4")
|
s.add_dependency('nokogiri', "~> 1.4")
|
||||||
s.add_dependency('redcarpet')
|
|
||||||
|
|
||||||
s.add_development_dependency('RedCloth')
|
s.add_development_dependency('RedCloth')
|
||||||
s.add_development_dependency('mocha')
|
s.add_development_dependency('mocha')
|
||||||
@@ -38,7 +38,6 @@ Gem::Specification.new do |s|
|
|||||||
s.add_development_dependency('shoulda')
|
s.add_development_dependency('shoulda')
|
||||||
s.add_development_dependency('rack-test')
|
s.add_development_dependency('rack-test')
|
||||||
s.add_development_dependency('wikicloth')
|
s.add_development_dependency('wikicloth')
|
||||||
s.add_development_dependency('rake', '~> 0.9.2')
|
|
||||||
|
|
||||||
# = MANIFEST =
|
# = MANIFEST =
|
||||||
s.files = %w[
|
s.files = %w[
|
||||||
@@ -698,7 +697,6 @@ Gem::Specification.new do |s|
|
|||||||
lib/gollum/frontend/templates/history.mustache
|
lib/gollum/frontend/templates/history.mustache
|
||||||
lib/gollum/frontend/templates/layout.mustache
|
lib/gollum/frontend/templates/layout.mustache
|
||||||
lib/gollum/frontend/templates/page.mustache
|
lib/gollum/frontend/templates/page.mustache
|
||||||
lib/gollum/frontend/templates/pages.mustache
|
|
||||||
lib/gollum/frontend/templates/search.mustache
|
lib/gollum/frontend/templates/search.mustache
|
||||||
lib/gollum/frontend/templates/searchbar.mustache
|
lib/gollum/frontend/templates/searchbar.mustache
|
||||||
lib/gollum/frontend/views/compare.rb
|
lib/gollum/frontend/views/compare.rb
|
||||||
@@ -709,7 +707,6 @@ Gem::Specification.new do |s|
|
|||||||
lib/gollum/frontend/views/history.rb
|
lib/gollum/frontend/views/history.rb
|
||||||
lib/gollum/frontend/views/layout.rb
|
lib/gollum/frontend/views/layout.rb
|
||||||
lib/gollum/frontend/views/page.rb
|
lib/gollum/frontend/views/page.rb
|
||||||
lib/gollum/frontend/views/pages.rb
|
|
||||||
lib/gollum/frontend/views/search.rb
|
lib/gollum/frontend/views/search.rb
|
||||||
lib/gollum/git_access.rb
|
lib/gollum/git_access.rb
|
||||||
lib/gollum/markup.rb
|
lib/gollum/markup.rb
|
||||||
|
|||||||
+11
-11
@@ -8,19 +8,19 @@ require 'github/markup'
|
|||||||
require 'sanitize'
|
require 'sanitize'
|
||||||
|
|
||||||
# internal
|
# internal
|
||||||
require File.expand_path('../gollum/git_access', __FILE__)
|
require 'gollum/git_access'
|
||||||
require File.expand_path('../gollum/committer', __FILE__)
|
require 'gollum/committer'
|
||||||
require File.expand_path('../gollum/pagination', __FILE__)
|
require 'gollum/pagination'
|
||||||
require File.expand_path('../gollum/blob_entry', __FILE__)
|
require 'gollum/blob_entry'
|
||||||
require File.expand_path('../gollum/wiki', __FILE__)
|
require 'gollum/wiki'
|
||||||
require File.expand_path('../gollum/page', __FILE__)
|
require 'gollum/page'
|
||||||
require File.expand_path('../gollum/file', __FILE__)
|
require 'gollum/file'
|
||||||
require File.expand_path('../gollum/markup', __FILE__)
|
require 'gollum/markup'
|
||||||
require File.expand_path('../gollum/albino', __FILE__)
|
require 'gollum/albino'
|
||||||
require File.expand_path('../gollum/sanitization', __FILE__)
|
require 'gollum/sanitization'
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '1.3.1'
|
VERSION = '1.2.1'
|
||||||
|
|
||||||
class Error < StandardError; end
|
class Error < StandardError; end
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ module Gollum
|
|||||||
# Returns an array of Grit::Commit instances.
|
# Returns an array of Grit::Commit instances.
|
||||||
def parents
|
def parents
|
||||||
@parents ||= begin
|
@parents ||= begin
|
||||||
arr = [@options[:parent] || @wiki.repo.commit(@wiki.ref)]
|
arr = [@options[:parent] || @wiki.repo.commit('master')]
|
||||||
arr.flatten!
|
arr.flatten!
|
||||||
arr.compact!
|
arr.compact!
|
||||||
arr
|
arr
|
||||||
@@ -118,7 +118,7 @@ module Gollum
|
|||||||
def update_working_dir(dir, name, format)
|
def update_working_dir(dir, name, format)
|
||||||
unless @wiki.repo.bare
|
unless @wiki.repo.bare
|
||||||
if @wiki.page_file_dir
|
if @wiki.page_file_dir
|
||||||
dir = dir.size.zero? ? @wiki.page_file_dir : ::File.join(dir, @wiki.page_file_dir)
|
dir = dir.size.zero? ? @wiki.page_file_dir : File.join(dir, @wiki.page_file_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
path =
|
path =
|
||||||
@@ -142,7 +142,7 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns the String SHA1 of the new commit.
|
# Returns the String SHA1 of the new commit.
|
||||||
def commit
|
def commit
|
||||||
sha1 = index.commit(@options[:message], parents, actor, nil, @wiki.ref)
|
sha1 = index.commit(@options[:message], parents, actor)
|
||||||
@callbacks.each do |cb|
|
@callbacks.each do |cb|
|
||||||
cb.call(self, sha1)
|
cb.call(self, sha1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ module Precious
|
|||||||
@name = "Preview"
|
@name = "Preview"
|
||||||
@page = wiki.preview_page(@name, params[:content], params[:format])
|
@page = wiki.preview_page(@name, params[:content], params[:format])
|
||||||
@content = @page.formatted_data
|
@content = @page.formatted_data
|
||||||
@editable = false
|
|
||||||
mustache :page
|
mustache :page
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -156,7 +155,6 @@ module Precious
|
|||||||
@page = page
|
@page = page
|
||||||
@name = name
|
@name = name
|
||||||
@content = page.formatted_data
|
@content = page.formatted_data
|
||||||
@editable = true
|
|
||||||
mustache :page
|
mustache :page
|
||||||
else
|
else
|
||||||
halt 404
|
halt 404
|
||||||
@@ -171,13 +169,6 @@ module Precious
|
|||||||
mustache :search
|
mustache :search
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/pages' do
|
|
||||||
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
|
||||||
@results = wiki.pages
|
|
||||||
@ref = wiki.ref
|
|
||||||
mustache :pages
|
|
||||||
end
|
|
||||||
|
|
||||||
get '/*' do
|
get '/*' do
|
||||||
show_page_or_file(params[:splat].first)
|
show_page_or_file(params[:splat].first)
|
||||||
end
|
end
|
||||||
@@ -188,7 +179,6 @@ module Precious
|
|||||||
@page = page
|
@page = page
|
||||||
@name = name
|
@name = name
|
||||||
@content = page.formatted_data
|
@content = page.formatted_data
|
||||||
@editable = true
|
|
||||||
mustache :page
|
mustache :page
|
||||||
elsif file = wiki.file(name)
|
elsif file = wiki.file(name)
|
||||||
content_type file.mime_type
|
content_type file.mime_type
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ a:hover, a:visited {
|
|||||||
line-height: normal;
|
line-height: normal;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.08em 0 0 0;
|
padding: 0.08em 0 0 0;
|
||||||
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#head ul.actions {
|
#head ul.actions {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
// get form fields
|
// get form fields
|
||||||
var oldAction = $('#gollum-editor form').attr('action');
|
var oldAction = $('#gollum-editor form').attr('action');
|
||||||
var $form = $($('#gollum-editor form').get(0));
|
var $form = $($('#gollum-editor form').get(0));
|
||||||
$form.attr('action', '/preview');
|
$form.attr('action', this.href);
|
||||||
$form.attr('target', '_blank');
|
$form.attr('target', '_blank');
|
||||||
$form.submit();
|
$form.submit();
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,10 @@
|
|||||||
<div id="head">
|
<div id="head">
|
||||||
<h1>{{title}}</h1>
|
<h1>{{title}}</h1>
|
||||||
<ul class="actions">
|
<ul class="actions">
|
||||||
<li class="minibutton"><a href="/pages"
|
|
||||||
class="action-all-pages">All Pages</a></li>
|
|
||||||
<li class="minibutton" class="jaws">
|
<li class="minibutton" class="jaws">
|
||||||
<a href="#" id="minibutton-new-page">New Page</a></li>
|
<a href="#" id="minibutton-new-page">New Page</a></li>
|
||||||
{{#editable}}
|
|
||||||
<li class="minibutton"><a href="/edit/{{escaped_name}}"
|
<li class="minibutton"><a href="/edit/{{escaped_name}}"
|
||||||
class="action-edit-page">Edit Page</a></li>
|
class="action-edit-page">Edit Page</a></li>
|
||||||
{{/editable}}
|
|
||||||
<li class="minibutton"><a href="/history/{{escaped_name}}"
|
<li class="minibutton"><a href="/history/{{escaped_name}}"
|
||||||
class="action-page-history">Page History</a></li>
|
class="action-page-history">Page History</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
<div id="wiki-wrapper" class="results">
|
|
||||||
<div id="head">
|
|
||||||
<h1>{{title}}</h1>
|
|
||||||
<ul class="actions">
|
|
||||||
<li class="minibutton"><a href="/"
|
|
||||||
class="action-edit-page">Home</a></li>
|
|
||||||
</ul>
|
|
||||||
{{>searchbar}}
|
|
||||||
</div>
|
|
||||||
<div id="results">
|
|
||||||
|
|
||||||
{{#has_results}}
|
|
||||||
<ul>
|
|
||||||
{{#results}}
|
|
||||||
<li>
|
|
||||||
<a href="/{{name}}">{{name}}</a>
|
|
||||||
</li>
|
|
||||||
{{/results}}
|
|
||||||
</ul>
|
|
||||||
{{/has_results}}
|
|
||||||
|
|
||||||
{{#no_results}}
|
|
||||||
<p id="no-results">
|
|
||||||
There are no pages in <strong>{{ref}}</strong>.
|
|
||||||
</p>
|
|
||||||
{{/no_results}}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div id="footer">
|
|
||||||
<ul class="actions">
|
|
||||||
<li class="minibutton"><a href="#">Back to Top</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@@ -19,10 +19,6 @@ module Precious
|
|||||||
@page.version.authored_date.strftime("%Y-%m-%d %H:%M:%S")
|
@page.version.authored_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
end
|
end
|
||||||
|
|
||||||
def editable
|
|
||||||
@editable
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_footer
|
def has_footer
|
||||||
@footer = (@page.footer || false) if @footer.nil?
|
@footer = (@page.footer || false) if @footer.nil?
|
||||||
!!@footer
|
!!@footer
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
module Precious
|
|
||||||
module Views
|
|
||||||
class Pages < Layout
|
|
||||||
attr_reader :results, :ref
|
|
||||||
|
|
||||||
def title
|
|
||||||
"All pages in #{@ref}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def has_results
|
|
||||||
!@results.empty?
|
|
||||||
end
|
|
||||||
|
|
||||||
def no_results
|
|
||||||
@results.empty?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -28,17 +28,13 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# ref - a String Git reference (ex: "master")
|
# ref - a String Git reference (ex: "master")
|
||||||
#
|
#
|
||||||
# Returns a String, or nil if the ref isn't found.
|
# Returns a String.
|
||||||
def ref_to_sha(ref)
|
def ref_to_sha(ref)
|
||||||
ref = ref.to_s
|
|
||||||
return if ref.empty?
|
|
||||||
sha =
|
|
||||||
if sha?(ref)
|
if sha?(ref)
|
||||||
ref
|
ref
|
||||||
else
|
else
|
||||||
get_cache(:ref, ref) { ref_to_sha!(ref) }
|
get_cache(:ref, ref) { ref_to_sha!(ref) }
|
||||||
end.to_s
|
end
|
||||||
sha.empty? ? nil : sha
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Gets a recursive list of Git blobs for the whole tree at the
|
# Public: Gets a recursive list of Git blobs for the whole tree at the
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ require 'digest/sha1'
|
|||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
|
|
||||||
class Markup
|
class Markup
|
||||||
# Initialize a new Markup object.
|
# Initialize a new Markup object.
|
||||||
#
|
#
|
||||||
@@ -438,49 +437,4 @@ module Gollum
|
|||||||
def update_cache(type, id, data)
|
def update_cache(type, id, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
|
||||||
require 'redcarpet'
|
|
||||||
|
|
||||||
class MarkupGFM < Markup
|
|
||||||
def render(no_follow = false)
|
|
||||||
sanitize = no_follow ?
|
|
||||||
@wiki.history_sanitizer :
|
|
||||||
@wiki.sanitizer
|
|
||||||
|
|
||||||
data = extract_tex(@data.dup)
|
|
||||||
data = extract_tags(data)
|
|
||||||
|
|
||||||
flags = [
|
|
||||||
:autolink,
|
|
||||||
:fenced_code,
|
|
||||||
:tables,
|
|
||||||
:strikethrough,
|
|
||||||
:lax_htmlblock,
|
|
||||||
:gh_blockcode,
|
|
||||||
:no_intraemphasis
|
|
||||||
]
|
|
||||||
data = Redcarpet.new(data, *flags).to_html
|
|
||||||
data = process_tags(data)
|
|
||||||
|
|
||||||
doc = Nokogiri::HTML::DocumentFragment.parse(data)
|
|
||||||
|
|
||||||
doc.search('pre').each do |node|
|
|
||||||
next unless lang = node['lang']
|
|
||||||
text = node.inner_text
|
|
||||||
html = Gollum::Albino.colorize(text, lang)
|
|
||||||
node.replace(html)
|
|
||||||
end
|
|
||||||
|
|
||||||
doc = sanitize.clean_node!(doc) if sanitize
|
|
||||||
yield doc if block_given?
|
|
||||||
|
|
||||||
data = doc_to_html(doc)
|
|
||||||
data = process_tex(data)
|
|
||||||
data
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue LoadError
|
|
||||||
MarkupGFM = Markup
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-7
@@ -168,7 +168,7 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns the String data.
|
# Returns the String data.
|
||||||
def formatted_data(&block)
|
def formatted_data(&block)
|
||||||
@blob && @wiki.markup_classes[format].new(self).render(historical?, &block)
|
@blob && @wiki.markup_class.new(self).render(historical?, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: The format of the page.
|
# Public: The format of the page.
|
||||||
@@ -199,10 +199,10 @@ module Gollum
|
|||||||
options[:pretty] = 'raw'
|
options[:pretty] = 'raw'
|
||||||
options.delete :max_count
|
options.delete :max_count
|
||||||
options.delete :skip
|
options.delete :skip
|
||||||
log = @wiki.repo.git.native "log", options, @wiki.ref, "--", @path
|
log = @wiki.repo.git.native "log", options, "master", "--", @path
|
||||||
Grit::Commit.list_from_string(@wiki.repo, log)
|
Grit::Commit.list_from_string(@wiki.repo, log)
|
||||||
else
|
else
|
||||||
@wiki.repo.log(@wiki.ref, @path, log_pagination_options(options))
|
@wiki.repo.log('master', @path, log_pagination_options(options))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -390,9 +390,5 @@ module Gollum
|
|||||||
|
|
||||||
find_page_in_tree(map, name, '')
|
find_page_in_tree(map, name, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
|
||||||
%(#<#{self.class.name}:#{object_id} #{name} (#{format}) @wiki=#{@wiki.repo.path.inspect}>)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -47,27 +47,6 @@ module Gollum
|
|||||||
'img' => {'src' => ['http', 'https', :relative]}
|
'img' => {'src' => ['http', 'https', :relative]}
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
# Default transformers to force @id attributes with 'wiki-' prefix
|
|
||||||
|
|
||||||
TRANSFORMERS = [
|
|
||||||
lambda do |env|
|
|
||||||
node = env[:node]
|
|
||||||
return if env[:is_whitelisted] || !node.element? || !node['id']
|
|
||||||
prefix = env[:config][:id_prefix]
|
|
||||||
node['id'] = node['id'].gsub(/\A(#{prefix})?/, prefix)
|
|
||||||
|
|
||||||
{:node_whitelist => [node]}
|
|
||||||
end,
|
|
||||||
lambda do |env|
|
|
||||||
node = env[:node]
|
|
||||||
return unless node['href']
|
|
||||||
prefix = env[:config][:id_prefix]
|
|
||||||
node['href'] = node['href'].gsub(/\A\#(#{prefix})?/, '#'+prefix)
|
|
||||||
|
|
||||||
{:node_whitelist => [node]}
|
|
||||||
end
|
|
||||||
].freeze
|
|
||||||
|
|
||||||
# Gets an Array of whitelisted HTML elements. Default: ELEMENTS.
|
# Gets an Array of whitelisted HTML elements. Default: ELEMENTS.
|
||||||
attr_reader :elements
|
attr_reader :elements
|
||||||
|
|
||||||
@@ -79,13 +58,6 @@ module Gollum
|
|||||||
# attributes. Default: PROTOCOLS
|
# attributes. Default: PROTOCOLS
|
||||||
attr_reader :protocols
|
attr_reader :protocols
|
||||||
|
|
||||||
# Gets a Hash describing which URI protocols are allowed in HTML
|
|
||||||
# attributes. Default: TRANSFORMERS
|
|
||||||
attr_reader :transformers
|
|
||||||
|
|
||||||
# Gets a String prefix which is added to ID attributes. Default: 'wiki-'
|
|
||||||
attr_reader :id_prefix
|
|
||||||
|
|
||||||
# Gets a Hash describing HTML attributes that Sanitize should add.
|
# Gets a Hash describing HTML attributes that Sanitize should add.
|
||||||
# Default: {}
|
# Default: {}
|
||||||
attr_reader :add_attributes
|
attr_reader :add_attributes
|
||||||
@@ -98,10 +70,8 @@ module Gollum
|
|||||||
@elements = ELEMENTS
|
@elements = ELEMENTS
|
||||||
@attributes = ATTRIBUTES
|
@attributes = ATTRIBUTES
|
||||||
@protocols = PROTOCOLS
|
@protocols = PROTOCOLS
|
||||||
@transformers = TRANSFORMERS
|
|
||||||
@add_attributes = {}
|
@add_attributes = {}
|
||||||
@allow_comments = false
|
@allow_comments = false
|
||||||
@id_prefix = 'wiki-'
|
|
||||||
yield self if block_given?
|
yield self if block_given?
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -130,9 +100,7 @@ module Gollum
|
|||||||
:attributes => attributes,
|
:attributes => attributes,
|
||||||
:protocols => protocols,
|
:protocols => protocols,
|
||||||
:add_attributes => add_attributes,
|
:add_attributes => add_attributes,
|
||||||
:allow_comments => allow_comments?,
|
:allow_comments => allow_comments?
|
||||||
:transformers => transformers,
|
|
||||||
:id_prefix => id_prefix
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+19
-54
@@ -10,10 +10,7 @@ module Gollum
|
|||||||
attr_writer :file_class
|
attr_writer :file_class
|
||||||
|
|
||||||
# Sets the markup class used by all instances of this Wiki.
|
# Sets the markup class used by all instances of this Wiki.
|
||||||
attr_writer :markup_classes
|
attr_writer :markup_class
|
||||||
|
|
||||||
# Sets the default ref for the wiki.
|
|
||||||
attr_accessor :default_ref
|
|
||||||
|
|
||||||
# Sets the default name for commits.
|
# Sets the default name for commits.
|
||||||
attr_accessor :default_committer_name
|
attr_accessor :default_committer_name
|
||||||
@@ -53,31 +50,13 @@ module Gollum
|
|||||||
|
|
||||||
# Gets the markup class used by all instances of this Wiki.
|
# Gets the markup class used by all instances of this Wiki.
|
||||||
# Default: Gollum::Markup
|
# Default: Gollum::Markup
|
||||||
def markup_classes
|
|
||||||
@markup_classes ||
|
|
||||||
if superclass.respond_to?(:markup_classes)
|
|
||||||
superclass.markup_classes
|
|
||||||
else
|
|
||||||
classes = Hash.new(::Gollum::Markup)
|
|
||||||
|
|
||||||
# Add custom markup classes for different languages
|
|
||||||
classes[:markdown] = ::Gollum::MarkupGFM
|
|
||||||
classes
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Gets the default markup class used by all instances of this Wiki.
|
|
||||||
# Kept for backwards compatibility until Gollum v2.x
|
|
||||||
def markup_class
|
def markup_class
|
||||||
markup_classes[:default]
|
@markup_class ||
|
||||||
|
if superclass.respond_to?(:markup_class)
|
||||||
|
superclass.markup_class
|
||||||
|
else
|
||||||
|
::Gollum::Markup
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets the default markup class used by all instances of this Wiki.
|
|
||||||
# Kept for backwards compatibility until Gollum v2.x
|
|
||||||
def markup_class=(default)
|
|
||||||
new_classes = Hash.new default
|
|
||||||
@markup_classes = Hash.new(default).update(markup_classes)
|
|
||||||
default
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gets the default sanitization options for current pages used by
|
# Gets the default sanitization options for current pages used by
|
||||||
@@ -101,7 +80,6 @@ module Gollum
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.default_ref = 'master'
|
|
||||||
self.default_committer_name = 'Anonymous'
|
self.default_committer_name = 'Anonymous'
|
||||||
self.default_committer_email = 'anon@anon.com'
|
self.default_committer_email = 'anon@anon.com'
|
||||||
|
|
||||||
@@ -116,9 +94,6 @@ module Gollum
|
|||||||
# Gets the sanitization options for older page revisions used by this Wiki.
|
# Gets the sanitization options for older page revisions used by this Wiki.
|
||||||
attr_reader :history_sanitization
|
attr_reader :history_sanitization
|
||||||
|
|
||||||
# Gets the String ref in which all page files reside.
|
|
||||||
attr_reader :ref
|
|
||||||
|
|
||||||
# Gets the String directory in which all page files reside.
|
# Gets the String directory in which all page files reside.
|
||||||
attr_reader :page_file_dir
|
attr_reader :page_file_dir
|
||||||
|
|
||||||
@@ -131,11 +106,9 @@ module Gollum
|
|||||||
# Default: "/"
|
# Default: "/"
|
||||||
# :page_class - The page Class. Default: Gollum::Page
|
# :page_class - The page Class. Default: Gollum::Page
|
||||||
# :file_class - The file Class. Default: Gollum::File
|
# :file_class - The file Class. Default: Gollum::File
|
||||||
# :markup_classes - A hash containing the markup Classes for each
|
# :markup_class - The markup Class. Default: Gollum::Markup
|
||||||
# document type. Default: { Gollum::Markup }
|
|
||||||
# :sanitization - An instance of Sanitization.
|
# :sanitization - An instance of Sanitization.
|
||||||
# :page_file_dir - String the directory in which all page files reside
|
# :page_file_dir - String the directory in which all page files reside
|
||||||
# :ref - String the repository ref to retrieve pages from
|
|
||||||
#
|
#
|
||||||
# Returns a fresh Gollum::Repo.
|
# Returns a fresh Gollum::Repo.
|
||||||
def initialize(path, options = {})
|
def initialize(path, options = {})
|
||||||
@@ -149,9 +122,8 @@ module Gollum
|
|||||||
@base_path = options[:base_path] || "/"
|
@base_path = options[:base_path] || "/"
|
||||||
@page_class = options[:page_class] || self.class.page_class
|
@page_class = options[:page_class] || self.class.page_class
|
||||||
@file_class = options[:file_class] || self.class.file_class
|
@file_class = options[:file_class] || self.class.file_class
|
||||||
@markup_classes = options[:markup_classes] || self.class.markup_classes
|
@markup_class = options[:markup_class] || self.class.markup_class
|
||||||
@repo = @access.repo
|
@repo = @access.repo
|
||||||
@ref = options[:ref] || self.class.default_ref
|
|
||||||
@sanitization = options[:sanitization] || self.class.sanitization
|
@sanitization = options[:sanitization] || self.class.sanitization
|
||||||
@history_sanitization = options[:history_sanitization] ||
|
@history_sanitization = options[:history_sanitization] ||
|
||||||
self.class.history_sanitization
|
self.class.history_sanitization
|
||||||
@@ -167,20 +139,20 @@ module Gollum
|
|||||||
# Public: Get the formatted page for a given page name.
|
# Public: Get the formatted page for a given page name.
|
||||||
#
|
#
|
||||||
# name - The human or canonical String page name of the wiki page.
|
# name - The human or canonical String page name of the wiki page.
|
||||||
# version - The String version ID to find (default: @ref).
|
# version - The String version ID to find (default: "master").
|
||||||
#
|
#
|
||||||
# Returns a Gollum::Page or nil if no matching page was found.
|
# Returns a Gollum::Page or nil if no matching page was found.
|
||||||
def page(name, version = @ref)
|
def page(name, version = 'master')
|
||||||
@page_class.new(self).find(name, version)
|
@page_class.new(self).find(name, version)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Get the static file for a given name.
|
# Public: Get the static file for a given name.
|
||||||
#
|
#
|
||||||
# name - The full String pathname to the file.
|
# name - The full String pathname to the file.
|
||||||
# version - The String version ID to find (default: @ref).
|
# version - The String version ID to find (default: "master").
|
||||||
#
|
#
|
||||||
# Returns a Gollum::File or nil if no matching file was found.
|
# Returns a Gollum::File or nil if no matching file was found.
|
||||||
def file(name, version = @ref)
|
def file(name, version = 'master')
|
||||||
@file_class.new(self).find(name, version)
|
@file_class.new(self).find(name, version)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -409,11 +381,11 @@ module Gollum
|
|||||||
|
|
||||||
# Public: Lists all pages for this wiki.
|
# Public: Lists all pages for this wiki.
|
||||||
#
|
#
|
||||||
# treeish - The String commit ID or ref to find (default: @ref)
|
# treeish - The String commit ID or ref to find (default: master)
|
||||||
#
|
#
|
||||||
# Returns an Array of Gollum::Page instances.
|
# Returns an Array of Gollum::Page instances.
|
||||||
def pages(treeish = nil)
|
def pages(treeish = nil)
|
||||||
tree_list(treeish || @ref)
|
tree_list(treeish || 'master')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Returns the number of pages accessible from a commit
|
# Public: Returns the number of pages accessible from a commit
|
||||||
@@ -422,7 +394,7 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns a Fixnum
|
# Returns a Fixnum
|
||||||
def size(ref = nil)
|
def size(ref = nil)
|
||||||
tree_map_for(ref || @ref).inject(0) do |num, entry|
|
tree_map_for(ref || 'master').inject(0) do |num, entry|
|
||||||
num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
|
num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
|
||||||
end
|
end
|
||||||
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
||||||
@@ -435,7 +407,7 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns an Array with Objects of page name and count of matches
|
# Returns an Array with Objects of page name and count of matches
|
||||||
def search(query)
|
def search(query)
|
||||||
args = [{}, '-i', '-c', query, @ref, '--']
|
args = [{}, '-i', '-c', query, 'master', '--']
|
||||||
args << '--' << @page_file_dir if @page_file_dir
|
args << '--' << @page_file_dir if @page_file_dir
|
||||||
|
|
||||||
@repo.git.grep(*args).split("\n").map! do |line|
|
@repo.git.grep(*args).split("\n").map! do |line|
|
||||||
@@ -457,7 +429,7 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns an Array of Grit::Commit.
|
# Returns an Array of Grit::Commit.
|
||||||
def log(options = {})
|
def log(options = {})
|
||||||
@repo.log(@ref, nil, log_pagination_options(options))
|
@repo.log('master', nil, log_pagination_options(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Public: Refreshes just the cached Git reference data. This should
|
# Public: Refreshes just the cached Git reference data. This should
|
||||||
@@ -511,7 +483,7 @@ module Gollum
|
|||||||
attr_reader :file_class
|
attr_reader :file_class
|
||||||
|
|
||||||
# Gets the markup class used by all instances of this Wiki.
|
# Gets the markup class used by all instances of this Wiki.
|
||||||
attr_reader :markup_classes
|
attr_reader :markup_class
|
||||||
|
|
||||||
# Normalize the data.
|
# Normalize the data.
|
||||||
#
|
#
|
||||||
@@ -539,15 +511,12 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns a flat Array of Gollum::Page instances.
|
# Returns a flat Array of Gollum::Page instances.
|
||||||
def tree_list(ref)
|
def tree_list(ref)
|
||||||
if sha = @access.ref_to_sha(ref)
|
sha = @access.ref_to_sha(ref)
|
||||||
commit = @access.commit(sha)
|
commit = @access.commit(sha)
|
||||||
tree_map_for(sha).inject([]) do |list, entry|
|
tree_map_for(sha).inject([]) do |list, entry|
|
||||||
next list unless @page_class.valid_page_name?(entry.name)
|
next list unless @page_class.valid_page_name?(entry.name)
|
||||||
list << entry.page(self, commit)
|
list << entry.page(self, commit)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a reverse diff for the given SHAs on the given Gollum::Page.
|
# Creates a reverse diff for the given SHAs on the given Gollum::Page.
|
||||||
@@ -615,9 +584,5 @@ module Gollum
|
|||||||
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
|
||||||
%(#<#{self.class.name}:#{object_id} #{@repo.path}>)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -38,12 +38,6 @@ def commit_details
|
|||||||
:email => "tom@github.com" }
|
:email => "tom@github.com" }
|
||||||
end
|
end
|
||||||
|
|
||||||
def normal(text)
|
|
||||||
text.gsub!(' ', '')
|
|
||||||
text.gsub!("\n", '')
|
|
||||||
text
|
|
||||||
end
|
|
||||||
|
|
||||||
# test/spec/mini 3
|
# test/spec/mini 3
|
||||||
# http://gist.github.com/25455
|
# http://gist.github.com/25455
|
||||||
# chris@ozmm.org
|
# chris@ozmm.org
|
||||||
|
|||||||
@@ -48,17 +48,4 @@ context "Wiki" do
|
|||||||
FileUtils.rm_rf(@path)
|
FileUtils.rm_rf(@path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "parents with default master ref" do
|
|
||||||
ref = 'a8ad3c09dd842a3517085bfadd37718856dee813'
|
|
||||||
committer = Gollum::Committer.new(@wiki)
|
|
||||||
assert_equal ref, committer.parents.first.sha
|
|
||||||
end
|
|
||||||
|
|
||||||
test "parents with custom ref" do
|
|
||||||
ref = '60f12f4254f58801b9ee7db7bca5fa8aeefaa56b'
|
|
||||||
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"), :ref => ref)
|
|
||||||
committer = Gollum::Committer.new(@wiki)
|
|
||||||
assert_equal ref, committer.parents.first.sha
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
+3
-17
@@ -173,7 +173,7 @@ context "Markup" do
|
|||||||
@wiki.write_page("Potato", :mediawiki, "a [[Potato|Potato Heaad]] ", commit_details)
|
@wiki.write_page("Potato", :mediawiki, "a [[Potato|Potato Heaad]] ", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal normal("<p>\na <a class=\"internal present\" href=\"/Potato\">Potato Heaad</a> </p>"), normal(output)
|
assert_equal "<p>\na <a class=\"internal present\" href=\"/Potato\">Potato Heaad</a> </p>", output
|
||||||
end
|
end
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
@@ -467,20 +467,6 @@ context "Markup" do
|
|||||||
compare(content, output, 'org')
|
compare(content, output, 'org')
|
||||||
end
|
end
|
||||||
|
|
||||||
test "id with prefix ok" do
|
|
||||||
content = "h2(example#wiki-foo). xxxx"
|
|
||||||
output = %(<h2 class="example" id="wiki-foo">xxxx</h2>)
|
|
||||||
compare(content, output, :textile)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "id prefix added" do
|
|
||||||
content = "h2(#foo). xxxx[1]\n\nfn1.footnote"
|
|
||||||
output = "<h2 id=\"wiki-foo\">xxxx" +
|
|
||||||
"<sup class=\"footnote\" id=\"wiki-fnr1\"><a href=\"#wiki-fn1\">1</a></sup></h2>" +
|
|
||||||
"\n<p class=\"footnote\" id=\"wiki-fn1\"><a href=\"#wiki-fnr1\"><sup>1</sup></a> footnote</p>"
|
|
||||||
compare(content, output, :textile)
|
|
||||||
end
|
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
#
|
#
|
||||||
# TeX
|
# TeX
|
||||||
@@ -513,7 +499,7 @@ context "Markup" do
|
|||||||
page = @wiki.page("Bilbo Baggins")
|
page = @wiki.page("Bilbo Baggins")
|
||||||
rendered = Gollum::Markup.new(page).render
|
rendered = Gollum::Markup.new(page).render
|
||||||
if regexes.empty?
|
if regexes.empty?
|
||||||
assert_equal normal(output), normal(rendered)
|
assert_equal output, rendered
|
||||||
else
|
else
|
||||||
regexes.each { |r| assert_match r, output }
|
regexes.each { |r| assert_match r, output }
|
||||||
end
|
end
|
||||||
@@ -528,6 +514,6 @@ context "Markup" do
|
|||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
page = @wiki.page("Bilbo Baggins")
|
page = @wiki.page("Bilbo Baggins")
|
||||||
rendered = Gollum::Markup.new(page).render
|
rendered = Gollum::Markup.new(page).render
|
||||||
assert_equal normal(output), normal(rendered)
|
assert_equal output, rendered
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,20 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|||||||
context "Wiki" do
|
context "Wiki" do
|
||||||
setup do
|
setup do
|
||||||
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"))
|
@wiki = Gollum::Wiki.new(testpath("examples/lotr.git"))
|
||||||
Gollum::Wiki.markup_classes = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
test "#markup_class gets default markup" do
|
|
||||||
assert_equal Gollum::Markup, Gollum::Wiki.markup_class
|
|
||||||
end
|
|
||||||
|
|
||||||
test "#markup_class= doesn't clobber alternate markups" do
|
|
||||||
custom = Class.new(Gollum::Markup)
|
|
||||||
Gollum::Wiki.markup_class = custom
|
|
||||||
|
|
||||||
assert_equal custom, Gollum::Wiki.markup_class
|
|
||||||
assert_equal custom, Gollum::Wiki.markup_classes[:orgmode]
|
|
||||||
assert_equal Gollum::MarkupGFM, Gollum::Wiki.markup_classes[:markdown]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test "repo path" do
|
test "repo path" do
|
||||||
@@ -297,11 +283,6 @@ context "page_file_dir option" do
|
|||||||
assert !File.exist?(File.join(@path, "New-Page.md"))
|
assert !File.exist?(File.join(@path, "New-Page.md"))
|
||||||
end
|
end
|
||||||
|
|
||||||
test "edit a page in a sub directory" do
|
|
||||||
page = @wiki.page('foo')
|
|
||||||
@wiki.update_page(page, page.name, page.format, 'new contents', commit_details)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "a file in page file dir should be found" do
|
test "a file in page file dir should be found" do
|
||||||
assert @wiki.page("foo")
|
assert @wiki.page("foo")
|
||||||
end
|
end
|
||||||
@@ -320,38 +301,3 @@ context "page_file_dir option" do
|
|||||||
FileUtils.rm_r(@path)
|
FileUtils.rm_r(@path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Wiki page writing with different branch" do
|
|
||||||
setup do
|
|
||||||
@path = testpath("examples/test.git")
|
|
||||||
FileUtils.rm_rf(@path)
|
|
||||||
@repo = Grit::Repo.init_bare(@path)
|
|
||||||
@wiki = Gollum::Wiki.new(@path)
|
|
||||||
|
|
||||||
# We need an initial commit to create the master branch
|
|
||||||
# before we can create new branches
|
|
||||||
cd = commit_details
|
|
||||||
@wiki.write_page("Gollum", :markdown, "# Gollum", cd)
|
|
||||||
|
|
||||||
# Create our test branch and check it out
|
|
||||||
@repo.update_ref("test", @repo.commits.first.id)
|
|
||||||
@branch = Gollum::Wiki.new(@path, :ref => "test")
|
|
||||||
end
|
|
||||||
|
|
||||||
teardown do
|
|
||||||
FileUtils.rm_rf(@path)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "write_page" do
|
|
||||||
cd = commit_details
|
|
||||||
|
|
||||||
@branch.write_page("Bilbo", :markdown, "# Bilbo", commit_details)
|
|
||||||
assert @branch.page("Bilbo")
|
|
||||||
assert @wiki.page("Gollum")
|
|
||||||
|
|
||||||
assert_equal 1, @wiki.repo.commits.size
|
|
||||||
assert_equal 1, @branch.repo.commits.size
|
|
||||||
|
|
||||||
assert_equal nil, @wiki.page("Bilbo")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|||||||
Reference in New Issue
Block a user