Index: openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl,v
diff -u -r1.76 -r1.77
--- openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 4 Feb 2018 00:59:29 -0000 1.76
+++ openacs-4/packages/acs-tcl/tcl/text-html-procs.tcl 3 Mar 2018 20:42:33 -0000 1.77
@@ -1856,57 +1856,73 @@
#
####################
+if {![info commands ns_reflow_text] ne ""} {
+ ad_proc ns_reflow_text {{-width 80} {-prefix ""} input} {
-ad_proc wrap_string {input {threshold 80}} {
- wraps a string to be no wider than 80 columns by inserting line breaks
-} {
- set result_rows [list]
- set start_of_line_index 0
- while 1 {
- set this_line [string range $input $start_of_line_index [expr {$start_of_line_index + $threshold - 1}]]
- if { $this_line eq "" } {
- return [join $result_rows "\n"]
- }
- set first_new_line_pos [string first "\n" $this_line]
- if { $first_new_line_pos != -1 } {
- # there is a newline
- lappend result_rows [string range $input $start_of_line_index [expr {$start_of_line_index + $first_new_line_pos - 1}]]
- set start_of_line_index [expr {$start_of_line_index + $first_new_line_pos + 1}]
- continue
- }
- if { $start_of_line_index + $threshold + 1 >= [string length $input] } {
- # we're on the last line and it is < threshold so just return it
- lappend result_rows $this_line
- return [join $result_rows "\n"]
- }
- set last_space_pos [string last " " $this_line]
- if { $last_space_pos == -1 } {
- # no space found! Try the first space in the whole rest of the string
- set next_space_pos [string first " " [string range $input $start_of_line_index end]]
- set next_newline_pos [string first "\n" [string range $input $start_of_line_index end]]
- if {$next_space_pos == -1} {
- set last_space_pos $next_newline_pos
- } elseif {$next_space_pos < $next_newline_pos} {
- set last_space_pos $next_space_pos
- } else {
- set last_space_pos $next_newline_pos
+ Reflow a plain text to the given width and prefix every line
+ optionally wiith the provided string
+
+ } {
+ set result_rows [list]
+ set start_of_line_index 0
+ while 1 {
+ set this_line [string range $input $start_of_line_index [expr {$start_of_line_index + $width - 1}]]
+ if { $this_line eq "" } {
+ set result [join $result_rows "\n"]
+ break
}
+ set first_new_line_pos [string first "\n" $this_line]
+ if { $first_new_line_pos != -1 } {
+ # there is a newline
+ lappend result_rows [string range $input $start_of_line_index \
+ [expr {$start_of_line_index + $first_new_line_pos - 1}]]
+ set start_of_line_index [expr {$start_of_line_index + $first_new_line_pos + 1}]
+ continue
+ }
+ if { $start_of_line_index + $width + 1 >= [string length $input] } {
+ # we're on the last line and it is < width so just return it
+ lappend result_rows $this_line
+ break
+ }
+ set last_space_pos [string last " " $this_line]
if { $last_space_pos == -1 } {
- # didn't find any more whitespace, append the whole thing as a line
- lappend result_rows [string range $input $start_of_line_index end]
- return [join $result_rows "\n"]
+ # no space found! Try the first space in the whole rest of the string
+ set next_space_pos [string first " " [string range $input $start_of_line_index end]]
+ set next_newline_pos [string first "\n" [string range $input $start_of_line_index end]]
+ if {$next_space_pos == -1} {
+ set last_space_pos $next_newline_pos
+ } elseif {$next_space_pos < $next_newline_pos} {
+ set last_space_pos $next_space_pos
+ } else {
+ set last_space_pos $next_newline_pos
+ }
+ if { $last_space_pos == -1 } {
+ # didn't find any more whitespace, append the whole thing as a line
+ lappend result_rows [string range $input $start_of_line_index end]
+ break
+ }
}
+ # OK, we have a last space pos of some sort
+ set real_index_of_space [expr {$start_of_line_index + $last_space_pos}]
+ lappend result_rows [string range $input $start_of_line_index $real_index_of_space-1]
+ set start_of_line_index [expr {$start_of_line_index + $last_space_pos + 1}]
}
- # OK, we have a last space pos of some sort
- set real_index_of_space [expr {$start_of_line_index + $last_space_pos}]
- lappend result_rows [string range $input $start_of_line_index $real_index_of_space-1]
- set start_of_line_index [expr {$start_of_line_index + $last_space_pos + 1}]
+ return $prefix[join $result_rows "\n$prefix"]
}
}
+ad_proc -deprecated wrap_string {input {width 80}} {
+ wraps a string to be no wider than 80 columns by inserting line breaks
+ @see ns_reflow_text
+} {
+ return [ns_reflow_text -width $width -prefix "" $input]
+}
+
+
+
####################
#
# Wrappers to make it easier to write generic code
@@ -2080,7 +2096,7 @@
set text [ad_text_to_html -- $text]
}
text/plain {
- set text [wrap_string $text $maxlen]
+ set text [ns_reflow_text -width $maxlen -- $text]
}
}
}
@@ -2090,7 +2106,7 @@
set text "
[ad_text_to_html -no_lines -- $text]
"
}
text/plain {
- set text [wrap_string $text $maxlen]
+ set text [ns_reflow_text -width $maxlen -- $text]
}
}
}
@@ -2110,7 +2126,7 @@
set text "
[ad_text_to_html -no_lines -- $text]
"
}
text/plain {
- set text [wrap_string $text $maxlen]
+ set text [ns_reflow_text -width $maxlen -- $text]
}
}
}
Index: openacs-4/packages/faq/faq.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/faq/faq.info,v
diff -u -r1.28 -r1.29
--- openacs-4/packages/faq/faq.info 7 Aug 2017 23:48:10 -0000 1.28
+++ openacs-4/packages/faq/faq.info 3 Mar 2018 20:42:33 -0000 1.29
@@ -7,7 +7,7 @@
ff
-
+ Nima MazloumiJennie Kim HousmanElizabeth Wirth
@@ -18,9 +18,9 @@
2#faq.FAQs#
-
+
-
+
Index: openacs-4/packages/faq/tcl/q-and-a-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/faq/tcl/q-and-a-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/faq/tcl/q-and-a-procs.tcl 7 Aug 2017 23:48:10 -0000 1.3
+++ openacs-4/packages/faq/tcl/q-and-a-procs.tcl 3 Mar 2018 20:42:33 -0000 1.4
@@ -26,7 +26,7 @@
append text_version "Faq: $faq_name
Author: $name ($email)\n\n"
- append text_version [wrap_string $q_a_text]
+ append text_version [ns_reflow_text -- $q_a_text]
append text_version "\n\n--
To view the entire FAQ go to:
$faq_url
Index: openacs-4/packages/sloan-bboard/sloan-bboard.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/sloan-bboard/sloan-bboard.info,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/sloan-bboard/sloan-bboard.info 19 Oct 2016 09:00:04 -0000 1.5
+++ openacs-4/packages/sloan-bboard/sloan-bboard.info 3 Mar 2018 20:42:33 -0000 1.6
@@ -7,7 +7,7 @@
ff
-
+ oraclepostgresql
@@ -19,8 +19,9 @@
2004-03-10OpenACSThis is the release candidate for bboard version 4.0.2. This package provides customizable discussion forums for a community of users.
-
+
+
Index: openacs-4/packages/sloan-bboard/tcl/bboard-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/sloan-bboard/tcl/bboard-procs.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/sloan-bboard/tcl/bboard-procs.tcl 20 Apr 2004 21:13:55 -0000 1.6
+++ openacs-4/packages/sloan-bboard/tcl/bboard-procs.tcl 3 Mar 2018 20:42:33 -0000 1.7
@@ -952,11 +952,11 @@
where forum_id = :forum_id
}
- if {[string equal $mime_type "text/plain"]} {
+ if {$mime_type eq "text/plain"} {
set result $content
- } elseif {[string equal $mime_type "text/plain; format=flowed"]} {
- set result [wrap_string $content]
- } elseif {[string equal $mime_type "text/html"]} {
+ } elseif {$mime_type eq "text/plain; format=flowed"} {
+ set result [ns_reflow_text -- $content]
+ } elseif {$mime_type eq "text/html"} {
set result [ad_html_to_text -- $content]
} else {
set result "Error display bboard posting as email!
Index: openacs-4/packages/sloan-bboard/www/forum-entry.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/sloan-bboard/www/forum-entry.adp,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/sloan-bboard/www/forum-entry.adp 29 Mar 2002 19:35:47 -0000 1.7
+++ openacs-4/packages/sloan-bboard/www/forum-entry.adp 3 Mar 2018 20:42:33 -0000 1.8
@@ -43,7 +43,7 @@
-->
Index: openacs-4/packages/sloan-bboard/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/sloan-bboard/www/index.adp,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/sloan-bboard/www/index.adp 29 Mar 2002 19:35:47 -0000 1.6
+++ openacs-4/packages/sloan-bboard/www/index.adp 3 Mar 2018 20:42:33 -0000 1.7
@@ -32,7 +32,7 @@