Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.Attachment


  /**
   * Tests that a relative URI in an attachment is translated.
   */
  public void testRelativeUriInAttachment() throws Exception {
    blogEntry.setAttachment(new Attachment("./files/someimage.jpg", 1024, "image/jpeg"));
    decorator.decorate(context, blogEntry);
    assertEquals("http://www.yourdomain.com/blog/files/someimage.jpg", blogEntry.getAttachment().getUrl());

    blogEntry.setAttachment(new Attachment("http://www.domain.com/files/someimage.jpg", 1024, "image/jpeg"));
    decorator.decorate(context, blogEntry);
    assertEquals("http://www.domain.com/files/someimage.jpg", blogEntry.getAttachment().getUrl());
  }
View Full Code Here


   */
  public void decorate(ContentDecoratorContext context, BlogEntry blogEntry) {
    blogEntry.setBody(replaceCommonUris(blogEntry.getBody()));
    blogEntry.setExcerpt(replaceCommonUris(blogEntry.getExcerpt()));

    Attachment attachment = blogEntry.getAttachment();
    if (attachment != null) {
      String attachmentUrl = attachment.getUrl();
      if (attachmentUrl.startsWith("./")) {
        attachment.setUrl(getBlog().getUrl() + attachmentUrl.substring(2));
      }
    }
  }
View Full Code Here

TOP

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

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.