Generating the page header <head></head> data

0 views
Skip to first unread message

bretweinraub

unread,
May 12, 2008, 2:45:00 PM5/12/08
to Comatose Plugin
I'd like to be able to generate a correct <head></head> section for
my comatose pages.

This means within the <head> section, the following:

<title></title>
<meta description=""/>
<meta keywords=""/>

I have a keywords and a title section in the admin interface (and
these do indeed update the database),
but they don't actual render into the html.

Is that the expected behavior?

If it is, any pointers to where I would be looking to implement a
patch for this?

Thanks,
Bret

Thibaut Barrère

unread,
May 12, 2008, 3:10:31 PM5/12/08
to comatos...@googlegroups.com
Is that the expected behavior?

Are you using a customized layout for the comatose public controller? (under app/views/layouts/application.rhtml for instance in my case)

If you do so, you can write:

    <meta name="Keywords" content="<%= @page.keywords rescue ''%>"/>
    <title><%= @page.title rescue '' %></title>

hth

-- Thibaut

bretweinraub

unread,
May 12, 2008, 3:16:30 PM5/12/08
to Comatose Plugin
I am.

That looks like it work great. I think I still need to patch comatose
for "meta description" though?

This is much better than what I just did, which was the following in
my page:

<script language="JavaScript">
document.title='{{ page.title }}'
</script>

Although that did work.....

Thanks,
Bret

On May 12, 1:10 pm, "Thibaut Barrère" <thibaut.barr...@gmail.com>
wrote:

Thibaut Barrère

unread,
May 12, 2008, 3:33:22 PM5/12/08
to comatos...@googlegroups.com
That looks like it work great.  I think I still need to patch comatose
for "meta description" though?

Glad it works for you. I believe meta description is not available in the built-in stuff. Two suggestions though:
- you add a custom meta-description column on the page, and hack the admin part to support this
- you generate the meta description based on the content (like : @page.body.truncate... or something like that, if appliable)

cheers

-- Thibaut

David Vrensk

unread,
May 13, 2008, 3:51:27 AM5/13/08
to comatos...@googlegroups.com
A third suggestion: add a vertical bar and your description string to the keywords field and then do this:

<%   keywords, description = @page.keywords.split('|') -%>
  <meta name="Keywords" content="<%= keywords %>" />
  <meta name="description" content="<%= description %>" />

Simple as that.

HTH,

/David

PS. Thibaut, I will try to find time to revisit that bug that you want closed.

Bret Weinraub

unread,
May 13, 2008, 12:31:33 PM5/13/08
to comatos...@googlegroups.com
Clever .....

I can think of a few uses for that.

Thanks!
Reply all
Reply to author
Forward
0 new messages