Commit 4faa5f21 authored by Jack Phoenix's avatar Jack Phoenix

Allow turning the live recent changes feature off

parent 52577994
......@@ -385,9 +385,17 @@ class LibertyTemplate extends BaseTemplate {
* Live recent function, build right side's Recent menus.
*/
protected function liveRecent() {
global $wgLibertyEnableLiveRC;
$skin = $this->getSkin();
$wgLibertyMaxRecent = isset( $GLOBALS['wgLibertyMaxRecent'] ) ?
$GLOBALS['wgLibertyMaxRecent'] : 10;
// Don't bother outputting this if the live RC feature is disabled in
// site configuration
if ( !$wgLibertyEnableLiveRC ) {
return;
}
?>
<div class="live-recent">
<div class="live-recent-header">
......
......@@ -9,7 +9,8 @@ class SkinLiberty extends SkinTemplate {
* @param OutputPage $out OutputPage
*/
public function initPage( OutputPage $out ) {
global $wgSitename, $wgTwitterAccount, $wgLanguageCode, $wgNaverVerification, $wgLogo;
// @codingStandardsIgnoreLine
global $wgSitename, $wgTwitterAccount, $wgLanguageCode, $wgNaverVerification, $wgLogo, $wgLibertyEnableLiveRC;
$mainColor = isset( $GLOBALS['wgLibertyMainColor'] ) ? $GLOBALS['wgLibertyMainColor'] : '#4188F1';
$ogLogo = isset( $GLOBALS['wgLibertyOgLogo'] ) ? $GLOBALS['wgLibertyOgLogo'] : $wgLogo;
......@@ -75,6 +76,11 @@ class SkinLiberty extends SkinTemplate {
'skins.liberty.layoutjs'
];
// Only load LiveRC JS is we have enabled that feature in site config
if ( $wgLibertyEnableLiveRC ) {
$modules[] = 'skins.liberty.liverc';
}
// Only load modal login JS for anons, no point in loading it for logged-in
// users since the modal HTML isn't even rendered for them.
if ( $skin->getUser()->isAnon() ) {
......
......@@ -10,6 +10,7 @@
"liberty-btn-save-changes": "Save changes",
"liberty-desc": "Default skin of Libre Wiki.",
"liberty-facebook": "Facebook",
"liberty-feed-new": "[New]",
"liberty-forgot-pw": "Forgot your password?",
"liberty-login": "Login",
"liberty-login-btn": "Login",
......
......@@ -51,31 +51,34 @@ $( function () {
withCredentials: true
},
dataType: 'json'
} )
.then( function ( data ) {
var recentChanges, html, time, line, text;
recentChanges = data.query.recentchanges;
html = recentChanges.map( function ( item ) {
time = new Date( item.timestamp );
line = '<li><a class="recent-item" href = "' + ( mw.config.get( 'wgArticlePath' ) ).replace( '$1', encodeURIComponent( item.title ) ) + '" title="' + item.title + '">[' + timeFormat( time ) + '] ';
text = '';
if ( item.type === 'new' ) {
text += '[New]';
}
text += item.title;
if ( text.length > 13 ) {
text = text.substr( 0, 13 );
text += '...';
}
text = text.replace( '[New]', '<span class="new">[New] </span>' );
line += text;
line += '</a></li>';
return line;
} ).join( '\n' );
$( '#live-recent-list' ).html( html );
}, function () {
return;
} );
} ).then( function ( data ) {
var recentChanges, html, time, line, text;
recentChanges = data.query.recentchanges;
html = recentChanges.map( function ( item ) {
time = new Date( item.timestamp );
line = '<li><a class="recent-item" href = "' + ( mw.config.get( 'wgArticlePath' ) ).replace( '$1', encodeURIComponent( item.title ) ) + '" title="' + item.title + '">[' + timeFormat( time ) + '] ';
text = '';
if ( item.type === 'new' ) {
text += '[New]';
}
text += item.title;
if ( text.length > 13 ) {
text = text.substr( 0, 13 );
text += '...';
}
// @todo FIXME: This just doesn't work and I've no idea why.
// The i18n msg is properly defined etc. yet it shows up as <liberty-feed-new>
// when called by the below line :-(
// text = text.replace( '[New]', '<span class="new">' + mw.msg( 'liberty-feed-new' ) + ' </span>' );
text = text.replace( '[New]', '<span class="new">[New] </span>' );
line += text;
line += '</a></li>';
return line;
} ).join( '\n' );
$( '#live-recent-list' ).html( html );
}, function () {
return;
} );
}
$( '#liberty-recent-tab1' ).click( function () {
......
......@@ -18,6 +18,7 @@
]
},
"config": {
"LibertyEnableLiveRC": true,
"LibertyUseGravatar": true
},
"ResourceModules": {
......@@ -65,7 +66,6 @@
"skins.liberty.layoutjs": {
"scripts": [
"js/live-recent.js",
"js/index-button.js",
"js/delay-scrolling.js",
"js/disable-notice.js",
......@@ -75,6 +75,12 @@
"dependencies": "mediawiki.cookie",
"position": "bottom"
},
"skins.liberty.liverc": {
"scripts": "js/live-recent.js",
"messages": [ "liberty-feed-new" ],
"dependencies": "mediawiki.util",
"position": "bottom"
},
"skins.liberty.loginjs": {
"scripts": "js/login-request.js",
"dependencies": "mediawiki.util",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment