Add theme reloading api

pull/146/head
johnniang 2019-04-30 18:01:36 +08:00
parent 6fcf1a6952
commit b3ca63b528
3 changed files with 16 additions and 1 deletions

View File

@ -135,4 +135,10 @@ public class ThemeController {
public ThemeProperty fetchTheme(@RequestParam("uri") String uri) { public ThemeProperty fetchTheme(@RequestParam("uri") String uri) {
return themeService.fetch(uri); return themeService.fetch(uri);
} }
@PostMapping("reload")
@ApiOperation("Reloads themes")
public void reload() {
themeService.reload();
}
} }

View File

@ -6,7 +6,6 @@ import run.halo.app.handler.theme.config.support.Group;
import run.halo.app.handler.theme.config.support.ThemeProperty; import run.halo.app.handler.theme.config.support.ThemeProperty;
import run.halo.app.model.support.ThemeFile; import run.halo.app.model.support.ThemeFile;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
@ -233,4 +232,9 @@ public interface ThemeService {
*/ */
@NonNull @NonNull
ThemeProperty fetch(@NonNull String uri); ThemeProperty fetch(@NonNull String uri);
/**
* Reloads themes
*/
void reload();
} }

View File

@ -433,6 +433,11 @@ public class ThemeServiceImpl implements ThemeService {
} }
} }
@Override
public void reload() {
eventPublisher.publishEvent(new ThemeUpdatedEvent(this));
}
/** /**
* Clones theme from git. * Clones theme from git.
* *