From fa364dc3e57929f8b839c86a4fd0d07e75ba0360 Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" Date: Tue, 12 Sep 2006 01:08:44 +0000 Subject: [PATCH] bug 349440: trim whitespace from the beginning of microsummaries generated by microsummary generators in addition to those provided as plain text. Patch by Justin Dolske. r=myk --- .../src/nsMicrosummaryService.js.in | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/browser/components/microsummaries/src/nsMicrosummaryService.js.in b/browser/components/microsummaries/src/nsMicrosummaryService.js.in index 0901598b1341..b8b97b3b22d9 100644 --- a/browser/components/microsummaries/src/nsMicrosummaryService.js.in +++ b/browser/components/microsummaries/src/nsMicrosummaryService.js.in @@ -1586,17 +1586,22 @@ MicrosummaryGenerator.prototype = { }, generateMicrosummary: function MSD_generateMicrosummary(pageContent) { + + var content; + if (this.content) { - var content = this.content.replace(/^\s+|\s+$/g, ""); - if (content.length > MAX_SUMMARY_LENGTH) - content = content.substring(0, MAX_SUMMARY_LENGTH); - return content; + content = this.content; } else if (this.template) { - // Note that _processTemplate truncates the summary for us, so we don't - // need to do anything more here - return this._processTemplate(pageContent); + content = this._processTemplate(pageContent); } else throw("generateMicrosummary called on uninitialized microsummary generator"); + + // Clean up the output + content = content.replace(/^\s+|\s+$/g, ""); + if (content.length > MAX_SUMMARY_LENGTH) + content = content.substring(0, MAX_SUMMARY_LENGTH); + + return content; }, calculateUpdateInterval: function MSD_calculateUpdateInterval(doc) { @@ -1637,11 +1642,7 @@ MicrosummaryGenerator.prototype = { // XXX When we support HTML microsummaries we'll need to do something // more sophisticated than just returning the text content of the fragment. - var content = fragment.textContent; - if (content.length > MAX_SUMMARY_LENGTH) - content = content.substring(0, MAX_SUMMARY_LENGTH); - - return content; + return fragment.textContent; } };