Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: third_party/polymer/v0_8/extract_inline_scripts.sh

Issue 1082403004: Import Polymer 0.8 and several key elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also remove polymer/explainer Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/polymer/v0_8/components/polymer/wct.conf.js ('k') | third_party/polymer/v0_8/reproduce.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/polymer/v0_8/extract_inline_scripts.sh
diff --git a/third_party/polymer/v0_8/extract_inline_scripts.sh b/third_party/polymer/v0_8/extract_inline_scripts.sh
new file mode 100755
index 0000000000000000000000000000000000000000..91fc6eaccb9d753c1a002236cc69b7c046d789f5
--- /dev/null
+++ b/third_party/polymer/v0_8/extract_inline_scripts.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# 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.
+
+set -e
+
+if [ "$#" -ne 2 ]
+then
+ echo "Usage: $0 <src_dir> <dst_dir>"
+ echo
+ echo "Copies <src_dir> to <dst_dir> and extracts all inline scripts from" \
+ "Polymer HTML files found in the destination directory to separate JS" \
+ "files. A JS file extracted from the file with name 'foo.html' will" \
+ "have a name 'foo-extracted.js'. Inclusion of the script file will be" \
+ "added to 'foo.html': '<script src=\"foo-extracted.js\"></script>'."
+ exit 1
+fi
+
+src="$1"
+dst="$2"
+
+if [ -e "$dst" ]
+then
+ echo "ERROR: '$dst' already exists. Please remove it before running the" \
+ "script." 1>&2
+ exit 1
+fi
+
+cp -r "$src" "$dst"
+find "$dst" -name "*.html" \
+ -not -path "*/demos/*" \
+ -not -path "*/test/*" \
+ -not -path "*/tests/*" \
+ -not -name "demo*.html" \
+ -not -name "index.html" \
+ -not -name "metadata.html" | \
+xargs grep -l "<script>" | \
+while read original_html_name
+do
+ dir=$(dirname "$original_html_name")
+ name=$(basename "$original_html_name" .html)
+
+ html_without_js="$dir/$name-extracted.html"
+ extracted_js="$dir/$name-extracted.js"
+ crisper --source "$original_html_name" --html "$html_without_js" --js "$extracted_js"
+ mv "$html_without_js" "$original_html_name"
+done
« no previous file with comments | « third_party/polymer/v0_8/components/polymer/wct.conf.js ('k') | third_party/polymer/v0_8/reproduce.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698