|
|
@@ -1,4 +1,7 @@
|
|
|
-const logger = require('@alias/logger')('growi:service:CustomizeService'); // eslint-disable-line no-unused-vars
|
|
|
+// eslint-disable-next-line no-unused-vars
|
|
|
+const logger = require('@alias/logger')('growi:service:CustomizeService');
|
|
|
+
|
|
|
+const DevidedPagePath = require('@commons/models/devided-page-path');
|
|
|
|
|
|
/**
|
|
|
* the service class of CustomizeService
|
|
|
@@ -35,17 +38,32 @@ class CustomizeService {
|
|
|
let configValue = this.configManager.getConfig('crowi', 'customize:title');
|
|
|
|
|
|
if (configValue == null || configValue.trim().length === 0) {
|
|
|
- configValue = '{{page}} - {{sitename}}';
|
|
|
+ configValue = '{{pagename}} - {{sitename}}';
|
|
|
}
|
|
|
|
|
|
this.customTitleTemplate = configValue;
|
|
|
}
|
|
|
|
|
|
- generateCustomTitle(page) {
|
|
|
+ generateCustomTitle(pageOrPath) {
|
|
|
+ const path = pageOrPath.path || pageOrPath;
|
|
|
+ const dPagePath = new DevidedPagePath(path, true, true);
|
|
|
+
|
|
|
+ const customTitle = this.customTitleTemplate
|
|
|
+ .replace('{{sitename}}', this.appService.getAppTitle())
|
|
|
+ .replace('{{pagepath}}', path)
|
|
|
+ .replace('{{page}}', dPagePath.latter) // for backward compatibility
|
|
|
+ .replace('{{pagename}}', dPagePath.latter);
|
|
|
+
|
|
|
+ return this.xssService.process(customTitle);
|
|
|
+ }
|
|
|
+
|
|
|
+ generateCustomTitleForFixedPageName(title) {
|
|
|
// replace
|
|
|
const customTitle = this.customTitleTemplate
|
|
|
.replace('{{sitename}}', this.appService.getAppTitle())
|
|
|
- .replace('{{page}}', page);
|
|
|
+ .replace('{{page}}', title)
|
|
|
+ .replace('{{pagepath}}', title)
|
|
|
+ .replace('{{pagename}}', title);
|
|
|
|
|
|
return this.xssService.process(customTitle);
|
|
|
}
|