Search in sources :

Example 1 with ThemeDto

use of com.tale.dto.ThemeDto in project tale by otale.

the class ThemeController method index.

@Route(value = "", method = HttpMethod.GET)
public String index(Request request) {
    // 读取主题
    String themesDir = AttachController.CLASSPATH + "templates/themes";
    File[] themesFile = new File(themesDir).listFiles();
    List<ThemeDto> themes = new ArrayList<>(themesFile.length);
    for (File f : themesFile) {
        if (f.isDirectory()) {
            ThemeDto themeDto = new ThemeDto(f.getName());
            if (FileKit.exist(f.getPath() + "/setting.html")) {
                themeDto.setHasSetting(true);
            }
            themes.add(themeDto);
            try {
                Blade.$().embedServer().addStatic("/templates/themes/" + f.getName() + "/screenshot.png");
            } catch (Exception e) {
            }
        }
    }
    request.attribute("current_theme", Commons.site_theme());
    request.attribute("themes", themes);
    return "admin/themes";
}
Also used : ThemeDto(com.tale.dto.ThemeDto) ArrayList(java.util.ArrayList) File(java.io.File) TipException(com.tale.exception.TipException) Route(com.blade.mvc.annotation.Route)

Aggregations

Route (com.blade.mvc.annotation.Route)1 ThemeDto (com.tale.dto.ThemeDto)1 TipException (com.tale.exception.TipException)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1