Sha256: a54735964fd5c034770d90055bf76db23ae1b08651a436ae7edf86dab97bafde
Contents?: true
Size: 1.8 KB
Versions: 3
Compression:
Stored size: 1.8 KB
Contents
module EltHelper def format(data) # for italics /.../ to _..._ \ #.gsub(/(\s+)\/([\w\séèàûîùô]*)\//, '\\1_\\2_') \ # On Date Time someone wrote: blockquote # Yahoo footer # Google footer # /italic/ # - listElement # 1. numbered list # chat log lines become list elements # short lines to which are added a break text = auto_link data \ .gsub(/^\b(.*:)$(\n)^>\s/, '\\1<br/>\\2\\2> ') \ .gsub(/^Yahoo! Groups Links$(\n{2}^<*.*$\s.*$)*/, '') \ .gsub(/^[-~]*$\n^You.*$\n^To.*$\n^To.*$\n^For more.*$\n^[-~]*$/, '') \ .gsub(/(\s+)\/([\w\s]*)\//, '\\1_\\2_') \ .gsub(/^-\s/, '* ') \ .gsub(/^\d+[\.-]\s+/, '# ') \ .gsub(/^(\d\d:\d\d\s)/, '* \\1') \ .gsub(/^\b(.{2,50})$(\n)\b/, '\\1<br/>\\2') \ if data != nil #hard_breaks = true textiled = text.blank? ? "" : RedCloth.new(text) begin textiled = textiled.to_html if !textiled.blank? rescue # TODO discover why RedCloth fails on this!!! textiled = textiled.gsub(/[->\[]/, ' ') textiled = textiled.to_html end if ! textiled.match(/[.\s]<p>/) and textiled.size < 200 then # Remove any leading and finishing <p> </p> as they are not required if textiled[0..2] == "<p>" then textiled = textiled[3..-1] end if textiled[-4..-1] == "</p>" then textiled = textiled[0..-5] end end textiled end # # Should we display an element's title # # The algo used is simple, display a title if it is not a simple reply to its # parent # def displayTitle? elt #elt.id and elt.subject.reverse.index(elt.parent.subject.reverse) != 0 elt.id and elt.parent and elt.subject and !elt.subject.empty? \ and elt.subject != elt.parent.subject \ and elt.parent.subject \ and elt.subject.downcase != elt.parent.subject.downcase \ and not elt.subject.sub(/(Re|réf|re|sv|aw):\s*/, '') == elt.parent.subject end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
parlement-0.7 | app/helpers/elt_helper.rb |
parlement-0.6 | app/helpers/elt_helper.rb |
parlement-0.8 | app/helpers/elt_helper.rb |