Changeset 1250
- Timestamp:
- 11/15/08 18:09:47 (16 months ago)
- Location:
- trunk/Score
- Files:
-
- 4 added
- 5 modified
-
mt-static/plugins/Score/FavTog (added)
-
mt-static/plugins/Score/FavTog/score.js (added)
-
mt-static/plugins/Score/Follow (added)
-
mt-static/plugins/Score/Follow/score.js (added)
-
mt-static/plugins/Score/score_base.js (modified) (1 diff)
-
plugins/Score/config.yaml (modified) (3 diffs)
-
plugins/Score/lib/Score/App.pm (modified) (1 diff)
-
plugins/Score/lib/Score/Tag.pm (modified) (1 diff)
-
tutorial.markdown (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Score/mt-static/plugins/Score/score_base.js
r1221 r1250 19 19 if (!xh) return false; 20 20 DOM.addClassName( el, pending ); 21 var url = commentScript + '?__mode=' + ns + '_score&static=1&entry_id=' + obj_id + '&score=' + score;21 var url = blogSettings.commentScript + '?__mode=' + ns + '_score&static=1&entry_id=' + obj_id + '&score=' + score; 22 22 xh.open('POST', url, true); 23 23 xh.onreadystatechange = function() { -
trunk/Score/plugins/Score/config.yaml
r1221 r1250 1 1 id: score 2 2 name: Score 3 version: 0. 13 version: 0.2 4 4 description: Scoring framework for 5 5 author_name: Beau Smith; Fumiaki Yoshimatsu … … 12 12 fivestar_score: $Score::Score::App::score_fivestar 13 13 favorite_score: $Score::Score::App::score_favorite 14 favtog_score: $Score::Score::App::score_favtog 14 15 15 16 tags: … … 19 20 FiveStarScore: $Score::Score::Tag::_hdlr_five_star_score 20 21 FavoriteScore: $Score::Score::Tag::_hdlr_favorite_score 22 FavTogCount: $Score::Score::Tag::_hdlr_favtog_count 23 FavTogScore: $Score::Score::Tag::_hdlr_favtog_score 21 24 22 25 # TODO -
trunk/Score/plugins/Score/lib/Score/App.pm
r1221 r1250 27 27 require JSON; 28 28 $app->print("dugScoreResponse($entry_id,$count);"); 29 return undef; 30 } 31 32 sub score_favtog { 33 my $app = shift; 34 my $q = $app->param; 35 my ( $sess_obj, $commenter ) = $app->get_commenter_session(); 36 # return $app->redirect_to_target unless $commenter && ( 'MT::Author' eq ref($commenter) ); 37 38 my $entry_id = $q->param('entry_id') 39 or return $app->handle_error( 40 $app->translate( 'Entry ID is missing.' ) ); 41 my $entry = $app->model('entry')->load($entry_id) 42 or return $app->handle_error( 43 $app->translate( 'Entry is missing.' ) ); 44 my $score = defined $q->param('score') 45 ? $q->param('score') 46 : 1; 47 48 $entry->set_score( 'favtog', $commenter, $score, 1 ); 49 my $sum = $entry->score_for( 'favtog' ); 50 51 $app->rebuild_entry( Entry => $entry_id, PreferredArchiveOnly => 1, BuildIndexes => 1 ) 52 or return $app->handle_error( 53 $app->translate( "Publish failed: [_1]", $app->errstr ) ); 54 55 $app->send_http_header("text/javascript+json"); 56 $app->{no_print_body} = 1; 57 require JSON; 58 $app->print("$sum"); 29 59 return undef; 30 60 } -
trunk/Score/plugins/Score/lib/Score/Tag.pm
r1221 r1250 19 19 my $html = <<HTML; 20 20 <a href="javascript:void(0)" id="dug$id" onclick="dugScore('$id');">$score</a> 21 HTML 22 return $html; 23 } 24 25 26 sub _hdlr_favtog_count { 27 my ( $ctx, $args ) = @_; 28 my $entry = $ctx->stash('entry') 29 or return $ctx->_no_entry_error(); 30 my $count = $entry->votes_for( 'FavTogScore' ); 31 return $ctx->count_format($count, $args); 32 } 33 34 sub _hdlr_favtog_score { 35 my ( $ctx, $args ) = @_; 36 my $tag = $args->{tag} || 'span'; 37 my $class = $args->{class} || ''; 38 $class = ' ' . $class if $class; 39 my $entry = $ctx->stash('entry') 40 or return $ctx->_no_entry_error(); 41 # my $score = $entry->votes_for( 'FavTogScore' ); 42 my $id = $entry->id; 43 my $html = <<HTML; 44 <$tag id="favtog$id" class="favtog$class">favorite</$tag> 21 45 HTML 22 46 return $html; -
trunk/Score/tutorial.markdown
r1221 r1250 66 66 Scoring 67 67 68 2. Update the header template with the JavaScript code to set a few variables and link to the base scoring functions.68 2. Set a few variables and link to the base scoring functions. If these variables my already exist in the blog's javascript file, you only need to link to the scripts in the header. 69 69 70 70 <script type="text/javascript"> 71 var staticWebPath = "<$mt:StaticWebPath$>"; 72 var commentScript = "<$mt:CGIPath$><$mt:CommentScript$>"; 71 var blogSettings = { 72 commentScript: '<$mt:CGIPath$><$mt:CommentScript$>', 73 staticWebPath: <$mt:StaticWebPath$>" 74 }; 73 75 </script> 74 76 <script type="text/javascript" src="<$mt:StaticWebPath$>plugins/Score/score_base.js"></script>
