Skip to content

Instantly share code, notes, and snippets.

@rfunduk
Created August 16, 2011 16:31
Show Gist options
  • Save rfunduk/1149484 to your computer and use it in GitHub Desktop.
Save rfunduk/1149484 to your computer and use it in GitHub Desktop.
<div id="footer"></div>
#!(path-to-python, eg. /usr/bin/python)
# get_timestamp.py
# A very simple CGI script that, given a path to a file,
# will return a timestamp of the last modified date/time.
import cgi
from os import getcwd
from os.path import getmtime, join
from datetime import datetime
from time import localtime
TIMEZONE = -5
data = cgi.FieldStorage()
if data.has_key( 'file' ):
filename = join( getcwd(), data['file'].value )
modified = datetime.fromtimestamp( getmtime( filename ) + \
( TIMEZONE * 3600 ) )
print "Content-Type: text/plain\r\n\r\n"
print "This file last modified on " + \
modified.strftime( "%B %d, %Y at %I:%M %p EST" )
function get_timestamp( filename, element ) {
$.ajax( {
type: 'get',
url: '/cgi-bin/get_timestamp.py',
data: 'file=../' + filename,
success: function( result ) {
element.html( result );
}
} );
}
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript">
$(document).ready( function () {
get_timestamp( 'index.html', $('#footer') );
} );
</script>
$('#links li a').each( function () {
var file = $(this).attr( 'href' ).slice( 1 );
span = $("<span id='" + file + "'>&nbsp;</span>" );
$(this).after( span );
get_timestamp( file, span );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment