| 1 |
|
package net.sourceforge.pebble.decorator; |
| 2 |
|
|
| 3 |
|
import net.sourceforge.pebble.domain.Blog; |
| 4 |
|
import net.sourceforge.pebble.domain.BlogEntry; |
| 5 |
|
import net.sourceforge.pebble.domain.StaticPage; |
| 6 |
|
import net.sourceforge.pebble.api.decorator.ContentDecoratorContext; |
| 7 |
|
|
| 8 |
|
import java.util.ResourceBundle; |
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
@author |
| 14 |
|
|
|
|
|
| 93,8% |
Uncovered Elements: 1 (16) |
Complexity: 4 |
Complexity Density: 0,33 |
|
| 15 |
|
public class EntryToPdfDecorator extends ContentDecoratorSupport { |
| 16 |
|
|
| 17 |
|
private static final String PDF_IMG = "<img src=\"common/images/pdf_logo.gif\" alt=\"Export this post as PDF document\" align=\"bottom\" border=\"0\" />"; |
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
@param |
| 23 |
|
|
| 24 |
|
@param |
| 25 |
|
|
| 26 |
|
|
|
|
|
| 83,3% |
Uncovered Elements: 1 (6) |
Complexity: 3 |
Complexity Density: 0,75 |
|
| 27 |
2
|
public void decorate(ContentDecoratorContext context, BlogEntry blogEntry) {... |
| 28 |
|
|
| 29 |
2
|
String body = blogEntry.getBody(); |
| 30 |
2
|
if (body != null && body.trim().length() > 0) { |
| 31 |
|
|
| 32 |
2
|
String html = generateDecorationHtml(blogEntry); |
| 33 |
2
|
blogEntry.setBody(body + html); |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
} |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
| 44 |
2
|
private String generateDecorationHtml(BlogEntry blogEntry) {... |
| 45 |
|
|
| 46 |
2
|
StringBuffer buf = new StringBuffer(); |
| 47 |
2
|
String title = blogEntry.getTitle(); |
| 48 |
2
|
String subtitle = blogEntry.getSubtitle(); |
| 49 |
|
|
| 50 |
2
|
buf.append("<p>"); |
| 51 |
2
|
buf.append("<a href=\"" + blogEntry.getBlog().getUrl() + "entryToPDF.action?entry=" + blogEntry.getId() + "\" title=\"Export " + title + " - " + subtitle + " as PDF document\">"); |
| 52 |
2
|
buf.append(PDF_IMG); |
| 53 |
2
|
buf.append("</a> Export this post to PDF document</p>"); |
| 54 |
|
|
| 55 |
2
|
return buf.toString(); |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
} |