Mercurial > public > sg101
view podcast/views.py @ 693:ad69236e8501
For issue #52, update many 3rd party Javascript libraries.
Updated to jquery 1.10.2, jquery ui 1.10.3.
This broke a lot of stuff.
- Found a newer version of the jquery cycle all plugin (3.0.3).
- Updated JPlayer to 2.4.0.
- Updated to MarkItUp 1.1.14. This also required me to add multiline attributes
set to true on various buttons in the markdown set.
- As per a stackoverflow post, added some code to get multiline titles in
a jQuery UI dialog. They removed that functionality but allow you to put it
back.
Tweaked the MarkItUp preview CSS to show blockquotes in italic.
Did not update TinyMCE at this time. I'm not using the JQuery version and this
version appears to work ok for now.
What I should do is make a repo for MarkItUp and do a vendor branch thing so
I don't have to futz around diffing directories to figure out if I'll lose
changes when I update.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 04 Sep 2013 19:55:20 -0500 |
parents | 89b240fe9297 |
children | e932f2ecd4a7 |
line wrap: on
line source
""" Views for the podcast application. """ import json import os.path from urlparse import urlparse from django.shortcuts import render_to_response from django.template import RequestContext from django.shortcuts import get_object_or_404 from podcast.models import Channel from podcast.models import Item def get_ext_from_url(url): """ This function returns the extension part of the path from the given url. """ ext = os.path.splitext(urlparse(url).path)[1] if ext.startswith('.'): ext = ext[1:] return ext def jplayer_params(ext, url, alt_ext, alt_url): """ Compute and returns a 2-tuple: (jplayer_media, jplayer_supplied) where jplayer_media: a string representation of the JSON for the jplayer setMedia parameter jplayer_supplied: the string for the jplayer supplied parameter media_list is an input list or tuple of 2-tuples of the form (media_type, url) where media_type is e.g. mp3, m4a, ogg, etc. """ media = dict([(ext, url)]) if alt_ext and alt_url: media[alt_ext] = alt_url # prefer mp4 to mp3 if alt_ext is None: supplied = [ext] elif ext == "m4a": supplied = (ext, alt_ext) else: supplied = (alt_ext, ext) supplied = ", ".join(supplied) return json.dumps(media), supplied def index(request): try: channel = Channel.objects.get(pk=1) except Channel.DoesNotExist: channel = None return render_to_response('podcast/index.html', { 'channel': channel, }, context_instance = RequestContext(request)) def detail(request, id): podcast = get_object_or_404(Item.objects.select_related(), pk = id) ext = get_ext_from_url(podcast.enclosure_url) alt_ext = None if podcast.alt_enclosure_url: alt_ext = get_ext_from_url(podcast.alt_enclosure_url) jplayer_media, jplayer_supplied = jplayer_params(ext, podcast.enclosure_url, alt_ext, podcast.alt_enclosure_url) return render_to_response('podcast/detail.html', { 'channel': podcast.channel, 'podcast': podcast, 'ext': ext, 'alt_ext': alt_ext, 'jplayer_media': jplayer_media, 'jplayer_supplied': jplayer_supplied, }, context_instance = RequestContext(request)) def feed(request): try: channel = Channel.objects.get(pk=1) except Channel.DoesNotExist: channel = None if channel: channel.items = Item.objects.filter(channel=channel) return render_to_response('podcast/feed.xml', { 'channel': channel, }, context_instance = RequestContext(request))