| 
  ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StaticPageTagsDecorator | Line # 13 | 5 | 0% | 4 | 9 | 0% | 
0.0
 | 
                
                                    |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 1 | package net.sourceforge.pebble.decorator; | |
| 2 | ||
| 3 | import net.sourceforge.pebble.domain.PageBasedContent; | |
| 4 | import net.sourceforge.pebble.domain.StaticPage; | |
| 5 | import net.sourceforge.pebble.api.decorator.ContentDecoratorContext; | |
| 6 | ||
| 7 | /** | |
| 8 | * Generates tag links for inclusion in the body of static pages, | |
| 9 | * when rendered as HTML and newsfeeds. | |
| 10 | * | |
| 11 | * @author Simon Brown | |
| 12 | */ | |
| 13 | public class StaticPageTagsDecorator extends AbstractTagsDecorator { | |
| 14 | ||
| 15 | /** | |
| 16 | * Decorates the specified static page. | |
| 17 | * | |
| 18 | * @param context the context in which the decoration is running | |
| 19 | * @param staticPage the static page to be decorated | |
| 20 | */ | |
| 21 | 0 | 
         @Override     | 
  
| 22 | public void decorate(ContentDecoratorContext context, StaticPage staticPage) { | |
| 23 | 0 | String html = generateDecorationHtml(context, staticPage); | 
| 24 | ||
| 25 | // now add the tags to the body, if not empty | |
| 26 | 0 | String body = staticPage.getBody(); | 
| 27 | 0 | if (body != null && body.trim().length() > 0) { | 
| 28 | 0 | staticPage.setBody(body + html); | 
| 29 | } | |
| 30 | } | |
| 31 | ||
| 32 | /** | |
| 33 | * Gets the base URL for tag links, complete with trailing slash. | |
| 34 | * | |
| 35 | * @param content the owning content | |
| 36 | * @return a URL as a String | |
| 37 | */ | |
| 38 | 0 | 
         public String getBaseUrl(PageBasedContent content) {     | 
  
| 39 | 0 | return content.getBlog().getUrl() + "tags/"; | 
| 40 | } | |
| 41 | ||
| 42 | } | |
  | 
||||||||||||