Fighting the cache

135 views
Skip to first unread message

Kevin Quick

unread,
May 3, 2011, 11:59:04 AM5/3/11
to hakyll
I've mostly achieved what I was trying to do (regarding my recent
questions), but then I seem to have taken a big step back.

Attached is my hakyll file (requires hakyll 3.1.1.2). The enhancement
I was working on is the TOCMarkCompiler which generates a TOC entry in
the Page metadata. This allows you to have something like:

default.template:
: <body>
: <table>
: <tr><td><table>$TOC$</table></td><td>$body$</td>
: </table>
: </body>

And then have two other template files:

tocsel.template:
: <tr><td><a class="tocsel"
href="$PAGEREF$">$PAGENAME$</a>&nbsp;&rarr;</td></tr>

tocnotsel.template:
: <tr><td><a class="tocent" href="$PAGEREF$">$PAGENAME$</a></td></tr>

My main then invokes this:

: requireA "tocsel.template"
: $ requireA "tocnotsel.template"
: $ applyTOCMarkCompiler ["main.markdown"
: ,"projects.markdown"
: ,"aboutme.markdown"
: ,"links.markdown"
: ]

Each page rendered then has a TOC metatdata key which has references
to the listed pages,
with the current page using the tocsel but other pages using tocnotsel.

This seemed to work! :-)

But then I created a new working directory (darcs get) and my troubles
began. Somehow I'd
managed to populate the cache in my original directory so that things
worked, but in the new directory with
no _cache, I get:

$ ./hakyll preview
Initialising
[ 0ms] Creating store
[ -1ms] Creating provider
Adding new compilers
Compiling templates/default.hamlet
[ ] Checking cache: modified
[ 0ms] Total compile time
Compiling templates/tocnotsel.html
[ ] Checking cache: modified
[ 0ms] Total compile time
Compiling templates/tocsel.html
[ ] Checking cache: modified
[ -1ms] Total compile time
Compiling about_me.markdown
[ ] Checking cache: modified
[ -2ms] Total compile time
[ ERROR] Hakyll.Core.Compiler.getDependency: templates/tocsel.html
not found in the cache, the cache might be corrupted or the item you
are referring to might not exist
Compiling css/sparqstyle.css
[ -3ms] Total compile time
[ 0ms] Routing to css/sparqstyle.css
Compiling newstart.markdown
[ ] Checking cache: modified
[ 2ms] Total compile time
[ ERROR] Hakyll.Core.Compiler.getDependency: templates/tocsel.html
not found in the cache, the cache might be corrupted or the item you
are referring to might not exist
Listening on http://0.0.0.0:8000
^C
$


I'm not sure why the dependencies don't exist: I've used requireA on
them and there is a match for them with
the templateCompiler (see attached). The above only happens on the
first run. On all runs after that:

$ ./hakyll preview
Initialising
[ 0ms] Creating store
[ 1ms] Creating provider
Adding new compilers
Compiling newstart.markdown
[ ] Checking cache: modified
hakyll: too few bytes. Failed reading at byte position 204
$

At this point I have to delete the _cache but then I revert to the upper error.

Jasper, I know you're busy with school, but I'd really appreciate some
pointers here from you or anyone else!

Thanks!

--
-KQ

hakyll.hs

Jasper Van der Jeugt

unread,
May 6, 2011, 3:57:49 AM5/6/11
to hak...@googlegroups.com
Hello Kevin,

Can I clone the full repository somewhere? (i.e. the darcs repository
that is failing.)

Cheers,
Jasper

Kevin Quick

unread,
May 13, 2011, 2:44:07 AM5/13/11
to hak...@googlegroups.com
Sorry, I don't have the repository available publicly at the moment.

I've worked around the problem for the moment: it seemed to be using
the require identifier for the templates was the issue:

match "template/*" $ compile TemplateCompiler
match "page/*" $ do
route $ setExtension "html"
compile $ requireA "template/tocsel.html" $ addTOCCompiler

Removing the requireA solved the issue:

match "page/*" $ do
route $ setExtension "html"
compile $ arr id &&& constA "template/tocsel.html" >>> addTOCCompiler

-KQ

--
-KQ

Reply all
Reply to author
Forward
0 new messages