Difference between revisions of "MePrintsInstall"

From EPrints Documentation
Jump to: navigation, search
(cfg/workflows/user/default.xml)
Line 109: Line 109:
 
       <field ref="profile_visibility" required="yes"/>
 
       <field ref="profile_visibility" required="yes"/>
 
     </component>
 
     </component>
 
Quick Notes for meprints-1.0_rc1-2.tgz (from you to me)
 
  
 +
===cfg/citations/user/default.xml===
  
 +
To replace the default EPrints user citation with the MePrints thumbnail citation:
  
 +
cp cfg/citations/user/default_with_thumbnail.xml cfg/citations/user/default.xml
  
2- bin/generate_meprints REPOSITORY_ID should work, test
+
'''Note: if you have already made changes to the default citation, you will want to examine both files and merge the MePrints changes into default.xml
  
3- to have the static profiles rendered properly:
+
==Testing==
  
=pod Marcus:
+
After applying all the changes above, restart Apache to activate MePrints.
Open up bin/generate_apacheconf and after;
 
  
my $https_cgiroot = $repository->get_conf( "https_cgiroot" );
+
===Homepage===
  
    add;
+
===Profile page===
  
my $profile_root = $repository->get_conf( "archiveroot" )."/user_profiles";
+
http://repositoryurl.com/cgi/meprints/profile?userid=1
  
    Next after;
+
===User views===
<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.
+
Run:
  
Test: If you now go to http://repositoryurl.com/cgi/meprints/profile?userid=1 you should see the profile id 1.
+
bin/generate_views ARCHIVEID --generate menus
  
 
+
Check http://my.repository.org/views/ - you should see 2 extra views. You may want to link these into your template.
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 11:43, 17 September 2009

For an overview of MePrints features, see MePrintsFeatures.

Installation (EPrints 3.1+)

Download the latest release to your local repository directory (eg. /opt/eprints3/archives/ARCHIVEID/).

Extract files:

tar xzvf meprints_xx.tgz

Install bin scripts

Edit the bin/generate_meprints file and check the include path on the first line. For example if you have installed EPrints in /var/lib/eprints3 change the line from:

#!/usr/bin/perl -w -I/opt/eprints3/perl_lib

to:

#!/usr/bin/perl -w -I/var/lib/eprints3/perl_lib

Install cgi scripts

Link the MePrints cgi scripts into the EPrints cgi directory:

ln -s /opt/eprints3/archives/ARCHIVEID/cgi/meprints/ /opt/eprints3/cgi/
ln -s /opt/eprints3/archives/ARCHIVEID/cgi/users/meprints/ /opt/eprints3/cgi/users/

Update database

Add the new MePrints user fields (defined in cfg/cfg.d/z_meprints.pl) to your repository database:

cd /opt/eprints3/
bin/epadmin update_database_structure ARCHIVEID --verbose

Patches

Apply the patchfile included with MePrints:

perl_lib/EPrints/DataSet.pm

MePrints introduces a new dataset containing all users with a public profile. To activate the new dataset:

Find the line:

my $INFO =

and replace with:

our $INFO =

Find the lines:

sub get_sql_dataset_ids
{
       return( qw/ import metafield cachemap message loginticket eprint user document saved_search subject history access request / );
}

and replace with:

sub get_sql_dataset_ids
{
       return( qw/ import metafield cachemap message loginticket eprint user document saved_search subject history access request public_profile_users / );
}

perl_lib/EPrints/Update/Views.pmm

Add support for MePrints views:

perl_lib/EPrints/Apache/Rewrite.pm

Add support for MePrints profile URLs (eg. http://my.repository.org/profiles/xyx):

Getting Started

To active MePrints, you will need to make some changes to your repository setup.

cfg/cfg.d/plugins.pl

To use the MePrints homepage instead instead of the default EPrints page, add the following lines to your cfg/cfg.d/plugins.pl configuration file:

$c->{plugin_alias_map}->{"Screen::User::View"} = "Screen::User::Homepage";
$c->{plugin_alias_map}->{"Screen::User::Homepage"} = undef;

cfg/cfg.d/user_fields_automatic.pl

To update the MePrints profile page automatically when a user changes his or her profile information, add the following lines to your cfg/cfg.d/user_fields_automatic.pl configuration file:

cfg/apachevhost.conf

To activate the MePrints profile pages, add the following lines to your cfg/apachevhost.conf configuration file:

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

cfg/workflows/user/default.xml

To allow users to choose whether their profile is public or private add the following lines to your cfg/workflows/user/default.xml file:

 <stage name="default">
   ...
   <component type="Field::Multi">
     <title><epc:phrase ref="user_section_personal" /></title>
     ...
   </component>
   <component type="Field::Multi">
     <title><epc:phrase ref="user_section_meprints" /></title>
     <field ref="profile_visibility" required="yes"/>
   </component>

cfg/citations/user/default.xml

To replace the default EPrints user citation with the MePrints thumbnail citation:

cp cfg/citations/user/default_with_thumbnail.xml cfg/citations/user/default.xml

Note: if you have already made changes to the default citation, you will want to examine both files and merge the MePrints changes into default.xml

Testing

After applying all the changes above, restart Apache to activate MePrints.

Homepage

Profile page

http://repositoryurl.com/cgi/meprints/profile?userid=1

User views

Run:

bin/generate_views ARCHIVEID --generate menus

Check http://my.repository.org/views/ - you should see 2 extra views. You may want to link these into your template.