mirror of
https://github.com/flarum/core.git
synced 2025-08-05 16:07:34 +02:00
Update for composer branch
This commit is contained in:
3
extensions/pusher/js/.gitignore
vendored
3
extensions/pusher/js/.gitignore
vendored
@@ -1,3 +0,0 @@
|
||||
bower_components
|
||||
node_modules
|
||||
dist
|
@@ -2,6 +2,6 @@ var gulp = require('flarum-gulp');
|
||||
|
||||
gulp({
|
||||
modules: {
|
||||
'pusher': 'src/**/*.js'
|
||||
'flarum/pusher': 'src/**/*.js'
|
||||
}
|
||||
});
|
||||
|
88
extensions/pusher/js/admin/dist/extension.js
vendored
Normal file
88
extensions/pusher/js/admin/dist/extension.js
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
System.register('flarum/pusher/main', ['flarum/extend', 'flarum/app', 'flarum/pusher/components/PusherSettingsModal'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var extend, app, PusherSettingsModal;
|
||||
return {
|
||||
setters: [function (_flarumExtend) {
|
||||
extend = _flarumExtend.extend;
|
||||
}, function (_flarumApp) {
|
||||
app = _flarumApp['default'];
|
||||
}, function (_flarumPusherComponentsPusherSettingsModal) {
|
||||
PusherSettingsModal = _flarumPusherComponentsPusherSettingsModal['default'];
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
app.initializers.add('flarum-pusher', function (app) {
|
||||
app.extensionSettings['flarum-pusher'] = function () {
|
||||
return app.modal.show(new PusherSettingsModal());
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
});;System.register('flarum/pusher/components/PusherSettingsModal', ['flarum/components/SettingsModal'], function (_export) {
|
||||
'use strict';
|
||||
|
||||
var SettingsModal, PusherSettingsModal;
|
||||
return {
|
||||
setters: [function (_flarumComponentsSettingsModal) {
|
||||
SettingsModal = _flarumComponentsSettingsModal['default'];
|
||||
}],
|
||||
execute: function () {
|
||||
PusherSettingsModal = (function (_SettingsModal) {
|
||||
babelHelpers.inherits(PusherSettingsModal, _SettingsModal);
|
||||
|
||||
function PusherSettingsModal() {
|
||||
babelHelpers.classCallCheck(this, PusherSettingsModal);
|
||||
babelHelpers.get(Object.getPrototypeOf(PusherSettingsModal.prototype), 'constructor', this).apply(this, arguments);
|
||||
}
|
||||
|
||||
babelHelpers.createClass(PusherSettingsModal, [{
|
||||
key: 'className',
|
||||
value: function className() {
|
||||
return 'PusherSettingsModal Modal--small';
|
||||
}
|
||||
}, {
|
||||
key: 'title',
|
||||
value: function title() {
|
||||
return 'Pusher Settings';
|
||||
}
|
||||
}, {
|
||||
key: 'form',
|
||||
value: function form() {
|
||||
return [m(
|
||||
'div',
|
||||
{ className: 'Form-group' },
|
||||
m(
|
||||
'label',
|
||||
null,
|
||||
'App ID'
|
||||
),
|
||||
m('input', { className: 'FormControl', bidi: this.setting('flarum-pusher.app_id') })
|
||||
), m(
|
||||
'div',
|
||||
{ className: 'Form-group' },
|
||||
m(
|
||||
'label',
|
||||
null,
|
||||
'App Key'
|
||||
),
|
||||
m('input', { className: 'FormControl', bidi: this.setting('flarum-pusher.app_key') })
|
||||
), m(
|
||||
'div',
|
||||
{ className: 'Form-group' },
|
||||
m(
|
||||
'label',
|
||||
null,
|
||||
'App Secret'
|
||||
),
|
||||
m('input', { className: 'FormControl', bidi: this.setting('flarum-pusher.app_secret') })
|
||||
)];
|
||||
}
|
||||
}]);
|
||||
return PusherSettingsModal;
|
||||
})(SettingsModal);
|
||||
|
||||
_export('default', PusherSettingsModal);
|
||||
}
|
||||
};
|
||||
});
|
@@ -13,17 +13,17 @@ export default class PusherSettingsModal extends SettingsModal {
|
||||
return [
|
||||
<div className="Form-group">
|
||||
<label>App ID</label>
|
||||
<input className="FormControl" bidi={this.setting('pusher.app_id')}/>
|
||||
<input className="FormControl" bidi={this.setting('flarum-pusher.app_id')}/>
|
||||
</div>,
|
||||
|
||||
<div className="Form-group">
|
||||
<label>App Key</label>
|
||||
<input className="FormControl" bidi={this.setting('pusher.app_key')}/>
|
||||
<input className="FormControl" bidi={this.setting('flarum-pusher.app_key')}/>
|
||||
</div>,
|
||||
|
||||
<div className="Form-group">
|
||||
<label>App Secret</label>
|
||||
<input className="FormControl" bidi={this.setting('pusher.app_secret')}/>
|
||||
<input className="FormControl" bidi={this.setting('flarum-pusher.app_secret')}/>
|
||||
</div>
|
||||
];
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { extend } from 'flarum/extend';
|
||||
import app from 'flarum/app';
|
||||
|
||||
import PusherSettingsModal from 'pusher/components/PusherSettingsModal';
|
||||
import PusherSettingsModal from 'flarum/pusher/components/PusherSettingsModal';
|
||||
|
||||
app.initializers.add('pusher', app => {
|
||||
app.extensionSettings.pusher = () => app.modal.show(new PusherSettingsModal());
|
||||
app.initializers.add('flarum-pusher', app => {
|
||||
app.extensionSettings['flarum-pusher'] = () => app.modal.show(new PusherSettingsModal());
|
||||
});
|
||||
|
@@ -2,6 +2,6 @@ var gulp = require('flarum-gulp');
|
||||
|
||||
gulp({
|
||||
modules: {
|
||||
'pusher': 'src/**/*.js'
|
||||
'flarum/pusher': 'src/**/*.js'
|
||||
}
|
||||
});
|
||||
|
177
extensions/pusher/js/forum/dist/extension.js
vendored
Normal file
177
extensions/pusher/js/forum/dist/extension.js
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
System.register('flarum/pusher/main', ['flarum/extend', 'flarum/app', 'flarum/components/DiscussionList', 'flarum/components/DiscussionPage', 'flarum/components/IndexPage', 'flarum/components/Button'], function (_export) {
|
||||
/*global Pusher*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var extend, app, DiscussionList, DiscussionPage, IndexPage, Button;
|
||||
return {
|
||||
setters: [function (_flarumExtend) {
|
||||
extend = _flarumExtend.extend;
|
||||
}, function (_flarumApp) {
|
||||
app = _flarumApp['default'];
|
||||
}, function (_flarumComponentsDiscussionList) {
|
||||
DiscussionList = _flarumComponentsDiscussionList['default'];
|
||||
}, function (_flarumComponentsDiscussionPage) {
|
||||
DiscussionPage = _flarumComponentsDiscussionPage['default'];
|
||||
}, function (_flarumComponentsIndexPage) {
|
||||
IndexPage = _flarumComponentsIndexPage['default'];
|
||||
}, function (_flarumComponentsButton) {
|
||||
Button = _flarumComponentsButton['default'];
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
app.initializers.add('flarum-pusher', function () {
|
||||
var loadPusher = m.deferred();
|
||||
|
||||
$.getScript('//js.pusher.com/3.0/pusher.min.js', function () {
|
||||
var socket = new Pusher(app.forum.attribute('pusherKey'), {
|
||||
authEndpoint: app.forum.attribute('apiUrl') + '/pusher/auth',
|
||||
auth: {
|
||||
headers: {
|
||||
'Authorization': 'Token ' + app.session.token
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
loadPusher.resolve({
|
||||
main: socket.subscribe('public'),
|
||||
user: app.session.user ? socket.subscribe('private-user' + app.session.user.id()) : null
|
||||
});
|
||||
});
|
||||
|
||||
app.pusher = loadPusher.promise;
|
||||
app.pushedUpdates = [];
|
||||
|
||||
extend(DiscussionList.prototype, 'config', function (x, isInitialized, context) {
|
||||
var _this = this;
|
||||
|
||||
if (isInitialized) return;
|
||||
|
||||
app.pusher.then(function (channels) {
|
||||
channels.main.bind('newPost', function (data) {
|
||||
var params = _this.props.params;
|
||||
|
||||
if (!params.q && !params.sort && !params.filter) {
|
||||
if (params.tags) {
|
||||
var tag = app.store.getBy('tags', 'slug', params.tags);
|
||||
|
||||
if (data.tagIds.indexOf(tag.id()) === -1) return;
|
||||
}
|
||||
|
||||
var id = String(data.discussionId);
|
||||
|
||||
if ((!app.current.discussion || id !== app.current.discussion.id()) && app.pushedUpdates.indexOf(id) === -1) {
|
||||
app.pushedUpdates.push(id);
|
||||
|
||||
if (app.current instanceof IndexPage) {
|
||||
app.setTitleCount(app.pushedUpdates.length);
|
||||
}
|
||||
|
||||
m.redraw();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
extend(context, 'onunload', function () {
|
||||
return channels.main.unbind();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
extend(DiscussionList.prototype, 'view', function (vdom) {
|
||||
var _this2 = this;
|
||||
|
||||
if (app.pushedUpdates) {
|
||||
var count = app.pushedUpdates.length;
|
||||
|
||||
if (count) {
|
||||
vdom.children.unshift(Button.component({
|
||||
className: 'Button Button--block DiscussionList-update',
|
||||
onclick: function onclick() {
|
||||
_this2.refresh(false).then(function () {
|
||||
_this2.loadingUpdated = false;
|
||||
app.pushedUpdates = [];
|
||||
app.setTitleCount(0);
|
||||
m.redraw();
|
||||
});
|
||||
_this2.loadingUpdated = true;
|
||||
},
|
||||
loading: this.loadingUpdated,
|
||||
children: app.trans('pusher.show_updated_discussions', { count: count })
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent any newly-created discussions from triggering the discussion list
|
||||
// update button showing.
|
||||
// TODO: Might be better pause the response to the push updates while the
|
||||
// composer is loading? idk
|
||||
extend(DiscussionList.prototype, 'addDiscussion', function (returned, discussion) {
|
||||
var index = app.pushedUpdates.indexOf(discussion.id());
|
||||
|
||||
if (index !== -1) {
|
||||
app.pushedUpdates.splice(index, 1);
|
||||
}
|
||||
|
||||
if (app.current instanceof IndexPage) {
|
||||
app.setTitleCount(app.pushedUpdates.length);
|
||||
}
|
||||
|
||||
m.redraw();
|
||||
});
|
||||
|
||||
extend(DiscussionPage.prototype, 'config', function (x, isInitialized, context) {
|
||||
var _this3 = this;
|
||||
|
||||
if (isInitialized) return;
|
||||
|
||||
app.pusher.then(function (channels) {
|
||||
channels.main.bind('newPost', function (data) {
|
||||
var id = String(data.discussionId);
|
||||
|
||||
if (_this3.discussion && _this3.discussion.id() === id && _this3.stream) {
|
||||
(function () {
|
||||
var oldCount = _this3.discussion.commentsCount();
|
||||
|
||||
app.store.find('discussions', _this3.discussion.id()).then(function () {
|
||||
_this3.stream.update();
|
||||
|
||||
if (!document.hasFocus()) {
|
||||
app.setTitleCount(Math.max(0, _this3.discussion.commentsCount() - oldCount));
|
||||
|
||||
$(window).one('focus', function () {
|
||||
return app.setTitleCount(0);
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
}
|
||||
});
|
||||
|
||||
extend(context, 'onunload', function () {
|
||||
return channels.main.unbind();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
extend(IndexPage.prototype, 'actionItems', function (items) {
|
||||
delete items.refresh;
|
||||
});
|
||||
|
||||
app.pusher.then(function (channels) {
|
||||
if (channels.user) {
|
||||
channels.user.bind('notification', function () {
|
||||
app.session.user.pushAttributes({
|
||||
unreadNotificationsCount: app.session.user.unreadNotificationsCount() + 1,
|
||||
newNotificationsCount: app.session.user.newNotificationsCount() + 1
|
||||
});
|
||||
delete app.cache.notifications;
|
||||
m.redraw();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
@@ -7,7 +7,7 @@ import DiscussionPage from 'flarum/components/DiscussionPage';
|
||||
import IndexPage from 'flarum/components/IndexPage';
|
||||
import Button from 'flarum/components/Button';
|
||||
|
||||
app.initializers.add('pusher', () => {
|
||||
app.initializers.add('flarum-pusher', () => {
|
||||
const loadPusher = m.deferred();
|
||||
|
||||
$.getScript('//js.pusher.com/3.0/pusher.min.js', () => {
|
||||
|
Reference in New Issue
Block a user