Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

AutoLinks

edamedam New
edited October 2009 in Vanilla 1.0 Help
AutoLinks
«13

Comments

  • Uploaded version 1.0 of AutoLinks.
  • Uploaded version 1.1 of AutoLinks.
  • Getting AutoLinks to work with Markdown Formatter

    To get AutoLinks to work nicely with the Markdown Formatter, you need to also have the HTML Foramtter installed and you need to modify both the Markdown Formatter and the HTML Formatter. I will give full instructions below, but...

    If you just want a get it working, you can download an already-modified versions of the Markdown Formatter 1.1.2 and the HTML Formatter 2.4 from here and here.

    If you would rather make the modifications manually, here are the steps involved.

    First, you need to get the Markdown Formatter to honour it's child formatters and accept HTML (which it should, as per the Markdown spec., but doesn't by default). This can be done with the following patch:--- default.php.orig 2009-03-13 15:57:59.000000000 +0000 +++ default.php 2009-03-19 15:10:45.000000000 +0000 @@ -17,13 +17,21 @@ class MarkdownFormatter extends StringFormatter { function Parse($String, $Object, $FormatPurpose) { if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) { - $String = $this->ProtectString($String); - return Markdown($String); + $String = $this->ParseChildren($String, $Object, $FormatPurpose); + if( isset( $Object->Context->StringManipulator->Formatters[ "Html" ] ) ) { + $String = Markdown( $String ); + $String = $Object->Context->StringManipulator->Formatters[ "Html" ]->Execute( $String, true ); + } + else { + $String = $this->EscapeHtml( $String ); + $String = Markdown( $String ); + } + return $String; } else { return $String; } } - function ProtectString ($String) { + function EscapeHtml ($String) { //$String = str_replace("<", "<", $String); // $String = str_replace(">", ">", $String); $String = explode("\n", $String);
    Second, you need to modify the HTML Formatter to allow the Markdown formatter to use it's parsing abilities. The following patch will achieve this:--- default.php.orig 2009-03-19 13:02:20.000000000 +0000 +++ default.php 2009-03-19 13:04:46.000000000 +0000 @@ -111,7 +111,7 @@ $this->TagArray = &$GLOBALS['Html_TagArray']; } - function Execute($String) + function Execute($String, $ParseOnly) { $this->TagArray = array('normal' => array(), 'extraclosing' => array()); $String = str_replace(chr(0), ' ', $String); @@ -172,7 +172,7 @@ $sReturn ); - if(HTML_CONVERT_NEWLINES) + if(HTML_CONVERT_NEWLINES && !$ParseOnly) $sReturn = str_replace( array("\r\n", "\r", "\n"), '<br />', @@ -389,7 +389,7 @@ function Parse($String, $Object, $FormatPurpose) { - if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) $sReturn = $this->Execute($String); + if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) $sReturn = $this->Execute($String, false); else $sReturn = $String; return $this->ParseChildren($sReturn, $Object, $FormatPurpose);
    Finally, you need to allow the "embed" tag through the HTML Formatter (which is disallowed by default). To achieve this, you need to remove 'embed' from the list of disallowed tags on line 76 in HTML Formatter's default.php. The following patch will achieve this:--- default.php.orig 2009-03-19 13:02:20.000000000 +0000 +++ default.php 2009-03-19 13:45:16.000000000 +0000 @@ -73,7 +73,7 @@ //which tags should simply be removed (be warned, most of these are here because they are not safe //enough to allow/clean, remove at your own risk) -$Html_DisallowedTags = array('link', 'iframe', 'frame', 'frameset', 'object', 'param', 'embed', 'style', +$Html_DisallowedTags = array('link', 'iframe', 'frame', 'frameset', 'object', 'param', 'style', 'applet', 'meta', 'layer', 'import', 'xml', 'script', 'body', 'html', 'head', 'title', 'ilayer'); //don't parse anything in these tags
    Any problems with these instructions, just let me know!
  • you might not have noticed this: http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=434 It can support anything you want and works on the server, client side or both.

    grep is your friend.

  • good job. but I need support for Attachments 2.1 (image or mpeg or flv..). please??
  • This seems to be PHP5 only because of the use of stripos() so i added a bit of code before the start of the class so that it becomes php4 and php5 compatible. if (!function_exists('stripos')) { function stripos($haystack, $needle){ return strpos($haystack, stristr( $haystack, $needle )); } }
  • does it support metacafe.com video?
  • i found that it doesn't support metacafe
  • Uploaded version 1.2 of AutoLinks.
  • version 1.2:
    • added support for metacafe
    • fixed compatibility with PHP4 (thanks garethablett!)
    @kelvin: you say you "need support for Attachments 2.1", what do you mean exactly? If you want mpg/flv attachments to display in-line, I think you should ask in the Inline Images 1.3 extension, or the Attachments 2.1 extension. The AutoLinks extension is only really for turning links in to embedded content.
  • thanks for the metacafe.
  • this is just superb plugin!! i appreciate!
    could you please tell me how to add url w/ mp3 player. i'd like to provide listening inside the topic but file's address as well.
  • RaizeRaize ✭✭
    This is one of the greatest Vanilla plugins ever invented. Thank you Edam!

    The other greatest Vanilla plugin never invented is BlogThis by Spode...now if only they could work together we could blow this joint.
  • Forgive my stupid question but what do you mean by AutoLinks?

    This is extension is HOT! Thank you.
  • Uploaded version 1.3 of AutoLinks.
  • version 1.3:
    • force creation of a link rather than embedding by prefixing the URL with a '!'
    • added support for tangle.com
    @Bentot: I thought "AutoLinks" sounds like it'll automatically create links. This doesn't really explain the embedding though... :o)

    Can anyone think of any obvious video sites that aren't supported?
  • I guess it means image and YouTube links will automatically display :)
    I love this extension. I wish someone will find a way to create one like Google video/audio chat
  • Now I will make you responsible to rewrite it for Vanila2. :)
  • Raize, you mentioned using AutoLinks and BlogThis. I'm using both of those addons, too, but AutoLinks doesn't seem to do anything for BlogThis. Example: rewild.info. Has anybody gotten these two to work together? Any ideas on how I might accomplish that? I'm not adverse to modifying some source code if need be, but any insight you can offer is much appreciated.
  • Hmm, these two extension *should* work together. I'll look in to why they aren't...
Sign In or Register to comment.