Refactor S2 backend to use the configured images / alt text instead of
hard coding the information. (No user-facing change)
Patch by kareila.
diffs (573 lines):
diff -r 2c176a71404b -r 9380b580348a bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Wed Jul 07 18:31:18 2010 +0800
+++ b/bin/upgrading/en.dat Thu Jul 08 15:00:02 2010 +0800
@@ -1983,6 +1983,8 @@ fcklang.videoprompt=Please enter the You
help=Help
+img.atom=Atom
+
img.btn_del=Delete
img.btn_down=Down
@@ -2003,6 +2005,8 @@ img.editentry=Edit Entry
img.edittags=Edit Tags
+img.foaf=FOAF
+
img.ins_obj=Insert Image/Object
img.memadd=Add to memories!
@@ -2013,6 +2017,8 @@ img.placeholder=Image
img.prev_entry=Previous Entry
+img.rss=RSS
+
img.tellfriend=Tell a Friend!
img.track=Track This
@@ -2020,6 +2026,8 @@ img.track_active=Track This
img.track_active=Track This
img.track_thread_active=Track This
+
+img.untrack=Untrack This
img.xml=XML Source
diff -r 2c176a71404b -r 9380b580348a cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm Wed Jul 07 18:31:18 2010 +0800
+++ b/cgi-bin/LJ/S2.pm Thu Jul 08 15:00:02 2010 +0800
@@ -2198,14 +2198,35 @@ sub Image_std
my $ctx = $LJ::S2::CURR_CTX or die "No S2 context available ";
unless ($LJ::S2::RES_MADE++) {
- $LJ::S2::RES_CACHE = {
- 'security-protected' =>
Image("$LJ::IMGPREFIX/silk/entry/locked.png", 16, 16,
$ctx->[S2::PROPS]->{'text_icon_alt_protected'}),
- 'security-private' =>
Image("$LJ::IMGPREFIX/silk/entry/private.png", 16, 16,
$ctx->[S2::PROPS]->{'text_icon_alt_private'}),
- 'security-groups' =>
Image("$LJ::IMGPREFIX/silk/entry/filtered.png", 21, 13,
$ctx->[S2::PROPS]->{'text_icon_alt_groups'}),
- 'adult-nsfw' => Image("$LJ::IMGPREFIX/icon_nsfw.png", 16, 16,
$ctx->[S2::PROPS]->{'text_icon_alt_nsfw'}),
- 'adult-18' => Image("$LJ::IMGPREFIX/icon_18.png", 16, 16,
$ctx->[S2::PROPS]->{'text_icon_alt_18'}),
- 'sticky-entry' =>
Image("$LJ::IMGPREFIX/silk/entry/sticky_entry.png", 16, 16,
$ctx->[S2::PROPS]->{'text_icon_alt_sticky_entry'}),
- };
+ $LJ::S2::RES_CACHE = {};
+ my $textmap = {
+ 'security-protected' => 'text_icon_alt_protected',
+ 'security-private' => 'text_icon_alt_private',
+ 'security-groups' => 'text_icon_alt_groups',
+ 'adult-nsfw' => 'text_icon_alt_nsfw',
+ 'adult-18' => 'text_icon_alt_18',
+ 'sticky-entry' => 'text_icon_alt_sticky_entry',
+ };
+ foreach ( keys %$textmap ) {
+ my $i = $LJ::Img::img{$_};
+ $LJ::S2::RES_CACHE->{$_} =
+ Image( "$LJ::IMGPREFIX$i->{src}",
+ $i->{width}, $i->{height},
+ $ctx->[S2::PROPS]->{ $textmap->{$_} } );
+ }
+
+ # additional icons from imageconf.pl
+ # with alt text from translation system
+ my @ic = qw( btn_del btn_freeze btn_unfreeze btn_scr btn_unscr
+ editcomment editentry edittags tellfriend memadd
+ prev_entry next_entry track untrack foaf atom rss );
+ foreach ( @ic ) {
+ my $i = $LJ::Img::img{$_};
+ $LJ::S2::RES_CACHE->{$_} =
+ Image( "$LJ::IMGPREFIX$i->{src}",
+ $i->{width}, $i->{height},
+ LJ::Lang::ml( $i->{alt} ) );
+ }
}
return $LJ::S2::RES_CACHE->{$name};
}
@@ -2341,7 +2362,7 @@ sub UserLite
'data_link' => {
'foaf' => Link("$LJ::SITEROOT/users/" . LJ::ehtml($u->{'user'}) .
'/data/foaf',
"FOAF",
- Image("$LJ::IMGPREFIX/data_foaf.gif", 32, 15,
"FOAF")),
+ Image_std( "foaf" ) ),
},
'data_links_order' => [ "foaf" ],
'link_keyseq' => [ ],
@@ -3064,35 +3085,35 @@ sub _Comment__get_link
return $null_link unless LJ::Talk::can_delete($remote, $u, $post_user,
$com_user);
return
LJ::S2::Link("$LJ::SITEROOT/delcomment?journal=$u->{'user'}&id=$this->{'talkid'}",
$ctx->[S2::PROPS]->{"text_multiform_opt_delete"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/comments/delete.png", 16, 16));
+ LJ::S2::Image_std( 'btn_del' ) );
}
if ($key eq "freeze_thread") {
return $null_link if $this->{'frozen'};
return $null_link unless LJ::Talk::can_freeze($remote, $u, $post_user,
$com_user);
return
LJ::S2::Link("$LJ::SITEROOT/talkscreen?mode=freeze&journal=$u->{'user'}&talkid=$this->{'talkid'}",
$ctx->[S2::PROPS]->{"text_multiform_opt_freeze"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/comments/freeze.png", 16, 16));
+ LJ::S2::Image_std( 'btn_freeze' ) );
}
if ($key eq "unfreeze_thread") {
return $null_link unless $this->{'frozen'};
return $null_link unless LJ::Talk::can_unfreeze($remote, $u,
$post_user, $com_user);
return
LJ::S2::Link("$LJ::SITEROOT/talkscreen?mode=unfreeze&journal=$u->{'user'}&talkid=$this->{'talkid'}",
$ctx->[S2::PROPS]->{"text_multiform_opt_unfreeze"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/comments/unfreeze.png", 16, 16));
+ LJ::S2::Image_std( 'btn_unfreeze' ) );
}
if ($key eq "screen_comment") {
return $null_link if $this->{'screened'};
return $null_link unless LJ::Talk::can_screen($remote, $u, $post_user,
$com_user);
return
LJ::S2::Link("$LJ::SITEROOT/talkscreen?mode=screen&journal=$u->{'user'}&talkid=$this->{'talkid'}",
$ctx->[S2::PROPS]->{"text_multiform_opt_screen"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/comments/screen.png", 16, 16));
+ LJ::S2::Image_std( 'btn_scr' ) );
}
if ($key eq "unscreen_comment") {
return $null_link unless $this->{'screened'};
return $null_link unless LJ::Talk::can_unscreen($remote, $u,
$post_user, $com_user);
return
LJ::S2::Link("$LJ::SITEROOT/talkscreen?mode=unscreen&journal=$u->{'user'}&talkid=$this->{'talkid'}",
$ctx->[S2::PROPS]->{"text_multiform_opt_unscreen"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/comments/unscreen.png", 16, 16));
+ LJ::S2::Image_std( 'btn_unscr' ) );
}
# added new button
@@ -3101,7 +3122,7 @@ sub _Comment__get_link
#return $null_link unless LJ::Talk::can_unscreen($remote, $u,
$post_user, $com_user);
return
LJ::S2::Link("$LJ::SITEROOT/talkscreen?mode=unscreen&journal=$u->{'user'}&talkid=$this->{'talkid'}",
$ctx->[S2::PROPS]->{"text_multiform_opt_unscreen_to_reply"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/comments/unscreen.png", 16, 16));
+ LJ::S2::Image_std( 'btn_unscr' ) );
}
@@ -3126,7 +3147,7 @@ sub _Comment__get_link
return LJ::S2::Link(
"$LJ::SITEROOT/manage/subscriptions/comments?journal=$u->{'user'}&talkid="
. $comment->dtalkid,
$ctx->[S2::PROPS]->{"text_multiform_opt_untrack"},
- LJ::S2::Image(
"$LJ::IMGPREFIX/silk/entry/untrack.png", 16, 16, 'Untrack this' ),
+ LJ::S2::Image_std( 'untrack' ),
'lj_etypeid' => $etypeid,
'lj_journalid' => $u->id,
'lj_subid' => $subscr->id,
@@ -3183,12 +3204,12 @@ sub _Comment__get_link
if ($key eq "watch_thread" && !$watching_parent) {
return LJ::S2::Link(
"$LJ::SITEROOT/manage/subscriptions/comments?journal=$u->{'user'}&talkid=$dtalkid",
$ctx->[S2::PROPS]->{"text_multiform_opt_track"},
- LJ::S2::Image(
"$LJ::IMGPREFIX/silk/entry/track.png", 16, 16, 'Track This' ), %btn_params );
+ LJ::S2::Image_std( 'track' ), %btn_params );
}
if ($key eq "watching_parent" && $watching_parent) {
return LJ::S2::Link(
"$LJ::SITEROOT/manage/subscriptions/comments?journal=$u->{'user'}&talkid=$dtalkid",
$ctx->[S2::PROPS]->{"text_multiform_opt_track"},
- LJ::S2::Image(
"$LJ::IMGPREFIX/silk/entry/untrack.png", 16, 16, 'Untrack This' ), %btn_params
);
+ LJ::S2::Image_std( 'untrack' ), %btn_params );
}
return $null_link;
}
@@ -3197,7 +3218,7 @@ sub _Comment__get_link
my $edit_url = $this->{edit_url} || $comment->edit_url;
return LJ::S2::Link($edit_url,
$ctx->[S2::PROPS]->{"text_multiform_opt_edit"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/comments/edit.png", 16, 16));
+ LJ::S2::Image_std( 'editcomment' ) );
}
if ($key eq "expand_comments") {
return $null_link unless $u->show_thread_expander( $remote );
@@ -3690,7 +3711,7 @@ sub _Entry__get_link
$remote->can_manage( $journalu ) );
return
LJ::S2::Link("$LJ::SITEROOT/editjournal?journal=$journal&itemid=$this->{'itemid'}",
$ctx->[S2::PROPS]->{"text_edit_entry"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/entry/edit.png", 16, 16));
+ LJ::S2::Image_std( 'editentry' ) );
}
if ($key eq "edit_tags") {
my $entry = LJ::Entry->new( $journalu, ditemid => $this->{itemid} );
@@ -3698,7 +3719,7 @@ sub _Entry__get_link
return $null_link unless $remote && LJ::Tags::can_add_entry_tags(
$remote, $entry );
return
LJ::S2::Link("$LJ::SITEROOT/edittags?journal=$journal&itemid=$this->{'itemid'}",
$ctx->[S2::PROPS]->{"text_edit_tags"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/entry/tag_edit.png", 16, 16));
+ LJ::S2::Image_std( 'edittags' ) );
}
if ($key eq "tell_friend") {
return $null_link unless LJ::is_enabled('tellafriend');
@@ -3706,23 +3727,23 @@ sub _Entry__get_link
return $null_link unless $entry->can_tellafriend($remote);
return
LJ::S2::Link("$LJ::SITEROOT/tools/tellafriend?journal=$journal&itemid=$this->{'itemid'}",
$ctx->[S2::PROPS]->{"text_tell_friend"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/entry/tellafriend.png", 16, 16));
+ LJ::S2::Image_std( 'tellfriend' ) );
}
if ($key eq "mem_add") {
return $null_link unless LJ::is_enabled('memories');
return
LJ::S2::Link("$LJ::SITEROOT/tools/memadd?journal=$journal&itemid=$this->{'itemid'}",
$ctx->[S2::PROPS]->{"text_mem_add"},
-
LJ::S2::Image("$LJ::IMGPREFIX/silk/entry/memories_add.png", 16, 16));
+ LJ::S2::Image_std( 'memadd' ) );
}
if ($key eq "nav_prev") {
return
LJ::S2::Link("$LJ::SITEROOT/go?journal=$journal&itemid=$this->{'itemid'}&dir=prev",
$ctx->[S2::PROPS]->{"text_entry_prev"},
-
LJ::S2::Image("$LJ::IMGPREFIX//silk/entry/previous.png", 16, 16));
+ LJ::S2::Image_std( 'prev_entry' ) );
}
if ($key eq "nav_next") {
return
LJ::S2::Link("$LJ::SITEROOT/go?journal=$journal&itemid=$this->{'itemid'}&dir=next",
$ctx->[S2::PROPS]->{"text_entry_next"},
-
LJ::S2::Image("$LJ::IMGPREFIX//silk/entry/next.png", 16, 16));
+ LJ::S2::Image_std( 'next_entry' ) );
}
my $etypeid = 'LJ::Event::JournalNewComment'->etypeid;
@@ -3769,7 +3790,7 @@ sub _Entry__get_link
return LJ::S2::Link(
"$LJ::SITEROOT/manage/subscriptions/entry?journal=$journal&itemid=$this->{'itemid'}",
$ctx->[S2::PROPS]->{"text_watch_comments"},
- LJ::S2::Image(
"$LJ::IMGPREFIX/silk/entry/track.png", 16, 16, 'Track This' ),
+ LJ::S2::Image_std( 'track' ),
'lj_journalid' => $journalu->id,
'lj_etypeid' => $etypeid,
'lj_subid' => 0,
@@ -3801,7 +3822,7 @@ sub _Entry__get_link
return LJ::S2::Link(
"$LJ::SITEROOT/manage/subscriptions/entry?journal=$journal&itemid=$this->{'itemid'}",
$ctx->[S2::PROPS]->{"text_unwatch_comments"},
- LJ::S2::Image(
"$LJ::IMGPREFIX/silk/entry/untrack.png", 16, 16, 'Untrack this' ),
+ LJ::S2::Image_std( 'untrack' ),
'lj_journalid' => $journalu->id,
'lj_subid' => $subscr->id,
'lj_etypeid' => $etypeid,
diff -r 2c176a71404b -r 9380b580348a cgi-bin/LJ/S2/RecentPage.pm
--- a/cgi-bin/LJ/S2/RecentPage.pm Wed Jul 07 18:31:18 2010 +0800
+++ b/cgi-bin/LJ/S2/RecentPage.pm Thu Jul 08 15:00:02 2010 +0800
@@ -51,8 +51,7 @@ sub RecentPage
my $datalink = sub {
my ($what, $caption) = @_;
return Link($p->{'base_url'} . "/data/$what" . ($opts->{tags} ?
"?tag=".join(",", map({ LJ::eurl($_) } @{$opts->{tags}})) : ""),
- $caption,
- Image("$LJ::IMGPREFIX/data_$what.gif", 32, 15, $caption));
+ $caption, Image_std( $what ) );
};
$p->{'data_link'} = {
diff -r 2c176a71404b -r 9380b580348a cgi-bin/imageconf.pl
--- a/cgi-bin/imageconf.pl Wed Jul 07 18:31:18 2010 +0800
+++ b/cgi-bin/imageconf.pl Thu Jul 08 15:00:02 2010 +0800
@@ -17,144 +17,214 @@ package LJ::Img;
package LJ::Img;
use vars qw(%img);
-$img{'ins_obj'} = {
- 'src' => '/ins-object.gif',
- 'width' => 129,
- 'height' => 52,
- 'alt' => 'img.ins_obj',
+$img{ins_obj} = {
+ src => '/ins-object.gif',
+ width => 129,
+ height => 52,
+ alt => 'img.ins_obj',
};
-$img{'btn_up'} = {
- 'src' => '/btn_up.gif',
- 'width' => 22,
- 'height' => 20,
- 'alt' => 'img.btn_up',
+$img{btn_up} = {
+ src => '/btn_up.gif',
+ width => 22,
+ height => 20,
+ alt => 'img.btn_up',
};
-$img{'btn_down'} = {
- 'src' => '/btn_dn.gif',
- 'width' => 22,
- 'height' => 20,
- 'alt' => 'img.btn_down',
+$img{btn_down} = {
+ src => '/btn_dn.gif',
+ width => 22,
+ height => 20,
+ alt => 'img.btn_down',
};
-$img{'btn_del'} = {
- 'src' => '/silk/comments/delete.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.btn_del',
+$img{btn_del} = {
+ src => '/silk/comments/delete.png',
+ width => 16,
+ height => 16,
+ alt => 'img.btn_del',
};
-$img{'btn_freeze'} = {
- 'src' => '/silk/comments/freeze.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.btn_freeze',
+$img{btn_freeze} = {
+ src => '/silk/comments/freeze.png',
+ width => 16,
+ height => 16,
+ alt => 'img.btn_freeze',
};
-$img{'btn_unfreeze'} = {
- 'src' => '/silk/comments/unfreeze.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.btn_unfreeze',
+$img{btn_unfreeze} = {
+ src => '/silk/comments/unfreeze.png',
+ width => 16,
+ height => 16,
+ alt => 'img.btn_unfreeze',
};
-$img{'btn_scr'} = {
- 'src' => '/silk/comments/screen.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.btn_scr',
+$img{btn_scr} = {
+ src => '/silk/comments/screen.png',
+ width => 16,
+ height => 16,
+ alt => 'img.btn_scr',
};
-$img{'btn_unscr'} = {
- 'src' => '/silk/comments/unscreen.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.btn_unscr',
+$img{btn_unscr} = {
+ src => '/silk/comments/unscreen.png',
+ width => 16,
+ height => 16,
+ alt => 'img.btn_unscr',
};
-$img{'prev_entry'} = {
- 'src' => '/silk/entry/previous.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.prev_entry',
+$img{prev_entry} = {
+ src => '/silk/entry/previous.png',
+ width => 16,
+ height => 16,
+ alt => 'img.prev_entry',
};
-$img{'next_entry'} = {
- 'src' => '/silk/entry/next.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.next_entry',
+$img{next_entry} = {
+ src => '/silk/entry/next.png',
+ width => 16,
+ height => 16,
+ alt => 'img.next_entry',
};
-$img{'memadd'} = {
- 'src' => '/silk/entry/memories_add.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.memadd',
+$img{memadd} = {
+ src => '/silk/entry/memories_add.png',
+ width => 16,
+ height => 16,
+ alt => 'img.memadd',
};
-$img{'editentry'} = {
- 'src' => '/silk/entry/edit.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.editentry',
+$img{editentry} = {
+ src => '/silk/entry/edit.png',
+ width => 16,
+ height => 16,
+ alt => 'img.editentry',
};
-$img{'edittags'} = {
- 'src' => '/silk/entry/tag_edit.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.edittags',
+$img{edittags} = {
+ src => '/silk/entry/tag_edit.png',
+ width => 16,
+ height => 16,
+ alt => 'img.edittags',
};
-$img{'tellfriend'} = {
- 'src' => '/silk/entry/tellafriend.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.tellfriend',
+$img{tellfriend} = {
+ src => '/silk/entry/tellafriend.png',
+ width => 16,
+ height => 16,
+ alt => 'img.tellfriend',
};
-$img{'placeholder'} = {
- 'src' => '/imageplaceholder2.png',
- 'width' => 35,
- 'height' => 35,
- 'alt' => 'img.placeholder',
+$img{placeholder} = {
+ src => '/imageplaceholder2.png',
+ width => 35,
+ height => 35,
+ alt => 'img.placeholder',
};
-$img{'xml'} = {
- 'src' => '/xml.gif',
- 'width' => 36,
- 'height' => 14,
- 'alt' => 'img.xml',
+$img{xml} = {
+ src => '/xml.gif',
+ width => 36,
+ height => 14,
+ alt => 'img.xml',
};
-$img{'track'} = {
- 'src' => '/silk/entry/track.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.track',
+$img{track} = {
+ src => '/silk/entry/track.png',
+ width => 16,
+ height => 16,
+ alt => 'img.track',
};
-$img{'track_active'} = {
- 'src' => '/silk/entry/untrack.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.track_active',
+$img{track_active} = {
+ src => '/silk/entry/untrack.png',
+ width => 16,
+ height => 16,
+ alt => 'img.track_active',
};
-$img{'track_thread_active'} = {
- 'src' => '/silk/entry/untrack.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.track_thread_active',
+$img{track_thread_active} = {
+ src => '/silk/entry/untrack.png',
+ width => 16,
+ height => 16,
+ alt => 'img.track_thread_active',
};
-$img{'editcomment'} = {
- 'src' => '/silk/comments/edit.png',
- 'width' => 16,
- 'height' => 16,
- 'alt' => 'img.editcomment',
+$img{untrack} = {
+ src => '/silk/entry/untrack.png',
+ width => 16,
+ height => 16,
+ alt => 'img.untrack',
+};
+
+$img{editcomment} = {
+ src => '/silk/comments/edit.png',
+ width => 16,
+ height => 16,
+ alt => 'img.editcomment',
+};
+
+$img{foaf} = {
+ src => '/data_foaf.gif',
+ width => 32,
+ height => 15,
+ alt => 'img.foaf',
+};
+
+$img{atom} = {
+ src => '/data_atom.gif',
+ width => 32,
+ height => 15,
+ alt => 'img.atom',
+};
+
+$img{rss} = {
+ src => '/data_rss.gif',
+ width => 32,
+ height => 15,
+ alt => 'img.rss',
+};
+
+$img{'security-protected'} = {
+ src => '/silk/entry/locked.png',
+ width => 16,
+ height => 16,
+ alt => '', # S2::PROPS
+};
+
+$img{'security-private'} = {
+ src => '/silk/entry/private.png',
+ width => 16,
+ height => 16,
+ alt => '', # S2::PROPS
+};
+
+$img{'security-groups'} = {
+ src => '/silk/entry/filtered.png',
+ width => 21,
+ height => 13,
+ alt => '', # S2::PROPS
+};
+
+$img{'adult-nsfw'} = {
+ src => '/icon_nsfw.png',
+ width => 16,
+ height => 16,
+ alt => '', # S2::PROPS
+};
+
+$img{'adult-18'} = {
+ src => '/icon_18.png',
+ width => 16,
+ height => 16,
+ alt => '', # S2::PROPS
+};
+
+$img{'sticky-entry'} = {
+ src => '/silk/entry/sticky_entry.png',
+ width => 16,
+ height => 16,
+ alt => '', # S2::PROPS
};
# load the site-local version, if it's around.
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog