Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.Template


              
        // if there is an "_entry" page, only load it once
        // but don't do it for dummy website
        if (weblog != null && !"zzz_none_zzz".equals(weblog.getHandle())) {
            // alternative display pages - customization
            Template entryPage = weblog.getPageByName("_entry");
            if (entryPage != null) {
                ctx.put("entryPage", TemplateWrapper.wrap(entryPage));
            }
            Template descPage = weblog.getPageByName("_desc");
            if (descPage != null) {
                ctx.put("descPage", TemplateWrapper.wrap(descPage));
            }
        }
View Full Code Here


               
                // Get the pages, put into context & load map
                List pages = mWebsite.getPages();
                Iterator pageIter = pages.iterator();
                while (pageIter.hasNext()) {
                    Template page = (Template) pageIter.next();
                    mPageMap.put(page.getName(), TemplateWrapper.wrap(page));
                }
            }
        } catch (RollerException e) {
            mLogger.error("PageModel Roller get*Manager Exception", e);
        }
View Full Code Here

        mLogger.debug("looking up page ["+pageName+"]");
       
        String template_id = null;
       
        try {
            Template pd = mWebsite.getPageByName(pageName);
            if(pd != null) {
                template_id = pd.getId();
            }
        } catch(Exception e) {
            mLogger.error(e);
        }
       
View Full Code Here

            }
        }

       
        // figure out what we are going to render
        Template page = null;
       
        // If this is a popup request, then deal with it specially
        // TODO: do we really need to keep supporting this?
        if (request.getParameter("popup") != null) {
            try {
                // Does user have a popupcomments page?
                page = weblog.getPageByName("_popupcomments");
            } catch(Exception e ) {
                // ignored ... considered page not found
            }
           
            // User doesn't have one so return the default
            if(page == null) {
                page = new WeblogTemplate("templates/weblog/popupcomments.vm", weblog,
                        "Comments", "Comments", "dummy_link",
                        "dummy_template", new Date(), "velocity", true, false, null);
            }
           
        // If request specified the page, then go with that
        } else if (pageRequest.getWeblogPageName() != null) {
            page = pageRequest.getWeblogPage();
           
        // If page not available from request, then use weblog's default
        } else {
            try {
                page = weblog.getDefaultPage();
            } catch(Exception e) {
                log.error("Error getting weblogs default page", e);
            }
        }
       
        // Still no page?  Then that is a 404
        if (page == null) {
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        log.debug("page found, dealing with it");
       
       
        // validation.  make sure that request input makes sense.
        boolean invalid = false;
        if(pageRequest.getWeblogPageName() != null && page.isHidden()) {
            invalid = true;
        }
        if(pageRequest.getLocale() != null) {
           
            // locale view only allowed if weblog has enabled it
            if(!pageRequest.getWeblog().isEnableMultiLang()) {
                invalid = true;
            }
           
        }
        if(pageRequest.getWeblogAnchor() != null) {
           
            // permalink specified.
            // entry must exist, be published before current time, and locale must match
            WeblogEntryData entry = pageRequest.getWeblogEntry();
            if(entry == null) {
                invalid = true;
            } else if (pageRequest.getLocale() != null &&
                    !entry.getLocale().startsWith(pageRequest.getLocale())) {
                invalid = true;
            } else if (!entry.isPublished()) {
                invalid = true;
            } else if (new Date().before(entry.getPubTime())) {
                invalid = true;
            }
           
        } else if(pageRequest.getWeblogCategoryName() != null) {
           
            // category specified.  category must exist.
            if(pageRequest.getWeblogCategory() == null) {
                invalid = true;
            }
           
        } else if(pageRequest.getTags() != null && pageRequest.getTags().size() > 0) {
           
            try {
                // tags specified.  make sure they exist.
                WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
                invalid = !wmgr.getTagComboExists(pageRequest.getTags(), (isSiteWide) ? null : weblog);
            } catch (RollerException ex) {
                invalid = true;
            }
        }

       
        if(invalid) {
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
       
        // allow for hit counting
        if(!isSiteWide) {
            this.processHit(weblog, request.getRequestURL().toString(), request.getHeader("referer"));
        }
       

        // looks like we need to render content
       
        // set the content type
        String mimeType = RollerContext.getServletContext().getMimeType(page.getLink());
        String contentType = "text/html; charset=utf-8";
        if(mimeType != null) {
            // we found a match ... set the content type
            contentType = mimeType+"; charset=utf-8";
        }

        HashMap model = new HashMap();
        try {
            PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
                    this, request, response,"", false, 8192, true);
           
            // special hack for menu tag
            request.setAttribute("pageRequest", pageRequest);
           
            // populate the rendering model
            Map initData = new HashMap();
            initData.put("request", request);
            initData.put("requestParameters", request.getParameterMap());
            initData.put("weblogRequest", pageRequest);
            initData.put("pageContext", pageContext);
           
            // if this was a comment posting, check for comment form
            WeblogEntryCommentForm commentForm =
                    (WeblogEntryCommentForm) request.getAttribute("commentForm");
            if(commentForm != null) {
                initData.put("commentForm", commentForm);
            }
           
            // Load models for pages
            String pageModels = RollerConfig.getProperty("rendering.pageModels");
            ModelLoader.loadModels(pageModels, model, initData, true);
           
            // Load special models for site-wide blog
            if(RollerRuntimeConfig.isSiteWideWeblog(weblog.getHandle())) {
                String siteModels = RollerConfig.getProperty("rendering.siteModels");
                ModelLoader.loadModels(siteModels, model, initData, true);
            }

            // Load weblog custom models
            ModelLoader.loadCustomModels(weblog, model, initData);
           
            // ick, gotta load pre-3.0 model stuff as well :(
            ModelLoader.loadOldModels(model, request, response, pageContext, pageRequest);
           
        } catch (RollerException ex) {
            log.error("Error loading model objects for page", ex);
           
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }
       
       
        // lookup Renderer we are going to use
        Renderer renderer = null;
        try {
            log.debug("Looking up renderer");
            renderer = RendererManager.getRenderer(page);
        } catch(Exception e) {
            // nobody wants to render my content :(
            log.error("Couldn't find renderer for page "+page.getId(), e);
           
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        // render content.  use size of about 24K for a standard page
        CachedContent rendererOutput = new CachedContent(24567, contentType);
        try {
            log.debug("Doing rendering");
            renderer.render(model, rendererOutput.getCachedWriter());
           
            // flush rendered output and close
            rendererOutput.flush();
            rendererOutput.close();
        } catch(Exception e) {
            // bummer, error during rendering
            log.error("Error during rendering for page "+page.getId(), e);
           
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
View Full Code Here

            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        // get their default page template to use for rendering
        Template page = null;
        try {
            page = weblog.getDefaultPage();
            if(page == null) {
                throw new RollerException("Could not lookup default page "+
                        "for weblog "+weblog.getHandle());
View Full Code Here

        // lookup Renderer we are going to use
        Renderer renderer = null;
        try {
            log.debug("Looking up renderer");
            Template template = new StaticTemplate(pageId, null, "velocity");
            renderer = RendererManager.getRenderer(template);
        } catch(Exception e) {
            // nobody wants to render my content :(

            // TODO: this log message has been disabled because it fills up
View Full Code Here

        // we've got to set the weblog in our previewRequest because that's
        // the object that gets referenced during rendering operations
        previewRequest.setWeblog(tmpWebsite);
       
       
        Template page = null;
        try {
            // we just want to show the default view
            page = tmpWebsite.getDefaultPage();
           
            if(page == null) {
                throw new RollerException("No default page for weblog: "+tmpWebsite.getHandle());
            }
        } catch(RollerException re) {
            // couldn't get page
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            log.error("Error getting default page for preview", re);
            return;
        }
       
        log.debug("preview page found, dealing with it");
       
        // set the content type
        String pageLink = previewRequest.getWeblogPageName();
        String mimeType = pageLink !=  null ? RollerContext.getServletContext().getMimeType(pageLink) : null;       
        String contentType = "text/html; charset=utf-8";
        if(mimeType != null) {
            // we found a match ... set the content type
            contentType = mimeType+"; charset=utf-8";
        } else if ("_css".equals(previewRequest.getWeblogPageName())) {
            // TODO: store content-type for each page so this hack is unnecessary
            contentType = "text/css; charset=utf-8";
        }
       
        // looks like we need to render content
        Map model = new HashMap();
        try {
            PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
                    this, request, response,"", false, 8192, true);
           
            // special hack for menu tag
            request.setAttribute("pageRequest", previewRequest);
           
            // populate the rendering model
            Map initData = new HashMap();
            initData.put("request", request);
            initData.put("weblogRequest", previewRequest);
            initData.put("pageContext", pageContext);
           
            // Load models for page previewing
            String pageModels = RollerConfig.getProperty("rendering.previewModels");
            ModelLoader.loadModels(pageModels, model, initData, true);
           
            // Load special models for site-wide blog
            if(RollerRuntimeConfig.isSiteWideWeblog(weblog.getHandle())) {
                String siteModels = RollerConfig.getProperty("rendering.siteModels");
                ModelLoader.loadModels(siteModels, model, initData, true);
            }

            // Load weblog custom models
            ModelLoader.loadCustomModels(weblog, model, initData);
           
            // ick, gotta load pre-3.0 model stuff as well :(
            ModelLoader.loadOldModels(model, request, response, pageContext, previewRequest);
           
        } catch (RollerException ex) {
            log.error("ERROR loading model for page", ex);
           
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }
       
       
        // lookup Renderer we are going to use
        Renderer renderer = null;
        try {
            log.debug("Looking up renderer");
            renderer = RendererManager.getRenderer(page);
        } catch(Exception e) {
            // nobody wants to render my content :(
            log.error("Couldn't find renderer for page "+page.getId(), e);
           
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        // render content.  use default size of about 24K for a standard page
        CachedContent rendererOutput = new CachedContent(24567);
        try {
            log.debug("Doing rendering");
            renderer.render(model, rendererOutput.getCachedWriter());
           
            // flush rendered output and close
            rendererOutput.flush();
            rendererOutput.close();
        } catch(Exception e) {
            // bummer, error during rendering
            log.error("Error during rendering for page "+page.getId(), e);
           
            if(!response.isCommitted()) response.reset();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
View Full Code Here

                //ModelLoader.loadCustomModels(weblog, model, initData);
               
               
                // lookup Renderer we are going to use
                Renderer renderer = null;
                Template template = new StaticTemplate("templates/feeds/weblog-"+type+"-"+format+".vm", null, "velocity");
                renderer = RendererManager.getRenderer(template);
               
               
                // render content.  use default size of about 24K for a standard page
                CachedContent rendererOutput = new CachedContent(24567);
View Full Code Here

       
        // lookup Renderer we are going to use
        Renderer renderer = null;
        try {
            log.debug("Looking up renderer");
            Template template = new StaticTemplate("templates/planet/planetrss.vm", null, "velocity");
            renderer = RendererManager.getRenderer(template);
        } catch(Exception e) {
            // nobody wants to render my content :(
            log.error("Couldn't find renderer for planet rss", e);
           
View Full Code Here

        if(this.weblogRequest == null) {
            throw new RollerException("expected weblogRequest from init data");
        }
       
        if (weblogRequest instanceof WeblogPageRequest) {
            Template weblogPage = ((WeblogPageRequest)weblogRequest).getWeblogPage();
            pageLink = (weblogPage != null) ? weblogPage.getLink() : null;
            pageNum = ((WeblogPageRequest)weblogRequest).getPageNum();
            tags = ((WeblogPageRequest)weblogRequest).getTags();
        } else if (weblogRequest instanceof WeblogFeedRequest) {
            tags = ((WeblogFeedRequest)weblogRequest).getTags();
        }
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.