Permalink
Browse files

more improvements

  • Loading branch information...
1 parent 99d8f30 commit 1b1e768ec83a186214387c3a202ff2fc0b6e9758 ojii committed Jun 4, 2010
View
@@ -1 +1 @@
-__version__ = '0.1.4'
+__version__ = '0.1.5'
@@ -39,27 +39,6 @@ function cmsplayer_ready (element, playlist, autoplay, playerid)
function displayPlayList() {
for (i=0; i < playlist.length; i++) {
song = playlist[i];
- display = "<li class='song' id='playlist_item_"+playerid+"_"+i+"'><span class='songname' id='cmsplay_song_"+i+"'>"+song.title+'</span>';
- if (song.artist_url)
- {
- display+=" - <a class='artist' href='"+song.artist_url+"'>"+song.artist_name+"</a>";
- }
- else if (song.artist_name)
- {
- display+=" - <span class='artist'>"+song.artist_name+"</span>";
- }
- if (song.credits_name)
- {
- if (song.credits_url)
- {
- display+=" - <a class='credits' href='"+song.credits_url+"'>"+song.credits_name+"</a>";
- }
- else
- {
- display+=" - <span class='credits'>"+song.credits_name+"</span>";
- }
- }
- $("#playlist_list_"+playerid +" ul").append(display);
$("#playlist_item_"+playerid+"_"+i).data( "index", i ).hover(
function() {
if (playItem != $(this).data("index")) {
View
@@ -16,6 +16,9 @@ def __unicode__(self):
@safe_json
def get_json_playlist(self):
+ return self.playlist()
+
+ def playlist(self):
playlist = []
ogg_support = self.ogg_support()
for song in self.songs.all():
@@ -24,7 +24,10 @@
<div id="playlist_list_{{ player.id }}" class="cmsplaylist">
<ul>
- </ul>
+ {% for song in player.playlist %}
+ {% include "jplayer/song.html" %}
+ {% endfor %}
+ </ul>
</div>
<script type="text/javascript">
$(document).ready(function(){
@@ -0,0 +1,19 @@
+<li class="song" id="playlist_item_{{ player.id }}_{{ forloop.counter0 }}">
+ <span class="songname">{{ song.title }}</span>
+ &nbsp;-&nbsp;
+ {% if song.artist_name %}
+ {% if song.artist_url %}
+ <a class="artist" href="{{ song.artist_url }}">{{ song.artist_name }}</a>"
+ {% else %}
+ <span class="artist">{{ song.artist_name }}</span>
+ {% endif %}
+ {% endif %}
+ &nbsp;-&nbsp;
+ {% if song.credits_name %}
+ {% if song.credits_url %}
+ <a class="credits" href="{{ song.credits_url }}">{{ song.credits_name }}</a>
+ {% else %}
+ <span class="credits">{{ song.credits_name }}</span>
+ {% endif %}
+ {% endif %}
+</li>
View
@@ -7,14 +7,23 @@
def _safe_json(data):
return mark_safe(dumps(data))
+def safe_json(func):
+ def decorated(*args, **kwargs):
+ return _safe_json(func(*args, **kwargs))
+ return decorated
+
class PlayerObject(object):
def __init__(self, playerid, playlist, autoplay, base_path, ogg_support):
self.id = playerid
- self.get_json_playlist = playlist
+ self.playlist = playlist
self.get_json_autoplay = autoplay
self.get_base_path = base_path
self.get_json_ogg_support = ogg_support
+ @safe_json
+ def get_json_playlist(self):
+ return self.playlist
+
def render(self, request):
return render_jplayer(self, request)
@@ -40,15 +49,9 @@ def _get_ogg(songobj):
except (KeyError, TypeError):
return hasattr(songobj, 'ogg') and bool(getattr(songobj, 'ogg', False))
oggsupport = _safe_json(all([_get_ogg(song) for song in playlist]))
- playlist = _safe_json(playlist)
autoplay = _safe_json(autoplay)
base_path = _safe_json(base_path)
return PlayerObject(playerid, playlist, autoplay, base_path, oggsupport)
def render_jplayer(player_object, request):
- return render_to_string('jplayer/player.html', {'player': player_object}, RequestContext(request))
-
-def safe_json(func):
- def decorated(*args, **kwargs):
- return _safe_json(func(*args, **kwargs))
- return decorated
+ return render_to_string('jplayer/player.html', {'player': player_object}, RequestContext(request))

0 comments on commit 1b1e768

Please sign in to comment.