Skip to content

Commit

Permalink
Merge branch 'release/0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Lauber committed Jan 28, 2012
2 parents e5b4974 + 0b0bd78 commit d1bd115
Show file tree
Hide file tree
Showing 39 changed files with 1,542 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
django-mpd-client

A Basic client for controlling an MPD daemon through a django backed web interface. Focus will be on devloping for a mobile platform first, while accessing the MPDClient through an ajax interface.

Versions:

- Version 0.1:
- Implemented basic ajax views for getting status, and controlling MPD.
- Play
- Pause
- Previous
- Next
- Volume
- Random
- Repeat

- Implemented a Controls index page capable of accessing the ajax commands, and displaying the current track information.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1
8 changes: 8 additions & 0 deletions mpd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#Editor Backup files
*.*~

# Compiled Python Files #
*.pyc

# Datbase Files #
*.db
Empty file added mpd/__init__.py
Empty file.
80 changes: 80 additions & 0 deletions mpd/ajax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from django.conf import settings
from django.http import HttpResponse, HttpResponseServerError
from django.template import RequestContext
from utilities.mpd import MPDClient
from utilities.viewtools import as_json, using_mpd

# Confiure Logging
import logging
logger = logging.getLogger(__name__)


@as_json
@using_mpd
def status( request ):
mpd = MPDClient()
with mpd.connect(settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT) as mpd:
data = mpd.status()
data.update( mpd.currentsong() )
return data


# Playback Controls
@using_mpd
def play( request ):
mpd = MPDClient()
with mpd.connect( settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT ) as mpd:
if mpd.status().get('state', None) == 'play':
mpd.pause()
else:
mpd.play()
return HttpResponse( "OK" )

@using_mpd
def prev( request ):
mpd = MPDClient()
with mpd.connect( settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT ) as mpd:
mpd.previous()
return HttpResponse( "OK" )

@using_mpd
def next( request ):
mpd = MPDClient()
with mpd.connect( settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT ) as mpd:
mpd.next()
return HttpResponse( "OK" )

@using_mpd
def stop( request ):
mpd = MPDClient()
with mpd.connect( settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT ) as mpd:
mpd.stop()
return HttpResponse( "OK" )

# General Controls
@using_mpd
def repeat( request ):
mpd = MPDClient()
with mpd.connect( settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT ) as mpd:
repeat = int( mpd.status()['repeat'] )
mpd.repeat( 0 if repeat == 1 else 1 )
return HttpResponse( "Repeat: %s" % repeat )


@using_mpd
def random( request ):
mpd = MPDClient()
with mpd.connect( settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT ) as mpd:
random = int( mpd.status()['random'] )
mpd.random( 0 if random == 1 else 1 )

return HttpResponse( "Random: %s" % random )

@using_mpd
def volume( request, volume ):
mpd = MPDClient()
with mpd.connect( settings.MPD_CLIENT_HOST, settings.MPD_CLIENT_PORT ) as mpd:
mpd.setvol(volume)
volume = mpd.status()['volume']
return HttpResponse( "Volume: %s" % volume )

14 changes: 14 additions & 0 deletions mpd/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python
from django.core.management import execute_manager
import imp
try:
imp.find_module('settings') # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
sys.exit(1)

import settings

if __name__ == "__main__":
execute_manager(settings)
Empty file added mpd/media/.gitignore
Empty file.
Empty file added mpd/media/css/.gitignore
Empty file.
60 changes: 60 additions & 0 deletions mpd/media/css/UIElements/UIElements.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@import url("userAgentOverride.css");
@import url("navigation.css");
@import url("inputs.css");
@import url("display.css");
/*@import url("selectors.css");*/

/* Classes */


.rounded {
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
border-radius: 8px;
}

.rounded > *:first-child {
-moz-border-top-left-radius: 8px;
-webkit-border-top-left-radius: 8px;
-khtml-border-top-left-radius: 8px;
border-top-left-radius: 8px;

-moz-border-top-right-radius: 8px;
-webkit-border-top-right-radius: 8px;
-khtml-border-top-right-radius: 8px;
border-top-right-radius: 8px;
}

.rounded > *:last-child {
-moz-border-bottom-left-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-khtml-border-bottom-left-radius: 8px;
border-bottom-left-radius: 8px;

-moz-border-bottom-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-khtml-border-bottom-right-radius: 8px;
border-bottom-right-radius: 8px;
}
/* UI Elements */


.breadcrumbs, .box, .check, .menu, .radio, .slider, .text, .toggle {
min-height:35px;
font-size: 30px;
text-decoration:none;
margin-top: 5px;
text-indent:5px;
}

.box, .check, .menu, .radio, .slider, .text, .toggle {
border: solid 2px #777777;
background:white;
}






42 changes: 42 additions & 0 deletions mpd/media/css/UIElements/breadcrumbs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#breadcrumbs {
margin-top:3px;
float:left;

}
#breadcrumbs > .crumb {
display:table-cell;
padding: 3px 8px;

color:white;
text-decoration:none;
border: solid 1px #555555;
background: -webkit-gradient(linear,0% 0%,0% 100%,from(#ADB5BF),color-stop(3%,#909CAD),color-stop(50%,#687B93),color-stop(51%,#61759F),color-stop(97%,#4D6492),to(#0D1622));
}

#breadcrumbs > .crumb:first-child {

border-left-style:solid;

-moz-border-top-left-radius: 8px;
-webkit-border-top-left-radius: 8px;
-khtml-border-top-left-radius: 8px;
border-top-left-radius: 8px;

-moz-border-bottom-left-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-khtml-border-bottom-left-radius: 8px;
border-bottom-left-radius: 8px;
}

#breadcrumbs > .crumb:last-child {

-moz-border-top-right-radius: 8px;
-webkit-border-top-right-radius: 8px;
-khtml-border-top-right-radius: 8px;
border-top-right-radius: 8px;

-moz-border-bottom-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-khtml-border-bottom-right-radius: 8px;
border-bottom-right-radius: 8px;
}
Empty file.
96 changes: 96 additions & 0 deletions mpd/media/css/UIElements/inputs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Radio buttons and checkboxes render the same,
but have different javascript functionality.*/
.radio, .check {
border: solid 2px #777777;
}

.radio > *, .check > * {
float:left;
height: 35px;
clear: both;
width:100%;
border-bottom:solid 1px #777777;
}

.radio > *:last-child, .check > *:last-child {
float:none;
clear:both;
border-bottom:none;
width:100%;
display:block;
}

.radio > .checked, .check > .checked {
background: #6A90A9;
}

.radio > *:hover, .check > *:hover {
background: #9AC0D9;
}

/* Toggle Switches, for simple boolean values,
toggles the checked class via javascript.*/
.toggleSwitch {
width:94px;
height:27px;
background-position: 0 0px;
-webkit-appearance: none;
border-radius: 0px !important;
}

.toggle > .toggleSwitch {
float:right;
margin-top:4px;
margin-right: 5px;
}

.toggleSwitch.checked {
background:url("/m/img/toggleOn.png");
}
.toggleSwitch:not(.checked) {
background:url("/m/img/toggleOff.png");
}

.toggle {
font-size: 30px;
}

/* Text Fields */
.text {
}
.text > label {

}
.text.rounded > label {
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
border-radius: 8px;
}
.text >input[type=text] {
position:absolute;
right: 0px;
border-style:inset 1px #77777;
margin-right:5px;
font-size: 26px;
padding-left: 5px;
}

.text.rounded > input[type=text] {
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
border-radius: 8px;
}

/* Text Boxes */



/* Input Sliders */
.slider input[type=range] {
float:right;
margin-top:10px;
margin-right: 10px;
}

49 changes: 49 additions & 0 deletions mpd/media/css/UIElements/navigation.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* menu buttons */
.menu {
font-size: 30px;
}

.menu:hover {
background: #9AC0D9;
}

/* Breadcrumbs */
.breadcrumbs {
margin:0px;
}

.breadcrumbs > .crumb {
display:table-cell;
padding: 3px 8px;
text-decoration:none;
border: solid 2px #555555;
border-left:none;
}

.breadcrumbs > .crumb:first-child {

border: solid 2px #555555;

-moz-border-top-left-radius: 8px;
-webkit-border-top-left-radius: 8px;
-khtml-border-top-left-radius: 8px;
border-top-left-radius: 8px;

-moz-border-bottom-left-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-khtml-border-bottom-left-radius: 8px;
border-bottom-left-radius: 8px;
}

.breadcrumbs > .crumb:last-child {

-moz-border-top-right-radius: 8px;
-webkit-border-top-right-radius: 8px;
-khtml-border-top-right-radius: 8px;
border-top-right-radius: 8px;

-moz-border-bottom-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-khtml-border-bottom-right-radius: 8px;
border-bottom-right-radius: 8px;
}
Loading

0 comments on commit d1bd115

Please sign in to comment.