Changeset 981

Show
Ignore:
Timestamp:
08/26/08 21:06:58 (3 months ago)
Author:
mpaschal
Message:

Ignore style.css too when finding web theme ID
Reduce theme metadata fields more automatically
Look for a few variant field names

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/StyleCatcher-2.1-dev/plugins/StyleCatcher/lib/StyleCatcher/CMS.pm

    r817 r981  
    593593        $theme = $url; 
    594594        # discard any generic 'screen.css' filename 
    595         $theme =~ s!/screen.css$!!
     595        $theme =~ s{ / (?:screen|style) \.css \z }{}xms
    596596        $theme =~ s/.*[\\\/]//; 
    597597        my @url = split( /\//, $url ); 
     
    665665    $thumbnail_large_link = $new_url . 'thumbnail-large.gif'; 
    666666 
     667    my %field_map = ( 
     668        author_url   => [ 'designer_url', 'author_url', 'author uri' ], 
     669        title        => [ 'name',         'theme name' ], 
     670        author       => [ 'designer',     'author' ], 
     671    ); 
     672    while (my ($best_name, $possible_names) = each %field_map) { 
     673        ($metadata{$best_name}) = grep { defined } 
     674            delete @metadata{ @$possible_names }; 
     675    } 
     676     
    667677    require MT::Util; 
    668678    my $data = { 
    669         name        => $theme, 
    670         description => $metadata{description} || '', 
    671         title       => $metadata{name} || '(Untitled)', 
    672         url         => $url, 
    673         imageSmall  => $thumbnail_link, 
    674         imageBig    => $thumbnail_large_link, 
    675         author      => $metadata{designer} || $metadata{author} || '', 
    676         author_url  => $metadata{designer_url} || $metadata{author_url} || ''
    677         author_affiliation => $metadata{author_affiliation} || ''
    678         layouts            => $metadata{layouts} || ''
    679         'sort'             => $metadata{name} || ''
    680         tags               => $tags
    681         blogs              => []
     679        name        => $theme, 
     680        description => $metadata{description} || '', 
     681        title        => $metadata{title} || '(Untitled)', 
     682        url          => $url, 
     683        imageSmall  => $thumbnail_link, 
     684        imageBig    => $thumbnail_large_link, 
     685        layouts      => $metadata{layouts} || '', 
     686        sort         => $metadata{name} || $theme || q{}
     687        tags         => $tags
     688        blogs        => []
     689        author       => $metadata{author}     || q{}
     690        author_url   => $metadata{author_url} || q{}
     691        author_affiliation => $metadata{author_affiliation} || q{}
    682692    }; 
    683693    $data;