Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

ScriptsToConcat.java/ScriptsToConcat.class that handles root relative URL's #101

Merged
merged 1 commit into from

2 participants

@tkahn

Implemented nelsams fix in the ScriptsToConcat.java file and compiled it
to a class file. This fixes the issue wher the build script couldn't
handle root relative URL's in the script tags. See issue #89.

@tkahn tkahn ScriptsToConcat.java works with root relative URL's
Implemented nelsams fix in the ScriptsToConcat.java file and compiled it
to a class file. This fixes the issue wher the build script couldn't
handle root relative URL's in the script tags.
8b53c80
@roblarsen
Collaborator

I have an alternative version of this script to integrate into the project. I'll capture this change and see what I can do.

@tkahn tkahn closed this
@roblarsen roblarsen reopened this
@roblarsen
Collaborator

I'm still happy to look at this for improvements to the java utility

@roblarsen roblarsen merged commit 2550e95 into h5bp:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 24, 2012
  1. @tkahn

    ScriptsToConcat.java works with root relative URL's

    tkahn authored
    Implemented nelsams fix in the ScriptsToConcat.java file and compiled it
    to a class file. This fixes the issue wher the build script couldn't
    handle root relative URL's in the script tags.
This page is out of date. Refresh to see the latest.
View
BIN  tools/ScriptsToConcat.class
Binary file not shown
View
107 tools/ScriptsToConcat.java
@@ -1,52 +1,55 @@
-// HTML5 boilerplate scripts parser
-// Daniel Holth <dholth@fastmail.fm.com>, 2012
-// Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
-
-import java.io.FileReader;
-import java.io.IOException;
-
-import javax.swing.text.MutableAttributeSet;
-import javax.swing.text.html.HTML;
-import javax.swing.text.html.HTML.Tag;
-import javax.swing.text.html.HTMLEditorKit.ParserCallback;
-import javax.swing.text.html.parser.ParserDelegator;
-
-
-/**
- * Parse an HTML file, printing the src attribute of all scripts
- * between magic <!-- scripts concatenated --> and <!-- end scripts --> comments.
- */
-public class ScriptsToConcat extends ParserCallback {
- private boolean emitting = false;
-
- @Override
- public void handleComment(char[] arg0, int arg1) {
- String text = new String(arg0);
- if(text.startsWith(" scripts concatenated ")) {
- emitting = true;
- } else if (text.startsWith(" end scripts ") ||
- text.startsWith(" end concatenated and minified scripts")) {
- emitting = false;
- }
- }
-
- @Override
- public void handleStartTag(Tag t, MutableAttributeSet a, int pos) {
- if(!emitting || t != HTML.Tag.SCRIPT) {
- return;
- }
- String scriptName = a.getAttribute(HTML.Attribute.SRC).toString();
- if(scriptName != null) {
- System.out.println(scriptName);
- }
- }
-
- public static void main(String args[]) throws IOException {
- if(args.length != 1) {
- System.err.println("Accepts exactly one argument: the filename of an HTML document.");
- System.exit(1);
- }
- FileReader fr = new FileReader(args[0]);
- new ParserDelegator().parse(fr, new ScriptsToConcat(), true);
- }
-}
+// HTML5 boilerplate scripts parser
+// Daniel Holth <dholth@fastmail.fm.com>, 2012
+// Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
+
+import java.io.FileReader;
+import java.io.IOException;
+
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.html.HTML;
+import javax.swing.text.html.HTML.Tag;
+import javax.swing.text.html.HTMLEditorKit.ParserCallback;
+import javax.swing.text.html.parser.ParserDelegator;
+
+
+/**
+ * Parse an HTML file, printing the src attribute of all scripts
+ * between magic <!-- scripts concatenated --> and <!-- end scripts --> comments.
+ */
+public class ScriptsToConcat extends ParserCallback {
+ private boolean emitting = false;
+
+ @Override
+ public void handleComment(char[] arg0, int arg1) {
+ String text = new String(arg0);
+ if(text.startsWith(" scripts concatenated ")) {
+ emitting = true;
+ } else if (text.startsWith(" end scripts ") ||
+ text.startsWith(" end concatenated and minified scripts")) {
+ emitting = false;
+ }
+ }
+
+ @Override
+ public void handleStartTag(Tag t, MutableAttributeSet a, int pos) {
+ if(!emitting || t != HTML.Tag.SCRIPT) {
+ return;
+ }
+ String scriptName = a.getAttribute(HTML.Attribute.SRC).toString();
+ if(scriptName != null) {
+ if(scriptName.startsWith("/")) {
+ System.out.println(scriptName);
+ }
+ System.out.println(scriptName);
+ }
+ }
+
+ public static void main(String args[]) throws IOException {
+ if(args.length != 1) {
+ System.err.println("Accepts exactly one argument: the filename of an HTML document.");
+ System.exit(1);
+ }
+ FileReader fr = new FileReader(args[0]);
+ new ParserDelegator().parse(fr, new ScriptsToConcat(), true);
+ }
+}
Something went wrong with that request. Please try again.