CcmNG: Some fixes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5695 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
c942050ca1
commit
3fce92753e
|
|
@ -228,7 +228,12 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
||||||
final String path) {
|
final String path) {
|
||||||
|
|
||||||
final String themePath = createThemePath(theme, version);
|
final String themePath = createThemePath(theme, version);
|
||||||
final String filePath = String.join("/", themePath, path);
|
final String filePath;
|
||||||
|
if ("/".equals(path)) {
|
||||||
|
filePath = String.join("", themePath, path);
|
||||||
|
} else {
|
||||||
|
filePath = String.join("/", themePath, path);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (ccmFiles.isDirectory(filePath)) {
|
if (ccmFiles.isDirectory(filePath)) {
|
||||||
|
|
@ -236,11 +241,13 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
||||||
.listFiles(filePath)
|
.listFiles(filePath)
|
||||||
.stream()
|
.stream()
|
||||||
.map(currentPath -> buildThemeFileInfo(
|
.map(currentPath -> buildThemeFileInfo(
|
||||||
String.join("/", theme, currentPath)))
|
themePath,
|
||||||
|
String.join("/", path, currentPath)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
final List<ThemeFileInfo> result = new ArrayList<>();
|
final List<ThemeFileInfo> result = new ArrayList<>();
|
||||||
final ThemeFileInfo fileInfo = buildThemeFileInfo(filePath);
|
final ThemeFileInfo fileInfo = buildThemeFileInfo(
|
||||||
|
themePath, path);
|
||||||
result.add(fileInfo);
|
result.add(fileInfo);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -264,7 +271,7 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
||||||
try {
|
try {
|
||||||
if (ccmFiles.existsFile(filePath)) {
|
if (ccmFiles.existsFile(filePath)) {
|
||||||
|
|
||||||
return Optional.of(buildThemeFileInfo(filePath));
|
return Optional.of(buildThemeFileInfo(themePath, path));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
@ -445,14 +452,30 @@ public class FileSystemThemeProvider implements ThemeProvider {
|
||||||
return Optional.of(themeInfo);
|
return Optional.of(themeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThemeFileInfo buildThemeFileInfo(final String filePath) {
|
private ThemeFileInfo buildThemeFileInfo(final String themePath,
|
||||||
|
final String filePath) {
|
||||||
|
|
||||||
|
final String path;
|
||||||
|
if (themePath.endsWith("/")
|
||||||
|
|| filePath.startsWith("/")) {
|
||||||
|
path = String.join("", themePath, filePath);
|
||||||
|
} else {
|
||||||
|
path= String.join("/", themePath, filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
if (path.startsWith(("/"))) {
|
||||||
|
name = path;
|
||||||
|
} else {
|
||||||
|
name = String.format("/%s", path);
|
||||||
|
}
|
||||||
|
|
||||||
final ThemeFileInfo fileInfo = new ThemeFileInfo();
|
final ThemeFileInfo fileInfo = new ThemeFileInfo();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fileInfo.setDirectory(ccmFiles.isDirectory(filePath));
|
fileInfo.setDirectory(ccmFiles.isDirectory(path));
|
||||||
fileInfo.setMimeType(ccmFiles.getMimeType(filePath));
|
fileInfo.setMimeType(ccmFiles.getMimeType(path));
|
||||||
fileInfo.setName(filePath);
|
fileInfo.setName(name);
|
||||||
fileInfo.setWritable(true);
|
fileInfo.setWritable(true);
|
||||||
|
|
||||||
return fileInfo;
|
return fileInfo;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue