зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1330973 - WebsiteMetadata.jsm: Add description length to Metadata JSON. r=Grisha
MozReview-Commit-ID: 4zxaHPLEWJ6 --HG-- extra : rebase_source : 861de1b6e5f47435963d641aa6a2245f18a77128
This commit is contained in:
Родитель
fd87861e7b
Коммит
4e6612f2c4
|
@ -22,7 +22,8 @@ var WebsiteMetadata = {
|
|||
Task.spawn(function() {
|
||||
let metadata = getMetadata(doc, doc.location.href, {
|
||||
image_url: metadataRules['image_url'],
|
||||
provider: metadataRules['provider']
|
||||
provider: metadataRules['provider'],
|
||||
description_length: metadataRules['description_length']
|
||||
});
|
||||
|
||||
// No metadata was extracted, so don't bother sending it.
|
||||
|
@ -92,12 +93,21 @@ function buildRuleset(name, rules, processors) {
|
|||
};
|
||||
}
|
||||
|
||||
const descriptionRules = [
|
||||
['meta[property="og:description"]', node => node.element.getAttribute('content')],
|
||||
['meta[name="description"]', node => node.element.getAttribute('content')],
|
||||
];
|
||||
|
||||
const metadataRules = {
|
||||
description: {
|
||||
rules: [
|
||||
['meta[property="og:description"]', node => node.element.getAttribute('content')],
|
||||
['meta[name="description"]', node => node.element.getAttribute('content')],
|
||||
],
|
||||
rules: descriptionRules
|
||||
},
|
||||
|
||||
description_length: {
|
||||
rules: descriptionRules,
|
||||
processors: [
|
||||
(description) => description.length
|
||||
]
|
||||
},
|
||||
|
||||
icon_url: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче