Difference between revisions of "MePrintsInstall"

From EPrints Documentation
Jump to: navigation, search
(Patches)
Line 40: Line 40:
  
 
add profile_visibility
 
add profile_visibility
 +
 +
 +
 +
Quick Notes for meprints-1.0_rc1-2.tgz (from you to me)
 +
 +
1. cp meprints-1.0_rc1-2.tgz /opt/eprints3/archives/REPOSITORY_ID/
 +
2. cd !$
 +
3. tar zxvf meprints-1.0_rc1-2.tgz
 +
4. vim bin/generate_meprints:
 +
if necessary, replace the include line (first line): -I/opt/eprints3/perl_lib
 +
 +
5. symlinks:
 +
ln -s /opt/eprints3/archives/REPOSITORY_ID/cgi/meprints/ /opt/eprints3/cgi/
 +
ln -s /opt/eprints3/archives/REPOSITORY_ID/cgi/users/meprints/ /opt/eprints3/cgi/users/
 +
 +
6. /opt/eprints3/bin/epadmin update_database_stucture
 +
 +
7. patches:
 +
1- vim perl_lib/EPrints/DataSet.pm, replace my $INFO => our $INFO and that method:
 +
 +
sub get_sql_dataset_ids
 +
{
 +
        return( qw/ import metafield cachemap message loginticket eprint user document saved_search subject history access request public_profile_users registered_profile_users hidden_profile_users / );
 +
}
 +
 +
2- bin/generate_meprints REPOSITORY_ID should work, test
 +
 +
3- to have the static profiles rendered properly:
 +
 +
=pod Marcus:
 +
Open up bin/generate_apacheconf and after;
 +
 +
my $https_cgiroot = $repository->get_conf( "https_cgiroot" );
 +
 +
    add;
 +
 +
my $profile_root = $repository->get_conf( "archiveroot" )."/user_profiles";
 +
 +
    Next after;
 +
<Directory "$htdocs_path">
 +
SetHandler perl-script
 +
PerlResponseHandler EPrints::Apache::Template::handler
 +
</Directory>
 +
 
 +
    add;
 +
<Directory "$profile_root">
 +
SetHandler perl-script
 +
PerlResponseHandler EPrints::Apache::Template::handler
 +
</Directory>
 +
 +
Run 'bin/generate_apacheconf' and then restart your web server to reflect the changes to the server configuration.
 +
 +
Test: If you now go to http://repositoryurl.com/cgi/meprints/profile?userid=1 you should see the profile id 1.
 +
 +
 +
8. extras:
 +
0- default user citation: replace default_with_thumbnail.xml with default.xml
 +
1- for custom 404 errors when hitting a non-existing profile:
 +
 +
=pod marcus:
 +
For custom user not found errors update the code code in cgi/handle_404 so that it resembles the following;
 +
 +
if( defined $newurl )
 +
{
 +
        $session->redirect( $newurl );
 +
}
 +
elsif( $url =~ m#^$urlpath/profile/(.*)/?# )
 +
{
 +
        &nouser_404( $session, $1 );
 +
}
 +
elsif( $url =~ m#^$urlpath/view/# )
 +
{
 +
        &noview_404( $session );
 +
}
 +
else
 +
{
 +
        &plain_404( $session );
 +
}
 +
 +
Now add a new subroutine to cgi/handle_404 called nouser_404;
 +
 +
sub nouser_404
 +
{
 +
        my( $session, $username ) = @_;
 +
 +
        $session->build_page(
 +
                $session->html_phrase( "cgi/handle_http_error:404_user_title" ),
 +
                $session->html_phrase( "cgi/handle_http_error:404_user_blurb",
 +
                        username => $session->make_text( $username ) ),
 +
                "nouser_404" );
 +
 +
        $session->send_page();
 +
}
 +
=cut
 +
 +
2. To enable the pretty urls:
 +
 +
=pod marcus:
 +
Now the final step is to update perl_lib/EPrints/Apache/Rewrite.pm so that we can have pretty URLs for user profiles of the form http://repositoryurl.com/profile/USERNAME. Look for the following block;
 +
 +
$r->filename( $repository->get_conf( "htdocs_path" )."/".$lang.$localpath );
 +
 +
if( $uri =~ m#^/view(.*)# )
 +
{
 +
my $session = new EPrints::Session(2); # don't open the CGI info
 +
EPrints::Update::Views::update_view_file( $session, $lang, $localpath, $uri );
 +
$session->terminate;
 +
}
 +
else
 +
{
 +
EPrints::Update::Static::update_static_file( $repository, $lang, $localpath );
 +
}
 +
 +
Replace it with;
 +
 +
# $r->filename( $repository->get_conf( "htdocs_path" )."/".$lang.$localpath );
 +
 +
        if ( $uri =~ m! ^/profile\/([0-9a-z]+)(.*)$ !x )
 +
        {
 +
my $session = new EPrints::Session(2); # don't open the CGI info
 +
                my $ds = $session->get_repository->get_dataset( 'hidden_profile_users' );
 +
                my $searchexp = EPrints::Search->new(
 +
                        satisfy_all => 1,
 +
                        session => $session,
 +
                        dataset => $ds
 +
                );
 +
 +
                $searchexp->add_field( $ds->get_field( 'username' ), $1 );
 +
                my $result = $searchexp->perform_search;
 +
                if ( $result->count > 0 )
 +
                {
 +
                        return FORBIDDEN;
 +
                }
 +
 +
                $searchexp->clear;
 +
 +
                $ds = $session->get_repository->get_dataset( 'registered_profile_users' );
 +
                $searchexp->set_dataset( $ds );
 +
                $searchexp->add_field( $ds->get_field( 'username' ), $1 );
 +
                $result = $searchexp->perform_search;
 +
                if ( $result->count > 0 and not defined $session->current_user )
 +
                {
 +
                        return FORBIDDEN;
 +
                }
 +
 +
                my $user = EPrints::User::user_with_username( $session, $1 );
 +
                if ( defined $user )
 +
                {
 +
                        $r->filename( $repository->get_conf( 'archiveroot' )."/user_profiles/".$user->get_id."/profile/index.html" );
 +
                }
 +
        } else {
 +
                $r->filename( $repository->get_conf( 'htdocs_path' ).'/'.$lang.$localpath );
 +
        }
 +
 +
if( $uri =~ m#^/view(.*)# )
 +
{
 +
my $session = new EPrints::Session(2); # don't open the CGI info
 +
EPrints::Update::Views::update_view_file( $session, $lang, $localpath, $uri );
 +
$session->terminate;
 +
}
 +
else
 +
{
 +
EPrints::Update::Static::update_static_file( $repository, $lang, $localpath );
 +
}
 +
=cut
 +
 +
9. Restart web server, generate views etc.

Revision as of 10:37, 17 September 2009

Patches

EPrints::Apache::Rewrite

  • rewrite /profile/foo URLs
  • check profile is public (to be moved out - MR)

EPrints::DataSet

  • add public_profile_users pseudo dataset

EPrints::Update::View

  • don't use hardcoded dataset

cgi/handle404

  • not needed?

Changes

plugins.pl

  • Add settings to use MePrints::Homepage instead of User::View

user_fields_automatic.pl

  • Remove static on change

apachevhost.conf

<Directory "/opt/meprints_test/archives/meprints/user_profiles">
  SetHandler perl-script
  PerlResponseHandler EPrints::Apache::Template::handler
</Directory>

workflows/user/default.xml

add profile_visibility


Quick Notes for meprints-1.0_rc1-2.tgz (from you to me)

1. cp meprints-1.0_rc1-2.tgz /opt/eprints3/archives/REPOSITORY_ID/ 2. cd !$ 3. tar zxvf meprints-1.0_rc1-2.tgz 4. vim bin/generate_meprints: if necessary, replace the include line (first line): -I/opt/eprints3/perl_lib

5. symlinks: ln -s /opt/eprints3/archives/REPOSITORY_ID/cgi/meprints/ /opt/eprints3/cgi/ ln -s /opt/eprints3/archives/REPOSITORY_ID/cgi/users/meprints/ /opt/eprints3/cgi/users/

6. /opt/eprints3/bin/epadmin update_database_stucture

7. patches: 1- vim perl_lib/EPrints/DataSet.pm, replace my $INFO => our $INFO and that method:

sub get_sql_dataset_ids {

       return( qw/ import metafield cachemap message loginticket eprint user document saved_search subject history access request public_profile_users registered_profile_users hidden_profile_users / );

}

2- bin/generate_meprints REPOSITORY_ID should work, test

3- to have the static profiles rendered properly:

=pod Marcus: Open up bin/generate_apacheconf and after;

my $https_cgiroot = $repository->get_conf( "https_cgiroot" );

   add;

my $profile_root = $repository->get_conf( "archiveroot" )."/user_profiles";

   Next after;

<Directory "$htdocs_path"> SetHandler perl-script PerlResponseHandler EPrints::Apache::Template::handler </Directory>

   add;

<Directory "$profile_root"> SetHandler perl-script PerlResponseHandler EPrints::Apache::Template::handler </Directory>

Run 'bin/generate_apacheconf' and then restart your web server to reflect the changes to the server configuration.

Test: If you now go to http://repositoryurl.com/cgi/meprints/profile?userid=1 you should see the profile id 1.


8. extras: 0- default user citation: replace default_with_thumbnail.xml with default.xml 1- for custom 404 errors when hitting a non-existing profile:

=pod marcus: For custom user not found errors update the code code in cgi/handle_404 so that it resembles the following;

if( defined $newurl ) {

       $session->redirect( $newurl );

} elsif( $url =~ m#^$urlpath/profile/(.*)/?# ) {

       &nouser_404( $session, $1 );

} elsif( $url =~ m#^$urlpath/view/# ) {

       &noview_404( $session );

} else {

       &plain_404( $session );

}

Now add a new subroutine to cgi/handle_404 called nouser_404;

sub nouser_404 {

       my( $session, $username ) = @_;
       $session->build_page(
               $session->html_phrase( "cgi/handle_http_error:404_user_title" ),
               $session->html_phrase( "cgi/handle_http_error:404_user_blurb",
                       username => $session->make_text( $username ) ),
               "nouser_404" );
       $session->send_page();

} =cut

2. To enable the pretty urls:

=pod marcus: Now the final step is to update perl_lib/EPrints/Apache/Rewrite.pm so that we can have pretty URLs for user profiles of the form http://repositoryurl.com/profile/USERNAME. Look for the following block;

$r->filename( $repository->get_conf( "htdocs_path" )."/".$lang.$localpath );

if( $uri =~ m#^/view(.*)# ) { my $session = new EPrints::Session(2); # don't open the CGI info EPrints::Update::Views::update_view_file( $session, $lang, $localpath, $uri ); $session->terminate; } else { EPrints::Update::Static::update_static_file( $repository, $lang, $localpath ); }

Replace it with;

# $r->filename( $repository->get_conf( "htdocs_path" )."/".$lang.$localpath );

       if ( $uri =~ m! ^/profile\/([0-9a-z]+)(.*)$ !x )
       {

my $session = new EPrints::Session(2); # don't open the CGI info

               my $ds = $session->get_repository->get_dataset( 'hidden_profile_users' );
               my $searchexp = EPrints::Search->new(
                       satisfy_all => 1,
                       session => $session,
                       dataset => $ds
               );
               $searchexp->add_field( $ds->get_field( 'username' ), $1 );
               my $result = $searchexp->perform_search;
               if ( $result->count > 0 )
               {
                       return FORBIDDEN;
               }
               $searchexp->clear;
               $ds = $session->get_repository->get_dataset( 'registered_profile_users' );
               $searchexp->set_dataset( $ds );
               $searchexp->add_field( $ds->get_field( 'username' ), $1 );
               $result = $searchexp->perform_search;
               if ( $result->count > 0 and not defined $session->current_user )
               {
                       return FORBIDDEN;
               }
               my $user = EPrints::User::user_with_username( $session, $1 );
               if ( defined $user )
               {
                       $r->filename( $repository->get_conf( 'archiveroot' )."/user_profiles/".$user->get_id."/profile/index.html" );
               }
       } else {
               $r->filename( $repository->get_conf( 'htdocs_path' ).'/'.$lang.$localpath );
       }

if( $uri =~ m#^/view(.*)# ) { my $session = new EPrints::Session(2); # don't open the CGI info EPrints::Update::Views::update_view_file( $session, $lang, $localpath, $uri ); $session->terminate; } else { EPrints::Update::Static::update_static_file( $repository, $lang, $localpath ); } =cut

9. Restart web server, generate views etc.