Skip to content

Commit

Permalink
Some deletes and minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Paco Guzman committed Mar 31, 2010
1 parent 1cab4c1 commit 3742e9c
Show file tree
Hide file tree
Showing 26 changed files with 356 additions and 530 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
EDGE
----
* Route refactor
* Avoid double submiting in ajax forms

0.1.1
----
Expand All @@ -13,4 +14,4 @@ EDGE
0.1.0
----
* Comment in a wall
* Reply comments in a wall
* Reply comments in a wall
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ TODO
More
-------

jQuery Form - [http://github.com/malsup/form](http://github.com/malsup/form)

[http://github.com/pacoguzman/tog_wall](http://github.com/pacoguzman/tog_wall)

[http://github.com/pacoguzman/tog_wall/wikis](http://github.com/pacoguzman/tog_wall/wikis)
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/member/graffities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ def like
respond_to do |format|
if can?(:like_graffity, @graffity) && @like.save && @like.move_to_child_of(@graffity)
flash[:ok] = I18n.t("tog_core.site.comment.added") # "like added"
status = :created
else
flash[:error] = I18n.t("tog_core.site.comment.error_commenting") # "like error"
status = :unprocessable_entity
end
format.html { redirect_to request.referer }
format.js { render :like; flash.discard }
format.js { render :like, :status => status; flash.discard }
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/graffities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module GraffitiesHelper
def graffities_paginate_link(*args)
options = args.extract_options!
wall_id = params[:wall_id].present? ? params[:wall_id] : current_user.profile.wall.id
url = show_more_member_wall_graffities_path(wall_id, options[:last_graffity].id)
url = show_more_member_wall_graffities_path(wall_id, :id => options[:last_graffity].id)

link_to content_tag(:span, t('tog_wall.views.walls.show.show_more.button')),
url, :class => 'graffity_paginate_link button',
Expand All @@ -26,7 +26,7 @@ def show_more_button(graffities)
end

def graffity_link_to_comment(graffity)
link_to I18n.t('tog_wall.views.site.comment.to_comment'), "#", :id => "reply-to-#{graffity.id}"
link_to I18n.t('tog_wall.views.site.comment.to_comment'), "#", :id => "reply-to-#{graffity.id}", :class => "reply"
end

def graffity_link_to_like(graffity)
Expand Down
4 changes: 1 addition & 3 deletions app/views/member/graffities/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<% form_for :graffity, :url => member_wall_graffities_path(@owner.wall), :html => {:id=>'graffity_form'} do |f| -%>
<fieldset>
<div class="fields">
<%= f.label :comment, I18n.t("tog_wall.model.graffity.comment.label"), :class => "hide" %>
<%= f.text_area :comment, {:placeholder => I18n.t("tog_wall.model.graffity.comment.textarea"),
:value => I18n.t("tog_wall.model.graffity.comment.textarea"),
:rows=>3, :cols=>40, :class=>"placeholder"} -%>
</div>
:rows=>3, :cols=>55, :class=>"placeholder"} -%>
</fieldset>

<div class="actions">
Expand Down
5 changes: 2 additions & 3 deletions app/views/member/graffities/_graffity.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
<%= graffity_link_to_walltowall(graffity) if can?(:see_walltowall, graffity) %>
</div>

<%= render :partial => "member/graffities/like_resume", :locals => {:likes => graffity.likes, :graffity => graffity} unless graffity.likes.empty? %>
<%= render :partial => "member/graffities/like_resume", :locals => {:likes => graffity.likes, :graffity => graffity} if graffity.likes.any? %>

<%= collapse_replies(graffity, :id => "collapsed_#{graffity.id}") %>
<%= render :partial => "member/graffities/reply", :collection => graffity.replies, :locals=>{:graffity=>graffity} %>
<%= render :partial => "member/graffities/reply", :collection => graffity.replies %>
<%= render :partial => "member/graffities/reply_form", :locals => {:instance => graffity,
:url => reply_member_graffity_path(graffity),
:form_element => :comment,
:label => I18n.t('general.post_comment')} if can?(:reply_at_wall, graffity.wall) %>
</div>
</div>
2 changes: 1 addition & 1 deletion app/views/member/graffities/_like_resume.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="like_resume_<%= graffity.id %>" class="small prepend-small">
<div id="like_<%= graffity.id %>" class="small prepend-small">
<div class="float_left">
<%#= TODO icono de likes %>
</div>
Expand Down
8 changes: 3 additions & 5 deletions app/views/member/graffities/_reply_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<div id="reply_div_to_<%= instance.id %>" class="prepend-small">
<% form_for Graffity.new, :url => url, :html => {:id => "reply_form_to_#{instance.id}", :class => "reply"} do |f| %>
<div id="reply_to_<%= instance.id %>" class="prepend-small">
<% form_for Graffity.new, :url => url, :html => {:id => dom_id(instance), :class => "reply"} do |f| %>

<div class="float_left avatar-tiny">
<%= link_to icon_for_profile(current_user.profile, 'tiny', :title => current_user.profile.full_name), profile_path(current_user.profile) %>
</div>
<fieldset>
<div class="fields">
<%= f.label "comment_#{instance.id}", I18n.t("tog_wall.model.reply.comment.label"), :class => "hide" %>
<%= f.text_area :comment, {:value => I18n.t("tog_wall.model.reply.comment.textarea"),
:placeholder => I18n.t("tog_wall.model.reply.comment.textarea"),
:id => "graffity_comment_#{instance.id}", :rows => 2, :cols => 35, :class => "reply placeholder"} -%>
</div>
:id => "graffity_comment_#{instance.id}", :rows => 2, :cols => 50, :class => "reply placeholder"} -%>
</fieldset>

<div class="actions">
Expand Down
8 changes: 5 additions & 3 deletions app/views/member/graffities/create.js.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<% if @graffity.approved && !@graffity.new_record? %>
<% escaped_js = escape_javascript(render(:partial => "member/graffities/graffity", :object => @graffity)) %>
if (jQuery("#graffities").children().length > 0)
<% escaped_js = escape_javascript(render(:partial => "member/graffities/graffity", :object => @graffity)) %>
if (jQuery("#graffities").children().length > 0) {
jQuery("#graffities").prepend("<%= escaped_js %>");
else
} else {
jQuery("#graffities").replaceWith("<%= escaped_js %>");
}

jQuery("textarea.reply", jQuery("#graffities")).filter(function(){
return !(!!jQuery(this).data('events'));
}).placeholder();
Expand Down
8 changes: 4 additions & 4 deletions app/views/member/graffities/like.js.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% if !@like.new_record? %>
jQuery("#<%= "like-to-#{@graffity.id}" %>").remove();
jQuery("#<%= "like-to-#{@graffity.id}" %>").remove();
<% escaped_js = escape_javascript(render("like_resume", :graffity => @graffity, :likes => @graffity.likes)) %>
if (jQuery("#<%= "like_resume_#{@graffity.id}" %>").size() > 0){
jQuery("#<%= "like_resume_#{@graffity.id}" %>").replaceWith("<%= escaped_js %>");
if (jQuery("#<%= "like_#{@graffity.id}" %>").size() > 0){
jQuery("#<%= "like_#{@graffity.id}" %>").replaceWith("<%= escaped_js %>");
} else {
jQuery("div.more", jQuery("#<%= dom_id(@graffity) %>")).after("<%= escaped_js %>");
jQuery("#<%= dom_id(@graffity) %>").find("div.more:first").after("<%= escaped_js %>");
}
<% end %>
2 changes: 1 addition & 1 deletion app/views/member/graffities/reply.js.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% if @reply.approved && !@reply.new_record? %>
<% escaped_js = escape_javascript(render(:partial => "member/graffities/reply", :object => @reply)) %>
jQuery("#<%= "reply_div_to_#{@graffity.id}" %>").before("<%= escaped_js %>");
jQuery("#<%= "reply_to_#{@graffity.id}" %>").before("<%= escaped_js %>");
<% end %>
36 changes: 36 additions & 0 deletions app/views/member/walls/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<% include_stylesheet "/tog_wall/stylesheets/personalization.css" %>
<% include_javascript "/tog_wall/javascripts/lowpro.js" %>
<% include_javascript "/tog_wall/javascripts/jquery-1.4.min.js" %>
<% include_javascript "/tog_wall/javascripts/jquery.noconflict.js" %>
<% include_javascript "/tog_wall/javascripts/jquery.form.js" %>
<% include_javascript "/tog_wall/javascripts/jquery.wall.js" %>
<% include_javascript "/tog_wall/javascripts/jquery.placeholder.js" %>

<% if can?(:comment_at_wall, @wall) %>
<%= render "member/graffities/form" %>
<% elsif !logged_in? %>
<%= "Debes iniciar sesión y ser amigo de #{@owner.full_name} para poder escribir comentarios en su muro" %>
<% else %>
<%= "Debes ser amigo de #{@owner.full_name} para poder escribir comentarios en su muro" %>
<% end %>

<div id="graffities" class="portlet portletJ">
<% if @graffities.blank? %>
<%= I18n.t('tog_wall.views.walls.show.graffities.not_found') %>
<% else %>
<%= render :partial => "member/graffities/graffity", :collection => @graffities %>
<% end -%>
</div>

<%= will_paginate @graffities, :renderer => FlowPagination::LinkRenderer %>

<script language="JavaScript" type="text/javascript">
//<![CDATA
document.observe("dom:loaded", function() {
// Comportaminentos javascript para las respuestas
Event.addBehavior({
'#graffities > div[id^=graffity_]' : CollapsableReplys(<%= options_for_collapse_to_js %>)
});
});
//]]>
</script>
7 changes: 7 additions & 0 deletions app/views/member/walls/show.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$("graffities").insert({bottom: "<%= escape_javascript(render :partial => "member/graffities/graffity", :collection => @graffities) %>"});
$('flow_pagination').replace("<%= escape_javascript(will_paginate(@graffities, :renderer => FlowPagination::LinkRenderer)) %>")
//TODO Reassign after ajax Lowpro doen's works
$$("form.reply").each(function(el) {
el.down("textarea.reply").actsAsReplyTextarea();
el.down("input[type=submit]").disable();
});
2 changes: 1 addition & 1 deletion app/views/walls/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% include_stylesheet "/tog_wall/stylesheets/personalization.css" %>
<% include_javascript "/tog_wall/javascripts/lowpro.js" %>
<% include_javascript "/tog_wall/javascripts/jquery-1.4.1.min.js" %>
<% include_javascript "/tog_wall/javascripts/jquery-1.4.2.min.js" %>
<% include_javascript "/tog_wall/javascripts/jquery.noconflict.js" %>
<% include_javascript "/tog_wall/javascripts/jquery.form.js" %>
<% include_javascript "/tog_wall/javascripts/jquery.wall.js" %>
Expand Down
7 changes: 7 additions & 0 deletions app/views/walls/show.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$("graffities").insert({bottom: "<%= escape_javascript(render :partial => "member/graffities/graffity", :collection => @graffities) %>"});
$('flow_pagination').replace("<%= escape_javascript(will_paginate(@graffities, :renderer => FlowPagination::LinkRenderer)) %>")
//TODO Reassign after ajax Lowpro doen's works
$$("form.reply").each(function(el) {
el.down("textarea.reply").actsAsReplyTextarea();
el.down("input[type=submit]").disable();
});
5 changes: 1 addition & 4 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@

Tog::Plugins.helpers WallsHelper, GraffitiesHelper

Tog::Search.sources << "Graffity"

#Tog::Interface.sections(:admin).add "Users", "/admin/users"
#Tog::Interface.sections(:member).add "My account", "/member/account"
Tog::Search.sources << "Graffity"
6 changes: 5 additions & 1 deletion locale/tog_wall.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
en:
interface:
site:
wall: Wall
wall:
datetimes:
articulo_el: ' '
yesterday_at: 'Yesterday at '
tog_wall:
see: see
cancel : Cancel
model:
graffity:
Expand All @@ -18,7 +22,7 @@ en:
walls:
show:
graffities:
not_found: There are not graffities in this wall
not_found: Any graffities in this wall
show_more:
button: Next graffities
loading: Loading next graffities...
Expand Down
8 changes: 6 additions & 2 deletions locale/tog_wall_es.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
es:
interface:
site:
wall: Muro
wall:
datetimes:
articulo_el: 'El '
yesterday_at: 'Ayer a las '
tog_wall:
see: ver
cancel: Cancelar
model:
graffity:
comment:
label: Comentario
textarea: ¿Qué estas pensando?
textarea: ¿Qué estás pensando?
reply:
comment:
label: Comment
Expand All @@ -18,7 +22,7 @@ es:
walls:
show:
graffities:
not_found: No hay grafitis en este muro
not_found: No hay grafitis en este muro todavía
show_more:
button: Conversaciones anteriores
loading: Cargando conversaciones anteriores...
Expand Down
3 changes: 2 additions & 1 deletion locale/tog_wall_pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pt-BR:
articulo_el: ' '
yesterday_at: 'Yesterday at '
tog_wall:
see: see
cancel : Cancel
model:
graffity:
Expand All @@ -18,7 +19,7 @@ pt-BR:
walls:
show:
graffities:
not_found: There are not graffities in this wall
not_found: Any graffities in this wall
show_more:
button: Next graffities
loading: Loading next graffities...
Expand Down
Loading

0 comments on commit 3742e9c

Please sign in to comment.