nuke whitespace

This commit is contained in:
Corey Donohoe
2012-04-10 18:38:04 -07:00
parent 8ee52e7d05
commit d6a4009989
14 changed files with 55 additions and 55 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
module Gollum
# Responsible for handling the commit process for a Wiki. It sets up the
# Responsible for handling the commit process for a Wiki. It sets up the
# Git index, provides methods for modifying the tree, and stores callbacks
# to be fired after the commit has been made. This is specifically
# to be fired after the commit has been made. This is specifically
# designed to handle multiple updated pages in a single commit.
class Committer
# Gets the instance of the Gollum::Wiki that is being updated.
@@ -21,7 +21,7 @@ module Gollum
# :tree - Optional String SHA of the tree to create the
# index from.
# :committer - Optional Gollum::Committer instance. If provided,
# assume that this operation is part of batch of
# assume that this operation is part of batch of
# updates and the commit happens later.
#
# Returns the Committer instance.
@@ -152,7 +152,7 @@ module Gollum
# Adds a callback to be fired after a commit.
#
# block - A block that expects this Committer instance and the created
# block - A block that expects this Committer instance and the created
# commit's SHA1 as the arguments.
#
# Returns nothing.
+1 -1
View File
@@ -16,7 +16,7 @@ module Precious
set :public_folder, "#{dir}/public"
set :static, true
set :default_markup, :markdown
set :mustache, {
# Tell mustache where the Views constant lives
:namespace => Precious,
+5 -5
View File
@@ -8,15 +8,15 @@ module Precious
def title
"Create a new page"
end
def is_create_page
true
end
def is_edit_page
false
end
def format
@format = (@page.format || false) if @format.nil? && @page
@format.to_s.downcase
@@ -39,10 +39,10 @@ module Precious
def formats
super(:markdown)
end
def default_markup
Precious::App.settings.default_markup
end
end
end
end
end
+2 -2
View File
@@ -10,8 +10,8 @@ module Precious
def has_results
!@results.empty?
end
def no_results
def no_results
@results.empty?
end
end
+2 -2
View File
@@ -10,8 +10,8 @@ module Precious
def has_results
!@results.empty?
end
def no_results
def no_results
@results.empty?
end
+3 -3
View File
@@ -422,7 +422,7 @@ module Gollum
#
#########################################################################
# Extract all sequence diagram blocks into the wsdmap and replace with
# Extract all sequence diagram blocks into the wsdmap and replace with
# placeholders.
#
# data - The raw String data.
@@ -436,7 +436,7 @@ module Gollum
end
end
# Process all diagrams from the wsdmap and replace the placeholders with
# Process all diagrams from the wsdmap and replace the placeholders with
# the final HTML.
#
# data - The String data (with placeholders).
@@ -487,7 +487,7 @@ module Gollum
if Gem::Version.new(Redcarpet::VERSION) > Gem::Version.new("1.17.2")
html_renderer = Redcarpet::Render::HTML.new({
:autolink => true,
:fenced_code_blocks => true,
:fenced_code_blocks => true,
:tables => true,
:strikethrough => true,
:lax_htmlblock => true,
+1 -1
View File
@@ -87,7 +87,7 @@ module Gollum
#
# filename - The string path or filename to strip
#
# Returns the stripped String.
# Returns the stripped String.
def self.strip_filename(filename)
::File.basename(filename, ::File.extname(filename))
end
+2 -2
View File
@@ -19,7 +19,7 @@ module Gollum
([1, page.to_i].max - 1) * per_page
end
# Fills in git-specific options for the log command using simple
# Fills in git-specific options for the log command using simple
# pagination options.
#
# options - Hash of options:
@@ -45,7 +45,7 @@ module Gollum
self.class.page_to_skip(page)
end
# Fills in git-specific options for the log command using simple
# Fills in git-specific options for the log command using simple
# pagination options.
#
# options - Hash of options:
+17 -17
View File
@@ -20,10 +20,10 @@ module Gollum
# Sets the default email for commits.
attr_accessor :default_committer_email
# Array of chars to substitute whitespace for when trying to locate file in git repo.
attr_accessor :default_ws_subs
# Sets sanitization options. Set to false to deactivate
# sanitization altogether.
attr_writer :sanitization
@@ -105,7 +105,7 @@ module Gollum
self.default_ref = 'master'
self.default_committer_name = 'Anonymous'
self.default_committer_email = 'anon@anon.com'
self.default_ws_subs = ['_','-']
# The String base path to prefix to internal links. For example, when set
@@ -124,7 +124,7 @@ module Gollum
# Gets the String directory in which all page files reside.
attr_reader :page_file_dir
# Gets the Array of chars to sub for ws in filenames.
attr_reader :ws_subs
@@ -225,10 +225,10 @@ module Gollum
# :tree - Optional String SHA of the tree to create the
# index from.
# :committer - Optional Gollum::Committer instance. If provided,
# assume that this operation is part of batch of
# assume that this operation is part of batch of
# updates and the commit happens later.
#
# Returns the String SHA1 of the newly written version, or the
# Returns the String SHA1 of the newly written version, or the
# Gollum::Committer instance if this is part of a batch update.
def write_page(name, format, data, commit = {})
multi_commit = false
@@ -239,9 +239,9 @@ module Gollum
else
Committer.new(self, commit)
end
filename = Gollum::Page.cname(name)
committer.add_to_index('', filename, format, data)
committer.after_commit do |index, sha|
@@ -269,19 +269,19 @@ module Gollum
# :tree - Optional String SHA of the tree to create the
# index from.
# :committer - Optional Gollum::Committer instance. If provided,
# assume that this operation is part of batch of
# assume that this operation is part of batch of
# updates and the commit happens later.
#
# Returns the String SHA1 of the newly written version, or the
# Returns the String SHA1 of the newly written version, or the
# Gollum::Committer instance if this is part of a batch update.
def update_page(page, name, format, data, commit = {})
name ||= page.name
format ||= page.format
dir = ::File.dirname(page.path)
dir = '' if dir == '.'
dir = '' if dir == '.'
filename = (rename = page.name != name) ?
Gollum::Page.cname(name) : page.filename_stripped
multi_commit = false
committer = if obj = commit[:committer]
@@ -290,14 +290,14 @@ module Gollum
else
Committer.new(self, commit)
end
if !rename && page.format == format
committer.add(page.path, normalize(data))
else
committer.delete(page.path)
committer.add_to_index(dir, filename, format, data, :allow_same_ext)
end
committer.after_commit do |index, sha|
@access.refresh
index.update_working_dir(dir, page.filename_stripped, page.format)
@@ -318,10 +318,10 @@ module Gollum
# :tree - Optional String SHA of the tree to create the
# index from.
# :committer - Optional Gollum::Committer instance. If provided,
# assume that this operation is part of batch of
# assume that this operation is part of batch of
# updates and the commit happens later.
#
# Returns the String SHA1 of the newly written version, or the
# Returns the String SHA1 of the newly written version, or the
# Gollum::Committer instance if this is part of a batch update.
def delete_page(page, commit)
multi_commit = false
@@ -628,7 +628,7 @@ module Gollum
rescue Grit::GitRuby::Repository::NoSuchShaFound
[]
end
def inspect
%(#<#{self.class.name}:#{object_id} #{@repo.path}>)
end
+1 -1
View File
@@ -37,7 +37,7 @@ context "Wiki" do
assert_equal committer, index
end
res = wiki.write_page("Gollum", :markdown, "# Gollum",
res = wiki.write_page("Gollum", :markdown, "# Gollum",
:committer => committer)
assert_equal committer, res
+1 -1
View File
@@ -1,5 +1,5 @@
# ~*~ encoding: utf-8 ~*~
path = File.join(File.dirname(__FILE__), "helper")
path = File.join(File.dirname(__FILE__), "helper")
require File.expand_path(path)
context "File" do
+2 -2
View File
@@ -478,11 +478,11 @@ np.array([[2,2],[1,3]],np.float)
test "sequence diagram blocks" do
content = "a\n\n{{{default\nalice->bob: Test\n}}}\n\nb"
output = /.*<img src="http:\/\/www\.websequencediagrams\.com\/\?img=\w{9}" \/>.*/
index = @wiki.repo.index
index.add("Bilbo-Baggins.md", content)
index.commit("Add sequence diagram")
page = @wiki.page("Bilbo Baggins")
rendered = Gollum::Markup.new(page).render
assert_not_nil rendered.match(output)
+5 -5
View File
@@ -25,7 +25,7 @@ context "Page" do
test "get existing page case insensitive" do
assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('bilbo baggins').path
end
test "get existing page with hyphen" do
assert_equal @wiki.page('Bilbo Baggins').path, @wiki.page('Bilbo-Baggins').path
end
@@ -33,19 +33,19 @@ context "Page" do
test "get existing page with underscore" do
assert_nil @wiki.page('Bilbo_Baggins')
end
test "get existing page where filename contains whitespace, with hypen" do
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise-Gamgee').path
end
test "get existing page where filename contains whitespace, with underscore" do
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise_Gamgee').path
end
test "get existing page where filename contains whitespace, with whitespace" do
assert_equal @wiki.page('Samwise Gamgee').path, @wiki.page('Samwise Gamgee').path
end
test "get nested page" do
page = @wiki.page('Eye Of Sauron')
assert_equal 'Mordor/Eye-Of-Sauron.md', page.path
+9 -9
View File
@@ -237,7 +237,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do
@path = cloned_testpath("examples/lotr.git")
@wiki = Gollum::Wiki.new(@path)
end
test "update_page" do
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
@@ -249,7 +249,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do
assert_equal "h1. Samwise Gamgee2", @wiki.page("Samwise Gamgee").raw_data
assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename
end
test "update page with format change, verify non-canonicalization of filename, where filename contains Whitespace" do
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
@@ -261,7 +261,7 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do
assert_equal "h1. Samwise Gamgee", @wiki.page("Samwise Gamgee").raw_data
assert_equal "Samwise Gamgee.textile", @wiki.page("Samwise Gamgee").filename
end
test "update page with name change, verify canonicalization of filename, where filename contains Whitespace" do
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
@@ -269,10 +269,10 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do
page = @wiki.page("Samwise Gamgee")
@wiki.update_page(page, 'Sam Gamgee', :textile, "h1. Samwise Gamgee", commit_details)
assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data
assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data
assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename
end
test "update page with name and format change, verify canonicalization of filename, where filename contains Whitespace" do
assert_equal :mediawiki, @wiki.page("Samwise Gamgee").format
assert_equal "Samwise Gamgee.mediawiki", @wiki.page("Samwise Gamgee").filename
@@ -283,8 +283,8 @@ context "Wiki page writing with whitespace (filename contains whitespace)" do
assert_equal :textile, @wiki.page("Sam Gamgee").format
assert_equal "h1. Samwise Gamgee", @wiki.page("Sam Gamgee").raw_data
assert_equal "Sam-Gamgee.textile", @wiki.page("Sam Gamgee").filename
end
end
teardown do
FileUtils.rm_rf(@path)
end
@@ -382,7 +382,7 @@ context "Wiki sync with working directory (filename contains whitespace)" do
@wiki.delete_page(page, commit_details)
assert !File.exist?(File.join(@path, "Samwise Gamgee.mediawiki"))
end
teardown do
FileUtils.rm_r(@path)
end
@@ -401,7 +401,7 @@ context "page_file_dir option" do
assert_equal "Hi", File.read(File.join(@path, @page_file_dir, "New-Page.md"))
assert !File.exist?(File.join(@path, "New-Page.md"))
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)