# HG changeset patch # User Goffi # Date 1308091922 -7200 # Node ID 9d8e79ac4c9cfd132e0af34c04d0028ec725928f # Parent 8f421a12b8f9d89fa334de758223841931094577 Login/Register box: integration of Adrien Vigneron's design diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/card_game.py --- a/browser_side/card_game.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/card_game.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/contact.py --- a/browser_side/contact.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/contact.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/dialog.py --- a/browser_side/dialog.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/dialog.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/games.py --- a/browser_side/games.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/games.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/jid.py --- a/browser_side/jid.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/jid.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/panels.py --- a/browser_side/panels.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/panels.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 @@ -749,9 +749,8 @@ def __init__(self, host): TabPanel.__init__(self) self.host=host - TabPanel() self.tabBar.setVisible(False) - self.addStyleName('mainTabPanel') + self.setStyleName('mainTabPanel') Window.addWindowResizeListener(self) def onWindowResized(self, width, height): diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/register.py --- a/browser_side/register.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/register.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,8 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson +Copyright (C) 2011 Adrien Vigneron 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 @@ -22,7 +23,11 @@ #This page manage subscription and new account creation import pyjd # this is dummy in pyjs +from pyjamas.ui.SimplePanel import SimplePanel from pyjamas.ui.VerticalPanel import VerticalPanel +from pyjamas.ui.HorizontalPanel import HorizontalPanel +from pyjamas.ui.TabPanel import TabPanel +from pyjamas.ui.TabBar import TabBar from pyjamas.ui.Grid import Grid from pyjamas.ui.PasswordTextBox import PasswordTextBox from pyjamas.ui.TextBox import TextBox @@ -30,14 +35,14 @@ from pyjamas.ui.Button import Button from pyjamas.ui.Label import Label from pyjamas.ui.CheckBox import CheckBox -from pyjamas.ui.DialogBox import DialogBox +from pyjamas.ui.PopupPanel import PopupPanel +from pyjamas.ui.Image import Image +from pyjamas.ui.Hidden import Hidden from pyjamas import Window from pyjamas.ui import HasAlignment import re - - class RegisterPanel(FormPanel): def __init__(self, callback): @@ -45,79 +50,92 @@ @param callback: method to call if login successful """ FormPanel.__init__(self) + self.setSize('600px', '350px') self.callback = callback self.setMethod(FormPanel.METHOD_POST) - vPanel = VerticalPanel() - vPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER) + main_panel = HorizontalPanel() + main_panel.setStyleName('registerPanel_main') + left_side = Image("register_left.png") + main_panel.add(left_side) + + ##TabPanel## + tab_bar = TabBar() + tab_bar.setStyleName('registerPanel_tabs') + right_side = TabPanel(tab_bar) + right_side.setStyleName('registerPanel_right_side') + main_panel.add(right_side) + main_panel.setCellWidth(right_side, '100%') + + + ##Login tab## + login_tab = SimplePanel() + login_tab.setStyleName('registerPanel_content') + login_vpanel = VerticalPanel() + login_tab.setWidget(login_vpanel) + + self.warning_msg = Label() self.warning_msg.setVisible(False) self.warning_msg.setStyleName('formWarning') - vPanel.add(self.warning_msg) + #login_vpanel.add(self.warning_msg) + login_label = Label('Login:') self.login_box = TextBox() self.login_box.setName("login") - self.pass_box = PasswordTextBox() - self.pass_box.setName("password") - login_grid = Grid(2, 2) - login_grid.setText(0,0,"Login:") - login_grid.setWidget(0,1, self.login_box) - login_grid.setText(1,0, "Password:") - login_grid.setWidget(1,1, self.pass_box) - vPanel.add(login_grid) + login_pass_label = Label('Password:') + login_pass_box = PasswordTextBox() + login_pass_box.setName("login_password") + login_vpanel.add(login_label) + login_vpanel.add(self.login_box) + login_vpanel.add(login_pass_label) + login_vpanel.add(login_pass_box) + login_but = Button("Log in", getattr(self, "onLogin")) + login_but.setStyleName('button') + login_but.addStyleName('red') + login_vpanel.add(login_but) + + #The hidden submit_type field + self.submit_type = Hidden('submit_type') + login_vpanel.add(self.submit_type) + - self.new_account = CheckBox('Register new account') - self.new_account.setName('new_account') - self.new_account.addClickListener(self.onNewAccountChecked) - vPanel.add(self.new_account) + ##Register tab## + register_tab = SimplePanel() + register_tab.setStyleName('registerPanel_content') + register_vpanel = VerticalPanel() + register_tab.setWidget(register_vpanel) - + register_login_label = Label('Login:') + register_login_box = TextBox() + register_login_box.setName("register_login") + email_label = Label('E-mail:') self.email_box = TextBox() self.email_box.setName("email") - self.register_grid = Grid(1, 2) - self.register_grid.setText(0,0,"email:") - self.register_grid.setWidget(0,1, self.email_box) - self.register_grid.setVisible(False) - vPanel.add(self.register_grid) - self.info_register_lb = Label('Your password will be sent to the given email') - self.info_register_lb.setVisible(False) - vPanel.add(self.register_grid) - vPanel.add(self.info_register_lb) + register_pass_label = Label('Password:') + self.register_pass_box = PasswordTextBox() + self.register_pass_box.setName("register_password") + register_vpanel.add(register_login_label) + register_vpanel.add(register_login_box) + register_vpanel.add(email_label) + register_vpanel.add(self.email_box) + register_vpanel.add(register_pass_label) + register_vpanel.add(self.register_pass_box) + + register_but = Button("Register", getattr(self, "onRegister")) + register_but.setStyleName('button') + register_but.addStyleName('red') + register_vpanel.add(register_but) - self.login_but = Button("Login", getattr(self, "onLogin")) - vPanel.add(self.login_but) - self.register_but = Button("Register", getattr(self, "onRegister")) - self.register_but.setVisible(False) - vPanel.add(self.register_but) - self.add(vPanel) + right_side.add(login_tab, 'Login') + right_side.add(register_tab, 'Register') + right_side.selectTab(0) + + self.add(main_panel) self.addFormHandler(self) self.setAction('register_api/login') - def changeMode(self, mode): - """Change the configuration of the dialog - @param mode: "login" or "register""" - if mode == "register": - self.pass_box.setEnabled(False) - self.register_grid.setVisible(True) - self.info_register_lb.setVisible(True) - self.login_but.setVisible(False) - self.register_but.setVisible(True) - self.new_account.setChecked(True) - else: - self.pass_box.setEnabled(True) - self.register_grid.setVisible(False) - self.info_register_lb.setVisible(False) - self.login_but.setVisible(True) - self.register_but.setVisible(False) - self.new_account.setChecked(False) - - - def onNewAccountChecked(self, sender): - if sender.isChecked(): - self.changeMode("register") - else: - self.changeMode("login") - def onLogin(self, button): + self.submit_type.setValue('login') self.submit() def onRegister(self, button): @@ -130,6 +148,7 @@ self.warning_msg.setVisible(True) else: self.warning_msg.setVisible(False) + self.submit_type.setValue('register') self.submit() @@ -149,16 +168,23 @@ self.warning_msg.setVisible(True) elif result == "REGISTRATION": self.warning_msg.setVisible(False) - self.changeMode('login') - self.pass_box.setText('') + self.register_pass_box.setText('') Window.alert('An email has been sent to you with your login informations\nPlease remember that this is ONLY A TECHNICAL DEMO') else: Window.alert('Submit error: %s' % result) -class RegisterBox(DialogBox): +class RegisterBox(PopupPanel): def __init__(self, callback, *args,**kwargs): - DialogBox.__init__(self,*args,**kwargs) + PopupPanel.__init__(self,*args,**kwargs) _form = RegisterPanel(callback) - self.setHTML('You are not identified, please log in') self.setWidget(_form) + + def onWindowResized(self, width, height): + super(RegisterBox, self).onWindowResized(width, height) + self.centerBox() + + def show(self): + super(RegisterBox, self).show() + self.centerBox() + diff -r 8f421a12b8f9 -r 9d8e79ac4c9c browser_side/tools.py --- a/browser_side/tools.py Wed Jun 15 00:49:34 2011 +0200 +++ b/browser_side/tools.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 diff -r 8f421a12b8f9 -r 9d8e79ac4c9c libervia.py --- a/libervia.py Wed Jun 15 00:49:34 2011 +0200 +++ b/libervia.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 @@ -25,7 +25,7 @@ from pyjamas.ui.KeyboardListener import KEY_ESCAPE from pyjamas import Window, DOM from pyjamas.JSONService import JSONProxy -from browser_side.register import RegisterPanel, RegisterBox +from browser_side.register import RegisterBox from browser_side.contact import ContactPanel from browser_side import panels, dialog from browser_side.jid import JID @@ -110,7 +110,7 @@ self.discuss_panel.changePanel(0,self.mpanels[0]) self.discuss_panel.changePanel(1,self.mpanels[1]) self.discuss_panel.changePanel(2,self.mpanels[2]) - self._dialog = None + self._register_box = None RootPanel().add(self.panel) DOM.addEventPreview(self) self.resize() @@ -151,8 +151,9 @@ def _isRegisteredCB(self, registered): if not registered: - self._dialog = RegisterBox(self.logged,centered=True) - self._dialog.show() + self._register_box = RegisterBox(self.logged) + self._register_box.centerBox() + self._register_box.show() else: self._register.call('isConnected', self._isConnectedCB) @@ -163,9 +164,9 @@ self.logged() def logged(self): - if self._dialog: - self._dialog.hide() - del self._dialog # don't work if self._dialog is None + if self._register_box: + self._register_box.hide() + del self._register_box # don't work if self._register_box is None #it's time to fill the page self.bridge.call('getContacts', self._getContactsCB) diff -r 8f421a12b8f9 -r 9d8e79ac4c9c libervia.tac --- a/libervia.tac Wed Jun 15 00:49:34 2011 +0200 +++ b/libervia.tac Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 @@ -313,14 +313,18 @@ - ALREADY WAITING: a request has already be made for this profile - server.NOT_DONE_YET: the profile is being processed, the return value will be given by self._logged or self._logginError """ - if 'new_account' in request.args: - return self._registerNewAccount(request.args) - try: - _login = request.args['login'][0] - if _login.startswith('@'): - raise Exception('No profile_key allowed') - _pass = request.args['password'][0] + if request.args['submit_type'][0] == 'login': + _login = request.args['login'][0] + if _login.startswith('@'): + raise Exception('No profile_key allowed') + _pass = request.args['login_password'][0] + + elif request.args['submit_type'][0] == 'register': + return self._registerNewAccount(request.args) + + else: + raise Exception('Unknown submit type') except KeyError: return "BAD REQUEST" @@ -359,7 +363,8 @@ #TODO: must be moved in SàT core try: - profile = login = args['login'][0] + profile = login = args['register_login'][0] + password = request.args['register_password'][0] #FIXME: password is ignored so far email = args['email'][0] except KeyError: return "BAD REQUEST" diff -r 8f421a12b8f9 -r 9d8e79ac4c9c server_side/blog.py --- a/server_side/blog.py Wed Jun 15 00:49:34 2011 +0200 +++ b/server_side/blog.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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 diff -r 8f421a12b8f9 -r 9d8e79ac4c9c server_side/html_tools.py --- a/server_side/html_tools.py Wed Jun 15 00:49:34 2011 +0200 +++ b/server_side/html_tools.py Wed Jun 15 00:52:02 2011 +0200 @@ -3,7 +3,7 @@ """ Libervia: a Salut à Toi frontend -Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) +Copyright (C) 2011 Jérôme Poisson 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