OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // These includes will be processed at build time by grit. | 5 // These includes will be processed at build time by grit. |
6 <include src="../../../../third_party/dom_distiller_js/js/domdistiller.js"/> | 6 <include src="../../../../third_party/dom_distiller_js/js/domdistiller.js"/> |
7 | 7 |
8 // Extracts long-form content from a page and returns an array where the first | 8 // Extracts long-form content from a page and returns an array where the first |
9 // element is the article title, the second element is HTML containing the | 9 // element is the article title, the second element is HTML containing the |
10 // long-form content, the third element is the next page link, and the fourth | 10 // long-form content, the third element is the next page link, and the fourth |
11 // element is the previous page link. | 11 // element is the previous page link. |
12 (function() { | 12 (function() { |
13 var result = new Array(4); | 13 var result = new Array(4); |
14 try { | 14 try { |
15 result[0] = com.dom_distiller.DocumentTitleGetter.getDocumentTitle( | 15 result[0] = com.dom_distiller.DocumentTitleGetter.getDocumentTitle( |
16 document.title, document.documentElement); | 16 document.title, document.documentElement); |
17 result[1] = com.dom_distiller.ContentExtractor.extractContent(); | 17 result[1] = com.dom_distiller.ContentExtractor.extractContent(); |
18 result[2] = com.dom_distiller.PagingLinksFinder.findNext( | 18 result[2] = com.dom_distiller.PagingLinksFinder.findNext( |
19 document.documentElement); | 19 document.documentElement); |
20 // TODO(shashishekhar): Add actual previous page link here. | 20 // TODO(shashishekhar): Add actual previous page link here. |
21 result[3] = ''; | 21 result[3] = ''; |
| 22 |
| 23 /** |
| 24 * // Properties from markup tags. |
| 25 * |
| 26 * var parser = new com.dom_distiller.MarkupParser(document.documentElement)
; |
| 27 * if (!parser.optOut()) { |
| 28 * // Basic properties. |
| 29 * var title = parser.getTitle(); // String type. |
| 30 * var pageType = parser.getType(); // String type. |
| 31 * var pageUrl = parser.getUrl(); // String type. |
| 32 * var author = parser.getAuthor(); // String type. |
| 33 * var description = parser.getDescription(); // String type. |
| 34 * var publisher = parser.getPublisher(); // String type. |
| 35 * var copyright = parser.getCopyright(); // String type. |
| 36 * |
| 37 * // Structured Image's. |
| 38 * var images = parser.getImages(); |
| 39 * for (var i = 0; i < images.length; i++) { |
| 40 * var image = images[i]; |
| 41 * var url = image.getUrl(); // String type. |
| 42 * var secureUrl = image.getSecureUrl(); // String type. |
| 43 * var type = image.getType(); // String type. |
| 44 * var caption = image.getCaption(); // String type. |
| 45 * var width = image.getWidth(); // int type. |
| 46 * var height = image.getHeight(); // int type. |
| 47 * } |
| 48 * |
| 49 * // Structured Article. |
| 50 * var article = parser.getArticle(); |
| 51 * if (article != null) { |
| 52 * var publishedTime = article.getPublishedTime(); // String type. |
| 53 * var modifiedTime = article.getModifiedTime(); // String type. |
| 54 * var expirationTime = article.getExpirationTime(); // String type. |
| 55 * var sectionName = article.getSection(); // String type. |
| 56 * var authors = article.getAuthors(); |
| 57 * for (var i = 0; i < authors.length; i++) { |
| 58 * var author = authors[i]; // String type. |
| 59 * } |
| 60 * } |
| 61 * } |
| 62 */ |
| 63 |
22 } catch (e) { | 64 } catch (e) { |
23 window.console.log("Error during distillation: " + e); | 65 window.console.log("Error during distillation: " + e); |
24 } | 66 } |
25 return result; | 67 return result; |
26 })() | 68 })() |
OLD | NEW |