rostra 0.1.12 → 0.1.13

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.
@@ -37,7 +37,7 @@ $(document).ready(function() {
37
37
  preFill: prefill
38
38
  });
39
39
 
40
- $('input.as-values').attr('name', name); // force name to not
40
+ $('input.as-values').attr('name', name); // force name to use rails-style hash params
41
41
  });
42
42
 
43
43
 
@@ -46,6 +46,13 @@ $(document).ready(function() {
46
46
  $(this).closest('.answer').find('form.comment').fadeIn();
47
47
  return false;
48
48
  });
49
+
50
+ $('form.comment a.cancel').click(function() {
51
+ var form = $(this).closest('form.comment');
52
+ form.fadeOut();
53
+ form[0].reset();
54
+ return false;
55
+ });
49
56
  }();
50
57
 
51
58
 
@@ -197,6 +197,9 @@ form.comment textarea {
197
197
  height: 100px;
198
198
  margin-top: 25px !important;
199
199
  }
200
+ form.comment input[type="submit"] {
201
+ margin-right: 10px;
202
+ }
200
203
 
201
204
  /* comments */
202
205
  .comments {
@@ -72,6 +72,14 @@ module Rostra
72
72
  resource.class.name.split('::').last.downcase
73
73
  end
74
74
 
75
+ # Checks for the current page using rails 3 route-style syntax:
76
+ #
77
+ # current_rostra_page?('questions#new')
78
+ #
79
+ def current_rostra_page?(controller_and_action)
80
+ controller_and_action == "#{controller_name}##{action_name}"
81
+ end
82
+
75
83
  private
76
84
 
77
85
  def vote_path(resource, direction)
@@ -9,7 +9,7 @@ module Rostra
9
9
 
10
10
  acts_as_taggable
11
11
  acts_as_voteable
12
- is_impressionable
12
+ is_impressionable counter_cache: { unique: true }
13
13
 
14
14
  validates :title, :presence => true, :uniqueness => true, :length => { :minimum => 15 }
15
15
  validates :user, :presence => true
@@ -25,18 +25,7 @@ module Rostra
25
25
  # Finds questions asked within the last 15 days ordered by non-unique page views.
26
26
  #
27
27
  def self.trending(limit = 5)
28
- Question.where(created_at: (15.days.ago)..(Time.now)).limit(limit)
29
-
30
- # Maybe try to use a subquery?
31
- # User.where(:id => accounts.project(:user_id).where(accounts[:user_id].not_eq(6)))
32
-
33
- # This code doesn't work in postgres.
34
- # Question
35
- # .where(created_at: (15.days.ago)..(Time.now))
36
- # .limit(limit)
37
- # .joins(:impressions)
38
- # .group('impressions.impressionable_id')
39
- # .order('count(impressions.impressionable_id) desc')
28
+ Question.where(created_at: (15.days.ago)..(Time.now)).limit(limit).order('impressions_count desc')
40
29
  end
41
30
 
42
31
  def answer_count
@@ -1,5 +1,3 @@
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><%= link_to "View the question", question_path(@question) %></p>
@@ -2,4 +2,4 @@
2
2
 
3
3
  Just letting you know there's been recent activity on <%= @question.title %>
4
4
 
5
- View the question visit: <%= question_path(@question) %>
5
+ View the question visit: <%= question_url(@question) %>
@@ -20,8 +20,8 @@
20
20
  <span class="type"><%= question.answer_count.abs == 1 ? 'answer' : 'answers' %></span>
21
21
  </div>
22
22
  <div class="views_count" title="Number of times this question was viewed">
23
- <span class="count"><%= question.unique_page_views %></span>
24
- <span class="type"><%= question.unique_page_views.abs == 1 ? 'view' : 'views' %></span>
23
+ <span class="count"><%= question.impressions_count %></span>
24
+ <span class="type"><%= question.impressions_count.abs == 1 ? 'view' : 'views' %></span>
25
25
  </div>
26
26
  </div>
27
27
 
@@ -63,6 +63,7 @@
63
63
  <%= f.hidden_field :commentable_type, value: "Rostra::Answer" %>
64
64
  <%= f.input :comment, label: '' %>
65
65
  <%= f.submit 'post comment' %>
66
+ <%= link_to 'cancel', '#', class: 'cancel' %>
66
67
  <% end %>
67
68
  <% end %>
68
69
 
@@ -1,11 +1,13 @@
1
1
  <div id="sidebar">
2
2
  <% if can_participate_in_rostra? %>
3
- <%= link_to 'Ask a question', new_question_path, class: "button" %>
3
+ <% unless current_rostra_page?('questions#new') || current_rostra_page?('questions#edit') %>
4
+ <%= link_to 'Ask a question', new_question_path, class: "button" %>
5
+ <% end %>
4
6
  <% else %>
5
7
  <%= link_to 'Login to ask a question', main_app_login_path, class: "button" %>
6
8
  <% end %>
7
9
 
8
- <% if can_participate_in_rostra? && controller_name == 'questions' && action_name == 'show' %>
10
+ <% if can_participate_in_rostra? && current_rostra_page?('questions#show') %>
9
11
  <%= render partial: 'rostra/shared/toggle_following_question_button', locals: { question: @question } %>
10
12
  <% end %>
11
13
 
@@ -0,0 +1,5 @@
1
+ class AddImpressionsCountToQuestions < ActiveRecord::Migration
2
+ def change
3
+ add_column :rostra_questions, :impressions_count, :integer, default: 0
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Rostra
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
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.12
5
+ version: 0.1.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cory Schires
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-10-27 00:00:00 -05:00
14
- default_executable:
13
+ date: 2011-10-31 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rails
@@ -201,7 +200,7 @@ dependencies:
201
200
  type: :development
202
201
  version_requirements: *id017
203
202
  - !ruby/object:Gem::Dependency
204
- name: grb
203
+ name: pry
205
204
  prerelease: false
206
205
  requirement: &id018 !ruby/object:Gem::Requirement
207
206
  none: false
@@ -212,7 +211,7 @@ dependencies:
212
211
  type: :development
213
212
  version_requirements: *id018
214
213
  - !ruby/object:Gem::Dependency
215
- name: email_spec
214
+ name: grb
216
215
  prerelease: false
217
216
  requirement: &id019 !ruby/object:Gem::Requirement
218
217
  none: false
@@ -222,6 +221,17 @@ dependencies:
222
221
  version: "0"
223
222
  type: :development
224
223
  version_requirements: *id019
224
+ - !ruby/object:Gem::Dependency
225
+ name: email_spec
226
+ prerelease: false
227
+ requirement: &id020 !ruby/object:Gem::Requirement
228
+ none: false
229
+ requirements:
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: "0"
233
+ type: :development
234
+ version_requirements: *id020
225
235
  description: Don't use. Not production ready
226
236
  email:
227
237
  - coryschires@gmail.com
@@ -545,6 +555,7 @@ files:
545
555
  - db/migrate/20111016021105_create_impressions_table.rb
546
556
  - db/migrate/20111019162723_create_rostra_question_followings.rb
547
557
  - db/migrate/20111024223022_add_send_email_notifications_to_question_followings.rb
558
+ - db/migrate/20111029214642_add_impressions_count_to_questions.rb
548
559
  - lib/generators/rostra/install_generator.rb
549
560
  - lib/generators/rostra/templates/app/helpers/rostra/application_helper.rb
550
561
  - lib/generators/rostra/templates/config/initializers/rostra.rb
@@ -560,7 +571,6 @@ files:
560
571
  - MIT-LICENSE
561
572
  - Rakefile
562
573
  - README.rdoc
563
- has_rdoc: true
564
574
  homepage: ""
565
575
  licenses: []
566
576
 
@@ -584,7 +594,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
584
594
  requirements: []
585
595
 
586
596
  rubyforge_project:
587
- rubygems_version: 1.5.2
597
+ rubygems_version: 1.8.11
588
598
  signing_key:
589
599
  specification_version: 3
590
600
  summary: Don't use. Not production ready