forked from leftypol/leftypol
Remove newlines and modifiers from thread title
Parts sampled from NPFchan
This commit is contained in:
parent
9c7239f2d4
commit
46d62584d0
|
@ -1914,6 +1914,10 @@ function unicodify($body) {
|
|||
return $body;
|
||||
}
|
||||
|
||||
function newline_to_full_stop($body) {
|
||||
return str_replace("\n", '. ', $body);
|
||||
}
|
||||
|
||||
function extract_modifiers($body) {
|
||||
$modifiers = array();
|
||||
|
||||
|
@ -1928,6 +1932,17 @@ function extract_modifiers($body) {
|
|||
return $modifiers;
|
||||
}
|
||||
|
||||
function remove_markup($body) {
|
||||
global $config;
|
||||
|
||||
foreach ($config['markup'] as $markup) {
|
||||
if (is_string($markup[1]))
|
||||
$body = preg_replace($markup[0], "$1", $body);
|
||||
}
|
||||
return $body;
|
||||
}
|
||||
|
||||
|
||||
function remove_modifiers($body) {
|
||||
return preg_replace('@<tinyboard ([\w\s]+)>(.+?)</tinyboard>@usm', '', $body);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
|
|||
new Twig_SimpleFilter('sprintf', 'sprintf'),
|
||||
new Twig_SimpleFilter('capcode', 'capcode'),
|
||||
new Twig_SimpleFilter('remove_modifiers', 'remove_modifiers'),
|
||||
new Twig_SimpleFilter('remove_markup', 'remove_markup'),
|
||||
new Twig_SimpleFilter('newline_to_full_stop', 'newline_to_full_stop'),
|
||||
new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'),
|
||||
new Twig_SimpleFilter('date', 'twig_date_filter'),
|
||||
new Twig_SimpleFilter('poster_id', 'poster_id'),
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
{% include 'header.html' %}
|
||||
|
||||
{% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup[:256]|remove_modifiers|e }}{% endif %}{% endset %}
|
||||
{% set meta_subject %}{% if config.thread_subject_in_title and thread.subject %}{{ thread.subject|e }}{% else %}{{ thread.body_nomarkup[:256]|remove_modifiers|newline_to_full_stop|remove_markup|e }}{% endif %}{% endset %}
|
||||
|
||||
<meta name="description" content="{{ board.url }} - {{ board.title|e }} - {{ meta_subject }}" />
|
||||
<meta name="twitter:card" value="summary">
|
||||
|
|
Loading…
Reference in New Issue
Block a user