Compare commits

...

30 Commits

Author SHA1 Message Date
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 170 additions and 30 deletions
+2 -2
View File
@@ -4,5 +4,5 @@ rvm:
notifications:
disabled: true
before_install:
- gem uninstall ffi -a
- sudo apt-get install -y asciidoc
- sudo apt-get update
- 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)
'[[_TOC_]]
[[_TOC_]]
This tag is case sensitive, use all upper case. The TOC tag can be inserted
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.
## RELEASING
For z releases:
$ rake bump
$ rake release
For x.y releases:
Update VERSION in lib/gollum.rb
$ rake gemspec
$ git tag vX.Y.Z
$ git push origin vX.Y.Z
$ gem build gollum.gemspec
$ gem push gollum-X.Y.Z.gem
$ rake release
## BUILDING THE GEM FROM MASTER
$ gem uninstall -aIx gollum
+29 -1
View File
@@ -17,6 +17,27 @@ def version
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
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
Date.today.to_s
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
#############################################################################
#
+2 -2
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 1.8.7"
s.name = 'gollum'
s.version = '2.2.2'
s.date = '2012-10-04'
s.version = '2.2.4'
s.date = '2012-10-13'
s.rubyforge_project = 'gollum'
s.summary = "A simple, Git-powered wiki."
+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__)
module Gollum
VERSION = '2.2.2'
VERSION = '2.2.4'
def self.assets_path
::File.expand_path('gollum/frontend/public', ::File.dirname(__FILE__))
+7
View File
@@ -23,5 +23,12 @@ module Precious
return url if url.nil?
url.gsub('%2F','/').gsub(/^\/+/,'')
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
@@ -194,13 +194,14 @@ var previewSet = function( text ) {
}
};
// 'c', 'c++', 'cpp' are github specific and transformed to c_cpp for Ace.
var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee', 'coldfusion',
'csharp', 'css', 'diff', 'golang', 'groovy', 'haxe', 'html',
'java', 'javascript', 'json', 'latex', 'less', 'liquid',
'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php', 'powershell',
'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql', 'svg',
'textile', 'text', 'xml', 'xquery', 'yaml' ];
// See pygmentsLanguageToAceMode for pygment to ace mode translations.
// TODO: Update languages and translation once Ace is upgraded to v1.0.
var languages = [ 'c', 'c++', 'cpp', 'clojure', 'coffee',
'coffeescript', 'coldfusion', 'csharp', 'css', 'diff', 'golang',
'groovy', 'haxe', 'html', 'java', 'javascript', 'json', 'latex',
'less', 'liquid', 'lua', 'markdown', 'ocaml', 'perl', 'pgsql', 'php',
'powershell', 'python', 'ruby', 'scad', 'scala', 'scss', 'sh', 'sql',
'svg', 'textile', 'text', 'xml', 'xquery', 'yaml' ];
var staticHighlight = require( 'ace/ext/static_highlight' );
var githubTheme = require( 'ace/theme/github' );
@@ -243,6 +244,31 @@ function highlight( element, language ) {
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 text = editorSession.getValue();
@@ -293,15 +319,7 @@ var makePreviewHtml = function () {
// the syntax for code highlighting means all code, even one line, contains newlines.
if ( txt.length > 1 && codeHTML.match( /\n/ ) ) {
var declaredLanguage = element.className.toLowerCase();
var aceMode = 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';
}
var aceMode = pygmentsLanguageToAceMode( declaredLanguage );
if ( $.inArray( declaredLanguage, languages ) === -1 ) {
// Unsupported language.
+31 -3
View File
@@ -122,7 +122,7 @@ module Gollum
end
node = Nokogiri::XML::Node.new('li', doc)
# % -> %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)
end
toc = toc.to_xhtml if toc != nil
@@ -407,6 +407,12 @@ module Gollum
presence = "present"
end
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>}
end
end
@@ -505,6 +511,28 @@ module Gollum
#
# Returns the placeholder'd String data.
def extract_code(data)
data.gsub!(/^([ \t]*)~~~ ?([^\r\n]+)?\r?\n(.+?)\r?\n\1~~~\r?$/m) do
m_indent = $1
m_lang = $2
m_code = $3
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
lang = $2 ? $2.strip : nil
id = Digest::SHA1.hexdigest("#{lang}.#{$3}")
@@ -558,12 +586,12 @@ module Gollum
encoding ||= 'utf-8'
begin
hl_code = Pygments.highlight(code, :lexer => lang, :options => {:encoding => encoding.to_s})
rescue ::RubyPython::PythonError
rescue
hl_code = code
end
highlighted << hl_code
end
@codemap.each do |id, spec|
body = spec[:output] || begin
if (body = highlighted.shift.to_s).size > 0
+47
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
@wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details)
@@ -197,6 +212,30 @@ context "Markup" do
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\"><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 "wiki link within code block" do
@wiki.write_page("Potato", :markdown, " sed -i '' 's/[[:space:]]*$//'", commit_details)
page = @wiki.page("Potato")
@@ -534,6 +573,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
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
+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 %{<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
# 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
context "Wiki page writing" do