function onEndShowScripts($action)
{
$user = common_current_user();
- if ($user) {
- $action->script('plugins/LinkPreview/linkpreview.js');
+ if ($user && common_config('attachments', 'process_links')) {
+ if (common_config('site', 'minify')) {
+ $js = 'linkpreview.min.js';
+ } else {
+ $js = 'linkpreview.js';
+ }
+ $action->script($this->path($js));
+ $data = json_encode(array(
+ 'api' => common_local_url('oembedproxy'),
+ 'width' => common_config('attachments', 'thumbwidth'),
+ 'height' => common_config('attachments', 'thumbheight'),
+ ));
+ $action->inlineScript('$(function() {SN.Init.LinkPreview && SN.Init.LinkPreview('.$data.');})');
}
return true;
}
*/
function onAutoload($cls)
{
- switch ($cls)
+ $lower = strtolower($cls);
+ switch ($lower)
{
- case 'LinkpreviewAction':
- require_once dirname(__FILE__) . '/linkpreviewaction.php';
+ case 'oembedproxyaction':
+ require_once dirname(__FILE__) . '/' . $lower . '.php';
return false;
default:
return true;
*/
function onStartInitializeRouter($m)
{
- $m->connect('main/preview/link',
- array('action' => 'linkpreview'));
+ $m->connect('main/oembed/proxy',
+ array('action' => 'oembedproxy'));
return true;
}