use of com.publiccms.views.pojo.entities.CmsPlaceMetadata in project PublicCMS-preview by sanluan.
the class IncludePlaceDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
String path = handler.getString("path");
String[] paths = handler.getStringArray("paths");
if (CommonUtils.notEmpty(path)) {
SysSite site = getSite(handler);
CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + path));
if (site.isUseSsi()) {
handler.print(new StringBuilder("<!--#include virtual=\"/").append(TemplateComponent.INCLUDE_DIRECTORY).append(path).append("\"-->").toString());
} else {
templateComponent.printPlace(handler.getWriter(), site, path, metadata);
}
} else if (CommonUtils.notEmpty(paths)) {
SysSite site = getSite(handler);
Map<String, String> map = new ConcurrentHashMap<>();
if (site.isUseSsi()) {
for (String p : paths) {
map.put(p, new StringBuilder("<!--#include virtual=\"/").append(TemplateComponent.INCLUDE_DIRECTORY).append(p).append("\"-->").toString());
}
handler.put("map", map).render();
} else {
Set<String> set = new HashSet<>();
for (String p : paths) {
set.add(p);
}
for (String p : set) {
pool.execute(new RanderTask(p, set.size(), map, getSite(handler), handler));
}
handler.setRenderd();
}
}
}
use of com.publiccms.views.pojo.entities.CmsPlaceMetadata in project PublicCMS-preview by sanluan.
the class CmsTemplateAdminController method publishPlace.
/**
* @param path
* @param request
* @param session
* @param model
* @return view name
*/
@RequestMapping("publishPlace")
public String publishPlace(String path, HttpServletRequest request, HttpSession session, ModelMap model) {
try {
SysSite site = getSite(request);
if (CommonUtils.notEmpty(path) && site.isUseSsi()) {
CmsPlaceMetadata metadata = metadataComponent.getPlaceMetadata(siteComponent.getWebTemplateFilePath(site, TemplateComponent.INCLUDE_DIRECTORY + path));
templateComponent.staticPlace(site, path, metadata);
logOperateService.save(new LogOperate(site.getId(), getAdminFromSession(session).getId(), LogLoginService.CHANNEL_WEB_MANAGER, "static", RequestUtils.getIpAddress(request), CommonUtils.getDate(), path));
}
return TEMPLATE_DONE;
} catch (IOException | TemplateException e) {
model.addAttribute(ERROR, e.getMessage());
log.error(e.getMessage(), e);
return TEMPLATE_ERROR;
}
}
Aggregations