Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b952b6d56 | |||
| 90cc512bd1 | |||
| b82556c9c0 | |||
| fbe3b4bb3b | |||
| 5ffd98ad31 | |||
| cb9dd4d228 | |||
| cd823bf10c | |||
| 5560ec52c2 | |||
| 065151a77f | |||
| 23454f556c | |||
| a2b3ddf931 | |||
| 44b0d2fcfc | |||
| aed4cc590a | |||
| 72ee08b5ab | |||
| 45547624e4 | |||
| f928cfa8be | |||
| 988984846a | |||
| 1149618653 | |||
| 168a033903 | |||
| 6a765c9791 | |||
| e16ae7b511 | |||
| 174334ea44 | |||
| dbdf06930d | |||
| c93e65ddc3 | |||
| 56101ed264 | |||
| 8269c8e574 | |||
| 2246419d1e | |||
| 118a0c318b | |||
| 5401cf2910 | |||
| 432f9b8d2f | |||
| 66fc8a2d31 | |||
| 2f3dd3d227 | |||
| c43fd9fa6c | |||
| 868518e0f5 | |||
| 039b5cce98 | |||
| 4a421842d5 | |||
| cfbb124f81 | |||
| dcb147cde2 | |||
| 8d06b5e67e | |||
| 4776d0b422 | |||
| 58bb340c33 | |||
| ee790a9b7c | |||
| ac432aad78 | |||
| 30207e0a39 | |||
| d98547a33c | |||
| b7cdeabbf6 |
+2
-2
@@ -4,5 +4,5 @@ rvm:
|
|||||||
notifications:
|
notifications:
|
||||||
disabled: true
|
disabled: true
|
||||||
before_install:
|
before_install:
|
||||||
- gem uninstall ffi -a
|
- sudo apt-get update
|
||||||
- sudo apt-get install -y asciidoc
|
- sudo apt-get install -y --force-yes asciidoc
|
||||||
@@ -295,7 +295,7 @@ This is useful for writing about the link syntax in your wiki pages.
|
|||||||
|
|
||||||
Gollum has a special tag to insert a table of contents (new in v2.1)
|
Gollum has a special tag to insert a table of contents (new in v2.1)
|
||||||
|
|
||||||
'[[_TOC_]]
|
[[_TOC_]]
|
||||||
|
|
||||||
This tag is case sensitive, use all upper case. The TOC tag can be inserted
|
This tag is case sensitive, use all upper case. The TOC tag can be inserted
|
||||||
into the `_Header`, `_Footer` or `_Sidebar` files too.
|
into the `_Header`, `_Footer` or `_Sidebar` files too.
|
||||||
@@ -413,6 +413,14 @@ By default, internal wiki links are all absolute from the root. To specify a dif
|
|||||||
|
|
||||||
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
wiki = Gollum::Wiki.new("my-gollum-repo.git", :base_path => "/wiki")
|
||||||
|
|
||||||
|
Note that base_path just modifies the links. To map gollum to a non-root location, use `map` in config.ru. See [#532](https://github.com/github/gollum/issues/532).
|
||||||
|
|
||||||
|
> :base_path - String base path for all Wiki links.
|
||||||
|
>
|
||||||
|
> The String base path to prefix to internal links. For example, when set
|
||||||
|
> to "/wiki", the page "Hobbit" will be linked as "/wiki/Hobbit". Defaults
|
||||||
|
> to "/".
|
||||||
|
|
||||||
Get the latest version of the given human or canonical page name:
|
Get the latest version of the given human or canonical page name:
|
||||||
|
|
||||||
page = wiki.page('page-name')
|
page = wiki.page('page-name')
|
||||||
@@ -547,12 +555,14 @@ your changes merged back into core is as follows:
|
|||||||
1. Send a pull request to the github/gollum project.
|
1. Send a pull request to the github/gollum project.
|
||||||
|
|
||||||
## RELEASING
|
## RELEASING
|
||||||
|
For z releases:
|
||||||
|
$ rake bump
|
||||||
|
$ rake release
|
||||||
|
|
||||||
|
For x.y releases:
|
||||||
Update VERSION in lib/gollum.rb
|
Update VERSION in lib/gollum.rb
|
||||||
$ rake gemspec
|
$ rake gemspec
|
||||||
$ git tag vX.Y.Z
|
$ rake release
|
||||||
$ git push origin vX.Y.Z
|
|
||||||
$ gem build gollum.gemspec
|
|
||||||
$ gem push gollum-X.Y.Z.gem
|
|
||||||
|
|
||||||
## BUILDING THE GEM FROM MASTER
|
## BUILDING THE GEM FROM MASTER
|
||||||
$ gem uninstall -aIx gollum
|
$ gem uninstall -aIx gollum
|
||||||
|
|||||||
@@ -17,6 +17,27 @@ def version
|
|||||||
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# assumes x.y.z all digit version
|
||||||
|
def next_version
|
||||||
|
# x.y.z
|
||||||
|
v = version.split '.'
|
||||||
|
# bump z
|
||||||
|
v[-1] = v[-1].to_i + 1
|
||||||
|
v.join '.'
|
||||||
|
end
|
||||||
|
|
||||||
|
def bump_version
|
||||||
|
old_file = File.read("lib/#{name}.rb")
|
||||||
|
old_version_line = old_file[/^\s*VERSION\s*=\s*.*/]
|
||||||
|
new_version = next_version
|
||||||
|
# replace first match of old vesion with new version
|
||||||
|
old_file.sub!(old_version_line, " VERSION = '#{new_version}'")
|
||||||
|
|
||||||
|
File.write("lib/#{name}.rb", old_file)
|
||||||
|
|
||||||
|
new_version
|
||||||
|
end
|
||||||
|
|
||||||
def date
|
def date
|
||||||
Date.today.to_s
|
Date.today.to_s
|
||||||
end
|
end
|
||||||
@@ -71,7 +92,14 @@ end
|
|||||||
#
|
#
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
desc "Update version number and gemspec"
|
||||||
|
task :bump do
|
||||||
|
puts "Updated version to #{bump_version}"
|
||||||
|
# Execute does not invoke dependencies.
|
||||||
|
# Manually invoke gemspec then validate.
|
||||||
|
Rake::Task[:gemspec].execute
|
||||||
|
Rake::Task[:validate].execute
|
||||||
|
end
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
#
|
#
|
||||||
@@ -117,7 +145,7 @@ task :gemspec => :validate do
|
|||||||
split("\n").
|
split("\n").
|
||||||
sort.
|
sort.
|
||||||
reject { |file| file =~ /^\./ }.
|
reject { |file| file =~ /^\./ }.
|
||||||
reject { |file| file =~ /^(rdoc|pkg|test)/ }.
|
reject { |file| file =~ /^(rdoc|pkg|test|Home\.md)/ }.
|
||||||
map { |file| " #{file}" }.
|
map { |file| " #{file}" }.
|
||||||
join("\n")
|
join("\n")
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|||||||
s.required_ruby_version = ">= 1.8.7"
|
s.required_ruby_version = ">= 1.8.7"
|
||||||
|
|
||||||
s.name = 'gollum'
|
s.name = 'gollum'
|
||||||
s.version = '2.2.2'
|
s.version = '2.2.7'
|
||||||
s.date = '2012-10-04'
|
s.date = '2012-10-14'
|
||||||
s.rubyforge_project = 'gollum'
|
s.rubyforge_project = 'gollum'
|
||||||
|
|
||||||
s.summary = "A simple, Git-powered wiki."
|
s.summary = "A simple, Git-powered wiki."
|
||||||
@@ -47,7 +47,6 @@ Gem::Specification.new do |s|
|
|||||||
s.files = %w[
|
s.files = %w[
|
||||||
Gemfile
|
Gemfile
|
||||||
HISTORY.md
|
HISTORY.md
|
||||||
Home.md
|
|
||||||
LICENSE
|
LICENSE
|
||||||
README.md
|
README.md
|
||||||
Rakefile
|
Rakefile
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ require File.expand_path('../gollum/web_sequence_diagram', __FILE__)
|
|||||||
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
require File.expand_path('../gollum/frontend/uri_encode_component', __FILE__)
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
VERSION = '2.2.2'
|
VERSION = '2.2.7'
|
||||||
|
|
||||||
def self.assets_path
|
def self.assets_path
|
||||||
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ module Precious
|
|||||||
end
|
end
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
redirect File.join(settings.wiki_options[:base_path].to_s, 'Home')
|
redirect File.join(settings.wiki_options[:page_file_dir].to_s,settings.wiki_options[:base_path].to_s, 'Home')
|
||||||
end
|
end
|
||||||
|
|
||||||
# path is set to name if path is nil.
|
# path is set to name if path is nil.
|
||||||
@@ -145,6 +145,7 @@ module Precious
|
|||||||
page_name = CGI.unescape(params[:page])
|
page_name = CGI.unescape(params[:page])
|
||||||
wiki = wiki_new
|
wiki = wiki_new
|
||||||
page = wiki.paged(page_name, path, exact = true)
|
page = wiki.paged(page_name, path, exact = true)
|
||||||
|
return if page.nil?
|
||||||
rename = params[:rename].to_url if params[:rename]
|
rename = params[:rename].to_url if params[:rename]
|
||||||
name = rename || page.name
|
name = rename || page.name
|
||||||
committer = Gollum::Committer.new(wiki, commit_message)
|
committer = Gollum::Committer.new(wiki, commit_message)
|
||||||
@@ -190,13 +191,20 @@ module Precious
|
|||||||
path = '' if path.nil?
|
path = '' if path.nil?
|
||||||
format = params[:format].intern
|
format = params[:format].intern
|
||||||
|
|
||||||
|
page_dir = File.join(settings.wiki_options[:page_file_dir].to_s,
|
||||||
|
settings.wiki_options[:base_path].to_s)
|
||||||
|
# Home is a special case.
|
||||||
|
path = '' if name.downcase == 'home'
|
||||||
|
|
||||||
|
page_dir = File.join(page_dir, path)
|
||||||
|
|
||||||
# write_page is not directory aware so use wiki_options to emulate dir support.
|
# write_page is not directory aware so use wiki_options to emulate dir support.
|
||||||
wiki_options = settings.wiki_options.merge({ :page_file_dir => path })
|
wiki_options = settings.wiki_options.merge({ :page_file_dir => page_dir })
|
||||||
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
wiki.write_page(name, format, params[:content], commit_message)
|
wiki.write_page(name, format, params[:content], commit_message)
|
||||||
redirect to("/#{clean_url(CGI.escape(::File.join(path,name)))}")
|
redirect to("/#{clean_url(CGI.escape(::File.join(page_dir,name)))}")
|
||||||
rescue Gollum::DuplicatePageError => e
|
rescue Gollum::DuplicatePageError => e
|
||||||
@message = "Duplicate page: #{e.message}"
|
@message = "Duplicate page: #{e.message}"
|
||||||
mustache :error
|
mustache :error
|
||||||
|
|||||||
@@ -23,5 +23,12 @@ module Precious
|
|||||||
return url if url.nil?
|
return url if url.nil?
|
||||||
url.gsub('%2F','/').gsub(/^\/+/,'')
|
url.gsub('%2F','/').gsub(/^\/+/,'')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def trim_leading_slash url
|
||||||
|
return url if url.nil?
|
||||||
|
url.gsub!('%2F','/')
|
||||||
|
return '/' + url.gsub(/^\/+/,'') if url[0,1] == '/'
|
||||||
|
url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -194,13 +194,14 @@ var previewSet = function( text ) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 'c', 'c++', 'cpp' are github specific and transformed to c_cpp for Ace.
|
// See pygmentsLanguageToAceMode for pygment to ace mode translations.
|
||||||
var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee', 'coldfusion',
|
// TODO: Update languages and translation once Ace is upgraded to v1.0.
|
||||||
'csharp', 'css', 'diff', 'golang', 'groovy', 'haxe', 'html',
|
var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee',
|
||||||
'java', 'javascript', 'json', 'latex', 'less', 'liquid',
|
'coffeescript', 'coldfusion', 'csharp', 'css', 'diff', 'golang',
|
||||||
'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php', 'powershell',
|
'groovy', 'haxe', 'html', 'java', 'javascript', 'json', 'latex',
|
||||||
'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql', 'svg',
|
'less', 'liquid', 'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php',
|
||||||
'textile', 'text', 'xml', 'xquery', 'yaml' ];
|
'powershell', 'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql',
|
||||||
|
'svg', 'textile', 'text', 'xml', 'xquery', 'yaml' ];
|
||||||
|
|
||||||
var staticHighlight = require( 'ace/ext/static_highlight' );
|
var staticHighlight = require( 'ace/ext/static_highlight' );
|
||||||
var githubTheme = require( 'ace/theme/github' );
|
var githubTheme = require( 'ace/theme/github' );
|
||||||
@@ -243,6 +244,31 @@ function highlight( element, language ) {
|
|||||||
element.parentNode.parentNode.replaceChild( newDiv, element.parentNode );
|
element.parentNode.parentNode.replaceChild( newDiv, element.parentNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pygments and Ace have different names for languages.
|
||||||
|
function pygmentsLanguageToAceMode( declaredLanguage ) {
|
||||||
|
declaredLanguage = declaredLanguage.toLowerCase();
|
||||||
|
|
||||||
|
switch ( declaredLanguage ) {
|
||||||
|
case 'bash':
|
||||||
|
return 'sh';
|
||||||
|
case 'c':
|
||||||
|
case 'c++':
|
||||||
|
case 'cpp':
|
||||||
|
case 'objective-c':
|
||||||
|
return 'c_cpp';
|
||||||
|
case 'c#':
|
||||||
|
return 'csharp';
|
||||||
|
case 'coffeescript':
|
||||||
|
return 'coffee';
|
||||||
|
case 'html+erb':
|
||||||
|
return 'html'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume language name is the same
|
||||||
|
// if it's not handled above.
|
||||||
|
return declaredLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
var makePreviewHtml = function () {
|
var makePreviewHtml = function () {
|
||||||
var text = editorSession.getValue();
|
var text = editorSession.getValue();
|
||||||
|
|
||||||
@@ -293,15 +319,7 @@ var makePreviewHtml = function () {
|
|||||||
// the syntax for code highlighting means all code, even one line, contains newlines.
|
// the syntax for code highlighting means all code, even one line, contains newlines.
|
||||||
if ( txt.length > 1 && codeHTML.match( /\n/ ) ) {
|
if ( txt.length > 1 && codeHTML.match( /\n/ ) ) {
|
||||||
var declaredLanguage = element.className.toLowerCase();
|
var declaredLanguage = element.className.toLowerCase();
|
||||||
var aceMode = declaredLanguage;
|
var aceMode = pygmentsLanguageToAceMode( declaredLanguage );
|
||||||
|
|
||||||
// GitHub supports 'c', 'c++', 'cpp'
|
|
||||||
// which must trigger the 'c_cpp' mode in Ace.
|
|
||||||
if ( declaredLanguage === 'c' ||
|
|
||||||
declaredLanguage === 'c++' ||
|
|
||||||
declaredLanguage === 'cpp' ) {
|
|
||||||
aceMode = 'c_cpp';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $.inArray( declaredLanguage, languages ) === -1 ) {
|
if ( $.inArray( declaredLanguage, languages ) === -1 ) {
|
||||||
// Unsupported language.
|
// Unsupported language.
|
||||||
|
|||||||
+39
-10
@@ -76,7 +76,7 @@ module Gollum
|
|||||||
doc,toc = process_headers(doc)
|
doc,toc = process_headers(doc)
|
||||||
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
|
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
|
||||||
yield doc if block_given?
|
yield doc if block_given?
|
||||||
data = doc.to_html
|
data = doc.to_xhtml
|
||||||
|
|
||||||
data = process_toc_tags(data)
|
data = process_toc_tags(data)
|
||||||
data = process_tex(data)
|
data = process_tex(data)
|
||||||
@@ -95,16 +95,12 @@ module Gollum
|
|||||||
def process_headers(doc)
|
def process_headers(doc)
|
||||||
toc = nil
|
toc = nil
|
||||||
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
|
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
|
||||||
id = encodeURIComponent(h.content.gsub(' ','-'))
|
h_name = h.content.gsub(' ','-')
|
||||||
|
|
||||||
level = h.name.gsub(/[hH]/,'').to_i
|
level = h.name.gsub(/[hH]/,'').to_i
|
||||||
|
|
||||||
# Add anchors
|
# Add anchors
|
||||||
anchor = Nokogiri::XML::Node.new('a', doc)
|
h.add_child(%Q{<a class="anchor" id="#{h_name}" href="##{h_name}"></a>})
|
||||||
anchor['class'] = 'anchor'
|
|
||||||
anchor['id'] = id
|
|
||||||
# % -> %25 so anchors work on Firefox. See issue #475
|
|
||||||
anchor['href'] = '#' + id.gsub('%', '%25')
|
|
||||||
h.add_child(anchor)
|
|
||||||
|
|
||||||
# Build TOC
|
# Build TOC
|
||||||
toc ||= Nokogiri::XML::DocumentFragment.parse('<div class="toc"><div class="toc-title">Table of Contents</div></div>')
|
toc ||= Nokogiri::XML::DocumentFragment.parse('<div class="toc"><div class="toc-title">Table of Contents</div></div>')
|
||||||
@@ -122,7 +118,7 @@ module Gollum
|
|||||||
end
|
end
|
||||||
node = Nokogiri::XML::Node.new('li', doc)
|
node = Nokogiri::XML::Node.new('li', doc)
|
||||||
# % -> %25 so anchors work on Firefox. See issue #475
|
# % -> %25 so anchors work on Firefox. See issue #475
|
||||||
node.add_child("<a href='##{id.gsub('%', '%25')}'>#{h.content}</a>")
|
node.add_child(%Q{<a href="##{h_name}">#{h.content}</a>})
|
||||||
tail.add_child(node)
|
tail.add_child(node)
|
||||||
end
|
end
|
||||||
toc = toc.to_xhtml if toc != nil
|
toc = toc.to_xhtml if toc != nil
|
||||||
@@ -407,6 +403,12 @@ module Gollum
|
|||||||
presence = "present"
|
presence = "present"
|
||||||
end
|
end
|
||||||
link = ::File.join(@wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name))
|
link = ::File.join(@wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name))
|
||||||
|
|
||||||
|
# //page is invalid
|
||||||
|
# strip all duplicate forward slashes using helpers.rb trim_leading_slash
|
||||||
|
# //page => /page
|
||||||
|
link = trim_leading_slash link
|
||||||
|
|
||||||
%{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
|
%{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -505,6 +507,33 @@ module Gollum
|
|||||||
#
|
#
|
||||||
# Returns the placeholder'd String data.
|
# Returns the placeholder'd String data.
|
||||||
def extract_code(data)
|
def extract_code(data)
|
||||||
|
data.gsub!(/^([ \t]*)(~~~+) ?([^\r\n]+)?\r?\n(.+?)\r?\n\1(~~~+)\r?$/m) do
|
||||||
|
m_indent = $1
|
||||||
|
m_start = $2 # ~~~
|
||||||
|
m_lang = $3
|
||||||
|
m_code = $4
|
||||||
|
m_end = $5 # ~~~
|
||||||
|
|
||||||
|
# start and finish tilde fence must be the same length
|
||||||
|
return '' if m_start.length != m_end.length
|
||||||
|
|
||||||
|
lang = m_lang ? m_lang.strip : nil
|
||||||
|
id = Digest::SHA1.hexdigest("#{lang}.#{m_code}")
|
||||||
|
cached = check_cache(:code, id)
|
||||||
|
|
||||||
|
# extract lang from { .ruby } or { #stuff .ruby .indent }
|
||||||
|
# see http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
|
||||||
|
|
||||||
|
lang = lang.match(/\.([^}\s]+)/)
|
||||||
|
lang = lang[1] unless lang.nil?
|
||||||
|
|
||||||
|
@codemap[id] = cached ?
|
||||||
|
{ :output => cached } :
|
||||||
|
{ :lang => lang, :code => m_code, :indent => m_indent }
|
||||||
|
|
||||||
|
"#{m_indent}#{id}" # print the SHA1 ID with the proper indentation
|
||||||
|
end
|
||||||
|
|
||||||
data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```\r?$/m) do
|
data.gsub!(/^([ \t]*)``` ?([^\r\n]+)?\r?\n(.+?)\r?\n\1```\r?$/m) do
|
||||||
lang = $2 ? $2.strip : nil
|
lang = $2 ? $2.strip : nil
|
||||||
id = Digest::SHA1.hexdigest("#{lang}.#{$3}")
|
id = Digest::SHA1.hexdigest("#{lang}.#{$3}")
|
||||||
@@ -558,7 +587,7 @@ module Gollum
|
|||||||
encoding ||= 'utf-8'
|
encoding ||= 'utf-8'
|
||||||
begin
|
begin
|
||||||
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
|
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
|
||||||
rescue ::RubyPython::PythonError
|
rescue
|
||||||
hl_code = code
|
hl_code = code
|
||||||
end
|
end
|
||||||
highlighted << hl_code
|
highlighted << hl_code
|
||||||
|
|||||||
+5
-1
@@ -184,7 +184,7 @@ context "Frontend" do
|
|||||||
name = "A"
|
name = "A"
|
||||||
post "/create", :content => 'abc', :page => name,
|
post "/create", :content => 'abc', :page => name,
|
||||||
:format => 'markdown', :message => 'def'
|
:format => 'markdown', :message => 'def'
|
||||||
follow_redirect!
|
|
||||||
assert last_response.ok?
|
assert last_response.ok?
|
||||||
|
|
||||||
@wiki.clear_cache
|
@wiki.clear_cache
|
||||||
@@ -273,6 +273,9 @@ context "Frontend" do
|
|||||||
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
|
Precious::App.set(:wiki_options, { :base_path => '/wiki/' })
|
||||||
get "/"
|
get "/"
|
||||||
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
assert_match "http://example.org/wiki/Home", last_response.headers['Location']
|
||||||
|
|
||||||
|
# Reset base path
|
||||||
|
Precious::App.set(:wiki_options, { :base_path => nil })
|
||||||
end
|
end
|
||||||
|
|
||||||
test "author details in session are used" do
|
test "author details in session are used" do
|
||||||
@@ -377,6 +380,7 @@ context "Frontend with lotr" do
|
|||||||
test "edit pages within sub-directories" do
|
test "edit pages within sub-directories" do
|
||||||
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
post "/create", :content => 'big smelly creatures', :page => 'Orc',
|
||||||
:path => 'Mordor', :format => 'markdown', :message => 'oooh, scary'
|
: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',
|
post "/edit/Mordor/Orc", :content => 'not so big smelly creatures',
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ context "gitcode" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'that the rendered output is correctly fetched and rendered as html code' do
|
test 'that the rendered output is correctly fetched and rendered as html code' do
|
||||||
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"nt\"><ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">><a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">></span>0<span class=\"nt\"></a></li></span>\n<span class=\"nt\"></ol></span>\n</pre></div>\n\n<p>b</p>}, @rendered
|
assert_equal %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"nt\"><ol</span> <span class=\"na\">class=</span><span class=\"s\">\"tree\"</span><span class=\"nt\">></span>\n <span class=\"nt\"><li</span> <span class=\"na\">class=</span><span class=\"s\">\"file\"</span><span class=\"nt\">><a</span> <span class=\"na\">href=</span><span class=\"s\">\"0\"</span><span class=\"nt\">></span>0<span class=\"nt\"></a></li></span>\n<span class=\"nt\"></ol></span>\n</pre>\n</div>\n\n<p>b</p>}, @rendered
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'contents' do
|
test 'contents' do
|
||||||
|
|||||||
+87
-27
@@ -55,6 +55,21 @@ context "Markup" do
|
|||||||
#
|
#
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
|
test "absolute link to non-existent page" do
|
||||||
|
@wiki.write_page("linktest", :markdown, "[[/Page]]", commit_details)
|
||||||
|
|
||||||
|
page = @wiki.page("linktest")
|
||||||
|
doc = Nokogiri::HTML page.formatted_data
|
||||||
|
paras = doc / :p
|
||||||
|
para = paras.first
|
||||||
|
anchors = para / :a
|
||||||
|
assert_equal 1, paras.size
|
||||||
|
assert_equal 1, anchors.size
|
||||||
|
assert_equal 'internal absent', anchors[0]['class']
|
||||||
|
assert_equal '/Page', anchors[0]['href']
|
||||||
|
assert_equal '/Page', anchors[0].text
|
||||||
|
end
|
||||||
|
|
||||||
test "double page links no space" do
|
test "double page links no space" do
|
||||||
@wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details)
|
@wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details)
|
||||||
|
|
||||||
@@ -178,7 +193,7 @@ context "Markup" do
|
|||||||
test "wiki link within inline code block" do
|
test "wiki link within inline code block" do
|
||||||
@wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details)
|
@wiki.write_page("Potato", :markdown, "`sed -i '' 's/[[:space:]]*$//'`", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
assert_equal "<p><code>sed -i '' 's/[[:space:]]*$//'</code></p>", page.formatted_data
|
assert_equal "<p>\n <code>sed -i '' 's/[[:space:]]*$//'</code>\n</p>", page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "regexp gsub! backref (#383)" do
|
test "regexp gsub! backref (#383)" do
|
||||||
@@ -193,20 +208,57 @@ context "Markup" do
|
|||||||
DATA
|
DATA
|
||||||
), commit_details)
|
), commit_details)
|
||||||
output = @wiki.page(page).formatted_data
|
output = @wiki.page(page).formatted_data
|
||||||
expected = %Q{<pre><code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code></pre>}.strip # remove trailing \n
|
expected = %Q{<pre>\n <code> <div class=\"highlight\"><pre><span class=\"n\">rot13</span><span class=\"p\">=</span><span class=\"s\">'tr '</span><span class=\"o\">\\</span><span class=\"s\">''</span><span class=\"n\">A</span><span class=\"o\">-</span><span class=\"n\">Za</span><span class=\"o\">-</span><span class=\"n\">z</span><span class=\"o\">'\\</span><span class=\"s\">''</span> <span class=\"s\">'\\''N-ZA-Mn-za-m'</span><span class=\"o\">\\</span><span class=\"s\">'</span>\n</pre></div>\n</code>\n</pre>}
|
||||||
|
assert_equal expected, output
|
||||||
|
end
|
||||||
|
|
||||||
|
test "~~~ code blocks #537" do
|
||||||
|
page = 'test_rgx'
|
||||||
|
@wiki.write_page(page, :markdown,
|
||||||
|
%Q(~~~ {.ruby}
|
||||||
|
'hi'
|
||||||
|
~~~
|
||||||
|
), commit_details)
|
||||||
|
output = @wiki.page(page).formatted_data
|
||||||
|
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
||||||
|
assert_equal expected, output
|
||||||
|
end
|
||||||
|
|
||||||
|
test "~~~ code blocks #537 with more than one class" do
|
||||||
|
page = 'test_rgx'
|
||||||
|
@wiki.write_page(page, :markdown,
|
||||||
|
%Q(~~~ {#hi .ruby .sauce}
|
||||||
|
'hi'
|
||||||
|
~~~
|
||||||
|
), commit_details)
|
||||||
|
output = @wiki.page(page).formatted_data
|
||||||
|
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"s1\">'hi'</span>\n</pre>\n</div>}
|
||||||
|
assert_equal expected, output
|
||||||
|
end
|
||||||
|
|
||||||
|
test "~~~ code blocks #537 with lots of tildes" do
|
||||||
|
page = 'test_rgx'
|
||||||
|
@wiki.write_page(page, :markdown,
|
||||||
|
%Q(~~~~~~ {#hi .ruby .sauce}
|
||||||
|
~~
|
||||||
|
'hi'~
|
||||||
|
~~~~~~
|
||||||
|
), commit_details)
|
||||||
|
output = @wiki.page(page).formatted_data
|
||||||
|
expected = %Q{<div class=\"highlight\">\n <pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre>\n</div>}
|
||||||
assert_equal expected, output
|
assert_equal expected, output
|
||||||
end
|
end
|
||||||
|
|
||||||
test "wiki link within code block" do
|
test "wiki link within code block" do
|
||||||
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
assert_equal "<pre><code>sed -i '' 's/[[:space:]]*$//'\n</code></pre>", page.formatted_data
|
assert_equal "<pre>\n <code>sed -i '' 's/[[:space:]]*$//'\n</code>\n</pre>", page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "piped wiki link within code block" do
|
test "piped wiki link within code block" do
|
||||||
@wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details)
|
@wiki.write_page("Potato", :markdown, "`make a link [[home|sweet home]]`", commit_details)
|
||||||
page = @wiki.page("Potato")
|
page = @wiki.page("Potato")
|
||||||
assert_equal "<p><code>make a link [[home|sweet home]]</code></p>", page.formatted_data
|
assert_equal "<p>\n <code>make a link [[home|sweet home]]</code>\n</p>", page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
@@ -222,7 +274,7 @@ context "Markup" do
|
|||||||
|
|
||||||
page = @wiki.page(name)
|
page = @wiki.page(name)
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal %{<p>a <img src="#{scheme}://example.com/bilbo.jpg"> b</p>}, output
|
assert_equal %{<p>a <img src=\"#{scheme}://example.com/bilbo.jpg\" /> b</p>}, output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -233,7 +285,7 @@ context "Markup" do
|
|||||||
|
|
||||||
page = @wiki.page(name)
|
page = @wiki.page(name)
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal %{<p>a <img src="#{scheme}://example.com/bilbo.JPG"> b</p>}, output
|
assert_equal %{<p>a <img src=\"#{scheme}://example.com/bilbo.JPG\" /> b</p>}, output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -245,7 +297,7 @@ context "Markup" do
|
|||||||
@wiki.write_page("Bilbo Baggins", :markdown, "a [[/alpha.jpg]] [[a | /alpha.jpg]] b", commit_details)
|
@wiki.write_page("Bilbo Baggins", :markdown, "a [[/alpha.jpg]] [[a | /alpha.jpg]] b", commit_details)
|
||||||
|
|
||||||
page = @wiki.page("Bilbo Baggins")
|
page = @wiki.page("Bilbo Baggins")
|
||||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"><a href="/wiki/alpha.jpg">a</a> b</p>}, page.formatted_data
|
assert_equal %{<p>a <img src=\"/wiki/alpha.jpg\" /><a href=\"/wiki/alpha.jpg\">a</a> b</p>}, page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with relative path on root" do
|
test "image with relative path on root" do
|
||||||
@@ -256,7 +308,7 @@ context "Markup" do
|
|||||||
index.commit("Add alpha.jpg")
|
index.commit("Add alpha.jpg")
|
||||||
|
|
||||||
page = @wiki.page("Bilbo Baggins")
|
page = @wiki.page("Bilbo Baggins")
|
||||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"><a href="/wiki/alpha.jpg">a</a> b</p>}, page.formatted_data
|
assert_equal %Q{<p>a <img src=\"/wiki/alpha.jpg\" /><a href=\"/wiki/alpha.jpg\">a</a> b</p>}, page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with relative path" do
|
test "image with relative path" do
|
||||||
@@ -268,7 +320,7 @@ context "Markup" do
|
|||||||
|
|
||||||
page = @wiki.page("Bilbo Baggins")
|
page = @wiki.page("Bilbo Baggins")
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal %{<p>a <img src="/wiki/greek/alpha.jpg"><a href="/wiki/greek/alpha.jpg">a</a> b</p>}, output
|
assert_equal %{<p>a <img src=\"/wiki/greek/alpha.jpg\" /><a href=\"/wiki/greek/alpha.jpg\">a</a> b</p>}, output
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with absolute path on a preview" do
|
test "image with absolute path on a preview" do
|
||||||
@@ -278,7 +330,7 @@ context "Markup" do
|
|||||||
index.commit("Add alpha.jpg")
|
index.commit("Add alpha.jpg")
|
||||||
|
|
||||||
page = @wiki.preview_page("Test", "a [[/alpha.jpg]] b", :markdown)
|
page = @wiki.preview_page("Test", "a [[/alpha.jpg]] b", :markdown)
|
||||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"> b</p>}, page.formatted_data
|
assert_equal %{<p>a <img src=\"/wiki/alpha.jpg\" /> b</p>}, page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with relative path on a preview" do
|
test "image with relative path on a preview" do
|
||||||
@@ -289,12 +341,12 @@ context "Markup" do
|
|||||||
index.commit("Add alpha.jpg")
|
index.commit("Add alpha.jpg")
|
||||||
|
|
||||||
page = @wiki.preview_page("Test", "a [[alpha.jpg]] [[greek/alpha.jpg]] b", :markdown)
|
page = @wiki.preview_page("Test", "a [[alpha.jpg]] [[greek/alpha.jpg]] b", :markdown)
|
||||||
assert_equal %{<p>a <img src="/wiki/alpha.jpg"><img src="/wiki/greek/alpha.jpg"> b</p>}, page.formatted_data
|
assert_equal %{<p>a <img src=\"/wiki/alpha.jpg\" /><img src=\"/wiki/greek/alpha.jpg\" /> b</p>}, page.formatted_data
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with alt" do
|
test "image with alt" do
|
||||||
content = "a [[alpha.jpg|alt=Alpha Dog]] b"
|
content = "a [[alpha.jpg|alt=Alpha Dog]] b"
|
||||||
output = %{<p>a <img src="/greek/alpha.jpg" alt="Alpha Dog"> b</p>}
|
output = %{<p>a<imgsrc=\"/greek/alpha.jpg\"alt=\"AlphaDog\"/>b</p>}
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -302,7 +354,7 @@ context "Markup" do
|
|||||||
%w{em px}.each do |unit|
|
%w{em px}.each do |unit|
|
||||||
%w{width height}.each do |dim|
|
%w{width height}.each do |dim|
|
||||||
content = "a [[alpha.jpg|#{dim}=100#{unit}]] b"
|
content = "a [[alpha.jpg|#{dim}=100#{unit}]] b"
|
||||||
output = "<p>a <img src=\"/greek/alpha.jpg\" #{dim}=\"100#{unit}\"> b</p>"
|
output = "<p>a<imgsrc=\"/greek/alpha.jpg\"#{dim}=\"100#{unit}\"/>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -311,7 +363,7 @@ context "Markup" do
|
|||||||
test "image with bogus dimension" do
|
test "image with bogus dimension" do
|
||||||
%w{width height}.each do |dim|
|
%w{width height}.each do |dim|
|
||||||
content = "a [[alpha.jpg|#{dim}=100]] b"
|
content = "a [[alpha.jpg|#{dim}=100]] b"
|
||||||
output = "<p>a <img src=\"/greek/alpha.jpg\"> b</p>"
|
output = "<p>a<imgsrc=\"/greek/alpha.jpg\"/>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -319,7 +371,7 @@ context "Markup" do
|
|||||||
test "image with vertical align" do
|
test "image with vertical align" do
|
||||||
%w{top texttop middle absmiddle bottom absbottom baseline}.each do |align|
|
%w{top texttop middle absmiddle bottom absbottom baseline}.each do |align|
|
||||||
content = "a [[alpha.jpg|align=#{align}]] b"
|
content = "a [[alpha.jpg|align=#{align}]] b"
|
||||||
output = "<p>a <img src=\"/greek/alpha.jpg\" align=\"#{align}\"> b</p>"
|
output = %Q{<p>a<imgsrc=\"/greek/alpha.jpg\"align=\"#{align}\"/>b</p>}
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -327,40 +379,40 @@ context "Markup" do
|
|||||||
test "image with horizontal align" do
|
test "image with horizontal align" do
|
||||||
%w{left center right}.each do |align|
|
%w{left center right}.each do |align|
|
||||||
content = "a [[alpha.jpg|align=#{align}]] b"
|
content = "a [[alpha.jpg|align=#{align}]] b"
|
||||||
output = "<p>a <span class=\"align-#{align}\"><span><img src=\"/greek/alpha.jpg\"></span></span> b</p>"
|
output = "<p>a<spanclass=\"align-#{align}\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with float" do
|
test "image with float" do
|
||||||
content = "a\n\n[[alpha.jpg|float]]\n\nb"
|
content = "a\n\n[[alpha.jpg|float]]\n\nb"
|
||||||
output = "<p>a</p>\n\n<p><span class=\"float-left\"><span><img src=\"/greek/alpha.jpg\"></span></span></p>\n\n<p>b</p>"
|
output = "<p>a</p><p><spanclass=\"float-left\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span></p><p>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with float and align" do
|
test "image with float and align" do
|
||||||
%w{left right}.each do |align|
|
%w{left right}.each do |align|
|
||||||
content = "a\n\n[[alpha.jpg|float|align=#{align}]]\n\nb"
|
content = "a\n\n[[alpha.jpg|float|align=#{align}]]\n\nb"
|
||||||
output = "<p>a</p>\n\n<p><span class=\"float-#{align}\"><span><img src=\"/greek/alpha.jpg\"></span></span></p>\n\n<p>b</p>"
|
output = "<p>a</p><p><spanclass=\"float-#{align}\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span></p><p>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with frame" do
|
test "image with frame" do
|
||||||
content = "a\n\n[[alpha.jpg|frame]]\n\nb"
|
content = "a\n\n[[alpha.jpg|frame]]\n\nb"
|
||||||
output = "<p>a</p>\n\n<p><span class=\"frame\"><span><img src=\"/greek/alpha.jpg\"></span></span></p>\n\n<p>b</p>"
|
output = "<p>a</p><p><spanclass=\"frame\"><span><imgsrc=\"/greek/alpha.jpg\"/></span></span></p><p>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "absolute image with frame" do
|
test "absolute image with frame" do
|
||||||
content = "a\n\n[[http://example.com/bilbo.jpg|frame]]\n\nb"
|
content = "a\n\n[[http://example.com/bilbo.jpg|frame]]\n\nb"
|
||||||
output = "<p>a</p>\n\n<p><span class=\"frame\"><span><img src=\"http://example.com/bilbo.jpg\"></span></span></p>\n\n<p>b</p>"
|
output = "<p>a</p><p><spanclass=\"frame\"><span><imgsrc=\"http://example.com/bilbo.jpg\"/></span></span></p><p>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "image with frame and alt" do
|
test "image with frame and alt" do
|
||||||
content = "a\n\n[[alpha.jpg|frame|alt=Alpha]]\n\nb"
|
content = "a\n\n[[alpha.jpg|frame|alt=Alpha]]\n\nb"
|
||||||
output = "<p>a</p>\n\n<p><span class=\"frame\"><span><img src=\"/greek/alpha.jpg\" alt=\"Alpha\"><span>Alpha</span></span></span></p>\n\n<p>b</p>"
|
output = "<p>a</p><p><spanclass=\"frame\"><span><imgsrc=\"/greek/alpha.jpg\"alt=\"Alpha\"/><span>Alpha</span></span></span></p><p>b</p>"
|
||||||
relative_image(content, output)
|
relative_image(content, output)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -409,7 +461,7 @@ context "Markup" do
|
|||||||
|
|
||||||
test "code blocks" do
|
test "code blocks" do
|
||||||
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
content = "a\n\n```ruby\nx = 1\n```\n\nb"
|
||||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
|
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||||
|
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.md", content)
|
index.add("Bilbo-Baggins.md", content)
|
||||||
@@ -422,7 +474,7 @@ context "Markup" do
|
|||||||
|
|
||||||
test "code blocks with carriage returns" do
|
test "code blocks with carriage returns" do
|
||||||
content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb"
|
content = "a\r\n\r\n```ruby\r\nx = 1\r\n```\r\n\r\nb"
|
||||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre></div>\n\n<p>b</p>}
|
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"mi\">1</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||||
|
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.md", content)
|
index.add("Bilbo-Baggins.md", content)
|
||||||
@@ -453,7 +505,7 @@ context "Markup" do
|
|||||||
|
|
||||||
test "code blocks with multibyte caracters indent" do
|
test "code blocks with multibyte caracters indent" do
|
||||||
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
|
content = "a\n\n```ruby\ns = 'やくしまるえつこ'\n```\n\nb"
|
||||||
output = %Q{<p>a</p>\n\n<div class=\"highlight\"><pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre></div>\n\n<p>b</p>}
|
output = %Q{<p>a</p>\n\n<div class=\"highlight\">\n <pre><span class=\"n\">s</span> <span class=\"o\">=</span> <span class=\"s1\">'やくしまるえつこ'</span>\n</pre>\n</div>\n\n<p>b</p>}
|
||||||
index = @wiki.repo.index
|
index = @wiki.repo.index
|
||||||
index.add("Bilbo-Baggins.md", content)
|
index.add("Bilbo-Baggins.md", content)
|
||||||
index.commit("Add alpha.jpg")
|
index.commit("Add alpha.jpg")
|
||||||
@@ -513,7 +565,7 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
output_page = @wiki.page("page").formatted_data
|
output_page = @wiki.page("page").formatted_data
|
||||||
|
|
||||||
assert_equal %Q{<p>a b</p>}, output_script
|
assert_equal %Q{<p>a b</p>}, output_script
|
||||||
assert_equal %Q{<div class=\"highlight\"><pre><span class=\"nt\"><p></span>a b<span class=\"nt\"></p></span>\n</pre></div>}, output_page
|
assert_equal %Q{<div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a b<span class=\"nt\"></p></span>\n</pre>\n</div>}, output_page
|
||||||
end
|
end
|
||||||
|
|
||||||
test "embed code page absolute link" do
|
test "embed code page absolute link" do
|
||||||
@@ -522,7 +574,7 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
|
|
||||||
page = @wiki.page("a")
|
page = @wiki.page("a")
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!base<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
||||||
end
|
end
|
||||||
|
|
||||||
test "embed code page relative link" do
|
test "embed code page relative link" do
|
||||||
@@ -531,7 +583,15 @@ np.array([[2,2],[1,3]],np.float)
|
|||||||
|
|
||||||
page = @wiki.page("a")
|
page = @wiki.page("a")
|
||||||
output = page.formatted_data
|
output = page.formatted_data
|
||||||
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre></div>\n}, output
|
assert_equal %Q{<p>a\n</p><div class=\"highlight\">\n <pre><span class=\"nt\"><p></span>a\n!rel<span class=\"nt\"></p></span>\n</pre>\n</div>\n}, output
|
||||||
|
end
|
||||||
|
|
||||||
|
test "code block in unsupported language" do
|
||||||
|
@wiki.write_page("a", :markdown, "a\n```nonexistent\ncode\n```\nb", commit_details)
|
||||||
|
|
||||||
|
page = @wiki.page("a")
|
||||||
|
output = page.formatted_data
|
||||||
|
assert_equal %Q{<p>a\ncode\nb</p>}, output
|
||||||
end
|
end
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ context "Page" do
|
|||||||
page = @wiki.page('Bilbo Baggins')
|
page = @wiki.page('Bilbo Baggins')
|
||||||
assert_equal Gollum::Page, page.class
|
assert_equal Gollum::Page, page.class
|
||||||
assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/
|
assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/
|
||||||
assert page.formatted_data =~ %r{<h1>Bilbo Baggins<a class="anchor" id="Bilbo-Baggins" href="#Bilbo-Baggins"></a>\n</h1>\n\n<p>Bilbo Baggins}
|
assert page.formatted_data =~ %r{<h1>Bilbo Baggins<a class="anchor" id="Bilbo-Baggins" href="#Bilbo-Baggins"></a></h1>\n\n<p>Bilbo Baggins}
|
||||||
assert_equal 'Bilbo-Baggins.md', page.path
|
assert_equal 'Bilbo-Baggins.md', page.path
|
||||||
assert_equal :markdown, page.format
|
assert_equal :markdown, page.format
|
||||||
assert_equal @wiki.repo.commits.first.id, page.version.id
|
assert_equal @wiki.repo.commits.first.id, page.version.id
|
||||||
|
|||||||
+24
-7
@@ -29,19 +29,36 @@ context "Unicode Support" do
|
|||||||
assert_equal "# 한글", utf8(page.raw_data)
|
assert_equal "# 한글", utf8(page.raw_data)
|
||||||
|
|
||||||
# markup.rb
|
# markup.rb
|
||||||
# #简介
|
|
||||||
# href.gsub('%', '%25') so the anchor works in Firefox.
|
|
||||||
# <a href="#%25ED%2595%259C%25EA%25B8%2580" id="%ED%95%9C%EA%B8%80" class="anchor"></a>
|
|
||||||
doc = Nokogiri::HTML page.formatted_data
|
doc = Nokogiri::HTML page.formatted_data
|
||||||
h1s = doc / :h1
|
h1s = doc / :h1
|
||||||
h1 = h1s.first
|
h1 = h1s.first
|
||||||
anchors = h1 / :a
|
anchors = h1 / :a
|
||||||
assert_equal 1, h1s.size
|
assert_equal 1, h1s.size
|
||||||
assert_equal 1, anchors.size
|
assert_equal 1, anchors.size
|
||||||
assert_equal '#%25ED%2595%259C%25EA%25B8%2580', anchors[0]['href']
|
assert_equal '#한글', anchors[0]['href']
|
||||||
assert_equal '%ED%95%9C%EA%B8%80', anchors[0]['id']
|
assert_equal '한글', anchors[0]['id']
|
||||||
assert_equal 'anchor', anchors[0]['class']
|
assert_equal 'anchor', anchors[0]['class']
|
||||||
assert_equal '', anchors[0].text
|
assert_equal '', anchors[0].text
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create and read non-latin page with anchor 2" do
|
||||||
|
@wiki.write_page("test", :markdown, "# La faune d'Édiacara")
|
||||||
|
|
||||||
|
page = @wiki.page("test")
|
||||||
|
assert_equal Gollum::Page, page.class
|
||||||
|
assert_equal "# La faune d'Édiacara", utf8(page.raw_data)
|
||||||
|
|
||||||
|
# markup.rb
|
||||||
|
doc = Nokogiri::HTML page.formatted_data
|
||||||
|
h1s = doc / :h1
|
||||||
|
h1 = h1s.first
|
||||||
|
anchors = h1 / :a
|
||||||
|
assert_equal 1, h1s.size
|
||||||
|
assert_equal 1, anchors.size
|
||||||
|
assert_equal %q(#La-faune-d'Édiacara), anchors[0]['href']
|
||||||
|
assert_equal %q(La-faune-d'Édiacara), anchors[0]['id']
|
||||||
|
assert_equal 'anchor', anchors[0]['class']
|
||||||
|
assert_equal '', anchors[0].text
|
||||||
end
|
end
|
||||||
|
|
||||||
test "unicode with existing format rules" do
|
test "unicode with existing format rules" do
|
||||||
|
|||||||
+11
-1
@@ -123,7 +123,7 @@ context "Wiki page previewing" do
|
|||||||
test "preview_page" do
|
test "preview_page" do
|
||||||
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
page = @wiki.preview_page("Test", "# Bilbo", :markdown)
|
||||||
assert_equal "# Bilbo", page.raw_data
|
assert_equal "# Bilbo", page.raw_data
|
||||||
assert_equal %Q{<h1>Bilbo<a class="anchor" id="Bilbo" href="#Bilbo"></a>\n</h1>}, page.formatted_data
|
assert_equal %Q{<h1>Bilbo<a class=\"anchor\" id=\"Bilbo\" href=\"#Bilbo\"></a></h1>}, page.formatted_data
|
||||||
assert_equal "Test.md", page.filename
|
assert_equal "Test.md", page.filename
|
||||||
assert_equal "Test", page.name
|
assert_equal "Test", page.name
|
||||||
end
|
end
|
||||||
@@ -142,6 +142,16 @@ context "Wiki TOC" do
|
|||||||
assert_equal '<h1>Bilbo<a class="anchor" id="Bilbo" href="#Bilbo"></a></h1>', page.formatted_data.gsub(/\n/,"")
|
assert_equal '<h1>Bilbo<a class="anchor" id="Bilbo" href="#Bilbo"></a></h1>', page.formatted_data.gsub(/\n/,"")
|
||||||
assert_equal %{<div class="toc"><div class="toc-title">Table of Contents</div><ul><li><a href="#Bilbo">Bilbo</a></li></ul></div>}, page.toc_data.gsub(/\n */,"")
|
assert_equal %{<div class="toc"><div class="toc-title">Table of Contents</div><ul><li><a href="#Bilbo">Bilbo</a></li></ul></div>}, page.toc_data.gsub(/\n */,"")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Ensure ' creates valid links in TOC
|
||||||
|
# Incorrect: <a href=\"#a\" b=\"\">
|
||||||
|
# Correct: <a href=\"#a'b\">
|
||||||
|
test "' in link" do
|
||||||
|
page = @wiki.preview_page("Test", "# a'b", :markdown)
|
||||||
|
assert_equal "# a'b", page.raw_data
|
||||||
|
assert_equal %q{<h1>a'b<a class="anchor" id="a'b" href="#a'b"></a></h1>}, page.formatted_data.gsub(/\n/,"")
|
||||||
|
assert_equal %{<div class=\"toc\"><div class=\"toc-title\">Table of Contents</div><ul><li><a href=\"#a'b\">a'b</a></li></ul></div>}, page.toc_data.gsub(/\n */,"")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Wiki page writing" do
|
context "Wiki page writing" do
|
||||||
|
|||||||
Reference in New Issue
Block a user