Skip to content

Commit

Permalink
configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
daileyet committed Aug 13, 2015
1 parent 09cb61b commit 42752d5
Show file tree
Hide file tree
Showing 29 changed files with 675 additions and 344 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.1.jar"/>
Expand Down
2 changes: 1 addition & 1 deletion src/logging.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Note that these classes must be on the system classpath.
# By default we only configure a ConsoleHandler, which will only
# show messages at the INFO and above levels.
handlers= java.util.logging.ConsoleHandler
handlers= openthinks.others.IgnoreJDKLoggerHander

# To also add the FileHandler, use the following line instead.
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
Expand Down
51 changes: 51 additions & 0 deletions src/openthinks/others/IgnoreJDKLoggerHander.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @Title: IgnoreJDKLoggerHander.java
* @Package openthinks.others
* @Description: TODO
* @author dailey.yet@outlook.com
* @date Aug 13, 2015
* @version V1.0
*/
package openthinks.others;

import java.util.logging.Handler;
import java.util.logging.LogRecord;

/**
* @author dailey.yet@outlook.com
*
*/
public class IgnoreJDKLoggerHander extends Handler {

@Override
public void publish(LogRecord record) {
}

@Override
public void flush() {

}

@Override
public void close() throws SecurityException {

}

}
112 changes: 0 additions & 112 deletions src/openthinks/others/safaribook/SafariBookConfigure.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@
* under the License.
*
* @Title: HtmlPageTransfer.java
* @Package openthinks.others.safaribook
* @Description: TODO
* @author dailey.yet@outlook.com
* @date Aug 11, 2015
* @version V1.0
*/
package openthinks.others.safaribook;
package openthinks.others.webpages;

import java.io.File;
import java.net.URL;
import java.util.Objects;
import java.util.regex.Pattern;

import openthinks.libs.utilities.CommonUtilities;
import openthinks.others.safaribook.agent.HtmlCssResourceAgent;
import openthinks.others.safaribook.agent.HtmlImageResourceAgent;
import openthinks.others.safaribook.agent.HtmlJsResourceAgent;
import openthinks.others.safaribook.agent.HtmlPageResourceAgent;
import openthinks.others.safaribook.keeper.HtmlResourceKeeper;
import openthinks.others.safaribook.util.ProcessLoger;
import openthinks.others.webpages.agent.HtmlCssResourceAgent;
import openthinks.others.webpages.agent.HtmlImageResourceAgent;
import openthinks.others.webpages.agent.HtmlJsResourceAgent;
import openthinks.others.webpages.agent.HtmlPageResourceAgent;
import openthinks.others.webpages.keeper.HtmlResourceKeeper;
import openthinks.others.webpages.util.ProcessLoger;

import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlImage;
Expand Down Expand Up @@ -117,8 +116,7 @@ void processAnchors() {
}

void processPage() {
final HtmlResourceKeeper<HtmlPageResourceAgent> keeper = new HtmlResourceKeeper<HtmlPageResourceAgent>(
htmlPage, keepDir);
final HtmlResourceKeeper keeper = new HtmlResourceKeeper(htmlPage, keepDir);
keeper.initial(htmlPage.getUrl(), () -> {
return new HtmlPageResourceAgent(keeper);
}).keep();
Expand All @@ -133,54 +131,41 @@ void processStylesheets() {
&& !linkNode.getAttribute("href").isEmpty()
&& "stylesheet".equalsIgnoreCase(linkNode.getAttribute("rel"));

})
.forEach(
(linkNode) -> {
HtmlLink link = (HtmlLink) linkNode;
final HtmlResourceKeeper<HtmlCssResourceAgent> keeper = new HtmlResourceKeeper<HtmlCssResourceAgent>(
link, getCssKeepDir());
URL url = getFullyQualifiedUrl(link.getHrefAttribute());
keeper.initial(url, () -> {
return new HtmlCssResourceAgent(keeper);
}).keep();
});
}).forEach((linkNode) -> {
HtmlLink link = (HtmlLink) linkNode;
final HtmlResourceKeeper keeper = new HtmlResourceKeeper(link, getCssKeepDir());
URL url = getFullyQualifiedUrl(link.getHrefAttribute());
keeper.initial(url, () -> {
return new HtmlCssResourceAgent(keeper);
}).keep();
});
}

void processImgElements() {
htmlPage.getElementsByTagName("img")
.stream()
.filter((domNode) -> {
return domNode.hasAttribute("src") && !domNode.getAttribute("src").isEmpty();
})
.forEach(
(imgNode) -> {
HtmlImage el = (HtmlImage) imgNode;
final HtmlResourceKeeper<HtmlImageResourceAgent> keeper = new HtmlResourceKeeper<HtmlImageResourceAgent>(
el, getImageKeepDir());
URL url = getFullyQualifiedUrl(imgNode.getAttribute("src"));
keeper.initial(url, () -> {
return new HtmlImageResourceAgent(keeper);
}).keep();

});
htmlPage.getElementsByTagName("img").stream().filter((domNode) -> {
return domNode.hasAttribute("src") && !domNode.getAttribute("src").isEmpty();
}).forEach((imgNode) -> {
HtmlImage el = (HtmlImage) imgNode;
final HtmlResourceKeeper keeper = new HtmlResourceKeeper(el, getImageKeepDir());
URL url = getFullyQualifiedUrl(imgNode.getAttribute("src"));
keeper.initial(url, () -> {
return new HtmlImageResourceAgent(keeper);
}).keep();

});
}

void processScriptElements() {
htmlPage.getElementsByTagName("script")
.stream()
.filter((domNode) -> {
return domNode.hasAttribute("src") && !domNode.getAttribute("src").isEmpty();
})
.forEach(
(scriptNode) -> {

final HtmlResourceKeeper<HtmlJsResourceAgent> keeper = new HtmlResourceKeeper<HtmlJsResourceAgent>(
(HtmlScript) scriptNode, getJsKeepDir());
URL url = getFullyQualifiedUrl(scriptNode.getAttribute("src"));
keeper.initial(url, () -> {
return new HtmlJsResourceAgent(keeper);
}).keep();
});
htmlPage.getElementsByTagName("script").stream().filter((domNode) -> {
return domNode.hasAttribute("src") && !domNode.getAttribute("src").isEmpty();
}).forEach((scriptNode) -> {

final HtmlResourceKeeper keeper = new HtmlResourceKeeper((HtmlScript) scriptNode, getJsKeepDir());
URL url = getFullyQualifiedUrl(scriptNode.getAttribute("src"));
keeper.initial(url, () -> {
return new HtmlJsResourceAgent(keeper);
}).keep();
});
}

/**
Expand Down
Loading

0 comments on commit 42752d5

Please sign in to comment.