summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 01:55:12 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 01:55:12 +0300
commit6e749800d8a9f6b77bf50be92a70b7916c2804f3 (patch)
tree3d6ba2eb67fa11f228b756e0f84ef8ecb3f6ff34 /public
parent546daa78721e6abdbc89afcecc158118c2239865 (diff)
downloadclassroom-6e749800d8a9f6b77bf50be92a70b7916c2804f3.tar.gz
classroom-6e749800d8a9f6b77bf50be92a70b7916c2804f3.tar.bz2
classroom-6e749800d8a9f6b77bf50be92a70b7916c2804f3.zip
hotfixes and optimizations
Diffstat (limited to 'public')
-rw-r--r--public/app/controllers/Auth.php1
-rw-r--r--public/app/controllers/admin/Course_admin.php6
-rw-r--r--public/app/controllers/cms/Course.php8
-rw-r--r--public/app/routes/frontend.php1
-rw-r--r--public/app/views/error/404.php24
-rw-r--r--public/assets/css/class.css4
-rw-r--r--public/assets/js/lesson-features.js21
7 files changed, 60 insertions, 5 deletions
diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php
index 32ff07a..4a6b9ed 100644
--- a/public/app/controllers/Auth.php
+++ b/public/app/controllers/Auth.php
@@ -227,6 +227,7 @@ class Auth {
unset($_COOKIE['cluser']);
setcookie('cluser', '', -1, '/');
return true;
+
} else {
return false;
}
diff --git a/public/app/controllers/admin/Course_admin.php b/public/app/controllers/admin/Course_admin.php
index f68ead2..fcf38c9 100644
--- a/public/app/controllers/admin/Course_admin.php
+++ b/public/app/controllers/admin/Course_admin.php
@@ -174,6 +174,9 @@ class Course_admin {
// set lesson's media files; NOTE: lesson_media table
// ERROR: self::create_medias_for_lesson($post['media'], $id, $post['privilege_id']);
self::create_medias_for_lesson($post['media'], $id);
+
+ // recache media
+ Cache_service::files_attributes(PROXY_IGNORE_CACHE);
}
return true;
@@ -229,6 +232,9 @@ class Course_admin {
// update lesson's media files
// ERROR: self::create_medias_for_lesson($post['media'], $post['id'], $post['privilege_id']);
self::create_medias_for_lesson($post['media'], $post['id']);
+
+ // recache media
+ Cache_service::files_attributes(PROXY_IGNORE_CACHE);
}
return true;
diff --git a/public/app/controllers/cms/Course.php b/public/app/controllers/cms/Course.php
index c795ab9..47eac5f 100644
--- a/public/app/controllers/cms/Course.php
+++ b/public/app/controllers/cms/Course.php
@@ -68,6 +68,12 @@ class Course {
Render::file($real_path, $media_type);
}
+ } else {
+ Render::view('error/404', [
+ 'error_code' => 403,
+ 'moto' => 'Forbidden',
+ 'message' => ''
+ ]);
}
}
@@ -85,7 +91,9 @@ class Course {
$medias = Cache_service::files_attributes();
foreach($medias as $key => $medi) {
+
if ($medi['path'] == $path) {
+
return $medi;
}
}
diff --git a/public/app/routes/frontend.php b/public/app/routes/frontend.php
index 601641f..be06b1c 100644
--- a/public/app/routes/frontend.php
+++ b/public/app/routes/frontend.php
@@ -45,7 +45,6 @@ Route::add('/page/([0-9]*)', // request lesson by lesson-id
function($id) { Course::page($id); }
);
-
Route::add('/serve/file/([0-9a-zA-Z-_\.\/]*)', // serve file by path
function ($path) { Course::serve_file($path); } // (also ?type= is sent)
);
diff --git a/public/app/views/error/404.php b/public/app/views/error/404.php
index 4bbf083..a085830 100644
--- a/public/app/views/error/404.php
+++ b/public/app/views/error/404.php
@@ -1,3 +1,23 @@
+<?php
+/** general error page
+ *
+ * defaults to 404 error but can be used for any other error code
+ *
+ * imported variables:
+ *
+ * optional @var $error_code (int) : error code
+ * optional @var $moto (string) : super-mini description text
+ * optional @var $message (string)
+ *
+ */
+
+ if (!isset($error_code)) { // if error code not set
+ $error_code = 404; // set default (404)
+ }
+
+ http_response_code(403);
+
+?>
<!DOCTYPE html>
<html lang="en">
<head>
@@ -32,8 +52,8 @@
<body>
<div class='container'>
<div class='content'>
- <h3>4O4</h3>
- Not found<br />
+ <h3><?=$error_code?></h3>
+ <?= $moto ?? 'Not found' ?><br />
<!--
<br />
diff --git a/public/assets/css/class.css b/public/assets/css/class.css
index 5ad26c4..5252975 100644
--- a/public/assets/css/class.css
+++ b/public/assets/css/class.css
@@ -389,4 +389,6 @@
.classroom footer .no-list-mark ul li { margin: 0 0 4px 0; }
-.classroom .page-container { max-width: 1024px; } \ No newline at end of file
+.classroom .page-container { max-width: 1024px; }
+
+iframe .ytp-chrome-top-buttons { display: none !important; } \ No newline at end of file
diff --git a/public/assets/js/lesson-features.js b/public/assets/js/lesson-features.js
index 3634aa3..189b301 100644
--- a/public/assets/js/lesson-features.js
+++ b/public/assets/js/lesson-features.js
@@ -2,7 +2,9 @@ const valid_codeblocks = [ // supported sort-code keys
'youtube',
'spotify',
'spotify-track',
- 'world-data'
+ 'world-data',
+ 'vimeo',
+ 'dailymotion'
];
@@ -35,6 +37,15 @@ var owid_template = ( id => { // our world in data (explorer)
return '<iframe src="https://ourworldindata.org/explorers/'+ id +'?zoomToSelection=true&hideControls=true" loading="lazy" style="width: 100%; height: 480px; border: 0px none;"></iframe>'
});
+var vimeo_template = ( id => {
+ return '<div style="padding:56.25% 0 0 0;position:relative;"><iframe src="https://player.vimeo.com/video/'+ id +'?h=2e7bdb3901&title=0&byline=0&portrait=0" style="position:absolute;top:0;left:0;width:100%;height:100%;" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe></div><script src="https://player.vimeo.com/api/player.js"></script>'
+});
+
+var dailymotion_template = ( id => {
+ return '<div style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;"> <iframe style="width:100%;height:100%;position:absolute;left:0px;top:0px;overflow:hidden" frameborder="0" type="text/html" src="https://www.dailymotion.com/embed/video/'+ id +'" width="100%" height="100%" allowfullscreen title="Dailymotion Video Player" > </iframe> </div>'
+});
+
+
/** inject_codeblocks
* --- -- -- - - -
@@ -98,6 +109,14 @@ function inject_codeblocks(code) {
codeblock = owid_template(id);
break;
+ case 'vimeo':
+ codeblock = vimeo_template(id);
+ break;
+
+ case 'dailymotion':
+ codeblock = dailymotion_template(id);
+ break;
+
default:
codeblock = id;