summaryrefslogtreecommitdiffstats
path: root/index
diff options
context:
space:
mode:
authorrsiddharth <rsiddharth@ninthfloor.org>2012-11-10 11:29:31 +0530
committerrsiddharth <rsiddharth@ninthfloor.org>2012-11-10 11:29:31 +0530
commitceed73fa063ffb3b72d21c8a8800122c115acc58 (patch)
treee6519430ea904e1e7842b17e1ad177a17ef5bfb4 /index
parent00a25a7ef03e25864019ef2e4f3fe5813ec292e9 (diff)
marked-up files should have a '.scruffy' extension from now on. This
commit is an un-stable commit. It has bugs. removed: io/PresentFile.java (moved to status/PresentFile.java) added: conversion/CreateHtmlFile.java (creates a corresponding '.html' file for a given '.scruffy' marked-up file) (needs some fine-tuning) status/PresentFile.java (see above) modified: conversion/ConvertFile.java (CreatHtmlFile object takes care of producing a corresponding html 'File') conversion/FileSieve.java (regex modified to reflect the '.scruffy' extension) index/IndexCreator.java (edits to reflect the '.scruffy' extension) parsers/BackButton.java (edit to reflect the '.scruffy' extension) parsers/DocumentName.java (edit to reflect the package change for PresentFile class) parsers/Header.java (edit to reflect the package change for PresentFile class) todo (updated todo)
Diffstat (limited to 'index')
-rw-r--r--index/IndexCreator.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/index/IndexCreator.java b/index/IndexCreator.java
index ef683f7..e06db24 100644
--- a/index/IndexCreator.java
+++ b/index/IndexCreator.java
@@ -25,28 +25,31 @@ import java.io.*;
import java.util.regex.*;
import scruf.io.*;
import scruf.conversion.*;
+import scruf.status.*;
public class IndexCreator {
private File directory;
private File index;
+ private CreateHtmlFile htmlFile;
private StringBuilder indexContent;
// set to true, if index file is modified.
boolean modified = false;
public IndexCreator(File directory) {
this.directory = directory;
- index = new File(directory,"index");
+ index = new File(directory,"index.scruffy");
indexContent = new StringBuilder();
if(index.exists()) {
indexContent.append(new ReadFile(index).
getContent());
}
+ htmlFile = new CreateHtmlFile();
}
public void add(File file) {
- String fileName = file.getName();
+ String fileName = htmlFile.create().getName();
if(shouldAdd(fileName)) {
System.out.println("New Entry: "+fileName);
indexContent.append("[[./");
- indexContent.append(fileName+".html");
+ indexContent.append(fileName);
indexContent.append("|");
indexContent.append(PresentFile.name);
indexContent.append("]]\n");
@@ -56,7 +59,7 @@ public class IndexCreator {
public boolean shouldConvert() {
if(modified)
new WriteFile(index,indexContent.toString()).write();
- return (modified);
+ return modified;
}
public File indexFile() {
return index;
@@ -67,7 +70,7 @@ public class IndexCreator {
boolean check1 = !(Pattern.compile(regex).
matcher(indexContent.toString()).find());
// checks if fileName is index itself.
- boolean check2 = !(Pattern.matches(fileName,"index"));
+ boolean check2 = !(Pattern.matches(fileName,"index.scruffy"));
boolean add = (check1 && check2);
return add;
}