Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nick
committed
Nov 1, 2010
1 parent
60c4c61
commit 212b32e
Showing
12 changed files
with
208 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,8 @@ header: | |
acl: | ||
- auth: guest | ||
|
||
footer: | ||
- name: add_song | ||
acl: | ||
- auth: user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
from google.appengine.api import users | ||
|
||
from lib.djama import action | ||
|
||
from models.songs import Song | ||
|
||
class add_song(action): | ||
def get(self): | ||
self._print('eee') | ||
def post(self): | ||
if not users.get_current_user(): | ||
self._print('{"status":"0", "message":"Not logged"}') | ||
|
||
errors = False | ||
params = {} | ||
for field in ['song_name', 'author_name', 'album_name', 'album_year', 'song_uri']: | ||
if self.request.params.get(field): | ||
params[field] = self.request.params.get(field) | ||
else: | ||
errors = True | ||
|
||
if not errors: | ||
song = Song() | ||
song.owner = users.get_current_user() | ||
song.uri = params['song_uri'] | ||
song.name = params['song_name'] | ||
song.author = params['author_name'] | ||
song.album = params['album_name'] | ||
song.albumYear = params['album_year'] | ||
song.status = True; | ||
song.put() | ||
|
||
self._print('{"status":"1", "message":"Added successully"}') | ||
else: | ||
self._print('{"status":"0", "message":"Not all fields are filled"}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
.bold { | ||
font-weight:bold; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
#add_song { | ||
position:absolute; | ||
top:50px; | ||
left:50%; | ||
width:500px; | ||
margin-left:-250px; | ||
display:none; | ||
} | ||
|
||
#add_song input { | ||
border:1px solid #000; | ||
background:#F1FFDE; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
function add_song(action) { | ||
var errors = false; | ||
dojo.forEach(['song_name', 'author_name', 'album_name', 'album_year', 'song_uri'], function(item){ | ||
var _item = dojo.byId(item); | ||
|
||
_item.style.backgroundColor = '#F1FFDE'; | ||
if (_item.value == '') { | ||
errors = true; | ||
_item.style.backgroundColor = '#FFDEDE'; | ||
} | ||
}); | ||
|
||
if (!errors) { | ||
dojo.xhrPost({ | ||
form: dojo.byId("add_song_form"), | ||
handleAs: "json", | ||
load: function(data) { | ||
if (data.status == 1) { | ||
console.log(data.message); | ||
if (action == 'close') { | ||
add_song_close(); | ||
} else { | ||
dojo.byId('song_name').value = ''; | ||
dojo.byId('song_uri').value = ''; | ||
} | ||
} else { | ||
alert(data.message); | ||
} | ||
}, | ||
error: function(error) { | ||
console.log('error, crap!'); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
function add_song_close() { | ||
var add_song_window = dojo.byId('add_song'); | ||
add_song_window.style.display = 'none'; | ||
Player.load(); | ||
} | ||
|
||
function add_song_show() { | ||
var add_song_window = dojo.byId('add_song'); | ||
add_song_window.style.display = 'block'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<a href="javascript:void(0);" onclick="add_song_show();">Add new Song</a> | ||
<div id="add_song"> | ||
<form action="/api/songs/add_song.json" method="post" id="add_song_form"> | ||
<b>Add Song:</b><br /> | ||
<label for="song_name">Song Name: </label><input type="text" id="song_name" name="song_name"><br /> | ||
<label for="author_name">Author Name: </label><input type="text" id="author_name" name="author_name"><br /> | ||
<label for="album_name">Album Name: </label><input type="text" id="album_name" name="album_name"><br /> | ||
<label for="album_yeaar">Album Year: </label><input type="text" id="album_year" name="album_year"><br /> | ||
<label for="song_uri">Song Uri: </label><input type="text" id="song_uri" name="song_uri"><br /> | ||
<a href="javascript:void(0);" onclick="add_song('close');">Submit</a> | | ||
<a href="javascript:void(0);" onclick="add_song('another');">Submit and add more</a> | | ||
<a href="javascript:void(0);" onclick="add_song_close();">Cancel</a> | ||
</form> | ||
</div> | ||
|
||
<script type="text/javascript" src="/static/js/widgets/footer/add_song.js"></script> | ||
<link rel="stylesheet" href="/static/css/widgets/footer/add_song.css" type="text/css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div> | ||
Hey, {{ user }} | <a href="{{ url }}">Logout</a> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,54 @@ | ||
Heeey! | ||
|
||
<html> | ||
<head> | ||
<title>Your music on pyDjama</title> | ||
<script type="text/javascript"> | ||
var mainJsonUri = '/api/songs/main.json'; | ||
</script> | ||
</head> | ||
<body> | ||
<object | ||
class="playerpreview" | ||
id="myFlash" | ||
type="application/x-shockwave-flash" | ||
data="/static/player_mp3_js.swf" | ||
width="1" | ||
height="1"> | ||
|
||
<param name="movie" value="/static/player_mp3_js.swf" /> | ||
<param name="AllowScriptAccess" value="always" /> | ||
<param name="FlashVars" value="listener=Player&interval=500" /> | ||
|
||
</object> | ||
{% if widgets.header %} | ||
{% for widget in widgets.header %} | ||
{{ widget }} | ||
{% endfor %} | ||
{% endif %} | ||
{% endif %} | ||
|
||
<div id="loading_shadow"></div> | ||
<div id="loading">Loading</div> | ||
|
||
<div id="player"> | ||
<div class="controls"> | ||
<ul> | ||
<li><a href="javascript:void(0);" onclick="Player.playPrev();">Prev</a></li> | ||
<li><a href="javascript:void(0);" onclick="Player.play();">Play</a></li> | ||
<li><a href="javascript:void(0);" onclick="Player.pause();">Pause</a></li> | ||
<li><a href="javascript:void(0);" onclick="Player.playNext();">Next</a></li> | ||
<li><a href="javascript:void(0);" onclick="Player.stop();">Stop</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
<ul id="playlist"> | ||
</ul> | ||
|
||
<link rel="stylesheet" href="/static/css/alpha/index.css" type="text/css" /> | ||
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" type="text/javascript"></script> | ||
<script src="/static/js/player/player.js" type="text/javascript"></script> | ||
{% if widgets.footer %} | ||
{% for widget in widgets.footer %} | ||
{{ widget }} | ||
{% endfor %} | ||
{% endif %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
from lib.djama import widget | ||
|
||
class add_song(widget): | ||
def pre_dispatch(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters