~kungtotte/dtt

00e6d953c711938796e134f8c2c22e3675d3185c — Thomas Landin 2 months ago 7607607
Removed perf. fix because of a bug

I'll live with the slow performance for now; I need to figure out a
better way to improve performance.
2 files changed, 3 insertions(+), 11 deletions(-)

M src/dtt.nim
M src/utils.nim
M src/dtt.nim => src/dtt.nim +1 -5
@@ 115,9 115,7 @@ proc buildCmd(posts_per_page: int = 5) =
      page.tmpl = if existsFile(tmpl_dir / name & ".mustache"): name else: "page"
      pages.add(page)
      if isBlog(dir, name):
        let
          updatePost = needsUpdate(page.abs_path, page.out_path / page.filename)
          post = buildBlogPost(content_dir / f, tmpl_dir, updatePost)
        let post = buildBlogPost(content_dir / f, tmpl_dir)
        posts.add(post)
      else:
        links.add({"target": page.rel_path, "title": page.title}.toTable)


@@ 126,8 124,6 @@ proc buildCmd(posts_per_page: int = 5) =
    num_blogs = if posts_per_page == -1: posts.high else: min(posts.len - 1, posts_per_page)
  sort(posts, dateSort, Descending) # Sort blogs in reverse date order
  for page in pages:
    if not needsUpdate(page.abs_path, page.out_path / page.filename):
      continue
    var context = newContext(searchDirs = @[tmpl_dir])
    context["links"] = links
    if posts.len > 0:

M src/utils.nim => src/utils.nim +2 -6
@@ 85,7 85,7 @@ proc postsToContext*(posts: seq[BlogPost]): seq[Table[string, string]] =
  for post in posts:
    result.add({"id": post.slug, "post": post.content, "date": post.date, "link": post.url}.toTable)

proc buildBlogPost*(full_path: string, tmpl_dir: string, updatePost: bool = false): BlogPost =
proc buildBlogPost*(full_path: string, tmpl_dir: string): BlogPost =
  let
    (dir, name, _) = splitFile(full_path)
    target = if lastPathPart(dir) == "content": name & ".html" else: lastPathPart(dir) / name & ".html"


@@ 97,11 97,7 @@ proc buildBlogPost*(full_path: string, tmpl_dir: string, updatePost: bool = fals
  context["slug"] = slug
  context["date"] = date
  context["blog_link"] = target
  let rendered = if updatePost:
    context.renderTemplate(full_path, "post", tmpl_dir)
  else:
    let cached_file = findBaseDir(getCurrentDir()) / "output" / target
    readFile(cached_file)
  let rendered = context.renderTemplate(full_path, "post", tmpl_dir)
  result.slug = slug
  result.date = date
  result.url = target