aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <rsiddharth@ninthfloor.org>2012-12-21 09:21:15 +0530
committerrsiddharth <rsiddharth@ninthfloor.org>2012-12-21 09:21:15 +0530
commit86c7e3798569604e83e9f13adfe232021cdb0967 (patch)
tree29b185937090e09f800bc01a907891389505f7d2
parent92f629c0109fd23ed5859beb8b5f126318451469 (diff)
downloadscruf-86c7e3798569604e83e9f13adfe232021cdb0967.tar.gz
scruf-86c7e3798569604e83e9f13adfe232021cdb0967.tar.bz2
scruf-86c7e3798569604e83e9f13adfe232021cdb0967.tar.xz
scruf-86c7e3798569604e83e9f13adfe232021cdb0967.zip
[bug-fix]: Each directory is checked if it contains the style.css, if
not present a new style.css in copied to the respective location. To reflect this, styling.StyleChecker class is used in conversion.ConvertDirectory instead of scruf.Scruf. modified: Scruf.java conversion/ConvertDirectory.java
-rw-r--r--Scruf.java2
-rw-r--r--conversion/ConvertDirectory.java29
2 files changed, 21 insertions, 10 deletions
diff --git a/Scruf.java b/Scruf.java
index fc8b310..b8fa579 100644
--- a/Scruf.java
+++ b/Scruf.java
@@ -36,14 +36,12 @@ public class Scruf {
String dirs[] = readList.split("\n");
File directory;
ConvertDirectory html = new ConvertDirectory();
- StyleChecker styleSheet = new StyleChecker();
for(String dir:dirs) {
// if empty string, do nothing.
if(dir.length()==0) {
continue;
}
directory = new File(dir).getAbsoluteFile();
- styleSheet.resolve(directory);
DirectoryInfo.level=0;
html.convert(directory);
}
diff --git a/conversion/ConvertDirectory.java b/conversion/ConvertDirectory.java
index a5717bb..32446da 100644
--- a/conversion/ConvertDirectory.java
+++ b/conversion/ConvertDirectory.java
@@ -25,14 +25,18 @@ import java.io.*;
import scruf.index.*;
import scruf.status.*;
import scruf.conversion.ignore.*;
+import scruf.styling.*;
public class ConvertDirectory {
private ConvertFile html;
private CanConvert canConvert;
private boolean can;
+ private StyleChecker styleSheet;
+ private boolean styleFlag;
public ConvertDirectory() {
- html = new ConvertFile();
- canConvert = new CanConvert();
+ html = new ConvertFile();
+ canConvert = new CanConvert();
+ styleSheet = new StyleChecker();
}
public void convert(File directory) {
if(!directory.isDirectory()) {
@@ -47,14 +51,18 @@ public class ConvertDirectory {
IndexCreator index = new IndexCreator(directory);
// iterate through the directory.
System.out.println("Current Directory: "+directory.getAbsolutePath());
+ // reset styleFlag.
+ styleFlag = false;
for(File file:directory.listFiles(new FileSieve())) {
if(file.isFile()) {
- can = canConvert.check(file);
- if(can) {
- System.out.println("Converting..."+file.getAbsolutePath());
- html.convert(file);
- index.add(file);
- }
+ can = canConvert.check(file);
+ if(can) {
+ System.out.println("Converting..."+file.getAbsolutePath());
+ html.convert(file);
+ index.add(file);
+ // set styleFlag.
+ styleFlag = true;
+ }
}
else if(file.isDirectory()) {
// Perform conversion, only if, directory
@@ -65,6 +73,11 @@ public class ConvertDirectory {
}
}
}
+ // if styleFlag is set, check for style sheet in
+ // in the directory.
+ if(styleFlag) {
+ styleSheet.resolve(directory);
+ }
boolean convertIndex = (index.shouldConvert() ||
canConvert.check(index.indexFile()));
if(convertIndex) {