Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:user:interfaces [2018/07/31 13:29]
kjdon [Additional Resources]
en:user:interfaces [2019/09/23 12:02] (current)
kjdon [How to change just one template]
Line 11: Line 11:
 add a new language translation of an interface. add a new language translation of an interface.
  
-==== Modifying an existing interface====+===== Modifying an existing interface=====
 Most of an interface is defined by XSLT files, which are stored in ''​$GSDL3HOME/​ Most of an interface is defined by XSLT files, which are stored in ''​$GSDL3HOME/​
 interfaces/<​interface-name>/​transform''​. These can be changed and the changes interfaces/<​interface-name>/​transform''​. These can be changed and the changes
Line 43: Line 43:
 can be useful when you are trying to write some new XSLT statements. can be useful when you are trying to write some new XSLT statements.
  
-==== Creating a new interface====+==== How to change just one template ==== 
 + 
 +You might like to make changes to the interface, but restrict them to a subset of the library. There are different ways to change a template. 
 +For example, suppose we wanted to change what gets displayed on the about page for the collection description. If we look at the transform/​pages/​about.xsl,​ we find some templates:​ 
 +<​code>​ 
 +<​xsl:​template match="/​page">​ 
 +.... 
 +   <​xsl:​call-template name="​coll-description"/>​ 
 +</​xsl:​template>​ 
 + 
 +<​xsl:​template name="​coll-description">​ 
 +  <​gslib:​collectionDescriptionTextAndServicesLinks/>​ 
 +</​xsl:​template>​ 
 +</​code>​ 
 + 
 +We might decide that we don't want the default behaviour for the coll-description template and we want to change it. 
 + 
 +    - Edit the XSL file in web/​interfaces/​default/​transform - if we edit the template directly in the main pages/​about.xsl file, then the change will apply to all collections in our library. 
 +    - Edit the XSL file in web/​sites/<​sitename>/​transform - if we have multiple sites, we can make a new pages/​about.xsl in the site's transform folder, and it will apply to only those collections in that site. 
 +    - Edit the XSL in web/​collect/<​collname>/​transform - we can make a new pages/​about.xsl file in the collection'​s transform folder. Any changes we make here will only affect this collection. 
 + 
 +The new about.xsl file doesn'​t have to implement everything in the old version. You can add in only the templates that you want to change. 
 + 
 +For example, this might be the collection'​s about.xsl. We are only changing 1 template. The rest of the about page templates will come from the defualt XSL file: web/​interfaces/​default/​transform/​pages/​about.xsl,​ 
 +<​code>​ 
 +<?xml version="​1.0"​ encoding="​ISO-8859-1"?>​ 
 +<​xsl:​stylesheet version="​1.0"​ 
 + xmlns:​xsl="​http://​www.w3.org/​1999/​XSL/​Transform"​ 
 + xmlns:​java="​http://​xml.apache.org/​xslt/​java"​ 
 + xmlns:​util="​xalan://​org.greenstone.gsdl3.util.XSLTUtil"​ 
 + xmlns:​gslib="​http://​www.greenstone.org/​skinning"​ 
 + extension-element-prefixes="​java util"​ 
 + exclude-result-prefixes="​java util">​ 
 + 
 + 
 + ​ <​xsl:​template name="​coll-description">​ 
 +    <​xsl:​value-of select="/​page/​pageResponse/​collection/​displayItemList/​ 
 +displayItem[@name='​description'​]"​ disable-output-escaping="​yes"/>​ 
 +   <​h4>​This collection has <​xsl:​value-of select="/​page/​pageResponse/​collection/​ 
 +metadataList/​metadata[@name='​numDocs'​]"/>​ docs.</​h4>​ 
 + </​xsl:​template>​ 
 + 
 +</​xsl:​stylesheet>​ 
 +</​code>​ 
 + 
 +==== Changing the interface language==== 
 +The interface language can be changed by going to the preferences page, and 
 +choosing a language from the list, which includes all languages into which the 
 +interface has been translated. 
 + 
 +It is easy to add a new interface language to Greenstone. Language specific 
 +text strings are separated out from the rest of the system to allow for easy incorporation of new languages. These text strings are contained in Java resource bundle 
 +properties files. These are plain text files consisting of key-value pairs, located in 
 +''​$GSDL3HOME/​WEB-INF/​classes''​. Each interface has one named ''​interface_name.properties''​ 
 +(where '​name'​ is the interface name, for example, ''​interface_default.properties'',​ 
 +or ''​interface_classic.properties''​). Each service class has one with the same 
 +name as the class (e.g. ''​GS2Search.properties''​). To add another language all of 
 +the base .properties files must be translated. The translated files keep the same 
 +names, but with a language extension added. For example, a French version of 
 +''​interface_default.properties''​ would be named ''​interface_default_fr.properties''​. 
 +Keys will be looked up in the properties file closest to the specified language. 
 +For example, if language ''​fr_CA''​ was specified (French language, country Canada), 
 +and the default locale was ''​en_GB'',​ Java would look at properties files in the following order,  
 +until it found the key: ''​XXX_fr_CA.properties'',​ ''​XXX_fr.properties'',​ 
 +''​XXX_en_GB.properties'',​ then ''​XXX_en.properties'',​ and finally the default ''​XXX.properties''​. 
 + 
 +These new files are available straight away. To use the new language, add e.g. 
 +''​l=fr''​ to the arguments in the URL. To get Greenstone to add it in to the list of 
 +languages on the preferences page, an entry needs to be added into the languages 
 +list in the ''​interfaceConfig.xml''​ file. Modification of this file 
 +requires a restart of the Tomcat server for the changes to be recognized. 
 + 
 + 
 +===== Creating a new interface=====
 {{ :​en:​exampleinterface.png?​direct&​400|}} {{ :​en:​exampleinterface.png?​direct&​400|}}
 Instead of modifying an existing interface, you can also create a new interface. Creating Instead of modifying an existing interface, you can also create a new interface. Creating
Line 75: Line 148:
 </​code>​ </​code>​
  
-===== Interface configuration file =====+==== Interface configuration file ====
  
 The interface configuration file ''​interfaceConfig.xml''​ lists all the actions that the interface knows about at the start (other ones can be loaded dynamically). **Actions** create the web pages for the library: there is generally one Action per type of page. For example, a query action produces the pages for searching, while a document action displays the documents. The configuration file specifies what short name each action maps to (this is used in library URLs for the //a//, i.e. action, parameter) e.g. QueryAction should use ''​a=q''​. If the interface uses XSLT, it specifies what XSLT file should be used for each action and possibly each subaction. This makes it easy for developers to implement and use different actions and/or XSLT files without recompilation. The server must be restarted, however. The interface configuration file ''​interfaceConfig.xml''​ lists all the actions that the interface knows about at the start (other ones can be loaded dynamically). **Actions** create the web pages for the library: there is generally one Action per type of page. For example, a query action produces the pages for searching, while a document action displays the documents. The configuration file specifies what short name each action maps to (this is used in library URLs for the //a//, i.e. action, parameter) e.g. QueryAction should use ''​a=q''​. If the interface uses XSLT, it specifies what XSLT file should be used for each action and possibly each subaction. This makes it easy for developers to implement and use different actions and/or XSLT files without recompilation. The server must be restarted, however.
Line 85: Line 158:
   * **berryBaskets**:​ Whether berry basket functionality is available or not   * **berryBaskets**:​ Whether berry basket functionality is available or not
   * **displayAnnotationService**:​ Whether any annotation services (specified in the site config file) should be displayed with a document or not.   * **displayAnnotationService**:​ Whether any annotation services (specified in the site config file) should be displayed with a document or not.
-===== Using new interface ​=====+==== Using the new interface ====
  
 To use a new interface, the ''​$GSDL3HOME/​WEB-INF/​web.xml''​ file must be edited: To use a new interface, the ''​$GSDL3HOME/​WEB-INF/​web.xml''​ file must be edited:
Line 130: Line 203:
  
  The Tomcat server must be restarted for this to take effect.  The Tomcat server must be restarted for this to take effect.
- 
-==== Changing the interface language==== 
-The interface language can be changed by going to the preferences page, and 
-choosing a language from the list, which includes all languages into which the 
-interface has been translated. 
- 
-It is easy to add a new interface language to Greenstone. Language specific 
-text strings are separated out from the rest of the system to allow for easy incorporation of new languages. These text strings are contained in Java resource bundle 
-properties files. These are plain text files consisting of key-value pairs, located in 
-''​$GSDL3HOME/​WEB-INF/​classes''​. Each interface has one named ''​interface_name.properties''​ 
-(where '​name'​ is the interface name, for example, ''​interface_default.properties'',​ 
-or ''​interface_classic.properties''​). Each service class has one with the same 
-name as the class (e.g. ''​GS2Search.properties''​). To add another language all of 
-the base .properties files must be translated. The translated files keep the same 
-names, but with a language extension added. For example, a French version of 
-''​interface_default.properties''​ would be named ''​interface_default_fr.properties''​. 
-Keys will be looked up in the properties file closest to the specified language. 
-For example, if language ''​fr_CA''​ was specified (French language, country Canada), 
-and the default locale was ''​en_GB'',​ Java would look at properties files in the following order, ​ 
-until it found the key: ''​XXX_fr_CA.properties'',​ ''​XXX_fr.properties'',​ 
-''​XXX_en_GB.properties'',​ then ''​XXX_en.properties'',​ and finally the default ''​XXX.properties''​. 
- 
-These new files are available straight away —to use the new language, add e.g. 
-''​l=fr''​ to the arguments in the URL. To get Greenstone to add it in to the list of 
-languages on the preferences page, an entry needs to be added into the languages 
-list in the ''​interfaceConfig.xml''​ file. Modification of this file 
-requires a restart of the Tomcat server for the changes to be recognized.