Skip to content

Commit

Permalink
Generated next theme from runtime scanning rather than hard coding
Browse files Browse the repository at this point in the history
  • Loading branch information
martinlau committed Jun 25, 2013
1 parent 96e5d6f commit ac37281
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<root>
<item name='org.springframework.core.io.Resource org.springframework.core.io.Resource createRelative(java.lang.String)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<item name="org.springframework.core.io.support.ResourcePatternResolver org.springframework.core.io.Resource[] getResources(java.lang.String)">
<annotation name="jet.runtime.typeinfo.KotlinSignature">
<val name="value" val="&quot;fun getResources(locationPattern: String): Array&lt;Resource&gt;&quot;" />
</annotation>
</item>
<item name="org.springframework.core.io.support.ResourcePatternUtils org.springframework.core.io.support.ResourcePatternResolver getResourcePatternResolver(org.springframework.core.io.ResourceLoader)">
<annotation name="org.jetbrains.annotations.NotNull" />
</item>
</root>

4 changes: 4 additions & 0 deletions fixture-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@ import javax.servlet.http.HttpServletResponse
import kotlin.dom.addClass
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter
import org.springframework.web.servlet.support.RequestContextUtils
import org.springframework.core.io.support.ResourcePatternUtils
import org.springframework.core.io.support.PathMatchingResourcePatternResolver
import java.util.Collections

public class NextThemeInterceptor: HandlerInterceptorAdapter() {

val themes: List<String> = arrayListOf(
"amelia",
"cerulean",
"cosmo",
"cyborg",
"default",
"journal",
"readable",
"shamrock",
"simplex",
"slate",
"spacelab",
"spruce",
"superhero",
"united"
)
val themes: List<String>

{
val resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(PathMatchingResourcePatternResolver())
val resources = resourcePatternResolver.getResources("classpath*:/META-INF/resources/webjars/bootswatch/2.3.1/**/bootstrap.min.css")
val unsorted: MutableList<String> = resources.mapTo(LinkedList()) { it.createRelative(".").getFilename()!! }

themes = unsorted.sort()
}

override fun preHandle(request: HttpServletRequest, response: HttpServletResponse, handler: Any): Boolean {

Expand Down

0 comments on commit ac37281

Please sign in to comment.