diff options
author | Dries Buytaert <dries@buytaert.net> | 2002-12-21 18:53:39 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2002-12-21 18:53:39 +0000 |
commit | c10ce14d1e8b8b5200c61801bf7f7565199aa18c (patch) | |
tree | a6417d878878792f9717ca0ead164ba6ba95a1cc /modules | |
parent | d21ba6b0f17fc56c91fabb49ed1c8286d31ac5e7 (diff) | |
download | brdo-c10ce14d1e8b8b5200c61801bf7f7565199aa18c.tar.gz brdo-c10ce14d1e8b8b5200c61801bf7f7565199aa18c.tar.bz2 |
- 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.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/node.module | 46 | ||||
-rw-r--r-- | modules/node/node.module | 46 |
2 files changed, 30 insertions, 62 deletions
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, "<br />", $size)) { - return substr($body, 0, $length + 6); + return substr($body, 0, $length); } if ($length = strpos($body, "<br>", $size)) { - return substr($body, 0, $length + 4); + return substr($body, 0, $length); } if ($length = strpos($body, "</p>", $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 "<h3>". t("Preview full version") ."</h3>"; - node_view($view, 0); print "<h3>". t("Preview trimmed version") ."</h3>"; node_view($view, 1); - print "<p><i>". 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.") ."</i></p>"; + print "<p><i>". 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.") ."</i></p>"; + print "<h3>". t("Preview full version") ."</h3>"; + node_view($view, 0); } else { node_view($view, 0); diff --git a/modules/node/node.module b/modules/node/node.module index 1d5709a57..a98521c5a 100644 --- a/modules/node/node.module +++ b/modules/node/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, "<br />", $size)) { - return substr($body, 0, $length + 6); + return substr($body, 0, $length); } if ($length = strpos($body, "<br>", $size)) { - return substr($body, 0, $length + 4); + return substr($body, 0, $length); } if ($length = strpos($body, "</p>", $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 "<h3>". t("Preview full version") ."</h3>"; - node_view($view, 0); print "<h3>". t("Preview trimmed version") ."</h3>"; node_view($view, 1); - print "<p><i>". 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.") ."</i></p>"; + print "<p><i>". 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.") ."</i></p>"; + print "<h3>". t("Preview full version") ."</h3>"; + node_view($view, 0); } else { node_view($view, 0); |