diff browser_side/radiocol.py @ 128:2849ec993d89

basic radio collective
author Goffi <goffi@goffi.org>
date Mon, 23 Jan 2012 00:15:19 +0100
parents e19a8de8b3de
children dd0d39ae7d24
line wrap: on
line diff
--- a/browser_side/radiocol.py	Sun Jan 22 19:38:05 2012 +0100
+++ b/browser_side/radiocol.py	Mon Jan 23 00:15:19 2012 +0100
@@ -24,13 +24,14 @@
 from pyjamas.ui.HorizontalPanel import HorizontalPanel
 from pyjamas.ui.SimplePanel import SimplePanel
 from pyjamas.ui.FormPanel import FormPanel
-from pyjamas.ui.DockPanel import DockPanel
 from pyjamas.ui.NamedFrame import NamedFrame
 from pyjamas.ui.FileUpload import FileUpload
 from pyjamas.ui.Label import Label
 from pyjamas.ui.Button import Button
 from pyjamas.ui.ClickListener import ClickHandler
 from pyjamas.ui.MouseListener import MouseHandler
+from pyjamas.ui.Hidden import Hidden
+from pyjamas.ui.HTML import HTML
 from pyjamas import Window
 
 from jid import JID
@@ -41,22 +42,21 @@
 
     def __init__(self):
         VerticalPanel.__init__(self)
+        self.title = Label("title:")
         self.artist = Label("artist:")
         self.album = Label("album:")
-        self.title = Label("title:")
+        self.add(self.title)
         self.add(self.artist)
         self.add(self.album)
-        self.add(self.title)
 
 class ControlPanel(FormPanel):
     """Panel used to show controls to add a song, or vote for the current one"""
 
-    def __init__(self):
+    def __init__(self, referee):
         FormPanel.__init__(self)
         self.setEncoding(FormPanel.ENCODING_MULTIPART)
         self.setMethod(FormPanel.METHOD_POST)
         self.setAction("upload") # set this as appropriate
-        #self.setTarget("results")
         vPanel = VerticalPanel()
 
         hPanel = HorizontalPanel()
@@ -68,9 +68,10 @@
         hPanel.add(Button("Upload song", getattr(self, "onBtnClick")))
 
         vPanel.add(hPanel)
-
-        results = NamedFrame("results")
-        vPanel.add(results)
+        
+        #We need to know the referee
+        referee_field = Hidden('referee', referee)
+        vPanel.add(referee_field)
 
         self.add(vPanel)
         self.addFormHandler(self)
@@ -102,19 +103,21 @@
         # Now we set up the layout
         self.left_panel = VerticalPanel()
         self.add(self.left_panel)
-        self.right_panel = DockPanel()
+        self.right_panel = VerticalPanel()
         self.metadata_panel = MetadataPanel()
-        self.right_panel.add(self.metadata_panel, DockPanel.CENTER)
-        self.control_panel = ControlPanel()
-        self.right_panel.add(self.control_panel, DockPanel.SOUTH)
+        self.right_panel.add(self.metadata_panel)
+        self.control_panel = ControlPanel(self.referee)
+        self.right_panel.add(self.control_panel)
         self.add(self.right_panel)
-        self.right_panel.setBorderWidth(1)
+        #self.right_panel.setBorderWidth(1)
         self.left_panel.add(Label("Musique 1"))
         self.left_panel.add(Label("Musique 2"))
-        self.left_panel.add(Label("Musique 3"))
-        self.left_panel.add(Label("Musique 4"))
-        self.left_panel.add(Label("Musique 5"))
+        self.audio = HTML("")
+        self.right_panel.add(self.audio)
 
         
         self.addClickListener(self)
+    
+    def radiocolPreload(self, filename, title, artist, album):
+        self.audio.setHTML('<audio preload="auto" controls="controls" src="radiocol/%s" />' % html_sanitize(filename))