Commit c10ce14d authored by Dries's avatar Dries

- 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.
parent d21ba6b0
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment