This commit is contained in:
Toks
2013-04-17 20:09:48 -04:00
parent 30d7e22522
commit 53ee04d6a2
7 changed files with 48 additions and 8 deletions

View File

@@ -0,0 +1,31 @@
a.user-admin.with-style {
color: red;
}
a.user-moderator.with-style {
color: orange;
}
a.user-janitor.with-style {
color: green;
}
a.user-contributor.with-style {
color: purple;
}
a.user-builder.with-style {
color: #6633FF;
}
a.user-platinum.with-style {
color: gray;
}
a.user-gold.with-style {
color: #0000FF;
}
a.user-member.with-style {
color: auto;
}

View File

@@ -71,11 +71,8 @@ module ApplicationHelper
end
def link_to_user(user)
link_to(user.pretty_name, user_path(user), :class => user.level_class)
end
def link_to_user_unless(condition, user)
link_to_unless(condition, user.pretty_name, user_path(user), :class => user.level_class)
user_class = CurrentUser.user.style_usernames? ? "#{user.level_class} with-style" : user.level_class
link_to(user.pretty_name, user_path(user), :class => user_class)
end
def mod_link_to_user(user, positive_or_negative)

View File

@@ -185,6 +185,10 @@ class AnonymousUser
false
end
def style_usernames?
false
end
%w(member banned privileged builder platinum contributor janitor moderator admin).each do |name|
define_method("is_#{name}?") do
false

View File

@@ -17,7 +17,7 @@ class User < ActiveRecord::Base
end
attr_accessor :password, :old_password
attr_accessible :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin]
attr_accessible :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin]
attr_accessible :level, :as => :admin
validates_length_of :name, :within => 2..100, :on => :create
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
@@ -506,7 +506,7 @@ class User < ActiveRecord::Base
module ApiMethods
def hidden_attributes
super + [:password_hash, :bcrypt_password_hash, :email, :email_verification_key, :time_zone, :created_at, :updated_at, :receive_email_notifications, :last_logged_in_at, :last_forum_read_at, :has_mail, :default_image_size, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :base_upload_limit, :recent_tags, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :enable_sequential_post_navigation, :hide_deleted_posts, :per_page]
super + [:password_hash, :bcrypt_password_hash, :email, :email_verification_key, :time_zone, :created_at, :updated_at, :receive_email_notifications, :last_logged_in_at, :last_forum_read_at, :has_mail, :default_image_size, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :base_upload_limit, :recent_tags, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :enable_sequential_post_navigation, :hide_deleted_posts, :per_page, :style_usernames]
end
def serializable_hash(options = {})

View File

@@ -1,6 +1,6 @@
<ul>
<li>ID: <%= post.id %></li>
<li>Uploader: <%= link_to_user_unless(post.uploader.nil?, post.uploader) + "&nbsp;".html_safe + link_to("&raquo;".html_safe, posts_path(:tags => "user:#{post.uploader.name}")) %></li>
<li>Uploader: <%= link_to_user(post.uploader) + "&nbsp;".html_safe + link_to("&raquo;".html_safe, posts_path(:tags => "user:#{post.uploader.name}")) %></li>
<li>Date: <%= link_to time_ago_in_words_tagged(post.created_at), posts_path(:tags => "date:#{post.created_at.to_date}") %></li>
<% if post.approver %>
<li>Approver: <%= link_to_user(post.approver) %></li>

View File

@@ -25,6 +25,8 @@
<%= f.input :per_page, :label => "Posts per page", :as => :select, :collection => (1..100), :include_blank => false %>
<% end %>
<%= f.input :style_usernames, :as => :select, :label => "Colored usernames", :hint => "Color each user's name depending on their rank", :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %>
<%= f.input :blacklisted_tags, :hint => "Put any tag combinations you never want to see here. Each combination should go on a separate line.", :input_html => {:size => "40x5"} %>
<div class="input text optional field_with_hint">
<label class="text optional" for="user_favorite_tags">Frequent tags</label>

View File

@@ -0,0 +1,6 @@
class AddStyleUsernamesToUsers < ActiveRecord::Migration
def change
execute "set statement_timeout = 0"
add_column :users, :style_usernames, :boolean, :null => false, :default => false
end
end