Is there a plugin for formatting diaspora articles?

Hi!

It seems that diaspora is formatting their messages in a special way:

For example:
"... die sie kriegen können ([siehe auch](https://blog.fefe.de/?ts=b595b908)), aber jetzt mit dem ..."

That means that the description of a link is between [ and ] and the url is between ( and ) where some characters are escaped (for example "_").

Is there a plugin that can decode these postings so that they are looking good?

Thanks!

Michael

Comments

  • I'd look at the friendika code that allows diaspora posts to render correctly in friendika, since friendika is php. I know that friendika has function in its wordpress plugin, for instance, to render the bbcode into html for WP, and, I believe it has similar code somewhere to render the diaspora posts correctly in friendika. see project.friendika.com for more info

    I could write a php script that does this, myself, I believe (basically, it's just regex replacements), but I'm not yet knowledgeable enough to know how precisely to plug that in to statusnet so that SN recognizes an incoming diaspora post and acts accordingly.
  • I wrote a small plugin for this purpose:

    <?php<br />if (!defined('LACONICA')) {
    exit(1);
    }

    class DiasporaPlugin extends Plugin
    {
    function __construct()
    {
    parent::__construct();
    }

    function onStartShowNoticeItem($notice)
    {
    $content = $notice->notice->rendered;

    if (((strpos(" ".$content, "http") OR strpos(" ".$content, "#")) and !strpos($content, "href")) or (strpos($notice->notice->content, "
    $content = str_replace(array("\n#"), array(" #"), "\n".$notice->notice->content);
    $rendered = Markdown($content);
    if (substr($rendered, 0, 3) == "

    ")
    $rendered = substr($rendered, 3, -5);

    $rendered = trim(preg_replace("@(\s|:|>)(http|https)://(.*?)(\s|<|:)@", '$1<a href="$2://$3">$2://$3$4', " ".$rendered." "));

    $rendered = preg_replace('/(^|\&quot\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/ue', "'\\1#'.common_tag_link('\\2')", $rendered);
    $notice->notice->rendered = $rendered;
    //print_r($notice->notice);
    }
    return true;
    }
    }

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID