diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index 8acf7605..5be0e43b 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -5,6 +5,7 @@ require 'gollum-lib' require 'mustache/sinatra' require 'useragent' require 'stringex' +require 'json' require 'gollum' require 'gollum/views/layout' @@ -131,6 +132,14 @@ module Precious Gollum::Wiki.new(settings.gollum_path, settings.wiki_options) end + get '/last-commit-info' do + content_type :json + if page = wiki_page(params[:path]).page + version = page.last_version + {:author => version.author.name, :date => version.authored_date}.to_json + end + end + get '/emoji/:name' do begin [200, {'Content-Type' => 'image/png'}, emoji(params['name'])] @@ -509,7 +518,6 @@ module Precious name = extract_name(fullpath) || wiki.index_page path = extract_path(fullpath) || '/' - if page = wiki.paged(name, path, exact = true) @page = page @name = name @@ -518,7 +526,6 @@ module Precious # Extensions and layout data @editable = true - @page_exists = !page.last_version.nil? @toc_content = wiki.universal_toc ? @page.toc_data : nil @mathjax = wiki.mathjax @h1_title = wiki.h1_title diff --git a/lib/gollum/public/gollum/javascript/gollum.js b/lib/gollum/public/gollum/javascript/gollum.js index 5fc447d3..c5b1460f 100755 --- a/lib/gollum/public/gollum/javascript/gollum.js +++ b/lib/gollum/public/gollum/javascript/gollum.js @@ -306,6 +306,19 @@ $(document).ready(function() { $.GollumEditor(); } + if( $("#last-edit").length ) { + $("#page-info-toggle").click ( function () { + $.ajax({ + url: '/last-commit-info', + data: {path: $("#page-info-toggle").data('pagepath')}, + success: function ( data ) { + $("#last-edit").html('Last edited by ' + data.author + ', ' + data.date); + } + }); + $("#last-edit").html(' Getting commit info...'); + }) + } + if( $('#wiki-wrapper.create').length ){ $("#gollum-editor-submit").click( function() { window.onbeforeunload = null; } ); $("#gollum-editor-body").one('change', function(){ diff --git a/lib/gollum/templates/page.mustache b/lib/gollum/templates/page.mustache index 80d1bf85..f23aec2a 100644 --- a/lib/gollum/templates/page.mustache +++ b/lib/gollum/templates/page.mustache @@ -40,12 +40,10 @@ Mousetrap.bind(['e'], function( e ) { class="action-edit-page">Edit {{/editable}} {{/allow_editing}} - {{#page_exists}}