# -*- encoding : utf-8 -*- class Card; module Set; module All; module Comment; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/all/comment.rb ~~~~~~~~~~~ event :add_comment, after: :approve, on: :save, when: proc { |c| c.comment } do cleaned_comment = comment.split(/\n/).map do |line| "

#{line.strip.empty? ? ' ' : line}

" end * "\n" signature = if Auth.signed_in? "[[#{Auth.current.name}]]" else Env.session[:comment_author] = comment_author if Env.session "#{comment_author} (Not signed in)" end self.content = %{ #{content} #{'
' unless content.blank?} #{cleaned_comment}
--#{signature}.....#{Time.zone.now}
} end format do view :comment_box, denial: :blank, tags: :unknown_ok, perms: lambda { |r| r.card.ok? :comment } do |_args| <<-HTML
#{comment_form}
HTML end def comment_form card_form :update do %{ #{hidden_field_tag('card[name]', card.name) if card.new_card? # FIXME: wish we had more generalized solution for names. # without this, nonexistent cards will often take left's linkname. # (needs test) } #{text_area :comment, rows: 3} #{comment_buttons} } end end def comment_buttons <<-HTML
#{ unless Auth.signed_in? card.comment_author = session[:comment_author] || params[:comment_author] || 'Anonymous' # ENGLISH %{ #{text_field :comment_author}} end } #{submit_button text: 'Comment', type: :submit, disable_with: 'Commenting'}
HTML end end # ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/05_standard/set/all/comment.rb ~~~~~~~~~~~ end;end;end;end;