зеркало из https://github.com/mozilla/pjs.git
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
This commit is contained in:
Родитель
866eb1abe0
Коммит
caed698b91
|
@ -1586,17 +1586,22 @@ MicrosummaryGenerator.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
generateMicrosummary: function MSD_generateMicrosummary(pageContent) {
|
generateMicrosummary: function MSD_generateMicrosummary(pageContent) {
|
||||||
|
|
||||||
|
var content;
|
||||||
|
|
||||||
if (this.content) {
|
if (this.content) {
|
||||||
var content = this.content.replace(/^\s+|\s+$/g, "");
|
content = this.content;
|
||||||
if (content.length > MAX_SUMMARY_LENGTH)
|
|
||||||
content = content.substring(0, MAX_SUMMARY_LENGTH);
|
|
||||||
return content;
|
|
||||||
} else if (this.template) {
|
} else if (this.template) {
|
||||||
// Note that _processTemplate truncates the summary for us, so we don't
|
content = this._processTemplate(pageContent);
|
||||||
// need to do anything more here
|
|
||||||
return this._processTemplate(pageContent);
|
|
||||||
} else
|
} else
|
||||||
throw("generateMicrosummary called on uninitialized microsummary generator");
|
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) {
|
calculateUpdateInterval: function MSD_calculateUpdateInterval(doc) {
|
||||||
|
@ -1637,11 +1642,7 @@ MicrosummaryGenerator.prototype = {
|
||||||
|
|
||||||
// XXX When we support HTML microsummaries we'll need to do something
|
// XXX When we support HTML microsummaries we'll need to do something
|
||||||
// more sophisticated than just returning the text content of the fragment.
|
// more sophisticated than just returning the text content of the fragment.
|
||||||
var content = fragment.textContent;
|
return fragment.textContent;
|
||||||
if (content.length > MAX_SUMMARY_LENGTH)
|
|
||||||
content = content.substring(0, MAX_SUMMARY_LENGTH);
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче