diff --git a/app/assets/stylesheets/common/user_styles.css.scss b/app/assets/stylesheets/common/user_styles.css.scss new file mode 100644 index 000000000..225eb8935 --- /dev/null +++ b/app/assets/stylesheets/common/user_styles.css.scss @@ -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; +} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ba2de6c46..9f9f31901 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) diff --git a/app/logical/anonymous_user.rb b/app/logical/anonymous_user.rb index 057337633..a4d49219b 100644 --- a/app/logical/anonymous_user.rb +++ b/app/logical/anonymous_user.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index b06e9dac0..e66277190 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 = {}) diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index bcc4f8298..55ddac99b 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -1,6 +1,6 @@