Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 748d76dff1 | |||
| 2ebed41225 | |||
| 86d14fa7ab | |||
| 82e31e971a | |||
| 3d591b49cb | |||
| df505a7289 | |||
| 17dcde1f61 | |||
| 2a052cae8d | |||
| d3594f6652 | |||
| ad561226b9 | |||
| 8403868ac3 | |||
| a1d760df1e | |||
| e3950d52c1 | |||
| 7427ddd900 | |||
| 364b2b85ae | |||
| a71ab7c418 | |||
| 2bb1937fa9 | |||
| 3c44205be7 |
+18
-1
@@ -1,4 +1,21 @@
|
||||
# HEAD
|
||||
# 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
|
||||
* Add Page sidebars, similar to Page footers.
|
||||
|
||||
@@ -48,6 +48,10 @@ opts = OptionParser.new do |opts|
|
||||
opts.on("--page-file-dir [PATH]", "Specify the sub directory for all page files (default: repository root).") do |path|
|
||||
wiki_options[:page_file_dir] = path
|
||||
end
|
||||
|
||||
opts.on("--ref [REF]", "Specify the repository ref to use (default: master).") do |ref|
|
||||
wiki_options[:ref] = ref
|
||||
end
|
||||
end
|
||||
|
||||
# Read command line options into `options` hash
|
||||
|
||||
+4
-3
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
||||
s.rubygems_version = '1.3.5'
|
||||
|
||||
s.name = 'gollum'
|
||||
s.version = '1.2.0'
|
||||
s.date = '2011-03-31'
|
||||
s.version = '1.3.0'
|
||||
s.date = '2011-04-25'
|
||||
s.rubyforge_project = 'gollum'
|
||||
|
||||
s.summary = "A simple, Git-powered wiki."
|
||||
@@ -697,6 +697,7 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/templates/history.mustache
|
||||
lib/gollum/frontend/templates/layout.mustache
|
||||
lib/gollum/frontend/templates/page.mustache
|
||||
lib/gollum/frontend/templates/pages.mustache
|
||||
lib/gollum/frontend/templates/search.mustache
|
||||
lib/gollum/frontend/templates/searchbar.mustache
|
||||
lib/gollum/frontend/views/compare.rb
|
||||
@@ -707,12 +708,12 @@ Gem::Specification.new do |s|
|
||||
lib/gollum/frontend/views/history.rb
|
||||
lib/gollum/frontend/views/layout.rb
|
||||
lib/gollum/frontend/views/page.rb
|
||||
lib/gollum/frontend/views/pages.rb
|
||||
lib/gollum/frontend/views/search.rb
|
||||
lib/gollum/git_access.rb
|
||||
lib/gollum/markup.rb
|
||||
lib/gollum/page.rb
|
||||
lib/gollum/pagination.rb
|
||||
lib/gollum/ruby1.8.rb
|
||||
lib/gollum/sanitization.rb
|
||||
lib/gollum/wiki.rb
|
||||
templates/formatting.html
|
||||
|
||||
+1
-4
@@ -7,9 +7,6 @@ require 'grit'
|
||||
require 'github/markup'
|
||||
require 'sanitize'
|
||||
|
||||
# ruby 1.8 compatibility
|
||||
require 'gollum/ruby1.8'
|
||||
|
||||
# internal
|
||||
require 'gollum/git_access'
|
||||
require 'gollum/committer'
|
||||
@@ -23,7 +20,7 @@ require 'gollum/albino'
|
||||
require 'gollum/sanitization'
|
||||
|
||||
module Gollum
|
||||
VERSION = '1.2.0'
|
||||
VERSION = '1.3.0'
|
||||
|
||||
class Error < StandardError; end
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ module Gollum
|
||||
# Returns an array of Grit::Commit instances.
|
||||
def parents
|
||||
@parents ||= begin
|
||||
arr = [@options[:parent] || @wiki.repo.commit('master')]
|
||||
arr = [@options[:parent] || @wiki.repo.commit(@wiki.ref)]
|
||||
arr.flatten!
|
||||
arr.compact!
|
||||
arr
|
||||
@@ -142,7 +142,7 @@ module Gollum
|
||||
#
|
||||
# Returns the String SHA1 of the new commit.
|
||||
def commit
|
||||
sha1 = index.commit(@options[:message], parents, actor)
|
||||
sha1 = index.commit(@options[:message], parents, actor, nil, @wiki.ref)
|
||||
@callbacks.each do |cb|
|
||||
cb.call(self, sha1)
|
||||
end
|
||||
|
||||
@@ -169,6 +169,13 @@ module Precious
|
||||
mustache :search
|
||||
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
|
||||
show_page_or_file(params[:splat].first)
|
||||
end
|
||||
|
||||
@@ -42,7 +42,6 @@ a:hover, a:visited {
|
||||
line-height: normal;
|
||||
margin: 0;
|
||||
padding: 0.08em 0 0 0;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
#head ul.actions {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<div id="head">
|
||||
<h1>{{title}}</h1>
|
||||
<ul class="actions">
|
||||
<li class="minibutton"><a href="/pages"
|
||||
class="action-all-pages">All Pages</a></li>
|
||||
<li class="minibutton" class="jaws">
|
||||
<a href="#" id="minibutton-new-page">New Page</a></li>
|
||||
<li class="minibutton"><a href="/edit/{{escaped_name}}"
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<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>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
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
|
||||
@@ -74,12 +74,14 @@ module Gollum
|
||||
# Returns the placeholder'd String data.
|
||||
def extract_tex(data)
|
||||
data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do
|
||||
id = Digest::SHA1.hexdigest($1)
|
||||
@texmap[id] = [:block, $1]
|
||||
tag = CGI.escapeHTML($1)
|
||||
id = Digest::SHA1.hexdigest(tag)
|
||||
@texmap[id] = [:block, tag]
|
||||
id
|
||||
end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do
|
||||
id = Digest::SHA1.hexdigest($1)
|
||||
@texmap[id] = [:inline, $1]
|
||||
tag = CGI.escapeHTML($1)
|
||||
id = Digest::SHA1.hexdigest(tag)
|
||||
@texmap[id] = [:inline, tag]
|
||||
id
|
||||
end
|
||||
end
|
||||
|
||||
+2
-2
@@ -199,10 +199,10 @@ module Gollum
|
||||
options[:pretty] = 'raw'
|
||||
options.delete :max_count
|
||||
options.delete :skip
|
||||
log = @wiki.repo.git.native "log", options, "master", "--", @path
|
||||
log = @wiki.repo.git.native "log", options, @wiki.ref, "--", @path
|
||||
Grit::Commit.list_from_string(@wiki.repo, log)
|
||||
else
|
||||
@wiki.repo.log('master', @path, log_pagination_options(options))
|
||||
@wiki.repo.log(@wiki.ref, @path, log_pagination_options(options))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
class String
|
||||
alias :lines :to_a if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
|
||||
end
|
||||
+18
-9
@@ -12,6 +12,9 @@ module Gollum
|
||||
# Sets the markup class used by all instances of this Wiki.
|
||||
attr_writer :markup_class
|
||||
|
||||
# Sets the default ref for the wiki.
|
||||
attr_accessor :default_ref
|
||||
|
||||
# Sets the default name for commits.
|
||||
attr_accessor :default_committer_name
|
||||
|
||||
@@ -80,6 +83,7 @@ module Gollum
|
||||
end
|
||||
end
|
||||
|
||||
self.default_ref = 'master'
|
||||
self.default_committer_name = 'Anonymous'
|
||||
self.default_committer_email = 'anon@anon.com'
|
||||
|
||||
@@ -94,6 +98,9 @@ module Gollum
|
||||
# Gets the sanitization options for older page revisions used by this Wiki.
|
||||
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.
|
||||
attr_reader :page_file_dir
|
||||
|
||||
@@ -109,6 +116,7 @@ module Gollum
|
||||
# :markup_class - The markup Class. Default: Gollum::Markup
|
||||
# :sanitization - An instance of Sanitization.
|
||||
# :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.
|
||||
def initialize(path, options = {})
|
||||
@@ -124,6 +132,7 @@ module Gollum
|
||||
@file_class = options[:file_class] || self.class.file_class
|
||||
@markup_class = options[:markup_class] || self.class.markup_class
|
||||
@repo = @access.repo
|
||||
@ref = options[:ref] || self.class.default_ref
|
||||
@sanitization = options[:sanitization] || self.class.sanitization
|
||||
@history_sanitization = options[:history_sanitization] ||
|
||||
self.class.history_sanitization
|
||||
@@ -139,20 +148,20 @@ module Gollum
|
||||
# Public: Get the formatted page for a given page name.
|
||||
#
|
||||
# name - The human or canonical String page name of the wiki page.
|
||||
# version - The String version ID to find (default: "master").
|
||||
# version - The String version ID to find (default: @ref).
|
||||
#
|
||||
# Returns a Gollum::Page or nil if no matching page was found.
|
||||
def page(name, version = 'master')
|
||||
def page(name, version = @ref)
|
||||
@page_class.new(self).find(name, version)
|
||||
end
|
||||
|
||||
# Public: Get the static file for a given name.
|
||||
#
|
||||
# name - The full String pathname to the file.
|
||||
# version - The String version ID to find (default: "master").
|
||||
# version - The String version ID to find (default: @ref).
|
||||
#
|
||||
# Returns a Gollum::File or nil if no matching file was found.
|
||||
def file(name, version = 'master')
|
||||
def file(name, version = @ref)
|
||||
@file_class.new(self).find(name, version)
|
||||
end
|
||||
|
||||
@@ -381,11 +390,11 @@ module Gollum
|
||||
|
||||
# Public: Lists all pages for this wiki.
|
||||
#
|
||||
# treeish - The String commit ID or ref to find (default: master)
|
||||
# treeish - The String commit ID or ref to find (default: @ref)
|
||||
#
|
||||
# Returns an Array of Gollum::Page instances.
|
||||
def pages(treeish = nil)
|
||||
tree_list(treeish || 'master')
|
||||
tree_list(treeish || @ref)
|
||||
end
|
||||
|
||||
# Public: Returns the number of pages accessible from a commit
|
||||
@@ -394,7 +403,7 @@ module Gollum
|
||||
#
|
||||
# Returns a Fixnum
|
||||
def size(ref = nil)
|
||||
tree_map_for(ref || 'master').inject(0) do |num, entry|
|
||||
tree_map_for(ref || @ref).inject(0) do |num, entry|
|
||||
num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
|
||||
end
|
||||
rescue Grit::GitRuby::Repository::NoSuchShaFound
|
||||
@@ -407,7 +416,7 @@ module Gollum
|
||||
#
|
||||
# Returns an Array with Objects of page name and count of matches
|
||||
def search(query)
|
||||
args = [{}, '-i', '-c', query, 'master', '--']
|
||||
args = [{}, '-i', '-c', query, @ref, '--']
|
||||
args << '--' << @page_file_dir if @page_file_dir
|
||||
|
||||
@repo.git.grep(*args).split("\n").map! do |line|
|
||||
@@ -429,7 +438,7 @@ module Gollum
|
||||
#
|
||||
# Returns an Array of Grit::Commit.
|
||||
def log(options = {})
|
||||
@repo.log('master', nil, log_pagination_options(options))
|
||||
@repo.log(@ref, nil, log_pagination_options(options))
|
||||
end
|
||||
|
||||
# Public: Refreshes just the cached Git reference data. This should
|
||||
|
||||
@@ -48,4 +48,17 @@ context "Wiki" do
|
||||
FileUtils.rm_rf(@path)
|
||||
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
|
||||
|
||||
@@ -301,3 +301,38 @@ context "page_file_dir option" do
|
||||
FileUtils.rm_r(@path)
|
||||
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