From 310b567c6790767e9e6740151aee23d4c7db26e9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 4 Sep 2007 15:00:44 +0000 Subject: [PATCH] Monotone-Parent: 7f9eeda74d55829371d1c66f2c2545473af168ff Monotone-Revision: e36214d6c44a28c81a60a0867712c70d3e3a1651 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-09-04T15:00:44 Monotone-Branch: ca.inverse.sogo --- UI/MainUI/SOGoRootPage.h | 35 +++++++ UI/MainUI/SOGoRootPage.m | 122 ++++++++++--------------- UI/Templates/MainUI/SOGoRootPage.wox | 95 +++++++++++++++---- UI/WebServerResources/SOGoRootPage.css | 36 ++++++++ UI/WebServerResources/SOGoRootPage.js | 15 +++ 5 files changed, 212 insertions(+), 91 deletions(-) create mode 100644 UI/MainUI/SOGoRootPage.h create mode 100644 UI/WebServerResources/SOGoRootPage.css create mode 100644 UI/WebServerResources/SOGoRootPage.js diff --git a/UI/MainUI/SOGoRootPage.h b/UI/MainUI/SOGoRootPage.h new file mode 100644 index 000000000..fe3ebe466 --- /dev/null +++ b/UI/MainUI/SOGoRootPage.h @@ -0,0 +1,35 @@ +/* SOGoRootPage.h - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SOGOROOTPAGE_H +#define SOGOROOTPAGE_H + +#import + +@interface SOGoRootPage : UIxPageFrame +{ + NSString *userName; +} + +@end + +#endif /* SOGOROOTPAGE_H */ diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 912def217..2b5cca182 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -19,87 +19,58 @@ 02111-1307, USA. */ -#import - -#import -#import #import #import +#import #import #import #import -#import #import -#import -#import +#import -@interface SOGoRootPage : SoComponent -{ - NSString *userName; -} +#import +#import -@end +#import "SOGoRootPage.h" @implementation SOGoRootPage -static BOOL doNotRedirect = NO; - -+ (void)initialize { - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; - - if ((doNotRedirect = [ud boolForKey:@"SOGoDoNotRedirectRootPage"])) - NSLog(@"SOGoRootPage: home-page redirect is disabled."); -} - -- (void)dealloc { - [self->userName release]; +- (void) dealloc +{ + [userName release]; [super dealloc]; } /* accessors */ -- (void)setUserName:(NSString *)_value { - ASSIGNCOPY(self->userName, _value); +- (void) setUserName: (NSString *) _value +{ + ASSIGNCOPY (userName, _value); } -- (NSString *)userName { - return self->userName; + +- (NSString *) userName +{ + return userName; } /* actions */ -- (id)connectAction { - NSString *url; - - [self takeFormValuesForKeys:@"userName", nil]; - - if ([[self userName] length] == 0) - return nil; - - url = [@"/" stringByAppendingString:[[self userName] stringByEscapingURL]]; - if (![url hasSuffix:@"/"]) - url = [url stringByAppendingString:@"/"]; - - url = [[self context] urlWithRequestHandlerKey:@"so" - path:url queryString:nil]; - return [self redirectToLocation:url]; -} - -- (id)defaultAction { +- (id ) defaultAction +{ WOResponse *r; NSString *login, *rhk; - id auth, user; - id home, base; + SOGoAuthenticator *auth; + SOGoUser *user; + SOGoUserFolder *home; + WOApplication *base; - if (doNotRedirect) - return self; - /* Note: ctx.activeUser is NOT set here. Don't know why, so we retrieve the user from the authenticator. */ - auth = [[self clientObject] authenticatorInContext:[self context]]; - user = [auth userInContext:[self context]]; + auth = [[self clientObject] authenticatorInContext: context]; + user = [auth userInContext: context]; login = [user login]; if ([login isEqualToString:@"anonymous"]) { @@ -108,11 +79,11 @@ static BOOL doNotRedirect = NO; } /* check base */ - + base = [self application]; - rhk = [[[self context] request] requestHandlerKey]; + rhk = [[context request] requestHandlerKey]; if (([rhk length] == 0) || ([base requestHandlerForKey:rhk] == nil)) { - base = [base lookupName:@"so" inContext:[self context] acquire:NO]; + base = [base lookupName: @"so" inContext: context acquire: NO]; if (![base isNotNull] || [base isKindOfClass:[NSException class]]) { /* use root page if home could not be found */ @@ -123,7 +94,7 @@ static BOOL doNotRedirect = NO; /* lookup home-page */ - home = [base lookupName:login inContext:[self context] acquire:NO]; + home = [base lookupName: login inContext: context acquire: NO]; if (![home isNotNull] || [home isKindOfClass:[NSException class]]) { /* use root page if home could not be found */ return self; @@ -131,33 +102,40 @@ static BOOL doNotRedirect = NO; /* redirect to home-page */ - r = [[self context] response]; - [r setStatus:302 /* moved */]; - [r setHeader:[home baseURLInContext:[self context]] forKey:@"location"]; + r = [context response]; + [r setStatus: 302 /* moved */]; + [r setHeader: [home baseURLInContext: context] + forKey: @"location"]; + return r; } /* response generation */ -- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { +- (void) appendToResponse: (WOResponse *) response + inContext: (WOContext *) ctx +{ NSString *rhk; // TODO: we might also want to look into the HTTP basic-auth to redirect to // the login URL! - rhk = [[_ctx request] requestHandlerKey]; - if ([rhk length]==0 || [[self application] requestHandlerForKey:rhk]==nil) { - /* a small hack to redirect to a valid URL */ - NSString *url; + rhk = [[ctx request] requestHandlerKey]; + if ([rhk length] == 0 + || [[self application] requestHandlerForKey: rhk] == nil) + { + /* a small hack to redirect to a valid URL */ + NSString *url; - url = [_ctx urlWithRequestHandlerKey:@"so" path:@"/" queryString:nil]; - [_response setStatus:302 /* moved */]; - [_response setHeader:url forKey:@"location"]; - [self logWithFormat:@"URL: %@", url]; - return; - } - - [super appendToResponse:_response inContext:_ctx]; + url = [ctx urlWithRequestHandlerKey: @"so" path: @"/" queryString: nil]; + [response setStatus: 302 /* moved */]; + [response setHeader: url forKey: @"location"]; + [self logWithFormat: @"URL: %@", url]; + return; + } + + [response setHeader: @"text/html" forKey: @"content-type"]; + [super appendToResponse: response inContext: ctx]; } @end /* SOGoRootPage */ diff --git a/UI/Templates/MainUI/SOGoRootPage.wox b/UI/Templates/MainUI/SOGoRootPage.wox index 5cf9a093f..314b97f89 100644 --- a/UI/Templates/MainUI/SOGoRootPage.wox +++ b/UI/Templates/MainUI/SOGoRootPage.wox @@ -1,24 +1,81 @@ - - + + - - Scalable OGo Homepage - + xmlns:rsrc="OGo:url" + xmlns:label="OGo:label" + > + + + + <var:string value="title"/> + + + + + + + + + + + + + - -

Scalable OGo Homepage

+ + -
- Login: - - -
- - - + + + + + + + + + + + + + + +
+
+
+

+
+ +
+ +
+
+
+
+ + + +
diff --git a/UI/WebServerResources/SOGoRootPage.css b/UI/WebServerResources/SOGoRootPage.css new file mode 100644 index 000000000..ee7ab9448 --- /dev/null +++ b/UI/WebServerResources/SOGoRootPage.css @@ -0,0 +1,36 @@ +BODY +{ background-color: #999; } + +DIV#loginScreen +{ + background-color: #d4d0c8; + margin: 0px auto; + margin-top: 5em; + padding: 10px; + border: 2px solid transparent; + width: 158px; + height: 250px; + -moz-border-top-colors: #efebe7 #fff; + -moz-border-left-colors: #efebe7 #fff; + -moz-border-right-colors: #000 #9c9a94 transparent; + -moz-border-bottom-colors: #000 #9c9a94 transparent; +} + +DIV#loginScreen IMG +{ border: 1px solid #999; } + +DIV#loginScreen INPUT +{ width: 100%; } + +DIV#loginButton +{ text-align: right; } + +DIV#loginButton INPUT +{ width: auto; + margin-top: 5px; } + +DIV#loginButton IMG#progressIndicator +{ float: left; + border: 0px none; + margin-top: 5px; + margin-left: 5px; } diff --git a/UI/WebServerResources/SOGoRootPage.js b/UI/WebServerResources/SOGoRootPage.js new file mode 100644 index 000000000..dd93cb3b2 --- /dev/null +++ b/UI/WebServerResources/SOGoRootPage.js @@ -0,0 +1,15 @@ +function initLogin() { + var submit = $("submit"); + var userName = $("userName"); + userName.focus(); + Event.observe(submit, "click", onLoginClick); +} + +function onLoginClick(event) { + startAnimation($("loginButton"), $("submit")); + + var loginString = $("userName").value + ":" + $("password").value; + document.cookie = "0xHIGHFLYxSOGo-0.9 = basic" + loginString.base64encode(); +} + +addEvent(window, 'load', initLogin);