#!/usr/bin/perl
# 
#  Main.pm - Perlmodule which computes the Main content of Oroborus.org
# 
#  Copyright (C) 2002 Stefan Pfetzing and Martin Helas
# 
#  This program 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 program 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; if not, write to the Free Software Foundation,
#  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
# 

# define the Package name
package Oroborus::Main;

#use Apache::Reload;
use strict;
our ($q, $mailinglists, $bugs, $download, $screenshots, $links, $imprint, $disclaimer);
use Oroborus::Mailinglists;
use Oroborus::Bugs;
use Oroborus::Download;
use Oroborus::Screenshots;
use Oroborus::Links;
use Oroborus::Imprint;
use Oroborus::Disclaimer;
use IO::File;


# constructor needs one argument, a reference to a CGI object
sub new($) {
	my $proto = shift();
	$q = shift();
	my $class = ref($proto) || $proto;
	my $self  = {};
	bless ($self, $class);

	$mailinglists = new Oroborus::Mailinglists($q);
	$bugs = new Oroborus::Bugs($q);
	$download = new Oroborus::Download($q);
	$screenshots = new Oroborus::Screenshots($q);
	$links = new Oroborus::Links($q);
	$imprint = new Oroborus::Imprint($q);
	$disclaimer = new Oroborus::Disclaimer($q);

	$self->{_SITES} = { "Main" => $self,
		"Mailing Lists" => $mailinglists,
		"Bugs" => $bugs,
		"Download" => $download,
		"Screenshots" => $screenshots,
		"Links" => $links,
		"Imprint" => $imprint,
		"Disclaimer" => $disclaimer};

	return $self;
}

# destructor
sub DESTROY() {
};

sub toString() {
	my $self = shift();
	my $sites = $self->{_SITES};
	foreach my $key (keys(%$sites)) {
		if ($key eq $q->param("node")) {
			return $self->addTable($$sites{$key}->getContent());
		}
	}
	return $self->addTable($self->getContent());
}

# produce the table around the content (the inner table fragment)
sub addTable($) {
	my $self = shift();
	return $q->Tr(
		$q->td({-class=>"Node",
			-colspan=>"3"},
			$q->table({-border=>"0",
				-cellpadding=>"0",
				-cellspacing=>"25",
				-width=>"100%"},
				$q->Tr(
					$q->td({-width=>"100%"},
						shift()
					)
				)
			)
		)
	)
}

sub getContent() {
	my $self = shift();
	$q->table({-border=>"0",
		-width=>"100%",
		-class=>"Main"},
		$q->Tr(
			$q->td({-width=>"60%",
				-class=>"Main"},
				$q->table({-width=>"100%",
					-cellpadding=>"0",
					-cellspacing=>"0"},
					$q->Tr(
						$q->td(
							$q->h2("Info about Oroborus")
						)
					),
					$q->Tr(
						$q->td(
							$q->p($q->br(),
								"Oroborus basically is a really minimalistic window manager, which is about 75kb small on a PowerPC machine and about 63kb on an x86 machine.",
								"&quot;Minimalistic&quot; means that the Oroborus window manager doesn't provide some things other window managers provide. ",
								"So you will need some external tools also provided by this project."
							),
							$q->p(
								"The main improvement with this is that you gain much flexibility."
							),
							$q->p(
								"Besides being small Oroborus has some features most other windows managers don't provide:"
							),
							$q->ul(
								$q->li([
									"good default key bindings" ,
									"windows are moveable by keyboard",
									"highly configurable",
									"xpm-themable",
									"GNOME compatible",
									"NET_WM compatible",
									"sort of KDE compatible",
									"and many, many more..." ]
								)
							),
							$q->p(
								"We suggest to use the following add-on tools we provide together with Oroborus:"
							),
							$q->ul(
								$q->li([
									$q->font({-class=>"List"},"KeyLaunch") . $q->br() . 
										"KeyLaunch is a small utility for binding commands to a hot key. ".
										"It reads a configuration file in ~/.keylaunchrc. KeyLaunch uses Ctrl, ".
										"Alt and Shift as modifier keys, the hotkey is up to the user.",
									$q->font({-class=>"List"},"DeskMenu") . $q->br() . 
										"DeskMenu is a root menu program which is activated by clicking the root window. ".
										"It is configured from a .deskmenurc file in your home directory. DeskMenu is ".
										"useful for window managers which do not provide a menu such as Oroborus.",
									$q->font({-class=>"List"},"DeskLaunch") . " (well, we prefer GNOME)" . $q->br() . 
										"DeskLaunch is a small utility for creating desktop icons using pixmaps. ".
										"A simple click will launch the desired application."]
								)
							),
						)
					)
				)
			),
			$q->td({-width=>"5%"},"&nbsp;"),
			$q->td({-width=>"35%",
				-class=>"Main"},
				$self->readNews()
			)
		)
	),
	$q->h5('Last Update: $Date: 2003/02/21 05:25:52')
}

sub readNews() {
	my $news = new IO::File;
	open ($news, "<", "news.txt") or return "Could not read News, please report this to Stefan Pfetzing <dreamind AT dreamind DOT de>";
	my @news = readline($news);
	my $content = $q->Tr(
		$q->td({-class=>"NodeNews"},
			$q->h2("News")));
	for (my $i = 0; $i<@news; $i+=5) {
	$content .= $q->Tr(
			$q->td({-class=>"NewsTitle"},
				$q->a({-href=>"javascript:switchShow('News". $i/5 . "')"},
					$q->b($news[$i]), " ", $news[$i+1])
			)
		);
	$content .= $q->Tr(
			$q->td({-class=>"NewsItem"},
				$q->div({-id=>"News". $i/5 ,
						-class=>"Hidden"},
					$news[$i+2]
				)
			)
		);
	$content .= $q->Tr(
			$q->td({-class=>"Author"},
				$news[$i+3]
			)
		);
	}

	$content .= $q->Tr(
			$q->td({-class=>"NodeHelp"},
				$q->br(), $q->br(), $q->div({-class=>"Help"},"To show the details for a news entry click on the news title.")
			)
		);

	return $q->table({-width=>"100%",
			-cellpadding=>"0",
			-cellspacing=>"0"},
		$content
	);
}
# return a true value
1;
__END__


