Compare commits

...

33 Commits

Author SHA1 Message Date
bootstraponline 72ee08b5ab Release 2.2.5 2012-10-14 11:21:56 -06:00
bootstraponline 45547624e4 Improve tilde fence support
More than 3 tildes can be used. The code block must end with the same amount of tildes used to open the code block.

Fix #537

http://johnmacfarlane.net/pandoc/README.html#delimited-code-blocks
2012-10-14 11:02:45 -06:00
bootstraponline f928cfa8be Don't ship Lorem ipsum in gem 2012-10-13 20:21:08 -06:00
bootstraponline 988984846a Release 2.2.4 2012-10-13 20:01:57 -06:00
bootstraponline 1149618653 Fix #537 2012-10-13 19:53:41 -06:00
bootstraponline 168a033903 Remove old comment 2012-10-13 14:59:42 -06:00
bootstraponline 6a765c9791 Fix #537 2012-10-13 14:52:28 -06:00
bootstraponline e16ae7b511 Travis is having a bad day
E: There are problems and -y was used without --force-yes
before_install: 'sudo apt-get install -y asciidoc' returned false.
Done. Build script exited with: 1
2012-10-13 14:07:15 -06:00
bootstraponline 174334ea44 Remove comment 2012-10-13 13:58:56 -06:00
bootstraponline dbdf06930d Fix 2012-10-13 13:55:20 -06:00
bootstraponline c93e65ddc3 Merge branch 'master' of github.com:github/gollum 2012-10-13 13:32:19 -06:00
bootstraponline 56101ed264 Fix #535 and add test 2012-10-13 13:32:08 -06:00
bootstraponline 8269c8e574 TOC doesn't require ' 2012-10-13 13:11:31 -06:00
bootstraponline 2246419d1e Fix spacing 2012-10-13 13:09:20 -06:00
bootstraponline 118a0c318b Update comment 2012-10-13 13:06:15 -06:00
bootstraponline 5401cf2910 Fix #542 2012-10-13 13:04:51 -06:00
bootstraponline 432f9b8d2f Add test for #542 2012-10-13 12:57:58 -06:00
bootstraponline 66fc8a2d31 Revert "Fix #542"
This reverts commit 2f3dd3d227.
2012-10-13 12:55:43 -06:00
bootstraponline 2f3dd3d227 Fix #542
Page link may contain duplicate starting forward slashes.
//page points to http://page/ when what we want is
/page pointing to http://localhost:1234/page
2012-10-13 09:53:25 -06:00
bootstraponline c43fd9fa6c Update language comment 2012-10-12 21:19:24 -06:00
bootstraponline 868518e0f5 Bash is Ace mode sh 2012-10-12 20:58:05 -06:00
bootstraponline 039b5cce98 Try to fix Travis
FFI is no longer used in the new pygments.rb.
apt-get update may resolve the asciidoc install failure.
2012-10-12 20:24:31 -06:00
bootstraponline 4a421842d5 https://github.com/travis-ci/travis-ci/issues/725
Modified README to trigger a Travis CI build. It's currently broken.
2012-10-12 20:22:10 -06:00
bootstraponline cfbb124f81 Update README.md 2012-10-12 20:16:43 -06:00
bootstraponline dcb147cde2 Ensure declaredLanguage is lower case 2012-10-10 20:20:33 -06:00
bootstraponline 8d06b5e67e Fix pygments language to Ace mode translation 2012-10-10 20:16:04 -06:00
bootstraponline 4776d0b422 Use rake release in readme 2012-10-10 19:45:42 -06:00
bootstraponline 58bb340c33 Release 2.2.3 2012-10-10 19:43:30 -06:00
bootstraponline ee790a9b7c Add rake bump to readme 2012-10-10 19:38:53 -06:00
bootstraponline ac432aad78 Add bump task to Rakefile 2012-10-10 19:35:04 -06:00
bootstraponline 30207e0a39 Merge pull request #533 from wrs/wrs_syntaxfixes
Two little syntax highlighting fixes
2012-10-10 16:56:37 -07:00
Walter Smith d98547a33c Fix lack of CoffeeScript livepreview
Pygments calls it coffeescript, but Ace calls it coffee.
2012-10-10 14:20:50 -07:00
Walter Smith b7cdeabbf6 Catch all Pygments errors
An unrecognized language was generating a MentosError rather than a
PythonError. Just catch anything that goes wrong in Pygments.
2012-10-10 14:20:50 -07:00
10 changed files with 189 additions and 32 deletions
+2 -2
View File
@@ -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
+7 -5
View File
@@ -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.
@@ -547,12 +547,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
+30 -2
View File
@@ -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
View File
@@ -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.5'
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
View File
@@ -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.5'
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__))
+7
View File
@@ -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.
+35 -2
View File
@@ -122,7 +122,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="##{id.gsub("%", "%25")}">#{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 +407,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 +511,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 +591,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
+60
View File
@@ -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)
@@ -197,6 +212,43 @@ context "Markup" do
assert_equal expected, output assert_equal expected, output
end 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\"><pre><span class=\"s1\">'hi'</span>\n</pre></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\"><pre><span class=\"s1\">'hi'</span>\n</pre></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\"><pre><span class=\"o\">~~</span>\n<span class=\"s1\">'hi'</span><span class=\"o\">~</span>\n</pre></div>}
assert_equal expected, output
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")
@@ -534,6 +586,14 @@ np.array([[2,2],[1,3]],np.float)
assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\">&lt;p&gt;</span>a\n!rel<span class=\"nt\">&lt;/p&gt;</span>\n</pre></div>\n}, output assert_equal %Q{<p>a\n</p><div class=\"highlight\"><pre><span class=\"nt\">&lt;p&gt;</span>a\n!rel<span class=\"nt\">&lt;/p&gt;</span>\n</pre></div>\n}, output
end 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
######################################################################### #########################################################################
# #
# Web Sequence Diagrams # Web Sequence Diagrams
+10
View File
@@ -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