Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.Blog


    BlogEntry blogEntry = event.getBlogEntry();
    sendNotification((BlogEntry)blogEntry.clone());
  }

  private void sendNotification(BlogEntry blogEntry) {
    Blog blog = blogEntry.getBlog();

    // first of all decorate the blog entry, as if it was being rendered
    // via a HTML page or XML feed
    ContentDecoratorContext context = new ContentDecoratorContext();
    context.setView(ContentDecoratorContext.SUMMARY_VIEW);
    context.setMedia(ContentDecoratorContext.EMAIL);
    blog.getContentDecoratorChain().decorate(context, blogEntry);

    SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z");
    sdf.setTimeZone(blog.getTimeZone());

    String subject = MailUtils.getBlogEntryPrefix(blog, blogEntry.getState()) + " " + blogEntry.getTitle();

    String message = "Blog entry posted by " + (blogEntry.getUser() != null ? blogEntry.getUser().getName() : blogEntry.getAuthor()) + " on " + sdf.format(blogEntry.getDate());
    message += "\n<br>";
    message += blogEntry.getBody();
    message += "\n<br>";
    message += "<a href=\"" + blogEntry.getLocalPermalink() + "\">Permalink</a>";

    if (blogEntry.isUnpublished()) {
      message += " | ";
      message += "<a href=\"" + blog.getUrl() + "manageBlogEntry.secureaction?entry=" + blogEntry.getId() + "&submit=Publish&confirm=true\">Publish</a>";
    }

    // and send the e-mail
    try {
      MailUtils.sendMail(MailUtils.createSession(), blog, blog.getEmailAddresses(), new HashSet(), subject, message);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here


   * Gets the title of this view.
   *
   * @return the title as a String
   */
  public String getTitle() {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Day daily = (Day)getModel().get(Constants.DAILY_BLOG);
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG, blog.getLocale());
    dateFormat.setTimeZone(blog.getTimeZone());
    return dateFormat.format(daily.getDate());

  }
View Full Code Here

    BlogEntry blogEntry = event.getBlogEntry();
    sendNotification((BlogEntry)blogEntry.clone());
  }

  private void sendNotification(BlogEntry blogEntry) {
    Blog blog = blogEntry.getBlog();

    // first of all decorate the blog entry, as if it was being rendered
    // via a HTML page or XML feed
    ContentDecoratorContext context = new ContentDecoratorContext();
    context.setView(ContentDecoratorContext.DETAIL_VIEW);
    context.setMedia(ContentDecoratorContext.EMAIL);
    blog.getContentDecoratorChain().decorate(context, blogEntry);

    SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z");
    sdf.setTimeZone(blog.getTimeZone());

    String subject = MailUtils.getBlogEntryPrefix(blog) + " " + blogEntry.getTitle();

    String message = "<a href=\"" + blogEntry.getLocalPermalink() + "\">Blog entry</a> posted by " + (blogEntry.getUser() != null ? blogEntry.getUser().getName() : blogEntry.getAuthor()) + " on " + sdf.format(blogEntry.getDate());
    message += "\n<br>";
    if (blogEntry.getExcerpt() != null && blogEntry.getExcerpt().trim().length() > 0) {
      message += blogEntry.getExcerpt();
    } else {
      message += blogEntry.getBody();
    }
    message += "\n<br>";
    message += "<a href=\"" + blogEntry.getLocalPermalink() + "\">Permalink</a>";

    message += " | ";
    message += "<a href=\"" + blog.getUrl() + "unsubscribe.action?email=" + EMAIL_ADDRESS_TOKEN + "\">Opt-out</a>";

    List<String> to = blog.getEmailSubscriptionList().getEmailAddresses();

    // now send personalized e-mails to the blog owner and everybody
    // that left a comment specifying their e-mail address
    try {
      Session session = MailUtils.createSession();
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 id = request.getParameter("id");

    if (id != null && id.length() > 0) {
      Category category = blog.getCategory(id);
      getModel().put(Constants.CATEGORY_KEY, category);
    }
    getModel().put(Constants.CATEGORIES, blog.getCategories());

    return new CategoriesView(true);
  }
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");
    String trackBackUrl = request.getParameter("url");
    String excerpt = request.getParameter("excerpt");
    String trackBackResponseMessage;
    Integer trackBackResponseCode;

    BlogService service = new BlogService();
    BlogEntry blogEntry = null;
    if (entryId != null) {
      try {
        blogEntry = service.getBlogEntry(blog, entryId);
      } catch (BlogServiceException e) {
        throw new ServletException(e);
      }
    }

    if (blogEntry == null) {
      // the entry cannot be found - it may have been removed or the
      // requesting URL was wrong

      return new NotFoundView();
    } else if (trackBackUrl == null || trackBackUrl.trim().length() == 0) {
      getModel().put(Constants.BLOG_ENTRY_KEY, blogEntry);
      return new TrackBackFormView();
    } else {
      // extract the information to send in the trackback
      String title = blogEntry.getTitle();
      String blogName = blogEntry.getBlog().getName();
      String url = blogEntry.getPermalink();

      // now send the trackback
      try {
        HttpClient httpClient = new HttpClient();
        PostMethod postMethod = new PostMethod(trackBackUrl);
        postMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=" + blog.getCharacterEncoding());
        NameValuePair[] data = {
          new NameValuePair("title", title),
          new NameValuePair("url", url),
          new NameValuePair("excerpt", excerpt),
          new NameValuePair("blog_name", blogName)
View Full Code Here

   * Gets the URI that this view represents.
   *
   * @return the URI as a String
   */
  public String getUri() {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    CommentConfirmationStrategy strategy = blog.getCommentConfirmationStrategy();
    return strategy.getUri();
  }
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 name = request.getParameter("name");
    String type = request.getParameter("type");
    String path = request.getParameter("path");
    String content = request.getParameter("fileContent");

    try {
      FileManager fileManager = new FileManager(blog, type);
      fileManager.saveFile(path, name, content);

      // if it's a theme file, also save a copy to blog.dir/theme
      if (type.equals(FileMetaData.THEME_FILE)) {
        fileManager = new FileManager(blog, FileMetaData.BLOG_DATA);
        fileManager.saveFile("/theme" + path, name, content);
      }

      blog.info("File \"" + StringUtils.transformHTML(name) + "\" saved.");
    } catch (IllegalFileAccessException e) {
      return new ForbiddenView();
    } catch (IOException ioe) {
      throw new ServletException(ioe);
    }
View Full Code Here

  /**
   * Prepares the view for presentation.
   */
  public void prepare() {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = (Log)getModel().get("log");
    StringBuffer buf = new StringBuffer();
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss Z");
    sdf.setTimeZone(blog.getTimeZone());

    buf.append("Host");
    buf.append(SEPARATOR);
    buf.append("Date/Time");
    buf.append(SEPARATOR);
View Full Code Here

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

    StaticPage staticPage;
    try {
      staticPage = service.getStaticPageByName(blog, name);
    } catch (StaticPageServiceException e) {
      throw new ServletException(e);
    }
    if (staticPage == null) {
      // the page cannot be found - it may have been removed or the
      // requesting URL was wrong
      return new NotFoundView();
    } else {
      getModel().put(Constants.STATIC_PAGE_KEY, staticPage);
      getModel().put(Constants.MONTHLY_BLOG, blog.getBlogForThisMonth());
      getModel().put("displayMode", "detail");

      return new StaticPageView();
    }
  }
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 name = request.getParameter("name");

    StaticPage staticPage = new StaticPage(blog);
    staticPage.setName(name);
    staticPage.setTitle("Title");
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.