online status + bug fixes

ye
This commit is contained in:
Conkley 2022-06-24 19:19:30 +10:00
parent 43b2c739d7
commit c4758d42f8
12 changed files with 482 additions and 114 deletions

View File

@ -37,12 +37,14 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\UserLastActivity::class,
],
'api' => [
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
use Illuminate\Http\Request;
class UserLastActivity
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::check()) {
$expireTime = Carbon::now()->addMinute(2); // keep online for 2 min
Cache::put('is_online_' . Auth::user()->id, true, $expireTime);
/*Last Seen
User::where('id', Auth::user()->id)->update(['last_seen' => Carbon::now()]);*/
}
return $next($request);
}
}

397
public/css/app.js Normal file
View File

@ -0,0 +1,397 @@
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[2]!./resources/css/app.css":
/*!*****************************************************************************************************************************************************************************************!*\
!*** ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[2]!./resources/css/app.css ***!
\*****************************************************************************************************************************************************************************************/
/***/ (() => {
throw new Error("Module build failed (from ./node_modules/css-loader/dist/cjs.js):\nError: Can't resolve '../img/animated.png' in 'C:\\wamp64\\www\\morblox-site\\resources\\css'\n at finishWithoutResolve (C:\\wamp64\\www\\morblox-site\\node_modules\\enhanced-resolve\\lib\\Resolver.js:309:18)\n at C:\\wamp64\\www\\morblox-site\\node_modules\\enhanced-resolve\\lib\\Resolver.js:386:15\n at C:\\wamp64\\www\\morblox-site\\node_modules\\enhanced-resolve\\lib\\Resolver.js:435:5\n at eval (eval at create (C:\\wamp64\\www\\morblox-site\\node_modules\\tapable\\lib\\HookCodeFactory.js:33:10), <anonymous>:16:1)\n at C:\\wamp64\\www\\morblox-site\\node_modules\\enhanced-resolve\\lib\\Resolver.js:435:5\n at eval (eval at create (C:\\wamp64\\www\\morblox-site\\node_modules\\tapable\\lib\\HookCodeFactory.js:33:10), <anonymous>:27:1)\n at C:\\wamp64\\www\\morblox-site\\node_modules\\enhanced-resolve\\lib\\DescriptionFilePlugin.js:87:43\n at C:\\wamp64\\www\\morblox-site\\node_modules\\enhanced-resolve\\lib\\Resolver.js:435:5\n at eval (eval at create (C:\\wamp64\\www\\morblox-site\\node_modules\\tapable\\lib\\HookCodeFactory.js:33:10), <anonymous>:15:1)\n at C:\\wamp64\\www\\morblox-site\\node_modules\\enhanced-resolve\\lib\\Resolver.js:435:5");
/***/ }),
/***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js":
/*!****************************************************************************!*\
!*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
\****************************************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var isOldIE = function isOldIE() {
var memo;
return function memorize() {
if (typeof memo === 'undefined') {
// Test for IE <= 9 as proposed by Browserhacks
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
// Tests for existence of standard globals is to allow style-loader
// to operate correctly into non-standard environments
// @see https://github.com/webpack-contrib/style-loader/issues/177
memo = Boolean(window && document && document.all && !window.atob);
}
return memo;
};
}();
var getTarget = function getTarget() {
var memo = {};
return function memorize(target) {
if (typeof memo[target] === 'undefined') {
var styleTarget = document.querySelector(target); // Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch (e) {
// istanbul ignore next
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target];
};
}();
var stylesInDom = [];
function getIndexByIdentifier(identifier) {
var result = -1;
for (var i = 0; i < stylesInDom.length; i++) {
if (stylesInDom[i].identifier === identifier) {
result = i;
break;
}
}
return result;
}
function modulesToDom(list, options) {
var idCountMap = {};
var identifiers = [];
for (var i = 0; i < list.length; i++) {
var item = list[i];
var id = options.base ? item[0] + options.base : item[0];
var count = idCountMap[id] || 0;
var identifier = "".concat(id, " ").concat(count);
idCountMap[id] = count + 1;
var index = getIndexByIdentifier(identifier);
var obj = {
css: item[1],
media: item[2],
sourceMap: item[3]
};
if (index !== -1) {
stylesInDom[index].references++;
stylesInDom[index].updater(obj);
} else {
stylesInDom.push({
identifier: identifier,
updater: addStyle(obj, options),
references: 1
});
}
identifiers.push(identifier);
}
return identifiers;
}
function insertStyleElement(options) {
var style = document.createElement('style');
var attributes = options.attributes || {};
if (typeof attributes.nonce === 'undefined') {
var nonce = true ? __webpack_require__.nc : 0;
if (nonce) {
attributes.nonce = nonce;
}
}
Object.keys(attributes).forEach(function (key) {
style.setAttribute(key, attributes[key]);
});
if (typeof options.insert === 'function') {
options.insert(style);
} else {
var target = getTarget(options.insert || 'head');
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
}
target.appendChild(style);
}
return style;
}
function removeStyleElement(style) {
// istanbul ignore if
if (style.parentNode === null) {
return false;
}
style.parentNode.removeChild(style);
}
/* istanbul ignore next */
var replaceText = function replaceText() {
var textStore = [];
return function replace(index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
}();
function applyToSingletonTag(style, index, remove, obj) {
var css = remove ? '' : obj.media ? "@media ".concat(obj.media, " {").concat(obj.css, "}") : obj.css; // For old IE
/* istanbul ignore if */
if (style.styleSheet) {
style.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = style.childNodes;
if (childNodes[index]) {
style.removeChild(childNodes[index]);
}
if (childNodes.length) {
style.insertBefore(cssNode, childNodes[index]);
} else {
style.appendChild(cssNode);
}
}
}
function applyToTag(style, options, obj) {
var css = obj.css;
var media = obj.media;
var sourceMap = obj.sourceMap;
if (media) {
style.setAttribute('media', media);
} else {
style.removeAttribute('media');
}
if (sourceMap && typeof btoa !== 'undefined') {
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
} // For old IE
/* istanbul ignore if */
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
while (style.firstChild) {
style.removeChild(style.firstChild);
}
style.appendChild(document.createTextNode(css));
}
}
var singleton = null;
var singletonCounter = 0;
function addStyle(obj, options) {
var style;
var update;
var remove;
if (options.singleton) {
var styleIndex = singletonCounter++;
style = singleton || (singleton = insertStyleElement(options));
update = applyToSingletonTag.bind(null, style, styleIndex, false);
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
} else {
style = insertStyleElement(options);
update = applyToTag.bind(null, style, options);
remove = function remove() {
removeStyleElement(style);
};
}
update(obj);
return function updateStyle(newObj) {
if (newObj) {
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
return;
}
update(obj = newObj);
} else {
remove();
}
};
}
module.exports = function (list, options) {
options = options || {}; // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (!options.singleton && typeof options.singleton !== 'boolean') {
options.singleton = isOldIE();
}
list = list || [];
var lastIdentifiers = modulesToDom(list, options);
return function update(newList) {
newList = newList || [];
if (Object.prototype.toString.call(newList) !== '[object Array]') {
return;
}
for (var i = 0; i < lastIdentifiers.length; i++) {
var identifier = lastIdentifiers[i];
var index = getIndexByIdentifier(identifier);
stylesInDom[index].references--;
}
var newLastIdentifiers = modulesToDom(newList, options);
for (var _i = 0; _i < lastIdentifiers.length; _i++) {
var _identifier = lastIdentifiers[_i];
var _index = getIndexByIdentifier(_identifier);
if (stylesInDom[_index].references === 0) {
stylesInDom[_index].updater();
stylesInDom.splice(_index, 1);
}
}
lastIdentifiers = newLastIdentifiers;
};
};
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/nonce */
/******/ (() => {
/******/ __webpack_require__.nc = undefined;
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
/*!*******************************!*\
!*** ./resources/css/app.css ***!
\*******************************/
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
/* harmony import */ var _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _node_modules_css_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_1_node_modules_postcss_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_2_app_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !!../../node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[1]!../../node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[2]!./app.css */ "./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].oneOf[1].use[2]!./resources/css/app.css");
/* harmony import */ var _node_modules_css_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_1_node_modules_postcss_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_2_app_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_1_node_modules_postcss_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_2_app_css__WEBPACK_IMPORTED_MODULE_1__);
var options = {};
options.insert = "head";
options.singleton = false;
var update = _node_modules_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()((_node_modules_css_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_1_node_modules_postcss_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_2_app_css__WEBPACK_IMPORTED_MODULE_1___default()), options);
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((_node_modules_css_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_1_node_modules_postcss_loader_dist_cjs_js_ruleSet_1_rules_5_oneOf_1_use_2_app_css__WEBPACK_IMPORTED_MODULE_1___default().locals) || {});
})();
/******/ })()
;

BIN
public/img/MORBLOX.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -1,78 +1,6 @@
window.addEventListener('resize', function() {
var logo_full = document.getElementById("logo_full")
var logo_small = document.getElementById("logo_small")
var smallbtn = document.getElementById("smallbtn1")
var smallbtn0 = document.getElementById("smallbtn0")
var smallbtn2 = document.getElementById("smallbtn2")
var smallbtn3 = document.getElementById("smallbtn3")
var smallbtn1 = document.getElementById("smallbtn4")
var smallbtn5 = document.getElementById("smallbtn5")
var viewport_width = window.innerWidth;
if (viewport_width < 900) {
logo_full.className = "invisible";
logo_small.className = "";
} else {
logo_small.className = "invisible";
logo_full.className = "";
}
if (viewport_width < 600) {
smallbtn.className = "invisible";
smallbtn2.className = "invisible";
smallbtn3.className = "invisible";
} else {
smallbtn.className = "navbarbutton";
smallbtn2.className = "navbarbutton";
smallbtn3.className = "navbarbutton";
}
if (viewport_width < 425) {
smallbtn0.className = "invisible";
smallbtn1.className = "invisible";
} else {
smallbtn0.className = "navbarbutton";
smallbtn1.className = "navbarbutton";
}
if (viewport_width < 280) {
smallbtn5.className = "invisible";
} else {
smallbtn5.className = "navbarbutton";
}
});
window.onload = function() {
var logo_full = document.getElementById("logo_full")
var logo_small = document.getElementById("logo_small")
var smallbtn = document.getElementById("smallbtn1")
var smallbtn0 = document.getElementById("smallbtn0")
var smallbtn2 = document.getElementById("smallbtn2")
var smallbtn3 = document.getElementById("smallbtn3")
var smallbtn1 = document.getElementById("smallbtn4")
var smallbtn5 = document.getElementById("smallbtn5")
var viewport_width = window.innerWidth;
if (viewport_width < 900) {
logo_full.className = "invisible";
logo_small.className = "";
} else {
logo_small.className = "invisible";
logo_full.className = "";
}
if (viewport_width < 600) {
smallbtn.className = "invisible";
smallbtn2.className = "invisible";
smallbtn3.className = "invisible";
} else {
smallbtn.className = "navbarbutton";
smallbtn2.className = "navbarbutton";
smallbtn3.className = "navbarbutton";
}
if (viewport_width < 425) {
smallbtn0.className = "invisible";
smallbtn1.className = "invisible";
} else {
smallbtn0.className = "navbarbutton";
smallbtn1.className = "navbarbutton";
}
if (viewport_width < 280) {
smallbtn5.className = "invisible";
} else {
smallbtn5.className = "navbarbutton";
}
};
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/
/******/
/******/ })()
;

View File

@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
"/js/main.js": "/js/main.js?id=9f73e36163448599799c0ba369b82b17",
"/css/app.js": "/css/app.js?id=bea72d76448120e19444500780652630"
}

View File

@ -12,8 +12,8 @@
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="MORBLOX.png" />
<link rel="apple-touch-startup-image" href="MORBLOXSplash.png" />
<link rel="apple-touch-icon" href="{{ asset('img/MORBLOX.png') }}" />
<link rel="apple-touch-startup-image" href="{{ asset('img/MORBLOXsplash.png') }}" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}">
<link href="{{ asset('css/app.css') }}" rel="stylesheet">

View File

@ -4,35 +4,39 @@
@endsection
@section('content')
<div id="profiletopcontainer">
<h1 id="usernameframe">{{ $user->name }}</h1>
<p id="onlinestatus" class="onlinestatus_website">Website</p>
</div>
<div id="content_special">
<div id="profileleftcontainer">
<p id="status">"I'm new to MORBLOX!"</p>
<img alt="profile image" src="{{ asset('img/reviewpending.png') }}" width="75%">
<p id="bio">{{ $user->blurb }}</p>
<ul></ul>
<div id="stats">
<h3>Joined: {{ $user->created_at->format('d/m/Y') }}</h3>
<p>(day/month/year)</p>
<h3>Place Visits: 0</h3>
<div id="profiletopcontainer">
<h1 id="usernameframe">{{ $user->name }}</h1>
@if (Cache::has('is_online_' . $user->id))
<p id="onlinestatus" class="onlinestatus_website">Website</p>
@else
<p id="onlinestatus" class="onlinestatus_offline">Offline</p>
@endif
</div>
<div id="content_special">
<div id="profileleftcontainer">
<p id="status">"I'm new to MORBLOX!"</p>
<img alt="profile image" src="{{ asset('img/reviewpending.png') }}" width="75%">
<p id="bio">{{ $user->blurb }}</p>
<ul></ul>
<div id="stats">
<h3>Joined: {{ $user->created_at->format('d/m/Y') }}</h3>
<p>(day/month/year)</p>
<h3>Place Visits: 0</h3>
</div>
<ul></ul>
<h2>MORBLOX Badges</h2>
<p>This user has not collected any MORBLOX badges yet!</p>
<ul></ul>
<h2>Game Badges</h2>
<p>This user has not collected any game badges yet!</p>
</div>
<div id="profilerightcontainer">
<h2>Games</h2>
<p>This user hasn't made any games yet!</p>
<ul></ul>
<h2>Friends</h2>
<p>This user hasn't made friends with anyone!</p>
</div>
<ul></ul>
<h2>MORBLOX Badges</h2>
<p>This user has not collected any MORBLOX badges yet!</p>
<ul></ul>
<h2>Game Badges</h2>
<p>This user has not collected any game badges yet!</p>
</div>
<div id="profilerightcontainer">
<h2>Games</h2>
<p>This user hasn't made any games yet!</p>
<ul></ul>
<h2>Friends</h2>
<p>This user hasn't made friends with anyone!</p>
</div>
<ul></ul>
</div>
@endsection

View File

@ -5,7 +5,8 @@
@section('content')
@if (request()->query('q'))
<h1 id="usernameframe">Users - {{ DB::table('users')->where('name', 'LIKE', '%'.request()->query('q').'%')->count() }} found</h1>
<h1 id="usernameframe">Users -
{{ DB::table('users')->where('name', 'LIKE', '%' . request()->query('q') . '%')->count() }} found</h1>
<a href="{{ route('users') }}" style="color:#2260DD">Clear Search</a>
@else
<h1 id="usernameframe">Users</h1>
@ -14,7 +15,8 @@
<ul></ul>
<form method="GET" action="{{ route('users') }}">
<p><input type="text" id="q" name="q" placeholder="Enter a Username..." value="{{ request()->q }}">
<button class="greybutton" type="submit">Search</button></p>
<button class="greybutton" type="submit">Search</button>
</p>
</form>
<ul></ul>
<div id="SearchContainer">
@ -27,7 +29,11 @@
<div id="ProfileContainerBox1TextContainer">
<a href="{{ route('profile', $user->id) }}" id="FeedContainerBox1Username">{{ $user->name }}</a>
<p>"I'm new to MORBLOX!"</p>
<p class="onlinestatus_website">Online</p>
@if (Cache::has('is_online_' . $user->id))
<p id="onlinestatus" class="onlinestatus_website">Website</p>
@else
<p id="onlinestatus" class="onlinestatus_offline">Offline</p>
@endif
</div>
</div>
@endforeach