From 3f8ef5c72aa4fbfad5c320d91abdd4f2d547c029 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 27 Dec 2010 08:40:19 +0000 Subject: [PATCH] torrus, RT#10574 --- FS/FS/Mason.pm | 3 +- FS/FS/Mason/Request.pm | 5 +-- FS/FS/Mason/StandaloneRequest.pm | 23 ++++++++++ Makefile | 15 +++++++ htetc/freeside-torrus.conf | 22 ++++++++++ httemplate/docs/credits.html | 1 + httemplate/docs/license.html | 4 ++ torrus/FREESIDE_INSTALL | 11 +++++ torrus/configs/torrus-siteconfig.pl | 7 +++- torrus/perllib/Torrus/CGI.pm | 8 +++- torrus/perllib/Torrus/Renderer.pm | 6 ++- torrus/perllib/Torrus/Renderer/Freeside.pm | 65 +++++++++++++++++++++++++++++ torrus/perllib/Torrus/Renderer/Frontpage.pm | 8 +++- torrus/perllib/Torrus/Renderer/HTML.pm | 8 +++- torrus/templates/html-incblocks.txt | 27 ++---------- 15 files changed, 177 insertions(+), 36 deletions(-) create mode 100644 FS/FS/Mason/StandaloneRequest.pm create mode 100644 htetc/freeside-torrus.conf create mode 100644 torrus/FREESIDE_INSTALL create mode 100644 torrus/perllib/Torrus/Renderer/Freeside.pm diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 9b010e8d6..2d45e78a1 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -458,7 +458,8 @@ sub mason_interps { #my $request_class = 'HTML::Mason::Request'. #( $mode eq 'apache' ? '::ApacheHandler' : '' ); - my $request_class = 'FS::Mason::Request'; + my $request_class = $mode eq 'standalone' ? 'FS::Mason::StandaloneRequest' + : 'FS::Mason::Request'; #not entirely sure it belongs here, but what the hey if ( %%%RT_ENABLED%%% && $mode ne 'standalone' ) { diff --git a/FS/FS/Mason/Request.pm b/FS/FS/Mason/Request.pm index 95c802796..565f85eb0 100644 --- a/FS/FS/Mason/Request.pm +++ b/FS/FS/Mason/Request.pm @@ -24,7 +24,7 @@ sub new { my %opt = @_; my $mode = $superclass =~ /Apache/i ? 'apache' : 'standalone'; - freeside_setup($opt{'comp'}, $mode); + $class->freeside_setup($opt{'comp'}, $mode); $class->SUPER::new(@_); @@ -34,8 +34,7 @@ sub new { # for Mason 1.39 vs. Perl 5.10.0 sub freeside_setup { - - my( $filename, $mode ) = @_; + my( $class, $filename, $mode ) = @_; if ( $filename =~ qr(/REST/\d+\.\d+/NoAuth/) ) { diff --git a/FS/FS/Mason/StandaloneRequest.pm b/FS/FS/Mason/StandaloneRequest.pm new file mode 100644 index 000000000..a5e4dcb2a --- /dev/null +++ b/FS/FS/Mason/StandaloneRequest.pm @@ -0,0 +1,23 @@ +package FS::Mason::StandaloneRequest; + +use strict; +use warnings; +use base 'FS::Mason::Request'; + +sub new { + my $class = shift; + + $class->alter_superclass('HTML::Mason::Request'); + + #huh... shouldn't alter_superclass take care of this for us? + __PACKAGE__->valid_params( %{ HTML::Mason::Request->valid_params() } ); + + my %opt = @_; + #its already been altered# $class->freeside_setup($opt{'comp'}, 'standalone'); + FS::Mason::Request->freeside_setup($opt{'comp'}, 'standalone'); + + $class->SUPER::new(@_); + +} + +1; diff --git a/Makefile b/Makefile index 265d62754..2a8d93c2f 100644 --- a/Makefile +++ b/Makefile @@ -108,6 +108,8 @@ FREESIDE_URL = "http://localhost/freeside/" #for now, same db as specified in DATASOURCE... eventually, otherwise? RT_DB_DATABASE = freeside +TORRUS_ENABLED = 0 + # for cvs-upgrade-deploy target, the username who checked out the CVS copy. CVS_USER = ivan @@ -261,6 +263,7 @@ install-apache: [ -d ${APACHE_CONF} ] && \ ( install -o root -m 755 htetc/freeside-base${APACHE_VERSION}.conf ${APACHE_CONF} && \ ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \ + ( [ ${TORRUS_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-torrus.conf ${APACHE_CONF} || true ) && \ perl -p -i -e "\ s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \ s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \ @@ -374,6 +377,18 @@ install-rt: s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\ " ${RT_PATH}/etc/RT_SiteConfig.pm; fi +configure-torrus: + cd torrus; \ + torrus_user=freeside var_user=freeside var_group=freeside ./configure + +install-torrus: + cd torrus; \ + make; \ + make install + perl -p -i -e "\ + s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\ + " /usr/local/etc/torrus/conf/torrus-siteconfig.pl + clean: rm -rf masondocs rm -rf httemplate/docs/man diff --git a/htetc/freeside-torrus.conf b/htetc/freeside-torrus.conf new file mode 100644 index 000000000..357f0fee3 --- /dev/null +++ b/htetc/freeside-torrus.conf @@ -0,0 +1,22 @@ +Alias /freeside/torrus/plain "/usr/local/torrus/sup/webplain" +PerlRequire "/usr/local/torrus/conf_defaults/webmux2.pl" + + + SetHandler perl-script + PerlHandler Torrus::Apache2Handler + + AuthName Freeside + AuthType Basic + AuthUserFile /usr/local/etc/freeside/htpasswd + require valid-user + + + + SetHandler default-handler + Options None + + AuthName Freeside + AuthType Basic + AuthUserFile /usr/local/etc/freeside/htpasswd + require valid-user + diff --git a/httemplate/docs/credits.html b/httemplate/docs/credits.html index a3e769554..cf132fa8c 100644 --- a/httemplate/docs/credits.html +++ b/httemplate/docs/credits.html @@ -85,6 +85,7 @@ Matt Peterson
Luke Pfeifer
Ricardo Signes
Steve Simitzis
+Stanislav Sinyagin
Jason Spence
James Switzer
Audrey Tang
diff --git a/httemplate/docs/license.html b/httemplate/docs/license.html index fc3da6913..d106b908e 100644 --- a/httemplate/docs/license.html +++ b/httemplate/docs/license.html @@ -52,6 +52,10 @@ Request Tracker software in this case to be "merely aggregated" with Freeside, and not a "combined work", and as such Request Tracker is distributed only under the original GPLv2 license. +

+Contains "Torrus" from Stanislav Sinyagin / K-Open +GmbH, licensed under the terms of the GNU GPL. +

diff --git a/torrus/FREESIDE_INSTALL b/torrus/FREESIDE_INSTALL new file mode 100644 index 000000000..fa4984851 --- /dev/null +++ b/torrus/FREESIDE_INSTALL @@ -0,0 +1,11 @@ +i should move to the wiki once this is further along + +aptitude install rrdtool librrds-perl libxml-libxml-perl libberkeleydb-perl libtemplate-perl libproc-daemon-perl libnet-snmp-perl libapache-session-perl libjson-perl + +make configure-torrus +make install-torrus + +#(and for the apache config) +# in Makefile, set TORRUS_ENABLED = 1 +make install-apache + diff --git a/torrus/configs/torrus-siteconfig.pl b/torrus/configs/torrus-siteconfig.pl index ed51c1730..e5f30dc89 100644 --- a/torrus/configs/torrus-siteconfig.pl +++ b/torrus/configs/torrus-siteconfig.pl @@ -7,7 +7,7 @@ ( 'main' => { 'description' => 'The main tree', - 'info' => 'some tree', + 'info' => 'main tree', #'some tree', #per-agent? 'xmlfiles' => [qw(routers.xml)], 'run' => { 'collector' => 1, 'monitor' => 0 } } ); @@ -17,5 +17,10 @@ # $Torrus::Renderer::companyURL = 'http://torrus.sf.net'; # $Torrus::Renderer::siteInfo = `hostname`; +#Freeside +$Torrus::CGI::authorizeUsers = 0; +$Torrus::Renderer::rendererURL = '/freeside/torrus'; +$Torrus::Renderer::plainURL = '/freeside/torrus/plain/'; +$Torrus::Renderer::Freeside::FSURL = '%%%FREESIDE_URL%%%'; 1; diff --git a/torrus/perllib/Torrus/CGI.pm b/torrus/perllib/Torrus/CGI.pm index 574e87252..88a434e6c 100644 --- a/torrus/perllib/Torrus/CGI.pm +++ b/torrus/perllib/Torrus/CGI.pm @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -# $Id: CGI.pm,v 1.1 2010-12-27 00:03:43 ivan Exp $ +# $Id: CGI.pm,v 1.2 2010-12-27 08:40:19 ivan Exp $ # Stanislav Sinyagin # Universal CGI handler for Apache mod_perl and FastCGI @@ -37,9 +37,13 @@ use Torrus::ACL; ## Torrus::CGI->process($q) ## Expects a CGI object as input +our $q; + sub process { - my($class, $q) = @_; + #my($class, $q) = @_; + my $class = shift; + $q = shift; my $path_info = $q->url(-path => 1); diff --git a/torrus/perllib/Torrus/Renderer.pm b/torrus/perllib/Torrus/Renderer.pm index 803dd1858..b1eddb0fc 100644 --- a/torrus/perllib/Torrus/Renderer.pm +++ b/torrus/perllib/Torrus/Renderer.pm @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -# $Id: Renderer.pm,v 1.1 2010-12-27 00:03:39 ivan Exp $ +# $Id: Renderer.pm,v 1.2 2010-12-27 08:40:19 ivan Exp $ # Stanislav Sinyagin package Torrus::Renderer; @@ -36,7 +36,9 @@ use Torrus::Renderer::RRDtool; use base qw(Torrus::Renderer::HTML Torrus::Renderer::RRDtool Torrus::Renderer::Frontpage - Torrus::Renderer::AdmInfo); + Torrus::Renderer::AdmInfo + Torrus::Renderer::Freeside + ); sub new { diff --git a/torrus/perllib/Torrus/Renderer/Freeside.pm b/torrus/perllib/Torrus/Renderer/Freeside.pm new file mode 100644 index 000000000..7b304742c --- /dev/null +++ b/torrus/perllib/Torrus/Renderer/Freeside.pm @@ -0,0 +1,65 @@ +package Torrus::Renderer::Freeside; + +use strict; + +#Freeside +use FS::Mason qw( mason_interps ); +use FS::UID qw(cgisuidsetup); +use FS::TicketSystem; + +my $outbuf; +my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf); + +sub freesideHeader { + my($self, $title, $stylesheet, $c) = (shift, shift); + + #from html-incblocks.txt + my $head = + # + # [% IF expires %][% END %] + ' + '; + + $self->freesideComponent('/elements/header.html', + { + 'title' => $title, + 'head' => $head, + #'etc' => $etc, + 'nobr' => 1, + #'nocss' => 1, + } + ); +} + +sub freesideFooter { + my $self = shift; + $self->FreesideComponent('/elements/footer.html'); +} + +our $FSURL; + +sub freesideComponent { + my($self, $comp) = (shift, shift); + +# my $conf = new FS::Conf; + $FS::Mason::Request::FSURL = $FSURL; + $FS::Mason::Request::FSURL .= '/' unless $FS::Mason::Request::FSURL =~ /\/$/; +# $FS::Mason::Request::QUERY_STRING = $packet->{'query_string'} || ''; + + cgisuidsetup($Torrus::CGI::q); + FS::TicketSystem->init(); + + $outbuf = ''; + #$fs_interp->exec($comp, @args); #only FS for now alas... + $fs_interp->exec($comp, @_); #only FS for now alas... + + #errors? (turn off in-line error reporting?) + + return $outbuf; + +} + +1; + diff --git a/torrus/perllib/Torrus/Renderer/Frontpage.pm b/torrus/perllib/Torrus/Renderer/Frontpage.pm index 5a9d0a39d..715a01926 100644 --- a/torrus/perllib/Torrus/Renderer/Frontpage.pm +++ b/torrus/perllib/Torrus/Renderer/Frontpage.pm @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -# $Id: Frontpage.pm,v 1.1 2010-12-27 00:03:44 ivan Exp $ +# $Id: Frontpage.pm,v 1.2 2010-12-27 08:40:19 ivan Exp $ # Stanislav Sinyagin package Torrus::Renderer::Frontpage; @@ -208,7 +208,11 @@ sub renderTreeChooser hasPrivilege( $_[0], 'DisplayTree' ) } , 'mayGlobalSearch' => sub { return $self->mayGlobalSearch(); }, - 'searchResults' => sub { return $self->doGlobalSearch($_[0]); } + 'searchResults' => sub { return $self->doGlobalSearch($_[0]); }, + + #Freeside + 'freesideHeader' => sub { return $self->freesideHeader(@_); }, + 'freesideFooter' => sub { return $self->freesideFooter(); }, }; diff --git a/torrus/perllib/Torrus/Renderer/HTML.pm b/torrus/perllib/Torrus/Renderer/HTML.pm index e9f72acf0..296e699a1 100644 --- a/torrus/perllib/Torrus/Renderer/HTML.pm +++ b/torrus/perllib/Torrus/Renderer/HTML.pm @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -# $Id: HTML.pm,v 1.1 2010-12-27 00:03:44 ivan Exp $ +# $Id: HTML.pm,v 1.2 2010-12-27 08:40:19 ivan Exp $ # Stanislav Sinyagin package Torrus::Renderer::HTML; @@ -112,7 +112,11 @@ sub render_html 'verifyDate' => sub { return verifyDate($_[0]); }, 'markup' => sub{ return $self->translateMarkup( @_ ); }, 'searchEnabled' => $Torrus::Renderer::searchEnabled, - 'searchResults' => sub { return $self->doSearch($config_tree, $_[0]); } + 'searchResults' => sub { return $self->doSearch($config_tree, $_[0]); }, + + #Freeside + 'FreesideHeader' => sub { return $self->FreesideHeader(@_); }, + 'freesideFooter' => sub { return $self->freesideFooter(); }, }; diff --git a/torrus/templates/html-incblocks.txt b/torrus/templates/html-incblocks.txt index ca5540e69..f2d55f6d4 100644 --- a/torrus/templates/html-incblocks.txt +++ b/torrus/templates/html-incblocks.txt @@ -1,5 +1,5 @@ [%# - $Id: html-incblocks.txt,v 1.1 2010-12-27 00:04:03 ivan Exp $ + $Id: html-incblocks.txt,v 1.2 2010-12-27 08:40:19 ivan Exp $ All BLOCK statements are defined here %] @@ -11,11 +11,9 @@ [% BLOCK htmlstart; IF ! contentClass; contentClass="Content"; END %] - - - - + +[% freesideHeader(title, style('stylesheet')) %] + -[% title %] - -[% IF expires %][% END %] - - -

- -[% IF companyLogo %][% ELSE; companyName; END %] - - [% IF siteInfo %] [% siteInfo %] -- 2.11.0