1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class LinkPreviewPlugin extends Plugin
- {
- const PLUGIN_VERSION = '2.0.0';
- public function onPluginVersion(array &$versions): bool
- {
- $versions[] = array('name' => 'LinkPreview',
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Brion Vibber',
- 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/LinkPreview',
- 'rawdescription' =>
-
- _m('UI extension for previewing thumbnails from links.'));
- return true;
- }
-
- function onEndShowScripts($action)
- {
- $user = common_current_user();
- if ($user && common_config('attachments', 'process_links')) {
- $action->script($this->path('js/linkpreview.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;
- }
-
- public function onStartInitializeRouter(URLMapper $m)
- {
- $m->connect('main/oembed/proxy',
- array('action' => 'oembedproxy'));
- return true;
- }
- }
|