rostra 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -29,6 +29,35 @@ Call <tt>rostra</tt> in your user model:
29
29
  end
30
30
 
31
31
 
32
+ == Customizing the question and answer models
33
+ Rostra provides a DSL for adding application specific logic to <tt>Rostra::Question</tt> and <tt>Rostra:Answer</tt>:
34
+
35
+ class User < ActiveRecord::Base
36
+ rostra do
37
+ questions do
38
+ # Code inside this block will be evaluated in the context of `Rostra::Question`.
39
+
40
+ # So an instance method might look like:
41
+ #
42
+ def active?
43
+ # call this like @question.active?
44
+ end
45
+ end
46
+
47
+ answers do
48
+ # Code inside this block will be evaluated in the context of `Rostra::Answer`
49
+
50
+ # So a class method might look like:
51
+ #
52
+ def self.recently_up_voted
53
+ # call this like Rostra::Answer.recently_up_voted
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+
32
61
  == Contributing to Rostra
33
62
  Fork the project, make your changes, and submit a pull request. Please ensure the tests pass:
34
63
 
@@ -1,7 +1,7 @@
1
1
  p, li { line-height: 18px; margin: 0 0 10px 0; }
2
2
  a, a:visited { }
3
3
  a:hover { }
4
- h1 { font-size: 36px; margin: 20px 0 50px; padding-bottom: 5px; border-bottom: 1px #ccc solid; }
4
+ h1 { font-size: 36px; margin: 20px 0 30px; padding-bottom: 5px; border-bottom: 1px #ccc solid; }
5
5
  h3 { font-size: 22px; margin: 0 0 10px 0; }
6
6
  h4 { font-size: 18px; margin: 30px 0 10px 0; border-bottom: 1px #ccc solid; padding-bottom: 5px; }
7
7
 
@@ -15,12 +15,6 @@ module Rostra
15
15
 
16
16
  helper_method Rostra::Config.rostra_user
17
17
 
18
- # def current_user
19
- # rostra_user
20
- # end
21
-
22
- # alias :current_user :
23
-
24
18
  def main_app_login_path
25
19
  send(:main_app).send(Rostra::Config.main_app_login_path)
26
20
  end
@@ -15,9 +15,10 @@ module Rostra
15
15
  # Finds questions asked within the last 15 days ordered by non-unique page views.
16
16
  #
17
17
  def self.trending(limit = 5)
18
- Question
19
- .where(created_at: (15.days.ago)..(Time.now)).limit(limit)
18
+ Question.where(created_at: (15.days.ago)..(Time.now)).limit(limit)
20
19
 
20
+ # This code doesn't work in postgres.
21
+ #
21
22
  # Question
22
23
  # .where(created_at: (15.days.ago)..(Time.now))
23
24
  # .limit(limit)
@@ -15,6 +15,22 @@
15
15
  <%= content_tag :div, msg, id: "flash_#{name}", class: 'flash' %>
16
16
  <% end %>
17
17
 
18
+ <h1><%=
19
+ case "#{controller_name}##{action_name}"
20
+ when "questions#show" then @question.title
21
+ when "questions#index" then
22
+ if params[:tag_search].present?
23
+ "Recent Questions for tag #{params[:tag_search]}"
24
+ else
25
+ "Recent Questions"
26
+ end
27
+ when "questions#new" then "Post a new question"
28
+ when "questions#edit" then "Editing question"
29
+ when "answers#edit" then "Editing answer"
30
+ else "Recent Questions"
31
+ end
32
+ %></h1>
33
+
18
34
  <%= yield %>
19
35
  </div>
20
36
  </body>
@@ -1,5 +1,3 @@
1
- <h1>Editing answer</h1>
2
-
3
1
  <%= render 'rostra/shared/sidebar' %>
4
2
 
5
3
  <div id="page_content">
@@ -1,5 +1,3 @@
1
- <h1>Editing question</h1>
2
-
3
1
  <%= render 'rostra/shared/sidebar' %>
4
2
 
5
3
  <div id="page_content">
@@ -1,10 +1,3 @@
1
- <h1>
2
- Recent Questions
3
- <% if params[:tag_search] %>
4
- for tag "<%= params[:tag_search] %>"
5
- <% end %>
6
- </h1>
7
-
8
1
  <%= render 'rostra/shared/sidebar' %>
9
2
 
10
3
  <div id="page_content">
@@ -1,5 +1,3 @@
1
- <h1>Post a new question</h1>
2
-
3
1
  <%= render 'rostra/shared/sidebar' %>
4
2
 
5
3
  <div id="page_content">
@@ -1,5 +1,3 @@
1
- <h1><%= @question.title %></h1>
2
-
3
1
  <%= render 'rostra/shared/sidebar' %>
4
2
 
5
3
  <div id="page_content">
@@ -7,7 +5,6 @@
7
5
  <div class="question" id="<%= dom_id(@question) %>">
8
6
  <%= render partial: 'rostra/shared/votes', locals: { resource: @question } %>
9
7
  <%= image_tag avatar_url(@question.user), class: 'avatar' %>
10
- <h3 class="title"><%= @question.title %></h3>
11
8
  <cite>
12
9
  Asked by <%= @question.user.rostra_user_name %>
13
10
  <%= link_to 'edit', edit_question_path(@question) if can? :manage, @question %>
@@ -1,3 +1,3 @@
1
1
  module Rostra
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/rostra.rb CHANGED
@@ -17,13 +17,26 @@ module Rostra
17
17
  # rostra
18
18
  # end
19
19
  #
20
- def rostra
20
+ def rostra(&block)
21
21
  has_many :questions
22
22
  has_many :answers
23
23
  has_many :comments
24
24
  acts_as_voter
25
25
 
26
26
  include InstanceMethods
27
+
28
+ if block_given?
29
+ def Rostra.questions(&questions_block)
30
+ Rostra::Question.class_eval(&questions_block)
31
+ end
32
+
33
+ def Rostra.answers(&answers_block)
34
+ Rostra::Answer.class_eval(&answers_block)
35
+ end
36
+
37
+ Rostra.class_eval(&block)
38
+ end
39
+
27
40
  end
28
41
  end
29
42
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rostra
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.7
5
+ version: 0.0.8
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-10-16 00:00:00 -05:00
13
+ date: 2011-10-18 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency