From fc76e4aea33e4a841f36b7edcce35fdbad2d8fbe Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 15 Dec 2012 23:25:11 +0530 Subject: bunch of new todos; 'todo' renamed to 'TODO'. removed: todo added: TODO --- TODO | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ todo | 43 ----------------------------------------- 2 files changed, 71 insertions(+), 43 deletions(-) create mode 100644 TODO delete mode 100644 todo diff --git a/TODO b/TODO new file mode 100644 index 0000000..8a29a3d --- /dev/null +++ b/TODO @@ -0,0 +1,71 @@ +SCRUF - TODO -*- mode: org; -*- + +* features + +** build system (GNU auto tools) + +** test suite + +** implement lists + introduce mark-up for lists. Weird that I have not implement + yet. + +** [hp] documentation + + introduction to 'scruf' & 'scruffy' mark-up. [started writing, but + might not get it done anytime in the near future.] + + +* distribution related + +** README file + a brief description of the project; pointer to website; notes on + the platform; a roadmap to important files; pointer to INSTALL + file; pointer to AUTHORS file; project news +** INSTALL file + contain installation instruction. +** AUTHORS file +** HISTORY file + this might is not needed at present. +** FAQ file + this might is not needed at present. +** checksum + md5sum. +** manual + the manual file should also be part of the source distribution. + +* website + +** mailing list + +** links to related projects + +* testing + +** build homepage + Test it by generating your _full_ homepage using scruf. + +* finished todos + +** [done] ignore directories + way to ignore directories + +** [done] move PresentFile.java to status/ + +** [done] extension for scruffy files + extension for scruff marked-up files to make discovery easier. + +** [done] modify conversion/CanConvert.java (bug) + +** [done] link to scruffy source + include a link or something to view the 'source'. + +** [done] 'quote' special symbols inside a code-block. +** [done] 'last update' string + the 'last updated' string must be dangled somewhere in the document + that is licked by scruf. + +** [done] tags + introduce 'meta' info in html doc generated -- authorinfo. + + diff --git a/todo b/todo deleted file mode 100644 index 6c20aab..0000000 --- a/todo +++ /dev/null @@ -1,43 +0,0 @@ -SCRUF - TODO -*- mode: org; -*- - -* features - -** implement lists - introduce mark-up for lists. Weird that I have not implement - yet. - - -** [hp] documentation - - introduction to 'scruf' & 'scruffy' mark-up. [started writing, but - might not get it done anytime in the near future.] - -* testing - -** build homepage - Test it by generating your _full_ homepage using scruf. - -* finished todos - -** [done] ignore directories - way to ignore directories - -** [done] move PresentFile.java to status/ - -** [done] extension for scruffy files - extension for scruff marked-up files to make discovery easier. - -** [done] modify conversion/CanConvert.java (bug) - -** [done] link to scruffy source - include a link or something to view the 'source'. - -** [done] 'quote' special symbols inside a code-block. -** [done] 'last update' string - the 'last updated' string must be dangled somewhere in the document - that is licked by scruf. - -** [done] tags - introduce 'meta' info in html doc generated -- authorinfo. - - -- cgit v1.2.3 From af6aefa0467762e1900da4740490deb43255e443 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Thu, 20 Dec 2012 10:53:55 +0530 Subject: [bug-fix]: Back Buttons were not put in webpages that were present in the "root" directory. This commit fixes this. modified: parsers/BackButton.java --- parsers/BackButton.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/parsers/BackButton.java b/parsers/BackButton.java index e504648..38e5a9e 100644 --- a/parsers/BackButton.java +++ b/parsers/BackButton.java @@ -29,14 +29,15 @@ public class BackButton implements Parser { // this method doesn't modify the filContent. public String parse(String fileContent) { StringBuilder fileBuilder = new StringBuilder(fileContent); + String fileName = PresentFile.file.getName(); /** * Back button is added only if the present directory being * parsed is not 'root'. */ - if(DirectoryInfo.level!=0) { + if(DirectoryInfo.level!=0 || !(fileName.equals("index.scruffy"))) { fileBuilder.append("\n
\n"); fileBuilder.append(" back "); }else { fileBuilder.append("./\"> back "); -- cgit v1.2.3 From 307571748a50fa6272ea13e6213e7d4d9d59c711 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Thu, 20 Dec 2012 11:03:14 +0530 Subject: SymbolMap class which was in CodeBlock.java is shifted to a dedicated file -- parsers/SymbolMap.java. added: parsers/SymbolMap.java modified: parsers/CodeBlocks.java --- parsers/CodeBlocks.java | 57 +-------------------------------------------- parsers/SymbolMap.java | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 56 deletions(-) create mode 100644 parsers/SymbolMap.java diff --git a/parsers/CodeBlocks.java b/parsers/CodeBlocks.java index 251c4de..75efa27 100644 --- a/parsers/CodeBlocks.java +++ b/parsers/CodeBlocks.java @@ -36,70 +36,15 @@ public class CodeBlocks implements Parser { while(matcher.find()) { replacement.delete(0,replacement.length()); replacement.append("
"); - replacement.append(lbreak.parse(quote(matcher.group(3)))); + replacement.append(lbreak.parse(symbolMap.quote(matcher.group(3)))); replacement.append("
"); matcher.appendReplacement(sbuffer,replacement.toString()); } matcher.appendTail(sbuffer); return sbuffer.toString(); } - /** - * this method quotes symbols to a HTML number. - */ - private String quote(String string) { - Pattern pattern = Pattern.compile("(\\&(amp|lt|gt|(\\#35))\\;)|(\\p{Punct})"); - Matcher matcher = pattern.matcher(string); - StringBuffer sbuffer = new StringBuffer(); - while(matcher.find()) { - if(matcher.group(4)!=null) { - matcher.appendReplacement(sbuffer, - symbolMap.get(matcher.group())); - } - } - matcher.appendTail(sbuffer); - return sbuffer.toString(); - } } -/** - * Map of Symbols & their HTML equivalent numbers. - */ -class SymbolMap extends HashMap { - public SymbolMap() { - put("!","!"); - put("\"","""); - put("#","#"); - put("$","$"); - put("%","%"); - put("&","&"); - put("'","'"); - put("(","("); - put(")",")"); - put("*","*"); - put("+","+"); - put(",",","); - put("-","-"); - put(".","."); - put("/","/"); - put(":",":"); - put(";",";"); - put("<","<"); - put("=","="); - put(">",">"); - put("?","?"); - put("@","@"); - put("[","["); - put("\\","\"); - put("]","]"); - put("^","^"); - put("_","_"); - put("`","`"); - put("{","{"); - put("|","|"); - put("}","}"); - put("~","~"); - } -} /** Special Case: diff --git a/parsers/SymbolMap.java b/parsers/SymbolMap.java new file mode 100644 index 0000000..94f1f14 --- /dev/null +++ b/parsers/SymbolMap.java @@ -0,0 +1,62 @@ + +package scruf.parsers; + +import java.util.regex.*; +import java.util.*; + +/** + * Map of Symbols & their HTML equivalent numbers. + */ +public class SymbolMap extends HashMap { + public SymbolMap() { + put("!","!"); + put("\"","""); + put("#","#"); + put("$","$"); + put("%","%"); + put("&","&"); + put("'","'"); + put("(","("); + put(")",")"); + put("*","*"); + put("+","+"); + put(",",","); + put("-","-"); + put(".","."); + put("/","/"); + put(":",":"); + put(";",";"); + put("<","<"); + put("=","="); + put(">",">"); + put("?","?"); + put("@","@"); + put("[","["); + put("\\","\"); + put("]","]"); + put("^","^"); + put("_","_"); + put("`","`"); + put("{","{"); + put("|","|"); + put("}","}"); + put("~","~"); + } + /** + * this method quotes symbols to a HTML number. + */ + public String quote(String string) { + Pattern pattern = Pattern.compile("(\\&(amp|lt|gt|(\\#35))\\;)|(\\p{Punct})"); + Matcher matcher = pattern.matcher(string); + StringBuffer sbuffer = new StringBuffer(); + while(matcher.find()) { + if(matcher.group(4)!=null) { + matcher.appendReplacement(sbuffer, + this.get(matcher.group())); + } + } + matcher.appendTail(sbuffer); + return sbuffer.toString(); + } +} + -- cgit v1.2.3 From 8843f4b84b9124502c7396a6a7cc87a7e076b779 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Thu, 20 Dec 2012 11:26:27 +0530 Subject: [bug-fix]: From now on, all the special characters in the string inside "monospace" blocks (the ones surrounded by ` character) are quoted to the corresponding HTML number. modified: parsers/WordDecoration.java --- parsers/WordDecoration.java | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/parsers/WordDecoration.java b/parsers/WordDecoration.java index 1df8cc6..e7cc0ac 100644 --- a/parsers/WordDecoration.java +++ b/parsers/WordDecoration.java @@ -28,13 +28,14 @@ import scruf.io.*; public class WordDecoration implements Parser { private HashMap tagMap; + private SymbolMap symbolMap; public WordDecoration() { tagMap = new HashMap(); tagMap.put("''","$7"); tagMap.put("__","$7"); tagMap.put("'''","$7"); tagMap.put("%%%","
$7
"); - tagMap.put("`","$7"); + symbolMap = new SymbolMap(); } public String parse(String fileContent) { Pattern pattern = @@ -44,10 +45,35 @@ public class WordDecoration implements Parser { StringBuffer sbuffer = new StringBuffer(); String replacement; while(matcher.find()) { - replacement = tagMap.get(matcher.group(1)); + // if the block found is a monospace block, + // get the replacement from 'monospaceBlock' + // method, else get it from the 'tagMap': + if(matcher.group(6)!=null) { + // group 7 is the string inside the word decorated + // mark up. (see the pattern above) + replacement = monospaceBlock(matcher.group(7)); + }else { + replacement = tagMap.get(matcher.group(1)); + } matcher.appendReplacement(sbuffer,replacement); } matcher.appendTail(sbuffer); return sbuffer.toString(); } + + // monopace blocks need special treatment, therefore, + // this method for its construction: + private String monospaceBlock(String content) { + // quote all special characters in the monospace + // block: + String quotedContent= symbolMap.quote(content); + + // build monospace HTML block: + StringBuilder sb = new StringBuilder(); + sb.append(""); + sb.append(quotedContent); + sb.append(""); + + return sb.toString(); + } } -- cgit v1.2.3 From 21c6704ad90ce094557274e6525c1a3b47a128af Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 21 Dec 2012 07:24:08 +0530 Subject: updated TODO modified: TODO --- TODO | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 8a29a3d..df33c12 100644 --- a/TODO +++ b/TODO @@ -12,38 +12,39 @@ SCRUF - TODO -*- mode: org; -*- ** [hp] documentation - introduction to 'scruf' & 'scruffy' mark-up. [started writing, but - might not get it done anytime in the near future.] - + introduction to 'scruf' & 'scruffy' mark-up. finished the initial + draft. It need to be edited and fine tuned. + +** mark-up to center align text * distribution related ** README file a brief description of the project; pointer to website; notes on the platform; a roadmap to important files; pointer to INSTALL - file; pointer to AUTHORS file; project news + file; pointer to AUTHORS file; project NEWS. ** INSTALL file - contain installation instruction. + point to the manual where installation instruction can be found. ** AUTHORS file +** NEWS file + should contain information about new releases and features(if + needed). ** HISTORY file - this might is not needed at present. + not required for 0.1.0 release. ** FAQ file - this might is not needed at present. + not required for 0.1.0 release. ** checksum md5sum. ** manual the manual file should also be part of the source distribution. -* website - -** mailing list +** package & upload it in savannah -** links to related projects +* website + +** create a documentation section in the homepage. -* testing - -** build homepage - Test it by generating your _full_ homepage using scruf. +** create a mailing list section in the homepage * finished todos @@ -68,4 +69,6 @@ SCRUF - TODO -*- mode: org; -*- ** [done] tags introduce 'meta' info in html doc generated -- authorinfo. - +** [done] mailing list +** [done] build rsiddharth's weblog + Test it by generating rsiddharth's weblog using scruf. -- cgit v1.2.3 From 92f629c0109fd23ed5859beb8b5f126318451469 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 21 Dec 2012 09:03:05 +0530 Subject: added license text to parsers/SymbolMap.java. modified: parsers/SymbolMap.java --- parsers/SymbolMap.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/parsers/SymbolMap.java b/parsers/SymbolMap.java index 94f1f14..752fcf6 100644 --- a/parsers/SymbolMap.java +++ b/parsers/SymbolMap.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; -- cgit v1.2.3 From 86c7e3798569604e83e9f13adfe232021cdb0967 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 21 Dec 2012 09:21:15 +0530 Subject: [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 --- Scruf.java | 2 -- conversion/ConvertDirectory.java | 29 +++++++++++++++++++++-------- 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) { -- cgit v1.2.3 From 3d807dc03b68d3991fdf3d7e147b5309bd6f3703 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 21 Dec 2012 09:25:21 +0530 Subject: [method named changed]: The method named 'resolve()' in styling/StyleChecker.java is changed to 'check()'. modified: conversion/ConvertDirectory.java styling/StyleChecker.java --- conversion/ConvertDirectory.java | 2 +- styling/StyleChecker.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conversion/ConvertDirectory.java b/conversion/ConvertDirectory.java index 32446da..87a0145 100644 --- a/conversion/ConvertDirectory.java +++ b/conversion/ConvertDirectory.java @@ -76,7 +76,7 @@ public class ConvertDirectory { // if styleFlag is set, check for style sheet in // in the directory. if(styleFlag) { - styleSheet.resolve(directory); + styleSheet.check(directory); } boolean convertIndex = (index.shouldConvert() || canConvert.check(index.indexFile())); diff --git a/styling/StyleChecker.java b/styling/StyleChecker.java index 68d7b46..3a2cc4e 100644 --- a/styling/StyleChecker.java +++ b/styling/StyleChecker.java @@ -28,7 +28,7 @@ public class StyleChecker { private File curDir; private String styleContent; - public void resolve(File curDir) { + public void check(File curDir) { this.curDir = curDir.getAbsoluteFile(); styleSheet = new File(curDir,"style.css"); // if style shee doesn't exists, copy default sheet -- cgit v1.2.3 From 7667485f10c7e95a9bfe8620cbc271870694e6f1 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 21 Dec 2012 09:29:01 +0530 Subject: Scruf.java has been renamed to Run.java removed: Scruf.java unknown: Run.java --- Scruf.java | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 Scruf.java diff --git a/Scruf.java b/Scruf.java deleted file mode 100644 index b8fa579..0000000 --- a/Scruf.java +++ /dev/null @@ -1,49 +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; - -import java.io.*; -import scruf.io.*; -import scruf.conversion.*; -import scruf.styling.*; -import scruf.status.*; -import scruf.index.*; - -public class Scruf { - public static void main(String[] args) { - Initialization init = new Initialization(args); - File list = init.getListFile(); - ReadFile readList = new ReadFile(list); - String dirs[] = readList.split("\n"); - File directory; - ConvertDirectory html = new ConvertDirectory(); - for(String dir:dirs) { - // if empty string, do nothing. - if(dir.length()==0) { - continue; - } - directory = new File(dir).getAbsoluteFile(); - DirectoryInfo.level=0; - html.convert(directory); - } - } -} -- cgit v1.2.3 From 03ab823d0318865544c54baaaa0b4ebb63fae4fa Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 21 Dec 2012 09:47:17 +0530 Subject: [bug-fix]: when the default style sheet is newer than the style sheet in that directory, the new default style sheet is copied to that directory. added Run.java to bzr (forgot to add it in the last commit) modified: styling/StyleChecker.java styling/style.css --- Run.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++ styling/StyleChecker.java | 14 +++++++++----- styling/style.css | 2 +- 3 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 Run.java diff --git a/Run.java b/Run.java new file mode 100644 index 0000000..582545d --- /dev/null +++ b/Run.java @@ -0,0 +1,49 @@ +/*+ + * 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; + +import java.io.*; +import scruf.io.*; +import scruf.conversion.*; +import scruf.styling.*; +import scruf.status.*; +import scruf.index.*; + +public class Run { + public static void main(String[] args) { + Initialization init = new Initialization(args); + File list = init.getListFile(); + ReadFile readList = new ReadFile(list); + String dirs[] = readList.split("\n"); + File directory; + ConvertDirectory html = new ConvertDirectory(); + for(String dir:dirs) { + // if empty string, do nothing. + if(dir.length()==0) { + continue; + } + directory = new File(dir).getAbsoluteFile(); + DirectoryInfo.level=0; + html.convert(directory); + } + } +} diff --git a/styling/StyleChecker.java b/styling/StyleChecker.java index 3a2cc4e..e70170a 100644 --- a/styling/StyleChecker.java +++ b/styling/StyleChecker.java @@ -23,18 +23,22 @@ package scruf.styling; import scruf.io.*; import java.io.*; + public class StyleChecker { private File styleSheet; private File curDir; private String styleContent; - + // the default style sheet in scruf package. + private File scrufStyleSheet = new File("scruf/styling/style.css"); public void check(File curDir) { this.curDir = curDir.getAbsoluteFile(); styleSheet = new File(curDir,"style.css"); - // if style shee doesn't exists, copy default sheet - // to the directory. - if(!styleSheet.exists()) { - styleContent = new ReadFile(new File("scruf/styling/style.css")).getContent(); + // if style sheet doesn't exists or if the default style is newer + // than style sheet in the directory, copy default sheet to the + // directory. + if((!styleSheet.exists()) || + scrufStyleSheet.lastModified() > styleSheet.lastModified()) { + styleContent = new ReadFile(scrufStyleSheet).getContent(); new WriteFile(styleSheet,styleContent).write(); } } diff --git a/styling/style.css b/styling/style.css index 9166be3..d6a533a 100644 --- a/styling/style.css +++ b/styling/style.css @@ -6,7 +6,7 @@ */ article { - font-size:1.50em; /* 1.88 */ + font-size:1.50em; font-family:"Palatino Linotype","Book Antiqua",Palatino,"URW Palladio L",FreeSerif,serif; color:#787878; margin-left:auto; -- cgit v1.2.3