mirror of
https://github.com/flarum/core.git
synced 2025-08-02 14:37:49 +02:00
Update for beta 6, fix some errors
This commit is contained in:
34
extensions/embed/js/forum/dist/extension.js
vendored
34
extensions/embed/js/forum/dist/extension.js
vendored
@@ -10,15 +10,15 @@
|
|||||||
//# sourceMappingURL=iframeResizer.contentWindow.map;
|
//# sourceMappingURL=iframeResizer.contentWindow.map;
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
System.register('flarum/embed/components/DiscussionPage', ['flarum/components/DiscussionPage', 'flarum/components/PostStream', 'flarum/helpers/listItems'], function (_export, _context) {
|
System.register('flarum/embed/components/DiscussionPage', ['flarum/components/DiscussionPage', 'flarum/components/LoadingIndicator', 'flarum/helpers/listItems'], function (_export, _context) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var BaseDiscussionPage, PostStream, listItems, DiscussionPage;
|
var BaseDiscussionPage, LoadingIndicator, listItems, DiscussionPage;
|
||||||
return {
|
return {
|
||||||
setters: [function (_flarumComponentsDiscussionPage) {
|
setters: [function (_flarumComponentsDiscussionPage) {
|
||||||
BaseDiscussionPage = _flarumComponentsDiscussionPage.default;
|
BaseDiscussionPage = _flarumComponentsDiscussionPage.default;
|
||||||
}, function (_flarumComponentsPostStream) {
|
}, function (_flarumComponentsLoadingIndicator) {
|
||||||
PostStream = _flarumComponentsPostStream.default;
|
LoadingIndicator = _flarumComponentsLoadingIndicator.default;
|
||||||
}, function (_flarumHelpersListItems) {
|
}, function (_flarumHelpersListItems) {
|
||||||
listItems = _flarumHelpersListItems.default;
|
listItems = _flarumHelpersListItems.default;
|
||||||
}],
|
}],
|
||||||
@@ -50,7 +50,7 @@ System.register('flarum/embed/components/DiscussionPage', ['flarum/components/Di
|
|||||||
m(
|
m(
|
||||||
'div',
|
'div',
|
||||||
{ className: 'DiscussionPage-discussion' },
|
{ className: 'DiscussionPage-discussion' },
|
||||||
m(
|
this.discussion ? [m(
|
||||||
'nav',
|
'nav',
|
||||||
{ className: 'DiscussionPage-nav--embed' },
|
{ className: 'DiscussionPage-nav--embed' },
|
||||||
m(
|
m(
|
||||||
@@ -58,12 +58,11 @@ System.register('flarum/embed/components/DiscussionPage', ['flarum/components/Di
|
|||||||
null,
|
null,
|
||||||
listItems(this.sidebarItems().toArray())
|
listItems(this.sidebarItems().toArray())
|
||||||
)
|
)
|
||||||
),
|
), m(
|
||||||
m(
|
|
||||||
'div',
|
'div',
|
||||||
{ className: 'DiscussionPage-stream' },
|
{ className: 'DiscussionPage-stream' },
|
||||||
this.stream ? this.stream.render() : ''
|
this.stream.render()
|
||||||
)
|
)] : m(LoadingIndicator, { className: 'LoadingIndicator--block' })
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -104,10 +103,10 @@ System.register('flarum/embed/components/DiscussionPage', ['flarum/components/Di
|
|||||||
});;
|
});;
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
System.register('flarum/embed/main', ['flarum/extend', 'flarum/app', 'flarum/components/Composer', 'flarum/components/PostStream', 'flarum/components/ModalManager', 'flarum/components/AlertManager', 'flarum/components/PostMeta', 'flarum/utils/mapRoutes', 'flarum/utils/Pane', 'flarum/utils/Drawer', 'flarum/embed/components/DiscussionPage'], function (_export, _context) {
|
System.register('flarum/embed/main', ['flarum/extend', 'flarum/app', 'flarum/components/Composer', 'flarum/components/PostStream', 'flarum/components/ModalManager', 'flarum/components/AlertManager', 'flarum/components/PostMeta', 'flarum/utils/mapRoutes', 'flarum/utils/Pane', 'flarum/utils/Drawer', 'flarum/utils/ScrollListener', 'flarum/embed/components/DiscussionPage'], function (_export, _context) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var override, extend, app, Composer, PostStream, ModalManager, AlertManager, PostMeta, mapRoutes, Pane, Drawer, DiscussionPage;
|
var override, extend, app, Composer, PostStream, ModalManager, AlertManager, PostMeta, mapRoutes, Pane, Drawer, ScrollListener, DiscussionPage;
|
||||||
return {
|
return {
|
||||||
setters: [function (_flarumExtend) {
|
setters: [function (_flarumExtend) {
|
||||||
override = _flarumExtend.override;
|
override = _flarumExtend.override;
|
||||||
@@ -130,6 +129,8 @@ System.register('flarum/embed/main', ['flarum/extend', 'flarum/app', 'flarum/com
|
|||||||
Pane = _flarumUtilsPane.default;
|
Pane = _flarumUtilsPane.default;
|
||||||
}, function (_flarumUtilsDrawer) {
|
}, function (_flarumUtilsDrawer) {
|
||||||
Drawer = _flarumUtilsDrawer.default;
|
Drawer = _flarumUtilsDrawer.default;
|
||||||
|
}, function (_flarumUtilsScrollListener) {
|
||||||
|
ScrollListener = _flarumUtilsScrollListener.default;
|
||||||
}, function (_flarumEmbedComponentsDiscussionPage) {
|
}, function (_flarumEmbedComponentsDiscussionPage) {
|
||||||
DiscussionPage = _flarumEmbedComponentsDiscussionPage.default;
|
DiscussionPage = _flarumEmbedComponentsDiscussionPage.default;
|
||||||
}],
|
}],
|
||||||
@@ -156,7 +157,7 @@ System.register('flarum/embed/main', ['flarum/extend', 'flarum/app', 'flarum/com
|
|||||||
return original(post).replace('/embed', '/d');
|
return original(post).replace('/embed', '/d');
|
||||||
});
|
});
|
||||||
|
|
||||||
app.pageInfo = m.prop();
|
app.pageInfo = m.prop({});
|
||||||
|
|
||||||
var reposition = function reposition() {
|
var reposition = function reposition() {
|
||||||
var info = app.pageInfo();
|
var info = app.pageInfo();
|
||||||
@@ -205,6 +206,15 @@ System.register('flarum/embed/main', ['flarum/extend', 'flarum/app', 'flarum/com
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a class to the body which indicates that the page has been scrolled
|
||||||
|
// down.
|
||||||
|
new ScrollListener(function (top) {
|
||||||
|
var $app = $('#app');
|
||||||
|
var offset = $app.offset().top;
|
||||||
|
|
||||||
|
$app.toggleClass('affix', top >= offset).toggleClass('scrolled', top > offset);
|
||||||
|
}).start();
|
||||||
|
|
||||||
// Initialize FastClick, which makes links and buttons much more responsive on
|
// Initialize FastClick, which makes links and buttons much more responsive on
|
||||||
// touch devices.
|
// touch devices.
|
||||||
$(function () {
|
$(function () {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import BaseDiscussionPage from 'flarum/components/DiscussionPage';
|
import BaseDiscussionPage from 'flarum/components/DiscussionPage';
|
||||||
import PostStream from 'flarum/components/PostStream';
|
import LoadingIndicator from 'flarum/components/LoadingIndicator';
|
||||||
import listItems from 'flarum/helpers/listItems';
|
import listItems from 'flarum/helpers/listItems';
|
||||||
|
|
||||||
export default class DiscussionPage extends BaseDiscussionPage {
|
export default class DiscussionPage extends BaseDiscussionPage {
|
||||||
@@ -14,12 +14,16 @@ export default class DiscussionPage extends BaseDiscussionPage {
|
|||||||
<div className="DiscussionPage">
|
<div className="DiscussionPage">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div className="DiscussionPage-discussion">
|
<div className="DiscussionPage-discussion">
|
||||||
|
{this.discussion ? [
|
||||||
<nav className="DiscussionPage-nav--embed">
|
<nav className="DiscussionPage-nav--embed">
|
||||||
<ul>{listItems(this.sidebarItems().toArray())}</ul>
|
<ul>{listItems(this.sidebarItems().toArray())}</ul>
|
||||||
</nav>
|
</nav>,
|
||||||
<div className="DiscussionPage-stream">
|
<div className="DiscussionPage-stream">
|
||||||
{this.stream ? this.stream.render() : ''}
|
{this.stream.render()}
|
||||||
</div>
|
</div>
|
||||||
|
] : (
|
||||||
|
<LoadingIndicator className="LoadingIndicator--block"/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -8,6 +8,7 @@ import PostMeta from 'flarum/components/PostMeta';
|
|||||||
import mapRoutes from 'flarum/utils/mapRoutes';
|
import mapRoutes from 'flarum/utils/mapRoutes';
|
||||||
import Pane from 'flarum/utils/Pane';
|
import Pane from 'flarum/utils/Pane';
|
||||||
import Drawer from 'flarum/utils/Drawer';
|
import Drawer from 'flarum/utils/Drawer';
|
||||||
|
import ScrollListener from 'flarum/utils/ScrollListener';
|
||||||
|
|
||||||
import DiscussionPage from 'flarum/embed/components/DiscussionPage';
|
import DiscussionPage from 'flarum/embed/components/DiscussionPage';
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ app.initializers.replace('boot', () => {
|
|||||||
return original(post).replace('/embed', '/d');
|
return original(post).replace('/embed', '/d');
|
||||||
});
|
});
|
||||||
|
|
||||||
app.pageInfo = m.prop();
|
app.pageInfo = m.prop({});
|
||||||
|
|
||||||
const reposition = function() {
|
const reposition = function() {
|
||||||
const info = app.pageInfo();
|
const info = app.pageInfo();
|
||||||
@@ -89,6 +90,17 @@ app.initializers.replace('boot', () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a class to the body which indicates that the page has been scrolled
|
||||||
|
// down.
|
||||||
|
new ScrollListener(top => {
|
||||||
|
const $app = $('#app');
|
||||||
|
const offset = $app.offset().top;
|
||||||
|
|
||||||
|
$app
|
||||||
|
.toggleClass('affix', top >= offset)
|
||||||
|
.toggleClass('scrolled', top > offset);
|
||||||
|
}).start();
|
||||||
|
|
||||||
// Initialize FastClick, which makes links and buttons much more responsive on
|
// Initialize FastClick, which makes links and buttons much more responsive on
|
||||||
// touch devices.
|
// touch devices.
|
||||||
$(() => {
|
$(() => {
|
||||||
|
@@ -25,19 +25,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
> ul {
|
> ul {
|
||||||
z-index: 100;
|
.header-background();
|
||||||
background: @body-bg;
|
border-bottom: 0;
|
||||||
|
height: auto !important;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border-bottom: 1px solid @control-bg;
|
|
||||||
|
|
||||||
|
@media @phone {
|
||||||
|
position: static;
|
||||||
|
}
|
||||||
@media @tablet-up {
|
@media @tablet-up {
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
padding: 15px 15px;
|
padding: 15px 15px;
|
||||||
|
|
||||||
|
.scrolled & {
|
||||||
|
.box-shadow(0 2px 6px @shadow-color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> li {
|
> li {
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Flarum.
|
|
||||||
*
|
|
||||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Flarum\Embed;
|
|
||||||
|
|
||||||
use Flarum\Forum\Controller\DiscussionController as BaseDiscussionController;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
|
||||||
|
|
||||||
class DiscussionController extends BaseDiscussionController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function render(ServerRequestInterface $request)
|
|
||||||
{
|
|
||||||
$view = parent::render($request);
|
|
||||||
|
|
||||||
$view->addBootstrapper('flarum/embed/main');
|
|
||||||
$view->setLayout(__DIR__.'/../views/embed.blade.php');
|
|
||||||
|
|
||||||
return $view;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getAssets()
|
|
||||||
{
|
|
||||||
$assets = parent::getAssets();
|
|
||||||
|
|
||||||
$assets->addFile(__DIR__.'/../js/forum/dist/extension.js');
|
|
||||||
$assets->addFile(__DIR__.'/../less/forum/extension.less');
|
|
||||||
$assets->setFilename('embed');
|
|
||||||
|
|
||||||
return $assets;
|
|
||||||
}
|
|
||||||
}
|
|
40
extensions/embed/src/EmbedWebApp.php
Normal file
40
extensions/embed/src/EmbedWebApp.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Embed;
|
||||||
|
|
||||||
|
use Flarum\Forum\WebApp;
|
||||||
|
|
||||||
|
class EmbedWebApp extends WebApp
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getView()
|
||||||
|
{
|
||||||
|
$view = parent::getView();
|
||||||
|
|
||||||
|
$view->getJs()->addFile(__DIR__.'/../js/forum/dist/extension.js');
|
||||||
|
$view->getCss()->addFile(__DIR__.'/../less/forum/extension.less');
|
||||||
|
|
||||||
|
$view->loadModule('flarum/embed/main');
|
||||||
|
$view->setLayout(__DIR__.'/../views/embed.blade.php');
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getAssets()
|
||||||
|
{
|
||||||
|
return $this->assets->make('embed');
|
||||||
|
}
|
||||||
|
}
|
27
extensions/embed/src/EmbeddedDiscussionController.php
Normal file
27
extensions/embed/src/EmbeddedDiscussionController.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of Flarum.
|
||||||
|
*
|
||||||
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Flarum\Embed;
|
||||||
|
|
||||||
|
use Flarum\Api\Client;
|
||||||
|
use Flarum\Forum\Controller\DiscussionController;
|
||||||
|
use Flarum\Forum\UrlGenerator;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
|
||||||
|
class EmbeddedDiscussionController extends DiscussionController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function __construct(EmbedWebApp $webApp, Dispatcher $events, Client $api, UrlGenerator $url)
|
||||||
|
{
|
||||||
|
parent::__construct($webApp, $events, $api, $url);
|
||||||
|
}
|
||||||
|
}
|
@@ -28,6 +28,6 @@ class AddEmbedRoute
|
|||||||
*/
|
*/
|
||||||
public function addEmbedRoute(ConfigureForumRoutes $event)
|
public function addEmbedRoute(ConfigureForumRoutes $event)
|
||||||
{
|
{
|
||||||
$event->get('/embed/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]', 'embed.discussion', 'Flarum\Embed\DiscussionController');
|
$event->get('/embed/{id:\d+(?:-[^/]*)?}[/{near:[^/]*}]', 'embed.discussion', 'Flarum\Embed\EmbeddedDiscussionController');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
namespace Flarum\Embed\Listener;
|
namespace Flarum\Embed\Listener;
|
||||||
|
|
||||||
use Flarum\Embed\DiscussionController;
|
use Flarum\Embed\DiscussionController;
|
||||||
|
use Flarum\Embed\EmbedWebApp;
|
||||||
use Flarum\Event\ExtensionWasDisabled;
|
use Flarum\Event\ExtensionWasDisabled;
|
||||||
use Flarum\Event\ExtensionWasEnabled;
|
use Flarum\Event\ExtensionWasEnabled;
|
||||||
use Flarum\Event\SettingWasSet;
|
use Flarum\Event\SettingWasSet;
|
||||||
@@ -21,14 +22,14 @@ class FlushEmbedAssetsWhenSettingsAreChanged
|
|||||||
/**
|
/**
|
||||||
* @var DiscussionController
|
* @var DiscussionController
|
||||||
*/
|
*/
|
||||||
protected $controller;
|
protected $webApp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DiscussionController $controller
|
* @param EmbedWebApp $webApp
|
||||||
*/
|
*/
|
||||||
public function __construct(DiscussionController $controller)
|
public function __construct(EmbedWebApp $webApp)
|
||||||
{
|
{
|
||||||
$this->controller = $controller;
|
$this->webApp = $webApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,12 +48,12 @@ class FlushEmbedAssetsWhenSettingsAreChanged
|
|||||||
public function flushCss(SettingWasSet $event)
|
public function flushCss(SettingWasSet $event)
|
||||||
{
|
{
|
||||||
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
|
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
|
||||||
$this->controller->flushCss();
|
$this->webApp->getAssets()->flushCss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function flushAssets()
|
public function flushAssets()
|
||||||
{
|
{
|
||||||
$this->controller->flushAssets();
|
$this->webApp->getAssets()->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user