Skip to content

SpringUI

lyncodev edited this page Dec 19, 2012 · 6 revisions

SpringUI Developer Documentation

Note: In order to understand the SpringUI development, it is required some good understanding of:

Structure

SpringUI is developed within DSpace source structure. It's a new module (named dspace-springui), with the following structure:

dspace-springui/src/main
   |- java/ (java code)
   |- webapp/ (html templates, i18n messages & web resources)

Spring MVC

SpringUI is being developed with Spring MVC library, the location of each piece:

  • M (java/) package org.dspace.orm - Hibernate 4
  • V (webapp/) WEB-INF/views - Jtwig
  • C (java/) package org.dspace.springui.controllers

Jtwig

Jtwig is a templating engine based on Twig which makes html templating easy.

It's possible to use the Twig manual to understand the syntax of jtwig, as they are almost the same. However, there are some differences.

The Jtwig Invoker

An invoker is a Java method invoked from the view. So, instead of fulfilling the ModelMap on each controller action, it's possible to call a method that would fulfill it. Let's look for the following example.

Imagine we want to add a welcome message to the main layout. We do not need to fill the ModelMap every time, we just need to use an invoker

{% call UserRelated getUserInfo  %}
{% if user.isGuest %}
Hi Guest!
{% else %}
Hi {{ user.name }}!
{% endif %}

Basically, the invoker will add information to the current ModelMap. Invokers are located at package org.dspace.springui.invokers

Themes

Jtwig supports themes within DSpace and to change the current theme one only needs to change dspace/config/modules/springui.cfg

The HTML templates should be located in the dspace-springui/src/main/webapp/WEB-INF/views/<theme_name>/ directory.

Assets

Jtwig could manage themed assets. Currently all assets (web resources) are located in the dspace-springui/src/main/webapp/public/default directory.

To refer them one do not need to specify the default path as it is related with the current theme, one could use the asset function. For instance:

Imagine you want to link the bootstrap.min.css resource, one just needs to use the asset function

<link href="{{ asset 'css/bootstrap.min.css' }}" rel="stylesheet"media="screen">

The path would then be translated to public/default/css/bootstrap.min.css.

Clone this wiki locally