diff options
-rw-r--r-- | conversion/CanConvert.java | 3 | ||||
-rw-r--r-- | conversion/CreateHtmlFile.java | 14 | ||||
-rw-r--r-- | license/Liberate.java | 2 | ||||
-rw-r--r-- | parsers/ParserList.java | 1 | ||||
-rw-r--r-- | parsers/Source.java | 36 |
5 files changed, 51 insertions, 5 deletions
diff --git a/conversion/CanConvert.java b/conversion/CanConvert.java index baf62c5..8f704e7 100644 --- a/conversion/CanConvert.java +++ b/conversion/CanConvert.java @@ -25,9 +25,10 @@ import java.io.*; public class CanConvert { private File htmlFile; + private CreateHtmlFile createHtml = new CreateHtmlFile(); private long modified1, modified2; public boolean check(File file) { - htmlFile = new File(file.getAbsolutePath()+".html"); + htmlFile = createHtml.create(file); modified1 = file.lastModified(); modified2 = htmlFile.lastModified(); if(modified1 > modified2) { diff --git a/conversion/CreateHtmlFile.java b/conversion/CreateHtmlFile.java index a502f7e..729b3cf 100644 --- a/conversion/CreateHtmlFile.java +++ b/conversion/CreateHtmlFile.java @@ -28,11 +28,19 @@ import scruf.status.*; public class CreateHtmlFile { private Pattern pattern = Pattern.compile("(.+?\\.)scruffy"); private Matcher matcher; + private File htmlFile=null; + /** + * This method uses PresentFile.file as the 'file' for + * which a corresponding 'htmlFile' has to be created. + */ public File create() { - File htmlFile=null; - matcher = pattern.matcher(PresentFile.file.getName()); + return create(PresentFile.file); + } + public File create(File file) { + htmlFile=null; + matcher = pattern.matcher(file.getName()); if(matcher.find()) { - htmlFile = new File(PresentFile.file.getParentFile(), + htmlFile = new File(file.getParentFile(), matcher.group(1)+"html"); }else { System.err.println("ERROR: something wrong with scruf: unable to create html file"+ diff --git a/license/Liberate.java b/license/Liberate.java index c7d1222..22ab291 100644 --- a/license/Liberate.java +++ b/license/Liberate.java @@ -67,7 +67,7 @@ public class Liberate { public static void main(String[] args) { Liberate libre = new Liberate(); - libre.baptize("./scruf/",".+\\.java"); + libre.baptize("./scruf/",".+\\.java$"); } }
\ No newline at end of file diff --git a/parsers/ParserList.java b/parsers/ParserList.java index 85e3d17..999dadc 100644 --- a/parsers/ParserList.java +++ b/parsers/ParserList.java @@ -38,6 +38,7 @@ public class ParserList { parsers.add(new Images()); parsers.add(new Footer()); parsers.add(new Paragraphs()); + parsers.add(new Source()); parsers.add(new BackButton()); parsers.add(new Header()); } diff --git a/parsers/Source.java b/parsers/Source.java new file mode 100644 index 0000000..4dbe303 --- /dev/null +++ b/parsers/Source.java @@ -0,0 +1,36 @@ +/*+ + * Copyright 2012 rsiddharth + * Email: <rsiddharth@ninthfloor.org> + * + * This file is part of Scruf. + * + * Scruf is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +package scruf.parsers; + +import scruf.status.*; + +public class Source implements Parser { + private StringBuilder sbuilder; + public String parse(String fileContent) { + sbuilder = new StringBuilder(fileContent); + // append a link to the source. + sbuilder.append("\n <div class=\"source\"> \n"); + sbuilder.append("\n <a href=\"./"+PresentFile.file.getName()+ + "\">source</a> \n </div>"); + return sbuilder.toString(); + } +} |