Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.Blog


   *
   * @param context   the context in which the decoration is running
   * @param blogEntry the blog entry to be decorated
   */
  public void decorate(ContentDecoratorContext context, BlogEntry blogEntry) {
    Blog blog = blogEntry.getBlog();

    if ((blogEntry.getExcerpt() != null && blogEntry.getExcerpt().length() > 0 && context.getView() == ContentDecoratorContext.SUMMARY_VIEW)) {
      StringBuffer buf = new StringBuffer();
      buf.append(blogEntry.getExcerpt());

View Full Code Here


   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String type = request.getParameter("type");
    String path = request.getParameter("path");

    // if there is no path, we're looking at the root
    if (path == null || path.length() == 0) {
      path = "/";
    }

    try {
      String filename;
      if (type.equals(FileMetaData.BLOG_DATA)) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        if (path.equals("/logs")) {
          filename = blog.getId() + "-logs-" + sdf.format(blog.getCalendar().getTime()) + ".zip";
        } else {
          filename = blog.getId() + "-" + sdf.format(blog.getCalendar().getTime()) + ".zip";
        }
      } else {
        filename = "export.zip";
      }

View Full Code Here

   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    BlogEntry blogEntry;
    Comment comment;

    String entry = request.getParameter("entry");
    String rememberMe = request.getParameter("rememberMe");
    String submitType = request.getParameter("submit");

    BlogService service = new BlogService();
    try {
      blogEntry = service.getBlogEntry(blog, entry);
    } catch (BlogServiceException e) {
      throw new ServletException(e);
    }
    if (blogEntry == null) {
      // just send back a 404 - this is probably somebody looking for a way
      // to send comment spam ;-)
      log.info("ignoring saveComment with no related blog entry (spam) from " + request.getRemoteAddr());
      return new NotFoundView();
    } else if (!blogEntry.isCommentsEnabled()) {
      return new CommentConfirmationView();
    }

    comment = createComment(request, blogEntry);
    ValidationContext context = validateComment(comment);

    // are we previewing or adding the comment?
    String previewButton = I18n.getMessage(blog, "comment.previewButton");

    ContentDecoratorContext decoratorContext = new ContentDecoratorContext();
    decoratorContext.setView(ContentDecoratorContext.DETAIL_VIEW);
    decoratorContext.setMedia(ContentDecoratorContext.HTML_PAGE);

    Comment decoratedComment = (Comment)comment.clone();
    blog.getContentDecoratorChain().decorate(decoratorContext, decoratedComment);
    getModel().put("decoratedComment", decoratedComment);
    getModel().put("undecoratedComment", comment);
    getModel().put("rememberMe", rememberMe);
    getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);
    getModel().put(Constants.COMMENT_KEY, comment);
    request.getSession().setAttribute("rememberMe", request.getParameter("rememberMe"));

    if (submitType == null || submitType.equalsIgnoreCase(previewButton) || context.hasErrors()) {
      return new CommentFormView();
    } else {
      CommentConfirmationStrategy strategy = blog.getCommentConfirmationStrategy();

      Comment clonedComment = (Comment)comment.clone();
      request.getSession().setAttribute(Constants.COMMENT_KEY, comment);

      if (strategy.confirmationRequired(clonedComment)) {
View Full Code Here

   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String entryId = request.getParameter("entry");

    BlogEntry blogEntry = null;
    if (entryId != null) {
      BlogService service = new BlogService();
View Full Code Here

    }
    if (!getModel().contains(Constants.STATIC_PAGE_KEY)) {
      return "template";
    }
    StaticPage staticPage = (StaticPage) getModel().get(Constants.STATIC_PAGE_KEY);
    Blog blog = (Blog) getModel().get(Constants.BLOG_KEY);
    String templateFile = blog.getThemeDirectory() + "/" + staticPage.getTemplate() + ".jsp";
    if (new File(templateFile).canRead()) {
      return staticPage.getTemplate();
    }
    return "template";
  }
View Full Code Here

   * @throws  JspException    if something goes wrong
   */
  public int doStartTag() throws JspException {

    HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
    Blog blog = (Blog)request.getAttribute(Constants.BLOG_KEY);
    Month month = (Month)request.getAttribute(Constants.MONTHLY_BLOG);
    Day today = blog.getBlogForToday();
    Calendar now = blog.getCalendar();

    if (month == null) {
      month = today.getMonth();
    }

    Calendar firstDayOfMonth = blog.getCalendar();
    firstDayOfMonth.setTime(month.getBlogForDay(1).getDate());

    SimpleDateFormat monthAndYearFormatter = new SimpleDateFormat("MMMM yyyy", blog.getLocale());
    monthAndYearFormatter.setTimeZone(blog.getTimeZone());
    SimpleDateFormat monthFormatter = new SimpleDateFormat("MMM", blog.getLocale());
    monthFormatter.setTimeZone(blog.getTimeZone());
    NumberFormat numberFormatter = NumberFormat.getIntegerInstance(blog.getLocale());

    Month firstMonth = blog.getBlogForFirstMonth();

    try {
      JspWriter out = pageContext.getOut();

      out.write("<div class=\"calendar\">");
      out.write("<table width=\"100%\">");
      out.write("<tr>");
      out.write("<td colspan=\"7\" align=\"center\">");
      if (month.before(firstMonth)) {
        out.write("<b>");
        out.write(monthAndYearFormatter.format(month.getDate()));
        out.write("</b>");
      } else {
        out.write("<b><a href=\"");
        out.write(UrlRewriter.doRewrite(month.getPermalink()));
        out.write("\">");
        out.write(monthAndYearFormatter.format(month.getDate()));
        out.write("</a></b>");
      }
      out.write("</td>");
      out.write("</tr>");

      int firstDayOfWeek = now.getFirstDayOfWeek();

      // write out the calendar header
      DateFormatSymbols symbols = new DateFormatSymbols(blog.getLocale());
      String[] days = symbols.getShortWeekdays();
      out.write("<tr>");
      for (int i = firstDayOfWeek; i <= 7; i++) {
        out.write("<td class=\"calendarDayHeader\" width=\"14%\">" + days[i] + "</td>");
      }
      for (int i = 1; i < firstDayOfWeek; i++) {
        out.write("<td class=\"calendarDayHeader\">" + days[i] + "</td>");
      }
      out.write("</tr>");

      // write out the body of the calendar
      Iterator it = getDatesForCompleteWeeks(blog, month).iterator();
      Calendar cal;
      int count = 0;
      while (it.hasNext()) {
        cal = (Calendar)it.next();
        Day daily = blog.getBlogForDay(cal.getTime());

        String formattedNumber = numberFormatter.format(cal.get(Calendar.DAY_OF_MONTH));
        if (formattedNumber.length() == 1) {
          formattedNumber = "&nbsp;" + formattedNumber;
        }
View Full Code Here

   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    StaticPageService service = new StaticPageService();
    StaticPage staticPage = null;
    try {
      staticPage = service.getStaticPageById(blog, request.getParameter("page"));
    } catch (StaticPageServiceException e) {
View Full Code Here

   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String[] emails = request.getParameterValues("email");

    if (emails != null) {
      Set<String> emailSet = new HashSet<String>();
      for (String email : emails) {
        email = StringUtils.filterHTML(email);
        blog.getEmailSubscriptionList().removeEmailAddress(email);
        emailSet.add(email);
      }

      String emailListAsString = "";
      for (String email : emailSet) {
View Full Code Here

    AbstractBlog abstractBlog = (AbstractBlog) request.getAttribute(Constants.BLOG_KEY);

    try {
      if (abstractBlog instanceof Blog) {
        PageDecoratorContext context = new PageDecoratorContext(request);
        Blog blog = (Blog) abstractBlog;
        if (PAGE_DECORATOR_HEAD.equals(plugin)) {
          for (PageDecorator decorator : blog.getPageDecorators()) {
            decorator.decorateHead(pageContext.getOut(), context);
          }
        } else if (PAGE_DECORATOR_HEADER.equals(plugin)) {
          for (PageDecorator decorator : blog.getPageDecorators()) {
            decorator.decorateHeader(pageContext.getOut(), context);
          }
        } else if (PAGE_DECORATOR_FOOTER.equals(plugin)) {
          for (PageDecorator decorator : blog.getPageDecorators()) {
            decorator.decorateFooter(pageContext.getOut(), context);
          }
        }
        if (OPEN_ID_COMMENT_AUTHOR_PROVIDER.equals(plugin)) {
          for (OpenIdCommentAuthorProvider provider : blog.getOpenIdCommentAuthorProviders()) {
            provider.renderProvider(pageContext.getOut(), context);
          }
        }
      }
    } catch (IOException ioe) {
View Full Code Here

  public void setUrl(String url) {
    this.url = url;

    if (url != null) {
      Blog blog = (Blog)getJspContext().getAttribute(Constants.BLOG_KEY, PageContext.REQUEST_SCOPE);
      NewsFeedCache.getInstance().addSubscription(blog, url);
    }
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.domain.Blog

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.