DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
-
Upload
tim-donohue -
Category
Software
-
view
621 -
download
4
Transcript of DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
Licensed under Creative Commons Attribution-ShareAlike 4.0 International License
UI PrototypeSpring Boot + Thymeleaf
Tim Donohue, [email protected]
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)
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
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
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
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)
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
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)
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)
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’)
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)
Demo
Prototype code / docs• https://github.com/tdonohue/DSpace-
Spring-Boot– See README for documentation
Limits of Prototype• No actual item editing/creation
– Concentrated more on testing Thymeleaf extendability
• Spring Security AuthN/Z not integrated with DSpace’s