Skip to content

Commit 9761ce8

Browse files
committed
Added Collaborative editor extension
1 parent 399b857 commit 9761ce8

File tree

161 files changed

+43007
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+43007
-0
lines changed

TogetherJS.hooks.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
class TogetherJSHooks {
4+
5+
// Add the togetherjs scripts to the page so we can do cool things
6+
static function getModules( $out, $skin ) {
7+
$out->addModules( array( 'ext.togetherjs' ) );
8+
9+
return true;
10+
}
11+
}

TogetherJS.i18n.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
$messages['en'] = array(
4+
'togetherjs-name' => 'TogetherJS',
5+
'togetherjs-start' => 'Start working together',
6+
'togetherjs-tab' => 'Collaborative Mode',
7+
'togetherjs-desc' => 'Add realtime collaboration to wiki editing.'
8+
);
9+
10+
$messages['qqq'] = array(
11+
'togetherjs-name' => 'The name of the collaboration tool as provided to users.',
12+
'togetherjs-start' => 'Text to show when hovering over the button to start the collaboration tool',
13+
'togetherjs-tab' => 'Name of the button in the tab which starts the collaboration tool',
14+
'togetherjs-desc' => 'Description of this extension',
15+
);

TogetherJS.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
$moduleInfo = array(
4+
'localBasePath' => __DIR__,
5+
'remoteExtPath' => 'TogetherJS',
6+
);
7+
8+
$wgExtensionMessagesFiles['TogetherJS'] = __DIR__ . '/TogetherJS.i18n.php';
9+
10+
$wgResourceModules['togetherjs'] = array_merge( array(
11+
'scripts' => array(
12+
'js/ext.togetherjs.config.js',
13+
'js/togetherjs.js',
14+
),
15+
'dependencies' => array(
16+
'mediawiki.user',
17+
),
18+
'messages' => array(
19+
'togetherjs-name',
20+
),
21+
), $moduleInfo );
22+
23+
$wgResourceModules['ext.togetherjs'] = array_merge( array(
24+
'scripts' => array(
25+
'js/ext.togetherjs.js',
26+
'js/ext.togetherjs.ve.js',
27+
),
28+
29+
'dependencies' => array(
30+
'togetherjs',
31+
),
32+
'messages' => array(
33+
'togetherjs-name',
34+
'togetherjs-start',
35+
'togetherjs-tab',
36+
),
37+
), $moduleInfo );
38+
39+
$wgAutoloadClasses['TogetherJSHooks'] = __DIR__ . '/TogetherJS.hooks.php';
40+
$wgHooks['BeforePageDisplay'][] = 'TogetherJSHooks::getModules';

js/ext.togetherjs.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
( function ( mw ) {
2+
"use strict";
3+
4+
/* TogetherJS configuration; loaded *before* TogetherJS loads. */
5+
window.TogetherJSConfig = {
6+
toolName: mw.msg( 'togetherjs-name' ),
7+
baseUrl: mw.config.get( 'wgServer' ) +
8+
mw.config.get( 'wgExtensionAssetsPath' ) +
9+
'/TogetherJS',
10+
hubBase: 'http://hub.togetherjs.com/',
11+
12+
useMinimizedCode: true,
13+
cacheBust: false,
14+
lang: (function(lang) {
15+
// re-map language codes to those supported by togetherJS
16+
if (/_/.test(lang || '')) {
17+
return lang.replace(/_/g, '-');
18+
}
19+
return lang || 'en-US';
20+
})(mw.config.get( 'wgUserLanguage' )),
21+
callToStart: function(callback) {
22+
// defer loading of TogetherJS until after mw loads.
23+
var hook = mw.hook( 'togetherjs.autostart' );
24+
var once = function() {
25+
hook.remove(once);
26+
callback();
27+
};
28+
hook.add( once );
29+
},
30+
getUserName: function() {
31+
if (mw.user.isAnon()) { return null; }
32+
return mw.user.getName();
33+
}
34+
};
35+
36+
}( mediaWiki ) );

js/ext.togetherjs.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
( function ( mw, $, TogetherJS ) {
2+
"use strict";
3+
4+
// add option to start togetherjs in a action tab
5+
var pTabsId = $( '#p-views' ).length ? 'p-views' : 'p-cactions';
6+
mw.util.addPortletLink( pTabsId, '#', mw.msg( 'togetherjs-tab' ),
7+
'ca-tjs-start', mw.msg( 'togetherjs-start' ) );
8+
$( '#ca-tjs-start' ).click( TogetherJS );
9+
10+
// add togetherjs to edit source toolbar
11+
if ( mw.toolbar ) {
12+
mw.toolbar.addButton({
13+
imageId: 'togetherjs-button',
14+
imageFile: TogetherJSConfig.baseUrl +
15+
'/togetherjs/images/notification-togetherjs-logo.png',
16+
speedTip: mw.msg( 'togetherjs-start' )
17+
});
18+
$( '#togetherjs-button' ).click( function( event ) {
19+
/* jshint newcap: false */
20+
TogetherJS(); // toggle togetherjs
21+
return false;
22+
} );
23+
}
24+
25+
}( mediaWiki, jQuery, TogetherJS ) );

0 commit comments

Comments
 (0)