Skip to content

Commit

Permalink
oo. Multi lang static pages.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.eprints.org/eprints/trunk/system@418 9491667e-5006-0410-a446-efbe8990b998
  • Loading branch information
cgutteridge committed Apr 29, 2001
1 parent c4dc9e4 commit 4301a8a
Show file tree
Hide file tree
Showing 26 changed files with 743 additions and 765 deletions.
77 changes: 33 additions & 44 deletions bin/generate_static
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,33 @@ use strict;


my $session = new EPrints::Session( 1 , $ARGV[0] );
print "____________________________\n";
my $language;
foreach $language ( keys %EPrints::Site::General::languages )
{
print $language."\n";
my $basepath = $session->getSite->getConf( "static_html_root" ).
"/$language/";
my $func = sub { generate_static( $language, $basepath, $session ) };
find( { wanted=>$func, follow=>1 }, $basepath );
}
exit;

find( { wanted=>\&generate_static, follow=>1 },
$session->{site}->{static_html_root}."/" );

$session->terminate();


sub generate_static
{
my( $language , $basepath , $session ) = @_;
# Ignore CVS directories
return if( $File::Find::name =~ /\/CVS/ );

my $destination_filename = $File::Find::name;
$destination_filename =~ s/$session->{site}->{static_html_root}/$session->{site}->{local_html_root}/;

my $newpath = $session->getSite->getConf( "local_html_root" ).
"/$language/";
$destination_filename =~ s/$basepath/$newpath/;

print STDERR "$File::Find::name -> $destination_filename\n";

Expand All @@ -48,55 +61,31 @@ print STDERR "$File::Find::name -> $destination_filename\n";
# If it's a directory, just make sure it exists in the destination.
unless( -e $destination_filename )
{
mkdir $destination_filename, 0775
mkdir( $destination_filename, 0775 )
or die "Can't make directory $destination_filename: $!\n";
}
}
else
{
# Is this is an HTML file?
if( /.+\.html/i )
# Is this is an HTML template file?
if( $destination_filename =~ s/\.xhtml$/.html/i )
{
# It's an HTML file. Add the "skin" if necessary
my $must_add_skin = 0;

# Open up the files
open IN, $File::Find::name
or die "Error opening $File::Find::name: $!\n";

open OUT, ">$destination_filename"
or die "Error opening $destination_filename for writing: $!\n";

my $first_line = <IN>;
chomp();

if( $first_line =~ s/^title:\s+//i )
my $parser = new XML::DOM::Parser(
ParseParamEnt => 1,
NoLWP => 1,
ProtocolEncoding => "ISO-8859-1" );
my $dom = eval {
$parser->parsefile( $File::Find::name );
};
if( $@ )
{
# We need to add the site frame
$must_add_skin = 1;

print OUT $session->{render}->start_html( $first_line );
my $err = $@;
$err =~ s# at /.*##;
die "Error parsing $File::Find::name\n$err";
}
else
{
# We're just copying verbatim
print OUT "$first_line\n";
}

# Copy the file across
while( <IN> )
{
chomp();
print OUT EPrints::Mailer::update_template_line($session, $_, undef );
print OUT "\n";
}

# Write the site frame terminator if appropriate
print OUT $session->{render}->end_html() if( $must_add_skin );

# Close the files
close( IN );
close( OUT );
print STDERR "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \n";
print STDERR $dom->getFirstChild->getNodeName."\n";
print $dom->printToFile( $destination_filename );
}
else
{
Expand Down
1 change: 0 additions & 1 deletion bin/startup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@


use EPrints::Auth;
use EPrints::Citation;
use EPrints::Database;
use EPrints::Deletion;
use EPrints::Document;
Expand Down
5 changes: 0 additions & 5 deletions cfg/intl/english
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
######################################################################


<file Citation.pm>
L:unknowneprint = Unknown EPrint field $(fieldname) in "$(citation_spec)"
A:na = N/A
</file>

<file Database.pm>
L:created_table = Created table: $(tablename)
L:bad_cache = Not a legal cache table: $(tableid)
Expand Down
2 changes: 1 addition & 1 deletion cgi/advsearch
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ my $searchexp = new EPrints::SearchExpression(
fieldnames=>$session->getSite()->getConf( "advanced_search_fields" ) );

my $preamble = $session->make_element( "p" );
$preamble->appendChild( $session->html_phrase( "dont_panic" ) );
$preamble->appendChild( $session->HTMLPhrase( "dont_panic" ) );

$searchexp->process_webpage(
$session->phrase( "adv_search" ),
Expand Down
2 changes: 1 addition & 1 deletion cgi/search
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ my $searchexp = new EPrints::SearchExpression(

my $preamble = $session->make_element( "p" );
my $a = $session->make_element( "a", href=>"advsearch" );
$a->appendChild( $session->html_phrase( "adv_search" ) );
$a->appendChild( $session->HTMLPhrase( "adv_search" ) );
$preamble->appendChild( $a );

my $title = $session->phrase( "simple_search" );
Expand Down
5 changes: 0 additions & 5 deletions intl/english
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
# Library Files
######################################################################


FILE = Citation.pm
unknowneprint = Unknown EPrint field $(fieldname) in "$(citation_spec)"
na = N/A

FILE = Database.pm
created_table = Created table: $(tablename)
bad_cache = Not a legal cache table: $(tableid)
Expand Down
53 changes: 30 additions & 23 deletions lib/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use Apache::Constants qw( OK AUTH_REQUIRED FORBIDDEN DECLINED SERVER_ERROR );

use EPrints::Session;
use EPrints::RequestWrapper;
use EPrints::Constants;

#tmp
use EPrints::Log;
Expand All @@ -29,61 +28,66 @@ sub authen
{
my( $r ) = @_;

print STDERR "Authen\n";
print STDERR "Authen\n";

my($res, $passwd_sent) = $r->get_basic_auth_pw;

my ($user_sent) = $r->connection->user;

print STDERR ref($r)."!!\n";
return OK unless $r->is_initial_req; # only the first internal request

if( !defined $user_sent )
{
print STDERR "bleep\n";
print STDERR "no user name\n";
return AUTH_REQUIRED;
}
print STDERR "URL: ".$r->the_request()."\n";
print STDERR "URL: ".$r->the_request()."\n";

my $session = new EPrints::Session( 2 , $r->hostname.$r->uri );
print STDERR "THE USER IS: $user_sent\n";
my $user = $session->{database}->get_single( $TID_USER , $user_sent );

print STDERR "THE USER IS: $user_sent\n";

my $ds = $session->getSite->getDataSet( "user" );

my $user = $session->getDB->get_single( $ds , $user_sent );
if( !defined $user )
{
print STDERR "zong\n";
print STDERR "zong\n";
$r->note_basic_auth_failure;
return AUTH_REQUIRED;
}
print STDERR "GRP:".$user->{usertype}."\n";
my $usertypedata = $session->{site}->{userauth}->{$user->{usertype}};
my $usertypedata = $session->getSite->getConf(
"userauth", $user->getValue( "usertype" ) );
if( !defined $usertypedata )
{
#cjg this is an error
print STDERR "Unknown user type: $user->{usertype}\n";
$session->getSite->log(
"Unknown user type: $user->{usertype}" );
return AUTH_REQUIRED;
}
print STDERR "X2:".join(",",keys %{$usertypedata->{conf}})."\n";
print STDERR "X2:".join(",",keys %{$usertypedata->{conf}})."\n";
my $rwrapper = EPrints::RequestWrapper->new(
$r ,
$usertypedata->{conf} );
my $result;
$result = &{$usertypedata->{routine}}( $rwrapper );
my $result = &{$usertypedata->{routine}}( $rwrapper );
$session->terminate();
return $result;
}

sub authz
{
my( $r ) = @_;
print STDERR "Authz\n";
print STDERR "XX:".$r->requires()."\n";
print STDERR EPrints::Log::render_struct( $r->requires() );
print STDERR "Authz\n";
print STDERR "XX:".$r->requires()."\n";
print STDERR EPrints::Log::render_struct( $r->requires() );
my %okgroups = ();
my $authz = 0;
my $reqset;
foreach $reqset ( @{$r->requires()} )
{
my $val = $reqset->{requirement};
print STDERR "REQUIxxx: $val\n";
print STDERR "REQUIxxx: $val\n";
$val =~ s/^\s*require\s+//;
# handle different requirement-types
if ($val =~ /valid-user/) {
Expand All @@ -94,26 +98,29 @@ sub authz
$okgroups{$_}++;
}
}
print STDERR "REQUIRES: $val\n";
print STDERR "REQUIRES: $val\n";
}

my ($user_sent) = $r->connection->user;
my $user_sent = $r->connection->user;
my $session = new EPrints::Session( 2 , $r->hostname.$r->uri );
print STDERR "THE USER IS: $user_sent\n";
my $user = $session->{database}->get_single( $TID_USER , $user_sent );
print STDERR "THE USER IS: $user_sent\n";
my $ds = $session->getSite->getDataSet( "user" );
my $user = $session->getDB->get_single( $ds , $user_sent );
if( defined $user )
{
foreach( @{$session->{site}->{userauth}->{$user->{usertype}}->{priv}} )
foreach( @{$session->getSite->getConf(
"userauth", $user->{usertype}, "priv" )} )
{
$authz = 1 if( defined $okgroups{$_} );
}
}

$session->terminate();
$session->terminate;

return OK if( $authz );

$r->note_basic_auth_failure;

return AUTH_REQUIRED;
}

Expand Down
Loading

0 comments on commit 4301a8a

Please sign in to comment.