rostra 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -96,6 +96,7 @@ div#questions {
96
96
  float: right;
97
97
  }
98
98
 
99
+
99
100
  /* questions stats section */
100
101
  .question .stats {
101
102
  float: left;
@@ -1,10 +1,12 @@
1
1
  module Rostra
2
2
  class ApplicationMailer < ActionMailer::Base
3
+ helper 'rostra/base/application'
3
4
  layout Rostra::Config.email_layout
4
5
 
5
- def notification(user, question)
6
+ def notification(user, added_content, question)
6
7
  @user = user
7
8
  @question = question
9
+ @added_content = added_content
8
10
  mail(
9
11
  :to => user.rostra_user_email,
10
12
  :subject => "There's been activity on: #{question.title}",
@@ -2,6 +2,7 @@ class Comment < ActiveRecord::Base
2
2
 
3
3
  include ActsAsCommentable::Comment
4
4
  include Rostra::EmailNotifier
5
+ include Rostra::TimestampObserver
5
6
 
6
7
  belongs_to :commentable, :polymorphic => true
7
8
  belongs_to :user
@@ -15,4 +16,6 @@ class Comment < ActiveRecord::Base
15
16
  commentable.question if commentable.is_a?(Rostra::Answer)
16
17
  end
17
18
 
19
+ alias_attribute :text, :comment
20
+
18
21
  end
@@ -1,6 +1,7 @@
1
1
  module Rostra
2
2
  class Answer < ActiveRecord::Base
3
3
  include Rostra::EmailNotifier
4
+ include Rostra::TimestampObserver
4
5
 
5
6
  belongs_to :question
6
7
  belongs_to :user
@@ -1,5 +1,8 @@
1
1
  module Rostra
2
2
  class Question < ActiveRecord::Base
3
+ include Rostra::TimestampObserver
4
+ extend FriendlyId
5
+
3
6
  belongs_to :user
4
7
  has_many :answers, :dependent => :destroy
5
8
  has_many :question_followings, :dependent => :destroy
@@ -10,7 +13,6 @@ module Rostra
10
13
  acts_as_taggable
11
14
  acts_as_voteable
12
15
  is_impressionable counter_cache: { unique: true }
13
- extend FriendlyId
14
16
  friendly_id :title, use: :slugged
15
17
 
16
18
  validates :title, presence: true, uniqueness: true, length: { :minimum => 15 }
@@ -33,8 +35,10 @@ module Rostra
33
35
  @answer_count = answers.count
34
36
  end
35
37
 
36
- def unique_page_views
37
- impressionist_count(filter: :ip_address)
38
+ # The last time the question has had any activity (i.e. commment, answer, etc).
39
+ #
40
+ def active_at
41
+ updated_at || created_at
38
42
  end
39
43
 
40
44
  private
@@ -1,3 +1,8 @@
1
1
  <h3>Hi <%= @user.rostra_user_name %>,</h3>
2
2
 
3
3
  <p>Just letting you know there's been recent activity on <%= link_to @question.title, question_url(@question) %></p>
4
+
5
+ <p>
6
+ <strong><%= link_to_profile(@added_content.user) %> says:</strong><br />
7
+ <%= strip_tags(truncate(@added_content.text, length: 500)) %>
8
+ </p>
@@ -2,4 +2,7 @@
2
2
 
3
3
  Just letting you know there's been recent activity on <%= @question.title %>
4
4
 
5
+ <%= link_to_profile(@added_content.user) %> says:</strong>
6
+ <%= strip_tags(truncate(@added_content.text, length: 500)) %>
7
+
5
8
  View the question visit: <%= question_url(@question) %>
@@ -39,7 +39,7 @@
39
39
  <%= strip_tags(question.details) %>
40
40
  <% end %>
41
41
  </div>
42
- <div class="timestamp"><%= time_ago_in_words(question.created_at) %> ago</div>
42
+ <div class="timestamp">active <%= time_ago_in_words(question.active_at) %> ago</div>
43
43
  <%= tag_list(question) %>
44
44
  </div>
45
45
  <div class="clear"></div>
@@ -13,7 +13,7 @@ module Rostra
13
13
  def notify_followers
14
14
  question.notified_followers.each do |user|
15
15
  next if self.user == user
16
- ApplicationMailer.notification(user, question).deliver
16
+ ApplicationMailer.notification(user, self, question).deliver
17
17
  end
18
18
  end
19
19
 
data/lib/rostra/engine.rb CHANGED
@@ -11,6 +11,7 @@ module Rostra
11
11
  require 'kaminari'
12
12
  require 'friendly_id'
13
13
  require_relative 'email_notifier'
14
+ require_relative 'timestamp_observer'
14
15
 
15
16
  isolate_namespace Rostra
16
17
 
@@ -0,0 +1,15 @@
1
+ module Rostra
2
+ module TimestampObserver
3
+
4
+ def self.included(base)
5
+ base.after_save :set_active_at
6
+ end
7
+
8
+ private
9
+
10
+ def set_active_at
11
+ question = self.is_a?(Rostra::Question) ? self : self.question
12
+ question.touch
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Rostra
2
- VERSION = "0.1.19"
2
+ VERSION = "0.1.20"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rostra
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.19
5
+ version: 0.1.20
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cory Schires
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-13 00:00:00 Z
13
+ date: 2011-11-15 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -576,6 +576,7 @@ files:
576
576
  - lib/rostra/config.rb
577
577
  - lib/rostra/email_notifier.rb
578
578
  - lib/rostra/engine.rb
579
+ - lib/rostra/timestamp_observer.rb
579
580
  - lib/rostra/version.rb
580
581
  - lib/rostra.rb
581
582
  - lib/tasks/cucumber.rake