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/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2c44635..fcf1e89 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -171,8 +171,26 @@ module ApplicationHelper end end + def nsltv_regex + /\[NSLTV\]/i + end + def upcoming_matches - GoogleCalendar.new(ENV['GOOGLE_CALENDAR_ID'], timezone_offset).upcoming.sort_by do |event| + GoogleCalendar.new(ENV['GOOGLE_CALENDAR_ID'], timezone_offset). + upcoming. + find_all{|e| + not nsltv_regex =~ (e.summary) + }.sort_by do |event| + event.start + end + end + + def upcoming_nsltv + GoogleCalendar.new(ENV['GOOGLE_CALENDAR_ID'], timezone_offset). + upcoming. + find_all{|e| + nsltv_regex =~ (e.summary) + }.sort_by do |event| event.start 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/_calendar.html.erb b/app/views/widgets/_calendar.html.erb index ccb3094..9dc7fbd 100644 --- a/app/views/widgets/_calendar.html.erb +++ b/app/views/widgets/_calendar.html.erb @@ -2,7 +2,7 @@

<%= t('widget.schedule') %>

-
+
<% upcoming_matches.group_by{ |e| e.start.month }.each do |month, events| %> <% events.group_by { |e| e.start.day }.each do |day, day_events| %>
<%= day_events.first.start.strftime("%A, %e %B") %>
@@ -19,3 +19,24 @@
<% end %> +<% if upcoming_nsltv.size > 0 %> +
+

NSLTV

+ +
+ <% upcoming_nsltv.group_by{ |e| e.start.month }.each do |month, events| %> + <% events.group_by { |e| e.start.day }.each do |day, day_events| %> +
<%= day_events.first.start.strftime("%A, %e %B") %>
+ <% day_events.each do |event| %> +
+

+ <%= event.start.strftime("%H:%M %Z") %> + <%= event.formatted_summary.sub(nsltv_regex, '') %> +

+
+ <% end %> + <% end %> + <% end %> +
+
+<% end %> 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/migrate/20150701233306_remove_tweets.rb b/db/migrate/20150701233306_remove_tweets.rb new file mode 100644 index 0000000..d86c6ee --- /dev/null +++ b/db/migrate/20150701233306_remove_tweets.rb @@ -0,0 +1,8 @@ +class RemoveTweets < ActiveRecord::Migration + def up + drop_table :tweets + end + + def down + end +end 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"