From 446a117ec86dc860b3cb8161dadd92faa55791a6 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 6 Nov 2010 12:15:10 -0400 Subject: [PATCH] top contributors --- app/controllers/users_controller.rb | 5 +++++ app/models/user.rb | 2 +- app/stylesheets/screen.sass | 1 + app/stylesheets/users/_top_contributors.sass | 15 ++++++++++++++ app/views/users/top_contributors.html.haml | 15 ++++++++++++++ public/stylesheets/compiled/screen.css | 21 ++++++++++++++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 app/controllers/users_controller.rb create mode 100644 app/stylesheets/users/_top_contributors.sass create mode 100644 app/views/users/top_contributors.html.haml diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 00000000..70ed203d --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,5 @@ +class UsersController < ApplicationController + def top_contributors + @users = User.top_contributors.paginate :page => params[:page], :per_page => 20 + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 1f607637..467784bc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,7 +3,7 @@ class User < ActiveRecord::Base has_many :contributions - scope :top_contributors, order('points DESC') + scope :top_contributors, order('points DESC').where(arel_table[:points].gt(0)) def self.find_or_create_from_remote_auth_data(user_data) user = find_or_initialize_by_remote_id_and_auth_server_id( diff --git a/app/stylesheets/screen.sass b/app/stylesheets/screen.sass index 82652df5..d35429f1 100644 --- a/app/stylesheets/screen.sass +++ b/app/stylesheets/screen.sass @@ -11,3 +11,4 @@ @import outfits/new @import pets/bulk @import static/terms +@import users/top_contributors diff --git a/app/stylesheets/users/_top_contributors.sass b/app/stylesheets/users/_top_contributors.sass new file mode 100644 index 00000000..94d41b35 --- /dev/null +++ b/app/stylesheets/users/_top_contributors.sass @@ -0,0 +1,15 @@ +body.users-top_contributors + text-align: center + + #top-contributors + border: + spacing: 0 + width: 1px 1px 0 0 + margin: 1em auto + &, td, th + border: + color: $text-color + style: solid + td, th + border-width: 0 0 1px 1px + padding: .5em 1em diff --git a/app/views/users/top_contributors.html.haml b/app/views/users/top_contributors.html.haml new file mode 100644 index 00000000..8b04129a --- /dev/null +++ b/app/views/users/top_contributors.html.haml @@ -0,0 +1,15 @@ +- title 'Top Contributors' += will_paginate @users +%table#top-contributors + %thead + %tr + %th{:scope => 'column'} Rank + %th{:scope => 'column'} User + %th{:scope => 'column'} Points + %tbody + - @users.each_with_index do |user, rank| + %tr + %th{:scope => 'row'}= @users.offset + rank + 1 + %td= link_to user.name, user_contributions_path(user) + %td= user.points += will_paginate @users diff --git a/public/stylesheets/compiled/screen.css b/public/stylesheets/compiled/screen.css index 231e1e8a..ea9ca518 100644 --- a/public/stylesheets/compiled/screen.css +++ b/public/stylesheets/compiled/screen.css @@ -956,3 +956,24 @@ body.pets-bulk .script-only { body.static-terms { text-align: center; } + +/* line 1, ../../../app/stylesheets/users/_top_contributors.sass */ +body.users-top_contributors { + text-align: center; +} +/* line 4, ../../../app/stylesheets/users/_top_contributors.sass */ +body.users-top_contributors #top-contributors { + border-spacing: 0; + border-width: 1px 1px 0 0; + margin: 1em auto; +} +/* line 9, ../../../app/stylesheets/users/_top_contributors.sass */ +body.users-top_contributors #top-contributors, body.users-top_contributors #top-contributors td, body.users-top_contributors #top-contributors th { + border-color: #004400; + border-style: solid; +} +/* line 13, ../../../app/stylesheets/users/_top_contributors.sass */ +body.users-top_contributors #top-contributors td, body.users-top_contributors #top-contributors th { + border-width: 0 0 1px 1px; + padding: 0.5em 1em; +}