Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"node": true,
"es2023": true
},
"extends": ["eslint:recommended", "prettier"],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ================= BASIC META ================= -->
Expand Down Expand Up @@ -211,6 +211,7 @@ <h2 id="live-heading" class="h4 mb-4">Live Streams</h2>
<!-- Popular Tags -->
<section class="mt-5">
<h2 class="h5 mb-3">Popular Tags</h2>
<div class="d-flex flex-wrap gap-2">
<div id="popularTags" class="d-flex flex-wrap gap-2">
<span class="badge bg-primary tag-filter">JavaScript</span>
<span class="badge bg-primary tag-filter">Python</span>
Expand Down
23 changes: 13 additions & 10 deletions public/offline.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Offline</title>
<link rel="stylesheet" href="/src/css/style.css">
</head>
<body>
<link rel="stylesheet" href="/src/css/style.css" />
</head>
<body>
<div class="container text-center">
<h1>You are Offline</h1>
<p>It seems you are not connected to the internet. Please check your connection and try again.</p>
<a href="/" class="btn btn-primary">Go to Home</a>
<h1>You are Offline</h1>
<p>
It seems you are not connected to the internet. Please check your
connection and try again.
</p>
<a href="/" class="btn btn-primary">Go to Home</a>
</div>
</body>
</body>
</html>
84 changes: 44 additions & 40 deletions public/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,55 @@
// service-worker.js
const CACHE_NAME = 'devstream-v1';
const CACHE_NAME = "devstream-v2";

// List of resources to cache
const CACHE_RESOURCES = [
"/",
"/index.html",
"/src/css/style.css",
"/src/js/main.js",
"/manifest.json",
"/src/assets/images/preview-placeholder.jpg",
"/src/assets/icons/icon-192x192.png",
"/src/assets/icons/icon-512x512.png",
"/src/assets/icons/maskable-icon-192x192.png",
"/src/assets/icons/maskable-icon-512x512.png",
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css",
"https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css",
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js",
"https://fonts.googleapis.com/css2?family=Roboto:wght@400&display=swap",
"https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxK.woff2"
'/',
'/index.html',
'/src/css/style.css',
'/src/js/main.js',
'/manifest.json',
'/src/assets/images/preview-placeholder.jpg',
'/src/assets/icons/icon-192x192.png',
'/src/assets/icons/icon-512x512.png',
'/src/assets/icons/maskable-icon-192x192.png',
'/src/assets/icons/maskable-icon-512x512.png',
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css',
'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css',
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js',
'https://fonts.googleapis.com/css2?family=Roboto:wght@400&display=swap',
'https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxK.woff2',
];

// Install event handler
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
console.log("Installing service worker...");
return cache.addAll(CACHE_RESOURCES);
}).catch(error => {
console.error("Error during cache installation:", error);
})
);
self.addEventListener('install', (event) => {
event.waitUntil(
caches
.open(CACHE_NAME)
.then((cache) => {
console.log('Installing service worker...');
return cache.addAll(CACHE_RESOURCES);
})
.catch((error) => {
console.error('Error during cache installation:', error);
})
);
});

// Activate event handler
self.addEventListener("activate", (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
console.log("Removing outdated cache:", cacheName);
return caches.delete(cacheName);
}
})
);
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
console.log('Removing outdated cache:', cacheName);
return caches.delete(cacheName);
}
})
);
);
})
);
});

// Fetch event handler with cache-first strategy
Expand Down Expand Up @@ -87,10 +91,10 @@ self.addEventListener("fetch", (event) => {
});

// Message event handler for debugging
self.addEventListener("message", (event) => {
if (event.data === "skipWaiting") {
self.skipWaiting();
}
self.addEventListener('message', (event) => {
if (event.data === 'skipWaiting') {
self.skipWaiting();
}
});

// Push notification handler
Expand Down
3 changes: 3 additions & 0 deletions src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ body.dark header.bg-white {

/* Navigation links within the header */
header .nav-link {
color: var(
--color-header-text
); /* Ensure nav links get the header text color */
color: #000 !important;
}

Expand Down
1 change: 1 addition & 0 deletions src/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const UserSchema = new mongoose.Schema({
unique: true,
trim: true,
lowercase: true,
match: [/.+\@.+\..+/, 'Please fill a valid email address'],
match: [/.+@.+\..+/, 'Please fill a valid email address'],
},
// Store the hashed password
Expand Down
Loading