cortex-reaver 0.2.3 → 0.2.4

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.
@@ -24,7 +24,6 @@ module CortexReaver
24
24
  end
25
25
 
26
26
  on_save do |comment, request|
27
- comment.title = request[:title]
28
27
  comment.body = request[:body]
29
28
  comment.comment_id = request[:comment_id]
30
29
  comment.journal_id = request[:journal_id]
@@ -80,11 +79,11 @@ module CortexReaver
80
79
  CortexReaver.db.transaction do
81
80
  @comment = Comment.new
82
81
 
83
- @comment.title = request[:title]
84
82
  @comment.body = request[:body]
85
83
  @comment.comment_id = request[:comment_id]
86
84
  @comment.journal_id = request[:journal_id]
87
85
  @comment.photograph_id = request[:photograph_id]
86
+ @comment.page_id = request[:page_id]
88
87
 
89
88
  if session[:user]
90
89
  # A user is logged in. Use their account.
@@ -112,7 +111,7 @@ module CortexReaver
112
111
  # Clear action cache
113
112
  Ramaze::Cache.action.clear
114
113
 
115
- flash[:notice] = "Your comment (<a href=\"##{@comment.url.gsub(/.*#/, '')}\">#{h @comment.title}</a>) has been posted."
114
+ flash[:notice] = "<a href=\"##{@comment.url.gsub(/.*#/, '')}\">Your comment</a> has been posted."
116
115
  redirect @comment.parent.url
117
116
  end
118
117
  rescue => e
@@ -4,7 +4,7 @@ module CortexReaver
4
4
  # trait :app => :cortex_reaver
5
5
  engine :Erubis
6
6
  layout :text
7
- helper :form, :auth, :navigation, :workflow, :error, :sidebar, :aspect, :common
7
+ helper :form, :auth, :navigation, :workflow, :error, :sidebar, :aspect, :common, :gravatar
8
8
  end
9
9
  end
10
10
 
@@ -45,6 +45,7 @@ module CortexReaver
45
45
  # Render that page.
46
46
  @title = @page.title
47
47
 
48
+ # Workflows
48
49
  if user.can_edit? Page.new
49
50
  workflow "Edit this page", PageController.r(:edit, @page.id), :edit, :page
50
51
  end
@@ -52,6 +53,14 @@ module CortexReaver
52
53
  workflow "Delete this page", PageController.r(:delete, @page.id), :delete, :page
53
54
  end
54
55
 
56
+ # Set up comments
57
+ if comment = session[:pending_comment] and comment.parent == @page
58
+ @new_comment = session.delete :pending_comment
59
+ else
60
+ # Create a comment to be posted
61
+ @new_comment = CortexReaver::Comment.new :page => @page
62
+ end
63
+
55
64
  PageController.render_view('show')
56
65
  elsif not ids.empty?
57
66
  # Didn't have that page
@@ -34,6 +34,7 @@ module CortexReaver
34
34
  page.page_id = request[:page_id]
35
35
  page.name = Page.canonicalize request[:name], :id => page.id, :page_id => page.page_id
36
36
  page.draft = request[:draft]
37
+ page.comments_enabled = request[:comments_enabled]
37
38
  page.body = request[:body]
38
39
  end
39
40
 
@@ -0,0 +1,11 @@
1
+ module Ramaze
2
+ module Helper
3
+ module Gravatar
4
+ # Returns an IMG tag for a comment.
5
+ def gravatar_img(o)
6
+ email = o.creator.email rescue o.email || 'anonymous'
7
+ "<img src=\"http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email)}?r=pg&s=60\" alt=\"#{email}\" title=\"#{email}\" />"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module CortexReaver
2
+ class CommentsEnabledOnPagesSchema < Sequel::Migration
3
+ def down
4
+ alter_table(:pages) { drop_column :comments_enabled }
5
+ end
6
+
7
+ def up
8
+ alter_table(:pages) { add_column :comments_enabled, :boolean, :default => false }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module CortexReaver
2
+ class DropCommentTitlesSchema < Sequel::Migration
3
+ def down
4
+ alter_table(:comments) { add_column :varchar, :title }
5
+ end
6
+
7
+ def up
8
+ if CortexReaver.db[:comments].filter(:title => nil).invert.count > 0
9
+ puts "About to drop titles on comments. Hit enter to confirm, ctrl-c to cancel."
10
+ gets
11
+ end
12
+
13
+ alter_table(:comments) { drop_column :title }
14
+ end
15
+ end
16
+ end
@@ -15,19 +15,6 @@ module CortexReaver
15
15
  many_to_one :comment, :class => 'CortexReaver::Comment'
16
16
  one_to_many :comments, :class => 'CortexReaver::Comment'
17
17
 
18
- # Infer blank titles
19
- def before_save
20
- return false unless super
21
-
22
- if title.blank?
23
- title = 'Re: ' + parent.title.to_s
24
- title.gsub!(/^(Re: )+/, 'Re: ')
25
- self.title = title
26
- end
27
-
28
- true
29
- end
30
-
31
18
  # Update parent comment counts
32
19
  def before_destroy
33
20
  return false unless super
@@ -68,19 +55,8 @@ module CortexReaver
68
55
  '/comments'
69
56
  end
70
57
 
71
- def self.infer_blank_titles
72
- self.all.each do |comment|
73
- if comment.title.blank?
74
- comment.title = 'Re: ' + comment.parent.title.to_s
75
- comment.title.gsub!(/^(Re: )+/, 'Re: ')
76
- comment.skip_timestamp_update = true
77
- comment.save
78
- end
79
- end
80
- end
81
-
82
58
  def to_s
83
- title || 'comment ' + id.to_s
59
+ 'comment ' + id.to_s
84
60
  end
85
61
 
86
62
  def url
@@ -89,7 +65,6 @@ module CortexReaver
89
65
 
90
66
  def validate
91
67
  validates_presence :body
92
- validates_max_length 255, :title, :allow_blank => true
93
68
  validates_max_length 255, :name, :allow_blank => true
94
69
  validates_max_length 255, :http, :allow_blank => true
95
70
  validates_max_length 255, :email, :allow_blank => true
@@ -107,14 +82,14 @@ module CortexReaver
107
82
  unless self[field].blank?
108
83
  count += 1
109
84
  if count > 1
110
- self.errors[attribute] << 'has too many kinds of parents'
85
+ self.errors[:comment] << 'has too many kinds of parents'
111
86
  break
112
87
  end
113
88
  end
114
89
  end
115
90
 
116
91
  if count == 0
117
- self.errors[attribute] << "doesn't have a parent"
92
+ self.errors[:comment] << "doesn't have a parent"
118
93
  end
119
94
  end
120
95
  end
@@ -1,7 +1,48 @@
1
- .journal > .comments {
2
- margin-top: 2em;
1
+ div.comment {
2
+ margin-bottom: 10px;
3
+ padding: 6px;
4
+ -webkit-box-shadow: 0 0px 4px #bbb;
5
+ -moz-box-shadow: 0 0px 4px #bbb;
6
+ -webkit-border-radius: 3px;
7
+ -moz-border-radius: 3px;
8
+ position: relative;
9
+ min-height: 60px;
3
10
  }
4
11
 
5
- .comment {
6
- margin-bottom: 10px;
12
+ .comment .avatar {
13
+ position: absolute;
14
+ top: 6px;
15
+ left: 6px;
16
+ }
17
+
18
+ .comment .body {
19
+ margin-left: 66px;
20
+ margin-bottom: 20px;
21
+ }
22
+
23
+ .comment p:first-child {
24
+ margin-top: 0;
25
+ }
26
+
27
+ .comment .footer {
28
+ background: transparent;
29
+ position: absolute;
30
+ bottom: 6px;
31
+ left: 72px;
32
+ right: 6px;
33
+ height: 12px;
34
+ border: none;
35
+ padding: 2px;
36
+ }
37
+
38
+ .comment .footer .byline {
39
+ margin-bottom: 0;
40
+ position: relative;
41
+ height: auto;
42
+ }
43
+
44
+ .comment .footer .actions {
45
+ float: right;
46
+ width: 120px;
47
+ text-align: right;
7
48
  }
@@ -10,7 +10,6 @@ h1 {
10
10
 
11
11
  h2 {
12
12
  font-size: 150%;
13
- margin-top: 0;
14
13
  }
15
14
 
16
15
  h3 {
@@ -0,0 +1,3 @@
1
+ .page > .body *:first-child {
2
+ margin-top: 0;
3
+ }
@@ -11,15 +11,15 @@ h1 a, h2 a, h3 a {
11
11
  color: #555;
12
12
  }
13
13
 
14
- /* Text entries */
15
- .text-entry h2 {
14
+ .text-entry > *:first-child {
15
+ margin-top: 0;
16
16
  margin-bottom: 0;
17
- padding-bottom: 0;
18
17
  }
19
18
 
20
19
  .text-entry .byline {
21
20
  color: #666;
22
21
  position: relative;
22
+ height: 4px;
23
23
  }
24
24
 
25
25
  .text-entry .footer {
@@ -1,6 +1,6 @@
1
1
  module CortexReaver
2
2
  APP_NAME = 'Cortex Reaver'
3
- APP_VERSION = '0.2.3'
3
+ APP_VERSION = '0.2.4'
4
4
  APP_AUTHOR = 'Kyle Kingsbury'
5
5
  APP_EMAIL = 'aphyr@aphyr.com'
6
6
  APP_URL = 'http://aphyr.com'
@@ -1,17 +1,17 @@
1
1
  <div class="comment text-entry">
2
- <h2><a id="comment_<%= @comment.id %>" href="<%= @comment.url %>"><%=h @comment.title %></a></h2>
3
- <div class="byline">
4
- <%= author_info @comment %>
2
+ <a id="comment_<%= @comment.id %>"></a>
3
+ <div class="avatar">
4
+ <%= gravatar_img @comment %>
5
5
  </div>
6
6
  <div class="body">
7
7
  <%= @comment.body_cache %>
8
8
  </div>
9
+
9
10
  <div class="footer">
11
+ <div class="byline">
12
+ <%= author_info @comment %>
13
+ </div>
10
14
  <ul class="actions">
11
- <li><a href="<%=@comment.url %>_comments">
12
- <img src="/images/comment.gif" class="icon" alt="comment" />
13
- <%= @comment.comment_count %> <%= @comment.comment_count == 1 ? 'comment' : 'comments' %>
14
- </a></li>
15
15
  <% if user.can_edit? @comment %>
16
16
  <li><a href="/comments/edit/<%= @comment.id %>">
17
17
  <img src="/images/edit.gif" class="icon" alt="edit" /> Edit
@@ -24,8 +24,10 @@
24
24
  </a>
25
25
  </li>
26
26
  <% end %>
27
+ <li><a href="<%= @comment.url %>">Link</a></li>
27
28
  </ul>
28
29
  </div>
30
+
29
31
  <% unless @hide_comments %>
30
32
  <a id="comment_<%= @comment.id %>_comments" ></a>
31
33
  <div class="comments">
@@ -12,7 +12,6 @@
12
12
  <% end %>
13
13
 
14
14
  <%= form_for @comment, Rs(@form_action), [
15
- :title,
16
15
  :name,
17
16
  :email,
18
17
  :http,
@@ -1,4 +1,5 @@
1
1
  <div class="comments">
2
+ <h2>Recent Comments</h2>
2
3
  <% @comments.all.each do |comment| %>
3
4
  <%= CortexReaver::CommentController.render_view 'comment', 'comment' => comment, 'hide_comments' => true %>
4
5
  <% end %>
@@ -5,7 +5,6 @@
5
5
  <%= errors_on @new_comment %>
6
6
 
7
7
  <form class="comment-form" action="<%= CortexReaver::CommentController.r :post %>" method="post">
8
- <%= form_p :title, :model => @new_comment %>
9
8
  <p class="dont-read-me">
10
9
  Please avoid writing anything here unless you are a computer:
11
10
  <label for="captcha">Captcha</label>
@@ -31,7 +31,7 @@
31
31
 
32
32
  <% unless @hide_comments %>
33
33
  <div class="comments">
34
- <a id="comments" />
34
+ <a id="comments" /><h2>Comments</h2>
35
35
  <% @journal.comments_dataset.order(:created_on).all.each do |comment| %>
36
36
  <%= CortexReaver::CommentController.render_view :comment, 'comment' => comment %>
37
37
  <% end %>
@@ -9,6 +9,7 @@
9
9
  <%= live_tags_field @page %>
10
10
  <%= form_p :body, :model => @page, :type => 'textarea' %>
11
11
  <%= attachment_form @page %>
12
+ <%= form_p :comments_enabled, :model => @page, :type => 'checkbox', :description => 'Allow comments' %>
12
13
  <%= form_p :draft, :model => @page, :type => 'checkbox', :description => 'This is a draft' %>
13
14
  <input type="submit" name="submit" />
14
15
  </form>
@@ -3,4 +3,15 @@
3
3
  <%= @page.body_cache %>
4
4
  <div class="clear"></div>
5
5
  </div>
6
+
7
+ <% if @page.comments_enabled %>
8
+ <div class="comments">
9
+ <a id="comments">
10
+ <% @page.comments_dataset.order(:created_on).all.each do |comment| %>
11
+ <%= CortexReaver::CommentController.render_view :comment, 'comment' => comment %>
12
+ <% end %>
13
+ </div>
14
+
15
+ <%= CortexReaver::CommentController.render_view :post_form, 'comment' => @new_comment %>
16
+ <% end %>
6
17
  </div>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cortex-reaver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Kingsbury
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-17 00:00:00 -08:00
12
+ date: 2009-12-13 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -158,6 +158,7 @@ files:
158
158
  - lib/cortex_reaver/public/css/custom.css
159
159
  - lib/cortex_reaver/public/css/table.css
160
160
  - lib/cortex_reaver/public/css/icons.css
161
+ - lib/cortex_reaver/public/css/page.css
161
162
  - lib/cortex_reaver/public/css/actions.css
162
163
  - lib/cortex_reaver/public/css/journals.css
163
164
  - lib/cortex_reaver/public/css/fonts.css
@@ -273,6 +274,7 @@ files:
273
274
  - lib/cortex_reaver/view/head.rhtml
274
275
  - lib/cortex_reaver/cache.rb
275
276
  - lib/cortex_reaver/migrations/003_journals.rb
277
+ - lib/cortex_reaver/migrations/015_page_comments.rb
276
278
  - lib/cortex_reaver/migrations/009_mysql.rb
277
279
  - lib/cortex_reaver/migrations/011_user_roles.rb
278
280
  - lib/cortex_reaver/migrations/002_pages.rb
@@ -284,6 +286,7 @@ files:
284
286
  - lib/cortex_reaver/migrations/007_comments.rb
285
287
  - lib/cortex_reaver/migrations/014_convert_projects_to_pages.rb
286
288
  - lib/cortex_reaver/migrations/013_draft.rb
289
+ - lib/cortex_reaver/migrations/016_drop_comment_titles.rb
287
290
  - lib/cortex_reaver/migrations/001_users.rb
288
291
  - lib/cortex_reaver/migrations/004_photographs.rb
289
292
  - lib/cortex_reaver/controller/tag.rb
@@ -312,6 +315,7 @@ files:
312
315
  - lib/cortex_reaver/helper/sidebar.rb
313
316
  - lib/cortex_reaver/helper/workflow.rb
314
317
  - lib/cortex_reaver/helper/attachments.rb
318
+ - lib/cortex_reaver/helper/gravatar.rb
315
319
  - lib/cortex_reaver/helper/navigation.rb
316
320
  - lib/cortex_reaver/helper/crud.rb
317
321
  - lib/cortex_reaver/helper/photographs.rb