2016-04-02 06:05:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!defined('GNUSOCIAL')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2016-04-02 06:15:52 +00:00
|
|
|
class GSGreenTextPlugin extends Plugin
|
2016-04-02 06:05:03 +00:00
|
|
|
{
|
|
|
|
const VERSION = '0.0.1';
|
|
|
|
|
|
|
|
public function onEndShowStyles(Action $action)
|
|
|
|
{
|
|
|
|
$action->style(".greentext { color: green; }");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function onQvitterEndShowHeadElements(Action $action)
|
|
|
|
{
|
|
|
|
$this->onEndShowStyles($action);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onStartNoticeSave(&$notice)
|
|
|
|
{
|
|
|
|
$sepnotice = preg_split("/<br\s*?\/?>\r?\n*/", $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',
|
2016-04-02 06:18:00 +00:00
|
|
|
'homepage' => 'https://gitgud.io/ShitposterClub/GSGreenText/',
|
2016-04-02 06:05:03 +00:00
|
|
|
'description' =>
|
|
|
|
_m('Starting line with ">" makes line green.'));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|