[vhffs-dev] [1566] Wooops. |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1566
Author: beuss
Date: 2010-03-18 16:29:20 +0100 (Thu, 18 Mar 2010)
Log Message:
-----------
Wooops. Better if we add templates... Added a render_error method.
Modified Paths:
--------------
branches/vhffs-design/vhffs-panel/templates/Makefile.am
Added Paths:
-----------
branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Member.pm
branches/vhffs-design/vhffs-panel/templates/content/member/error.tt
branches/vhffs-design/vhffs-panel/templates/content/member/home.tt
branches/vhffs-design/vhffs-panel/templates/layouts/member.tt
branches/vhffs-design/vhffs-panel/templates/parts/member/group-menu.tt
branches/vhffs-design/vhffs-panel/templates/parts/member/header.tt
branches/vhffs-design/vhffs-panel/templates/parts/member/top-menu.tt
Added: branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Member.pm
===================================================================
--- branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Member.pm (rev 0)
+++ branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Member.pm 2010-03-18 15:29:20 UTC (rev 1566)
@@ -0,0 +1,104 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+# Panel class for displaying pages for logged in
+# users
+
+package Vhffs::Panel::Member;
+
+use base qw(Vhffs::Panel);
+
+use locale;
+use Locale::gettext;
+use POSIX qw(locale_h);
+
+use Template;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Tag;
+use Vhffs::Functions;
+
+# Trying to have a singleton to allow
+# require to keep infos/errors
+my $panel;
+
+sub new {
+ my $class = shift;
+ $panel = $class->SUPER::new(@_) unless($panel);
+ $panel->check_member();
+ return $panel;
+}
+
+sub render {
+ my ($self, $file, $vars) = @_;
+ my $vhffs = $self->{vhffs};
+ my $conf = $vhffs->get_config;
+
+ $vars = {} unless(defined $vars);
+
+ my $default_vars = {
+ public => $self->is_public,
+ help_url => $vhffs->get_config->get_panel->{'url_help'},
+ public_url => $vhffs->get_config->get_panel->{'url_public'},
+ theme => $conf->get_panel->{default_theme},
+ current_user => $self->{user}
+ };
+
+ $vars = {%$default_vars, %$vars};
+
+ unless($self->{is_ajax_request}) {
+ # Add info about current group for left menu
+ }
+
+ $self->SUPER::render($file, $vars, $self->{templatedir}.'/panel/', 'layouts/member.tt');
+}
+
+=head2 render_error
+
+Use this when your script hits conditions that make it
+unable to perform its action (missing parameters,
+insufficient access level, etc.).
+
+B<Never returns>.
+
+=cut
+
+sub render_error {
+ my ($self, $message) = @_;
+
+ $self->render('content/member/error.tt', { error_message => $message });
+ exit 0;
+}
+
+1;
Modified: branches/vhffs-design/vhffs-panel/templates/Makefile.am
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/Makefile.am 2010-03-18 14:44:24 UTC (rev 1565)
+++ branches/vhffs-design/vhffs-panel/templates/Makefile.am 2010-03-18 15:29:20 UTC (rev 1566)
@@ -129,9 +129,10 @@
content/anonymous/login.tt \
content/anonymous/lost-password.tt \
content/anonymous/subscribe.tt \
- content/member/home.tt \
+ content/member/error.tt \
+ content/member/home.tt \
layouts/anonymous.tt \
layouts/member.tt \
parts/member/header.tt \
parts/member/group-menu.tt \
- parts/member/top-menu.tt
+ parts/member/top-menu.tt
Added: branches/vhffs-design/vhffs-panel/templates/content/member/error.tt
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/content/member/error.tt (rev 0)
+++ branches/vhffs-design/vhffs-panel/templates/content/member/error.tt 2010-03-18 15:29:20 UTC (rev 1566)
@@ -0,0 +1,3 @@
+<h1>[% 'Sorry, an error occured' | i18n %]</h1>
+<p class="error">[% error_message | html %]</p>
+<p><a href="/panel.pl">[% 'Home' | i18n %]</a></p>
Added: branches/vhffs-design/vhffs-panel/templates/content/member/home.tt
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/content/member/home.tt (rev 0)
+++ branches/vhffs-design/vhffs-panel/templates/content/member/home.tt 2010-03-18 15:29:20 UTC (rev 1566)
@@ -0,0 +1,2 @@
+<h1>[% 'Welcome on VHFFS %s' | i18n | pretty_print(current_user.username) %]</h1>
+<p>[% 'If you are new to VHFFS, you should start to read quickly the whole help available by clicking on the help button in the upper right of your screen.' | i18n %]</p>
Added: branches/vhffs-design/vhffs-panel/templates/layouts/member.tt
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/layouts/member.tt (rev 0)
+++ branches/vhffs-design/vhffs-panel/templates/layouts/member.tt 2010-03-18 15:29:20 UTC (rev 1566)
@@ -0,0 +1,43 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta name="author" content="VHFFS Team, based on G. Wolfgang original design" />
+ <link rel="stylesheet" type="text/css" media="screen,projection" href="/themes/[% theme %]/main.css" />
+ <script type="text/javascript" src="/js/dojo/dojo.js"></script>
+ <script type="text/javascript" src="/js/dijit/dijit.js"></script>
+ <script type="text/javascript" src="/js/member.js"></script>
+ <title>Vhffs::Virtual hosting for free software</title>
+</head>
+
+<body>
+<div id="background-container">
+ <div class="page-container-panel">
+ <div id="loading" style="display:none">
+ <img src="/themes/[% theme %]/img/loading.gif" alt="Loading..."/>
+ </div>
+ <div id="header">
+[% INCLUDE 'parts/member/header.tt' %]
+ </div>
+ <!-- Navigation Level 2 -->
+ <div id="top-menu">
+[% INCLUDE 'parts/member/top-menu.tt' %]
+ </div>
+
+ <!-- NAVIGATION -->
+ <!-- Navigation Level 3 -->
+ <div id="left-menu">
+[% INCLUDE 'parts/member/group-menu.tt' %]
+ </div>
+ <div class="content2">
+[% PROCESS $template %]
+ </div> <!-- FOOTER -->
+ <div id="footer">
+ <p>Powered by <a href="http://www.vhffs.org">VHFFS</a></p>
+ </div>
+ </div>
+ </div>
+</body>
+
+</html>
+
Added: branches/vhffs-design/vhffs-panel/templates/parts/member/group-menu.tt
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/parts/member/group-menu.tt (rev 0)
+++ branches/vhffs-design/vhffs-panel/templates/parts/member/group-menu.tt 2010-03-18 15:29:20 UTC (rev 1566)
@@ -0,0 +1,56 @@
+[%#
+ IF current_group ....
+ <h1>tfcontrib</h1>
+ <h2>Espaces Web</h2>
+ <div class="menu">
+
+ <a href="#">site1</a>
+ <a href="?page=create">Create</a>
+ </div>
+ <h2>Bases MySQL</h2>
+ <div class="menu">
+ <a href="#">tfcontrib_db1</a>
+ <a href="#">tfcontrib_db1</a>
+
+ <a href="#">tfcontrib_db1</a>
+ <a href="?page=create">Create</a>
+ </div>
+ <h2 class="empty">PostgreSQL</h2>
+ <div class="menu">
+ <a href="?page=create">Create</a>
+ </div>
+
+ <h2 class="empty">CVS</h2>
+ <div class="menu">
+ <a href="?page=create">Create</a>
+ </div>
+ <h2 class="empty">Subversion</h2>
+ <div class="menu">
+ <a href="?page=create">Create</a>
+
+ </div>
+ <h2 class="empty">Git</h2>
+ <div class="menu">
+ <a href="#">Create</a>
+ </div>
+ <h2 class="empty">Noms de domaine</h2>
+ <div class="menu">
+
+ <a href="#">Create</a>
+ </div>
+ <h2 class="empty">Espaces de téléchargement</h2>
+ <div class="menu">
+ <a href="#">Create</a>
+ </div>
+
+ <h2 class="empty">Domaines mail</h2>
+ <div class="menu">
+ <a href="#">Create</a>
+ </div>
+ <h2>Listes de diffusion</h2>
+ <div class="menu">
+ <a href="#">tfmodostafftuxfamilyorg</a>
+
+ <a href="#">Create</a>
+ </div>
+%]
Added: branches/vhffs-design/vhffs-panel/templates/parts/member/header.tt
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/parts/member/header.tt (rev 0)
+++ branches/vhffs-design/vhffs-panel/templates/parts/member/header.tt 2010-03-18 15:29:20 UTC (rev 1566)
@@ -0,0 +1,24 @@
+ <!-- HEADER -->
+ <!-- Sitename -->
+ <div class="header-left">
+ <div class="site-name">
+ <a href="/panel.pl"><img src="/themes/[% theme %]/img/vhffs.png" alt="Virtual Hosting For Free Software"/></a>
+ </div>
+ </div>
+
+ <div class="header-right">
+ <!-- Flag navigations -->
+ <div class="navflag">
+ <a href="/panel.pl?lang=fr_FR"><img class="img-navflag" src="/themes/[% theme %]/img/flag_fr.png" alt="[% 'French' | i18n %]" /></a>
+ <a href="/panel.pl?lang=es_ES"><img class="img-navflag" src="/themes/[% theme %]/img/flag_es.png" alt="[% 'Spanish' | i18n %]" /></a>
+ <a href="/panel.pl?lang=en_EN"><img class="img-navflag" src="/themes/[% theme %]/img/flag_en.png" alt="[% 'English' | i18n %]" /></a>
+ </div>
+
+ <!-- Navigation Level 1 -->
+ <div class="nav1">
+ <a href="http://bugs.vhffs.org">[% 'Report a bug' | i18n %]</a>
+ <a href="[% help_url %]">[% 'Help' | i18n %]</a>
+ <a href="/auth.pl?logout=1">[% 'Logout' | i18n %]</a>
+ </div>
+ </div>
+ <div style="clear:both"></div>
Added: branches/vhffs-design/vhffs-panel/templates/parts/member/top-menu.tt
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/parts/member/top-menu.tt (rev 0)
+++ branches/vhffs-design/vhffs-panel/templates/parts/member/top-menu.tt 2010-03-18 15:29:20 UTC (rev 1566)
@@ -0,0 +1,9 @@
+ <ul>
+ <li><a href="/panel.pl" class="selected">[% 'Home' | i18n %]</a></li>
+ <li><a href="/user/prefs.pl">[% 'Preferences' | i18n %]</a></li>
+ <li><a href="/group/index.pl">[% 'My groups' | i18n %]</a></li>
+[% IF current_user.is_moderator OR current_user.is_admin %]
+ <li><a href="#">[% 'Tags' | i18n %]</a></li>
+ <li><a href="/admin/index.pl">[% 'Administration' | i18n %]</a></li>
+[% END %]
+ </ul>