Commit 38213fecf97fea82664c9621bc7e0c21c926a776

Authored by Leandro Santos
1 parent 62c1d338

Adding ranking block

lib/gamification_plugin.rb
... ... @@ -53,6 +53,12 @@ class GamificationPlugin < Noosfero::Plugin
53 53 ['jquery.noty.packaged.min.js', 'jquery.easypiechart.min.js', 'main.js']
54 54 end
55 55  
  56 +
  57 + def self.extra_blocks
  58 + { GamificationPlugin::RankingBlock => {}}
  59 + end
  60 +
  61 +
56 62 ActionDispatch::Reloader.to_prepare do
57 63 Merit.setup do |config|
58 64 config.checks_on_each_request = false
... ...
lib/gamification_plugin/ranking_block.rb 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +class GamificationPlugin::RankingBlock < Block
  2 +
  3 + settings_items :limit, :type => :integer, :default => 5
  4 +
  5 + def self.description
  6 + _('Gamification Ranking')
  7 + end
  8 +
  9 + def help
  10 + _('This block display te gamification rank.')
  11 + end
  12 +
  13 + def self.pretty_name
  14 + _('Gamification Ranking')
  15 + end
  16 +
  17 + def embedable?
  18 + true
  19 + end
  20 +
  21 + def content(args={})
  22 + block = self
  23 + proc do
  24 + render :file => 'blocks/ranking', :locals => {:block => block}
  25 + end
  26 + end
  27 +
  28 +end
... ...
views/blocks/ranking.html.erb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<%= block_title(block.title) %>
  2 +<% extend GamificationPlugin::DashboardHelper %>
  3 +
  4 +<div class="ranking_block" id="ranking_block_<%= block.id %>">
  5 + <%= ranking(block.owner, Time.zone.now.at_beginning_of_week, 5) %>
  6 +</div>
... ...