Permalink
Browse files

remove resource logic.

  • Loading branch information...
1 parent c49e424 commit f844798ba26e6b0a6ca7c3bd2d435957a23c49f2 @chloerei chloerei committed Feb 18, 2012
Showing with 5 additions and 977 deletions.
  1. +0 −10 app/assets/javascripts/resources/new.js
  2. +0 −39 app/assets/javascripts/resources/show.js
  3. +0 −70 app/assets/stylesheets/code_campo.scss
  4. +0 −7 app/assets/stylesheets/resources.scss
  5. +0 −46 app/controllers/comments_controller.rb
  6. +1 −2 app/controllers/homepage_controller.rb
  7. +0 −1 app/controllers/people_controller.rb
  8. +0 −66 app/controllers/resources_controller.rb
  9. +0 −53 app/models/comment.rb
  10. +0 −5 app/models/notification/comment_comment.rb
  11. +0 −5 app/models/notification/resource_comment.rb
  12. +0 −42 app/models/resource.rb
  13. +0 −2 app/models/user.rb
  14. +0 −18 app/views/comments/_comment.haml
  15. +0 −8 app/views/comments/_up_votes_count.haml
  16. +0 −12 app/views/comments/create.js.erb
  17. +0 −29 app/views/comments/new.haml
  18. +0 −4 app/views/comments/vote_up.js.erb
  19. +2 −8 app/views/homepage/index.haml
  20. +0 −2 app/views/layouts/_topbar.haml
  21. +0 −13 app/views/notifications/notification/_comment_comment.haml
  22. +0 −10 app/views/notifications/notification/_mention.haml
  23. +0 −13 app/views/notifications/notification/_resource_comment.haml
  24. +0 −22 app/views/people/show.haml
  25. +0 −19 app/views/resources/_resource.haml
  26. +0 −5 app/views/resources/_votes_count.haml
  27. +0 −63 app/views/resources/index.haml
  28. +0 −30 app/views/resources/new.haml
  29. +0 −46 app/views/resources/show.haml
  30. +0 −4 app/views/resources/vote_up.js.erb
  31. +1 −1 config/locales/en.yml
  32. +1 −1 config/locales/zh-CN.yml
  33. +0 −18 config/routes.rb
  34. +0 −9 test/factories/comments.rb
  35. +0 −7 test/factories/notification_comment_comments.rb
  36. +0 −7 test/factories/notification_resource_comments.rb
  37. +0 −10 test/factories/resources.rb
  38. +0 −64 test/functional/comments_controller_test.rb
  39. +0 −3 test/functional/notifications_controller_test.rb
  40. +0 −108 test/functional/resources_controller_test.rb
  41. +0 −73 test/unit/comment_test.rb
  42. +0 −7 test/unit/notification/comment_comment_test.rb
  43. +0 −7 test/unit/notification/resource_comment_test.rb
  44. +0 −8 test/unit/resource_test.rb
@@ -1,10 +0,0 @@
-//= require jquery.tagEditor
-
-$(function(){
- $(':input[name*=tag_string]').tagEditor();
- var $form = $('form');
- var setting = window[$form.attr('id')];
- $(':input[name*=tag_string][data-validate]').change(function(){
- $(this).isValid(setting.validators);
- });
-})
@@ -1,39 +0,0 @@
-$(function(){
- var $new_comment_form = $('#new_comment');
-
- $('.reply a').live('click', function(event){
- var $comment = $(this).parents('.comment');
- var parent_id = $comment.data('comment-id');
- var form_id = 'new_comment_' + parent_id;
- var form = $('#' + form_id);
- if (!form.length) {
- form = $new_comment_form.clone();
- form.find('.alert-message').remove();
- form.attr('id', form_id).attr('action', $new_comment_form.attr('action') + '&parent_id=' + parent_id);
- var cancel_link = $('<a href="#" class="btn">Cancel</a>');
- cancel_link.click(function(event) {
- form.fadeOut('fast', function(){$(this).remove()});
- event.preventDefault();
- });
- form.find(':submit').after(cancel_link);
- form.hide().appendTo($comment).fadeIn('fast', function(){form.find('textarea').focus();});
- } else {
- form.find('textarea').focus();
- }
- event.preventDefault();
- });
-
- $('#comments form.new_comment').live('ajax:success', function() {
- $(this).hide().remove();
- });
-
- $('#new_comment').live('ajax:success', function() {
- $(this).find('textarea').val('');
- });
-
- $('form.new_comment').live('ajax:error', function(event, xhr, status) {
- var message = $('<div class="alert-message error fade in"><a href="#" class="close">×</a><p></p></div>').alert();
- message.find('p').text(xhr.responseText);
- message.hide().prependTo($(this)).fadeIn('fast');
- });
-})
@@ -255,7 +255,6 @@ section {
padding: 14px;
&#notifications,
- &#resources,
&#topics,
&#replies {
padding: 0;
@@ -391,72 +390,3 @@ section {
margin-bottom: 5px;
color: gray;
}
-
-#resources {
- table.item-list td {
- vertical-align: middle;
-
- &.thin {
- width: 100px;
- }
-
- &.last {
- width: 60px;
- }
- }
-}
-
-#comments {
- ul {
- list-style: none;
- margin: 0 0 0 34px;
- }
-
- & > ul {
- margin: 0 0 15px 0;
- }
-
- li {
- color: #404040;
- }
-
- .avatar {
- display: table-cell;
- width: 24px;
- padding-right: 10px;
- vertical-align: top;
-
- img {
- width: 24px;
- height: 24px;
- }
- }
-
- .comment {
- display: table-cell;
- vertical-align: top;
- width: 100%;
-
- .info {
- margin-bottom: 10px;
- }
-
- .content {
- margin-bottom: 15px;
- border-bottom: 1px dashed #CCC;
- }
- }
-
- .info {
- color: gray;
- font-weight: bold;
- }
-
- form .btn {
- margin-right: 10px;
- }
-}
-
-.new_comment textarea {
- width: 80%;
-}
@@ -1,7 +0,0 @@
-/*
- *= require 'tag_editor'
- */
-
-.tag-editor {
- width: 630px;
-}
@@ -1,46 +0,0 @@
-class CommentsController < ApplicationController
- before_filter :require_logined
- respond_to :html, :js, :only => [:create, :vote_up]
-
- def new
- @resource = Resource.number params[:resource_id]
- @parent = Comment.number params[:parent_id] if params[:parent_id]
- @comment = Comment.new
- end
-
- def create
- @comment = current_user.comments.new params[:comment]
- @comment.resource = @resource = Resource.number(params[:resource_id])
- @comment.parent = @parent = Comment.number(params[:parent_id]) if params[:parent_id]
- respond_with(@comment) do |format|
- if @comment.save
- format.html {
- flash[:success] = 'Success Post Comment.'
- redirect_to resource_url(@comment.resource, :anchor => @comment.anchor)
- }
- format.js { render :create, :layout => false }
- else
- format.html { render :new }
- format.js { render :text => @comment.errors.full_messages.join(','), :status => 406, :layout => false }
- end
- end
- end
-
- def vote_up
- @comment = Comment.number params[:id]
- current_user.vote(@comment, :up)
- respond_with(@comment) do |format|
- format.html { redirect_to resource_path(@comment.resource, :anchor => @comment.anchor) }
- format.js { render :vote_up, :layout => false }
- end
- end
-
- def unvote_up
- @comment = Comment.number params[:id]
- current_user.unvote(@comment)
- respond_with(@comment) do |format|
- format.html { redirect_to resource_path(@comment.resource, :anchor => @comment.anchor) }
- format.js { render :vote_up, :layout => false }
- end
- end
-end
@@ -1,9 +1,8 @@
class HomepageController < ApplicationController
def index
- @resources = Resource.order_by([[:created_at, :desc]]).limit(5)
@topics = Topic.active.limit(10)
@users_count = User.count
- @resources_count = Resource.count
@topics_count = Topic.count
+ @replies_count = Reply.count
end
end
@@ -3,7 +3,6 @@ class PeopleController < ApplicationController
def show
@topics = @person.topics.order_by([[:created_at, :desc]]).page(1).per(5)
- @resources = @person.resources.order_by([[:created_at, :desc]]).page(1).per(5)
end
protected
@@ -1,66 +0,0 @@
-class ResourcesController < ApplicationController
- before_filter :require_logined, :except => [:index, :tagged, :show]
- respond_to :html, :js, :only => [:vote_up, :unvote_up]
-
- def index
- @resources = Resource.order_by([[:created_at, :desc]]).page(params[:page])
- end
-
- def tagged
- @resources = Resource.where(:tags => params[:tag]).order_by([[:created_at, :desc]]).page(params[:page])
- render :index
- end
-
- def voted
- @resources = Resource.up_voted_by(current_user).order_by([[:created_at, :desc]]).page(params[:page])
- render :index
- end
-
- def interesting
- @resources = Resource.where(:tags.in => current_user.favorite_tags).order_by([[:created_at, :desc]]).page(params[:page])
- render :index
- end
-
- def my
- @resources = current_user.resources.order_by([[:created_at, :desc]]).page(params[:page])
- render :index
- end
-
- def show
- @resource = Resource.number params[:id]
- @relate_resources = @resource.relate_resources(5)
- @comments = @resource.comments.order_by([["votes.point", :desc], [:created_at, :asc]]).to_a
- end
-
- def new
- @resource = Resource.new :tag_string => params[:tag]
- end
-
- def create
- @resource = current_user.resources.new params[:resource]
- if @resource.save
- flash[:success] = 'Success Submit Resource.'
- redirect_to @resource
- else
- render :new
- end
- end
-
- def vote_up
- @resource = Resource.number params[:id]
- current_user.vote(@resource, :up)
- respond_with(@resource) do |format|
- format.html { redirect_referrer_or_default @resource }
- format.js { render :vote_up, :layout => false }
- end
- end
-
- def unvote_up
- @resource = Resource.number params[:id]
- current_user.unvote(@resource)
- respond_with(@resource) do |format|
- format.html { redirect_referrer_or_default @resource }
- format.js { render :vote_up, :layout => false }
- end
- end
-end
View
@@ -1,53 +0,0 @@
-class Comment
- include Mongoid::Document
- include Mongoid::Timestamps::Created
- include Mongoid::NumberId
- include Mongo::Voteable
- include Mentionable
-
- voteable self, :up => 1
-
- field :content
-
- belongs_to :user
- belongs_to :resource
- has_many :children, :class_name => 'Comment', :as => :parent, :dependent => :destroy
- belongs_to :parent, :class_name => 'Comment'
- has_one :notification_comment_comment, :class_name => 'Notification::CommentComment', :dependent => :delete
- has_one :notification_resource_comment, :class_name => 'Notification::ResourceComment', :dependent => :delete
-
- validates :content, :user, :resource, :presence => true
-
- after_create :update_resource, :send_resource_comment_notification,
- :send_comment_comment_notification
-
- attr_accessible :content
-
- def update_resource
- resource.inc :comments_count, 1
- end
-
- def anchor
- "comment-#{number_id}"
- end
-
- def send_resource_comment_notification
- if user != resource.user && parent.blank?
- Notification::ResourceComment.create :user => resource.user, :comment => self
- end
- end
-
- def send_comment_comment_notification
- if parent.present? && user != parent.user
- Notification::CommentComment.create :user => parent.user, :comment => self
- end
- end
-
- def no_mention_users
- if parent.present?
- [user, parent.user]
- else
- [user, resource.user]
- end
- end
-end
@@ -1,5 +0,0 @@
-class Notification::CommentComment < Notification::Base
- belongs_to :comment
-
- validates :comment, :presence => true
-end
@@ -1,5 +0,0 @@
-class Notification::ResourceComment < Notification::Base
- belongs_to :comment
-
- validates :comment, :presence => true
-end
View
@@ -1,42 +0,0 @@
-class Resource
- include Mongoid::Document
- include Mongoid::Timestamps::Created
- include Mongoid::NumberId
- include Mongo::Voteable
-
- voteable self, :up => 1, :index => true
-
- field :title
- field :url
- field :tags, :type => Array, :default => []
- field :comments_count, :default => 0
-
- belongs_to :user
- has_many :comments, :dependent => :delete
-
- attr_accessible :title, :url, :tag_string
-
- validates :title, :url, :presence => true
- validates :tag_string, :tag_string => true, :format => { :with => /\A[^\/]+\z/, :message => I18n.t("errors.no_allow_slash"), :allow_blank => true}
- validates :url, :format => {:with => URI::Parser.new.regexp[:ABS_URI]}
-
- def tag_string=(string)
- self.tags = string.to_s.downcase.split(/[,\s]+/).uniq
- end
-
- def tag_string
- self.tags.join(', ')
- end
-
- def host
- URI.parse(url).try(:host)
- end
-
- def relate_resources(count)
- Resource.any_in(:tags => tags).limit(count).where(:_id.ne => id)
- end
-
- def anchor
- "resource-#{number_id}"
- end
-end
View
@@ -33,8 +33,6 @@ def has_unread?
unread.count > 0
end
end
- has_many :resources, :dependent => :destroy
- has_many :comments, :dependent => :destroy
has_many :topics, :dependent => :destroy
has_many :replies, :dependent => :destroy
embeds_one :profile
Oops, something went wrong.

0 comments on commit f844798

Please sign in to comment.