Preparing plugins for no-minify-in-core-policy

also making the file structure better with js and css folders for Realtime and LinkPreview
This commit is contained in:
Mikael Nordfeldth 2014-02-24 00:59:29 +01:00
parent 398491b39b
commit 97830b0701
17 changed files with 12 additions and 31 deletions

View File

@ -27,12 +27,10 @@
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) {
exit(1);
}
require_once INSTALLDIR.'/plugins/Realtime/RealtimePlugin.php';
/**
* Plugin to do realtime updates using Comet
*
@ -64,10 +62,10 @@ class CometPlugin extends RealtimePlugin
{
$scripts = parent::_getScripts();
$ours = array('jquery.comet.js', 'cometupdate.js');
$ours = array('js/jquery.comet.js', 'js/cometupdate.js');
foreach ($ours as $script) {
$scripts[] = 'plugins/Comet/'.$script;
$scripts[] = $this->path($script);
}
return $scripts;
@ -81,7 +79,7 @@ class CometPlugin extends RealtimePlugin
function _connect()
{
require_once INSTALLDIR.'/plugins/Comet/bayeux.class.inc.php';
require_once INSTALLDIR.'/plugins/Comet/extlib/Bayeux/Bayeux.class.php';
// Bayeux? Comet? Huh? These terms confuse me
$this->bay = new Bayeux($this->server, $this->user, $this->password);
}

View File

@ -52,12 +52,7 @@ class LinkPreviewPlugin extends Plugin
{
$user = common_current_user();
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));
$action->script($this->path('js/linkpreview.js'));
$data = json_encode(array(
'api' => common_local_url('oembedproxy'),
'width' => common_config('attachments', 'thumbwidth'),

View File

@ -1 +0,0 @@
(function(){var b={api:"https://noembed.com/embed",width:100,height:75,cache:{},callbacks:{},lookup:function(d,e){if(typeof b.cache[d]=="object"){e(b.cache[d])}else{if(typeof b.callbacks[d]=="undefined"){b.callbacks[d]=[e];b.rawLookup(d,function(h){b.cache[d]=h;var g=b.callbacks[d];b.callbacks[d]=undefined;for(var f=0;f<g.length;f++){g[f](h)}})}else{b.callbacks[d].push(e)}}},rawLookup:function(d,f){var e={url:d,format:"json",maxwidth:b.width,maxheight:b.height,token:$("#token").val()};$.ajax({url:b.api,data:e,dataType:"json",success:function(g,h){f(g)},error:function(h,i,g){f(null)}})}};SN.Init.LinkPreview=function(d){if(d.api){b.api=d.api}if(d.width){b.width=d.width}if(d.height){b.height=d.height}};var c=SN.U.Counter;SN.U.Counter=function(d){var e=d.data("LinkPreview");if(e){e.previewLinks(d.find(".notice_data-text:first").val())}return c(d)};var a=SN.Init.NoticeFormSetup;SN.Init.NoticeFormSetup=function(d){a(d);d.bind("reset",function(){e.clear()});var e={links:[],state:[],refresh:[],findLinks:function(i){var g=/(?:^| )(https?:\/\/.+?\/.+?)(?= |$)/mg;var f=[];var h;while((h=g.exec(i))!==null){f.push(h[1])}return f},ensureArea:function(){if(d.find(".link-preview").length<1){d.append('<div class="notice-status link-preview thumbnails"></div>')}},prepLinkPreview:function(g){var h="link-preview-"+g;var f=e.links[g];e.refresh[g]=false;e.markLoading(g);b.lookup(f,function(l){var i=null;var j=100;if(l&&typeof l.thumbnail_url=="string"){i=l.thumbnail_url;if(typeof l.thumbnail_width!=="undefined"){if(l.thumbnail_width<j){j=l.thumbnail_width}}}else{if(l&&l.type=="photo"&&typeof l.url=="string"){i=l.url;if(typeof l.width!=="undefined"){if(l.width<j){j=l.width}}}}if(i){e.ensureArea();var k=$('<span class="inline-attachment"><a><img/></a></span>');k.find("a").attr("href",f).attr("target","_blank").last().find("img").attr("src",i).attr("width",j).attr("title",l.title||l.url||f);d.find("."+h).empty().append(k)}else{e.clearLink(g)}if(e.refresh[g]){e.prepLinkPreview(g)}else{e.markDone(g)}})},previewLinks:function(j){var h;var f=e.links;var g=e.findLinks(j);e.links=g;for(h=0;h<f.length&&h<g.length;h++){if(g[h]!=f[h]){if(e.state[h]=="loading"){e.refresh[h]=true}else{e.prepLinkPreview(h)}}}if(g.length>f.length){for(h=f.length;h<g.length;h++){e.addPreviewArea(h);e.prepLinkPreview(h)}}else{if(f.length>g.length){for(h=g.length;h<f.length;h++){e.clearLink(h)}}}if(g.length==0){e.clear()}},addPreviewArea:function(f){e.ensureArea();var g="link-preview-"+f;if(d.find("."+g).length<1){d.find(".link-preview").append('<span class="'+g+'"></span>')}},clearLink:function(f){var g="link-preview-"+f;d.find("."+g).html("")},markLoading:function(f){e.state[f]="loading";var g="link-preview-"+f;d.find("."+g).attr("style","opacity: 0.5")},markDone:function(f){e.state[f]="done";var g="link-preview-"+f;d.find("."+g).removeAttr("style")},clear:function(){e.links=[];d.find(".link-preview").remove()}};d.data("LinkPreview",e)}})();

View File

@ -27,12 +27,10 @@
* @link http://status.net/
*/
if (!defined('STATUSNET') && !defined('LACONICA')) {
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) {
exit(1);
}
require_once INSTALLDIR.'/plugins/Realtime/RealtimePlugin.php';
/**
* Plugin to do realtime updates using Meteor
*
@ -96,7 +94,7 @@ class MeteorPlugin extends RealtimePlugin
} else {
$scripts[] = 'http://'.$this->webserver.(($this->webport == 80) ? '':':'.$this->webport).'/meteor.js';
}
$scripts[] = $this->path('meteorupdater.min.js');
$scripts[] = $this->path('js/meteorupdater.js');
return $scripts;
}

View File

@ -1 +0,0 @@
var MeteorUpdater=function(){return{init:function(c,a,b){Meteor.callbacks.process=function(d){RealtimeUpdate.receive(JSON.parse(d))};Meteor.host=c;Meteor.port=a;Meteor.joinChannel(b,0);Meteor.connect()}}}();

View File

@ -27,12 +27,10 @@
* @link http://laconi.ca/
*/
if (!defined('LACONICA')) {
if (!defined('GNUSOCIAL') && !defined('STATUSNET')) {
exit(1);
}
require_once INSTALLDIR.'/plugins/Realtime/RealtimePlugin.php';
/**
* Plugin to do realtime updates using Orbited + STOMP
*
@ -76,9 +74,9 @@ class OrbitedPlugin extends RealtimePlugin
$root = 'http://'.$server.(($port == 80) ? '':':'.$port);
$scripts[] = $root.'/static/Orbited.js';
$scripts[] = 'plugins/Orbited/orbitedextra.js';
$scripts[] = $this->path('js/orbitedextra.js');
$scripts[] = $root.'/static/protocols/stomp/stomp.js';
$scripts[] = 'plugins/Orbited/orbitedupdater.js';
$scripts[] = $this->path('js/orbitedupdater.js');
return $scripts;
}

View File

@ -142,7 +142,7 @@ class RealtimePlugin extends Plugin
public function onEndShowStylesheets(Action $action)
{
$action->cssLink(Plugin::staticPath('Realtime', 'realtimeupdate.css'),
$action->cssLink($this->path('css/realtimeupdate.css'),
null,
'screen, projection, tv');
return true;
@ -391,12 +391,7 @@ class RealtimePlugin extends Plugin
function _getScripts()
{
if (common_config('site', 'minify')) {
$js = 'realtimeupdate.min.js';
} else {
$js = 'realtimeupdate.js';
}
return array(Plugin::staticPath('Realtime', $js));
return array($this->path('js/realtimeupdate.js'));
}
/**

File diff suppressed because one or more lines are too long