/** * to complete with '/' * * @param module of webengine * @param ctx the webContext * @return */ public static String getSkinPathPrefix(Module module, WebContext ctx) { if (Framework.getProperty(SKIN_PATH_PREFIX_KEY) != null) { return module.getSkinPathPrefix(); } String webenginePath = ctx.getRequest().getHeader(NUXEO_WEBENGINE_BASE_PATH); if (webenginePath == null) { return module.getSkinPathPrefix(); } else { return ctx.getBasePath() + "/" + module.getName() + "/skin"; } }
/** * Retrieves a certain number of blog posts with information about the last <b>BlogPost</b>-s that * are made under an <b>BlogSite</b> that is received as parameter. */ @Override public Model getModel() throws ModelException { BlogPostListModel model = new BlogPostListModel(); if (WebEngine.getActiveContext() != null) { WebContext ctx = WebEngine.getActiveContext(); CoreSession session = ctx.getCoreSession(); DocumentModel documentModel = ctx.getTargetObject().getAdapter(DocumentModel.class); SimpleDateFormat simpleMonthFormat = new SimpleDateFormat("dd MMMM yyyy", WebEngine.getActiveContext().getLocale()); try { DocumentModel blogSite = SiteUtils.getFirstWebSiteParent(session, documentModel); DocumentModelList blogPosts = SiteQueriesCollection.queryLastModifiedPages( session, blogSite.getPathAsString(), BLOG_POST_DOC_TYPE, BLOG_POST_DOC_TYPE.equals(documentModel.getType()) ? noForBlogPost : noForBlogSite); for (DocumentModel blogPost : blogPosts) { String title = SiteUtils.getString(blogPost, "dc:title"); String path = SiteUtils.getPagePath(blogSite, blogPost); String description = SiteUtils.getString(blogPost, "dc:description"); String content = SiteUtils.getFistNWordsFromString( SiteUtils.getString(blogPost, WEBPAGE_CONTENT), Integer.MAX_VALUE); String author = SiteUtils.getString(blogPost, "dc:creator"); GregorianCalendar creationDate = SiteUtils.getGregorianCalendar(blogPost, "dc:created"); String day = getWeekDay(creationDate.get(Calendar.DAY_OF_WEEK)); BlogSiteArchiveDayModel dayModel = getYearModel(model, day); if (dayModel == null) { dayModel = new BlogSiteArchiveDayModel( day, simpleMonthFormat.format(creationDate.getTime()), 0); model.addItem(dayModel); } dayModel.increaseCount(); BlogPostModel blogPostModel = new BlogPostModel(title, path, description, content, author); dayModel.addItem(blogPostModel); } } catch (Exception e) { throw new ModelException(e); } } return model; }