Permalink
Browse files

Auto_link statuses. Beginning backend work of adding hashtags.

  • Loading branch information...
1 parent bb98787 commit 546ffa3c59cd628b3c1e565deb569a78df04d9e1 @wfarr wfarr committed Jul 2, 2010
View
@@ -1,6 +1,9 @@
require 'tinder'
class Status < ActiveRecord::Base
+ include Twitter::Autolink
+ include Twitter::Extractor
+
validate :set_project_from_code
validates_presence_of :user_id, :message
validate :times_are_sane
@@ -18,6 +21,8 @@ class Status < ActiveRecord::Base
after_create :cache_user_status
after_create :process_previous
+ before_save :render_message
+
include AASM
aasm_initial_state :pending
@@ -28,6 +33,10 @@ class Status < ActiveRecord::Base
transitions :from => :pending, :to => :processed, :guard => :calculate_hours
end
+ def render_message
+ self['rendered'] = auto_link self.message, { :hashtag_url_base => "/hashtags/" }
+ end
+
def membership
@membership = (project? ? user.memberships.for(project) : nil) || false unless @membership == false
end
@@ -46,9 +46,9 @@
<% else %>
<%= link_to_filtered_statuses h(status.project.name), :context => nil, :project => status.project %> /
<% end %>
- <%= link_to(status_for(status), status, :class => 'entry-title entry-content') %>
+ <%= status.rendered %>
</h4>
- <p class="quiet">posted by <%= link_to(h(status.user.login), status.user) %>, <%= status_at status %> from <strong><%=h status.source || "the web" %></strong></p>
+ <p class="quiet">posted by <%= link_to(h(status.user.login), status.user) %>, <%= link_to status_at(status), status %> from <strong><%=h status.source || "the web" %></strong></p>
<% if status.processed? -%>
<span class="others">
<span class="num"><%= status.hours.to_f %></span>
@@ -52,8 +52,8 @@
<%= link_to gravatar_for(status.user), status.user %>
</div>
<div class="media-content">
- <h4 class="media-title status"><%= link_to(status_for(status), status, :class => 'entry-title entry-content') %></h4>
- <p class="quiet">posted by <%= link_to(h(status.user.login), status.user) %>, <%= status_at status %> from <strong><%=h status.source || "the web" %></strong></p>
+ <h4 class="media-title status"><%= status.rendered %></h4>
+ <p class="quiet">posted by <%= link_to(h(status.user.login), status.user) %>, <%= link_to status_at(status), status %> from <strong><%=h status.source || "the web" %></strong></p>
<% if status.processed? -%>
<span class="others">
<span class="num"><%= status.hours.to_f %></span>
@@ -51,9 +51,9 @@
<%= link_to gravatar_for(status.user), status.user %>
</div>
<div class="media-content">
- <h4 class="media-title status"><%= link_to(status_for(status), status, :class => 'entry-title entry-content') %></h4>
+ <h4 class="media-title status"><%= status.rendered %></h4>
<p class="quiet">
- posted <strong><%= status_at status %></strong>
+ posted <strong><%= link_to status_at(status), status %></strong>
from <%=h status.source || "the web" %>
<% if status.project? -%>to <%= link_to_filtered_statuses h(status.project.name), :filter => params[:filter], :date => params[:date], :project => status.project %><% end -%>
</p>
View
@@ -20,6 +20,7 @@
}
config.gem 'tinder', :version => '1.4.0'
+ config.gem 'twitter-text'
config.gem 'fastercsv', :version => '1.2.3'
config.gem 'googlecharts', :lib => "gchart", :version => '1.3.6'
config.gem 'hpricot', :version => '>=0.6'
@@ -0,0 +1,16 @@
+class AddRenderedTextToStatus < ActiveRecord::Migration
+ def self.up
+ add_column :statuses, :rendered, :string
+
+ Status.reset_column_information
+
+ Status.all.each do |status|
+ status.render_message
+ status.save!
+ end
+ end
+
+ def self.down
+ remove_column :statuses, :rendered
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100630014806) do
+ActiveRecord::Schema.define(:version => 20100702172625) do
create_table "bj_config", :primary_key => "bj_config_id", :force => true do |t|
t.string "hostname"
@@ -172,6 +172,7 @@
t.integer "project_id"
t.string "source", :default => "the web"
t.datetime "finished_at"
+ t.string "rendered"
end
add_index "statuses", ["created_at", "user_id"], :name => "index_statuses_on_created_at_and_user_id"

0 comments on commit 546ffa3

Please sign in to comment.