33import java .util .Locale ;
44
55import org .mycore .common .xml .MCRXMLFunctions ;
6- import org .mycore .common .xsl .MCRParameterCollector ;
76import org .mycore .frontend .MCRFrontendUtil ;
7+ import org .mycore .common .config .MCRConfiguration2 ;
88import org .mycore .viewer .configuration .MCRViewerConfiguration ;
99import org .mycore .viewer .configuration .MCRViewerDefaultConfigurationStrategy ;
1010
@@ -14,40 +14,40 @@ public class MIRViewerConfigurationStrategy extends MCRViewerDefaultConfiguratio
1414
1515 @ Override
1616 public MCRViewerConfiguration get (HttpServletRequest request ) {
17- MCRViewerConfiguration mcrViewerConfiguration = super .get (request );
17+ MCRViewerConfiguration configuration = super .get (request );
1818 String baseURL = MCRFrontendUtil .getBaseURL (request );
19- MCRParameterCollector params = new MCRParameterCollector (request );
2019
2120 if (!MCRXMLFunctions .isMobileDevice (request .getHeader ("User-Agent" ))) {
2221 // Default Stylesheet
23- String theme = params .getParameter ("MIR.Layout.Theme" , null );
24- String file = params .getParameter ("MIR.DefaultLayout.CSS" , null );
25- String mirBootstrapCSSURL = String .format (Locale .ROOT , "%srsc/sass/mir-layout/scss/%s-%s.css" , baseURL ,
26- theme , file );
27- mcrViewerConfiguration .addCSS (mirBootstrapCSSURL );
28-
29- // customLayout Stylesheet
30- String customLayout = params .getParameter ("MIR.CustomLayout.CSS" , "" );
31- if (customLayout .length () > 0 ) {
32- String customLayoutURL = String .format (Locale .ROOT , "%scss/%s" , baseURL , customLayout );
33- mcrViewerConfiguration .addCSS (customLayoutURL );
34- }
35-
36- String customJS = params .getParameter ("MIR.CustomLayout.JS" , "" );
37- if (customJS .length () > 0 ) {
38- mcrViewerConfiguration .addScript (String .format (Locale .ROOT , "%sjs/%s" , baseURL , customJS ), false );
39- }
22+ MCRConfiguration2 .getString ("MIR.Layout.Theme" ).ifPresent (theme ->
23+ MCRConfiguration2 .getString ("MIR.DefaultLayout.CSS" ).ifPresent (file -> {
24+ String defaultCssUrl = String .format (Locale .ROOT , "%srsc/sass/mir-layout/scss/%s-%s.css" ,
25+ baseURL , theme , file );
26+ configuration .addCSS (defaultCssUrl );
27+ }));
28+
29+ // custom Stylesheet
30+ MCRConfiguration2 .getString ("MIR.CustomLayout.CSS" ).ifPresent (customCss -> {
31+ String customCssUrl = String .format (Locale .ROOT , "%scss/%s" , baseURL , customCss );
32+ configuration .addCSS (customCssUrl );
33+ });
34+
35+ // custom Script
36+ MCRConfiguration2 .getString ("MIR.CustomLayout.JS" ).ifPresent (customJs -> {
37+ String customJsUrl = String .format (Locale .ROOT , "%sjs/%s" , baseURL , customJs );
38+ configuration .addScript (customJsUrl , false );
39+ });
4040
4141 if (request .getParameter ("embedded" ) != null ) {
42- mcrViewerConfiguration .setProperty ("permalink.updateHistory" , false );
43- mcrViewerConfiguration .setProperty ("chapter.showOnStart" , false );
42+ configuration .setProperty ("permalink.updateHistory" , false );
43+ configuration .setProperty ("chapter.showOnStart" , false );
4444 } else {
4545 // Default JS
46- mcrViewerConfiguration
47- .addScript (MCRFrontendUtil . getBaseURL () + "assets/bootstrap/js/bootstrap.min.js" , false );
46+ String defaultJsUrl = MCRFrontendUtil . getBaseURL () + "assets/bootstrap/js/bootstrap.min.js" ;
47+ configuration .addScript (defaultJsUrl , false );
4848 }
4949 }
5050
51- return mcrViewerConfiguration ;
51+ return configuration ;
5252 }
5353}
0 commit comments