EPrints 2.3 Documentation - How-To Guides |
Simple instructions are in the ArchiveConfig.pm section.
Example situation: On my main website www.foobars.ac.uk I have a page per research project, of which we have hundreds. Each project has a short unique id code, eg. ``manticore''. I have a field in my eprints archive (eprints.foobars.ac.uk) which is configured:
{ name=>"projectcodes", type=>"text", multiple=>1 }
I add the following browse view:
{ id=>"by_project", allow_null=>0, fields=>"projectcodes", order=>"-year/title" }
This will generate a page http://eprints.foobars.ac.uk/views/by_project/manticore.html with a list of all papers in that project, we can link to that URL!
If you want a subject to link the subject browse page of that value, add the browse_link property to the field (and regenerate the abstracts if you want).
If you remove the browse view you should remove the browse_link or it will be a broken link.
Values rendered inside citations which are used to link to the main record will not link into the browse view for obvious reasons.
If you change that to:
{ id=>"by_project", allow_null=>0, fields=>"projectcodes", order=>"-year/title", noindex=>1, nolink=>1, nohtml=>1, include=>1 }
This will generate a view which is NOT listed on the /view/ page and it will not skip making the .html file and make a .include file per value. This will only contain the ``count'' of items and the XHTML of their citations. This can be used as part of a page on the http://www.foobaars.ac.uk/ site; either by using php and capturing it on-the-fly using readfile
or scripting it with perl or NFS exporting the filesystem onto the main server (or just doing it all on one computer) and using server side includes to place it in a page.
I want to list the project papers in a strict format in a table with 4 columns: title, author(s), year and an icon which links to the document abstract page...
I add some more options to the browse view:
{ id=>"by_project", allow_null=>0, fields=>"projectcodes", order=>"-year/title", noindex=>1, nolink=>1, nohtml=>1, include=>1, nocount=>1, citation=>"project_table" }
Now I add a new citation to the citations config file:
<ep:citation type="project_table"><tr><td>&title;</td><td>&authors;</td> <td>&year;</td><td><ep:linkhere><img src="http://www.foobars.ac.uk/images/paperlink.png" alt="view" width="32" height="64" border="0" /></ep:linkhere></td></tr></ep:citation>
That should generate for the manticore project, in the ``.include'' file (I've cut the contents of the ``img'' tag for readability:
<tr><td>Making Stuff</td><td>Guy, A.</td><td>2001</td><td><a href="http://eprints.foobar.ac.uk/archive/00000923/"><img ... /></a> </td></tr> <tr><td>Eating Food</td><td>Herring, Walter and Chips, Bob</td><td> 2000</td><td><a href="http://eprints.foobar.ac.uk/archive/00000445/"> <img ... /></a></td></tr>
This is where the authors and editors field having an ID comes in handy.
Say we use local username to identify people in the ``Person ID'' fields, we can now set up a view:
{ id=>"by_person", allow_null=>0, fields=>"authors.id/editors.id", order=>"-year/title", noindex=>1, include=>1 }
This will generate both .html pages and .include pages. An member of your organisation can get
a list of their records either by linking to /views/by_person/alice.html
(where alice is their username) or by snarfing the URL /views/by_person/alice.include
into his own homepage.
This convers adding a new field to a new system, not a live system. It is possible to add a new field to a live system but invloves SQL hacking.
In this example we add a new ``set'' field called ``local'' which will have 3 options ``yes'',``no'' and ``partial'' - this will indicate if the item in question was produced in our organisation or not.
{ name => "local", type => "set", input_rows => 1, options => [ "yes", "no", "partial" ] }
input_rows being set to one will make it appear as a pull-down menu.
<field name="local" required="yes" />
File(s)
<ep:phrase ref="eprint_fieldname_local">Produced Locally</ep:phrase> <ep:phrase ref="eprint_fieldhelp_local">Please indicate if this item was produces in the foo organisation, or not. <ep:phrase ref="eprint_fieldopt_local_yes">produced locally</ep:phrase> <ep:phrase ref="eprint_fieldopt_local_no">not produced locally</ep:phrase> <ep:phrase ref="eprint_fieldopt_local_partial">only partially produced locally</ep:phrase>
In our example case we only want this to appear when citing technical reports, so we change that entry to:
<ep:citation type="eprint_techreport"><ep:linkhere><span class="citation">&authors; <ep:ifset name="year">(&year;) </ep:ifset>&title;. Technical Report<ep:ifset name="reportno"> &reportno;</ep:ifset><ep:ifset name="department">, &department; </ep:ifset><ep:ifset name="institution">, &institution;</ep:ifset>. &local;.</span></ep:linkhere></ep:citation>
All we've done is add &local;.
to the end. It's not inside <ep:ifset name="local">
as it is a required field and will (should) always be set.
In our example we only want to mention items if an item was not produced locally. We'll add it below the documents and above the abstract...
Single language example:
if( $eprint->get_value( "local" ) ne "yes" ) { # don't need to "my $p" as it's done earlier. $p = $session->make_element( "p" ); $p->appendChild( $session->make_text( "This item was " ) ); $p->appendChild( $eprint->render_value( "local" ) ); $p->appendChild( $session->make_text( "." ) );
# Append our new paragraph to the page. $page->appendChild( $p ); }
Multiple-language example:
If you want to make it handle more than language then we'll need to use the archive phrase file - we would add something like this to each languages file:
<ep:phrase ref="page:itemnotlocal"><p>This item was <pin ref="status" />.</p></ep:phrase>
And to the ArchiveRenderConfig.pm file:
if( $eprint->get_value( "local" ) ne "yes" ) { my $localmsg = $session->html_phrase( "page:itemnotlocal", status=>$eprint->render_value( "local" ) ); $page->appendChild( $localmsg ); }
You may prefer to use this method even if you are only using a single language.
If you add a field you will need to run erase_archive and create_tables before you will see a change. EPrints will fail to run if you change the fields and do rebuild the tables.
The quick answer is to say ``the opposite of adding one''.
file(s)
Add the eprint type to metadata-types.xml. Some fields should probably be ``required''.
Add the name of the type to the phrase file.
Add a citation for this type to the citations file.
Remove it from metadata-types.xml
You can remove it from the phrase file & citations but it won't hurt to leave it there.
Add it to metadata-types.xml. This does not need any fields.
Add the name of the document type to the phrase file.
Add a citation for this document to the citations file.
If you want this to be one of the must-have-one-of document types then add it's id to the list in ArchiveConfig.pm
If you want to do something ``clever'' on the abstract page then edit the ArchiveRenderConfig.pm file. If you don't then it will use the citiation you created to render it in the list, as with PDF, HTML etc.
The UK Open University (open.ac.uk) have set up a service which allows you to create a discussion for every EPrint in your archive.
The really easy way to do this is to use their discussion server. If you want to run your own d3e server the software is available from http://d3e.sourceforge.net/
Just add the following code to the ArchiveRenderConfig.pm file just before the
if( $has_multiple_versions )
bit.
Please note that this code is not internationalised.
##################################### # Begin D3Eprints links
my $ol = $session->make_element( "ol" ); my $li = $session->make_element( "li" ); $a = $session->render_link( EPrints::Utils::url_escape( "http://d3eprints.open.ac.uk/disc.php?url=".$eprint->get_url ), "_top" ); $a->appendChild( $session->make_text( "View public discussion of this document" ) ); $li->appendChild( $a ); $ol->appendChild( $li );
$li = $session->make_element( "li" ); $a = $session->render_link( EPrints::Utils::url_escape( "http://d3eprints.open.ac.uk/private/disc.php?url=". $eprint->get_url ), "_top" ); $a->appendChild( $session->make_text( "Create private discussion of this document" ) ); $li->appendChild( $a ); $ol->appendChild( $li );
$table->appendChild( _render_row( $session, $session->make_text( "D3Eprints discussion" ), $ol ) );
# End of D3Eprints links #####################################
The contents of the ``latest'' page - /perl/latest - can be included via a cron tab using wget and a server side include or using something like PHP's command to do:
readfile( "http://eprints.foo.org/perl/latest?mainonly=yes" );
The ``mainonly=yes'' flag is a hack which supresses the template of any eprints page in the /perl/ area so that it can be included, but it is most useful for ``latest''.
WARNING: If you have a script which imports 1000 records in one night then latest isn't currently bright enough to truncate the list so your homepage could get kinda messy.
EPrints does not support this natively but there are several options.
There is plenty of software which will provide a full text search of a website. To add non-eprints cgi scripts to your site create a directory in the cgi dir:
mkdir /opt/eprints2/cgi/local
and place your scripts in there, they will have URLs under http://yoursite.com/perl/
This is very easy, but will only index public documents. Any search engine will work, but Google is a good choice. Google provide a site-search service which allows you to register with them and then have a form which searches your site using google and adds your logo and colourscheme to the results.
A really easy solution is to just make a form which links to our ``google_site'' script which just adds ``site:yoursite.com'' to the google request to limit the search results. The HTML for this would be something like:
<form action="/perl/google_site"> <p>Use Google to search this site: <input name="q" value="" /> <input type="submit" name="go" value="Search" /> </form>
For other search engines; see their documentation for how to make a form to search only your site.
This should have been in the 2.2 docs but I didn't have time. Check the latest version of the documentation at software.eprints.org, if it's not there then bug me at support@eprints.org
This should have been in the 2.2 docs but I didn't have time. Check the latest version of the documentation at software.eprints.org, if it's not there then bug me at support@eprints.org
This should have been in the 2.2 docs but I didn't have time. Check the latest version of the documentation at software.eprints.org, if it's not there then bug me at support@eprints.org
EPrints 2.3 Documentation - How-To Guides |