Initial commit playing with Turbolinks.
This commit is contained in:
parent
0dbb587c81
commit
49e3cda913
|
@ -103,14 +103,14 @@ return [
|
|||
'api_csrf' => null,
|
||||
];
|
||||
|
||||
return 'let App = ' . json_encode($app, JSON_THROW_ON_ERROR) . ';';
|
||||
return 'document.body.App = ' . json_encode($app, JSON_THROW_ON_ERROR) . ';';
|
||||
},
|
||||
<<<'JS'
|
||||
let currentTheme = document.documentElement.getAttribute('data-theme');
|
||||
if (currentTheme === 'browser') {
|
||||
currentTheme = (window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light';
|
||||
document.body.currentTheme = document.documentElement.getAttribute('data-theme');
|
||||
if (document.body.currentTheme === 'browser') {
|
||||
document.body.currentTheme = (window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light';
|
||||
}
|
||||
App.theme = currentTheme;
|
||||
document.body.App.theme = document.body.currentTheme;
|
||||
JS,
|
||||
],
|
||||
],
|
||||
|
@ -125,6 +125,9 @@ return [
|
|||
'src' => 'dist/lib/sweetalert2/sweetalert2.min.js',
|
||||
'defer' => true,
|
||||
],
|
||||
[
|
||||
'src' => 'dist/lib/turbo/turbo.es2017-umd.js',
|
||||
],
|
||||
],
|
||||
],
|
||||
'inline' => [
|
||||
|
@ -136,7 +139,7 @@ return [
|
|||
$csrfToken = $csrf->generate(ApiAuth::API_CSRF_NAMESPACE);
|
||||
$csrfJson = json_encode($csrfToken, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
return "App.api_csrf = ${csrfJson};";
|
||||
return "document.body.App.api_csrf = ${csrfJson};";
|
||||
},
|
||||
],
|
||||
],
|
||||
|
|
|
@ -50,28 +50,33 @@ var jsFiles = {
|
|||
'node_modules/roboto-fontface/fonts/roboto/*'
|
||||
]
|
||||
},
|
||||
'luxon': {
|
||||
files: [
|
||||
'node_modules/luxon/build/global/luxon.min.js'
|
||||
]
|
||||
},
|
||||
'humanize-duration': {
|
||||
files: [
|
||||
'node_modules/humanize-duration/humanize-duration.js'
|
||||
]
|
||||
},
|
||||
'clipboard': {
|
||||
base: 'node_modules/clipboard/dist',
|
||||
files: [
|
||||
'node_modules/clipboard/dist/clipboard.min.js'
|
||||
]
|
||||
},
|
||||
'webcaster': {
|
||||
base: null,
|
||||
files: [
|
||||
'js/webcaster/*.js'
|
||||
]
|
||||
},
|
||||
'luxon': {
|
||||
files: [
|
||||
'node_modules/luxon/build/global/luxon.min.js'
|
||||
]
|
||||
},
|
||||
'humanize-duration': {
|
||||
files: [
|
||||
'node_modules/humanize-duration/humanize-duration.js'
|
||||
]
|
||||
},
|
||||
'clipboard': {
|
||||
base: 'node_modules/clipboard/dist',
|
||||
files: [
|
||||
'node_modules/clipboard/dist/clipboard.min.js'
|
||||
]
|
||||
},
|
||||
'webcaster': {
|
||||
base: null,
|
||||
files: [
|
||||
'js/webcaster/*.js'
|
||||
]
|
||||
},
|
||||
'turbo': {
|
||||
files: [
|
||||
'node_modules/@hotwired/turbo/dist/turbo.es2017-umd.js'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
var defaultTasks = Object.keys(jsFiles);
|
||||
|
|
|
@ -5,7 +5,7 @@ function confirmDangerousAction (el) {
|
|||
$el = $el.closest('a');
|
||||
}
|
||||
|
||||
let confirmTitle = App.lang.confirm;
|
||||
let confirmTitle = document.body.App.lang.confirm;
|
||||
if ($el.data('confirm-title')) {
|
||||
confirmTitle = $el.data('confirm-title');
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"@fullcalendar/luxon2": "^5.10.2",
|
||||
"@fullcalendar/timegrid": "^5.9.0",
|
||||
"@fullcalendar/vue": "^5.9.0",
|
||||
"@hotwired/turbo": "^7.2.4",
|
||||
"axios": "^1",
|
||||
"bootstrap": "^4.6.0 <5",
|
||||
"bootstrap-notify": "^3.1.3",
|
||||
|
@ -1735,6 +1736,14 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@hotwired/turbo": {
|
||||
"version": "7.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@hotwired/turbo/-/turbo-7.2.4.tgz",
|
||||
"integrity": "sha512-c3xlOroHp/cCZHDOuLp6uzQYEbvXBUVaal0puXoGJ9M8L/KHwZ3hQozD4dVeSN9msHWLxxtmPT1TlCN7gFhj4w==",
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
|
||||
|
@ -11323,6 +11332,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@hotwired/turbo": {
|
||||
"version": "7.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@hotwired/turbo/-/turbo-7.2.4.tgz",
|
||||
"integrity": "sha512-c3xlOroHp/cCZHDOuLp6uzQYEbvXBUVaal0puXoGJ9M8L/KHwZ3hQozD4dVeSN9msHWLxxtmPT1TlCN7gFhj4w=="
|
||||
},
|
||||
"@jridgewell/gen-mapping": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz",
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
"@fullcalendar/luxon2": "^5.10.2",
|
||||
"@fullcalendar/timegrid": "^5.9.0",
|
||||
"@fullcalendar/vue": "^5.9.0",
|
||||
"@hotwired/turbo": "^7.2.4",
|
||||
"axios": "^1",
|
||||
"bootstrap": "^4.6.0 <5",
|
||||
"bootstrap-notify": "^3.1.3",
|
||||
|
|
|
@ -12,18 +12,18 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||
silent: true
|
||||
});
|
||||
|
||||
if (typeof App.locale !== 'undefined') {
|
||||
Vue.config.language = App.locale;
|
||||
}
|
||||
if (typeof document.body.App.locale !== 'undefined') {
|
||||
Vue.config.language = document.body.App.locale;
|
||||
}
|
||||
|
||||
// Configure auto-CSRF on requests
|
||||
if (typeof App.api_csrf !== 'undefined') {
|
||||
axios.defaults.headers.common['X-API-CSRF'] = App.api_csrf;
|
||||
}
|
||||
// Configure auto-CSRF on requests
|
||||
if (typeof document.body.App.api_csrf !== 'undefined') {
|
||||
axios.defaults.headers.common['X-API-CSRF'] = document.body.App.api_csrf;
|
||||
}
|
||||
|
||||
Vue.use(VueAxios, axios);
|
||||
Vue.use(VueAxios, axios);
|
||||
|
||||
Vue.prototype.$eventHub = new Vue();
|
||||
Vue.prototype.$eventHub = new Vue();
|
||||
});
|
||||
|
||||
export default function (component) {
|
||||
|
|
|
@ -144,7 +144,7 @@ export default {
|
|||
},
|
||||
formatTimestamp(unix_timestamp) {
|
||||
return DateTime.fromSeconds(unix_timestamp).toLocaleString(
|
||||
{...DateTime.DATETIME_SHORT, ...App.time_config}
|
||||
{...DateTime.DATETIME_SHORT, ...document.body.App.time_config}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ export default {
|
|||
},
|
||||
toLocaleTime(timestamp) {
|
||||
return DateTime.fromSeconds(timestamp).toLocaleString(
|
||||
{...DateTime.DATETIME_SHORT, ...App.time_config}
|
||||
{...DateTime.DATETIME_SHORT, ...document.body.App.time_config}
|
||||
);
|
||||
},
|
||||
formatFileSize(size) {
|
||||
|
|
|
@ -105,7 +105,7 @@ export default {
|
|||
singleFile: !this.allowMultiple,
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-API-CSRF': App.api_csrf
|
||||
'X-API-CSRF': document.body.App.api_csrf
|
||||
},
|
||||
withCredentials: true,
|
||||
allowDuplicateUploads: true,
|
||||
|
|
|
@ -19,7 +19,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
calendarOptions: {
|
||||
locale: App.locale_short,
|
||||
locale: document.body.App.locale_short,
|
||||
locales: allLocales,
|
||||
plugins: [luxon2Plugin, timeGridPlugin],
|
||||
initialView: 'timeGridWeek',
|
||||
|
@ -36,7 +36,7 @@ export default {
|
|||
views: {
|
||||
timeGridWeek: {
|
||||
slotLabelFormat: {
|
||||
...App.time_config,
|
||||
...document.body.App.time_config,
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
omitZeroMinute: true,
|
||||
|
|
|
@ -268,7 +268,7 @@ export default {
|
|||
return '';
|
||||
}
|
||||
return DateTime.fromSeconds(value).setZone(this.stationTimeZone).toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
{...DateTime.DATETIME_MED, ...document.body.App.time_config}
|
||||
);
|
||||
},
|
||||
selectable: true,
|
||||
|
|
|
@ -193,13 +193,13 @@ export default {
|
|||
},
|
||||
formatTime (time) {
|
||||
return DateTime.fromSeconds(time).setZone(this.stationTimeZone).toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
{...DateTime.DATETIME_MED, ...document.body.App.time_config}
|
||||
);
|
||||
},
|
||||
formatLength (length) {
|
||||
return humanizeDuration(length * 1000, {
|
||||
round: true,
|
||||
language: App.locale_short,
|
||||
language: document.body.App.locale_short,
|
||||
fallbacks: ['en']
|
||||
});
|
||||
},
|
||||
|
|
|
@ -61,21 +61,21 @@ export default {
|
|||
|
||||
if (start_moment.hasSame(now, 'day')) {
|
||||
row.start_formatted = start_moment.toLocaleString(
|
||||
{...DateTime.TIME_SIMPLE, ...App.time_config}
|
||||
{...DateTime.TIME_SIMPLE, ...document.body.App.time_config}
|
||||
);
|
||||
} else {
|
||||
row.start_formatted = start_moment.toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
{...DateTime.DATETIME_MED, ...document.body.App.time_config}
|
||||
);
|
||||
}
|
||||
|
||||
if (end_moment.hasSame(start_moment, 'day')) {
|
||||
row.end_formatted = end_moment.toLocaleString(
|
||||
{...DateTime.TIME_SIMPLE, ...App.time_config}
|
||||
{...DateTime.TIME_SIMPLE, ...document.body.App.time_config}
|
||||
);
|
||||
} else {
|
||||
row.end_formatted = end_moment.toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
{...DateTime.DATETIME_MED, ...document.body.App.time_config}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ export default {
|
|||
methods: {
|
||||
formatTime(time) {
|
||||
return this.getDateTime(time).toLocaleString(
|
||||
{...DateTime.TIME_WITH_SECONDS, ...App.time_config}
|
||||
{...DateTime.TIME_WITH_SECONDS, ...document.body.App.time_config}
|
||||
);
|
||||
},
|
||||
formatRelativeTime(time) {
|
||||
|
|
|
@ -41,7 +41,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
tileUrl: 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/' + App.theme + '_all/{z}/{x}/{y}.png',
|
||||
tileUrl: 'https://cartodb-basemaps-{s}.global.ssl.fastly.net/' + document.body.App.theme + '_all/{z}/{x}/{y}.png',
|
||||
tileAttribution: 'Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL.',
|
||||
}
|
||||
},
|
||||
|
|
|
@ -105,7 +105,7 @@ export default {
|
|||
},
|
||||
formatTime(time) {
|
||||
return DateTime.fromSeconds(time).setZone(this.stationTimeZone).toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
{...DateTime.DATETIME_MED, ...document.body.App.time_config}
|
||||
);
|
||||
},
|
||||
doDelete(url) {
|
||||
|
|
|
@ -166,12 +166,12 @@ export default {
|
|||
},
|
||||
formatTimestamp(unix_timestamp) {
|
||||
return DateTime.fromSeconds(unix_timestamp).toLocaleString(
|
||||
{...DateTime.DATETIME_SHORT, ...App.time_config}
|
||||
{...DateTime.DATETIME_SHORT, ...document.body.App.time_config}
|
||||
);
|
||||
},
|
||||
formatTimestampStation(unix_timestamp) {
|
||||
return DateTime.fromSeconds(unix_timestamp).setZone(this.stationTimeZone).toLocaleString(
|
||||
{...DateTime.DATETIME_SHORT, ...App.time_config}
|
||||
{...DateTime.DATETIME_SHORT, ...document.body.App.time_config}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ export default {
|
|||
sortable: false,
|
||||
formatter: (value, key, item) => {
|
||||
return DateTime.fromSeconds(value).toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
{...DateTime.DATETIME_MED, ...document.body.App.time_config}
|
||||
);
|
||||
},
|
||||
class: 'pl-3'
|
||||
|
@ -77,7 +77,7 @@ export default {
|
|||
return this.$gettext('Live');
|
||||
}
|
||||
return DateTime.fromSeconds(value).toLocaleString(
|
||||
{...DateTime.DATETIME_MED, ...App.time_config}
|
||||
{...DateTime.DATETIME_MED, ...document.body.App.time_config}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Settings } from 'luxon';
|
||||
import {Settings} from 'luxon';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
Settings.defaultLocale = App.locale_with_dashes;
|
||||
Settings.defaultLocale = document.body.App.locale_with_dashes;
|
||||
|
||||
Settings.defaultZoneName = 'UTC';
|
||||
});
|
||||
|
|
|
@ -253,9 +253,8 @@ final class Assets
|
|||
|
||||
$this->addInlineJs(
|
||||
<<<JS
|
||||
let {$name};
|
||||
$(function () {
|
||||
{$name} = {$nameWithoutPrefix}.default('{$elementId}', {$propsJson});
|
||||
document.body.{$name} = {$nameWithoutPrefix}.default('{$elementId}', {$propsJson});
|
||||
});
|
||||
JS
|
||||
);
|
||||
|
@ -553,7 +552,8 @@ final class Assets
|
|||
$cspScriptSrc = $this->getCspDomains();
|
||||
$cspScriptSrc[] = "'self'";
|
||||
$cspScriptSrc[] = "'unsafe-eval'";
|
||||
$cspScriptSrc[] = "'nonce-" . $this->getCspNonce() . "'";
|
||||
$cspScriptSrc[] = "'unsafe-inline'";
|
||||
// $cspScriptSrc[] = "'nonce-" . $this->getCspNonce() . "'";
|
||||
$csp[] = 'script-src ' . implode(' ', $cspScriptSrc);
|
||||
|
||||
$cspWorkerSrc = [];
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Middleware\Module;
|
||||
|
||||
use App\Exception;
|
||||
use App\Http\ServerRequest;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
/**
|
||||
* Module middleware for the file management pages.
|
||||
*/
|
||||
final class StationFiles
|
||||
{
|
||||
public function __invoke(ServerRequest $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
if (!$request->getStation()->getBackendTypeEnum()->isEnabled()) {
|
||||
throw new Exception(__('This feature is not currently supported on this station.'));
|
||||
}
|
||||
|
||||
return $handler->handle($request);
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ $(document).on('click', '.api-call', function (e) {
|
|||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: {
|
||||
"X-API-CSRF": App.api_csrf
|
||||
"X-API-CSRF": document.body.App.api_csrf
|
||||
},
|
||||
url: btn.attr('href'),
|
||||
success: function (data) {
|
||||
|
@ -50,11 +50,11 @@ $(function () {
|
|||
function updateClock() {
|
||||
let d = new Date();
|
||||
|
||||
let timeConfig = {...App.time_config};
|
||||
let timeConfig = {...document.body.App.time_config};
|
||||
timeConfig.timeZone = <?=$this->escapeJs($station->getTimezone()) ?>;
|
||||
timeConfig.timeStyle = 'long';
|
||||
|
||||
let time = d.toLocaleString(App.locale_with_dashes, timeConfig);
|
||||
let time = d.toLocaleString(document.body.App.locale_with_dashes, timeConfig);
|
||||
|
||||
$('#station-time').text(time);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue