mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-12 11:17:58 +00:00
changed context handling for command models for logging
added method to convert the user initiated context to a concrete command model added method to find if a template exists added method to render a context aware model added banid command
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package dev.sheldan.abstracto.templating.loading;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.ContextAware;
|
||||
import dev.sheldan.abstracto.core.models.ServerContext;
|
||||
import dev.sheldan.abstracto.templating.TemplateDto;
|
||||
import dev.sheldan.abstracto.templating.TemplateService;
|
||||
import freemarker.template.Configuration;
|
||||
@@ -30,6 +32,11 @@ public class TemplateServiceBean implements TemplateService {
|
||||
return repository.getOne(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean templateExists(String key) {
|
||||
return getTemplateByKey(key) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String renderTemplate(TemplateDto templateDto) {
|
||||
return null;
|
||||
@@ -55,6 +62,18 @@ public class TemplateServiceBean implements TemplateService {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String renderContextAwareTemplate(String key, ServerContext serverContext) {
|
||||
return renderTemplate(getTemplateKey(key, serverContext), serverContext);
|
||||
}
|
||||
|
||||
private String getTemplateKey(String key, ContextAware contextAware) {
|
||||
if(!contextAware.getTemplateSuffix().equals("")) {
|
||||
return key + "_" + contextAware.getTemplateSuffix();
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createTemplate(String key, String content) {
|
||||
repository.save(TemplateDto.builder().key(key).content(content).lastModified(Instant.now()).build());
|
||||
|
||||
Reference in New Issue
Block a user