From 14b1a9d7eb6d725df3c214d4e147fc1290856a50 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 26 Oct 2012 22:09:25 +0530 Subject: stylesheet modified --- styling/style.css | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/styling/style.css b/styling/style.css index 17e41a4..19d037f 100644 --- a/styling/style.css +++ b/styling/style.css @@ -1,8 +1,14 @@ +/* + Author: rsiddharth + Contact: + License: Public Domain + +*/ + article { - font-size:1.50em; /* 1.88 */ - font-style:normal; + font-size:1.50em; /* 1.88 */ font-family:"Palatino Linotype","Book Antiqua",Palatino,"URW Palladio L",FreeSerif,serif; - color:#686868; + color:#787878; margin-left:auto; margin-right:auto; border:1px; @@ -11,10 +17,10 @@ article { box-shadow: 1px 1.5px 3px 0.5px #bababa; } -h1, h2, h3, h4 { +h1, h2, h3, h4, h5 { margin-left:auto; - margin-right:auto; - border:1px; + margin-right:auto; + border:1px; padding:5px; width:75%; text-align:center; @@ -27,7 +33,7 @@ p, i, b{ width:70%; text-align:justify; line-height:170%; - /*-moz-word-wrap:break-word;*/ + -moz-word-wrap:break-word; } .center { text-align:center; @@ -36,7 +42,7 @@ p, i, b{ blockquote { font-size:0.77em; font-style:oblique; - color:#787878; + color:#888888; text-align:justify; background-color:#fcfcfc; margin-left:auto; @@ -64,6 +70,18 @@ div.code { width:65%; } +div.time { + font-size:0.50em; + font-family:"Palatino Linotype","Book Antiqua",Palatino,"URW Palladio L",FreeSerif,serif; + color:#aaaaaa; + margin-left:auto; + margin-right:auto; + border:1px; + padding:5px; + width:20%; + text-align:center; +} + img { margin-left:auto; margin-right:auto; @@ -71,6 +89,7 @@ img { border: 1px; padding: 10px; } + a:link,a:visited { transition:border-bottom 0.3s, color 0.3s; -moz-transition:border-bottom 0.3s, color 0.3s; @@ -87,10 +106,10 @@ a:hover,a:active { } div.back { - font-size:0.9em; + font-size:0.7em; font-family:junicode,"Palatino Linotype","Book Antiqua",Palatino,"URW Palladio L",FreeSerif,serif; text-align:center; - color:#686868; + color:#989898; margin-left:auto; margin-right:auto; border:1px; @@ -102,7 +121,7 @@ footer { font-size:0.8em; font-family:"Palatino Linotype","Book Antiqua",Palatino,"URW Palladio L",FreeSerif,serif; text-align:center; - color:#686868; + color:#989898; margin-left:auto; margin-right:auto; border:1px; -- cgit v1.2.3 From 0b6b2b85fe63ffc522f08700a5ea0fd7c51e25b7 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 26 Oct 2012 22:12:12 +0530 Subject: removed abstract --- abstract | 120 --------------------------------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 abstract diff --git a/abstract b/abstract deleted file mode 100644 index c85d7ae..0000000 --- a/abstract +++ /dev/null @@ -1,120 +0,0 @@ - Project Scruf. - - What. - -This is a "just for fun" project aiming at converting plain text -documents to html web pages. We are are focusing on producing -fundamental and simple web-pages which are clean, yet simple, we will -be using CSS to ease down on the design and the format of the web-pages -that are produced by the program. - -The plain text document will contain mark-ups that are to frilled by -the user for the program to identify different elements of the -document. For instance, a

heading should be surrounded by the -'==', as it is evident, the number of equals sign (=) is equal to the -heading number, a

heading should be surrounded '===='. - - - An illustration. - - a marked-up plain text document. - - -== heading two == - -this is paragraph *one*. - -this is paragraph _three_. - -Do you know how to /count/ ?. - - the html-converted plain text document. - - - -

this is paragraph one.

- -

this is paragraph three

- -

Do you know how to count - - - - - - - - Why. - -So why should we write a html conversion program from the scratch when -we have awesome suites like WordPress and the like. Why re-invent the -wheel ?. - -Here are few reasons by we desire to write from scratch : - - * If we have to adapt or modify an already existing converter, we - need to bunch of source files before we can even start thinking - about how to adapt it. It takes a lot of time to adapt - specifically to our needs. - - * This project aims to project a very very simple, clean and - small blogging program which can cater to the user without - the need MySQL, PHP or other complex programs. - - * We didn't start this project without a purpose, siddharth - wishes to exploit the html converter to host his verbal rambles - on his web site. - - How. - -How are we going to crunch this project ?. What follows gives some -details about the project. - - Platform - -The program will be compatible on GNU/Linux machines. We don't have -plans to have support for Windows/ Mac OSX machines. - - Programming Language. - -The suite will be written in the (filthy) Java programming -language. OpenJDK 6.0 will be used for compiling the programs. - - Cascading Style Sheets. - -The project will also write simple and clean stylesheets for properly -formatting and frilling the html documents that are produced by the -programs. - Documentation. - -A minimalistic documentation to learn the mark-ups will be made -available for the user to start writing marked-up plain text documents -ready for html conversion. - - Who - - Who is behind this project anyway ?. - - - * Sury Narayanan : He will responsible for writing - stylesheet to decorate the html docs. - - * Saravana Bharathy : He will writing the documentation for - the mark-ups for the plain text document. - - * Siddharth : He will be writing code for the project and he - will be the first user of the html converter. - - - Licensing. - -All programs written under the project scruf will be licensed under -the GNU General Public License v3 or later. - - - \ No newline at end of file -- cgit v1.2.3 From dbfd2dac27c947300c082ba0542650ecfec5a198 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 26 Oct 2012 23:33:44 +0530 Subject: modified: todo: list of things to be done. unknown: abstract --- todo | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/todo b/todo index f900683..d3c02c7 100644 --- a/todo +++ b/todo @@ -1,2 +1,16 @@ -IndexGenerator thingy has to be re-written. (why ? I seem to have -forgotten, need to invistigate). +# Write a introductory page for scruf. + + A scruffy begining. + + Liberated. + + Download. + + Rebuke, Critique, etc + + Improve. + +# Test it by generating your _full_ homepage using scruf. + +# Documentation on how to use scruf. + + + The documentation should introduce folks to the scruffy + mark-up. + + Tell them how scruf works. + + Tell them how they can use scruf. + -- cgit v1.2.3 From d7245231e63111092aa364a48a757d83720137ff Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 26 Oct 2012 23:34:55 +0530 Subject: added abstract --- abstract | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 abstract diff --git a/abstract b/abstract new file mode 100644 index 0000000..c85d7ae --- /dev/null +++ b/abstract @@ -0,0 +1,120 @@ + Project Scruf. + + What. + +This is a "just for fun" project aiming at converting plain text +documents to html web pages. We are are focusing on producing +fundamental and simple web-pages which are clean, yet simple, we will +be using CSS to ease down on the design and the format of the web-pages +that are produced by the program. + +The plain text document will contain mark-ups that are to frilled by +the user for the program to identify different elements of the +document. For instance, a

heading should be surrounded by the +'==', as it is evident, the number of equals sign (=) is equal to the +heading number, a

heading should be surrounded '===='. + + + An illustration. + + a marked-up plain text document. + + +== heading two == + +this is paragraph *one*. + +this is paragraph _three_. + +Do you know how to /count/ ?. + + the html-converted plain text document. + + + +

this is paragraph one.

+ +

this is paragraph three

+ +

Do you know how to count + + + + + + + + Why. + +So why should we write a html conversion program from the scratch when +we have awesome suites like WordPress and the like. Why re-invent the +wheel ?. + +Here are few reasons by we desire to write from scratch : + + * If we have to adapt or modify an already existing converter, we + need to bunch of source files before we can even start thinking + about how to adapt it. It takes a lot of time to adapt + specifically to our needs. + + * This project aims to project a very very simple, clean and + small blogging program which can cater to the user without + the need MySQL, PHP or other complex programs. + + * We didn't start this project without a purpose, siddharth + wishes to exploit the html converter to host his verbal rambles + on his web site. + + How. + +How are we going to crunch this project ?. What follows gives some +details about the project. + + Platform + +The program will be compatible on GNU/Linux machines. We don't have +plans to have support for Windows/ Mac OSX machines. + + Programming Language. + +The suite will be written in the (filthy) Java programming +language. OpenJDK 6.0 will be used for compiling the programs. + + Cascading Style Sheets. + +The project will also write simple and clean stylesheets for properly +formatting and frilling the html documents that are produced by the +programs. + Documentation. + +A minimalistic documentation to learn the mark-ups will be made +available for the user to start writing marked-up plain text documents +ready for html conversion. + + Who + + Who is behind this project anyway ?. + + + * Sury Narayanan : He will responsible for writing + stylesheet to decorate the html docs. + + * Saravana Bharathy : He will writing the documentation for + the mark-ups for the plain text document. + + * Siddharth : He will be writing code for the project and he + will be the first user of the html converter. + + + Licensing. + +All programs written under the project scruf will be licensed under +the GNU General Public License v3 or later. + + + \ No newline at end of file -- cgit v1.2.3 From f6f99c41dbd86f85ce816ea8d388e44e04aed6cc Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 27 Oct 2012 16:34:13 +0530 Subject: modified: .bzrignore conversion/ConvertDirectory.java (bug-fix) It is checked whether file "index" is modified since the last conversion. This check was not performed before. conversion/ConvertFile.java Some optimization there. Now we check if the file content is "empty" before we delve into conversion. index/IndexCreator.java # "index" file is created in the directory, if it is not created. # write() renamed to shouldConvert(). The method now returns true when a link is added to 'index' or when the index.html file does not exists. io/ReadFile.java # Exception message for made verbose. todo --- .bzrignore | 1 + conversion/ConvertDirectory.java | 5 +++-- conversion/ConvertFile.java | 44 +++++++++++++++++++++------------------- index/IndexCreator.java | 35 ++++++++++++++++++++++++-------- io/ReadFile.java | 2 +- todo | 7 ------- 6 files changed, 54 insertions(+), 40 deletions(-) diff --git a/.bzrignore b/.bzrignore index e19e389..499a518 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1,2 +1,3 @@ scribble *.class +test diff --git a/conversion/ConvertDirectory.java b/conversion/ConvertDirectory.java index 3cc6a36..3b70a71 100644 --- a/conversion/ConvertDirectory.java +++ b/conversion/ConvertDirectory.java @@ -55,8 +55,9 @@ public class ConvertDirectory { } } - boolean modified = index.write(); - if(modified) + boolean convertIndex = (index.shouldConvert() || + canConvert.check(index.indexFile())); + if(convertIndex) html.convert(index.indexFile()); } } diff --git a/conversion/ConvertFile.java b/conversion/ConvertFile.java index 37da060..6767717 100644 --- a/conversion/ConvertFile.java +++ b/conversion/ConvertFile.java @@ -30,28 +30,30 @@ public class ConvertFile { private List parsers; private ReadFile readFile; public ConvertFile() { - parsers = new ParserList().list(); + parsers = new ParserList().list(); } public void convert(File file) { - /** - * footer is optional, so it is null - * by default. - */ - PresentFile.footer = null; - /** - * takes the present file reference - * for use outside this method. - */ - PresentFile.file = file; - readFile = new ReadFile(file); - String fileContent = readFile.getContent(); - // start conversion. - for(Parser p:parsers) { - fileContent = p.parse(fileContent); - } - - // Write converted file to respective html file. - File outputFile = new File(file.getAbsolutePath()+".html"); - new WriteFile(outputFile,fileContent).write(); + /** + * footer is optional, so it is null + * by default. + */ + PresentFile.footer = null; + /** + * takes the present file reference + * for use outside this method. + */ + PresentFile.file = file; + readFile = new ReadFile(file); + String fileContent = readFile.getContent(); + if(!fileContent.equals("")) { + // start conversion. + for(Parser p:parsers) { + fileContent = p.parse(fileContent); + + } + } + // Write converted file to respective html file. + File outputFile = new File(file.getAbsolutePath()+".html"); + new WriteFile(outputFile,fileContent).write(); } } diff --git a/index/IndexCreator.java b/index/IndexCreator.java index fc469ce..f86f03a 100644 --- a/index/IndexCreator.java +++ b/index/IndexCreator.java @@ -33,13 +33,20 @@ public class IndexCreator { // set to true, if index file is modified. boolean modified = false; public IndexCreator(File directory) { - this.directory = directory; - index = new File(directory,"index"); - indexContent = new StringBuilder(); - if(index.exists()) { - indexContent.append(new ReadFile(index). - getContent()); - } + this.directory = directory; + index = new File(directory,"index"); + indexContent = new StringBuilder(); + if(index.exists()) { + indexContent.append(new ReadFile(index). + getContent()); + }else { + try { + index.createNewFile(); + }catch(IOException e) { + throw new RuntimeException("Unable to create file: "+ + index.getAbsolutePath(),e); + } + } } public void add(File file) { String fileName = file.getName(); @@ -53,10 +60,20 @@ public class IndexCreator { modified=true; } } - public boolean write() { + public boolean shouldConvert() { + // we assume that index.html exists. + boolean indexHTMLExists=true; if(modified) new WriteFile(index,indexContent.toString()).write(); - return modified; + // Check for this existence of index.html. + if(!(new File(directory,"index.html").exists())) { + indexHTMLExists=false; + } + /** + * returns true either when 'index' is modified or + * when index.html does not exists. + */ + return (modified || !indexHTMLExists); } public File indexFile() { return index; diff --git a/io/ReadFile.java b/io/ReadFile.java index beccdc3..2607b16 100644 --- a/io/ReadFile.java +++ b/io/ReadFile.java @@ -44,7 +44,7 @@ public class ReadFile { new FileReader(file)); }catch(FileNotFoundException e) { throw new RuntimeException("Unable to open file :" - +file.getName()); + +file.getAbsolutePath()); } String line; StringBuilder sbuilder = new StringBuilder(); diff --git a/todo b/todo index d3c02c7..42ffce6 100644 --- a/todo +++ b/todo @@ -1,10 +1,3 @@ -# Write a introductory page for scruf. - + A scruffy begining. - + Liberated. - + Download. - + Rebuke, Critique, etc - + Improve. - # Test it by generating your _full_ homepage using scruf. # Documentation on how to use scruf. -- cgit v1.2.3 From c07055c10835b0e639ca3f4ebaeac7daabf80b1d Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 27 Oct 2012 16:44:16 +0530 Subject: todo modified --- todo | 3 +++ 1 file changed, 3 insertions(+) diff --git a/todo b/todo index 42ffce6..fefc7f1 100644 --- a/todo +++ b/todo @@ -1,3 +1,6 @@ +# IndexCreator must be modified -- the existence of indexHtml can be + checked using CanConvert object. + # Test it by generating your _full_ homepage using scruf. # Documentation on how to use scruf. -- cgit v1.2.3 From 4d897569def8493a8b279bed8bb0a83a0c572c31 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Tue, 30 Oct 2012 22:27:59 +0530 Subject: added license info to parsers/DocumentDate.java --- parsers/DocumentDate.java | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/parsers/DocumentDate.java b/parsers/DocumentDate.java index 717fe25..7b66caa 100644 --- a/parsers/DocumentDate.java +++ b/parsers/DocumentDate.java @@ -1,3 +1,24 @@ +/*+ + * Copyright 2012 rsiddharth + * Email: + * + * 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 . + */ + + package scruf.parsers; import java.util.regex.*; @@ -14,4 +35,4 @@ public class DocumentDate implements Parser { matcher.appendTail(sbuffer); return sbuffer.toString(); } -} \ No newline at end of file +} -- cgit v1.2.3 From 0019988533c9c1b2a4bfad50b3e0427babefb1bb Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Tue, 30 Oct 2012 23:46:04 +0530 Subject: removed abstract --- abstract | 120 --------------------------------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 abstract diff --git a/abstract b/abstract deleted file mode 100644 index c85d7ae..0000000 --- a/abstract +++ /dev/null @@ -1,120 +0,0 @@ - Project Scruf. - - What. - -This is a "just for fun" project aiming at converting plain text -documents to html web pages. We are are focusing on producing -fundamental and simple web-pages which are clean, yet simple, we will -be using CSS to ease down on the design and the format of the web-pages -that are produced by the program. - -The plain text document will contain mark-ups that are to frilled by -the user for the program to identify different elements of the -document. For instance, a

heading should be surrounded by the -'==', as it is evident, the number of equals sign (=) is equal to the -heading number, a

heading should be surrounded '===='. - - - An illustration. - - a marked-up plain text document. - - -== heading two == - -this is paragraph *one*. - -this is paragraph _three_. - -Do you know how to /count/ ?. - - the html-converted plain text document. - - - -

this is paragraph one.

- -

this is paragraph three

- -

Do you know how to count - - - - - - - - Why. - -So why should we write a html conversion program from the scratch when -we have awesome suites like WordPress and the like. Why re-invent the -wheel ?. - -Here are few reasons by we desire to write from scratch : - - * If we have to adapt or modify an already existing converter, we - need to bunch of source files before we can even start thinking - about how to adapt it. It takes a lot of time to adapt - specifically to our needs. - - * This project aims to project a very very simple, clean and - small blogging program which can cater to the user without - the need MySQL, PHP or other complex programs. - - * We didn't start this project without a purpose, siddharth - wishes to exploit the html converter to host his verbal rambles - on his web site. - - How. - -How are we going to crunch this project ?. What follows gives some -details about the project. - - Platform - -The program will be compatible on GNU/Linux machines. We don't have -plans to have support for Windows/ Mac OSX machines. - - Programming Language. - -The suite will be written in the (filthy) Java programming -language. OpenJDK 6.0 will be used for compiling the programs. - - Cascading Style Sheets. - -The project will also write simple and clean stylesheets for properly -formatting and frilling the html documents that are produced by the -programs. - Documentation. - -A minimalistic documentation to learn the mark-ups will be made -available for the user to start writing marked-up plain text documents -ready for html conversion. - - Who - - Who is behind this project anyway ?. - - - * Sury Narayanan : He will responsible for writing - stylesheet to decorate the html docs. - - * Saravana Bharathy : He will writing the documentation for - the mark-ups for the plain text document. - - * Siddharth : He will be writing code for the project and he - will be the first user of the html converter. - - - Licensing. - -All programs written under the project scruf will be licensed under -the GNU General Public License v3 or later. - - - \ No newline at end of file -- cgit v1.2.3 From 1f61844084d9e9383b3be04ff8f60c11eb628075 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Wed, 31 Oct 2012 22:00:35 +0530 Subject: modified: conversion/ConvertDirectory.java (minor edit) index/IndexCreator.java (removed code which (1) creates a index file, if it is not present (2) checks for the existence of index.html) io/WriteFile.java (made the stdout message more verbose) parsers/Header.java ('scruf' footer links to scruf's project page) todo (1 task completed) --- conversion/ConvertDirectory.java | 1 - index/IndexCreator.java | 19 +------------------ io/WriteFile.java | 2 +- parsers/Header.java | 2 +- todo | 3 +-- 5 files changed, 4 insertions(+), 23 deletions(-) diff --git a/conversion/ConvertDirectory.java b/conversion/ConvertDirectory.java index 3b70a71..3dbb8eb 100644 --- a/conversion/ConvertDirectory.java +++ b/conversion/ConvertDirectory.java @@ -54,7 +54,6 @@ public class ConvertDirectory { this.convert(file); } } - boolean convertIndex = (index.shouldConvert() || canConvert.check(index.indexFile())); if(convertIndex) diff --git a/index/IndexCreator.java b/index/IndexCreator.java index f86f03a..ef683f7 100644 --- a/index/IndexCreator.java +++ b/index/IndexCreator.java @@ -39,13 +39,6 @@ public class IndexCreator { if(index.exists()) { indexContent.append(new ReadFile(index). getContent()); - }else { - try { - index.createNewFile(); - }catch(IOException e) { - throw new RuntimeException("Unable to create file: "+ - index.getAbsolutePath(),e); - } } } public void add(File file) { @@ -61,19 +54,9 @@ public class IndexCreator { } } public boolean shouldConvert() { - // we assume that index.html exists. - boolean indexHTMLExists=true; if(modified) new WriteFile(index,indexContent.toString()).write(); - // Check for this existence of index.html. - if(!(new File(directory,"index.html").exists())) { - indexHTMLExists=false; - } - /** - * returns true either when 'index' is modified or - * when index.html does not exists. - */ - return (modified || !indexHTMLExists); + return (modified); } public File indexFile() { return index; diff --git a/io/WriteFile.java b/io/WriteFile.java index d19bb72..0a2a1e7 100644 --- a/io/WriteFile.java +++ b/io/WriteFile.java @@ -32,7 +32,7 @@ public class WriteFile { } public void write() { try { - System.out.println("Writing..."+outputFile.getName()); + System.out.println("Writing..."+outputFile.getAbsolutePath()); BufferedWriter bwriter = new BufferedWriter (new FileWriter(outputFile)); // write content to file. diff --git a/parsers/Header.java b/parsers/Header.java index eebec5d..5cf2c55 100644 --- a/parsers/Header.java +++ b/parsers/Header.java @@ -55,7 +55,7 @@ public class Header implements Parser { sbuilder.append("\n"); // add "powered by scruf" at bottom of page. sbuilder.append("\n

\n"); - sbuilder.append("powered by scruf"); + sbuilder.append("powered by scruf"); sbuilder.append("\n
\n"); // Close body tag sbuilder.append("\n\n"); diff --git a/todo b/todo index fefc7f1..a302bdd 100644 --- a/todo +++ b/todo @@ -1,5 +1,4 @@ -# IndexCreator must be modified -- the existence of indexHtml can be - checked using CanConvert object. +# the root page (of a site) should not have a ''home'' or ''back'' button. # Test it by generating your _full_ homepage using scruf. -- cgit v1.2.3 From e1804b3d0ef3be3db8be169043c6eae8a98bbc86 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Wed, 31 Oct 2012 23:32:29 +0530 Subject: added: status/ status/DirectoryInfo.java (record the directory 'level' at which scruf is parsing with respect to 'root' directory.) modified: Scruf.java (added a line to start the directory level count at zero) conversion/ConvertDirectory.java (DirectoryInfo.level used to take count of directory 'leve') conversion/ConvertFile.java (lines related to 'footer' things were removed) io/PresentFile.java ( 'footer' & 'backButton' field removed) parsers/BackButton.java (back button placement happens in the parse method itself, instead of doing it in Header.java) (back button is not placed, if the present directory is root directory) parsers/Footer.java (footer placement happens in the parse method itself, instead of doing it in Header.java) parsers/Header.java (back button placement & footer placement removed.) --- Scruf.java | 2 ++ conversion/ConvertDirectory.java | 13 ++++++++++--- conversion/ConvertFile.java | 5 ----- io/PresentFile.java | 2 -- parsers/BackButton.java | 30 ++++++++++++++++++------------ parsers/Footer.java | 8 ++++---- parsers/Header.java | 6 ------ status/DirectoryInfo.java | 10 ++++++++++ 8 files changed, 44 insertions(+), 32 deletions(-) create mode 100644 status/DirectoryInfo.java diff --git a/Scruf.java b/Scruf.java index d632faf..fc8b310 100644 --- a/Scruf.java +++ b/Scruf.java @@ -25,6 +25,7 @@ import java.io.*; import scruf.io.*; import scruf.conversion.*; import scruf.styling.*; +import scruf.status.*; import scruf.index.*; public class Scruf { @@ -43,6 +44,7 @@ public class Scruf { } 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 3dbb8eb..2a0f6a9 100644 --- a/conversion/ConvertDirectory.java +++ b/conversion/ConvertDirectory.java @@ -23,6 +23,7 @@ package scruf.conversion; import java.io.*; import scruf.index.*; +import scruf.status.*; public class ConvertDirectory { private ConvertFile html; @@ -41,22 +42,28 @@ public class ConvertDirectory { // index creator for the present directory. IndexCreator index = new IndexCreator(directory); // iterate through the directory. + System.out.println("Current Directory: "+directory.getAbsolutePath()); for(File file:directory.listFiles(new FileSieve())) { if(file.isFile()) { can = canConvert.check(file); if(can) { - System.out.println("Converting..."+file.getName()); + System.out.println("Converting..."+file.getAbsolutePath()); html.convert(file); index.add(file); } } else if(file.isDirectory()) { - this.convert(file); + ++DirectoryInfo.level; + this.convert(file); } } boolean convertIndex = (index.shouldConvert() || canConvert.check(index.indexFile())); - if(convertIndex) + if(convertIndex) { + System.out.println("Converting..."+index.indexFile().getAbsolutePath()); html.convert(index.indexFile()); + } + --DirectoryInfo.level; } + } diff --git a/conversion/ConvertFile.java b/conversion/ConvertFile.java index 6767717..4f2d7bd 100644 --- a/conversion/ConvertFile.java +++ b/conversion/ConvertFile.java @@ -33,11 +33,6 @@ public class ConvertFile { parsers = new ParserList().list(); } public void convert(File file) { - /** - * footer is optional, so it is null - * by default. - */ - PresentFile.footer = null; /** * takes the present file reference * for use outside this method. diff --git a/io/PresentFile.java b/io/PresentFile.java index 14ca7b5..9a3deaa 100644 --- a/io/PresentFile.java +++ b/io/PresentFile.java @@ -30,8 +30,6 @@ import java.io.*; */ public class PresentFile { public static String name; - public static String footer; - public static String backButton; public static File file; } diff --git a/parsers/BackButton.java b/parsers/BackButton.java index 6dd37d1..0bba9b8 100644 --- a/parsers/BackButton.java +++ b/parsers/BackButton.java @@ -23,21 +23,27 @@ package scruf.parsers; import java.io.*; import scruf.io.*; +import scruf.status.*; public class BackButton implements Parser { // this method doesn't modify the filContent. public String parse(String fileContent) { - StringBuilder button = new StringBuilder(); - button.append("\n\n"); - PresentFile.backButton = button.toString(); - return fileContent; + StringBuilder fileBuilder = new StringBuilder(fileContent); + /** + * Back button is added only if the present directory being + * parsed is not 'root'. + */ + if(DirectoryInfo.level!=0) { + fileBuilder.append("\n
\n"); + fileBuilder.append(" back "); + }else { + fileBuilder.append("./\"> back "); + } + fileBuilder.append("\n"); + fileBuilder.append("
\n"); + } + return fileBuilder.toString(); } } diff --git a/parsers/Footer.java b/parsers/Footer.java index 7f079bd..6c1db65 100644 --- a/parsers/Footer.java +++ b/parsers/Footer.java @@ -28,11 +28,11 @@ public class Footer implements Parser { Pattern pattern = Pattern.compile("\\-{70}\\n(.+)\\n\\-{70}"); Matcher matcher = pattern.matcher(fileContent); StringBuffer sbuffer = new StringBuffer(); + String footer=null; while(matcher.find()) { - PresentFile.footer = "\n
"+matcher.group(1)+"
\n"; - fileContent = new NullIt().nullIt(fileContent,matcher.group()); + footer = "\n
"+matcher.group(1)+"
\n"; + matcher.appendReplacement(sbuffer,footer); } - - return fileContent; + return sbuffer.toString(); } } diff --git a/parsers/Header.java b/parsers/Header.java index 5cf2c55..3d9b846 100644 --- a/parsers/Header.java +++ b/parsers/Header.java @@ -46,12 +46,6 @@ public class Header implements Parser { sbuilder.append("
\n"); // insert File Content. sbuilder.append(fileContent); - // add footer if footer is available. - if(PresentFile.footer!=null) { - sbuilder.append(PresentFile.footer); - } - // insert back button. - sbuilder.append(PresentFile.backButton); sbuilder.append("
\n"); // add "powered by scruf" at bottom of page. sbuilder.append("\n
\n"); diff --git a/status/DirectoryInfo.java b/status/DirectoryInfo.java new file mode 100644 index 0000000..eb65de8 --- /dev/null +++ b/status/DirectoryInfo.java @@ -0,0 +1,10 @@ +package scruf.status; + +public class DirectoryInfo { + /** + * This variable stores the 'level' at which + * scruf is parsing the files with respect to + * root. + */ + public static int level; +} \ No newline at end of file -- cgit v1.2.3 From 49878fe422c5c97f7c4f8f7be3bad030c48f4d66 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Wed, 31 Oct 2012 23:49:12 +0530 Subject: modified: status/DirectoryInfo.java (added license info) todo (1 task complete) --- status/DirectoryInfo.java | 23 ++++++++++++++++++++++- todo | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/status/DirectoryInfo.java b/status/DirectoryInfo.java index eb65de8..d2cd191 100644 --- a/status/DirectoryInfo.java +++ b/status/DirectoryInfo.java @@ -1,3 +1,24 @@ +/*+ + * Copyright 2012 rsiddharth + * Email: + * + * 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 . + */ + + package scruf.status; public class DirectoryInfo { @@ -7,4 +28,4 @@ public class DirectoryInfo { * root. */ public static int level; -} \ No newline at end of file +} diff --git a/todo b/todo index a302bdd..b2bf0a3 100644 --- a/todo +++ b/todo @@ -1,4 +1,4 @@ -# the root page (of a site) should not have a ''home'' or ''back'' button. + # Test it by generating your _full_ homepage using scruf. -- cgit v1.2.3 From 0242880b18f077ee9fbb824188f97507a349a0ee Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Wed, 31 Oct 2012 23:54:45 +0530 Subject: updated todo --- todo | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/todo b/todo index b2bf0a3..1cb7aff 100644 --- a/todo +++ b/todo @@ -1,11 +1,4 @@ - +# introduction to 'scruffy' mark-up. # Test it by generating your _full_ homepage using scruf. -# Documentation on how to use scruf. - - + The documentation should introduce folks to the scruffy - mark-up. - + Tell them how scruf works. - + Tell them how they can use scruf. - -- cgit v1.2.3 From 14e4df00173c52b6d4932402614e2531eba9abd6 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Thu, 1 Nov 2012 10:07:41 +0530 Subject: added: parsers/QuoteSpecialText.java (new parser to quote special text) modified: parsers/CodeBlocks.java (the regex was made more strict) parsers/Footer.java (fix: appendTail() was added after while()) parsers/ParserList.java (new parser, see above) (parser order changed) todo --- parsers/CodeBlocks.java | 7 +++---- parsers/Footer.java | 1 + parsers/ParserList.java | 3 ++- parsers/QuoteSpecialText.java | 46 +++++++++++++++++++++++++++++++++++++++++++ todo | 1 - 5 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 parsers/QuoteSpecialText.java diff --git a/parsers/CodeBlocks.java b/parsers/CodeBlocks.java index 2c47099..64e8841 100644 --- a/parsers/CodeBlocks.java +++ b/parsers/CodeBlocks.java @@ -25,7 +25,7 @@ import java.util.regex.*; public class CodeBlocks implements Parser { public String parse(String fileContent) { - Pattern pattern = Pattern.compile("(\\#\\#\\#)(.+?)(\\1)", + Pattern pattern = Pattern.compile("(\\#\\#\\#)(\\n+)(.+?)(\\n+)(\\1)", Pattern.DOTALL); Matcher matcher = pattern.matcher(fileContent); LineBreak lbreak = new LineBreak(); @@ -34,7 +34,7 @@ public class CodeBlocks implements Parser { while(matcher.find()) { replacement.delete(0,replacement.length()); replacement.append("
"); - replacement.append(quote(lbreak.parse(matcher.group(2)))); + replacement.append(lbreak.parse(quote(matcher.group(3)))); replacement.append("
"); matcher.appendReplacement(sbuffer,replacement.toString()); } @@ -53,9 +53,8 @@ public class CodeBlocks implements Parser { StringBuffer sbuffer = new StringBuffer(); String rep; while(matcher.find()) { - rep = "\\\\\\"+matcher.group(); + rep = "\\\\\\"+matcher.group(); matcher.appendReplacement(sbuffer,rep); - } matcher.appendTail(sbuffer); return sbuffer.toString(); diff --git a/parsers/Footer.java b/parsers/Footer.java index 6c1db65..f8d85ae 100644 --- a/parsers/Footer.java +++ b/parsers/Footer.java @@ -33,6 +33,7 @@ public class Footer implements Parser { footer = "\n
"+matcher.group(1)+"
\n"; matcher.appendReplacement(sbuffer,footer); } + matcher.appendTail(sbuffer); return sbuffer.toString(); } } diff --git a/parsers/ParserList.java b/parsers/ParserList.java index f57a6b8..85e3d17 100644 --- a/parsers/ParserList.java +++ b/parsers/ParserList.java @@ -28,15 +28,16 @@ public class ParserList { public ParserList() { parsers = new ArrayList(); // add Parsers. NOTE: parser order is significant. + parsers.add(new QuoteSpecialText()); parsers.add(new DocumentName()); parsers.add(new DocumentDate()); parsers.add(new WordDecoration()); parsers.add(new CodeBlocks()); parsers.add(new Headings()); - parsers.add(new Paragraphs()); parsers.add(new Links()); parsers.add(new Images()); parsers.add(new Footer()); + parsers.add(new Paragraphs()); parsers.add(new BackButton()); parsers.add(new Header()); } diff --git a/parsers/QuoteSpecialText.java b/parsers/QuoteSpecialText.java new file mode 100644 index 0000000..165ffa9 --- /dev/null +++ b/parsers/QuoteSpecialText.java @@ -0,0 +1,46 @@ +/*+ + * Copyright 2012 rsiddharth + * Email: + * + * 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 . + */ + + +package scruf.parsers; + +import java.util.*; +import java.util.regex.*; + +public class QuoteSpecialText implements Parser { + Map qmap; + public QuoteSpecialText() { + qmap = new HashMap(); + qmap.put("&","&"); + qmap.put("<","<"); + qmap.put(">",">"); + } + public String parse(String fileContent) { + Pattern pattern = Pattern.compile("(\\&)|(\\<)|(\\>)"); + Matcher matcher = pattern.matcher(fileContent); + StringBuffer sbuffer = new StringBuffer(); + while(matcher.find()) { + matcher.appendReplacement(sbuffer, + qmap.get(matcher.group())); + } + matcher.appendTail(sbuffer); + return sbuffer.toString(); + } +} diff --git a/todo b/todo index 1cb7aff..cbc770b 100644 --- a/todo +++ b/todo @@ -1,4 +1,3 @@ # introduction to 'scruffy' mark-up. # Test it by generating your _full_ homepage using scruf. - -- cgit v1.2.3 From 090a72358df3f73752d7cbffa78783e459678c0f Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 2 Nov 2012 00:07:41 +0530 Subject: modified: parsers/Header.java (now the 'scruf' footer links to project's homepage) todo (new things to do) --- parsers/Header.java | 3 +-- todo | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/parsers/Header.java b/parsers/Header.java index 3d9b846..902d0c6 100644 --- a/parsers/Header.java +++ b/parsers/Header.java @@ -49,12 +49,11 @@ public class Header implements Parser { sbuilder.append("\n"); // add "powered by scruf" at bottom of page. sbuilder.append("\n
\n"); - sbuilder.append("powered by scruf"); + sbuilder.append("powered by scruf"); sbuilder.append("\n
\n"); // Close body tag sbuilder.append("\n\n"); sbuilder.append("\n"); - return sbuilder.toString(); } diff --git a/todo b/todo index cbc770b..6d4a79d 100644 --- a/todo +++ b/todo @@ -1,3 +1,7 @@ +# way to ignore directories + +# extension for scruff marked-up files to make discovery easier. + # introduction to 'scruffy' mark-up. # Test it by generating your _full_ homepage using scruf. -- cgit v1.2.3 From ce326bf6912e309453097632457739655c41da8a Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 4 Nov 2012 22:23:35 +0530 Subject: added: docs/ docs/scruf --- docs/scruf | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docs/scruf diff --git a/docs/scruf b/docs/scruf new file mode 100644 index 0000000..d9edf07 --- /dev/null +++ b/docs/scruf @@ -0,0 +1,21 @@ +scruffy + +========== +Scruffy +========== + +Scruffy is a mark-up that is out right shabby and squalid, it is, in a +way inspired from the markup used in MoinMoin and MediaWiki. If it is +desired that the text version of the HTML files, that are to be, +generated, look sane enough to be interpreted as ''plain text'', it is +suggested that you look for static HTML generators that accept +Markdown. Markdown looks sane. Scruffy, as the name implies, is an +insane markup. + +With that, I leave you, to make a choice, whether you wish to use +Scruffy, and thus Scruf, at all. + +============================== +basic structure +============================== + -- cgit v1.2.3 From 00a25a7ef03e25864019ef2e4f3fe5813ec292e9 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 9 Nov 2012 23:49:48 +0530 Subject: added: conversion/ignore/ conversion/ignore/Ignored.java (a class getting info about ignored child-directories, in the present directory) modified: conversion/ConvertDirectory.java (added code to check if the child-directory is in the ignored list) docs/scruf (started sketching out documentation on how to use scruf) styling/style.css todo --- conversion/ConvertDirectory.java | 12 +++++- conversion/ignore/Ignored.java | 33 +++++++++++++++ docs/scruf | 91 ++++++++++++++++++++++++++++++++++------ styling/style.css | 4 ++ todo | 10 ++++- 5 files changed, 134 insertions(+), 16 deletions(-) create mode 100644 conversion/ignore/Ignored.java diff --git a/conversion/ConvertDirectory.java b/conversion/ConvertDirectory.java index 2a0f6a9..a5717bb 100644 --- a/conversion/ConvertDirectory.java +++ b/conversion/ConvertDirectory.java @@ -24,6 +24,7 @@ package scruf.conversion; import java.io.*; import scruf.index.*; import scruf.status.*; +import scruf.conversion.ignore.*; public class ConvertDirectory { private ConvertFile html; @@ -39,6 +40,9 @@ public class ConvertDirectory { " No conversion done on."); return; } + // Ignored object maintains a list of 'ignored' sub-directories + // in this directory. + Ignored ignored = new Ignored(directory); // index creator for the present directory. IndexCreator index = new IndexCreator(directory); // iterate through the directory. @@ -53,8 +57,12 @@ public class ConvertDirectory { } } else if(file.isDirectory()) { - ++DirectoryInfo.level; - this.convert(file); + // Perform conversion, only if, directory + // is not a ignored directory. + if(!ignored.ignored(file)) { + ++DirectoryInfo.level; + this.convert(file); + } } } boolean convertIndex = (index.shouldConvert() || diff --git a/conversion/ignore/Ignored.java b/conversion/ignore/Ignored.java new file mode 100644 index 0000000..8129f18 --- /dev/null +++ b/conversion/ignore/Ignored.java @@ -0,0 +1,33 @@ +package scruf.conversion.ignore; + +import java.io.*; +import scruf.io.*; + +public class Ignored { + private String ignoredList[]; + public Ignored(File directory) { + File ignoredFile = new File(directory,".ignored"); + if(ignoredFile.exists()) { + ignoredList = new ReadFile(ignoredFile).split("\n"); + } + } + public boolean ignored(File subdirectory) { + boolean ignored = false; + if(ignoredList!=null) { + for(String dir:ignoredList) { + if(subdirectory.getName().matches(dir)) { + System.out.println("Ignoring Directory: "+ + subdirectory.getAbsolutePath()); + ignored = true; + break; + } + } + } + return ignored; + } +} + +/** + CVS/ + /home/rsd/projects/scruf/www/CVS/ + */ \ No newline at end of file diff --git a/docs/scruf b/docs/scruf index d9edf07..63f0b3e 100644 --- a/docs/scruf +++ b/docs/scruf @@ -1,21 +1,88 @@ -scruffy +scruf - documentation ========== -Scruffy +scruf - documentation ========== -Scruffy is a mark-up that is out right shabby and squalid, it is, in a -way inspired from the markup used in MoinMoin and MediaWiki. If it is -desired that the text version of the HTML files, that are to be, -generated, look sane enough to be interpreted as ''plain text'', it is -suggested that you look for static HTML generators that accept -Markdown. Markdown looks sane. Scruffy, as the name implies, is an -insane markup. + ''scruf'' is a simple program that converts text marked-up in +''scruffy'' mark-up to HTML5 files. It was written specifically for +generating blog posts. The way ''scruf'' works is straight forward -- +it takes in directory and converts all the ''scruffy'' marked-up +plain-text files into corresponding HTML5 files. After the conversion, +''scruf'' puts links to the generated HTML5 files in the `index.html` +file of that directory. So, that's how ''scruf'' works. -With that, I leave you, to make a choice, whether you wish to use -Scruffy, and thus Scruf, at all. +==================== +using scruf +==================== + +Before you plunge into learning about scruf and eventually using +it. Let me run you through the pre-requisites. + + '''Paraphernalia''': ''scruf'' is written in Java, therefore, you'll + need the `openjdk` package, inorder to be able to compile and run + scruf. Go ahead and install `openjdk` before proceeding + forward. Number two, ''scruf'' was written on a GNU/Linux machine, + so, it should work well on all Unix-based operating systems. + +Once, you have a copy of `openjdk` installed on your machine, you're +all set to start licking ''scruf''. Here we go. ============================== -basic structure +scruffy mark-up ============================== +Inorder to convert plain-text files into HTML5 using ''scruf'', you +got to mark it up with the ''scruff'' mark-up, so that ''scruf'' +understands the elements of the plain-text document and duly converts +them into HTML5. As the name suggests ''scruffy'' mark is pretty +shabby when compared to cleaner mark-ups like +[[http://daringfireball.net/projects/markdown/|Markdown]]. ''scruffy'' +is inspired, to an extent, from [[http://moinmo.in/|MoinMoin]] & +[[http://www.mediawiki.org/wiki/MediaWiki|MediaWiki]] syntax. + + +======================================== +basic structure +======================================== + +The ''scruffy'' plain-text document that is going to be converted by +''scruf'', follows a format and here it is: + +### + +title + +========== +foo heading +========== + +$$$ 1 January 1970 $$$ + +The bar blog post goes like this... +... +... +the bar blog post ends + +---------------------------------------------------------------------- +author's signature +---------------------------------------------------------------------- + +### + +The first line in the ''scruffy'' document __must__ always begin with +the text of the title of the document. The ''title'' is the string +that is going to be displayed on the browser tabs and for compliance +sake, it is recommended that it be same as the ''heading'' of the +''scruffy'' document. Followed by the ''title'' is the heading, then +the body of the post/essay/whatever and finally the author's +signature. This is the basic structure of a ''scruffy'' document. + + +======================================== +syntax +======================================== + +============================== +running scruf +============================== diff --git a/styling/style.css b/styling/style.css index 19d037f..02e71af 100644 --- a/styling/style.css +++ b/styling/style.css @@ -25,6 +25,10 @@ h1, h2, h3, h4, h5 { width:75%; text-align:center; } +h1 { + font-size:1.80em; +} + p, i, b{ margin-left:auto; margin-right:auto; diff --git a/todo b/todo index 6d4a79d..07afedf 100644 --- a/todo +++ b/todo @@ -1,7 +1,13 @@ -# way to ignore directories +# 'quote' special symbols inside a code-block. + +# include a link or something to view the 'source'. [working on this one] + +# introduce 'meta' info in html doc generated -- authorinfo, date of creation, etc. + +-- way to ignore directories -- [done] # extension for scruff marked-up files to make discovery easier. -# introduction to 'scruffy' mark-up. +* introduction to 'scruf' & 'scruffy' mark-up. [working on this one] # Test it by generating your _full_ homepage using scruf. -- cgit v1.2.3 From ceed73fa063ffb3b72d21c8a8800122c115acc58 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 10 Nov 2012 11:29:31 +0530 Subject: 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) --- conversion/ConvertFile.java | 8 +++++--- conversion/CreateHtmlFile.java | 22 ++++++++++++++++++++++ conversion/FileSieve.java | 14 ++++++++++++-- index/IndexCreator.java | 13 ++++++++----- io/PresentFile.java | 37 ------------------------------------- parsers/BackButton.java | 2 +- parsers/DocumentName.java | 2 +- parsers/Header.java | 2 +- status/PresentFile.java | 37 +++++++++++++++++++++++++++++++++++++ todo | 14 +++++++++----- 10 files changed, 96 insertions(+), 55 deletions(-) create mode 100644 conversion/CreateHtmlFile.java delete mode 100644 io/PresentFile.java create mode 100644 status/PresentFile.java diff --git a/conversion/ConvertFile.java b/conversion/ConvertFile.java index 4f2d7bd..5065ad0 100644 --- a/conversion/ConvertFile.java +++ b/conversion/ConvertFile.java @@ -25,12 +25,15 @@ import scruf.io.*; import scruf.parsers.*; import java.util.*; import java.io.*; +import scruf.status.*; public class ConvertFile { private List parsers; private ReadFile readFile; + private CreateHtmlFile htmlFile; public ConvertFile() { parsers = new ParserList().list(); + htmlFile = new CreateHtmlFile(); } public void convert(File file) { /** @@ -47,8 +50,7 @@ public class ConvertFile { } } - // Write converted file to respective html file. - File outputFile = new File(file.getAbsolutePath()+".html"); - new WriteFile(outputFile,fileContent).write(); + // Write to corresponding html file. + new WriteFile(htmlFile.create(),fileContent).write(); } } diff --git a/conversion/CreateHtmlFile.java b/conversion/CreateHtmlFile.java new file mode 100644 index 0000000..ecd86c1 --- /dev/null +++ b/conversion/CreateHtmlFile.java @@ -0,0 +1,22 @@ +package scruf.conversion; + +import java.io.*; +import java.util.regex.*; +import scruf.status.*; + +public class CreateHtmlFile { + private Pattern pattern = Pattern.compile("(.+?\\.)scruffy"); + private Matcher matcher; + public File create() { + File htmlFile=null; + matcher = pattern.matcher(PresentFile.file.getName()); + if(matcher.find()) { + htmlFile = new File(PresentFile.file.getParentFile(), + matcher.group(1)+"html"); + }else { + System.err.println("ERROR: something wrong with scruf: unable to create html file"+ + " for "+PresentFile.file.getName()); + } + return htmlFile; + } +} \ No newline at end of file diff --git a/conversion/FileSieve.java b/conversion/FileSieve.java index 8d53648..3571433 100644 --- a/conversion/FileSieve.java +++ b/conversion/FileSieve.java @@ -28,9 +28,19 @@ public class FileSieve implements FileFilter { // this method return true, if this file doesn't represent // a html file. public boolean accept(File pathname) { - Pattern pattern = Pattern.compile("(.+\\.(html|png|jpg|css|tar|ttf))|(.+?\\~)|(index)|(\\..+)|(\\#.+?\\#)"); + // check if this is a directory, if yes, accept immediately. + if(pathname.isDirectory() && (!pathname.isHidden())) { + return true; + } + Pattern pattern = Pattern.compile(".+?\\.scruffy$"); + Pattern indexPattern = Pattern.compile("^index\\.scruffy$"); Matcher matcher = pattern.matcher(pathname.getName()); + Matcher indexMatcher = indexPattern.matcher(pathname.getName()); boolean bool = matcher.find(); - return !bool; + if(bool) { + // don't 'accept' if the file is 'index.scruffy'. + bool = !(indexMatcher.find()); + } + return bool; } } 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; } diff --git a/io/PresentFile.java b/io/PresentFile.java deleted file mode 100644 index 9a3deaa..0000000 --- a/io/PresentFile.java +++ /dev/null @@ -1,37 +0,0 @@ -/*+ - * Copyright 2012 rsiddharth - * Email: - * - * 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 . - */ - - -package scruf.io; - -import java.io.*; - -/** - * Contains information about the present file that - * is being parsed by the parsers. - * - */ -public class PresentFile { - public static String name; - public static File file; -} - - - diff --git a/parsers/BackButton.java b/parsers/BackButton.java index 0bba9b8..e504648 100644 --- a/parsers/BackButton.java +++ b/parsers/BackButton.java @@ -36,7 +36,7 @@ public class BackButton implements Parser { if(DirectoryInfo.level!=0) { fileBuilder.append("\n
\n"); fileBuilder.append(" back "); }else { fileBuilder.append("./\"> back "); diff --git a/parsers/DocumentName.java b/parsers/DocumentName.java index 09eaf22..032d7c0 100644 --- a/parsers/DocumentName.java +++ b/parsers/DocumentName.java @@ -22,7 +22,7 @@ package scruf.parsers; import java.io.*; -import scruf.io.*; +import scruf.status.*; public class DocumentName implements Parser { public String parse(String fileContent) { diff --git a/parsers/Header.java b/parsers/Header.java index 902d0c6..50575c1 100644 --- a/parsers/Header.java +++ b/parsers/Header.java @@ -21,7 +21,7 @@ package scruf.parsers; -import scruf.io.*; +import scruf.status.*; public class Header implements Parser { diff --git a/status/PresentFile.java b/status/PresentFile.java new file mode 100644 index 0000000..303d4bc --- /dev/null +++ b/status/PresentFile.java @@ -0,0 +1,37 @@ +/*+ + * Copyright 2012 rsiddharth + * Email: + * + * 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 . + */ + + +package scruf.status; + +import java.io.*; + +/** + * Contains information about the present file that + * is being parsed by the parsers. + * + */ +public class PresentFile { + public static String name; + public static File file; +} + + + diff --git a/todo b/todo index 07afedf..d925074 100644 --- a/todo +++ b/todo @@ -1,13 +1,17 @@ -# 'quote' special symbols inside a code-block. +# modify conversion/CanConvert.java (bug) # include a link or something to view the 'source'. [working on this one] -# introduce 'meta' info in html doc generated -- authorinfo, date of creation, etc. - --- way to ignore directories -- [done] +# 'quote' special symbols inside a code-block. -# extension for scruff marked-up files to make discovery easier. +# introduce 'meta' info in html doc generated -- authorinfo, date of creation, etc. * introduction to 'scruf' & 'scruffy' mark-up. [working on this one] # Test it by generating your _full_ homepage using scruf. + +[done] way to ignore directories + +[done] move PresentFile.java to status/ + +[done] extension for scruff marked-up files to make discovery easier. \ No newline at end of file -- cgit v1.2.3 From 727d6d17305e6dbba4c5231fb40012b5adfaca1b Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 10 Nov 2012 11:38:40 +0530 Subject: baptized the following files with GPL license info: conversion/CreateHtmlFile.java conversion/ignore/Ignored.java --- conversion/CreateHtmlFile.java | 23 ++++++++++++++++++++++- conversion/ignore/Ignored.java | 23 ++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/conversion/CreateHtmlFile.java b/conversion/CreateHtmlFile.java index ecd86c1..a502f7e 100644 --- a/conversion/CreateHtmlFile.java +++ b/conversion/CreateHtmlFile.java @@ -1,3 +1,24 @@ +/*+ + * Copyright 2012 rsiddharth + * Email: + * + * 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 . + */ + + package scruf.conversion; import java.io.*; @@ -19,4 +40,4 @@ public class CreateHtmlFile { } return htmlFile; } -} \ No newline at end of file +} diff --git a/conversion/ignore/Ignored.java b/conversion/ignore/Ignored.java index 8129f18..a13434e 100644 --- a/conversion/ignore/Ignored.java +++ b/conversion/ignore/Ignored.java @@ -1,3 +1,24 @@ +/*+ + * Copyright 2012 rsiddharth + * Email: + * + * 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 . + */ + + package scruf.conversion.ignore; import java.io.*; @@ -30,4 +51,4 @@ public class Ignored { /** CVS/ /home/rsd/projects/scruf/www/CVS/ - */ \ No newline at end of file + */ -- cgit v1.2.3 From 75114f9ba449a3bafd9d4ddb986e50b772c3a237 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 10 Nov 2012 17:20:42 +0530 Subject: New Parser: Source; Bug-fix for conversion/CanConvert.java & license/Liberate.java. added: parsers/Source.java (New Parser, adds a link to the 'scruffy' source file) modified: conversion/CanConvert.java (bug-fix) conversion/CreateHtmlFile.java (we have two versions of the create() method now) license/Liberate.java (regex fix) parsers/ParserList.java (new parser added, see above) --- conversion/CanConvert.java | 3 ++- conversion/CreateHtmlFile.java | 14 +++++++++++--- license/Liberate.java | 2 +- parsers/ParserList.java | 1 + parsers/Source.java | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 parsers/Source.java 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: + * + * 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 . + */ + + +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 "); + return sbuilder.toString(); + } +} -- cgit v1.2.3 From ab443161eaa4cb631423884972108785ce764269 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 10 Nov 2012 17:26:55 +0530 Subject: updated todo --- todo | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/todo b/todo index d925074..a15e999 100644 --- a/todo +++ b/todo @@ -1,7 +1,3 @@ -# modify conversion/CanConvert.java (bug) - -# include a link or something to view the 'source'. [working on this one] - # 'quote' special symbols inside a code-block. # introduce 'meta' info in html doc generated -- authorinfo, date of creation, etc. @@ -14,4 +10,8 @@ [done] move PresentFile.java to status/ -[done] extension for scruff marked-up files to make discovery easier. \ No newline at end of file +[done] extension for scruff marked-up files to make discovery easier. + +[done] modify conversion/CanConvert.java (bug) + +[done] include a link or something to view the 'source'. \ No newline at end of file -- cgit v1.2.3