Mercurial > libervia-web
view 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 source
#!/usr/bin/python # -*- coding: utf-8 -*- """ Libervia: a Salut à Toi frontend Copyright (C) 2011 Jérôme Poisson <goffi@goffi.org> This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import pyjd # this is dummy in pyjs from pyjamas.ui.VerticalPanel import VerticalPanel from pyjamas.ui.HorizontalPanel import HorizontalPanel from pyjamas.ui.SimplePanel import SimplePanel from pyjamas.ui.FormPanel import FormPanel 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 from tools import html_sanitize class MetadataPanel(VerticalPanel): def __init__(self): VerticalPanel.__init__(self) self.title = Label("title:") self.artist = Label("artist:") self.album = Label("album:") self.add(self.title) self.add(self.artist) self.add(self.album) class ControlPanel(FormPanel): """Panel used to show controls to add a song, or vote for the current one""" def __init__(self, referee): FormPanel.__init__(self) self.setEncoding(FormPanel.ENCODING_MULTIPART) self.setMethod(FormPanel.METHOD_POST) self.setAction("upload") # set this as appropriate vPanel = VerticalPanel() hPanel = HorizontalPanel() hPanel.setSpacing(5) self.field = FileUpload() self.field.setName("song") hPanel.add(self.field) hPanel.add(Button("Upload song", getattr(self, "onBtnClick"))) vPanel.add(hPanel) #We need to know the referee referee_field = Hidden('referee', referee) vPanel.add(referee_field) self.add(vPanel) self.addFormHandler(self) def onBtnClick(self): self.submit() def onSubmit(self, event): pass def onSubmitComplete(self, event): result = event.getResults() if result == "OK": Window.alert('Your song has been added to queue') elif result == "KO": Window.alert('Something went wrong during your song upload') else: Window.alert('Submit error: %s' % result) class RadioColPanel(HorizontalPanel, ClickHandler): def __init__(self, parent, referee, player_nick): HorizontalPanel.__init__(self) ClickHandler.__init__(self) self._parent = parent self.referee = referee self.setStyleName("radiocolPanel") # Now we set up the layout self.left_panel = VerticalPanel() self.add(self.left_panel) self.right_panel = VerticalPanel() self.metadata_panel = MetadataPanel() 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.left_panel.add(Label("Musique 1")) self.left_panel.add(Label("Musique 2")) 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))