Modify ReadmorePlugin.java to support the Chinese title (Roller Webblog)

xiaoxiao2021-03-06  60

The current version of Roller's READMORE plug-in, does not support Chinese title, and needs to modify the REDMOREPLUGIN.JAVA file to modify 105 lines in the ReadMorePlugin.java file (in the render: entry.getanchor () modified to: Urlencoder. Encode (entry.getanchor (), "UTF-8") can be modified the source code as follows:

/ *

* CREATED ON NOV 2, 2003

*

* /

Package org.roller.presentation.velocity.plugins.readmore;

Import org.apache.commons.lang.stringescapeutils;

Import org.apache.commons.logging.log;

Import org.apache.commons.logging.logfactory;

Import org.apache.velocity.Context.context;

Import org.roller.rollerexception;

Import org.roller.model.rollerfactory;

Import Org.roller.Model.userManager;

Import org.roller.pojos.weblogenTryData;

Import org.roller.pojos.websitedata;

Import org.roller.presentation.rollerRequest;

Import org.roller.presentation.velocity.pageplugin;

Import org.roller.util.utilities;

Import java.io.unsupportedEncodingexception;

Import java.net.urlencoder;

/ **

* @Author lance

*

* /

Public Class ReadmorePlugin IMPLEments PagePlugin

{

protected string name = "read more summary";

Protected string description = "stops entry after 250 character 250 character 250 character 250

"a line to the full function."

Private static log mlogger =

Logfactory.GetFactory (). GetInstance (ReadmorePlugin.class);

String ctxpath = "";

Public ReadmorePlugin ()

{

Mlogger.debug ("ReadmorePlugin Instantiated.");

}

Public string toString () {return name;}

/ * (non-javadoc)

* @see org.roller.presentation.velocity.pageplugin # init (org.roller.presentation.rollerRequest, Org.apache.Velocity.Context.context)

* /

Public Void Init (RollerRequest RREQ, Context CTX) THROWS ROLLLEEREXCEPTION

{

IF (RREQ == Null) Throw new RolleRexception ("RollerRequest is Null."); ctxpath = rreq.getRequest (). getContextPath ();

}

/ **

* @Param Mgr

* @Param Data

* @Return

* /

Private string getPagelink (UserManager Mgr, WebsiteData Website) Throws Rollerexception

{

Return Mgr.RetrieVepage (Website.GetDefault ()). getLink ();

}

/ *

* This Method Cannot Do It's Intended Job (Since It Cannot

* Read the current entry) SO it is to do no one!

*

* (non-javadoc)

* @see org.roller.presentation.velocity.pageplugin # render (java.lang.string)

* /

Public String Render (String STR)

{

Return Str;

}

Public String Render (WebloGENTRYDATA Entry, Boolean Skipflag)

{

IF (Skipflag)

Return entry.getText ();

// in Case It Didn't Initialize

String Pagelink = "Weblog";

Try

{

Pagelink = getpagelink

RollerFactory.Getroller (). GetuserManager (), entry.getWebsite ());

}

Catch (RolleRexception E)

{

Mlogger.warn ("Unable to Get Pagelink", E);

}

String result = utilities.truncatenicly (entry.getText (), 240, 260, "...");

Try

{

// if the result is shorter, We need to add "read more" LINK

IF (result.length ()

{

String link = "

"/ Comments /"

Entry.getWebsite (). getuser (). getusername ()

"/" Pagelink "/" Urlencoder.Encode (entry.getanchor (), "UTF-8")

"/"> Read more

"

Result = link;

}

}

Catch (unsupportedEncodingexception E)

{

// go with the "no eNCoding" Version

}

Return Result;

}

Public string getname () {return name;}

Public string getdescription () {return stringescapeutils.escapejavascript (description);

}

转载请注明原文地址:https://www.9cbs.com/read-91081.html

New Post(0)