From 4c185aec76d407642c3a8d489c5f64a042cb3b48 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Thu, 2 Jul 2015 02:34:39 +0300 Subject: [PATCH] Remove tweets --- app/controllers/tweets_controller.rb | 29 ---------------------------- app/models/tweet.rb | 22 --------------------- app/views/tweets/index.html.erb | 12 ------------ app/views/tweets/show.html.erb | 14 -------------- app/views/widgets/_tweets.html.erb | 19 ------------------ db/schema.rb | 11 +---------- 6 files changed, 1 insertion(+), 106 deletions(-) delete mode 100644 app/controllers/tweets_controller.rb delete mode 100644 app/models/tweet.rb delete mode 100644 app/views/tweets/index.html.erb delete mode 100644 app/views/tweets/show.html.erb delete mode 100644 app/views/widgets/_tweets.html.erb diff --git a/app/controllers/tweets_controller.rb b/app/controllers/tweets_controller.rb deleted file mode 100644 index 93106d0..0000000 --- a/app/controllers/tweets_controller.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'rss/2.0' -require 'open-uri' - -class TweetsController < ApplicationController - def index - @tweets = Tweet.all order: "created_at DESC" - @nobody = true - end - - def show - @tweet = Tweet.find(params[:id]) - end - - def refresh - open('http://twitter.com/statuses/user_timeline/16676427.rss') do |http| - RSS::Parser.parse(http.read, false).items.each do |item| - unless Tweet.first :conditions => {:link => item.link} - tweet = Tweet.new - tweet.link = item.link - tweet.msg = item.title.gsub(/NS2: /, "") - tweet.created_at = DateTime.parse item.pubDate.to_s - tweet.save - end - end - end - - render text: t(:tweets_refresh) - end -end diff --git a/app/models/tweet.rb b/app/models/tweet.rb deleted file mode 100644 index 6e34819..0000000 --- a/app/models/tweet.rb +++ /dev/null @@ -1,22 +0,0 @@ -# == Schema Information -# -# Table name: tweets -# -# id :integer not null, primary key -# msg :string(255) -# link :string(255) -# created_at :datetime -# updated_at :datetime -# - -class Tweet < ActiveRecord::Base - include Extra - - scope :recent2, :order => "created_at DESC", :limit => 2 - scope :recent, :order => "created_at DESC", :limit => 5 - has_many :comments, :as => :commentable - - def to_s - msg - end -end diff --git a/app/views/tweets/index.html.erb b/app/views/tweets/index.html.erb deleted file mode 100644 index 2d60b49..0000000 --- a/app/views/tweets/index.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<% @tweets.each do |item| %> - -
-

- <%= link_to (longtime item.created_at), item.link %> -

-

- <%= raw h item.msg %> -

- <%= link_to "Comments: #{item.comments.count}", item %> -
-<% end %> diff --git a/app/views/tweets/show.html.erb b/app/views/tweets/show.html.erb deleted file mode 100644 index c4303b7..0000000 --- a/app/views/tweets/show.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -

- NS2 Feed -

- -
-

- <%= link_to (longtime @tweet.created_at), @tweet.link %> -

-

- <%= h @tweet.msg %> -

-
- -<%= add_comments @tweet %> diff --git a/app/views/widgets/_tweets.html.erb b/app/views/widgets/_tweets.html.erb deleted file mode 100644 index 31c5d63..0000000 --- a/app/views/widgets/_tweets.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -
Latest NS2 tweets
-
-
-

- Latest tweets -

-
    -
      - <% Tweet.recent.each do |tweet| %> -
    1. - <%= namelink tweet, 25 %> -
    2. - <% end %> -
    -
-
-
- -<%= link_to "More..", articles_path %> diff --git a/db/schema.rb b/db/schema.rb index fb40af1..5422b4f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150621212615) do +ActiveRecord::Schema.define(:version => 20150701233306) do create_table "article_versions", :force => true do |t| t.integer "article_id" @@ -715,15 +715,6 @@ ActiveRecord::Schema.define(:version => 20150621212615) do add_index "topics", ["forum_id"], :name => "index_topics_on_forum_id" add_index "topics", ["user_id"], :name => "index_topics_on_user_id" - create_table "tweets", :force => true do |t| - t.string "msg" - t.string "link" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "tweets", ["created_at"], :name => "index_tweets_on_created_at" - create_table "user_versions", :force => true do |t| t.integer "user_id" t.integer "version"