[dw-free] Add "current mood of service" toy
[commit: http://hg.dwscoalition.org/dw-free/rev/eff6f5a0005f]
http://bugs.dwscoalition.org/show_bug.cgi?id=5
New toy: Mood of Service, which gauges the general mood of Dreamwidth, based
on the latest entries.
Patch by
exor674. Images by
maiden.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=5
New toy: Mood of Service, which gauges the general mood of Dreamwidth, based
on the latest entries.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/moods.dat
- bin/upgrading/update-db-general.pl
- bin/upgrading/update-db.pl
- cgi-bin/DW/Controller/Latest/Mood.pm
- cgi-bin/DW/LatestFeed.pm
- cgi-bin/ljmood.pl
- htdocs/img/mood/dwhappy.png
- htdocs/img/mood/dwsad.png
- htdocs/img/mood/gradient.png
- htdocs/latest.bml
- htdocs/latest.bml.text
- htdocs/site/index.bml
- htdocs/site/index.bml.text
- htdocs/stc/moodofservice.css
- views/latest/mood.tt
- views/latest/mood.tt.text
-------------------------------------------------------------------------------- diff -r 341f58d4f70e -r eff6f5a0005f bin/upgrading/moods.dat --- a/bin/upgrading/moods.dat Wed Jun 16 00:35:21 2010 +0800 +++ b/bin/upgrading/moods.dat Wed Jun 16 01:26:31 2010 +0800 @@ -1,135 +1,135 @@ MOOD 1 aggravated 2 -MOOD 1 aggravated 2 -MOOD 2 angry 0 -MOOD 3 annoyed 2 -MOOD 4 anxious 46 -MOOD 5 bored 25 -MOOD 6 confused 0 -MOOD 7 crappy 25 -MOOD 8 cranky 2 -MOOD 9 depressed 25 -MOOD 10 discontent 25 -MOOD 11 energetic 0 -MOOD 12 enraged 2 -MOOD 13 enthralled 0 -MOOD 14 exhausted 74 -MOOD 15 happy 0 -MOOD 16 high 41 -MOOD 17 horny 41 -MOOD 18 hungry 74 -MOOD 19 infuriated 2 -MOOD 20 irate 2 -MOOD 21 jubilant 15 -MOOD 22 lonely 25 -MOOD 23 moody 2 -MOOD 24 pissed off 2 -MOOD 25 sad 0 -MOOD 26 satisfied 53 -MOOD 27 sore 74 -MOOD 28 stressed 2 -MOOD 29 thirsty 74 -MOOD 30 thoughtful 0 -MOOD 31 tired 14 -MOOD 32 touched 15 -MOOD 33 lazy 61 -MOOD 34 drunk 74 -MOOD 35 ditzy 66 -MOOD 36 mischievous 66 -MOOD 37 morose 25 -MOOD 38 gloomy 25 -MOOD 39 melancholy 25 -MOOD 40 drained 14 -MOOD 41 excited 15 -MOOD 42 relieved 26 -MOOD 43 hopeful 70 -MOOD 44 amused 15 -MOOD 45 determined 0 -MOOD 46 scared 0 -MOOD 47 frustrated 2 -MOOD 48 indescribable 0 -MOOD 49 sleepy 31 -MOOD 51 groggy 31 -MOOD 52 hyper 11 -MOOD 53 relaxed 15 -MOOD 54 restless 74 -MOOD 55 disappointed 25 -MOOD 56 curious 6 -MOOD 57 mellow 53 -MOOD 58 peaceful 53 -MOOD 59 bouncy 11 -MOOD 60 nostalgic 30 -MOOD 61 okay 0 -MOOD 62 rejuvenated 69 -MOOD 63 complacent 64 -MOOD 64 content 26 -MOOD 65 indifferent 64 -MOOD 66 silly 15 -MOOD 67 flirty 66 -MOOD 68 calm 53 -MOOD 69 refreshed 15 -MOOD 70 optimistic 15 -MOOD 71 pessimistic 38 -MOOD 72 giggly 66 -MOOD 73 pensive 30 -MOOD 74 uncomfortable 25 -MOOD 75 lethargic 33 -MOOD 76 listless 33 -MOOD 77 recumbent 53 -MOOD 78 exanimate 33 -MOOD 79 embarrassed 46 -MOOD 80 envious 10 -MOOD 81 sympathetic 25 -MOOD 82 sick 74 -MOOD 83 hot 74 -MOOD 84 cold 74 -MOOD 85 worried 25 -MOOD 86 loved 15 -MOOD 87 awake 0 -MOOD 88 working 0 -MOOD 89 productive 88 -MOOD 90 accomplished 88 -MOOD 91 busy 88 -MOOD 92 blah 61 -MOOD 93 full 26 -MOOD 95 grumpy 2 -MOOD 96 weird 66 -MOOD 97 nauseated 82 -MOOD 98 ecstatic 15 -MOOD 99 chipper 15 -MOOD 100 rushed 28 -MOOD 101 contemplative 30 -MOOD 102 nerdy 0 -MOOD 103 geeky 102 -MOOD 104 cynical 2 -MOOD 105 quixotic 66 -MOOD 106 crazy 66 -MOOD 107 creative 88 -MOOD 108 artistic 88 -MOOD 109 pleased 15 -MOOD 110 bitchy 2 -MOOD 111 guilty 74 -MOOD 112 irritated 2 -MOOD 113 blank 78 -MOOD 114 apathetic 78 -MOOD 115 dorky 102 -MOOD 116 impressed 15 -MOOD 117 naughty 36 -MOOD 118 predatory 45 -MOOD 119 dirty 74 -MOOD 120 giddy 66 -MOOD 121 surprised 15 -MOOD 122 shocked 121 -MOOD 123 rejected 25 -MOOD 124 numb 25 -MOOD 125 cheerful 15 -MOOD 126 good 15 -MOOD 127 distressed 4 -MOOD 128 intimidated 46 -MOOD 129 crushed 25 -MOOD 130 devious 0 -MOOD 131 thankful 15 -MOOD 132 grateful 15 -MOOD 133 jealous 25 -MOOD 134 nervous 46 +MOOD 1 aggravated 2 20 +MOOD 2 angry 0 10 +MOOD 3 annoyed 2 20 +MOOD 4 anxious 46 15 +MOOD 5 bored 25 40 +MOOD 6 confused 0 40 +MOOD 7 crappy 25 20 +MOOD 8 cranky 2 20 +MOOD 9 depressed 25 10 +MOOD 10 discontent 25 25 +MOOD 11 energetic 0 65 +MOOD 12 enraged 2 1 +MOOD 13 enthralled 0 80 +MOOD 14 exhausted 74 40 +MOOD 15 happy 0 90 +MOOD 16 high 41 90 +MOOD 17 horny 41 90 +MOOD 18 hungry 74 40 +MOOD 19 infuriated 2 1 +MOOD 20 irate 2 20 +MOOD 21 jubilant 15 100 +MOOD 22 lonely 25 20 +MOOD 23 moody 2 30 +MOOD 24 pissed off 2 20 +MOOD 25 sad 0 30 +MOOD 26 satisfied 53 90 +MOOD 27 sore 74 25 +MOOD 28 stressed 2 30 +MOOD 29 thirsty 74 40 +MOOD 30 thoughtful 0 65 +MOOD 31 tired 14 40 +MOOD 32 touched 15 85 +MOOD 33 lazy 61 50 +MOOD 34 drunk 74 50 +MOOD 35 ditzy 66 50 +MOOD 36 mischievous 66 90 +MOOD 37 morose 25 15 +MOOD 38 gloomy 25 25 +MOOD 39 melancholy 25 20 +MOOD 40 drained 14 40 +MOOD 41 excited 15 90 +MOOD 42 relieved 26 75 +MOOD 43 hopeful 70 80 +MOOD 44 amused 15 85 +MOOD 45 determined 0 50 +MOOD 46 scared 0 20 +MOOD 47 frustrated 2 20 +MOOD 48 indescribable 0 50 +MOOD 49 sleepy 31 40 +MOOD 51 groggy 31 40 +MOOD 52 hyper 11 75 +MOOD 53 relaxed 15 90 +MOOD 54 restless 74 40 +MOOD 55 disappointed 25 20 +MOOD 56 curious 6 60 +MOOD 57 mellow 53 85 +MOOD 58 peaceful 53 85 +MOOD 59 bouncy 11 85 +MOOD 60 nostalgic 30 65 +MOOD 61 okay 0 50 +MOOD 62 rejuvenated 69 85 +MOOD 63 complacent 64 80 +MOOD 64 content 26 90 +MOOD 65 indifferent 64 50 +MOOD 66 silly 15 75 +MOOD 67 flirty 66 80 +MOOD 68 calm 53 90 +MOOD 69 refreshed 15 85 +MOOD 70 optimistic 15 80 +MOOD 71 pessimistic 38 20 +MOOD 72 giggly 66 90 +MOOD 73 pensive 30 55 +MOOD 74 uncomfortable 25 30 +MOOD 75 lethargic 33 40 +MOOD 76 listless 33 55 +MOOD 77 recumbent 53 75 +MOOD 78 exanimate 33 40 +MOOD 79 embarrassed 46 20 +MOOD 80 envious 10 25 +MOOD 81 sympathetic 25 50 +MOOD 82 sick 74 25 +MOOD 83 hot 74 40 +MOOD 84 cold 74 40 +MOOD 85 worried 25 20 +MOOD 86 loved 15 90 +MOOD 87 awake 0 50 +MOOD 88 working 0 50 +MOOD 89 productive 88 75 +MOOD 90 accomplished 88 75 +MOOD 91 busy 88 50 +MOOD 92 blah 61 40 +MOOD 93 full 26 85 +MOOD 95 grumpy 2 20 +MOOD 96 weird 66 50 +MOOD 97 nauseated 82 25 +MOOD 98 ecstatic 15 100 +MOOD 99 chipper 15 85 +MOOD 100 rushed 28 45 +MOOD 101 contemplative 30 65 +MOOD 102 nerdy 0 50 +MOOD 103 geeky 102 50 +MOOD 104 cynical 2 25 +MOOD 105 quixotic 66 50 +MOOD 106 crazy 66 50 +MOOD 107 creative 88 75 +MOOD 108 artistic 88 75 +MOOD 109 pleased 15 85 +MOOD 110 bitchy 2 20 +MOOD 111 guilty 74 25 +MOOD 112 irritated 2 20 +MOOD 113 blank 78 40 +MOOD 114 apathetic 78 40 +MOOD 115 dorky 102 50 +MOOD 116 impressed 15 85 +MOOD 117 naughty 36 90 +MOOD 118 predatory 45 50 +MOOD 119 dirty 74 40 +MOOD 120 giddy 66 95 +MOOD 121 surprised 15 50 +MOOD 122 shocked 121 50 +MOOD 123 rejected 25 15 +MOOD 124 numb 25 25 +MOOD 125 cheerful 15 85 +MOOD 126 good 15 80 +MOOD 127 distressed 4 15 +MOOD 128 intimidated 46 20 +MOOD 129 crushed 25 1 +MOOD 130 devious 0 60 +MOOD 131 thankful 15 80 +MOOD 132 grateful 15 85 +MOOD 133 jealous 25 20 +MOOD 134 nervous 46 15 MOODTHEME Kanji Moods : A bunch of moods in kanji by Pne 1 /img/mood/kanji/aggravated.gif 18 18 102 /img/mood/kanji/nerdy.gif 18 18 diff -r 341f58d4f70e -r eff6f5a0005f bin/upgrading/update-db-general.pl --- a/bin/upgrading/update-db-general.pl Wed Jun 16 00:35:21 2010 +0800 +++ b/bin/upgrading/update-db-general.pl Wed Jun 16 01:26:31 2010 +0800 @@ -192,6 +192,7 @@ CREATE TABLE moods ( moodid int(10) unsigned NOT NULL auto_increment, mood varchar(40) default NULL, parentmood int(10) unsigned NOT NULL default '0', + weight tinyint unsigned default NULL, PRIMARY KEY (moodid), UNIQUE KEY mood (mood) @@ -3882,6 +3883,10 @@ EOF q{ALTER TABLE import_data ADD COLUMN options BLOB} ); } + unless ( column_type( 'moods', 'weight' ) ) { + do_alter( 'moods', + q{ALTER TABLE moods ADD COLUMN weight tinyint unsigned default NULL} ); + } }); diff -r 341f58d4f70e -r eff6f5a0005f bin/upgrading/update-db.pl --- a/bin/upgrading/update-db.pl Wed Jun 16 00:35:21 2010 +0800 +++ b/bin/upgrading/update-db.pl Wed Jun 16 01:26:31 2010 +0800 @@ -567,9 +567,9 @@ sub populate_moods { print "Populating ${local}mood data.\n"; my %mood; # id -> [ mood, parent_id ] - my $sth = $dbh->prepare("SELECT moodid, mood, parentmood FROM moods"); + my $sth = $dbh->prepare("SELECT moodid, mood, parentmood, weight FROM moods"); $sth->execute; - while (@_ = $sth->fetchrow_array) { $mood{$_[0]} = [ $_[1], $_[2] ]; } + while (@_ = $sth->fetchrow_array) { $mood{$_[0]} = [ $_[1], $_[2], $_[3] ]; } my %moodtheme; # name -> [ id, des ] $sth = $dbh->prepare("SELECT moodthemeid, name, des FROM moodthemes WHERE is_public='Y'"); @@ -581,12 +581,15 @@ sub populate_moods { while (<M>) { chomp; - if (/^MOOD\s+(\d+)\s+(.+)\s+(\d+)\s*$/) { - my ($id, $mood, $parid) = ($1, $2, $3); + if (/^MOOD\s+(\d+)\s+(.+)\s+(\d+)\s+(\d+)\s*$/) { + my ($id, $mood, $parid, $weight) = ($1, $2, $3, $4); if (! $mood{$id} || $mood{$id}->[0] ne $mood || $mood{$id}->[1] ne $parid) { - $dbh->do("REPLACE INTO moods (moodid, mood, parentmood) VALUES (?,?,?)", - undef, $id, $mood, $parid); + $dbh->do( "REPLACE INTO moods (moodid, mood, parentmood, weight) VALUES (?,?,?,?)", + undef, $id, $mood, $parid, $weight ); + } elsif ( ! defined $mood{$id}->[2]) { + $dbh->do( "UPDATE moods SET weight = ? WHERE moodid = ?", + undef, $weight, $id ); } } diff -r 341f58d4f70e -r eff6f5a0005f cgi-bin/DW/Controller/Latest/Mood.pm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cgi-bin/DW/Controller/Latest/Mood.pm Wed Jun 16 01:26:31 2010 +0800 @@ -0,0 +1,82 @@ +#!/usr/bin/perl +# +# DW::Controller::Latest::Mood +# +# Mood of the service toy. +# +# Authors: +# Andrea Nall <anall@andreanall.com> +# +# Copyright (c) 2010 by Dreamwidth Studios, LLC. +# +# This program is free software; you may redistribute it and/or modify it under +# the same terms as Perl itself. For a copy of the license, please reference +# 'perldoc perlartistic' or 'perldoc perlgpl'. +# +package DW::Controller::Latest::Mood; +use strict; +use warnings; +use DW::Routing; +use DW::Template; +use DW::Request; +use JSON; + +DW::Routing->register_string( "/latest/mood", \&mood_handler ); + +sub mood_handler { + my $r = DW::Request->get; + + my $formats = { + html => sub { + DW::Template->render_template( "latest/mood.tt", $_[0] ); + }, + json => sub { + $r->status( 503 ) if $_[0]->{no_data}; + $r->print( objToJson( $_[0] ) ); + return $r->OK; + }, + }; + + my $format = $formats->{ $_[0]->format || 'html' }; + + return $r->NOT_FOUND if ! $format; + + my $moods = LJ::MemCache::get( "latest_moods" ) || []; + my $out = {}; + + if ( scalar @$moods ) { + my %counts; + my $score = 0; + my $count = scalar @$moods; + + my $metadata = LJ::get_moods(); + + foreach my $moodid ( @$moods ) { + $score += $metadata->{$moodid}->{weight} || 50; + $counts{$metadata->{$moodid}->{name}}++; + } + + my @names = sort { $counts{$b} <=> $counts{$a} || $a cmp $b } keys %counts; + my %top_counts = map { ($_,$counts{$_}) } @names[0..5]; + my @top_mood; + foreach my $mood ( @names ) { + if ( $counts{$mood} == $counts{$names[0]} ) { + push @top_mood, $mood; + } else { + last; + } + } + + $out->{counts} = \%top_counts; + $out->{score} = int($score / $count); + $out->{score} = $r->get_args->{score} if defined $r->get_args->{score}; + $out->{highest} = [ @names[0..5] ]; + $out->{top_mood} = \@top_mood; + } else { + $out->{no_data} = 1; + } + + return $format->( $out ); +} + +1; diff -r 341f58d4f70e -r eff6f5a0005f cgi-bin/DW/LatestFeed.pm --- a/cgi-bin/DW/LatestFeed.pm Wed Jun 16 00:35:21 2010 +0800 +++ b/cgi-bin/DW/LatestFeed.pm Wed Jun 16 01:26:31 2010 +0800 @@ -346,6 +346,15 @@ sub _process_queue { } + # step 7.8) if the entry has a mood, add the moodid to the list of moods. + my $moodid = $ent->prop( 'current_moodid' ); + if ( $item->{type} eq 'entry' and $moodid ) { + my $nom = "latest_moods"; + $lists{$nom} ||= LJ::MemCache::get( $nom ) || []; + unshift @{$lists{$nom}}, $moodid; + } + + # we always put the item onto the latest everything list unshift @{$lists{latest_items}}, $item; } diff -r 341f58d4f70e -r eff6f5a0005f cgi-bin/ljmood.pl --- a/cgi-bin/ljmood.pl Wed Jun 16 00:35:21 2010 +0800 +++ b/cgi-bin/ljmood.pl Wed Jun 16 01:26:31 2010 +0800 @@ -72,10 +72,10 @@ sub load_moods { return if $LJ::CACHED_MOODS; my $dbr = LJ::get_db_reader(); - my $sth = $dbr->prepare("SELECT moodid, mood, parentmood FROM moods"); + my $sth = $dbr->prepare("SELECT moodid, mood, parentmood, weight FROM moods"); $sth->execute; - while (my ($id, $mood, $parent) = $sth->fetchrow_array) { - $LJ::CACHE_MOODS{$id} = { 'name' => $mood, 'parent' => $parent, 'id' => $id }; + while (my ($id, $mood, $parent, $weight) = $sth->fetchrow_array) { + $LJ::CACHE_MOODS{$id} = { name => $mood, parent => $parent, id => $id, weight => $weight }; if ($id > $LJ::CACHED_MOOD_MAX) { $LJ::CACHED_MOOD_MAX = $id; } } $LJ::CACHED_MOODS = 1; diff -r 341f58d4f70e -r eff6f5a0005f htdocs/img/mood/dwhappy.png Binary file htdocs/img/mood/dwhappy.png has changed diff -r 341f58d4f70e -r eff6f5a0005f htdocs/img/mood/dwsad.png Binary file htdocs/img/mood/dwsad.png has changed diff -r 341f58d4f70e -r eff6f5a0005f htdocs/img/mood/gradient.png Binary file htdocs/img/mood/gradient.png has changed diff -r 341f58d4f70e -r eff6f5a0005f htdocs/latest.bml --- a/htdocs/latest.bml Wed Jun 16 00:35:21 2010 +0800 +++ b/htdocs/latest.bml Wed Jun 16 01:26:31 2010 +0800 @@ -129,17 +129,14 @@ body<= $tagfeeds .= "<br /><br />" . LJ::tag_cloud( $taghr ) . "\n"; } + + + my $ret = ""; + $ret .= "<?p " . BML::ml( ".intro", { sitename => $LJ::SITENAME } ) . " p?>"; + $ret .= "<?p " . BML::ml( ".intro.moods", { sitenameshort => $LJ::SITENAMESHORT, aopts => "href='$LJ::SITEROOT/latest/mood'" } ) . " p?>"; + # put filtering options in a standout box $tagfeeds = "<?standout $tagfeeds standout?><br />" if $tagfeeds; - - my $ret = <<EOF; -<?p Latest things on $LJ::SITENAME. This page shows you a sample of the most recently posted -things that are available on the site. The feed is updated every minute or two. Also, new -posts and comments won't show up until five (5) minutes after they are posted. Just in case -they are accidentally posted public. p?> - -$tagfeeds -EOF # great, we now have objects, we can construct our results in some fashion my $now = time; diff -r 341f58d4f70e -r eff6f5a0005f htdocs/latest.bml.text --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htdocs/latest.bml.text Wed Jun 16 01:26:31 2010 +0800 @@ -0,0 +1,5 @@ +;; -*- coding: utf-8 -*- + +.intro=Latest things on [[sitename]]. This page shows you a sample of the most recently posted things that are available on the site. The feed is updated every minute or two. Also, new posts and comments won't show up until five (5) minutes after they are posted. Just in case they are accidentally posted public. + +.intro.moods=Other things you can do with the latest entries: find out the <a [[aopts]]>general mood of [[sitenameshort]]</a>. diff -r 341f58d4f70e -r eff6f5a0005f htdocs/site/index.bml --- a/htdocs/site/index.bml Wed Jun 16 00:35:21 2010 +0800 +++ b/htdocs/site/index.bml Wed Jun 16 01:26:31 2010 +0800 @@ -161,6 +161,7 @@ _code?> <dl><dt><?_code return BML::ml('.maplinks.toys-title', { sitename => $LJ::SITENAMESHORT }); _code?></dt> <dd><ul> <li><a href='/birthdays'><?_ml .maplinks.birthdays _ml?></a></li> + <li><a href='/latest/mood'><?_ml .maplinks.latestmoods _ml?></a></li> </ul></dd></dl> <dl><dt><?_code return BML::ml('.maplinks.advanced-tools-title', { sitename => $LJ::SITENAMESHORT }); _code?></dt> diff -r 341f58d4f70e -r eff6f5a0005f htdocs/site/index.bml.text --- a/htdocs/site/index.bml.text Wed Jun 16 00:35:21 2010 +0800 +++ b/htdocs/site/index.bml.text Wed Jun 16 01:26:31 2010 +0800 @@ -133,6 +133,8 @@ .maplinks.birthdays=Upcoming birthdays +.maplinks.latestmoods=Mood of Service + .maplinks.advanced-tools-title=...use the advanced tools: .maplinks.console=Admin console @@ -147,4 +149,4 @@ .maplinks.search.site=Site search -.maplinks.search.journal=Journal search \ No newline at end of file +.maplinks.search.journal=Journal search diff -r 341f58d4f70e -r eff6f5a0005f htdocs/stc/moodofservice.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/htdocs/stc/moodofservice.css Wed Jun 16 01:26:31 2010 +0800 @@ -0,0 +1,32 @@ +/* + stc/moodofservice.css + + CSS classes for rendering the mood of service page. + + Authors: + maiden <brandnewaquarium@gmail.com> + Andrea Nall <anall@andreanall.com> + + Copyright (c) 2010 by Dreamwidth Studios, LLC. + + This program is free software; you may redistribute it and/or modify it under + the same terms as Perl itself. For a copy of the license, please reference + 'perldoc perlartistic' or 'perldoc perlgpl'. +*/ + +.happyface, .sadface { + float:left; +} + +/* Important: + If you change the left margin, the right margin or the width of the image please make sure to adjust + the formula in latest/mood.tt -- the formula relies on the values here to correctly place the indicator. +*/ +.moodgradient { + margin: 6px 12px 0 12px; + padding: 13px 0 0 0; + float:left; + height: 24px; + width: 650px; + background-image: url(/img/mood/gradient.png); +} diff -r 341f58d4f70e -r eff6f5a0005f views/latest/mood.tt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/views/latest/mood.tt Wed Jun 16 01:26:31 2010 +0800 @@ -0,0 +1,32 @@ +[%# latest/mood.tt + +"Current mood of service" toy. + +Authors: + maiden <brandnewaquarium@gmail.com> + Andrea Nall <anall@andreanall.com> + +Copyright (c) 2010 by Dreamwidth Studios, LLC. + +This program is free software; you may redistribute it and/or modify it under +the same terms as Perl itself. For a copy of the license, please reference +'perldoc perlartistic' or 'perldoc perlgpl'. +%] +[%- sections.title = '.title' | ml -%] +<p>[% '.info' | ml( aopts = "href=\"$roots.site/latest\"", sitename = site.name ) %]</p> +[%- IF no_data -%] +<p>[% '.no_data' | ml %]</p> +[%- ELSE -%] +[%- dw.need_res('stc/moodofservice.css') -%] +<h1>[% ( top_mood.length == 1 ? '.current_mood' : '.current_moods' ) | ml %]</h1> +<p>[% top_mood.join(', ') %]</p> + +<h1>[% '.emotional_weather' | ml %]</h1> +<div id="moodhold"> +<div class="sadface"> <img src="[% roots.img %]/mood/dwsad.png" alt="[% '.alt.sad' | ml %]" /></div> +<div class="moodgradient"> <img src="[% roots.img %]/silk/24x24/user.png" alt="[% '.alt.indicator' | ml(score = score, top = 100) %]" style="margin-left: [% (score / 100) * 650 - 12 | format("%ipx") %]" /></div> +[%# The above formula in the inline style is derived from the width and margin of the moodgradient class in the CSS file. + ( score / 100 ) * <width> - <margin (left or right)> %] +<div class="happyface"> <img src="[% roots.img %]/mood/dwhappy.png" alt="[% '.alt.happy' | ml %]" /></div> +</div> +[%- END -%] \ No newline at end of file diff -r 341f58d4f70e -r eff6f5a0005f views/latest/mood.tt.text --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/views/latest/mood.tt.text Wed Jun 16 01:26:31 2010 +0800 @@ -0,0 +1,19 @@ +;; -*- coding: utf-8 -*- + +.alt.happy=happy + +.alt.indicator=[[score]] out of [[top]] + +.alt.sad=sad + +.current_mood=Current Mood + +.current_moods=Current Moods + +.emotional_weather=Emotional Weather + +.info=Here you can see [[sitename]]'s current mood! This is the most-used mood on the last 1000 <a [[aopts]]>latest posts</a>. + +.no_data=There is currently no current mood to display. Please check later. + +.title=Mood of Service --------------------------------------------------------------------------------
no subject