Skip to content

Commit

Permalink
Merge pull request #24 from gradha/pr_tag_improvements
Browse files Browse the repository at this point in the history
Tag improvements
  • Loading branch information
dom96 committed Mar 25, 2014
2 parents 00023c2 + 2f5b00f commit 135e6be
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
25 changes: 16 additions & 9 deletions ipsum.nim
@@ -1,7 +1,8 @@
# Copyright (C) 2013 Dominik Picheta
# Licensed under MIT license.

import os, times, strutils, algorithm, strtabs, parseutils, tables, xmltree
import os, times, strutils, algorithm, strtabs, parseutils, tables, xmltree,
sequtils

import src/metadata, src/rstrender, src/config

Expand Down Expand Up @@ -143,10 +144,14 @@ proc generateArticle(filename, dest, style: string, meta: TArticleMetadata,

writeFile(path, output)

proc generateStatic(cfg: TConfig) =
## Generates rst files found in the static subdirectory.
proc processStatic(cfg: TConfig): seq[TArticleMetadata] =
## Processes files found in the static subdirectory.
##
## Non rst files will be copied as is.
## Non rst files will be copied as is, rst files will be processed with the
## static template.
##
## The proc will return the list of the metadata for parsed rst files.
result = @[]
let staticFilenames = findStaticFiles()
for i in staticFilenames:
let
Expand All @@ -159,6 +164,7 @@ proc generateStatic(cfg: TConfig) =
if meta.isDraft:
echo(" Article is a draft, omitting from article list.")
continue
result.add(meta)
generateArticle(src, dest, "static.html", meta, cfg)
else:
let dest = getCurrentDir() / outputDir / i
Expand Down Expand Up @@ -225,8 +231,9 @@ proc generateAtomFeed(meta: seq[TArticleMetadata], cfg: TConfig) =
when isMainModule:
let cfg = parseConfig(getCurrentDir() / "ipsum.ini")
createDir(getCurrentDir() / outputDir)
generateStatic(cfg)
let articles = processArticles(cfg)
generateDefault(articles, cfg)
generateTagPages(articles, cfg)
generateAtomFeed(articles, cfg)
let
staticMetadata = processStatic(cfg)
blogMetadata = processArticles(cfg)
generateDefault(blogMetadata, cfg)
generateTagPages(concat(blogMetadata, staticMetadata), cfg)
generateAtomFeed(blogMetadata, cfg)
3 changes: 2 additions & 1 deletion src/metadata.nim
Expand Up @@ -78,4 +78,5 @@ proc parseMetadata*(filename: string): TArticleMetadata =
raise newException(EInvalidValue, "Unknown key: " & key)
i.inc 3 # skip ---
i.inc skipWhitespace(article, i)
result.body = article[i .. -1]
result.body = article[i .. -1]
if result.tags.isNil: result.tags = @[]

0 comments on commit 135e6be

Please sign in to comment.