Commit ccac53f9 authored by cjhopman@chromium.org's avatar cjhopman@chromium.org

Update DomDistillerJsUpdater and Roll DomDistillerJs

The update script should build `ant package` and copy the entire
out/package directory.

This moves the path to domdistiller.js to .../package/js so update
that reference.

The old (non-proto) API is still supported, so this keeps using that.

Picked up changes:
fdb023d Fix Proto module's path
44e9366 This adds two simple protoc plugins.

NOTRY=true

Review URL: https://codereview.chromium.org/277563002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269485 0039d316-1c4b-4281-b951-d872f2087c98
parent e80e1f1b
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// These includes will be processed at build time by grit. // These includes will be processed at build time by grit.
<include src="../../../../third_party/dom_distiller_js/js/domdistiller.js"/> <include src="../../../../third_party/dom_distiller_js/package/js/domdistiller.js"/>
// Extracts long-form content from a page and returns an array where the first // Extracts long-form content from a page and returns an array where the first
// element is the article title, the second element is HTML containing the // element is the article title, the second element is HTML containing the
......
Name: dom-distiller-js Name: dom-distiller-js
URL: https://code.google.com/p/dom-distiller URL: https://code.google.com/p/dom-distiller
Version: feccd237e1 Version: fdb023d039
License: BSD License: BSD
Security Critical: yes Security Critical: yes
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
syntax = "proto2";
package dom_distiller.proto;
option optimize_for = LITE_RUNTIME;
option java_package = "com.dom_distiller.proto";
option java_outer_classname = "DomDistillerProtos";
message DistilledContent {
optional string html = 1;
}
message PaginationInfo {
optional string next_page = 1;
optional string prev_page = 2;
optional string canonical_page = 3;
}
message DomDistillerResult {
optional string title = 1;
optional DistilledContent distilled_content = 2;
optional PaginationInfo pagination_info = 3;
repeated string image_urls = 4;
}
message DomDistillerOptions {
}
#include "dom_distiller_js/dom_distiller.pb.h"
// proto dependencies
// base dependencies
#include "base/values.h"
#include "base/memory/scoped_ptr.h"
#include <string>
namespace dom_distiller {
namespace proto {
namespace json {
class DistilledContent {
public:
static dom_distiller::proto::DistilledContent ReadFromValue(const base::Value* json) {
dom_distiller::proto::DistilledContent message;
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) goto error;
if (dict->HasKey("1")) {
std::string field_value;
if (!dict->GetString("1", &field_value)) {
goto error;
}
message.set_html(field_value);
}
return message;
error:
return dom_distiller::proto::DistilledContent();
}
static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::DistilledContent& message) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
if (message.has_html()) {
dict->SetString("1", message.html());
}
return dict.PassAs<base::Value>();
}
};
class PaginationInfo {
public:
static dom_distiller::proto::PaginationInfo ReadFromValue(const base::Value* json) {
dom_distiller::proto::PaginationInfo message;
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) goto error;
if (dict->HasKey("1")) {
std::string field_value;
if (!dict->GetString("1", &field_value)) {
goto error;
}
message.set_next_page(field_value);
}
if (dict->HasKey("2")) {
std::string field_value;
if (!dict->GetString("2", &field_value)) {
goto error;
}
message.set_prev_page(field_value);
}
if (dict->HasKey("3")) {
std::string field_value;
if (!dict->GetString("3", &field_value)) {
goto error;
}
message.set_canonical_page(field_value);
}
return message;
error:
return dom_distiller::proto::PaginationInfo();
}
static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::PaginationInfo& message) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
if (message.has_next_page()) {
dict->SetString("1", message.next_page());
}
if (message.has_prev_page()) {
dict->SetString("2", message.prev_page());
}
if (message.has_canonical_page()) {
dict->SetString("3", message.canonical_page());
}
return dict.PassAs<base::Value>();
}
};
class DomDistillerResult {
public:
static dom_distiller::proto::DomDistillerResult ReadFromValue(const base::Value* json) {
dom_distiller::proto::DomDistillerResult message;
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) goto error;
if (dict->HasKey("1")) {
std::string field_value;
if (!dict->GetString("1", &field_value)) {
goto error;
}
message.set_title(field_value);
}
if (dict->HasKey("2")) {
const base::Value* inner_message_value;
if (!dict->Get("2", &inner_message_value)) {
goto error;
}
*message.mutable_distilled_content() =
dom_distiller::proto::json::DistilledContent::ReadFromValue(inner_message_value);
}
if (dict->HasKey("3")) {
const base::Value* inner_message_value;
if (!dict->Get("3", &inner_message_value)) {
goto error;
}
*message.mutable_pagination_info() =
dom_distiller::proto::json::PaginationInfo::ReadFromValue(inner_message_value);
}
if (dict->HasKey("4")) {
const base::ListValue* field_list;
if (!dict->GetList("4", &field_list)) {
goto error;
}
for (size_t i = 0; i < field_list->GetSize(); ++i) {
std::string field_value;
if (!field_list->GetString(i, &field_value)) {
goto error;
}
message.add_image_urls(field_value);
}
}
return message;
error:
return dom_distiller::proto::DomDistillerResult();
}
static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::DomDistillerResult& message) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
if (message.has_title()) {
dict->SetString("1", message.title());
}
if (message.has_distilled_content()) {
scoped_ptr<base::Value> inner_message_value =
dom_distiller::proto::json::DistilledContent::WriteToValue(message.distilled_content());
dict->Set("2", inner_message_value.release());
}
if (message.has_pagination_info()) {
scoped_ptr<base::Value> inner_message_value =
dom_distiller::proto::json::PaginationInfo::WriteToValue(message.pagination_info());
dict->Set("3", inner_message_value.release());
}
base::ListValue* field_list = new base::ListValue();
dict->Set("4", field_list);
for (int i = 0; i < message.image_urls_size(); ++i) {
field_list->AppendString(message.image_urls(i));
}
return dict.PassAs<base::Value>();
}
};
class DomDistillerOptions {
public:
static dom_distiller::proto::DomDistillerOptions ReadFromValue(const base::Value* json) {
dom_distiller::proto::DomDistillerOptions message;
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) goto error;
return message;
error:
return dom_distiller::proto::DomDistillerOptions();
}
static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::DomDistillerOptions& message) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
return dict.PassAs<base::Value>();
}
};
}
}
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
( (
dom_distiller_js_path=third_party/dom_distiller_js dom_distiller_js_path=third_party/dom_distiller_js
compiled_js_path=$dom_distiller_js_path/js/domdistiller.js dom_distiller_js_package=$dom_distiller_js_path/package
readme_chromium=$dom_distiller_js_path/README.chromium readme_chromium=$dom_distiller_js_path/README.chromium
tmpdir=/tmp/domdistiller-$$ tmpdir=/tmp/domdistiller-$$
changes=/tmp/domdistiller.changes changes=/tmp/domdistiller.changes
...@@ -23,13 +23,14 @@ ...@@ -23,13 +23,14 @@
pushd $tmpdir pushd $tmpdir
git clone https://code.google.com/p/dom-distiller/ . git clone https://code.google.com/p/dom-distiller/ .
ant extractjs
new_gitsha=$(git rev-parse --short=10 HEAD) new_gitsha=$(git rev-parse --short=10 HEAD)
git log --oneline ${curr_gitsha}.. > $changes git log --oneline ${curr_gitsha}.. > $changes
ant package
popd popd
mkdir -p $(dirname $compiled_js_path) rm -rf $dom_distiller_js_package
cp $tmpdir/out/domdistiller.js $compiled_js_path mkdir $dom_distiller_js_package
cp -rf $tmpdir/out/package/* $dom_distiller_js_package
cp $tmpdir/LICENSE $dom_distiller_js_path/ cp $tmpdir/LICENSE $dom_distiller_js_path/
sed -i "s/Version: [0-9a-f]*/Version: $new_gitsha/" $readme_chromium sed -i "s/Version: [0-9a-f]*/Version: $new_gitsha/" $readme_chromium
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment