     File.rm_rf! dstdir
     File.mkdir_p! dstdir
 
-    infolist = mkinfo(dir, proj, files, [])
-    tasks_post = Enum.map infolist, &(Task.async Serum.Build, :post_task, [srcdir, dstdir, proj, &1, template_post])
+    infolist = mkinfo(dir, files, [])
+    tasks_post = Enum.map infolist, &(Task.async Serum.Build, :post_task, [srcdir, dstdir, &1, template_post])
 
     IO.puts "Generating posts index..."
     File.open! "#{dstdir}index.html", [:write, :utf8], fn device ->


  def build_pages(dir, info) do
    template = Agent.get Global, &(Map.get &1, "template_page")
    proj = Agent.get Global, &(Map.get &1, :proj)

    IO.puts "Cleaning pages..."
    "#{dir}site/"
    |> File.ls!
    |> Enum.filter(&(String.ends_with? &1, ".html"))
    |> Enum.each(&(File.rm_rf! "#{dir}site/#{&1}"))

    info
    |> Enum.map(&(Task.async Serum.Build, :page_task, [dir, proj, &1, template]))
    |> Enum.each(&(Task.await &1))
  end

  def page_task(dir, proj, info, template) do
    txt = File.read!("#{dir}pages/#{info.name}.#{info.type}")
    html = case info.type do
      "md" -> Earmark.to_html txt
      "html" -> txt
    end
    html = template
           |> render(proj ++ [contents: html])
           |> genpage(proj ++ [page_title: info.title])
    File.open! "#{dir}site/#{info.name}.html", [:write, :utf8], fn device ->
      IO.write device, html
    end

      tmp = Enum.reduce m.tags, %{}, &(Map.put &2, &1, (Map.get &2, &1, []) ++ [m])
      Map.merge a, tmp, fn _, u, v -> MapSet.to_list(MapSet.new u ++ v) end
    end
    tasks_tag = Enum.map tagmap, &(Task.async Serum.Build, :tag_task, [dir, &1, template_list])

    Enum.each tasks_post ++ tasks_tag, &(Task.await &1)
  end

  def post_task(srcdir, dstdir, info, template) do
    [y, m, d] = info.raw_date
    dow = elem @dowstr, :calendar.day_of_the_week(y, m, d)
    datestr = "#{dow}, #{info.date}"

    [_, _|lines] = "#{srcdir}#{info.file}.md" |> File.read! |> String.split("\n")
    stub = lines |> Earmark.to_html
    html = template
           |> render([title: info.title, date: datestr, tags: info.tags, contents: stub])
           |> genpage([page_title: info.title])

    File.open! "#{dstdir}#{info.file}.html", [:write, :utf8], &(IO.write &1, html)
    IO.puts "  GEN  #{srcdir}#{info.file}.md -> #{dstdir}#{info.file}.html"
  end

  def tag_task(dir, {k, v}, template) do
    tagdir = "#{dir}site/tags/#{k.name}/"
    pt = "Posts Tagged \"#{k.name}\""
    File.mkdir_p! tagdir
    File.open! "#{tagdir}index.html", [:write, :utf8], fn device ->
      html = template
             |> render([header: pt, posts: Enum.reverse(v)])
             |> genpage([page_title: pt])
      IO.write device, html
    end
  end
