Sha256: 8d303f689cb26a824b9b5b08bdf294c6920f0b335e9ccab4cffc4444102f078b
Contents?: true
Size: 1.95 KB
Versions: 22
Compression:
Stored size: 1.95 KB
Contents
def commenting? comment && @action != :delete end event :add_comment, :prepare_to_store, on: :save, when: :comment do Env.session[:comment_author] = comment_author if Env.session return unless comment.present? self.content = [content, format.comment_with_signature].compact.join "\n<hr\>\n" end attr_writer :comment_author def comment_author @comment_author ||= Env.session[:comment_author] || Env.params[:comment_author] || "Anonymous" end def clean_comment comment.split(/\n/).map do |line| "<p>#{line.strip.empty? ? ' ' : line}</p>" end * "\n" end format do def comment_with_signature card.clean_comment + "\n" + comment_signature end def comment_signature wrap_with :div, class: "w-comment-author" do "#{comment_author}.....#{Time.zone.now}" end end def comment_author if Auth.signed_in? "[[#{Auth.current.name}]]" else "#{card.comment_author} (Not signed in)" end end view :comment_box, denial: :blank, tags: :unknown_ok, perms: :comment, cache: :never do wrap_with :div, class: "comment-box nodblclick" do action = card.new_card? ? :create : :update card_form action do [hidden_comment_fields, comment_box, comment_buttons] end end end def hidden_comment_fields return unless card.new_card? hidden_field_tag "card[name]", card.name # FIXME: wish we had more generalized solution for names. # without this, nonexistent cards will often take left's linkname. # (needs test) end def comment_box text_area :comment, rows: 3 end def comment_buttons wrap_with :div, class: "comment-buttons" do [comment_author_label, comment_submit_button] end end def comment_author_label return if Auth.signed_in? %(<label>My Name is:</label> #{text_field :comment_author}) end def comment_submit_button submit_button text: "Comment", type: :submit, disable_with: "Commenting" end end
Version data entries
22 entries across 22 versions & 1 rubygems