use of org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer in project symphony by b3log.
the class AdminProcessor method showDomain.
/**
* Shows a domain.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @param domainId the specified domain id
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/domain/{domainId}", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showDomain(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response, final String domainId) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/domain.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final JSONObject domain = domainQueryService.getDomain(domainId);
dataModel.put(Domain.DOMAIN, domain);
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
use of org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer in project symphony by b3log.
the class AdminProcessor method showArticles.
/**
* Shows admin articles.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/articles", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showArticles(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/articles.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
String pageNumStr = request.getParameter("p");
if (Strings.isEmptyOrNull(pageNumStr) || !Strings.isNumeric(pageNumStr)) {
pageNumStr = "1";
}
final int pageNum = Integer.valueOf(pageNumStr);
final int pageSize = PAGE_SIZE;
final int windowSize = WINDOW_SIZE;
final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, pageNum);
requestJSONObject.put(Pagination.PAGINATION_PAGE_SIZE, pageSize);
requestJSONObject.put(Pagination.PAGINATION_WINDOW_SIZE, windowSize);
final String articleId = request.getParameter("id");
if (!Strings.isEmptyOrNull(articleId)) {
requestJSONObject.put(Keys.OBJECT_ID, articleId);
}
final Map<String, Class<?>> articleFields = new HashMap<>();
articleFields.put(Keys.OBJECT_ID, String.class);
articleFields.put(Article.ARTICLE_TITLE, String.class);
articleFields.put(Article.ARTICLE_PERMALINK, String.class);
articleFields.put(Article.ARTICLE_CREATE_TIME, Long.class);
articleFields.put(Article.ARTICLE_VIEW_CNT, Integer.class);
articleFields.put(Article.ARTICLE_COMMENT_CNT, Integer.class);
articleFields.put(Article.ARTICLE_AUTHOR_ID, String.class);
articleFields.put(Article.ARTICLE_TAGS, String.class);
articleFields.put(Article.ARTICLE_STATUS, Integer.class);
articleFields.put(Article.ARTICLE_STICK, Long.class);
final int avatarViewMode = (int) request.getAttribute(UserExt.USER_AVATAR_VIEW_MODE);
final JSONObject result = articleQueryService.getArticles(avatarViewMode, requestJSONObject, articleFields);
dataModel.put(Article.ARTICLES, CollectionUtils.jsonArrayToList(result.optJSONArray(Article.ARTICLES)));
final JSONObject pagination = result.optJSONObject(Pagination.PAGINATION);
final int pageCount = pagination.optInt(Pagination.PAGINATION_PAGE_COUNT);
final JSONArray pageNums = pagination.optJSONArray(Pagination.PAGINATION_PAGE_NUMS);
dataModel.put(Pagination.PAGINATION_FIRST_PAGE_NUM, pageNums.opt(0));
dataModel.put(Pagination.PAGINATION_LAST_PAGE_NUM, pageNums.opt(pageNums.length() - 1));
dataModel.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, pageNum);
dataModel.put(Pagination.PAGINATION_PAGE_COUNT, pageCount);
dataModel.put(Pagination.PAGINATION_PAGE_NUMS, CollectionUtils.jsonArrayToList(pageNums));
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
use of org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer in project symphony by b3log.
the class AdminProcessor method showAd.
/**
* Shows ad.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/ad", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showAd(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/ad.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
dataModel.put("sideFullAd", "");
dataModel.put("headerBanner", "");
final JSONObject sideAdOption = optionQueryService.getOption(Option.ID_C_SIDE_FULL_AD);
if (null != sideAdOption) {
dataModel.put("sideFullAd", sideAdOption.optString(Option.OPTION_VALUE));
}
final JSONObject headerBanner = optionQueryService.getOption(Option.ID_C_HEADER_BANNER);
if (null != headerBanner) {
dataModel.put("headerBanner", headerBanner.optString(Option.OPTION_VALUE));
}
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
use of org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer in project symphony by b3log.
the class AdminProcessor method showUser.
/**
* Shows a user.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @param userId the specified user id
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/user/{userId}", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showUser(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response, final String userId) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/user.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final JSONObject user = userQueryService.getUser(userId);
Escapes.escapeHTML(user);
dataModel.put(User.USER, user);
final JSONObject result = roleQueryService.getRoles(1, Integer.MAX_VALUE, 10);
final List<JSONObject> roles = (List<JSONObject>) result.opt(Role.ROLES);
dataModel.put(Role.ROLES, roles);
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
use of org.b3log.latke.servlet.renderer.freemarker.AbstractFreeMarkerRenderer in project symphony by b3log.
the class AdminProcessor method showReservedWord.
/**
* Shows a reserved word.
*
* @param context the specified context
* @param request the specified request
* @param response the specified response
* @param id the specified reserved word id
* @throws Exception exception
*/
@RequestProcessing(value = "/admin/reserved-word/{id}", method = HTTPRequestMethod.GET)
@Before(adviceClass = { StopwatchStartAdvice.class, PermissionCheck.class })
@After(adviceClass = { PermissionGrant.class, StopwatchEndAdvice.class })
public void showReservedWord(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response, final String id) throws Exception {
final AbstractFreeMarkerRenderer renderer = new SkinRenderer(request);
context.setRenderer(renderer);
renderer.setTemplateName("admin/reserved-word.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
final JSONObject word = optionQueryService.getOption(id);
dataModel.put(Common.WORD, word);
dataModelService.fillHeaderAndFooter(request, response, dataModel);
}
Aggregations