Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
add comments, inkl. sub-comments and included pictures as first level…
Browse files Browse the repository at this point in the history
… html element instead of parsin information provided in properties file. Updated css comment's width.
  • Loading branch information
andrew01ait committed Oct 16, 2015
1 parent a4fd00e commit e989e91
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,39 @@ private void genPosts(File out, String[] postXmls) throws IOException {
Img pic = new Img("Photo", FileUtils.getWayTo(out, picFile));
singlePost.appendChild(pic);
}
singlePost.setCSSClass("comment");
//get the comments (and sub comments + pictures contained in them) and attach them as HTML elements
List<Node> commentNodes = getCommentNodes(postXml.getParentFile(), out);
singlePost.setCSSClass("comment"); //we're misusing the comment css for general post layout purposes
singlePost.appendChild(wrapInfos(PostInfoKey.values(), props, true));
for (Node n : commentNodes) {
singlePost.appendChild(n);
}
postsDoc.body.appendChild(singlePost);
}

writeDocument(postsDoc, out);
}

/**
* Extracts the information provided within a commentinfo.xml file, resolves attached images and returns a HTML Node
* element which can be added to a HTML Document Node
*
* @param postOrPhotoXMLRootDir
* @param photoOrPostHTMLFile
* @return
* @throws IOException
*/
private List<Node> getCommentNodes(File postOrPhotoXMLRootDir, File photoOrPostHTMLFile) throws IOException {
List<Node> commentNodes = new ArrayList<>();
File comments = new File(postOrPhotoXMLRootDir, "comments");
if (comments.exists()) {
for (File f : comments.listFiles()) {
commentNodes.add(genComment(f, photoOrPostHTMLFile));
}
}
return commentNodes;
}

private void genAlbum(Properties albumProps, File albumXml, File albumHtml, File coverPhoto) throws IOException {
Document albumFile = new Document(DocumentType.HTMLTransitional);
File photoHtmlContainer = albumHtml.getParentFile();
Expand Down Expand Up @@ -212,14 +237,8 @@ private void genAlbum(Properties albumProps, File albumXml, File albumHtml, File
photoItem.appendChild(photoLink);
photoList.appendChild(photoItem);

List<Node> commentNodes = new ArrayList<>();
File comments = new File(photoXml.getParentFile(), photoProps.getProperty(PhotoInfoKey.COMMENT_DIR.toString()));
if (comments.exists()) {
for (File f : comments.listFiles()) {
commentNodes.add(genComment(f, photoHtml));
}
}

//get the comments and attach them as HTML elements
List<Node> commentNodes = getCommentNodes(photoXml.getParentFile(), photoHtml);
genPhotoFile(photoProps, photoHtml, photoXml, this.htmlDir, commentNodes.toArray(new Node[commentNodes.size()]));
}
}
Expand Down Expand Up @@ -396,24 +415,28 @@ private Table wrapInfos(SerializerKey[] aik, Properties albumsProps, boolean ski
value = unpackList(Arrays.asList(value.split(";")));
}
if (key.getType().equals(Datatype.OTHER) && key.getLabel().equals("Kommentare")) {
value = unpackComments(value);
//comments are now extracted from the commentInfo.xml instead of the files's properties
} else {
//in all other cases take the information provided from the properties file
Tr row = new Tr();
row.appendChild(new Td().appendText(key.getLabel()));
row.appendChild(new Td().appendText(value));
table.appendChild(row);

}
Tr row = new Tr();
row.appendChild(new Td().appendText(key.getLabel()));
row.appendChild(new Td().appendText(value));
table.appendChild(row);
}
}
return table;
}

/**
* Helper to tokenize Comments and extract human readable information Required as Comments aren't handled as data
* type TODO add comments as proper datatype, and remove post-parsing
* type. No longer required as comments are provided as proper datatype and we're able to remove post-parsing
*
* @param s
* @return
*/
@Deprecated
private String unpackComments(String s) {
String ret = "";
String token1 = "Comments[data=[";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ ul {

background:radial-gradient(#FFFFFF, #d0b193);
/* border:3px solid #000000; */
width:500px;
width:700px;
border-radius:20px;
margin-left:auto;
margin-right:auto;
Expand Down

0 comments on commit e989e91

Please sign in to comment.