*1、Create external folder*
Create an external folder [/home/fanhl/01-java/cas/cas-templates/src] and
put templates, CSS, JS and IMGs here. In this way, you can change the user
interface without restarting the service
----------------
└── src
├── static
│ └── wukong
│ ├── css
│ ├── favicon.ico
│ ├── images
│ ├── js
│ └── yn.jpg
├── templates
│ └── themes
│ └── wukong
│ └── login
│ └── casLoginView.html
└── wukong.properties
---------------
*2、edit cas-overlay project*
*2.1 Configure service*
create resources/services/web-10000001.json
------------
{ "@class" : "org.apereo.cas.services.RegexRegisteredService", "serviceId"
: "^(https|imaps|http)://.*", "name" : "web", "id" : 10000001,
"evaluationOrder" : 10, "accessStrategy" : { "@class" :
"org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy", "enabled"
: true, "ssoEnabled" : true }, "theme": "wukong" }
------------
*2.2 reference external template, css, imgs*
edit application.yml
----------------
cas: service-registry: json: location: classpath:/services watcher-enabled:
true authn: accept: users: user::aaa view: template-prefixes: -
file:/home/fanhl/01-java/cas/cas-templates/src/templates/ spring:
thymeleaf: cache: false web: resources: static-locations: -
classpath:/static/ - file:/home/fanhl/01-java/cas/cas-templates/src/static/
----------------
*2.3 create wukong.properties*
--------
*cas.standard.css.file=/css/cas.css*
--------
If this file is not configured or empty, the new style cannot be displayed.
*3、debug template*
*3.1、run cas*
./gradlew run
*3.2 modify casLoginView.html*
*3.3 look result*
*4、Optimization suggestions*
I think there is a bug here. a mistake in the directory rules of template
and theme
CasThymeleafConfiguration.java
theme.setPrefix(viewPath + "themes/%s/"); => theme.setPrefix(viewPath +
"%s/");
-----------
val templatePrefixes = casProperties.getView().getTemplatePrefixes();
templatePrefixes.forEach(prefix -> {
try {
val prefixPath =
ResourceUtils.getFile(prefix).getCanonicalPath();
val viewPath = StringUtils.appendIfMissing(prefixPath, "/");
val theme =
prefix.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)
? new
ThemeClassLoaderTemplateResolver(themeResolver.getObject())
: new ThemeFileTemplateResolver(casProperties,
themeResolver.getObject());
configureTemplateViewResolver(theme);
theme.setPrefix(viewPath + "themes/%s/");
chain.addResolver(theme);
val template =
prefix.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX)
? new ClassLoaderTemplateResolver()
: new FileTemplateResolver();
configureTemplateViewResolver(template);
template.setPrefix(viewPath);
chain.addResolver(template);
} catch (final Exception e) {
LoggingUtils.warn(LOGGER, String.format("Could not add
template prefix '%s' to resolver", prefix), e);
}
});
------------
--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/a/apereo.org/d/msgid/cas-user/a0117d6b-3608-464f-8f1d-817d85029522n%40apereo.org.