Installing MePrints on Windows

Image of a face peeping over washing drying in front of a window

MePrints is an extension to the EPrints repository software that adds functionality for personal home pages for users with profile information and details of uploaded documents, most popular eprints etc.

The MePrints documentation is quite *nix centric but I have found that it is not impossible to get the extension running under Windows. Doing so requires installing a tool to process patch files and a small tweak to the MePrints code. You should also be comfortable with running programs and scripts using the Windows command prompt.

Download MePrints

At the time of writing the latest version of MePrints is 1.3. This can be downloaded from the EPrints file repository. You may want to go to search the repository for ‘MePrints’ to check if there is a more recent version.

Required Software

We’ll assume for the sake of this document that you have EPrints up and running on Windows. If not you can find instructions in an earlier blog post. In addition you will need software that will process patch files. Patch files are produced by version control software as a means of distributing a discrete set of changes. MePrints requires some changes to EPrints code and this is distributed as a patch. A free Patch program for Windows can be downloaded from the GNU sourceforge project. You can run the installer accepting the defaults.

Unpack MePrints

MePrints is distributed as a gzipped tar file (.tgz) and you will need archiving software that will be able unpack this file type. If your version of Windows does not have this natively or there is no other tool installed then 7Zip is a good alternative.

Install MePrints

The MePrints installation will make changes to core EPrints files and your database. We strongly recommend making a full backup before installing this extension.

The standard MePrints installation instructions can be found on the EPrints wiki. These will need to be tweaked slightly for Windows but generally hold true.

Unpack the MePrints installation file and copy the contents to the folder of the archive that will be using MePrints (e.g. C:\eprints\archives\myarchive\). The installation instructions say to check the include path in the file bin\generate_meprints but I have not found this to be necessary on Windows.

The installation instructions also say to link from the main EPrints CGI folder to MePrints folders in your archive. Again, I have not found this to be necessary on Windows and in any case support for symbolic link equivalents in Windows is patchy.

Using a command prompt, update the database as per the standard instructions but using the Windows location of EPrints and calling perl explicitly:

cd C:\eprints
perl bin/epadmin update_database_structure ARCHIVEID --verbose

You will now need to run Windows Patch to apply the patch file that ships with MePrints. Before doing this it is necessary to modify the patch file slightly. This file can be found in C:\eprints\archives\ARCHIVEID and is called meprints_1.0.patch. The modification to the file is necessary to convert the Unix style end-of-line delimiters (LF) into Windows style delimiters (CRLF). Some text editors have this facility built in. If yours does not then Notepad++ is a free editor that provides this functionality. Once this change has been made run the patch file:

cd C:\eprints
patch -R -p0 < archives/ARCHIVEID/meprints_1.0.patch

If you are running a version of EPrints less than 3.2 then you will also have to run a second patch. Do not do this if you are using EPrints 3.2 or greater:

patch -R -p0 < archives/ARCHIVE_ID/meprints_dataset.patch

The MePrints documentation now describes a set of changes to make to configuration files. In general these changes should be applied to files in the cfg/ folder within the archive that will be running MePrints rather than the core EPrints config folders. Not all of these changes are necessary on Windows – these are the ones that should be carried out:

Add the following to cfg/cfg.d/plugins.pl/ only if you are installing a MePrints version less than 1.3.

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

Add the highlighted below section to cfg/cfg.d/user_fields_automatic.pl:

$c->{user_fields_automatic} = sub {
    my $user = @_;
    ...
    if( defined $user->{changed} )
    {
        $user->remove_static();
    }
};

Add this line to cfg/cfg.d/eprint_fields_automatic.pl, before the closing curly brace:

$eprint->get_user->remove_static;

The next two changes in the standard installation documentation refer to files that do not exist, at least in EPrints 3.2.2 – cfg/cfg.d/urls.pl and cfg/apachevhost.conf. The change to the former file is not required.

If you are on a version of EPrints that has a file called cfg/apachevhost.conf then make the changes there. In more recent versions the latter file has been replaced by an equivalent in the main EPrints configuration folder:

C:\eprints\cfg\apache\

This folder will contain a file whose name is your Archive ID with the extension .conf. Add the changes to this file if it exists:

<Location "/profile">
    SetHandler perl-script
    PerlResponseHandler EPrints::Plugin::MePrints::MePrintsHandler
    DefaultType text/html
</Location>

Note the highlighted line above. This is not included in the standard documentation and has been added to fix behaviour that I observed relating to users who existed in the system before MePrints was installed. MePrints allows each user’s profile to be set as either Public or Private. For pre-existing users this value may be unset. Despite there being a default that appears to be observed in the code I found that when the value wasn’t set the response from the web server would always have a content type of text/plain. This resulted in the source of the page being rendered in the browser. The additional line above ensures that profile pages default to HTML.

Add the highlighted section below to cfg/workflows/user/default.xml:

<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"/>
        <field ref="jobtitle"/>
        <field ref="expertise"/>
        <field ref="biography"/>
        <field ref="qualifications"/>
    </component>

Copy the new default citation configuration file provided by MePrints over the existing file. Back up the existing file first. Also, as noted in the installation documentation, if you have made any changes to the default citation file you will need to re-add your changes after copying the MePrints version:

cd C:\eprints\archives\ARCHIVEID
cp cfg\citations\user\default_with_thumbnail.xml cfg\citations\user\default.xml

The final step from the standard installation documentation is to check the permissions on the MePrints folder within the relevant archive folder. I didn’t find this to be necessary on a test installation but if you are running on a more tightly locked-down server installation and have created a user specifically to run Apache then you may need to check that the web server account has Modify access on C:\eprints\archives\ARCHIVEID\meprints.

There is one additional change that needs to be made to overcome differences between the handling of binary files on Windows and Unix filesystems. Open the file C:\eprints\archives\ARCHIVEID\cgi\meprints\thumbnail. Add the line that is highlighted in the code below (at around line 34 in the code):

if( defined $fh )
{
    $session->send_http_header( content_type=>"image/png" );
    binmode $fh;
    my $buffer;
    while( read( $fh, $buffer, 4096 ) )

Note that if you upgrade MePrints in future you may need to re-apply this change.

Restart Apache to ensure that all changes are picked up. This should complete the installation. You can test by logging in as a user and clicking Homepage in the menu.

Issues on Windows

I have found the following issue on my Windows installation of MePrints:

  • Searching for users by name does not appear to work. Searching by username does work. Perhaps this is related to full-text indexing?
About these ads

About Rob Ingram
Rob Ingram is the Technical Officer for the Repositories Support Project offering technical advice and support to UK repository networks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: