From c10ce14d1e8b8b5200c61801bf7f7565199aa18c Mon Sep 17 00:00:00 2001
From: Dries Buytaert
Date: Sat, 21 Dec 2002 18:53:39 +0000
Subject: - Switched the "short version" and the "long version" on the preview
page.
- Removed a broken filter which caused some line breaks to be stripped.
- It is now possible to create short teasers and the '---' delimiter can
be outside the allowed range but not more than a factor two.
- Fine-tuned teaser extraction in absence of the '---' delimiter.
---
modules/node.module | 46 +++++++++++++++-------------------------------
1 file changed, 15 insertions(+), 31 deletions(-)
(limited to 'modules/node.module')
diff --git a/modules/node.module b/modules/node.module
index 1d5709a57..a98521c5a 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -59,11 +59,12 @@ function node_teaser($body) {
/*
** If a valid delimiter has been specified, use it to
- ** chop of the teaser.
+ ** chop of the teaser. The delimiter can be outside
+ ** the allowed range but no more than a factor two.
*/
$delimiter = strpos($body, "---");
- if ($delimiter > 100 && $delimiter < $size) {
+ if ($delimiter > 0 && $delimiter < $size * 2) {
return substr($body, 0, $delimiter);
}
@@ -73,20 +74,20 @@ function node_teaser($body) {
** we try to split at paragraph boundaries.
*/
- if ($length = strpos($body, "\n", $size)) {
- return substr($body, 0, $length + 1);
- }
-
if ($length = strpos($body, "
", $size)) {
- return substr($body, 0, $length + 6);
+ return substr($body, 0, $length);
}
if ($length = strpos($body, "
", $size)) {
- return substr($body, 0, $length + 4);
+ return substr($body, 0, $length);
}
if ($length = strpos($body, "
", $size)) {
- return substr($body, 0, $length + 4);
+ return substr($body, 0, $length);
+ }
+
+ if ($length = strpos($body, "\n", $size)) {
+ return substr($body, 0, $length);
}
/*
@@ -391,24 +392,6 @@ function node_filter_link($text) {
return ereg_replace($pat, $dst, $text);
}
-function node_filter_line($text) {
-
- /*
- ** This "line break filter" will try to get the line breaks right
- ** regardless of the user's input. Its goal aspires a consistent
- ** mark-up and use of line breaks and paragraphs.
- */
-
- /*
- ** Replace some common "artifacts":
- */
-
- $list = "blockquote|li|ol|ul|table|th|td|tr|pre";
- $text = preg_replace(array("/\n\s*<([\/])($list)/", "/($list)>\s*\n/"), array("<$1$2", "$1>"), $text);
-
- return trim($text);
-}
-
function node_comment_mode($nid) {
static $comment_mode;
if (!isset($comment_mode[$nid])) {
@@ -425,7 +408,8 @@ function node_filter($text) {
if (variable_get("filter_html", 0)) $text = node_filter_html($text);
if (variable_get("filter_link", 0)) $text = node_filter_link($text);
- return node_filter_line($text);
+
+ return trim($text);
}
function node_link($type, $node = 0, $main = 0) {
@@ -1073,11 +1057,11 @@ function node_preview($node, $error = NULL) {
$view->teaser = filter($view->teaser);
if ($view->teaser && $view->teaser != $view->body) {
- print "". t("Preview full version") ."
";
- node_view($view, 0);
print "". t("Preview trimmed version") ."
";
node_view($view, 1);
- print "". t("The trimmed version of your post shows how your post would look like when promoted to the main page or when exported for syndication. You can insert a delimiter '---' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."
";
+ print "". t("The trimmed version of your post shows how your post looks like when promoted to the main page or when exported for syndication. You can insert a delimiter '---' (without the quotes) to fine-tune where your post gets split. However note that delimiter will be ignored when misplaced.") ."
";
+ print "". t("Preview full version") ."
";
+ node_view($view, 0);
}
else {
node_view($view, 0);
--
cgit v1.2.3