diff --git a/.gitignore b/.gitignore index af40e5f2..123be1fd 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ nb-configuration.xml testdata.dump /boudicca.store /fetcher.cache + +out/ diff --git a/.run/BETA - OnlineHtmlPublisher.run.xml b/.run/BETA - OnlineHtmlPublisher.run.xml new file mode 100644 index 00000000..7e18d944 --- /dev/null +++ b/.run/BETA - OnlineHtmlPublisher.run.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/boudicca.base/publisher-event-html/README.md b/boudicca.base/publisher-event-html/README.md index 03249c68..1839f8ca 100644 --- a/boudicca.base/publisher-event-html/README.md +++ b/boudicca.base/publisher-event-html/README.md @@ -2,9 +2,9 @@ ## Start application -``` -gradlew bootRun or ./gradlew bootRun -``` +There is the new Launch config `BETA - OnlineHtmlPublisher` you can run/debug. +To reload the application after you made changes you can build the project via `Build -> Build Project` or pressing Ctrl+F9. +To make this rebuild and reload even faster you can change your settings in `Settings -> Build, Execution, Deployment -> Gradle -> Build and run using: ` to build with Intellij instead of Gradle. ## Stack diff --git a/boudicca.base/publisher-event-html/src/main/kotlin/base/boudicca/publisher/event/html/PublisherHtmlApplication.kt b/boudicca.base/publisher-event-html/src/main/kotlin/base/boudicca/publisher/event/html/PublisherHtmlApplication.kt index 5746c46e..6a7b93e2 100644 --- a/boudicca.base/publisher-event-html/src/main/kotlin/base/boudicca/publisher/event/html/PublisherHtmlApplication.kt +++ b/boudicca.base/publisher-event-html/src/main/kotlin/base/boudicca/publisher/event/html/PublisherHtmlApplication.kt @@ -3,8 +3,10 @@ package base.boudicca.publisher.event.html import base.boudicca.publisher.event.html.extension.HeaderExtensionValueResolver import base.boudicca.publisher.event.html.handlebars.HandlebarsViewResolver import com.github.jknack.handlebars.ValueResolver +import com.github.jknack.handlebars.cache.NullTemplateCache import com.github.jknack.handlebars.helper.ConditionalHelpers import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.runApplication import org.springframework.context.annotation.Bean import org.springframework.scheduling.annotation.EnableScheduling @@ -13,9 +15,13 @@ import org.springframework.web.servlet.ViewResolver @SpringBootApplication @EnableScheduling +@EnableConfigurationProperties(PublisherHtmlProperties::class) class PublisherHtmlApplication { @Bean - fun handlebarsViewResolver(headerExtensionValueResolver: HeaderExtensionValueResolver): ViewResolver { + fun handlebarsViewResolver( + headerExtensionValueResolver: HeaderExtensionValueResolver, + properties: PublisherHtmlProperties + ): ViewResolver { val viewResolver = HandlebarsViewResolver() for (helper in ConditionalHelpers.entries) { @@ -23,6 +29,11 @@ class PublisherHtmlApplication { } viewResolver.setPrefix("classpath:/templates") + + if (properties.localMode) { + viewResolver.setCacheFilter { _, _, _ -> false } + viewResolver.setTemplateCache(NullTemplateCache.INSTANCE) + } val valueResolvers = ValueResolver.defaultValueResolvers().union(listOf(headerExtensionValueResolver)) viewResolver.setValueResolvers(*valueResolvers.toTypedArray()) diff --git a/boudicca.base/publisher-event-html/src/main/kotlin/base/boudicca/publisher/event/html/PublisherHtmlProperties.kt b/boudicca.base/publisher-event-html/src/main/kotlin/base/boudicca/publisher/event/html/PublisherHtmlProperties.kt new file mode 100644 index 00000000..86053635 --- /dev/null +++ b/boudicca.base/publisher-event-html/src/main/kotlin/base/boudicca/publisher/event/html/PublisherHtmlProperties.kt @@ -0,0 +1,8 @@ +package base.boudicca.publisher.event.html + +import org.springframework.boot.context.properties.ConfigurationProperties + +@ConfigurationProperties(prefix = "boudicca") +data class PublisherHtmlProperties( + val localMode: Boolean = false, +) diff --git a/boudicca.base/publisher-event-html/src/main/resources/application.properties b/boudicca.base/publisher-event-html/src/main/resources/application.properties index 7436b99c..0e01958e 100644 --- a/boudicca.base/publisher-event-html/src/main/resources/application.properties +++ b/boudicca.base/publisher-event-html/src/main/resources/application.properties @@ -1,4 +1,5 @@ #logging.level.ROOT: DEBUG server.port=8080 boudicca.search.url=http://localhost:8082 -boudicca.search.additionalFilter= \ No newline at end of file +boudicca.search.additionalFilter= +spring.devtools.restart.exclude=static/**,templates/** \ No newline at end of file diff --git a/boudicca.base/search/src/main/kotlin/base/boudicca/search/BoudiccaSearchProperties.kt b/boudicca.base/search/src/main/kotlin/base/boudicca/search/BoudiccaSearchProperties.kt index a16c0dc5..a72cc611 100644 --- a/boudicca.base/search/src/main/kotlin/base/boudicca/search/BoudiccaSearchProperties.kt +++ b/boudicca.base/search/src/main/kotlin/base/boudicca/search/BoudiccaSearchProperties.kt @@ -4,7 +4,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties(prefix = "boudicca") data class BoudiccaSearchProperties( - val localMode: Boolean, + val localMode: Boolean = false, val eventDB: EventDBProperties, )