comparison 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
comparison
equal deleted inserted replaced
127:e19a8de8b3de 128:2849ec993d89
22 import pyjd # this is dummy in pyjs 22 import pyjd # this is dummy in pyjs
23 from pyjamas.ui.VerticalPanel import VerticalPanel 23 from pyjamas.ui.VerticalPanel import VerticalPanel
24 from pyjamas.ui.HorizontalPanel import HorizontalPanel 24 from pyjamas.ui.HorizontalPanel import HorizontalPanel
25 from pyjamas.ui.SimplePanel import SimplePanel 25 from pyjamas.ui.SimplePanel import SimplePanel
26 from pyjamas.ui.FormPanel import FormPanel 26 from pyjamas.ui.FormPanel import FormPanel
27 from pyjamas.ui.DockPanel import DockPanel
28 from pyjamas.ui.NamedFrame import NamedFrame 27 from pyjamas.ui.NamedFrame import NamedFrame
29 from pyjamas.ui.FileUpload import FileUpload 28 from pyjamas.ui.FileUpload import FileUpload
30 from pyjamas.ui.Label import Label 29 from pyjamas.ui.Label import Label
31 from pyjamas.ui.Button import Button 30 from pyjamas.ui.Button import Button
32 from pyjamas.ui.ClickListener import ClickHandler 31 from pyjamas.ui.ClickListener import ClickHandler
33 from pyjamas.ui.MouseListener import MouseHandler 32 from pyjamas.ui.MouseListener import MouseHandler
33 from pyjamas.ui.Hidden import Hidden
34 from pyjamas.ui.HTML import HTML
34 from pyjamas import Window 35 from pyjamas import Window
35 36
36 from jid import JID 37 from jid import JID
37 from tools import html_sanitize 38 from tools import html_sanitize
38 39
39 40
40 class MetadataPanel(VerticalPanel): 41 class MetadataPanel(VerticalPanel):
41 42
42 def __init__(self): 43 def __init__(self):
43 VerticalPanel.__init__(self) 44 VerticalPanel.__init__(self)
45 self.title = Label("title:")
44 self.artist = Label("artist:") 46 self.artist = Label("artist:")
45 self.album = Label("album:") 47 self.album = Label("album:")
46 self.title = Label("title:") 48 self.add(self.title)
47 self.add(self.artist) 49 self.add(self.artist)
48 self.add(self.album) 50 self.add(self.album)
49 self.add(self.title)
50 51
51 class ControlPanel(FormPanel): 52 class ControlPanel(FormPanel):
52 """Panel used to show controls to add a song, or vote for the current one""" 53 """Panel used to show controls to add a song, or vote for the current one"""
53 54
54 def __init__(self): 55 def __init__(self, referee):
55 FormPanel.__init__(self) 56 FormPanel.__init__(self)
56 self.setEncoding(FormPanel.ENCODING_MULTIPART) 57 self.setEncoding(FormPanel.ENCODING_MULTIPART)
57 self.setMethod(FormPanel.METHOD_POST) 58 self.setMethod(FormPanel.METHOD_POST)
58 self.setAction("upload") # set this as appropriate 59 self.setAction("upload") # set this as appropriate
59 #self.setTarget("results")
60 vPanel = VerticalPanel() 60 vPanel = VerticalPanel()
61 61
62 hPanel = HorizontalPanel() 62 hPanel = HorizontalPanel()
63 hPanel.setSpacing(5) 63 hPanel.setSpacing(5)
64 self.field = FileUpload() 64 self.field = FileUpload()
66 hPanel.add(self.field) 66 hPanel.add(self.field)
67 67
68 hPanel.add(Button("Upload song", getattr(self, "onBtnClick"))) 68 hPanel.add(Button("Upload song", getattr(self, "onBtnClick")))
69 69
70 vPanel.add(hPanel) 70 vPanel.add(hPanel)
71 71
72 results = NamedFrame("results") 72 #We need to know the referee
73 vPanel.add(results) 73 referee_field = Hidden('referee', referee)
74 vPanel.add(referee_field)
74 75
75 self.add(vPanel) 76 self.add(vPanel)
76 self.addFormHandler(self) 77 self.addFormHandler(self)
77 78
78 def onBtnClick(self): 79 def onBtnClick(self):
100 self.setStyleName("radiocolPanel") 101 self.setStyleName("radiocolPanel")
101 102
102 # Now we set up the layout 103 # Now we set up the layout
103 self.left_panel = VerticalPanel() 104 self.left_panel = VerticalPanel()
104 self.add(self.left_panel) 105 self.add(self.left_panel)
105 self.right_panel = DockPanel() 106 self.right_panel = VerticalPanel()
106 self.metadata_panel = MetadataPanel() 107 self.metadata_panel = MetadataPanel()
107 self.right_panel.add(self.metadata_panel, DockPanel.CENTER) 108 self.right_panel.add(self.metadata_panel)
108 self.control_panel = ControlPanel() 109 self.control_panel = ControlPanel(self.referee)
109 self.right_panel.add(self.control_panel, DockPanel.SOUTH) 110 self.right_panel.add(self.control_panel)
110 self.add(self.right_panel) 111 self.add(self.right_panel)
111 self.right_panel.setBorderWidth(1) 112 #self.right_panel.setBorderWidth(1)
112 self.left_panel.add(Label("Musique 1")) 113 self.left_panel.add(Label("Musique 1"))
113 self.left_panel.add(Label("Musique 2")) 114 self.left_panel.add(Label("Musique 2"))
114 self.left_panel.add(Label("Musique 3")) 115 self.audio = HTML("")
115 self.left_panel.add(Label("Musique 4")) 116 self.right_panel.add(self.audio)
116 self.left_panel.add(Label("Musique 5"))
117 117
118 118
119 self.addClickListener(self) 119 self.addClickListener(self)
120
121 def radiocolPreload(self, filename, title, artist, album):
122 self.audio.setHTML('<audio preload="auto" controls="controls" src="radiocol/%s" />' % html_sanitize(filename))
120 123