I suggest that you have a look at the Text preview extension. It is reasonably small and covers all important parts such as how to let CKAN know that the extension can preview a file, how to load templates, how to load javascript and css and how to use the resource proxy (which is there to get around the same origin policy).
The current version of the plugin in CKAN uses a feature that allows defining how reasonable an extension can preview files which is not available in older CKANs.
There is a json preview extension in the stable version 2.0 of CKAN which is slightly smaller that the text-preview and supports older CKANs as well.
A minimal preview plugin looks something like (without the template):
import ckan.plugins as p
class Preview(p.SingletonPlugin):
p.implements(p.IResourcePreview, inherit=True)
def can_preview(self, data_dict):
format = data_dict['resource']['format']
return format.lower() == 'gtfs'
def preview_template(self, context, data_dict):
return 'preview.html'