Changeset 1433


Ignore:
Timestamp:
Aug 17, 2012, 4:36:57 PM (9 years ago)
Author:
kake
Message:

Added meta descriptions to headers of map and list index pages.

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Changes

    r1432 r1433  
    660.70    ?
    77        Updated URLs for Leaflet JavaScript and CSS.
     8        Added meta descriptions to headers of map and list index pages.
    89
    9100.69    07 July 2012
  • trunk/MANIFEST

    r1421 r1433  
    131131t/408_google_analytics.t
    132132t/409_custom_header.t
     133t/410_meta_description.t
    133134t/500_http_response_codes.t
    134135t/501_display_node.t
  • trunk/lib/OpenGuides.pm

    r1421 r1433  
    10611061            $tt_vars{not_editable} = 1;
    10621062        }
     1063
     1064        $tt_vars{page_description} =
     1065            OpenGuides::Utils->get_index_page_description(
     1066                format => $args{format} || "",
     1067                criteria => \@criteria,
     1068            );
     1069
    10631070        my $feed_base = $self->config->script_url
    10641071                        . $self->config->script_name . "?action=index";
  • trunk/lib/OpenGuides/Utils.pm

    r1427 r1433  
    387387}
    388388
     389=item B<get_index_page_description>
     390
     391    $tt_vars{page_description} =
     392        OpenGuides::Utils->get_index_page_description(
     393            format => "map",
     394            criteria => [ type => "locale", value => "croydon" ],
     395    );
     396
     397Returns a sentence that can be used as a summary of what's shown on an
     398index page.
     399
     400=cut
     401
     402sub get_index_page_description {
     403    my ( $class, %args ) = @_;
     404    my $desc = ( $args{format} eq "map" ) ? "Map" : "List";
     405    $desc .= " of all our pages";
     406
     407    my ( @cats, @locs );
     408    foreach my $criterion ( @{$args{criteria}} ) {
     409        my ( $type, $name ) = ( $criterion->{type}, $criterion->{name} );
     410        if ( $type eq "category" ) {
     411            $name =~ s/Category //;
     412            push @cats, $name;
     413        } else {
     414            $name =~ s/Locale //;
     415            push @locs, $name;
     416        }
     417    }
     418
     419    if ( scalar @cats ) {
     420        $desc .= " labelled with: " . join( ", ", @cats );
     421        if ( scalar @locs ) {
     422            $desc .= ", and";
     423        }
     424    }
     425    if ( scalar @locs ) {
     426        $desc .= " located in: " . join( ", ", @locs );
     427    }
     428    $desc .= ".";
     429    return $desc;
     430}
     431
    389432=item B<detect_redirect>
    390433
  • trunk/templates/header.tt

    r1432 r1433  
    1616    <link rev="made" href="mailto:[% contact_email %]" />
    1717  [% END %]
    18   [% IF summary %]
     18
     19  [% IF page_description %]
     20    <meta name="description" content="[% page_description %]" />
     21  [% ELSIF summary %]
    1922    <meta name="description" content="[% summary %]" />
    2023  [% END %]
     24
    2125  [% IF (categories.size AND categories.size > 0)
    2226     OR (locales.size AND locales.size > 0) %]
Note: See TracChangeset for help on using the changeset viewer.