Remove tweets

This commit is contained in:
Ari Timonen 2015-07-02 02:34:39 +03:00
parent 9c0b29f4fe
commit 4c185aec76
6 changed files with 1 additions and 106 deletions

View file

@ -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

View file

@ -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

View file

@ -1,12 +0,0 @@
<% @tweets.each do |item| %>
<div class="box wide">
<h3>
<%= link_to (longtime item.created_at), item.link %>
</h3>
<p>
<%= raw h item.msg %>
</p>
<%= link_to "Comments: #{item.comments.count}", item %>
</div>
<% end %>

View file

@ -1,14 +0,0 @@
<h1>
NS2 Feed
</h1>
<div class="box wide">
<h3>
<%= link_to (longtime @tweet.created_at), @tweet.link %>
</h3>
<p>
<%= h @tweet.msg %>
</p>
</div>
<%= add_comments @tweet %>

View file

@ -1,19 +0,0 @@
<div class="header">Latest NS2 tweets</div>
<div class="body">
<div class="content">
<h3>
Latest tweets
</h3>
<ul>
<ol>
<% Tweet.recent.each do |tweet| %>
<li>
<%= namelink tweet, 25 %>
</li>
<% end %>
</ol>
</ul>
</div>
</div>
<%= link_to "More..", articles_path %>

View file

@ -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"