Skip to content

Commit

Permalink
remove favorite tags function.
Browse files Browse the repository at this point in the history
  • Loading branch information
chloerei committed Mar 11, 2012
1 parent 34244d2 commit a90546c
Show file tree
Hide file tree
Showing 16 changed files with 6 additions and 284 deletions.
21 changes: 0 additions & 21 deletions app/assets/javascripts/settings/favorite_tags.js

This file was deleted.

37 changes: 0 additions & 37 deletions app/assets/stylesheets/settings/favorite_tags.scss

This file was deleted.

35 changes: 0 additions & 35 deletions app/controllers/settings/favorite_tags_controller.rb

This file was deleted.

17 changes: 1 addition & 16 deletions app/controllers/topics_controller.rb
@@ -1,11 +1,10 @@
class TopicsController < ApplicationController
before_filter :old_id_redirect, :only => [:show]
before_filter :login_from_access_token, :only => [:interesting]
before_filter :require_logined, :except => [:index, :show, :tagged, :newest]
before_filter :find_topic, :only => [:show, :mark, :unmark]
before_filter :find_user_topic, :only => [:edit, :update]
respond_to :html, :js, :only => [:mark]
respond_to :html, :rss, :only => [:newest, :interesting, :tagged]
respond_to :html, :rss, :only => [:newest, :tagged]

def index
@topics = Topic.active.page(params[:page])
Expand Down Expand Up @@ -54,20 +53,6 @@ def tagged
end
end

def interesting
respond_with do |format|
format.html do
@topics = Topic.where(:tags.in => current_user.favorite_tags).active.page(params[:page])
render :index
end
format.rss do
@topics = Topic.where(:tags.in => current_user.favorite_tags).order_by([[:created_at, :desc]]).limit(20)
@page_title = I18n.t('code_campo_interesting_topics', :name => current_user.name)
render :index, :layout => false
end
end
end

def new
@topic = Topic.new :tag_string => params[:tag]
end
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/topics_helper.rb
Expand Up @@ -3,8 +3,6 @@ def subscribe_url
case action_name
when 'index', 'newest'
newest_topics_url(:format => :rss)
when 'interesting'
interesting_topics_url(:format => :rss, :access_token => current_user.access_token)
when 'tagged'
tagged_topics_url(:format => :rss, :tag => params[:tag])
end
Expand Down
21 changes: 1 addition & 20 deletions app/models/user.rb
Expand Up @@ -8,7 +8,6 @@ class User
field :name
field :email
field :password_digest
field :favorite_tags, :type => Array, :default => []
field :access_token
field :locale, :default => I18n.locale.to_s

Expand All @@ -20,12 +19,10 @@ class User
validates :password, :password_confirmation, :presence => true, :on => :create
validates :password, :length => {:minimum => 6, :allow_nil => true}
validates :current_password, :current_password => {:fields => [:name, :email, :password]}, :on => :update
validates :extra_favorite_tag_string, :format => { :with => /\A[^\/]+\z/, :message => I18n.t("errors.no_allow_slash"), :allow_blank => true}
validates :locale, :inclusion => {:in => AllowLocale}

attr_accessor :current_password
attr_reader :extra_favorite_tag_string
attr_accessible :name, :email, :password, :password_confirmation, :current_password, :extra_favorite_tag_string, :locale
attr_accessible :name, :email, :password, :password_confirmation, :current_password, :locale

has_many :notifications, :class_name => 'Notification::Base', :dependent => :delete do
def has_unread?
Expand All @@ -37,22 +34,6 @@ def has_unread?
embeds_one :profile

before_create :build_profile, :set_access_token
after_save :clear_extra_favorite_tag_string

def remove_favorite_tag(tag)
collection.update({:_id => self.id},
{"$pull" => {:favorite_tags => tag}})
end

def extra_favorite_tag_string=(string)
self.favorite_tags += string.to_s.downcase.split(/[,\s]+/).uniq
self.favorite_tags.uniq!
@extra_favorite_tag_string = string
end

def clear_extra_favorite_tag_string
@extra_favorite_tag_string = nil
end

def to_param
name
Expand Down
1 change: 0 additions & 1 deletion app/views/layouts/settings.haml
Expand Up @@ -20,7 +20,6 @@
%li{:class => (controller_name == 'accounts' ? 'active' : nil)}= link_to t('.account'), settings_account_path
%li{:class => (controller_name == 'passwords' ? 'active' : nil)}= link_to t('.password'), settings_password_path
%li{:class => (controller_name == 'profiles' ? 'active' : nil)}= link_to t('.profile'), settings_profile_path
%li{:class => (controller_name == 'favorite_tags' ? 'active' : nil)}= link_to t('.favorite_tags'), settings_favorite_tags_path
#mainbar.span9
%section#settings.box
= yield
Expand Down
20 changes: 0 additions & 20 deletions app/views/settings/favorite_tags/index.haml

This file was deleted.

20 changes: 1 addition & 19 deletions app/views/topics/index.haml
Expand Up @@ -43,30 +43,12 @@
%ul.nav.nav-tabs.nav-stacked
%li{:class => (action_name == 'index' ? 'active' : nil)}= link_to t('.active'), topics_path
%li{:class => (action_name == 'newest' ? 'active' : nil)}= link_to t('.newest'), newest_topics_path
%li{:class => (action_name == 'interesting' ? 'active' : nil)}= link_to t('.interesting'), interesting_topics_path
%li{:class => (action_name == 'marked' ? 'active' : nil)}= link_to t('.marked'), marked_topics_path
%li{:class => (action_name == 'my' ? 'active' : nil)}= link_to t('.my'), my_topics_path
%li{:class => (action_name == 'replied' ? 'active' : nil)}= link_to t('.replied'), replied_topics_path
- if action_name == 'tagged'
%section.box
%header
= t '.tagged', :tag => params[:tag]
- if current_user.favorite_tags.include? params[:tag]
= button_to t('.remove_favorite'), settings_favorite_tag_path(:id => params[:tag]), :method => :delete, :class => 'btn error'
- else
= button_to t('.add_favorite'), settings_favorite_tag_path(:id => params[:tag]), :method => :put, :class => 'btn success'
%section.box
%header
= t('.favorite_tags')
= link_to t('.settings'), settings_favorite_tags_path
- if current_user.favorite_tags.any?
.tags
- current_user.favorite_tags.each do |tag|
= link_to tag, tagged_topics_path(:tag => tag)

- else
= render :partial => 'shared/sidebar_login'
- if %w(index newest interesting tagged).include?(action_name)
- if %w(index newest tagged).include?(action_name)
%section.box
%header= t('.subscribe')
= link_to image_tag('rss.png'), subscribe_url
6 changes: 3 additions & 3 deletions config/application.rb
Expand Up @@ -52,9 +52,9 @@ class Application < Rails::Application
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

config.assets.precompile += %w(editor.js setttings/favorite_tags.js resources/new.js resources/show.js)
config.assets.precompile += %w(settings/favorite_tags.js topics/show.js)
config.assets.precompile += %w(editor.css resources.css search.css settings/favorite_tags.css)
config.assets.precompile += %w(editor.js resources/new.js resources/show.js)
config.assets.precompile += %w(topics/show.js)
config.assets.precompile += %w(editor.css resources.css search.css)

config.generators do |g|
g.test_framework :test_unit, :fixture_replacement => :factory_girl
Expand Down
16 changes: 0 additions & 16 deletions config/locales/en.yml
Expand Up @@ -19,15 +19,13 @@ en:
en: "English"
code_campo_newest_topics: "CodeCampo Newest Topics"
code_campo_tagged_newest_topics: "CodeCampo Newest Topics Tagged:%{tag}"
code_campo_interesting_topics: "CodeCampo Newest Topics Customize for %{name}"

layouts:
settings:
settings_title: "%{name}'s Settings"
account: "Account"
password: "Password"
profile: "Profile"
favorite_tags: "Favorite Tags"
topbar:
home: "Home"
resources: "Resources"
Expand Down Expand Up @@ -83,10 +81,6 @@ en:
passwords:
show:
password_settings: "Password settings"
favorite_tags:
index:
favorite_tags_settings: "Favorite tags settings"
add_favorite_tags: "Add favorite tags"
profiles:
show:
profile_settings: "Profile settings"
Expand Down Expand Up @@ -114,16 +108,11 @@ en:
votes_count: "%{count} points"
index:
resources: "Resources"
interesting: "Interesting"
voted: "Voted"
my: "My Resources"
tagged: "Tagged: %{tag}"
no_resources: "No Resources"
favorite_tags: "Favorite Tags"
settings: "Settings"
submit_resource: "Submit Resource"
add_favorite: "Add Favorite"
remove_favorite: "Remove Favorite"
new:
resources: "Resources"
submit_resource: "Submit Resource"
Expand Down Expand Up @@ -153,17 +142,13 @@ en:
topics: "Topics"
active: "Active"
newest: "Newest"
interesting: "Interesting"
marked: "Marked"
my: "My Topics"
tagged: "Tagged: %{tag}"
replied: "Replied"
no_topics: "No Topics"
favorite_tags: "Favorite Tags"
settings: "Settings"
create_topic: "Create Topic"
add_favorite: "Add Favorite"
remove_favorite: "Remove Favorite"
subscribe: "Subscribe"
show:
topics: "Topics"
Expand Down Expand Up @@ -261,7 +246,6 @@ en:
password_confirmation: "Password Confirmation"
locale: "Locale"
current_password: "Current Password"
extra_favorite_tag_string: "Extra Tags"
profile:
name: "Name"
avatar: "Avatar"
Expand Down
16 changes: 0 additions & 16 deletions config/locales/zh-CN.yml
Expand Up @@ -19,15 +19,13 @@ zh-CN:
en: "英文"
code_campo_newest_topics: "CodeCampo 最新主题"
code_campo_tagged_newest_topics: "CodeCampo 最新主题 标签:%{tag}"
code_campo_interesting_topics: "CodeCampo 最新主题 %{name} 定制"

layouts:
settings:
settings_title: "%{name} 的设置"
account: "账户"
password: "密码"
profile: "个人资料"
favorite_tags: "喜好标签"
topbar:
home: "首页"
resources: "资源"
Expand Down Expand Up @@ -83,10 +81,6 @@ zh-CN:
passwords:
show:
password_settings: "密码设置"
favorite_tags:
index:
favorite_tags_settings: "喜好标签设置"
add_favorite_tags: "添加喜欢标签"
profiles:
show:
profile_settings: "个人资料设置"
Expand Down Expand Up @@ -114,16 +108,11 @@ zh-CN:
votes_count: "%{count} 票"
index:
resources: "资源"
interesting: "喜好"
voted: "已投票"
my: "我的资源"
tagged: "标记为:%{tag}"
no_resources: "没有资源"
favorite_tags: "喜好标签"
settings: "设置"
submit_resource: "提交资源"
add_favorite: "添加为喜好"
remove_favorite: "从喜好中移除"
new:
resources: "资源"
submit_resource: "提交资源"
Expand Down Expand Up @@ -153,17 +142,13 @@ zh-CN:
topics: "话题"
active: "活跃"
newest: "最新"
interesting: "喜好"
marked: "收藏"
my: "我的话题"
tagged: "标记为:%{tag}"
replied: "回复过"
no_topics: "没有话题"
favorite_tags: "喜好标签"
settings: "设置"
create_topic: "创建话题"
add_favorite: "添加为喜好"
remove_favorite: "从喜好中移除"
subscribe: "订阅"
show:
topics: "话题"
Expand Down Expand Up @@ -261,7 +246,6 @@ zh-CN:
password_confirmation: "密码确认"
locale: "语言"
current_password: "当前密码"
extra_favorite_tag_string: "添加喜好标签"
profile:
name: "名称"
avatar: "头像"
Expand Down

0 comments on commit a90546c

Please sign in to comment.