Skip to content

Commit

Permalink
Fixed bug which prevented non markdown files from being copied over d…
Browse files Browse the repository at this point in the history
…uring quick publish
  • Loading branch information
pawandubey committed Nov 30, 2015
1 parent 759454a commit c307880
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/pawandubey/griffin/DirectoryCrawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
import com.moandjiezana.toml.Toml;
import static com.pawandubey.griffin.Configurator.LINE_SEPARATOR;
import static com.pawandubey.griffin.Data.config;
import static com.pawandubey.griffin.renderer.HandlebarsRenderer.templateRoot;
import com.pawandubey.griffin.model.Page;
import com.pawandubey.griffin.model.Parsable;
import com.pawandubey.griffin.model.Post;
import static com.pawandubey.griffin.renderer.Renderer.templateRoot;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -168,14 +168,14 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
LocalDateTime fileModified = LocalDateTime.ofInstant(Files.getLastModifiedTime(file).toInstant(), ZoneId.systemDefault());
LocalDateTime lastParse = LocalDateTime.parse(InfoHandler.LAST_PARSE_DATE, InfoHandler.formatter);
Path resolvedPath = Paths.get(OUTPUT_DIRECTORY).resolve(rootPath.relativize(file));
if (fileModified.isAfter(lastParse)) {
if (Files.probeContentType(file).equals("text/x-markdown")) {
if (Files.probeContentType(file).equals("text/x-markdown")) {
if (fileModified.isAfter(lastParse)) {
Parsable parsable = createParsable(file);
Data.fileQueue.put(parsable);
}
else {
Files.copy(file, resolvedPath, StandardCopyOption.REPLACE_EXISTING);
}
}
else {
Files.copy(file, resolvedPath, StandardCopyOption.REPLACE_EXISTING);
}

}
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/pawandubey/griffin/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ private void renderIndexRssAnd404() throws IOException {
*/
protected void renderTags() throws IOException {
if (config.getRenderTags()) {
//System.out.println(tags.get("code").size());
for (List<Parsable> l : tags.values()) {
l.sort((s, t) -> {
return t.getDate().compareTo(s.getDate());
});
}
int numThreads = (tags.size() / 10) + 1;
ExecutorService tagExecutor = Executors.newFixedThreadPool(numThreads);
executorSet.add(tagExecutor);
Expand Down Expand Up @@ -197,8 +201,8 @@ protected void renderTags() throws IOException {
}
}

List<Parsable> parsables = tags.get(a);

List<Parsable> parsables = tags.get(a);
for (Parsable p : parsables) {
Path slugPath = tagDir.resolve(p.getSlug());
if (Files.notExists(slugPath)) {
Expand All @@ -219,9 +223,9 @@ protected void renderTags() throws IOException {
}
}
}

if (lock.tryLock()) {
try (BufferedWriter bw = Files.newBufferedWriter(tagDir.resolve("index.html"), StandardCharsets.UTF_8)) {
//System.out.println(a + " : " + tags.get(a));
try (BufferedWriter bw = Files.newBufferedWriter(tagDir.resolve("index.html"), StandardCharsets.UTF_8)) {
bw.write(renderer.renderTagIndex(a, parsables));
}
catch (IOException ex) {
Expand Down Expand Up @@ -291,7 +295,7 @@ private String readFile(Path p) {
private void writeParsedFile(Parsable p) throws IOException {
Path htmlPath = resolveHtmlPath(p);

if (config.getRenderTags()) {
if (config.getRenderTags() && p instanceof Post) {
resolveTags(p, htmlPath);
}

Expand Down

0 comments on commit c307880

Please sign in to comment.