possibility for other plugins to add streams and translations to qvitter

This commit is contained in:
Hannes Mannerheim 2015-10-19 18:47:24 +02:00
parent 5c00ecc52c
commit 76f579b84a
4 changed files with 44 additions and 2 deletions

View File

@ -212,7 +212,11 @@ class QvitterPlugin extends Plugin {
if ($this->hijack_ui === true) {
$m->connect('', array('action' => 'qvitter'));
// other plugins might want to reroute to qvitter
Event::handle('QvitterHijackUI', array($m));
$m->connect('', array('action' => 'qvitter'));
$m->connect('main/all', array('action' => 'qvitter'));
$m->connect('main/public', array('action' => 'qvitter'));
$m->connect('search/notice', array('action' => 'qvitter'));

View File

@ -494,7 +494,7 @@ class QvitterAction extends ApiAction
</div>
</div>
</div>
<div class="menu-container"><?php
<div id="main-menu" class="menu-container"><?php
if($logged_in_user) {
?><a href="<?php print $instanceurl.$logged_in_user->nickname ?>/all" class="stream-selection friends-timeline"><i class="chev-right"></i></a>

View File

@ -37,6 +37,9 @@
· ·
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
// plugins can add translatons to this object
window.pluginTranslations = [];
// object to keep old states of streams in, to speed up stream change
window.oldStreams = new Object();
@ -723,6 +726,19 @@ $(window).load(function() {
function proceedToSetLanguageAndLogin(data){
window.sL = data;
// plugins might have added translations
$.each(window.pluginTranslations,function(k,pluginTranslation) {
if(typeof pluginTranslation[window.selectedLanguage] != 'undefined') {
$.extend(window.sL,pluginTranslation[window.selectedLanguage]);
}
else if(typeof pluginTranslation['en'] != 'undefined') {
$.extend(window.sL,pluginTranslation['en']);
}
});
// plugins might want to wait and do stuff until after language is set
$(document).trigger('qvitterAfterLanguageIsSet');
// if this is a RTL-language, add rtl class to body
if(window.sL.directionality == 'rtl') {
$('body').addClass('rtl');

View File

@ -37,6 +37,16 @@
· ·
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
/* ·
·
· Other plugins can add streams to Qvitter, by pushing streamObjects to
· this array. See the structure in pathToStreamRouter()
·
· · · · · · · · · */
window.pluginStreamObjects = [];
/* ·
·
@ -347,6 +357,18 @@ function pathToStreamRouter(path) {
streamObject.stream = 'statusnet/groups/list.json?count=10&screen_name=' + streamObject.nickname + '&withuserarray=1';
return streamObject;
}
// other plugins can add streams to Qvitter
if(window.pluginStreamObjects.length > 0) {
$.each(window.pluginStreamObjects,function(k,pluginStreamObject) {
if(typeof pluginStreamObject.pathRegExp != 'undefined' && pluginStreamObject.pathRegExp.test(path)){
$.extend(streamObject,pluginStreamObject);
return false;
}
});
return streamObject;
}
}