torrus, RT#10574
authorivan <ivan>
Mon, 27 Dec 2010 08:40:19 +0000 (08:40 +0000)
committerivan <ivan>
Mon, 27 Dec 2010 08:40:19 +0000 (08:40 +0000)
15 files changed:
FS/FS/Mason.pm
FS/FS/Mason/Request.pm
FS/FS/Mason/StandaloneRequest.pm [new file with mode: 0644]
Makefile
htetc/freeside-torrus.conf [new file with mode: 0644]
httemplate/docs/credits.html
httemplate/docs/license.html
torrus/FREESIDE_INSTALL [new file with mode: 0644]
torrus/configs/torrus-siteconfig.pl
torrus/perllib/Torrus/CGI.pm
torrus/perllib/Torrus/Renderer.pm
torrus/perllib/Torrus/Renderer/Freeside.pm [new file with mode: 0644]
torrus/perllib/Torrus/Renderer/Frontpage.pm
torrus/perllib/Torrus/Renderer/HTML.pm
torrus/templates/html-incblocks.txt

index 9b010e8..2d45e78 100644 (file)
@@ -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' ) {
index 95c8027..565f85e 100644 (file)
@@ -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 (file)
index 0000000..a5e4dcb
--- /dev/null
@@ -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;
index 265d627..2a8d93c 100644 (file)
--- 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 (file)
index 0000000..357f0fe
--- /dev/null
@@ -0,0 +1,22 @@
+Alias /freeside/torrus/plain "/usr/local/torrus/sup/webplain"
+PerlRequire "/usr/local/torrus/conf_defaults/webmux2.pl"
+
+<Location /freeside/torrus>
+  SetHandler perl-script
+  PerlHandler Torrus::Apache2Handler
+
+  AuthName Freeside
+  AuthType Basic
+  AuthUserFile /usr/local/etc/freeside/htpasswd
+  require valid-user
+</Location>
+
+<Location /freeside/torrus/plain>
+  SetHandler default-handler
+  Options None
+
+  AuthName Freeside
+  AuthType Basic
+  AuthUserFile /usr/local/etc/freeside/htpasswd
+  require valid-user
+</Location>
index a3e7695..cf132fa 100644 (file)
@@ -85,6 +85,7 @@ Matt Peterson<BR>
 Luke Pfeifer<BR>
 Ricardo Signes<BR>
 Steve Simitzis<BR>
+Stanislav Sinyagin<BR>
 Jason Spence<BR>
 James Switzer<BR>
 Audrey Tang<BR>
index fc3da69..d106b90 100644 (file)
@@ -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.
 
+<P>
+Contains "Torrus" <http://www.torrus.org/> from Stanislav Sinyagin / K-Open
+GmbH, licensed under the terms of the GNU GPL.
+
 <!--important widgets or other "whole" bits-->
 
 <P>
diff --git a/torrus/FREESIDE_INSTALL b/torrus/FREESIDE_INSTALL
new file mode 100644 (file)
index 0000000..fa49848
--- /dev/null
@@ -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
+
index ed51c17..e5f30dc 100644 (file)
@@ -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 } }
      );
 # $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;
index 574e872..88a434e 100644 (file)
@@ -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 <ssinyagin@yahoo.com>
 
 # 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);
 
index 803dd18..b1eddb0 100644 (file)
@@ -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 <ssinyagin@yahoo.com>
 
 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 (file)
index 0000000..7b30474
--- /dev/null
@@ -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 =
+  #  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
+  #  [% IF expires %]<META HTTP-EQUIV="Refresh" CONTENT="[% expires %]"/>[% END %]
+    '<STYLE type="text/css" media="all">
+     @import url( '. $Torrus::Renderer::plainURL. $stylesheet. ' );
+     </STYLE>
+    ';
+
+  $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;
+
index 5a9d0a3..715a019 100644 (file)
@@ -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 <ssinyagin@yahoo.com>
 
 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(); },
     };
 
 
index e9f72ac..296e699 100644 (file)
@@ -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 <ssinyagin@yahoo.com>
 
 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(); },
     };
     
     
index ca5540e..f2d55f6 100644 (file)
@@ -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
 %]
 
 
 [% BLOCK htmlstart;
    IF ! contentClass; contentClass="Content"; END %]
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-        "http://www.w3.org/TR/html4/strict.dtd">
-<HTML>
-<!-- Torrus Copyright (c) 2003-2004 Stanislav Sinyagin -->
-<HEAD>
+
+[% freesideHeader(title, style('stylesheet')) %]
+
 <SCRIPT language="JavaScript"> 
 <!--
 function helpwindow() 
@@ -25,26 +23,9 @@ window.open('[%url(token) _ '&view=helptext-html'%]','helpwindow',
 } 
 //--> 
 </SCRIPT>
-<TITLE>[% title %]</TITLE>
-<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
-[% IF expires %]<META HTTP-EQUIV="Refresh" CONTENT="[% expires %]"/>[% END %]
-<STYLE type="text/css" media="all">
-  @import url( [% plainURL _ style('stylesheet') %] );
-  [% cssoverlay = style('cssoverlay'); IF cssoverlay; %]
-  @import url( [% cssoverlay %] );
-  [% END %]
-</STYLE>
-</HEAD>
-<BODY>
 
 <DIV CLASS="Header">
 
-<SPAN CLASS="CompanyInfo">
-<A TITLE="company info"
-HREF="[%companyURL%]">[% IF companyLogo %]<IMG SRC="[%companyLogo%]"
-ALT=[%companyName%] STYLE="border:0">[% ELSE; companyName; END %]</A>
-</SPAN>
-
 [% IF siteInfo %]
 <SPAN CLASS="SiteInfo">
 [% siteInfo %]