how to manipulate key: value pairs?

8 views
Skip to first unread message

Joseph Huang

unread,
Mar 17, 2010, 4:47:11 PM3/17/10
to hak...@googlegroups.com
suppose i have a pair like this:

updated: 2010-03-02

and i want to turn the value into something like this: 2010-03-02T00:00:00Z

i tried adding it in the template, but it wont work because
$updatedT00:00:00Z is not recongized.

I am trying to make a feed that validates, has a meaningful
atom:update value, and i am stuck. also, i am running off of the git
repo.

--
http://jsh.nfshost.com

Jasper Van der Jeugt

unread,
Mar 17, 2010, 5:00:00 PM3/17/10
to hak...@googlegroups.com
Hello,

The github repo version currently supports Atom feed generation, and
the produced feeds validate. So you would probably want to build the
documentation using haddock. You can find some interesting functions
in the `Text.Hakyll.Feeds` module. I already wrote a simple tutorial
on this, which can be found here[1]. Good luck, and feel free to ask
if you have more questions about it :-)

Kind regards,
Jasper Van der Jeugt

[1]: http://github.com/jaspervdj/Hakyll/raw/master/examples/hakyll/tutorials/part05.markdown

josephshuang

unread,
Mar 17, 2010, 5:07:24 PM3/17/10
to hakyll
i saw the native support, but it currently sets the atom:updated
element to the date that the feed was built, so i am still rolling my
own because i want to make it so that it is the last time the article
was actually modified. from the atom spec:
http://www.atomenabled.org/developers/syndication/atom-format-spec.php#element.updated

The "atom:updated" element is a Date construct indicating the most
recent instant in time when an entry or feed was modified in a way the
publisher considers significant. Therefore, not all modifications
necessarily result in a changed atom:updated value.

atomUpdated = element atom:updated { atomDateConstruct}

Publishers MAY change the value of this element over time.

also, are there instructions on how to build the documentation
anywhere?

On Mar 17, 5:00 pm, Jasper Van der Jeugt <jasper...@gmail.com> wrote:
> Hello,
>
> The github repo version currently supports Atom feed generation, and
> the produced feeds validate. So you would probably want to build the
> documentation using haddock. You can find some interesting functions
> in the `Text.Hakyll.Feeds` module. I already wrote a simple tutorial
> on this, which can be found here[1]. Good luck, and feel free to ask
> if you have more questions about it :-)
>
> Kind regards,
> Jasper Van der Jeugt
>

> [1]:http://github.com/jaspervdj/Hakyll/raw/master/examples/hakyll/tutoria...

Jasper Van der Jeugt

unread,
Mar 17, 2010, 5:17:26 PM3/17/10
to hak...@googlegroups.com
Hello,

In fact, the updated field in atom gets set to `maximum articleDates`.
But anyway, here's a solution.

> import Hakyll.Text.ContextManipulations (changeValue)

We're going to define an arrow which will manipulate the updated field.

> let updateManipulator = changeValue "updated" (++ "T00:00:00Z")

And then, you would add a `>>> updateManipulator` before you pass it
to the rendering function, ie.

> renderChain ["some-template.xml"] (feed >>> updateManipulator)

Good luck & hoping this helps,


Kind regards,
Jasper Van der Jeugt

josephshuang

unread,
Mar 18, 2010, 8:19:20 PM3/18/10
to hakyll
i figured out how to do it by looking at Feed.hs

i actually have an updated on each post, so i had to do:

>let updateManipulator = changeValue "updated" (++ "T00:00:00Z")

>let feed = createListing "rss.xml" ["templates/rssitem.xml"] (map (>>> updateManipulator) renderablePosts) []
>renderChain ["templates/rss.xml"] feed

thanks for the help. Hakyll is great.

Joseph

On Mar 17, 5:17 pm, Jasper Van der Jeugt <jasper...@gmail.com> wrote:
> Hello,
>

Reply all
Reply to author
Forward
0 new messages