From 7d7c13b9ec508ddcd265625743180ae115d04f0f Mon Sep 17 00:00:00 2001 From: Nikolai Kristiansen Date: Thu, 9 Jun 2011 05:05:49 +0200 Subject: [PATCH] Fixed check for playing video. Cleaned up som non-portable settings. Updated README. Other minor stuff. --- .gitignore | 1 - README.md | 29 +++++++++++++------ .../{django-sample.wsgi => django.wsgi} | 7 ++++- .../{initial-data.json => initial_data.json} | 0 oliver_screen/templates/public/index.html | 3 +- .../templates/public/now_playing.html | 17 ++++++++--- oliver_screen/urls.py | 7 ++++- 7 files changed, 46 insertions(+), 18 deletions(-) rename oliver_screen/{django-sample.wsgi => django.wsgi} (52%) rename oliver_screen/{initial-data.json => initial_data.json} (100%) diff --git a/.gitignore b/.gitignore index 4930e28..e256fd2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ *.swo settings.py oliver_screen.sqlite3 -django.wsgi diff --git a/README.md b/README.md index 34a74b1..9512cec 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,31 @@ Requirements ============ -* python-django -* python-pylast +* Django + * sudo apt-get install python-django +* mod\_wsgi + * sudo apt-get install libapache2-mod-wsgi + * sudo a2enmod wsgi # enable it in apache. +* pylast + * svn checkout http://pylast.googlecode.com/svn/trunk/ pylast-read-only + * cd pylast-read-only + * sudo python setup.py install You will also need a LastFM account and a API account (http://www.last.fm/api/account). Install with Apache =================== -* $ git clone git://github.com/nikolaik/oliver_screen.git -* Move and edit settings-sample.py to suit your needs. -* Make available static files under oliver_screen/oliver_screen/static by symlinking or setup a and Alias in your Apache config. -* Set MEDIA_URL to the URL where static files are served. -* Set LASTFM_APIKEY and LASTFM_API_SECRET -* Make sure mod_wsgi is installed and enabled in Apache. First rename and edit django-sample.wsgi. Then setup a WSGIAlias in your apache config pointing to the .wsgi-file. -* $ python manage.py syncdb (creating an admin user) +* Get the code + * $ git clone git://github.com/nikolaik/oliver\_screen.git +* Make available static files under oliver\_screen/oliver\_screen/static by symlinking or setup a and Alias in your Apache config. +* Then setup a WSGIScriptAlias in your apache config pointing to the full path of django.wsgi. + * sudo /etc/init.d/apache restart # load new Apache configuration settings +* Copy settings-sample.py to settings.py and edit to suit your needs. + * Set MEDIA\_URL to the URL where static files are served. + * Set LASTFM\_APIKEY and LASTFM\_API\_SECRET +* Create the database. + * $ python manage.py syncdb (creating an admin user) * Make sure the files have correct permission (readable by www-data). + * If you created a sqlite database, make sure the file is writeable by www-data. * Goto /admin and login with the admin user, then add a LastFMUser and make it active. * Setup your music player (f.ex Spotify) to scrobble to that account Last.fm account. * Goto / and you should be set :=) diff --git a/oliver_screen/django-sample.wsgi b/oliver_screen/django.wsgi similarity index 52% rename from oliver_screen/django-sample.wsgi rename to oliver_screen/django.wsgi index 1c2b93e..98c90a2 100644 --- a/oliver_screen/django-sample.wsgi +++ b/oliver_screen/django.wsgi @@ -1,9 +1,14 @@ import os import sys +from os.path import dirname, join + +def map_path(target_name=''): + '''Enables path names to be decided at runtime.''' + return join(dirname(__file__), target_name).replace('\\', '/') os.environ['DJANGO_SETTINGS_MODULE'] = 'oliver_screen.settings' -path = '/home/nikk/dev' +path = map_path("..") if path not in sys.path: sys.path.append(path) import django.core.handlers.wsgi diff --git a/oliver_screen/initial-data.json b/oliver_screen/initial_data.json similarity index 100% rename from oliver_screen/initial-data.json rename to oliver_screen/initial_data.json diff --git a/oliver_screen/templates/public/index.html b/oliver_screen/templates/public/index.html index 407fff0..8f40a1a 100644 --- a/oliver_screen/templates/public/index.html +++ b/oliver_screen/templates/public/index.html @@ -75,8 +75,7 @@ /* The API calls this function when the player's state changes. */ function onPlayerStateChange(event) { if (event.data == YT.PlayerState.ENDED) { - // Hide the player when the song ends - $("#player").hide(); + /* Could do something on this state or others... */ } } diff --git a/oliver_screen/templates/public/now_playing.html b/oliver_screen/templates/public/now_playing.html index ea1680d..ae52634 100644 --- a/oliver_screen/templates/public/now_playing.html +++ b/oliver_screen/templates/public/now_playing.html @@ -1,12 +1,18 @@ {% if now_playing %} {% if now_playing.video %} {% else %} + {% if now_playing.image %}
{% endif %} diff --git a/oliver_screen/urls.py b/oliver_screen/urls.py index cd0aba5..048dab6 100644 --- a/oliver_screen/urls.py +++ b/oliver_screen/urls.py @@ -3,11 +3,16 @@ from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() +from os.path import dirname, join + +def map_path(target_name): + '''Enables path names to be decided at runtime.''' + return join(dirname(__file__), target_name).replace('\\', '/') urlpatterns = patterns('', # static file serving for development (http://docs.djangoproject.com/en/dev/howto/static-files/) (r'^static/(?P.*)$', 'django.views.static.serve', - {'document_root': '/home/nikk/dev/edb/oliver_screen/oliver_screen/static'}), + {'document_root': map_path('static')}), (r'^admin/', include(admin.site.urls)), (r'^tracks/', include('oliver_screen.tracks.urls')), (r'^$', include('oliver_screen.main.urls')),