https://wiki.eprints.org/w/api.php?action=feedcontributions&user=Uis475&feedformat=atomEPrints Documentation - User contributions [en-gb]2024-03-28T22:40:19ZUser contributionsMediaWiki 1.31.8https://wiki.eprints.org/w/index.php?title=Adding_new_views&diff=4603Adding new views2007-07-10T08:38:57Z<p>Uis475: </p>
<hr />
<div>{{development}}<br />
<br />
Browse views provide a way for visitors to your site to discover relevant content without a specific item in mind (for example, browsing all the content associated with a particular topic). Visitors arriving directly at the page for a specific item in the repository (for example, via a search engine) also use views you have defined to discover related content. <br />
<br />
There are two default views in EPrints - '''By Year''' and '''By Subject'''. This guide describes how to add additional views to your repository.<br />
<br />
__TOC__<br />
<br />
===The basics===<br />
<br />
The views for your repository are defined in the views configuration file:<br />
<br />
/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl<br />
<br />
Open this file and find the browse_views configuration setting:<br />
<br />
$c->{browse_views} = [<br />
{<br />
id => "year",<br />
fields => "-date;res=year",<br />
...<br />
},<br />
{<br />
id => "subjects",<br />
fields => "subjects",<br />
...<br />
},<br />
];<br />
<br />
The views are defined using a special (Perl) syntax: the view definition consists of a pair of curly braces (''note the comma after each closing brace'') enclosing a list of property/value pairs (note ''the comma'' after each line).<br />
<br />
The key part of the view definition is the '''fields''' property. This names the metadata field (or fields) that EPrints will use to construct the view. For example, for the '''By Year''' view, EPrints groups the records in the repository according to their '''date''' (note that the '''res=year''' suffix tells EPrints to only consider the year part), and constructs a Web page for each date listing the records. Similarly, the '''Browse by Subjscts''' view, groups the records according to the ''subjects'' they have been assigned to (a record may appear in more than one group!).<br />
<br />
Both the '''Browse by Year''' and '''Browse by Subject''' views are constructed using the values of a single field ('''date''' and '''subjects''' respectively).<br />
<br />
It is also possible to construct a view using the ''combined'' values of two or more fields (eg. group records by author '''and''' editor), or even using a sequence of two or more fields (eg. group records by journal title '''and then''' by volume number).<br />
<br />
===Worked example: browse by organisational structure===<br />
<br />
By default, EPrints has a ''divisions'' metadata field which allows authors to associate their deposits with the divisions (units, faculties, schools, departments, institutes, centres..) that were involved in producing their item (for example, the author's department, and the departments of any co-authors). This worked example allows visitors to browse the repository content by division.<br />
<br />
Open the views configuration file:<br />
<br />
/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl<br />
<br />
Add the following definition to the browse_views setting:<br />
<br />
$c->{browse_views} = [<br />
{<br />
id => "year",<br />
...<br />
},<br />
{<br />
id => "subjects",<br />
...<br />
},<br />
{<br />
id => "divisions",<br />
fields => "divisions",<br />
order => "-date/title",<br />
hideempty => 1,<br />
},<br />
];<br />
<br />
Save the file and generate the new view pages (this will also re-generate any existing views defined in the views configuration file):<br />
<br />
bin/generate_views ARCHIVEID --verbose<br />
<br />
Open the view page in a Web browser:<br />
<br />
http://your.repository.url/view/<br />
<br />
The view page lists all the available views. You should see your new views on the list:<br />
<br />
[[Image:View_page2.png|frame|none|The view page lists available views]]<br />
<br />
'''Fixing the undefined phrase warning''' The new view may appear on the views page with an ''undefined phrase'' warning (you may also notice a similar warning message when running generate_views):<br />
<br />
["viewname_eprint_divisions" not defined]<br />
<br />
Each view you create needs to be assigned a ''human-readable'' name, which EPrints will use on the view Web pages.<br />
<br />
Edit the language-specific phrases file for view names:<br />
<br />
/opt/eprints3/archives/ARCHIVEID/cfg/lang/en/phrases/views.xml<br />
<br />
Add an appropriate phrase which describes the new view, for example:<br />
<br />
<epp:phrase id="viewname_eprint_divisions">Division</epp:phrase><br />
<br />
Save the phrases file and regenerate the view pages:<br />
<br />
bin/generate_views ARCHIVEID --verbose<br />
<br />
===Example view definitions===<br />
<br />
====Browse by type====<br />
<br />
Every deposit in EPrints has a type (article, book, thesis...). To allow visitors to browse your repository content by type, add the following definition to the browse_views setting:<br />
<br />
{<br />
id => "types",<br />
fields => "type",<br />
order => "-date/title",<br />
hideempty => 1,<br />
},<br />
<br />
====Browse by author====<br />
<br />
===Example views (combined fields)===<br />
<br />
====Browse by author and editor====<br />
<br />
===Example views (multiple fields)===<br />
<br />
====Browse by journal title, then by volume====<br />
<br />
This example lets visitors browse the journals items in your repository have been published in, and then volumes within each journal.<br />
<br />
{<br />
id=>"journal_volume",<br />
fields=>"publication,volume",<br />
order=>"-date/title",<br />
hideempty => 1,<br />
},<br />
<br />
[[Image:Browse_by_journal.png|border]]<br />
<br />
[[Image:Browse_by_journal_volume.png|border]]<br />
<br />
<br />
<br />
===Linking in your view===<br />
<br />
You now need to add a link to your repository pages which takes visitors directly to your new view, or to the views page from where they can access all available views.<br />
<br />
[[Image:Browse_by_navbar.png]]<br />
<br />
====Generating CVs etc====<br />
<br />
===Linking items back to views===<br />
===Views as collections===</div>Uis475https://wiki.eprints.org/w/index.php?title=Adding_new_views&diff=4602Adding new views2007-07-10T08:37:20Z<p>Uis475: </p>
<hr />
<div>{{development}}<br />
<br />
Browse views provide a way for visitors to your site to discover relevant content without a specific item in mind (for example, browsing all the content associated with a particular topic). Visitors arriving directly at the page for a specific item in the repository (for example, via a search engine) also use views you have defined to discover related content. <br />
<br />
There are two default views in EPrints - '''By Year''' and '''By Subject'''. This guide describes how to add additional views to your repository.<br />
<br />
__TOC__<br />
<br />
===The basics===<br />
<br />
The views for your repository are defined in the views configuration file:<br />
<br />
/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl<br />
<br />
Open this file and find the browse_views configuration setting:<br />
<br />
$c->{browse_views} = [<br />
{<br />
id => "year",<br />
fields => "-date;res=year",<br />
...<br />
},<br />
{<br />
id => "subjects",<br />
fields => "subjects",<br />
...<br />
},<br />
];<br />
<br />
The views are defined using a special (Perl) syntax: the view definition consists of a pair of curly braces (''note the comma after each closing brace'') enclosing a list of property/value pairs (note ''the comma'' after each line).<br />
<br />
The key part of the view definition is the '''fields''' property. This names the metadata field (or fields) that EPrints will use to construct the view. For example, for the '''By Year''' view, EPrints groups the records in the repository according to their '''date''' (note that the '''res=year''' suffix tells EPrints to only consider the year part), and constructs a Web page for each date listing the records. Similarly, the '''Browse by Subjscts''' view, groups the records according to the ''subjects'' they have been assigned to (a record may appear in more than one group!).<br />
<br />
Both the '''Browse by Year''' and '''Browse by Subject''' views are constructed using the values of a single field ('''date''' and '''subjects''' respectively).<br />
<br />
It is also possible to construct a view using the ''combined'' values of two or more fields (eg. group records by author '''and''' editor), or even using a sequence of two or more fields (eg. group records by journal title '''and then''' by volume number).<br />
<br />
===Worked example: browse by organisational structure===<br />
<br />
By default, EPrints has a ''divisions'' metadata field which allows authors to associate their deposits with the divisions (units, faculties, schools, departments, institutes, centres..) that were involved in producing their item (for example, the author's department, and the departments of any co-authors). This worked example allows visitors to browse the repository content by division.<br />
<br />
Open the views configuration file:<br />
<br />
/opt/eprints3/archives/ARCHIVEID/cfg/cfg.d/views.pl<br />
<br />
Add the following definition to the browse_views setting:<br />
<br />
$c->{browse_views} = [<br />
{<br />
id => "year",<br />
...<br />
},<br />
{<br />
id => "subjects",<br />
...<br />
},<br />
{<br />
id => "divisions",<br />
fields => "divisions",<br />
order => "-date/title",<br />
hideempty => 1,<br />
},<br />
];<br />
<br />
Save the file and generate the new view pages (this will also re-generate any existing views defined in the views configuration file):<br />
<br />
bin/generate_views ARCHIVEID --verbose<br />
<br />
Open the view page in a Web browser:<br />
<br />
http://your.repository.url/view/<br />
<br />
The view page lists all the available views. You should see your new views on the list:<br />
<br />
[[Image:View_page2.png|frame|none|The view page lists available views]]<br />
<br />
'''Fixing the undefined phrase warning''' The new view may appear on the views page with an ''undefined phrase'' warning (you may also notice a similar warning message when running generate_views):<br />
<br />
["viewname_eprint_divisions" not defined]<br />
<br />
Each view you create needs to be assigned a ''human-readable'' name, which EPrints will use on the view Web pages.<br />
<br />
Edit the language-specific phrases file for view names:<br />
<br />
/opt/eprints3/archives/'''''YOUR_REPOSITORY_ID'''''/cfg/lang/en/phrases/views.xml<br />
<br />
Add an appropriate phrase which describes the new view, for example:<br />
<br />
<epp:phrase id="viewname_eprint_divisions">Division</epp:phrase><br />
<br />
Save the phrases file and regenerate the view pages:<br />
<br />
bin/generate_views ARCHIVEID --verbose<br />
<br />
===Example view definitions===<br />
<br />
====Browse by type====<br />
<br />
Every deposit in EPrints has a type (article, book, thesis...). To allow visitors to browse your repository content by type, add the following definition to the browse_views setting:<br />
<br />
{<br />
id => "types",<br />
fields => "type",<br />
order => "-date/title",<br />
hideempty => 1,<br />
},<br />
<br />
====Browse by author====<br />
<br />
===Example views (combined fields)===<br />
<br />
====Browse by author and editor====<br />
<br />
===Example views (multiple fields)===<br />
<br />
====Browse by journal title, then by volume====<br />
<br />
This example lets visitors browse the journals items in your repository have been published in, and then volumes within each journal.<br />
<br />
{<br />
id=>"journal_volume",<br />
fields=>"publication,volume",<br />
order=>"-date/title",<br />
hideempty => 1,<br />
},<br />
<br />
[[Image:Browse_by_journal.png|border]]<br />
<br />
[[Image:Browse_by_journal_volume.png|border]]<br />
<br />
<br />
<br />
===Linking in your view===<br />
<br />
You now need to add a link to your repository pages which takes visitors directly to your new view, or to the views page from where they can access all available views.<br />
<br />
[[Image:Browse_by_navbar.png]]<br />
<br />
====Generating CVs etc====<br />
<br />
===Linking items back to views===<br />
===Views as collections===</div>Uis475https://wiki.eprints.org/w/index.php?title=Branding,_the_next_level&diff=4441Branding, the next level2007-06-19T08:21:37Z<p>Uis475: /* Step One: design */</p>
<hr />
<div>This document describes how to completely customise the template of your EPrints 3 repository. Not just changing some colour schemes and images, but a reworking of the structure of the HTML.<br />
<br />
== Introduction ==<br />
The redesign process is not an easy one.<br/><br />
No, let me rephrase that: When designing a complete re-branding, altering the EPrints files is pretty - easy however the design, the xhtml and the css all requires some skill and knowledge. That part of the process is not discussed here, sorry.<br />
<br />
== Step One: design ==<br />
Get the design right.<br/><br />
Speak to Web Designers/Graphic Artists about layout/graphics/composition.<br/><br />
Speak to xhtml coders and CSS monkeys about accessibility, cross-browser compatibility, and good practice.<br/><br />
Make up some static pages to get the page right ''before'' you edit any EPrints files.<br />
<br />
This is the design I'm going to talk about:<br />
[[Image:overview.png]]<br />
<br />
== Step Two: implement ==<br />
Let us assume that you have configured the basic repository, created the database, and created an admin user.<br/><br />
Let us further assume that you are at the top of the installed EPrints software (<code>/opt/</code> or <code>/usr/local</code> or <code>/home/eprints</code> or wherever you've installed it)<br />
<br />
Edit the default template for your repository:<br />
<pre><br />
vi archives/ARCHIVEID/cfg/lang/en/templates/default.xml<br />
</pre><br />
<br />
Edit the file, or delete all the contents and start again.<br />
=== Head section ===<br />
<pre><br />
<br />
<?xml version="1.0" standalone="no" ?><br />
<!DOCTYPE html SYSTEM "entities.dtd" > <br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epc="http://eprints.org/ep3/control" xml:lang="en" lang="en"><br />
<head><br />
<title><epc:pin ref="title" textonly="yes"/> - <epc:phrase ref="archive_name"/></title><br />
<script src="/javascript/auto.js" type="text/javascript"></script><br />
<style type="text/css" media="screen">@import url(/style/auto.css);</style><br />
<style type="text/css" media="screen"> @import url(/style/eprints.css); </style><br />
<style type="text/css" media="print">@import url(/style/print.css);</style><br />
<!--[if IE]><br />
<style type="text/css" media="screen">@import url(/style/IE_Hacks.css);</style><br />
<![endif]--><br />
<br />
<link rel="icon" href="/favicon.ico" type="image/x-icon"/><br />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/><br />
<link rel="Top" href="{$config{frontpage}}"/><br />
<link rel="Search" href="/perl/search"/><br />
<epc:pin ref="head"/><br />
</head><br />
<br />
</pre><br />
<br />
This is the head section of the xhtml for our demo page. <br/><br />
* <code><title><epc:pin ref="title" textonly="yes"/> - <epc:phrase ref="archive_name"/></title></code> shows that the title is made from two elements defined in one of the ''phrases'' files<br />
* <code><script src="/javascript/auto.js" type="text/javascript"></script></code> is the line that pulls in the auto-completer javascript<br />
* <code><style type="text/css" media="screen">@import url(/style/auto.css);</style></code> is the bit that pulls in all the default javascript styling<br />
* <code><style type="text/css" media="screen"> @import url(/style/eprints.css); </style></code> is my extra CSS for my design<br />
* <code><style type="text/css" media="print">@import url(/style/print.css);</style></code> is the css that is referenced when printing to the page<br />
* <code>&lt;!--[if IE]&gt;<style type="text/css" media="screen">@import url(/style/IE_Hacks.css);</style>&lt;![endif]--&gt;</code> is my hack to include IE-specific CSS that the web validators won't see (or complain about)<br />
* <code><epc:pin ref="head"/></code> is a pin-holder for any extra head-section tags that are defined (''where?'')<br />
<br />
=== Body section ===<br />
<pre><br />
<br />
<body><br />
<div class="ep_noprint"><noscript><style type='text/css'>@import url(/style/nojs.css);</style></noscript></div><br />
<div id="container"><br />
<div id="banner" class="ep_noprint"><br />
<div id="banner_inner"><br />
<span id="the_depot_logo" >The DEPOT</span><br />
</div> <!-- end of banner_inner --><br />
</div> <!-- end of banner --><br />
<div id="main_area" class="clearfix"> <!-- start of the menus and body of text --><br />
<div id="top_menu" class="ep_noprint" ><br />
<div id="tabcontainer"><br />
<!-- Menu is defined dynamically --><br />
<ul id="navtabs"><epc:pin ref="login_status"/></ul><br />
</div> <!-- end of tabcontainer --><br />
</div> <!-- end of top_menu --><br />
<div id="content" ><br />
<epc:pin ref="page"/><br />
</div> <!-- end of content --><br />
</div> <!-- end of main_area --><br />
<div id="footer" class="clearfix ep_noprint"><br />
<img src="/images/logos.gif" title="Logos for EDINA and SHERPA" alt="[LOGOS]" class="edina_logo" style="float:left"/><br />
<span id="banner_image_copyright">Banner image &copy; JupiterImages 2006</span><br />
<div id="credit">This service is running on <em>GNU EPrints</em> repository-creating software, which generates <br />
repositories that are compliant with the <a href="http://www.openarchives.org">Open Archives Protocol for<br />
Metadata Harvesting OAI 2.0</a>.<br /><br />
<span id="take_down">&#187; <a href="/policy.html" title="What to do when you discover a deposit that infringes<br />
UK laws">how to complain</a> about a paper in the Depot</span></div><br />
</div> <!-- end of footer --><br />
</div><br />
</body><br />
<br />
</pre><br />
<br />
So - what do we have here?<br />
* <code>&lt;noscript&gt;&lt;style type='text/css'&gt;@import url(/style/nojs.css);&lt;/style&gt;&lt;/noscript&gt;</code> is a non-complient ''bodge'' to include extra CSS (used by the core eprints code) when there is no Javascript available.<br />
* <code>&lt;ul id="navtabs"&gt;&lt;epc:pin ref="login_status"/&gt;&lt;/ul&gt;</code> is the bit that defines the toolbar (more later)<br />
* <code>&lt;epc:pin ref="page"/&gt;</code> is the bit that defines where the code sits<br />
The rest is all design and layout (and there is a ''lot'' of design and layout in <code>/style/eprints.css</code><br />
<br />
== Toolbar ==<br />
<br />
=== Changing the separator ===<br />
The toolbar in a standard EPrints system is a series of &lt;span&gt;'ed items, with a defined separator.<br />
<br />
To change the seperator to (say) the hash symbol ('#'), edit the file <code>archives/deposit/cfg/lang/en/phrases/dynamic.xml</code> and add<br />
<pre><br />
<epp:phrase id="Plugin/Screen:tool_divide"> # </epp:phrase><br />
</pre><br />
(the <code>dynamic.xml</code> file needs to be valid XML, so you can't change the separator to something like <code>&lt;/li&gt;&lt;li&gt;</code>.)<br />
<br />
=== Changing the toolbar items ===<br />
The toolbar is dynamically created.<br />
* there is one form for an anonymous user<br />
** (this is where a user logs in, or creates a new account)<br />
*** [[image:anon_toolbar.png]]<br />
* and one for a logged in user<br />
** The toolbar for an admin-level user could look like:<br />
*** [[image:admin_toolbar.png]]<br />
<br />
To deviate from the default toolbar, you will need to provide your own xhtml. Edit <code>archives/deposit/cfg/lang/en/phrases/dynamic.xml</code> and add:<br />
<pre><br />
<epp:phrase id="dynamic:not_logged_in"><!--<br />
--><li><a class="h_menulink" href="/view/">Browse</a></li><!--<br />
--><li><a class="h_menulink" href="{$config{userhome}}">Login</a></li><!--<br />
--><li><a class="h_menulink" href="{$config{perl_url}}/register">Create Account</a></li><!--<br />
--></epp:phrase><br />
<br />
<epp:phrase id="dynamic:logged_in"><!--<br />
--><li class="logged_in_as" style="float: right">Logged in as <epc:pin name="user"/></li><!-- <br />
--><li><a class="h_menulink" href="/view/">Browse</a></li><!--<br />
--><epc:pin name="tools" /><!--<br />
--><li><a class="h_menulink" href="{$config{perl_url}}/logout">Logout</a></li><!--<br />
--></epp:phrase><br />
</pre><br />
my example is different from the standard EPrints layout in that I am also switching to using a list for each of my toolbar items<br />
<br />
'''Note''': the use of the xhtml comments as above is part of a CSS "trick"<br />
<br />
=== Removing items from the user list ===<br />
Items can easily be removed from the toolbar (I have removed the '''Saved Searches''' item.)<br />
<br />
Edit <code>archives/deposit/cfg/cfg.d/plugins.pl</code><br />
<pre><br />
# option to disable the functionality all together<br />
$c->{plugins}->{"Screen::User::SavedSearches"}->{params}->{disable} = 1;<br />
</pre><br />
<br />
Where <code>Screen::User::SavedSearches</code> corresponds to <code>perl_lib/EPrints/Plugin/<strong>Screen/User/SavedSearches.pm</strong></code><br />
<br />
=== Changing the actual format ===<br />
<br />
In my example, we have actually changed the toolbar to be a series if List Items (<code>&lt;li&gt;foo&lt;/li&gt;</code>)<br />
<br />
This is somewhat more complex, and requires code-hacking<br />
<br />
The toolbar is created in <code>perl_lib/EPrints/Session.pm</code>, in a function called <code>render_toolbar</code>.<br />
<br />
This needs to be changed in several places, however in essence, you need to replace:<br />
<pre><br />
my $first = 1;<br />
foreach my $tool ( @core )<br />
{<br />
if( $first )<br />
{<br />
$first = 0;<br />
} <br />
else<br />
{<br />
$core->appendChild( $self->html_phrase( "Plugin/Screen:tool_divide" ) );<br />
}<br />
my $a = $self->render_link( $url."?screen=".substr($tool->{screen_id},8) );<br />
$a->appendChild( $tool->{screen}->render_title );<br />
$core->appendChild( $a );<br />
}<br />
</pre><br />
with:<br />
<pre><br />
foreach my $tool ( @core )<br />
{<br />
my $a = $self->render_link( $url."?screen=".substr($tool->{screen_id},8) );<br />
$a->appendChild( $tool->{screen}->render_title );<br />
my $li = $self->make_element('li', class=>"");<br />
$li->appendChild($a);<br />
$core->appendChild( $li );<br />
}<br />
</pre><br />
(Thanks to Ben Wheeler for that)<br />
<br />
== Rebuild the web pages ==<br />
Every time you alter <code>archives/ARCHIVEID/cfg/lang/en/templates/default.xml</code>, you need to regenerate the pages of the service:<br />
<pre><br />
bin/generate_static ''archiveID''<br />
bin/generate_views ''archiveID''<br />
bin/generate_abstracts ''archiveID''<br />
</pre><br />
<br />
Every time you alter any of the <code>.xml</code> you need to reload the configuration:<br />
<pre><br />
bin/epadmin reload ''archiveID''<br />
</pre><br />
(though a proper web server restart is the best thing to do once you are happy with the configuration:<br />
<pre><br />
/path/to/web_server/bin/apachecfg restart<br />
</pre></div>Uis475