From c704d1f3b3aebb4b7086e45f2fd41398a097bbb0 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Mon, 18 Jun 2012 09:44:20 +0200 Subject: [PATCH 01/62] Hacky fix for encoding issues --- lib/gollum/frontend/views/history.rb | 4 ++-- lib/gollum/frontend/views/page.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gollum/frontend/views/history.rb b/lib/gollum/frontend/views/history.rb index d3cb143f..599d1209 100644 --- a/lib/gollum/frontend/views/history.rb +++ b/lib/gollum/frontend/views/history.rb @@ -15,8 +15,8 @@ module Precious :id7 => v.id[0..6], :num => i, :selected => @page.version.id == v.id, - :author => v.author.name, - :message => v.message, + :author => v.author.name.force_encoding('UTF-8'), + :message => v.message.force_encoding('UTF-8'), :date => v.committed_date.strftime("%B %d, %Y"), :gravatar => Digest::MD5.hexdigest(v.author.email) } end diff --git a/lib/gollum/frontend/views/page.rb b/lib/gollum/frontend/views/page.rb index 89eab7e7..829464e3 100644 --- a/lib/gollum/frontend/views/page.rb +++ b/lib/gollum/frontend/views/page.rb @@ -17,7 +17,7 @@ module Precious page_versions = @page.versions first = page_versions ? page_versions.first : false return DEFAULT_AUTHOR unless first - first.author.name + first.author.name.force_encoding('UTF-8') end def date From 67dd3afd929e3c0f639ccae366dff7367d22dafd Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Tue, 19 Jun 2012 15:33:47 +0200 Subject: [PATCH 02/62] Fix for 1.8 versions of ruby --- lib/gollum/frontend/views/history.rb | 4 ++-- lib/gollum/frontend/views/page.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gollum/frontend/views/history.rb b/lib/gollum/frontend/views/history.rb index 599d1209..8a48f696 100644 --- a/lib/gollum/frontend/views/history.rb +++ b/lib/gollum/frontend/views/history.rb @@ -15,8 +15,8 @@ module Precious :id7 => v.id[0..6], :num => i, :selected => @page.version.id == v.id, - :author => v.author.name.force_encoding('UTF-8'), - :message => v.message.force_encoding('UTF-8'), + :author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name, + :message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message, :date => v.committed_date.strftime("%B %d, %Y"), :gravatar => Digest::MD5.hexdigest(v.author.email) } end diff --git a/lib/gollum/frontend/views/page.rb b/lib/gollum/frontend/views/page.rb index 829464e3..0b47df1c 100644 --- a/lib/gollum/frontend/views/page.rb +++ b/lib/gollum/frontend/views/page.rb @@ -17,7 +17,7 @@ module Precious page_versions = @page.versions first = page_versions ? page_versions.first : false return DEFAULT_AUTHOR unless first - first.author.name.force_encoding('UTF-8') + first.author.name.respond_to?(:force_encoding) ? first.author.name.force_encoding('UTF-8') : first.author.name end def date From 41cd43ebc6edc08080f56491631b1427f715f8c1 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 2 Jul 2012 10:18:40 -0600 Subject: [PATCH 03/62] Updated Home (markdown) --- Home.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Home.md b/Home.md index 6edf0edb..3b1641c8 100644 --- a/Home.md +++ b/Home.md @@ -1,3 +1 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vulputate tincidunt sollicitudin. Quisque sit amet leo sed nunc eleifend rhoncus in consectetur leo. Vivamus posuere semper convallis. Duis malesuada lacus sed erat lobortis tincidunt mattis ligula consectetur. Sed aliquam vulputate eros at euismod. Aenean egestas lorem ligula, quis faucibus turpis. Curabitur a eros in ipsum gravida ornare. Sed elementum enim vel mi scelerisque dapibus. Nulla id libero ligula, quis tempus sem. Morbi nec felis tortor, ac cursus risus. Mauris elementum tortor id lacus eleifend non lobortis tellus pharetra. Etiam posuere cursus vestibulum. $x \lt y$ - -Morbi tincidunt dolor vel massa dictum volutpat. Vestibulum quis nibh metus, id tincidunt nisl. Vivamus eget sem ac risus eleifend rhoncus at eu nisl. Nunc elit massa, vulputate ac gravida eget, condimentum quis justo. Integer scelerisque, libero vel consequat ultricies, eros libero sagittis libero, pellentesque bibendum quam massa ut orci. Maecenas sit amet urna eget quam aliquam posuere. Nulla facilisi. Duis imperdiet augue sit amet metus ornare et hendrerit dui feugiat. Aenean a lacus neque. Sed eu enim tincidunt dolor pharetra porttitor. Vestibulum ut felis dui, rutrum iaculis orci. Duis eu bibendum tortor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse mollis sagittis purus sit amet sollicitudin. Phasellus vel interdum erat. \ No newline at end of file +$$ dollars \ No newline at end of file From 20dd0816a6d7a07524b6e0f321781e6a15a886bb Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 2 Jul 2012 10:27:30 -0600 Subject: [PATCH 04/62] Revert "Merge pull request #379 from pipex/latex-dollar-sign" This reverts commit b53c961db29ff82342045ce9c258bc2159796e92, reversing changes made to 9c40cbea7637dbe65ef4f941f51baf1b09642653. --- lib/gollum/markup.rb | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 312d03da..a02d8aa0 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -124,30 +124,17 @@ module Gollum # # Returns the placeholder'd String data. def extract_tex(data) - # Random string to escape the `$` character (might be overkill) - esc = "/%%/" data.gsub(/\\\[\s*(.*?)\s*\\\]/m) do tag = CGI.escapeHTML($1) id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:block, tag] id - end.gsub(/'\$/, esc). # Replace `'$` with the `esc` string in order to escape it - gsub(/\$\$\s*(.*?)\s*\$\$/m) do - tag = CGI.escapeHTML($1) - id = Digest::SHA1.hexdigest(tag) - @texmap[id] = [:block, tag] - id end.gsub(/\\\(\s*(.*?)\s*\\\)/m) do tag = CGI.escapeHTML($1) id = Digest::SHA1.hexdigest(tag) @texmap[id] = [:inline, tag] id - end.gsub(/\$\s*(.*?)\s*\$/m) do # match inline $$ - tag = CGI.escapeHTML($1) - id = Digest::SHA1.hexdigest(tag) - @texmap[id] = [:inline, tag] - id - end.gsub(/#{esc}/, '$') # replace the `esc` string back to `$` + end end # Process all TeX from the texmap and replace the placeholders with the From 1511baf12d134a27ec821bc939417bdd5793665d Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Mon, 2 Jul 2012 10:37:46 -0600 Subject: [PATCH 05/62] Restore Home.md. --- Home.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Home.md b/Home.md index 3b1641c8..6edf0edb 100644 --- a/Home.md +++ b/Home.md @@ -1 +1,3 @@ -$$ dollars \ No newline at end of file +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vulputate tincidunt sollicitudin. Quisque sit amet leo sed nunc eleifend rhoncus in consectetur leo. Vivamus posuere semper convallis. Duis malesuada lacus sed erat lobortis tincidunt mattis ligula consectetur. Sed aliquam vulputate eros at euismod. Aenean egestas lorem ligula, quis faucibus turpis. Curabitur a eros in ipsum gravida ornare. Sed elementum enim vel mi scelerisque dapibus. Nulla id libero ligula, quis tempus sem. Morbi nec felis tortor, ac cursus risus. Mauris elementum tortor id lacus eleifend non lobortis tellus pharetra. Etiam posuere cursus vestibulum. $x \lt y$ + +Morbi tincidunt dolor vel massa dictum volutpat. Vestibulum quis nibh metus, id tincidunt nisl. Vivamus eget sem ac risus eleifend rhoncus at eu nisl. Nunc elit massa, vulputate ac gravida eget, condimentum quis justo. Integer scelerisque, libero vel consequat ultricies, eros libero sagittis libero, pellentesque bibendum quam massa ut orci. Maecenas sit amet urna eget quam aliquam posuere. Nulla facilisi. Duis imperdiet augue sit amet metus ornare et hendrerit dui feugiat. Aenean a lacus neque. Sed eu enim tincidunt dolor pharetra porttitor. Vestibulum ut felis dui, rutrum iaculis orci. Duis eu bibendum tortor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse mollis sagittis purus sit amet sollicitudin. Phasellus vel interdum erat. \ No newline at end of file From 3f45c76f481691f8b554c41eaa022140df437e95 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Tue, 3 Jul 2012 10:53:18 -0600 Subject: [PATCH 06/62] Extract path on edit. Fix #410. --- lib/gollum/frontend/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 6f510853..b6cc0960 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -106,7 +106,7 @@ module Precious end post '/edit/*' do - path = sanitize_empty_params(params[:path]) + path = extract_path(sanitize_empty_params(params[:path])) wiki_options = settings.wiki_options.merge({ :page_file_dir => path }) wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) page = wiki.page(CGI.unescape(params[:page])) From 32930cee013a37b99d1fa9f21bcb00fd578a612e Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Tue, 3 Jul 2012 10:55:42 -0600 Subject: [PATCH 07/62] extract_path fails on nil paths. --- lib/gollum/frontend/helpers.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/gollum/frontend/helpers.rb b/lib/gollum/frontend/helpers.rb index 1e78f617..845a0c7a 100644 --- a/lib/gollum/frontend/helpers.rb +++ b/lib/gollum/frontend/helpers.rb @@ -2,6 +2,7 @@ module Precious module Helpers # Extract the path string that Gollum::Wiki expects def extract_path(file_path) + return nil if file_path.nil? last_slash = file_path.rindex("/") if last_slash file_path[0, last_slash] From 6ff939451c0e42c2438d49642bb030b4dfa601db Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Tue, 3 Jul 2012 13:55:08 -0600 Subject: [PATCH 08/62] Update livepreview. Update ace. Replace pagedown with sundown. Live preview is now able to render markdown identical to regular gollum by leveraging the same library. Thanks to @kripken for explaining how to best use emscripten for sundown. --- .../public/gollum/livepreview/index.html | 48 +- .../lib/ace/commands/multi_select_commands.js | 2 +- .../livepreview/js/ace/lib/ace/config.js | 7 +- .../livepreview/js/ace/lib/ace/css/editor.css | 39 +- .../ace/lib/ace/edit_session/bracket_match.js | 13 +- .../livepreview/js/ace/lib/ace/editor.js | 6 +- .../js/ace/lib/ace/keyboard/state_handler.js | 2 +- .../js/ace/lib/ace/layer/marker.js | 28 +- .../livepreview/js/ace/lib/ace/layer/text.js | 54 +- .../livepreview/js/ace/lib/ace/lib/event.js | 4 +- .../js/ace/lib/ace/mode/behaviour/html.js | 98 ++ .../js/ace/lib/ace/mode/behaviour/xml.js | 61 +- .../js/ace/lib/ace/mode/c9search.js | 12 - .../lib/ace/mode/c9search_highlight_rules.js | 2 +- .../livepreview/js/ace/lib/ace/mode/coffee.js | 2 +- .../lib/ace/mode/coffee_highlight_rules.js | 2 +- .../js/ace/lib/ace/mode/folding/c9search.js | 52 +- .../js/ace/lib/ace/mode/folding/coffee.js | 127 ++ .../ace/lib/ace/mode/folding/coffee_test.js | 108 ++ .../js/ace/lib/ace/mode/folding/fold_mode.js | 30 +- .../js/ace/lib/ace/mode/folding/pythonic.js | 2 +- .../ace/lib/ace/mode/folding/pythonic_test.js | 7 +- .../livepreview/js/ace/lib/ace/mode/html.js | 4 +- .../ace/lib/ace/mode/html_highlight_rules.js | 25 +- .../ace/mode/javascript_highlight_rules.js | 2 +- .../js/ace/lib/ace/mode/luapage.js | 2 +- .../lib/ace/mode/luapage_highlight_rules.js | 2 +- .../js/ace/lib/ace/mode/xml_util.js | 36 +- .../lib/ace/mouse/default_gutter_handler.js | 9 +- .../js/ace/lib/ace/mouse/default_handlers.js | 17 +- .../js/ace/lib/ace/requirejs/text.js | 10 +- .../js/ace/lib/ace/test/all_browser.js | 1 + .../js/ace/lib/ace/theme/chrome.css | 8 +- .../js/ace/lib/ace/theme/clouds.css | 3 +- .../js/ace/lib/ace/theme/clouds_midnight.css | 9 +- .../js/ace/lib/ace/theme/cobalt.css | 9 +- .../js/ace/lib/ace/theme/crimson_editor.css | 7 +- .../livepreview/js/ace/lib/ace/theme/dawn.css | 3 +- .../js/ace/lib/ace/theme/dreamweaver.css | 1 - .../js/ace/lib/ace/theme/eclipse.css | 5 +- .../js/ace/lib/ace/theme/github.css | 59 +- .../js/ace/lib/ace/theme/github.js | 2 +- .../js/ace/lib/ace/theme/idle_fingers.css | 9 +- .../js/ace/lib/ace/theme/kr_theme.css | 9 +- .../js/ace/lib/ace/theme/merbivore.css | 7 +- .../js/ace/lib/ace/theme/merbivore_soft.css | 9 +- .../js/ace/lib/ace/theme/mono_industrial.css | 7 +- .../js/ace/lib/ace/theme/monokai.css | 3 +- .../js/ace/lib/ace/theme/pastel_on_dark.css | 9 +- .../js/ace/lib/ace/theme/solarized_dark.css | 3 +- .../js/ace/lib/ace/theme/solarized_light.css | 3 +- .../js/ace/lib/ace/theme/textmate.css | 6 +- .../js/ace/lib/ace/theme/tomorrow.css | 7 +- .../js/ace/lib/ace/theme/tomorrow_night.css | 9 +- .../ace/lib/ace/theme/tomorrow_night_blue.css | 5 +- .../lib/ace/theme/tomorrow_night_bright.css | 9 +- .../lib/ace/theme/tomorrow_night_eighties.css | 9 +- .../js/ace/lib/ace/theme/twilight.css | 9 +- .../js/ace/lib/ace/theme/vibrant_ink.css | 9 +- .../js/ace/lib/ace/virtual_renderer.js | 40 +- .../livepreview/js/livepreview/livepreview.js | 94 +- .../js/pagedown/Markdown.Converter.js | 1355 ----------------- .../js/pagedown/Markdown.Sanitizer.js | 109 -- .../livepreview/js/sundown/sundown_o2.js | 1 + .../livepreview/licenses/pagedown/LICENSE.txt | 32 - .../livepreview/licenses/sundown/sundown.txt | 4 + .../public/gollum/livepreview/readme.md | 36 +- 67 files changed, 807 insertions(+), 1906 deletions(-) create mode 100644 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/behaviour/html.js create mode 100644 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee.js create mode 100644 lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/folding/coffee_test.js delete mode 100644 lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Converter.js delete mode 100644 lib/gollum/frontend/public/gollum/livepreview/js/pagedown/Markdown.Sanitizer.js create mode 100644 lib/gollum/frontend/public/gollum/livepreview/js/sundown/sundown_o2.js delete mode 100644 lib/gollum/frontend/public/gollum/livepreview/licenses/pagedown/LICENSE.txt create mode 100644 lib/gollum/frontend/public/gollum/livepreview/licenses/sundown/sundown.txt diff --git a/lib/gollum/frontend/public/gollum/livepreview/index.html b/lib/gollum/frontend/public/gollum/livepreview/index.html index 17fd51cd..17b8891c 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/index.html +++ b/lib/gollum/frontend/public/gollum/livepreview/index.html @@ -2,41 +2,45 @@ Live Preview - - + + -
+
-
+
- + data-markup-lang="{{format}}" name="content" class="mousetrap">{{content}} {{#header}} diff --git a/lib/gollum/page.rb b/lib/gollum/page.rb index 3ec3305d..66822015 100644 --- a/lib/gollum/page.rb +++ b/lib/gollum/page.rb @@ -259,6 +259,13 @@ module Gollum end end + # Public: The first 7 characters of the current version. + # + # Returns the first 7 characters of the current version. + def version_short + version.to_s[0,7] + end + # Public: The header Page. # # Returns the header Page or nil if none exists. diff --git a/test/test_app.rb b/test/test_app.rb index e4d2d875..5737da42 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -46,7 +46,7 @@ context "Frontend" do @wiki.clear_cache page_2 = @wiki.page(page_1.name) assert_equal 'abc', page_2.raw_data - assert_equal 'def', page_2.version.message + assert_equal 'def [ed6c9f6]', page_2.version.message assert_not_equal page_1.version.sha, page_2.version.sha end @@ -72,12 +72,12 @@ context "Frontend" do assert_equal 'header', header_2.raw_data assert_equal 'footer', foot_2.raw_data - assert_equal 'def', foot_2.version.message + assert_equal 'def [ed6c9f6]', foot_2.version.message assert_not_equal foot_1.version.sha, foot_2.version.sha assert_not_equal header_1.version.sha, header_2.version.sha assert_equal 'sidebar', side_2.raw_data - assert_equal 'def', side_2.version.message + assert_equal 'def [ed6c9f6]', side_2.version.message assert_not_equal side_1.version.sha, side_2.version.sha assert_equal commits+1, @wiki.repo.commits('master').size end @@ -95,7 +95,7 @@ context "Frontend" do assert_nil @wiki.page("B") page_2 = @wiki.page('C') assert_equal 'abc', page_2.raw_data - assert_equal 'def', page_2.version.message + assert_equal 'def [ed6c9f6]', page_2.version.message assert_not_equal page_1.version.sha, page_2.version.sha end diff --git a/test/test_unicode.rb b/test/test_unicode.rb index 0ffed378..f52bc7d8 100644 --- a/test/test_unicode.rb +++ b/test/test_unicode.rb @@ -61,8 +61,8 @@ context "Frontend Unicode support" do assert last_response.ok? @wiki.update_page(@wiki.page('PG'), nil, nil, '다른 text', {}) - page = @wiki.page('PG') - assert_equal '다른 text', utf8(page.raw_data) + page2 = @wiki.page('PG') + assert_equal '다른 text', utf8(page2.raw_data) post '/edit/PG', :page => 'PG', :content => '바뀐 text', :message => 'ghi' follow_redirect! @@ -71,7 +71,7 @@ context "Frontend Unicode support" do @wiki = Gollum::Wiki.new(@path) page = @wiki.page('PG') assert_equal '바뀐 text', utf8(page.raw_data) - assert_equal 'ghi', page.version.message + assert_equal 'ghi [' + page2.version_short + ']', page.version.message end test "heavy use 2" do @@ -82,8 +82,8 @@ context "Frontend Unicode support" do @wiki.update_page(@wiki.page('k'), nil, nil, '다른 text', {}) @wiki = Gollum::Wiki.new(@path) - page = @wiki.page('k') - assert_equal '다른 text', utf8(page.raw_data) + page2 = @wiki.page('k') + assert_equal '다른 text', utf8(page2.raw_data) post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text', :format => 'markdown', :message => 'ghi' @@ -93,7 +93,7 @@ context "Frontend Unicode support" do @wiki = Gollum::Wiki.new(@path) page = @wiki.page('k') assert_equal '바뀐 text', utf8(page.raw_data) - assert_equal 'ghi', page.version.message + assert_equal 'ghi [' + page2.version_short + ']', page.version.message end test 'transliteration' do From 2dbea36b81c62c9eb2d7dc0546e7e305c61f51ec Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 21 Jul 2012 16:31:38 -0600 Subject: [PATCH 56/62] Add rename button. Fix #444. --- .../public/gollum/javascript/gollum.js | 42 +++++++++++++++++++ lib/gollum/frontend/templates/page.mustache | 2 + 2 files changed, 44 insertions(+) diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index cbedb6bc..951016fb 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -113,6 +113,48 @@ $(document).ready(function() { } } + if ($('#minibutton-rename-page').length) { + $('#minibutton-rename-page').removeClass('jaws'); + $('#minibutton-rename-page').click(function(e) { + e.preventDefault(); + + var path = $(this).data('path'); + if (path) { + path = path + '/'; + } + + $.GollumDialog.init({ + title: 'Rename Page', + fields: [ + { + id: 'name', + name: 'Rename to', + type: 'text', + defaultValue: path || '' + } + ], + OK: function( res ) { + var name = 'Rename Page'; + if ( res['name'] ) { + name = res['name']; + } + var path = window.location.pathname; + var oldName = path.substring(path.lastIndexOf('/')+1); + var msg = 'Renamed ' + oldName + ' to ' + name; + jQuery.ajax( { + type: 'POST', + url: '/edit/' + oldName, + // omit path: pathName until https://github.com/github/gollum/issues/446 is fixed. + data: { rename: name, page: oldName, message: msg }, + success: function() { + window.location = '/' + encodeURIComponent(name); + } + }); + } + }); + }); + } + if ($('#minibutton-new-page').length) { $('#minibutton-new-page').removeClass('jaws'); $('#minibutton-new-page').click(function(e) { diff --git a/lib/gollum/frontend/templates/page.mustache b/lib/gollum/frontend/templates/page.mustache index f226dad3..847b875a 100644 --- a/lib/gollum/frontend/templates/page.mustache +++ b/lib/gollum/frontend/templates/page.mustache @@ -11,6 +11,8 @@ class="action-all-pages">File View
  • New Page
  • +
  • + Rename Page
  • {{#editable}}
  • Edit Page
  • From 3255709399086e7c7c942d94467ab9541ab113da Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 21 Jul 2012 16:52:18 -0600 Subject: [PATCH 57/62] Don't mess with the commit message. --- lib/gollum/frontend/app.rb | 3 +-- test/test_app.rb | 8 ++++---- test/test_unicode.rb | 12 ++++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index f6c00497..a237dad3 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -126,7 +126,6 @@ module Precious page = wiki.page(CGI.unescape(params[:page])) name = params[:rename] || page.name msg = commit_message - msg[:message]= msg[:message] + " [#{page.version_short}]" committer = Gollum::Committer.new(wiki, msg) commit = {:committer => committer} @@ -147,7 +146,7 @@ module Precious wiki_options = settings.wiki_options.merge({ :page_file_dir => @path }) wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) @page = wiki.page(@name) - wiki.delete_page(@page, { :message => "Destroyed #{@name} (#{@page.format}) [#{@page.version_short}]" }) + wiki.delete_page(@page, { :message => "Destroyed #{@name} (#{@page.format})" }) redirect '/' end diff --git a/test/test_app.rb b/test/test_app.rb index 5737da42..e4d2d875 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -46,7 +46,7 @@ context "Frontend" do @wiki.clear_cache page_2 = @wiki.page(page_1.name) assert_equal 'abc', page_2.raw_data - assert_equal 'def [ed6c9f6]', page_2.version.message + assert_equal 'def', page_2.version.message assert_not_equal page_1.version.sha, page_2.version.sha end @@ -72,12 +72,12 @@ context "Frontend" do assert_equal 'header', header_2.raw_data assert_equal 'footer', foot_2.raw_data - assert_equal 'def [ed6c9f6]', foot_2.version.message + assert_equal 'def', foot_2.version.message assert_not_equal foot_1.version.sha, foot_2.version.sha assert_not_equal header_1.version.sha, header_2.version.sha assert_equal 'sidebar', side_2.raw_data - assert_equal 'def [ed6c9f6]', side_2.version.message + assert_equal 'def', side_2.version.message assert_not_equal side_1.version.sha, side_2.version.sha assert_equal commits+1, @wiki.repo.commits('master').size end @@ -95,7 +95,7 @@ context "Frontend" do assert_nil @wiki.page("B") page_2 = @wiki.page('C') assert_equal 'abc', page_2.raw_data - assert_equal 'def [ed6c9f6]', page_2.version.message + assert_equal 'def', page_2.version.message assert_not_equal page_1.version.sha, page_2.version.sha end diff --git a/test/test_unicode.rb b/test/test_unicode.rb index f52bc7d8..0ffed378 100644 --- a/test/test_unicode.rb +++ b/test/test_unicode.rb @@ -61,8 +61,8 @@ context "Frontend Unicode support" do assert last_response.ok? @wiki.update_page(@wiki.page('PG'), nil, nil, '다른 text', {}) - page2 = @wiki.page('PG') - assert_equal '다른 text', utf8(page2.raw_data) + page = @wiki.page('PG') + assert_equal '다른 text', utf8(page.raw_data) post '/edit/PG', :page => 'PG', :content => '바뀐 text', :message => 'ghi' follow_redirect! @@ -71,7 +71,7 @@ context "Frontend Unicode support" do @wiki = Gollum::Wiki.new(@path) page = @wiki.page('PG') assert_equal '바뀐 text', utf8(page.raw_data) - assert_equal 'ghi [' + page2.version_short + ']', page.version.message + assert_equal 'ghi', page.version.message end test "heavy use 2" do @@ -82,8 +82,8 @@ context "Frontend Unicode support" do @wiki.update_page(@wiki.page('k'), nil, nil, '다른 text', {}) @wiki = Gollum::Wiki.new(@path) - page2 = @wiki.page('k') - assert_equal '다른 text', utf8(page2.raw_data) + page = @wiki.page('k') + assert_equal '다른 text', utf8(page.raw_data) post '/edit/' + CGI.escape('한글'), :page => 'k', :content => '바뀐 text', :format => 'markdown', :message => 'ghi' @@ -93,7 +93,7 @@ context "Frontend Unicode support" do @wiki = Gollum::Wiki.new(@path) page = @wiki.page('k') assert_equal '바뀐 text', utf8(page.raw_data) - assert_equal 'ghi [' + page2.version_short + ']', page.version.message + assert_equal 'ghi', page.version.message end test 'transliteration' do From 8eaf7fc49705966eeea3fdae929e3a386b082b2b Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 21 Jul 2012 16:57:20 -0600 Subject: [PATCH 58/62] Remove msg. --- lib/gollum/frontend/app.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index a237dad3..7dc4bc94 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -125,8 +125,7 @@ module Precious wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) page = wiki.page(CGI.unescape(params[:page])) name = params[:rename] || page.name - msg = commit_message - committer = Gollum::Committer.new(wiki, msg) + committer = Gollum::Committer.new(wiki, commit_message) commit = {:committer => committer} update_wiki_page(wiki, page, params[:content], commit, name, params[:format]) From 8eb8af8ef8c5e70ee4b5e89fc346659b5a352f0f Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 21 Jul 2012 21:00:14 -0600 Subject: [PATCH 59/62] Use old name default text on rename. --- .../frontend/public/gollum/javascript/gollum.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index 951016fb..0ba34c77 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -118,10 +118,8 @@ $(document).ready(function() { $('#minibutton-rename-page').click(function(e) { e.preventDefault(); - var path = $(this).data('path'); - if (path) { - path = path + '/'; - } + var path = window.location.pathname; + var oldName = path.substring(path.lastIndexOf('/')+1); $.GollumDialog.init({ title: 'Rename Page', @@ -130,7 +128,7 @@ $(document).ready(function() { id: 'name', name: 'Rename to', type: 'text', - defaultValue: path || '' + defaultValue: oldName || '' } ], OK: function( res ) { @@ -138,8 +136,7 @@ $(document).ready(function() { if ( res['name'] ) { name = res['name']; } - var path = window.location.pathname; - var oldName = path.substring(path.lastIndexOf('/')+1); + var msg = 'Renamed ' + oldName + ' to ' + name; jQuery.ajax( { type: 'POST', From 3424a424a7727dcb102e5e92fa09b3cf145fbc8a Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sun, 22 Jul 2012 13:25:25 -0600 Subject: [PATCH 60/62] Add /delete test. --- test/test_app.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_app.rb b/test/test_app.rb index e4d2d875..9f5a4dbb 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -153,6 +153,20 @@ context "Frontend" do assert_not_equal 'abc', page.raw_data end + test "delete a page" do + name = "deleteme" + post "/create", :content => 'abc', :page => name, + :format => 'markdown', :message => 'foo' + page = @wiki.page(name) + assert_equal 'abc', page.raw_data + + get '/delete/' + name + + @wiki.clear_cache + page = @wiki.page(name) + assert_equal nil, page + end + test "previews content" do post "/preview", :content => 'abc', :format => 'markdown' assert last_response.ok? From 3e5054f3571ce897858aaf04d83684f4e672030e Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sun, 22 Jul 2012 13:37:09 -0600 Subject: [PATCH 61/62] Call to_url on rename to prevent invalid renames. Remove to_url on delete so invalid names can be deleted. Handle nil in to_url. Update tests. --- lib/gollum/frontend/app.rb | 8 +++++--- test/test_app.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 7dc4bc94..e20e4d48 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -17,6 +17,7 @@ class String alias :upstream_to_url :to_url # _Header => header which causes errors def to_url + return nil if self.nil? return self if ['_Header', '_Footer', '_Sidebar'].include? self upstream_to_url end @@ -124,7 +125,8 @@ module Precious wiki_options = settings.wiki_options.merge({ :page_file_dir => path }) wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) page = wiki.page(CGI.unescape(params[:page])) - name = params[:rename] || page.name + rename = params[:rename].to_url if params[:rename] + name = rename || page.name committer = Gollum::Committer.new(wiki, commit_message) commit = {:committer => committer} @@ -134,14 +136,14 @@ module Precious update_wiki_page(wiki, page.sidebar, params[:sidebar], commit) if params[:sidebar] committer.commit - page = wiki.page(params[:rename]) if params[:rename] + page = wiki.page(rename) if rename redirect "/#{page.escaped_url_path}" end get '/delete/*' do @path = extract_path(params[:splat].first) - @name = extract_name(params[:splat].first).to_url + @name = extract_name(params[:splat].first) wiki_options = settings.wiki_options.merge({ :page_file_dir => @path }) wiki = Gollum::Wiki.new(settings.gollum_path, wiki_options) @page = wiki.page(@name) diff --git a/test/test_app.rb b/test/test_app.rb index 9f5a4dbb..d76eab1e 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -88,7 +88,7 @@ context "Frontend" do :rename => "C", :page => 'B', :format => page_1.format, :message => 'def' follow_redirect! - assert_equal "/C", last_request.fullpath + assert_equal '/c', last_request.fullpath assert last_response.ok? @wiki.clear_cache From f811ac510eeec104950b3b021bf02cd4a97cfc15 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sun, 22 Jul 2012 21:04:02 -0600 Subject: [PATCH 62/62] Improve names. Fix #447. --- lib/gollum/frontend/templates/page.mustache | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/gollum/frontend/templates/page.mustache b/lib/gollum/frontend/templates/page.mustache index 847b875a..21fda6d0 100644 --- a/lib/gollum/frontend/templates/page.mustache +++ b/lib/gollum/frontend/templates/page.mustache @@ -6,19 +6,19 @@ {{>searchbar}}
  • All Pages
  • + class="action-all-pages">All
  • File View
  • + class="action-all-pages">Files
  • - New Page
  • + New
  • - Rename Page
  • + Rename {{#editable}}
  • Edit Page
  • + class="action-edit-page">Edit {{/editable}}
  • Page History
  • + class="action-page-history">History