[webgen-users] Adding custom <link>s to the <head> via the contentprocessor head

11 views
Skip to first unread message

Thomas Leitner

unread,
Feb 3, 2010, 3:32:44 PM2/3/10
to webgen...@rubyforge.org
Hi everybody!

As was discussed on the ML some time ago, there is sometimes the need
for including custom links in the head section of an HTML document. For
example:

- adding links to javascript or CSS files
- adding links to next/previous HTML documents
- adding links to Atom/RSS feeds

What I have in mind is a `link` meta information key:

- Adding custom CSS/JS files (value is array or string):

link:
javascript: URI
css: URI
OR:

link:
javascript: [URI, URI]
css: [URI, URI]

- Adding other links:

link:
next: URI
prev:
href: URI
title: Some title
alternate:
- type: atom/xml
href: URI
- type: text/css
href: URI

- Automatically adding links to same page in other languages:

<link type="text/html" rel="alternate" hreflang="LANGCODE"
href="URI" lang="LANGCODE" title="TITLE" />

use `lang` and `title` only if title of linked page is specified

The meta information link has the special keys `javascript` and
`css`, all other keys are taken to be link types (next, prev,
start, ...) that are going into the `rel` attribute of the
generated <link> tag. The value of such keys can be a string value
(taken as value of the href attr), a hash (taken as attr name-value
pairs) or an array or the former two (to create multiple such link
types.
If you have any comments/suggestions on the above, please write! I will
implement the above in the coming days.

Best regards,
Thomas
_______________________________________________
webgen-users mailing list
webgen...@rubyforge.org
http://rubyforge.org/mailman/listinfo/webgen-users

Damien Pollet

unread,
Feb 3, 2010, 4:22:33 PM2/3/10
to webgen...@rubyforge.org
On Wed, Feb 3, 2010 at 21:32, Thomas Leitner <t_le...@gmx.at> wrote:
> If you have any comments/suggestions on the above, please write! I will
> implement the above in the coming days.

You have one tester (well, provided I can build my site at all :)

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Thomas Leitner

unread,
Feb 4, 2010, 2:01:25 PM2/4/10
to webgen...@rubyforge.org
On Wed, 3 Feb 2010 22:22:33 +0100, Damien Pollet wrote:
> On Wed, Feb 3, 2010 at 21:32, Thomas Leitner <t_le...@gmx.at> wrote:
> > If you have any comments/suggestions on the above, please write! I
> > will implement the above in the coming days.
>
> You have one tester (well, provided I can build my site at all :)

I have pushed the needed changes for this functionality to github and
rubyforge. Comments/Suggestions et al are welcome!

-- Thomas

Damien Pollet

unread,
Feb 4, 2010, 2:56:31 PM2/4/10
to webgen...@rubyforge.org
> I have pushed the needed changes for this functionality to github and
> rubyforge. Comments/Suggestions et al are welcome!

Is there an easy way to get a gem?
I tried rake in a checkout and it says there's no rdoc/task…

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Thomas Leitner

unread,
Feb 4, 2010, 6:21:53 PM2/4/10
to webgen...@rubyforge.org
On Thu, 4 Feb 2010 20:56:31 +0100, Damien Pollet wrote:
> > I have pushed the needed changes for this functionality to github
> > and rubyforge. Comments/Suggestions et al are welcome!
>
> Is there an easy way to get a gem?
> I tried rake in a checkout and it says there's no rdoc/task…

If you just want to run webgen, run the following in the checkout
directory:

ruby -rubygems -Ilib bin/webgen

If you want to use the rake tasks, you should install the development
dependencies (gem install --no-rdoc --no-ri webgen --development) -
though there is not task for running webgen. Use `rake -T` to show the
available tasks, `rake dev:gem` builds the gem.

-- Thomas

Damien Pollet

unread,
Feb 6, 2010, 6:47:22 AM2/6/10
to webgen...@rubyforge.org
On Fri, Feb 5, 2010 at 00:21, Thomas Leitner <t_le...@gmx.at> wrote:
> On Thu, 4 Feb 2010 20:56:31 +0100, Damien Pollet wrote:
>> > I have pushed the needed changes for this functionality to github
>> > and rubyforge. Comments/Suggestions et al are welcome!

Ok, seems to work fine.

My only grief is that with Matteo's blog code, the metadata is only
set for the main blog page, not for the individual posts… I tried
putting the data in the metainfo file, but
- globs are not powerful enough to match the blog index and the posts
(or I missed something)
I could duplicate it but it's ugly…
- relocatable does not work in the metainfo, so the link is probably
incorrect (posts are in subdirectories)

Anyway, it's now in use on my site :)

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Thomas Leitner

unread,
Feb 7, 2010, 2:28:36 PM2/7/10
to webgen...@rubyforge.org
> My only grief is that with Matteo's blog code, the metadata is only
> set for the main blog page, not for the individual posts… I tried
> putting the data in the metainfo file, but
> - globs are not powerful enough to match the blog index and the posts
> (or I missed something)
> I could duplicate it but it's ugly…

You could try to use YAML aliases sothat you need to specify the meta
info only once - see http://yaml.org/spec/1.0/#id2563922

> - relocatable does not work in the metainfo, so the link is probably
> incorrect (posts are in subdirectories)

Just specify an absolute path starting with a slash
(i.e. /path/to/feed.atom instead of to/feed.atom) - then the paths will
always be correct.

> Anyway, it's now in use on my site :)

Cool :-)

-- Thomas

Damien Pollet

unread,
Feb 8, 2010, 5:53:23 AM2/8/10
to webgen...@rubyforge.org
On Sun, Feb 7, 2010 at 20:28, Thomas Leitner <t_le...@gmx.at> wrote:
> You could try to use YAML aliases sothat you need to specify the meta
> info only once - see http://yaml.org/spec/1.0/#id2563922

yay, another overly verbose and underly clear spec document… :)

>> - relocatable does not work in the metainfo, so the link is probably
>> incorrect (posts are in subdirectories)
>
> Just specify an absolute path starting with a slash
> (i.e. /path/to/feed.atom instead of to/feed.atom) - then the paths will
> always be correct.

The problem is, if webgen translates those to absolute links in the
html, it won't work. I'm deploying the webgen output in a subtree of
the complete site, and I have a test deployment on a local web server
that does not have the same prefix.

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Thomas Leitner

unread,
Feb 8, 2010, 3:20:42 PM2/8/10
to webgen...@rubyforge.org
> > Just specify an absolute path starting with a slash
> > (i.e. /path/to/feed.atom instead of to/feed.atom) - then the paths
> > will always be correct.
>
> The problem is, if webgen translates those to absolute links in the
> html, it won't work. I'm deploying the webgen output in a subtree of
> the complete site, and I have a test deployment on a local web server
> that does not have the same prefix.

webgen translates internal paths *always* to relative paths! So it does
not matter where you deploy your site, it will work everywhere.
However, if you want absolute paths, it is also possible with a little
patching (there was a mail exchange about this some time ago).

-- Thomas

Damien Pollet

unread,
Feb 9, 2010, 11:04:02 AM2/9/10
to webgen...@rubyforge.org
On Mon, Feb 8, 2010 at 21:20, Thomas Leitner <t_le...@gmx.at> wrote:
>> The problem is, if webgen translates those to absolute links in the
>> html, it won't work. I'm deploying the webgen output in a subtree of
>> the complete site, and I have a test deployment on a local web server
>> that does not have the same prefix.
>
> webgen translates internal paths *always* to relative paths! So it does
> not matter where you deploy your site, it will work everywhere.
> However, if you want absolute paths, it is also possible with a little
> patching (there was a mail exchange about this some time ago).

No, relative is what I want. I just wasn't sure it would do that everywhere.
Actually the problem might be that I have a separate template file for
the blog posts, and maybe the blog generator does not propagate all
its metainfo. I didn't take the time to look in detail, links on the
main page are perfectly ok for the moment.


--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Damien Pollet

unread,
Feb 22, 2010, 11:10:46 AM2/22/10
to webgen...@rubyforge.org
Back on this…
I now have webgen complain:

ERROR -- No link target specified for link type 'alternate' in 'link'
meta information in </notes/index.en.html>

and so on… from reading the code it seems that the href is not found
in the metainfo, but here's what I have:

link:
alternate:
- type: application/atom+xml
href: /notes/feed.atom
title: Posts (Atom)
- type: application/rss+xml
href: /notes/feed.rss
title: Posts (RSS)

Thomas Leitner

unread,
Feb 23, 2010, 1:09:31 AM2/23/10
to webgen...@rubyforge.org
On Mon, 22 Feb 2010 17:10:46 +0100, Damien Pollet wrote:
> Back on this…
> I now have webgen complain:
>
> ERROR -- No link target specified for link type 'alternate' in 'link'
> meta information in </notes/index.en.html>
>
> and so on… from reading the code it seems that the href is not found
> in the metainfo, but here's what I have:
>
> link:
> alternate:
> - type: application/atom+xml
> href: /notes/feed.atom
> title: Posts (Atom)
> - type: application/rss+xml
> href: /notes/feed.rss
> title: Posts (RSS)

This is a bug in the content processor head which I have fixed in my
repo.

-- Thomas

Damien Pollet

unread,
Feb 25, 2010, 7:38:58 AM2/25/10
to webgen...@rubyforge.org
On Tue, Feb 23, 2010 at 07:09, Thomas Leitner <t_le...@gmx.at> wrote:
> This is a bug in the content processor head which I have fixed in my
> repo.

Is it pushed to github ?


--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Thomas Leitner

unread,
Feb 26, 2010, 7:04:02 AM2/26/10
to webgen...@rubyforge.org
On Thu, 25 Feb 2010 13:38:58 +0100, Damien Pollet wrote:
> On Tue, Feb 23, 2010 at 07:09, Thomas Leitner <t_le...@gmx.at>
> wrote:
> > This is a bug in the content processor head which I have fixed in my
> > repo.
>
> Is it pushed to github ?

It now is.

-- Thomas

Damien Pollet

unread,
Feb 26, 2010, 7:41:52 AM2/26/10
to webgen...@rubyforge.org
On Fri, Feb 26, 2010 at 13:04, Thomas Leitner <t_le...@gmx.at> wrote:
>> Is it pushed to github ?
>
> It now is.

OK, I pulled that…
- at first I got a bunch of errors due to mis-initialization of the
metainfo tag… switched from require to load in ex/init.rb and that
fixed those.
- everything looks nice, the link#targets work, the feed metadata too, but…

…some pieces of markdown code appear as-is in the output, e.g. the
tagline with my affiliation in the page headers, the title of entries
in the main blog page, and the <img> tag in the blog post pages.

The <img> tag problem was fixed by removing indentation (it was
recognized as a markdown code block).
The tagline looks more like the metainfo tag escapes —or does not
process its output like the include_file tag can.

--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet

Damien Pollet

unread,
Feb 26, 2010, 8:02:22 AM2/26/10
to webgen...@rubyforge.org
On Fri, Feb 26, 2010 at 13:41, Damien Pollet <damien...@gmail.com> wrote:
> but…

And in_menu: false is ignored (for at least one of the subdirectories)

Thomas Leitner

unread,
Feb 26, 2010, 9:14:47 AM2/26/10
to webgen...@rubyforge.org
> …some pieces of markdown code appear as-is in the output, e.g. the
> tagline with my affiliation in the page headers, the title of entries
> in the main blog page, and the <img> tag in the blog post pages.

This is due to a change in the meta info tag. The meta info values are
assumed to be output format agnostic. Therefore I added automatic
escaping of meta info values inserted by the metainfo tag. I have added
an option for disabling the escaping. The Github repo has been updated.

-- Thomas

Reply all
Reply to author
Forward
0 new messages