⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readmoredecorator.java

📁 pebble-blog 博客源码博客源码博客源码
💻 JAVA
字号:
package net.sourceforge.pebble.decorator;import net.sourceforge.pebble.domain.Blog;import net.sourceforge.pebble.domain.BlogEntry;import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;import java.util.ResourceBundle;/** * Adds a read more link : *  - when the entry is aggregated *  - when an excerpt is present, in the summary view * * @author Simon Brown */public class ReadMoreDecorator extends ContentDecoratorSupport {  /**   * Decorates the specified blog entry.   *   * @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();    ResourceBundle bundle = ResourceBundle.getBundle("resources", blog.getLocale());    if ((blogEntry.getExcerpt() != null && blogEntry.getExcerpt().length() > 0 && context.getView() == ContentDecoratorContext.SUMMARY_VIEW)) {      StringBuffer buf = new StringBuffer();      buf.append(blogEntry.getExcerpt());      buf.append("<p><a href=\"");      buf.append(blogEntry.getPermalink());      buf.append("\">");      buf.append(bundle.getString("common.readMore"));      buf.append("</a></p>");      blogEntry.setExcerpt(buf.toString());    } else if (blogEntry.isAggregated()) {      StringBuffer buf = new StringBuffer();      buf.append(blogEntry.getBody());      buf.append("<p><a href=\"");      buf.append(blogEntry.getPermalink());      buf.append("\">");      buf.append(bundle.getString("common.readMore"));      buf.append("</a></p>");      blogEntry.setBody(buf.toString());    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -