Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

First functional client.

  • Loading branch information...
commit ec99403dc3ef24f2863f8418477ae710e3699cb9 1 parent b368fe2
Dusty Phillips authored
View
35 pyjaco/walter.py
@@ -1,35 +0,0 @@
-class Player:
- def play(self):
- post("/play.html", {"some": "arg"}, self.update_status)
-
- def update_status(self, text):
- text = py(text)
- html('#status', text)
-
- def get_status(self):
- get("/status.html", self.update_status)
-
-player = Player()
-
-@JSVar("window")
-def setup():
- click(".play", player.play)
- window.setInterval(js(player.get_status), js(3000))
-
-@JSVar("jQuery")
-def click(selector, func):
- jQuery(js(selector)).click(js(func))
-
-@JSVar("jQuery")
-def html(selector, text):
- jQuery(js(selector)).html(js(text))
-
-@JSVar("jQuery")
-def post(url, params={}, func=None):
- jQuery.post(js(url), js(params), js(func))
-
-@JSVar("jQuery")
-def get(url, func=None):
- jQuery.get(js(url), js(func))
-
-jQuery(js(setup))
View
5 www/.aspen/mpdclient.py
@@ -11,6 +11,5 @@ def get_status_line(client):
if status['state'] != 'play':
return status['state'].capitalize()
else:
- song_id = status['songid']
- song_info = client.playlistinfo(song_id)
- return "%(artist)s - %(title)s" % song_info[0]
+ song_info = client.currentsong()
+ return "%(artist)s - %(title)s" % song_info
View
3  www/index.html
@@ -24,7 +24,10 @@
<input type="submit" value="Save" />
</form>
{% else %}
+ <div class="prev button">prev</div>
<div class="play button">play</div>
+ <div class="next button">next</div>
+ <div class="clearfix"></div>
<div id="status">Unknown...</div>
{% end %}
View
118 www/js/walter.js
@@ -1,108 +1,22 @@
-var Player = __inherit(object, 'Player', true);
-Player.PY$play = function() {
- var self = this;
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v1 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- post(str('/play.html'), dict([str('some'), str('arg')]), self.PY$__getattr__('update_status'));
-return None;
-};
-Player.PY$update_status = function() {
- var self = this;
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v2 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- var text = ('text' in __kwargs) ? __kwargs['text'] : $v2[0];
- delete __kwargs.text
- if (text === undefined) {
-__builtins__.PY$print('Player.update_status() did not get parameter text'); };
- text = py(text);
- html(str('#status'), text);
-return None;
-};
-Player.PY$get_status = function() {
- var self = this;
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v3 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- get(str('/status.html'), self.PY$__getattr__('update_status'));
-return None;
-};
-var player = Player();
-var setup = function() {
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v4 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- click(str('.play'), player.PY$__getattr__('play'));
- window.setInterval(js(player.PY$__getattr__('get_status')), js(int(3000)));
-return None;
+function play() {
+ $.post("/play.html", update_status);
}
-var click = function() {
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v5 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- var selector = ('selector' in __kwargs) ? __kwargs['selector'] : $v5[0];
- delete __kwargs.selector
- if (selector === undefined) {
-__builtins__.PY$print('click() did not get parameter selector'); };
- var func = ('func' in __kwargs) ? __kwargs['func'] : $v5[1];
- delete __kwargs.func
- if (func === undefined) {
-__builtins__.PY$print('click() did not get parameter func'); };
- jQuery(js(selector)).click(js(func));
-return None;
+function next() {
+ $.post("/next.html", update_status);
}
-var html = function() {
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v6 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- var selector = ('selector' in __kwargs) ? __kwargs['selector'] : $v6[0];
- delete __kwargs.selector
- if (selector === undefined) {
-__builtins__.PY$print('html() did not get parameter selector'); };
- var text = ('text' in __kwargs) ? __kwargs['text'] : $v6[1];
- delete __kwargs.text
- if (text === undefined) {
-__builtins__.PY$print('html() did not get parameter text'); };
- jQuery(js(selector)).html(js(text));
-return None;
+function prev() {
+ $.post("/prev.html", update_status);
}
-var post = function() {
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v7 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- var url = ('url' in __kwargs) ? __kwargs['url'] : $v7[0];
- delete __kwargs.url
- if (url === undefined) {
-__builtins__.PY$print('post() did not get parameter url'); };
- var params = $v7[1];
- if (params === undefined) { params = __kwargs.params === undefined ? dict([]) : __kwargs.params; };
- delete __kwargs.params
- if (params === undefined) {
-__builtins__.PY$print('post() did not get parameter params'); };
- var func = $v7[2];
- if (func === undefined) { func = __kwargs.func === undefined ? __builtins__.PY$None : __kwargs.func; };
- delete __kwargs.func
- if (func === undefined) {
-__builtins__.PY$print('post() did not get parameter func'); };
- jQuery.post(js(url), js(params), js(func));
-return None;
+function get_status() {
+ $.get("/status.html", update_status);
}
-var get = function() {
- var __kwargs = __kwargs_get(arguments);
- var __varargs = __varargs_get(arguments);
- var $v8 = Array.prototype.slice.call(arguments).concat(js(__varargs));
- var url = ('url' in __kwargs) ? __kwargs['url'] : $v8[0];
- delete __kwargs.url
- if (url === undefined) {
-__builtins__.PY$print('get() did not get parameter url'); };
- var func = $v8[1];
- if (func === undefined) { func = __kwargs.func === undefined ? __builtins__.PY$None : __kwargs.func; };
- delete __kwargs.func
- if (func === undefined) {
-__builtins__.PY$print('get() did not get parameter func'); };
- jQuery.get(js(url), js(func));
-return None;
+function update_status(text) {
+ $("#status").html(text);
}
-jQuery(js(setup));
+$(function() {
+ $(".play").click(play);
+ $(".next").click(next);
+ $(".prev").click(prev);
+ window.setInterval(get_status, js(3000));
+});
View
7 www/next.html
@@ -0,0 +1,7 @@
+import mpdclient
+^L
+client = mpdclient.get_client(request)
+client.next()
+status = mpdclient.get_status_line(client)
+^L
+{{status}}
View
7 www/prev.html
@@ -0,0 +1,7 @@
+import mpdclient
+^L
+client = mpdclient.get_client(request)
+client.previous()
+status = mpdclient.get_status_line(client)
+^L
+{{status}}
View
8 www/walter.css
@@ -1,4 +1,6 @@
div.button {
+ float: left;
+ margin-right: 10px;
border-style: outset;
border-width: 2px;
border-color: #009;
@@ -23,4 +25,8 @@ div.button {
color-stop(0.5, rgb(30,43,36)),
color-stop(0.75, rgb(36,88,219))
);
-}
+}
+.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
+* html .clearfix{height:1%;}
+.clearfix{display:inline-block;}
+.clearfix{display:block;}
Please sign in to comment.
Something went wrong with that request. Please try again.