diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 6f510853..cdb41b9e 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -67,6 +67,10 @@ module Precious enable :logging, :raise_errors, :dump_errors end + before do + @base_url = url('/') + end + get '/' do show_page_or_file('Home') end @@ -93,7 +97,7 @@ module Precious if @path live_preview_url << '&path=' + encodeURIComponent(@path) end - redirect live_preview_url + redirect to(live_preview_url) else @page = page @page.version = wiki.repo.log(wiki.ref, @page.path).first @@ -122,7 +126,7 @@ module Precious page = wiki.page(params[:rename]) if params[:rename] - redirect "/#{page.escaped_url_path}" + redirect to("/#{page.escaped_url_path}") end get '/create/*' do @@ -146,7 +150,7 @@ module Precious begin wiki.write_page(name, format, params[:content], commit_message) page = wiki.page(name) - redirect "/#{page.escaped_url_path}" + redirect to("/#{page.escaped_url_path}") rescue Gollum::DuplicatePageError => e @message = "Duplicate page: #{e.message}" mustache :error @@ -164,7 +168,7 @@ module Precious sha2 = shas.shift if wiki.revert_page(@page, sha1, sha2, commit_message) - redirect "/#{@page.escaped_url_path}" + redirect to("/#{@page.escaped_url_path}") else sha2, sha1 = sha1, "#{sha1}^" if !sha2 @versions = [sha1, sha2] @@ -201,12 +205,13 @@ module Precious @file = params[:splat].first @versions = params[:versions] || [] if @versions.size < 2 - redirect "/history/#{@file}" + redirect to("/history/#{@file}") else - redirect "/compare/%s/%s...%s" % [ + redirect to("/compare/%s/%s...%s" % [ @file, @versions.last, @versions.first] + ) end end diff --git a/lib/gollum/frontend/public/gollum/css/_styles.css b/lib/gollum/frontend/public/gollum/css/_styles.css index d70f29ed..f2ce367f 100644 --- a/lib/gollum/frontend/public/gollum/css/_styles.css +++ b/lib/gollum/frontend/public/gollum/css/_styles.css @@ -62,16 +62,16 @@ ol.tree } li.file a { - background: url(/images/fileview/document.png) 0 0 no-repeat; + background: url(../images/fileview/document.png) 0 0 no-repeat; color: #fff; padding-left: 21px; text-decoration: none; display: block; } - li.file a[href *= '.pdf'] { background: url(/images/fileview/document.png) 0 0 no-repeat; } - li.file a[href *= '.html'] { background: url(/images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.css'] { background: url(/images/fileview/document.png) 0 0 no-repeat; } - li.file a[href $= '.js'] { background: url(/images/fileview/document.png) 0 0 no-repeat; } + li.file a[href *= '.pdf'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href *= '.html'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.css'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } + li.file a[href $= '.js'] { background: url(../images/fileview/document.png) 0 0 no-repeat; } li input { position: absolute; @@ -86,14 +86,14 @@ ol.tree } li input + ol { - background: url(/images/fileview/toggle-small-expand.png) 40px 0 no-repeat; + background: url(../images/fileview/toggle-small-expand.png) 40px 0 no-repeat; margin: -1.188em 0 0 -44px; /* 15px */ height: 1.5em; } li input + ol > li { display: none; margin-left: -14px !important; padding-left: 1px; } li label { - background: url(/images/fileview/folder-horizontal.png) 15px 1px no-repeat; + background: url(../images/fileview/folder-horizontal.png) 15px 1px no-repeat; cursor: pointer; display: block; padding-left: 37px; @@ -101,7 +101,7 @@ ol.tree li input:checked + ol { - background: url(/images/fileview/toggle-small.png) 40px 5px no-repeat; + background: url(../images/fileview/toggle-small.png) 40px 5px no-repeat; margin: -1.5em 0 0 -44px; /* 20px */ padding: 1.563em 0 0 80px; height: auto; diff --git a/lib/gollum/frontend/public/gollum/css/gollum.css b/lib/gollum/frontend/public/gollum/css/gollum.css index 96381b3b..c21bb723 100755 --- a/lib/gollum/frontend/public/gollum/css/gollum.css +++ b/lib/gollum/frontend/public/gollum/css/gollum.css @@ -662,7 +662,7 @@ ul.actions { } #head #searchbar #searchbar-fauxtext #search-submit span { - background-image: url(/images/icon-sprite.png); + background-image: url(../images/icon-sprite.png); background-position: -431px -1px; background-repeat: no-repeat; display: block; diff --git a/lib/gollum/frontend/public/gollum/css/template.css b/lib/gollum/frontend/public/gollum/css/template.css index c9ea382b..b2b059d2 100644 --- a/lib/gollum/frontend/public/gollum/css/template.css +++ b/lib/gollum/frontend/public/gollum/css/template.css @@ -77,7 +77,7 @@ a.absent { .markdown-body h4:hover a.anchor, .markdown-body h5:hover a.anchor, .markdown-body h6:hover a.anchor { - background: url('/images/pin-20.png') no-repeat left center; + background: url(../images/pin-20.png) no-repeat left center; text-decoration: none; } .markdown-body h1 tt, @@ -133,7 +133,7 @@ a.absent { margin: 15px 0; } .markdown-body hr { - background: transparent url('/images/dirty-shade.png') repeat-x 0 0; + background: transparent url(../images/dirty-shade.png) repeat-x 0 0; border: 0 none; color: #ccc; height: 4px; diff --git a/lib/gollum/frontend/public/gollum/javascript/gollum.js b/lib/gollum/frontend/public/gollum/javascript/gollum.js index 3c614dd3..98c5d440 100755 --- a/lib/gollum/frontend/public/gollum/javascript/gollum.js +++ b/lib/gollum/frontend/public/gollum/javascript/gollum.js @@ -116,7 +116,7 @@ $(document).ready(function() { var name = res['name']; } - var url = ''; + var url = baseUrl; var path = $('#minibutton-new-page').data('path'); if (path) { url += '/' + encodeURIComponent(path) diff --git a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview/livepreview.js b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview/livepreview.js index 848b5d2f..00ffcae5 100644 --- a/lib/gollum/frontend/public/gollum/livepreview/js/livepreview/livepreview.js +++ b/lib/gollum/frontend/public/gollum/livepreview/js/livepreview/livepreview.js @@ -57,6 +57,9 @@ var commentEditorContainer = commentEditor.container; initAce( commentEditor, commentEditorSession ); +// Find the app's base url, knowing we are in /livepreview/index.html +var baseUrl = location.pathname.split('/').slice(0,-2).join('/'); + // RegExp from http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript $.key = function( key ) { var value = new RegExp( '[\\?&]' + key + '=([^]*)' ).exec( location.href ); @@ -94,7 +97,7 @@ $.save = function( commitMessage ) { var txt = editorSession.getValue(); var msg = defaultCommitMessage(); - var newLocation = location.protocol + '//' + location.host; + var newLocation = location.protocol + '//' + location.host + baseUrl; if (pathName) { newLocation += '/' + pathName; } @@ -330,7 +333,7 @@ var applyTimeout = function () { /* Load markdown from /data/page into the ace editor. */ jQuery.ajax( { type: 'GET', - url: '/data/' + $.key( 'page' ), + url: baseUrl + '/data/' + $.key( 'page' ), success: function( data ) { editorSession.setValue( data ); } diff --git a/lib/gollum/frontend/templates/compare.mustache b/lib/gollum/frontend/templates/compare.mustache index 4595f20e..55afc777 100644 --- a/lib/gollum/frontend/templates/compare.mustache +++ b/lib/gollum/frontend/templates/compare.mustache @@ -6,11 +6,11 @@