Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 7
- Log:
Initial import of RForum 0.2 sources from a downloaded Tarball.
RForum is a Ruby On Rails based forum and mail gateway service.
- Author:
- adh
- Date:
- Sat Jul 22 18:43:13 +0100 2006
- Size:
- 1630 Bytes
1 | module Wraptools |
2 | # unwrap format=flowed text |
3 | def self.unwrap(s) |
4 | s.gsub(/ \n/, " ") |
5 | end |
6 | |
7 | # unwrap a format=flowed text; preserves quoting information |
8 | def self.unwrap_quoted(s) |
9 | level = nil # the quoting level |
10 | ff = nil # does the line end with " "? |
11 | |
12 | text = '' |
13 | |
14 | s.split(/\r*\n/).each do |t| |
15 | |
16 | old_level = level |
17 | old_ff = ff |
18 | # detect the quoting level of the line |
19 | if t =~ /^(>+)/ |
20 | level = $1.size |
21 | else |
22 | level = 0 |
23 | end |
24 | |
25 | # trailing space? |
26 | ff = (t[-1,1] == " ") |
27 | |
28 | if old_ff and level == old_level |
29 | result = t.sub(/^>{#{level}}\s/, "") |
30 | else |
31 | result = t |
32 | end |
33 | |
34 | if old_ff == false or (old_ff == true and level != old_level) |
35 | text += "\n" |
36 | end |
37 | |
38 | text += result |
39 | end |
40 | |
41 | text.gsub(/ \n/, "\n") |
42 | end |
43 | |
44 | # wrap a text with format=flowed |
45 | def self.wrap_ff(s, n) |
46 | wrap(s, n, " \n") |
47 | end |
48 | |
49 | # wrap a text |
50 | def self.wrap(s, n, break_string="\n") |
51 | s.split("\n").map do |t| |
52 | if t =~ /^[>|]/ |
53 | t + "\n" |
54 | elsif t.strip == "" |
55 | t = "\n" |
56 | else |
57 | t.gsub(/(.{0,#{n-1}}\S)(\s+|\Z)/,"\\1" + break_string).gsub(/\s+\n$/,"\n") |
58 | end |
59 | end.join('').chop |
60 | end |
61 | |
62 | # split words that are longer than n characters |
63 | def self.break_long_words(s, n) |
64 | s.gsub(/(\S{#{n}})(?=\S)/, "\\1 \\2") |
65 | end |
66 | |
67 | # add one level of indentation to a text |
68 | def self.quote(s) |
69 | s.split(/\r*\n/).each do |line| |
70 | if line =~ /^>/ |
71 | line.replace '>' + line |
72 | else |
73 | line.replace '> ' + line |
74 | end |
75 | end.join("\n") |
76 | end |
77 | end |