Presentation of my user interface prototype (#1) using Spring Boot + Thymeleaf for the DSpace UI Prototype Challenge:
https://wiki.duraspace.org/display/DSPACE/DSpace+UI+Prototype+Challenge
NOTE: As this was just a prototype/proof-of-concept there are NO GUARANTEES that this work will become a new User interface.
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
1. Licensed under Creative Commons Attribution-ShareAlike 4.0 International License
UI Prototype
Spring Boot + Thymeleaf
Tim Donohue, DuraSpace
tdonohue@duraspace.org
2. Technologies used
• Spring Boot
– Newer, but built on Spring MVC
• See Cineca’s prototype for MVC overview
– Convention over configuration
• Prepackaged Maven / Gradle plugins
– Embeddable Tomcat/Jetty (in JAR)
– Autoconfiguration of Spring
• No requirement for XML configs
– Autoconfiguration of many templating
engines (Thymeleaf being one)
3. Technologies used
• Thymeleaf
– Java/HTML5 templating engine
– Looks like HTML (mostly)
– Natural templating (view static HTML)
– Supports HTML “fragments”
– FORCES separating content from layout
– Spring specific integrations
• Bootstrap
4. Technologies used
• DSpace 6 (pre-6) Java API
– With Enhanced Configuration Scheme
(local.cfg / Apache Commons Config)
• Provides auto-reloadable configs
• Spring Security (AutnN/Z)
– Used test “in memory” authN
– AuthZ lets you limit access via Path
– Very easy to use with Spring Boot
5. Spring Boot
• Configured to build a runnable JAR
(embedded Tomcat)
• Enabled Thymeleaf plugin
• Enabled Spring Security plugin
• Spring Boot Application configuration
– Application class
– application.properties
6. Thymeleaf
• Looks like HTML, with “th:” attributes
– th:fragment => th:include, th:replace
– th:text (replace text)
– th:if / th:unless
– th:each (loop Lists/Iterable/Map/array)
– th:with (sets a local variable)
– th:href (dynamically build links)
7. Thymeleaf
• Looks like HTML, with “th:” attributes
– th:fragment => th:include, th:replace
– th:text (replace text / adds i18n)
– th:if / th:unless
– th:each (loop Lists/Iterable/Map/array)
– th:with (sets a local variable)
– th:href (dynamically build links)
• (Very) basic Java calls supported
8. Thymeleaf
• Also some special expressions /
syntax:
– ${variable} => output value of variable
– #{i18n.key} => output i18n msg
– @{path} => output a link/URL
• And Java utility objects:
– #lists.isEmpty(java.util.List)
– #arrays
– #dates (formatting java.util.Date objs)
9. Prototype Theming
• Basic at this point
– /static/themes directory
– Themes consist of a layout.html and
CSS, images, JS
• Custom code in DSpaceController
– Allows one to customize theme loaded
based on paths (in local.cfg)
10. Theming with Thymeleaf
• layout.html
– Contains all our theme “fragments”
– (could split these into separate files,
e.g. header.html, footer.hml)
• Thymeleaf can select fragments
– by name
– by DOM selects (e.g. #id selects an
HTML tag by ‘id’)
11. AuthN/AuthZ
• Spring Security
– Not yet integrated with DSpace’s Auth
• AuthN is using Spring Security’s “test
mode” (in memory auth)
• AuthN/Z Defined entirely in
WebSecurityConfig
• Only one restricted path (/admin)
13. Prototype code / docs
• https://github.com/tdonohue/DSpac
e-Spring-Boot
– See README for documentation
14. Limits of Prototype
• No actual item editing/creation
– Concentrated more on testing
Thymeleaf extendability
• Spring Security AuthN/Z not
integrated with DSpace’s