From 2a288c876db4b6cd29c386b57eca18a5aee824d2 Mon Sep 17 00:00:00 2001 From: Uwe Kubosch Date: Fri, 27 Jan 2023 12:42:23 +0100 Subject: [PATCH] Use application message source --- README.md | 7 ++++++- build.gradle | 2 +- src/main/resources/ruby/controller_utils.rb | 12 ------------ src/main/resources/ruby/slim_helper.rb | 8 ++++++-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index e5a90c5..8faec7b 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,9 @@ https://github.com/DatekWireless/slim-spring-webmvc * https://s01.oss.sonatype.org/ * https://s01.oss.sonatype.org/content/repositories/releases/no/datek/ * https://search.maven.org/ -* https://search.maven.org/search?q=slim-spring-webmvc \ No newline at end of file +* https://search.maven.org/search?q=slim-spring-webmvc + +## Release to Maven Central + +* Bump the version in build.gradle +* \ No newline at end of file diff --git a/build.gradle b/build.gradle index 66493a9..6b16631 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group 'no.datek' -version '0.0.9' +version '0.1.0' java { withJavadocJar() diff --git a/src/main/resources/ruby/controller_utils.rb b/src/main/resources/ruby/controller_utils.rb index b22778f..3050664 100644 --- a/src/main/resources/ruby/controller_utils.rb +++ b/src/main/resources/ruby/controller_utils.rb @@ -6,16 +6,4 @@ def current_locale(request) end locale end - - @@message_source = Java::org.springframework.context.support::ReloadableResourceBundleMessageSource.new - @@message_source.setCacheSeconds(300) - @@message_source.setBasenames("classpath:lights_version", "classpath:lightsMessages") - - def message_source - @@message_source - end - - def message_source_accessor(locale) - MessageSourceAccessor.new(message_source, locale) - end end diff --git a/src/main/resources/ruby/slim_helper.rb b/src/main/resources/ruby/slim_helper.rb index 01ab84c..6c228c7 100644 --- a/src/main/resources/ruby/slim_helper.rb +++ b/src/main/resources/ruby/slim_helper.rb @@ -60,16 +60,20 @@ def params.[](key) super(key.to_s) end + application_context = rendering_context.application_context + message_source = application_context.get_bean(org.springframework.context.MessageSource.java_class) + message_source_accessor = MessageSourceAccessor.new(message_source, locale) + default_context = { _csrf: request.getAttribute('_csrf'), - application_context: rendering_context.application_context, + application_context: application_context, content_store: {}, ctx: request.contextPath, current_location: request.getSession().getAttribute("currentLocation"), currentLocation: request.getSession().getAttribute("currentLocation"), current_user: SecurityContextHolder.context&.authentication&.principal, locale: locale, - message: message_source_accessor(locale), + message: message_source_accessor, messages: message_source, messageSource: message_source, message_source: message_source,