Sfoglia il codice sorgente

Lots of changes for the views

master
Peter J. Jones 11 anni fa
parent
commit
f8deaae1d3

+ 4
- 1
app/helpers/comments_helper.rb Vedi File

@@ -31,11 +31,14 @@ module CommentsHelper

################################################################################
def comments_reply_link (title, parent, comment=nil)
comment_id = comment.id if comment.is_a?(ActiveRecord::Base)
comment_id ||= comment unless comment.nil?
link_to_remote(title, :method => :get, :url => {
"#{parent.class.to_s.underscore}_id" => parent.id,
:controller => 'comments',
:action => 'new',
:reply_id => (comment ? comment.id : nil),
:reply_id => comment_id,
:back => comments_this_site_url + request.request_uri,
})
end

+ 1
- 1
app/models/comment.rb Vedi File

@@ -84,7 +84,7 @@ class Comment < ActiveRecord::Base
# Returns the author's URL, cleaned up if necessary.
def author_url
url = self[:author_url]
url.blank? ? nil : "http://#{url}" unless url.match(/^http:\/\//i)
url.blank? ? nil : ("http://#{url}" unless url.match(/^http:\/\//i))
end

################################################################################

+ 22
- 9
app/views/comments/_attributes.html.erb Vedi File

@@ -1,15 +1,28 @@
<div class="author">
<% if !comment.author_url.blank? %>
<p><%= link_to(h(comment.author_name), comment.author_url) %></p>
<% else %>
<p><%= h(comment.author_name) %></p>
<% end %>
</div>
<div class="attributes">
<div class="author">
<% if Banter::Config.use_gravatar %>
<% sum = Digest::MD5.hexdigest((comment.author_email || 'fakeemail').downcase.gsub(/\s+/, '')) %>
<img class="avatar" src="http://www.gravatar.com/avatar/<%= sum %>.jpg?r=g&s=48"/>
<% end %>
<% if !comment.author_url.blank? %>
<p><%= link_to(h(comment.author_name), comment.author_url) %></p>
<% else %>
<p><%= h(comment.author_name) %></p>
<% end %>
</div>

<div class="date">
<%= h(comment.created_at.to_s(Banter::Config.date_format)) %>
<div class="date">
<%= h(comment.created_at.to_s(Banter::Config.date_format)) %>
</div>
<div class="reply-link">
<%= comments_reply_link('Reply', parent, (comment.reply_id ? comment.reply_id : comment)) %>
</div>
</div>

<div class="body">
<%= sanitize(comment.content_cache) %>
</div>

<br class="clear"/>

+ 4
- 7
app/views/comments/_comment.html.erb Vedi File

@@ -1,13 +1,10 @@
<div class="comment" id="<%= comment.dom_id %>">
<%= render(:partial => 'comments/attributes', :locals => {:comment => comment}) %>
<div class="comment <%= cycle("comment-even", "comment-odd", :name => "comment") %>" id="<%= comment.dom_id %>">
<%= render(:partial => 'comments/attributes', :locals => {:comment => comment, :parent => parent}) %>
<div class="replies">
<% comment.replies.each do |reply| %>
<%= render(:partial => 'comments/reply', :object => reply) %>
<%= render(:partial => 'comments/reply', :object => reply, :locals => {:parent => parent}) %>
<% end %>
</div>
<div class="bottom-reply-link">
<%= comments_reply_link('Reply', parent, comment) %>
<% reset_cycle('reply') -%>
</div>
</div>

+ 30
- 25
app/views/comments/_form.html.erb Vedi File

@@ -6,32 +6,37 @@
<%= form.hidden_field(:cached_parent_url) %>
<%= hidden_field_tag('reply_id', params[:reply_id]) %>
<p>
<label>Name:</label>
<%= form.text_field(:author_name) %>
</p>
<div class="attributes">
<p>
<label>Name: <em>(optional, but nice)</em></label>
<%= form.text_field(:author_name) %>
</p>
<p>
<label>Email: <em>(not published, used if you want replies)</em></label>
<%= form.text_field(:author_email) %>
</p>
<p>
<label>URL: <em>(optional, if you want free marketing)</em></label>
<%= form.text_field(:author_url) %>
</p>
<p>
<%= form.check_box(:wants_replies) %>
<label class="checkbox">Receive email when someone replies to this comment <em>(and only this comment)</em></label>
</p>
</div>
<p>
<label>Email: <em>(not published, used if you want replies)</em></label>
<%= form.text_field(:author_email) %>
</p>
<p>
<label>URL: <em>(optional, if you want free marketing)</em></label>
<%= form.text_field(:author_url) %>
</p>
<p>
<%= form.check_box(:wants_replies) %>
<label>Email me when someone replies to this comment <em>(and only this comment)</em></label>
</p>
<p>
<label>Comment: <em>(<a href="http://hobix.com/textile/">Textile</a> supported)</em></label>
<%= form.text_area(:content) %>
</p>
<%= submit_tag('Submit Comment', :disable_with => 'Posting') %>
<div class="contents">
<p>
<label>Comment: <em>(<a href="http://hobix.com/textile/">Textile</a> supported)</em></label>
<%= form.text_area(:content) %>
</p>
<%= button_to_function('Cancel') {|p| p['comment-form'].hide; p['comment-post-link'].show} %>
<%= submit_tag('Submit Comment', :disable_with => 'Posting') %>
</div>
<% end %>

<div id="comment-post-notice" style="display:none">

+ 2
- 2
app/views/comments/_reply.html.erb Vedi File

@@ -1,3 +1,3 @@
<div class="reply">
<%= render(:partial => 'comments/attributes', :locals => {:comment => reply}) %>
<div class="reply <%= cycle('reply-even', 'reply-odd', :name => 'reply') %>">
<%= render(:partial => 'comments/attributes', :locals => {:comment => reply, :parent => parent}) %>
</div>

+ 2
- 2
app/views/comments/_show.html.erb Vedi File

@@ -1,6 +1,6 @@
<div id="comments">
<h1>Comments (<%= parent.comments.count %>)</h1>
<h1><%= pluralize(parent.comments.count, 'Comment') %></h1>
<%= render(:partial => 'comments/comment', :collection => Comment.for(parent), :locals => {:parent => parent}) %>
<%= comments_reply_link('Post a comment.', parent) %>
<div id="comment-post-link"><%= comments_reply_link('Post a comment.', parent) %></div>
<div id="comment-form-area"></div>
</div>

+ 1
- 0
app/views/comments/create.js.rjs Vedi File

@@ -1,3 +1,4 @@
page['comment-form'].remove
page['comment-post-notice'].show
page['comment-post-link'].show
page << "Element.scrollTo('comment-post-notice');"

+ 2
- 0
app/views/comments/new.js.rjs Vedi File

@@ -1,2 +1,4 @@
page['comment-post-link'].hide
page['comment-form-area'].replace_html(:partial => 'form')
page << "Form.focusFirstElement('comment-form');"
page << "$('comment-form').scrollTo();"

+ 5
- 0
lib/banter/config.rb Vedi File

@@ -51,5 +51,10 @@ module Banter
cattr_accessor(:date_format)
@@date_format = :short
################################################################################
# Enable or disable Gravatar support.
cattr_accessor(:use_gravatar)
@@use_gravatar = true
end
end

Loading…
Annulla
Salva