|
27 | 27 | import org.springframework.context.annotation.Configuration;
|
28 | 28 | import org.springframework.core.env.Environment;
|
29 | 29 | import org.thymeleaf.spring4.view.ThymeleafViewResolver;
|
30 |
| -import ru.mystamps.web.Url; |
| 30 | +import ru.mystamps.web.feature.account.AccountUrl; |
| 31 | +import ru.mystamps.web.feature.category.CategoryUrl; |
| 32 | +import ru.mystamps.web.feature.collection.CollectionUrl; |
| 33 | +import ru.mystamps.web.feature.country.CountryUrl; |
| 34 | +import ru.mystamps.web.feature.image.ImageUrl; |
| 35 | +import ru.mystamps.web.feature.participant.ParticipantUrl; |
| 36 | +import ru.mystamps.web.feature.report.ReportUrl; |
| 37 | +import ru.mystamps.web.feature.series.SeriesUrl; |
| 38 | +import ru.mystamps.web.feature.series.importing.SeriesImportUrl; |
| 39 | +import ru.mystamps.web.feature.series.importing.sale.SeriesSalesImportUrl; |
| 40 | +import ru.mystamps.web.feature.site.ResourceUrl; |
| 41 | +import ru.mystamps.web.feature.site.SiteUrl; |
| 42 | + |
| 43 | +import java.util.HashMap; |
| 44 | +import java.util.Map; |
31 | 45 |
|
32 | 46 | /**
|
33 | 47 | * Adjusts {@link ThymeleafViewResolver} instance by setting static variables.
|
@@ -59,7 +73,34 @@ public void afterPropertiesSet() throws Exception {
|
59 | 73 | }
|
60 | 74 |
|
61 | 75 | boolean productionEnv = environment.acceptsProfiles("prod");
|
62 |
| - viewResolver.setStaticVariables(Url.asMap(productionEnv)); |
| 76 | + viewResolver.setStaticVariables(resourcesAsMap(productionEnv)); |
| 77 | + } |
| 78 | + |
| 79 | + // Not all URLs are exported here but only those that are being used on views |
| 80 | + private Map<String, ?> resourcesAsMap(boolean production) { |
| 81 | + Map<String, String> map = new HashMap<>(); |
| 82 | + |
| 83 | + map.put("PUBLIC_URL", production ? SiteUrl.PUBLIC_URL : SiteUrl.SITE); |
| 84 | + |
| 85 | + AccountUrl.exposeUrlsToView(map); |
| 86 | + CategoryUrl.exposeUrlsToView(map); |
| 87 | + CountryUrl.exposeUrlsToView(map); |
| 88 | + CollectionUrl.exposeUrlsToView(map); |
| 89 | + ParticipantUrl.exposeUrlsToView(map); |
| 90 | + ReportUrl.exposeUrlsToView(map); |
| 91 | + ResourceUrl.exposeUrlsToView(map); |
| 92 | + SeriesUrl.exposeUrlsToView(map); |
| 93 | + SeriesImportUrl.exposeUrlsToView(map); |
| 94 | + SeriesSalesImportUrl.exposeUrlsToView(map); |
| 95 | + SiteUrl.exposeUrlsToView(map); |
| 96 | + |
| 97 | + String resourcesHost = production ? ResourceUrl.STATIC_RESOURCES_URL : null; |
| 98 | + ImageUrl.exposeResourcesToView(map, resourcesHost); |
| 99 | + ResourceUrl.exposeResourcesToView(map, resourcesHost); |
| 100 | + |
| 101 | + ResourceUrl.exposeWebjarResourcesToView(map, production); |
| 102 | + |
| 103 | + return map; |
63 | 104 | }
|
64 | 105 |
|
65 | 106 | }
|
0 commit comments