49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
if (!defined('GNUSOCIAL')) {
|
|
exit(1);
|
|
}
|
|
|
|
class GSGreenTextPlugin extends Plugin
|
|
{
|
|
const VERSION = '0.0.1';
|
|
|
|
const LINE_SEP = "/\s*<br\s*?\/?>\s*/";
|
|
|
|
public function onEndShowStyles(Action $action)
|
|
{
|
|
$action->style(".greentext { color: green; }");
|
|
}
|
|
|
|
public function onQvitterEndShowHeadElements(Action $action)
|
|
{
|
|
$this->onEndShowStyles($action);
|
|
}
|
|
|
|
function onStartNoticeSave(&$notice)
|
|
{
|
|
$sepnotice = preg_split(self::LINE_SEP, $notice->rendered, -1);
|
|
|
|
foreach($sepnotice as &$sep)
|
|
{
|
|
if(0 === strpos($sep, '>'))
|
|
{
|
|
$sep = "<span class='greentext'>" . $sep . "</span>";
|
|
}
|
|
}
|
|
|
|
$notice->rendered = implode("<br />" . PHP_EOL, $sepnotice);
|
|
}
|
|
|
|
function onPluginVersion(array &$versions)
|
|
{
|
|
$versions[] = array('name' => 'GreenText',
|
|
'version' => self::VERSION,
|
|
'author' => 'MoonMan',
|
|
'homepage' => 'https://gitgud.io/ShitposterClub/GSGreenText/',
|
|
'description' =>
|
|
_m('Starting line with ">" makes line green.'));
|
|
return true;
|
|
}
|
|
}
|