+ <%= event.start.strftime("%H:%M %Z") %> + <%= event.formatted_summary.sub(nsltv_regex, '') %> +
+- Latest tweets -
--
-
- - <%= namelink tweet, 25 %> - - <% end %> -
-
- <% Tweet.recent.each do |tweet| %>
-
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| %> - -
- <%= raw h item.msg %> -
- <%= link_to "Comments: #{item.comments.count}", item %> -- <%= h @tweet.msg %> -
-