librelist archives

« back to archive

@title not title

@title not title

From:
Isaac Rabinovitch
Date:
2013-02-14 @ 06:10
I want to customize my <title>s so they contain the page title (from the 
# line) and the site title. The @title variable includes breadcrumbing, 
which I don't want. Can't seem to find an instance variable the just 
contains the plain page title.

Re: [nesta] @title not title

From:
James Abbott
Date:
2013-02-14 @ 08:09
Before looking for instance variables that contain the data you want, it's
best to examine what the API already provides. Here's a session from my irb
-r 'nesta/app' console:

p = Nesta::Page.find_by_path('ruby')
p.title
 => "Ruby - James Abbott Design\t& Development"  // category page
a = p.articles[0] // blog post
a.title
 => "Some screencasts I'd like to see  - Programmer's way"
a.heading
 => "Some screencasts I'd like to see "


/ James


On Thu, Feb 14, 2013 at 7:10 AM, Isaac Rabinovitch <isaac@picknit.com>wrote:

> I want to customize my <title>s so they contain the page title (from the
> # line) and the site title. The @title variable includes breadcrumbing,
> which I don't want. Can't seem to find an instance variable the just
> contains the plain page title.
>

Re: [nesta] @title not title

From:
Isaac Rabinovitch
Date:
2013-02-14 @ 19:04
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    James, perhaps my inexperience with Ruby and templating is showing,
    but doesn't data have to be in an instance variable before I can use
    it in a template?<br>
    <br>
    <div class="moz-cite-prefix">On 2/14/2013 12:09 AM, James Abbott
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAGoQ=r_L_sNaOOcVhsrrvtzn81zoKuG_PPAfcKAXaP+7bsPCiw@mail.gmail.com"
      type="cite">Before looking for instance variables that contain the
      data you want, it's best to examine what the API already provides.
      Here's a session from my irb -r 'nesta/app' console:<br>
      <br>
      p = Nesta::Page.find_by_path('ruby')<br>
      p.title<br>
       => "Ruby - James Abbott Design\t&amp; Development"  //
      category page<br>
      a = p.articles[0] // blog post<br>
      a.title<br>
       => "Some screencasts I'd like to see  - Programmer's way" <br>
      a.heading<br>
       => "Some screencasts I'd like to see " <br>
      <br>
      <br>
      / James<br>
      <br>
      <br>
      <div class="gmail_quote">On Thu, Feb 14, 2013 at 7:10 AM, Isaac
        Rabinovitch <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:isaac@picknit.com" 
target="_blank">isaac@picknit.com</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">I want to
          customize my <title>s so they contain the page title
          (from the<br>
          # line) and the site title. The @title variable includes
          breadcrumbing,<br>
          which I don't want. Can't seem to find an instance variable
          the just<br>
          contains the plain page title.<br>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>

Re: [nesta] @title not title

From:
Isaac Rabinovitch
Date:
2013-02-14 @ 20:01
Apologies for the raw HTML. Apparently librelist doesn't like emails 
that don't include a plain text copy. Turned that feature back on in 
Thunderbird.

On 2/14/2013 11:04 AM, Isaac Rabinovitch wrote:
> James, perhaps my inexperience with Ruby and templating is showing, 
> but doesn't data have to be in an instance variable before I can use 
> it in a template?
>
> On 2/14/2013 12:09 AM, James Abbott wrote:
>> Before looking for instance variables that contain the data you want, 
>> it's best to examine what the API already provides. Here's a session 
>> from my irb -r 'nesta/app' console:
>>
>> p = Nesta::Page.find_by_path('ruby')
>> p.title
>>  => "Ruby - James Abbott Design\t& Development"  // category page
>> a = p.articles[0] // blog post
>> a.title
>>  => "Some screencasts I'd like to see  - Programmer's way"
>> a.heading
>>  => "Some screencasts I'd like to see "
>>
>>
>> / James
>>
>>
>> On Thu, Feb 14, 2013 at 7:10 AM, Isaac Rabinovitch <isaac@picknit.com 
>> <mailto:isaac@picknit.com>> wrote:
>>
>>     I want to customize my <title>s so they contain the page title
>>     (from the
>>     # line) and the site title. The @title variable includes
>>     breadcrumbing,
>>     which I don't want. Can't seem to find an instance variable the just
>>     contains the plain page title.
>>
>>
>

Re: [nesta] @title not title

From:
Graham Ashton
Date:
2013-02-14 @ 20:11
On 2/14/2013 11:04 AM, Isaac Rabinovitch wrote:
> James, perhaps my inexperience with Ruby and templating is showing, but 
doesn't data have to be in an instance variable before I can use it in a 
template?

In general, no (you could also access it via a helper). We don't need to 
get into helpers though; @page is an instance variable and you can access 
its title by saying `@page.title`.

-- 
Graham Ashton
Founder, Agile Planner
https://www.agileplannerapp.com | @agileplanner | @grahamashton

Re: [nesta] @title not title

From:
Isaac Rabinovitch
Date:
2013-02-14 @ 20:27
Can you suggest an easy way to discover helper functions? Not obvious to 
me which ones are available.


On 2/14/2013 12:11 PM, Graham Ashton wrote:
> On 2/14/2013 11:04 AM, Isaac Rabinovitch wrote:
>> James, perhaps my inexperience with Ruby and templating is showing, but
doesn't data have to be in an instance variable before I can use it in a 
template?
> In general, no (you could also access it via a helper). We don't need to
get into helpers though; @page is an instance variable and you can access 
its title by saying `@page.title`.
>

Re: [nesta] @title not title

From:
James Abbott
Date:
2013-02-15 @ 10:12
>
> Can you suggest an easy way to discover helper functions? Not obvious to
> me which ones are available.
>

This may or may not be an "easy way", but here's my recommendation: find a
good printer and print Nesta out. All of its codebase. After spending some
hours reading through it, many questions will tend to answer themselves.

This applies to your open source project of choice, not just Nesta :-)

/J.

On Thu, Feb 14, 2013 at 9:27 PM, Isaac Rabinovitch <isaac@picknit.com>wrote:

> Can you suggest an easy way to discover helper functions? Not obvious to
> me which ones are available.
>
>
> On 2/14/2013 12:11 PM, Graham Ashton wrote:
> > On 2/14/2013 11:04 AM, Isaac Rabinovitch wrote:
> >> James, perhaps my inexperience with Ruby and templating is showing, but
> doesn't data have to be in an instance variable before I can use it in a
> template?
> > In general, no (you could also access it via a helper). We don't need to
> get into helpers though; @page is an instance variable and you can access
> its title by saying `@page.title`.
> >
>
>

Re: [nesta] @title not title

From:
Isaac Rabinovitch
Date:
2013-02-15 @ 17:40
I'm more of a Vim and Grep guy.

On 2/15/2013 2:12 AM, James Abbott wrote:
>
>     Can you suggest an easy way to discover helper functions? Not
>     obvious to
>     me which ones are available.
>
>
> This may or may not be an "easy way", but here's my recommendation: 
> find a good printer and print Nesta out. All of its codebase. After 
> spending some hours reading through it, many questions will tend to 
> answer themselves.
>
> This applies to your open source project of choice, not just Nesta :-)
>
> /J.
>
> On Thu, Feb 14, 2013 at 9:27 PM, Isaac Rabinovitch <isaac@picknit.com 
> <mailto:isaac@picknit.com>> wrote:
>
>     Can you suggest an easy way to discover helper functions? Not
>     obvious to
>     me which ones are available.
>
>
>     On 2/14/2013 12:11 PM, Graham Ashton wrote:
>     > On 2/14/2013 11:04 AM, Isaac Rabinovitch wrote:
>     >> James, perhaps my inexperience with Ruby and templating is
>     showing, but doesn't data have to be in an instance variable
>     before I can use it in a template?
>     > In general, no (you could also access it via a helper). We don't
>     need to get into helpers though; @page is an instance variable and
>     you can access its title by saying `@page.title`.
>     >
>
>

Re: [nesta] @title not title

From:
Isaac Rabinovitch
Date:
2013-02-14 @ 20:38
Alas, @page.title seems to contain same thing as @title.

On 2/14/2013 12:11 PM, Graham Ashton wrote:
> On 2/14/2013 11:04 AM, Isaac Rabinovitch wrote:
>> James, perhaps my inexperience with Ruby and templating is showing, but
doesn't data have to be in an instance variable before I can use it in a 
template?
> In general, no (you could also access it via a helper). We don't need to
get into helpers though; @page is an instance variable and you can access 
its title by saying `@page.title`.
>

Re: [nesta] @title not title

From:
Isaac Rabinovitch
Date:
2013-02-14 @ 20:52
OK,  after working through James's code, it finally dawned on me that 
@page.heading has what I need. Sorry for my cerebral density.

On 2/14/2013 12:38 PM, Isaac Rabinovitch wrote:
> Alas, @page.title seems to contain same thing as @title.
>
> On 2/14/2013 12:11 PM, Graham Ashton wrote:
>> On 2/14/2013 11:04 AM, Isaac Rabinovitch wrote:
>>> James, perhaps my inexperience with Ruby and templating is showing, 
but doesn't data have to be in an instance variable before I can use it in
a template?
>> In general, no (you could also access it via a helper). We don't need 
to get into helpers though; @page is an instance variable and you can 
access its title by saying `@page.title`.
>>

Re: [nesta] @title not title

From:
Graham Ashton
Date:
2013-02-14 @ 09:00
On 14 Feb 2013, at 08:09, James Abbott <abbottjam@gmail.com> wrote:

> Before looking for instance variables that contain the data you want, 
it's best to examine what the API already provides. Here's a session from 
my irb -r 'nesta/app' console:
> 
> p = Nesta::Page.find_by_path('ruby')
> p.title
>  => "Ruby - James Abbott Design\t& Development"  // category page
> a = p.articles[0] // blog post
> a.title
>  => "Some screencasts I'd like to see  - Programmer's way" 
> a.heading
>  => "Some screencasts I'd like to see " 

Using the heading instead will work, but in Nesta's opinion a page's 
heading (used in the h1 tag) and the title (used in the title tag) could 
be different, so it recently gained support for defining them separately.

In the code that's in git (to be released as 0.10.0, or maybe 1.0.0 if I 
embrace semantic versioning) the way the page title is set has changed, 
and it doesn't append the title of any other pages. It basically does 
this:

  def title
    metadata('title') || metadata('link text') || heading
  end

So the heading is the default, used if the other two metadata keys aren't defined.

Isaac - If the heading works for you, use that.

--
Graham Ashton
Founder, The Agile Planner
http://www.theagileplanner.com | @agileplanner | @grahamashton