This commit is contained in:
Keep Creating Online
2025-01-08 13:26:00 -05:00
parent ee8eaf45d5
commit 1f4db031c9
16 changed files with 554 additions and 578 deletions

BIN
android-chrome-192x192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
android-chrome-512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

BIN
favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

1
site.webmanifest Normal file
View File

@@ -0,0 +1 @@
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 318.32 108.98">
<defs>
<style>
.cls-1 {
fill: #fe0032;
}
.cls-2 {
fill: #fff;
}
</style>
</defs>
<g>
<rect class="cls-1" x="7.1" y="7.8" width="5.84" height="5.48"/>
<rect class="cls-1" x="7.1" y="18.78" width="24.02" height="5.48"/>
<rect class="cls-1" x="7.1" y="29.77" width="42.85" height="5.48"/>
<rect class="cls-1" x="7.1" y="40.76" width="61.68" height="5.48"/>
<rect class="cls-1" x="7.1" y="51.75" width="80.88" height="5.48"/>
<rect class="cls-1" x="7.1" y="62.74" width="61.68" height="5.48"/>
<rect class="cls-1" x="7.1" y="73.73" width="42.85" height="5.48"/>
<rect class="cls-1" x="7.1" y="84.72" width="24.02" height="5.48"/>
<rect class="cls-1" x="7.1" y="95.71" width="5.84" height="5.48"/>
</g>
<g>
<path class="cls-2" d="M121.28,25.08v44.54c0,5.67,2.79,8.54,8.22,8.54h11.57c5.51,0,8.3-2.87,8.3-8.54v-13.09c0-5.67-2.79-8.46-8.3-8.46h-16.6v-5.83h17.72c8.7,0,13.01,4.47,13.01,13.33v15.01c0,8.86-4.31,13.33-13.01,13.33h-13.73c-8.7,0-13.01-4.47-13.01-13.33V25.08h5.83Z"/>
<path class="cls-2" d="M168.53,25.08v6.26h-5.83v-6.26h5.83ZM168.53,42.64v41.27h-5.83v-41.27h5.83Z"/>
<path class="cls-2" d="M191.36,25.08v17.16h9.02v5.19h-9.02v36.48h-5.83v-36.48h-9.82v-5.19h9.82v-17.16h5.83Z"/>
<path class="cls-2" d="M212.88,42.24l16.84,35.68,16.6-35.68h6.07l-19.56,41.67h-6.31l-20.04-41.67h6.39Z"/>
<path class="cls-2" d="M264.05,25.08v6.26h-5.83v-6.26h5.83ZM264.05,42.24v41.67h-5.83v-41.67h5.83Z"/>
<path class="cls-2" d="M311.21,25.08v45.5c0,8.86-4.31,13.33-13.01,13.33h-13.73c-8.7,0-13.01-4.47-13.01-13.33v-15.01c0-8.86,4.31-13.33,13.01-13.33h17.72v5.83h-16.6c-5.51,0-8.3,2.79-8.3,8.46v13.09c0,5.67,2.79,8.54,8.3,8.54h11.49c5.51,0,8.3-2.87,8.3-8.54V25.08h5.83Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 318.32 108.98">
<defs>
<style>
.cls-1 {
fill: #fe0032;
}
.cls-2 {
fill: #383838;
}
</style>
</defs>
<g>
<rect class="cls-1" x="7.1" y="7.8" width="5.84" height="5.48"/>
<rect class="cls-1" x="7.1" y="18.78" width="24.02" height="5.48"/>
<rect class="cls-1" x="7.1" y="29.77" width="42.85" height="5.48"/>
<rect class="cls-1" x="7.1" y="40.76" width="61.68" height="5.48"/>
<rect class="cls-1" x="7.1" y="51.75" width="80.88" height="5.48"/>
<rect class="cls-1" x="7.1" y="62.74" width="61.68" height="5.48"/>
<rect class="cls-1" x="7.1" y="73.73" width="42.85" height="5.48"/>
<rect class="cls-1" x="7.1" y="84.72" width="24.02" height="5.48"/>
<rect class="cls-1" x="7.1" y="95.71" width="5.84" height="5.48"/>
</g>
<g>
<path class="cls-2" d="M121.28,25.08v44.54c0,5.67,2.79,8.54,8.22,8.54h11.57c5.51,0,8.3-2.87,8.3-8.54v-13.09c0-5.67-2.79-8.46-8.3-8.46h-16.6v-5.83h17.72c8.7,0,13.01,4.47,13.01,13.33v15.01c0,8.86-4.31,13.33-13.01,13.33h-13.73c-8.7,0-13.01-4.47-13.01-13.33V25.08h5.83Z"/>
<path class="cls-2" d="M168.53,25.08v6.26h-5.83v-6.26h5.83ZM168.53,42.64v41.27h-5.83v-41.27h5.83Z"/>
<path class="cls-2" d="M191.36,25.08v17.16h9.02v5.19h-9.02v36.48h-5.83v-36.48h-9.82v-5.19h9.82v-17.16h5.83Z"/>
<path class="cls-2" d="M212.88,42.24l16.84,35.68,16.6-35.68h6.07l-19.56,41.67h-6.31l-20.04-41.67h6.39Z"/>
<path class="cls-2" d="M264.05,25.08v6.26h-5.83v-6.26h5.83ZM264.05,42.24v41.67h-5.83v-41.67h5.83Z"/>
<path class="cls-2" d="M311.21,25.08v45.5c0,8.86-4.31,13.33-13.01,13.33h-13.73c-8.7,0-13.01-4.47-13.01-13.33v-15.01c0-8.86,4.31-13.33,13.01-13.33h17.72v5.83h-16.6c-5.51,0-8.3,2.79-8.3,8.46v13.09c0,5.67,2.79,8.54,8.3,8.54h11.49c5.51,0,8.3-2.87,8.3-8.54V25.08h5.83Z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -1,397 +1,219 @@
```css
/* css/style.css */
/* Global Colors */
:root {
--color-bg: #1a1a2e;
--color-primary: #9b59b6; /* Purple */
--color-secondary: #e74c3c; /* Red */
--color-text: #ecf0f1; /* Light gray */
--color-muted: #95a5a6; /* Muted gray */
}
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
--color-bg: #0f172a;
--color-card: #1e293b;
--color-primary: #8b5cf6;
--color-secondary: #f43f5e;
--color-text: #f8fafc;
--color-muted: #94a3b8;
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}
/* Core Styles */
body {
font-family: 'Arial', sans-serif;
background-color: var(--color-bg);
color: var(--color-text);
line-height: 1.6;
margin: 0;
font-family: system-ui, -apple-system, sans-serif;
background-color: var(--color-bg);
color: var(--color-text);
line-height: 1.5;
}
.container {
max-width: 1200px;
header {
margin-bottom: 2rem;
padding: 1rem 0;
display: flex;
justify-content: flex-start;
}
header img {
height: 6rem;
width: auto;
max-width: none;
}
.container {
max-width: 1480px;
margin: 0 auto;
padding: 1rem;
}
/* Video Grid */
#videoList {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 2rem;
padding: 1.5rem 0;
}
/* Header */
header {
text-align: center;
margin-bottom: 2rem;
/* Video Cards */
.video-card {
background-color: var(--color-card);
border-radius: 0.75rem;
overflow: hidden;
transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: var(--shadow-md);
}
header h1 {
font-size: 2.5rem;
color: var(--color-primary);
.video-card:hover {
transform: translateY(-4px);
box-shadow: var(--shadow-lg);
}
header p {
font-size: 1.1rem;
color: var(--color-muted);
.video-card .thumbnail-container {
position: relative;
padding-top: 56.25%;
background-color: #0f172a;
}
.video-card img.thumbnail {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
.video-card .details {
padding: 1.25rem;
}
.video-card h3 {
font-size: 1.125rem;
font-weight: 600;
color: var(--color-text);
margin-bottom: 0.75rem;
}
/* Modal Player */
#playerModal {
position: fixed;
inset: 0;
background-color: rgb(0 0 0 / 0.8);
backdrop-filter: blur(8px);
z-index: 50;
display: flex;
align-items: center;
justify-content: center;
padding: 1.5rem;
}
.modal-content {
background-color: var(--color-card);
border-radius: 1rem;
width: 100%;
max-width: 64rem;
max-height: 90vh;
overflow-y: auto;
box-shadow: var(--shadow-lg);
}
/* Progress Bars */
.progress-bar {
width: 100%;
height: 0.5rem;
background-color: rgb(255 255 255 / 0.1);
border-radius: 9999px;
overflow: hidden;
}
.progress-bar-fill {
height: 100%;
background-color: var(--color-primary);
transition: width 0.3s ease-out;
}
/* Forms & Inputs */
input, textarea {
width: 100%;
padding: 0.75rem;
background-color: var(--color-bg);
border: 1px solid rgb(255 255 255 / 0.1);
border-radius: 0.5rem;
color: var(--color-text);
transition: border-color 0.2s;
}
input:focus, textarea:focus {
outline: none;
border-color: var(--color-primary);
ring: 2px var(--color-primary);
}
/* Buttons */
button {
background-color: var(--color-primary);
color: var(--color-text);
border: none;
padding: 0.5rem 1rem;
font-size: 1rem;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
padding: 0.75rem 1.5rem;
background-color: var(--color-primary);
color: white;
border-radius: 0.5rem;
font-weight: 500;
transition: all 0.2s;
}
button:hover {
background-color: var(--color-secondary);
background-color: var(--color-secondary);
transform: translateY(-1px);
}
button:focus {
outline: 2px solid var(--color-primary);
outline-offset: 2px;
outline: none;
ring: 2px var(--color-primary);
}
/* Forms */
form input {
width: 100%;
padding: 0.5rem;
border: 1px solid var(--color-muted);
border-radius: 5px;
background-color: var(--color-bg);
color: var(--color-text);
margin-bottom: 1rem;
font-size: 1rem;
/* Utility Classes */
.line-clamp-2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
form input:focus {
border-color: var(--color-primary);
outline: none;
.hidden {
display: none;
}
/* Video List */
#videoList {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.5rem;
}
.video-card {
background-color: #24243e;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
transition: transform 0.3s;
display: flex;
flex-direction: column;
}
.video-card:hover {
transform: translateY(-5px);
}
.video-card img {
width: 100%;
display: block;
}
.video-card .details {
padding: 1rem;
flex-grow: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.video-card h3 {
font-size: 1.2rem;
color: var(--color-primary);
margin-bottom: 0.5rem;
}
.video-card button {
width: 100%;
margin-top: 1rem;
}
/* Highlight dev mode videos */
.video-card.border-red-500 {
border: 2px solid red;
}
.video-card p.text-red-500 {
color: var(--color-secondary) !important;
}
.video-card p.text-green-500 {
color: #2ecc71; /* Green */
}
/* Player Section */
#playerSection {
background-color: #24243e;
padding: 1rem;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
#playerSection video {
width: 100%;
border-radius: 10px;
}
.progress-bar {
width: 100%;
background-color: #4a4a4a;
border-radius: 9999px;
overflow: hidden;
height: 8px;
margin-bottom: 0.5rem;
}
.progress-bar-fill {
height: 100%;
background-color: var(--color-primary);
width: 0%;
transition: width 1s ease-in-out;
}
.stats {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
color: var(--color-muted);
}
/* Video Player Modal */
#playerModal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
display: none; /* Hidden by default */
justify-content: center;
align-items: center;
padding: 1rem;
z-index: 1000;
}
#playerModal .bg-white {
background-color: #24243e;
padding: 1rem;
border-radius: 10px;
position: relative;
width: 90%;
max-width: 800px;
}
#playerModal video {
width: 100%;
border-radius: 10px;
}
#playerModal .progress-bar {
width: 100%;
background-color: #4a4a4a;
border-radius: 9999px;
overflow: hidden;
height: 8px;
margin-top: 0.5rem;
}
#playerModal .progress-bar-fill {
height: 100%;
background-color: var(--color-primary);
width: 0%;
transition: width 1s ease-in-out;
}
#playerModal .stats {
display: flex;
justify-content: space-between;
font-size: 0.9rem;
color: var(--color-muted);
}
#closePlayer {
background-color: var(--color-secondary);
color: var(--color-text);
border: none;
padding: 0.5rem 1rem;
font-size: 1rem;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
#closePlayer:hover {
background-color: var(--color-primary);
}
#closePlayer:focus {
outline: 2px solid var(--color-primary);
outline-offset: 2px;
}
/* Notification Containers */
/* Notifications */
#errorContainer, #successContainer {
display: flex;
align-items: center;
justify-content: center;
border-radius: 5px;
padding: 1rem;
border-radius: 0.5rem;
padding: 1rem;
margin-bottom: 1rem;
display: flex;
align-items: center;
}
#errorContainer {
background-color: #f8d7da;
color: #721c24;
background-color: rgb(220 38 38 / 0.1);
color: #fecaca;
border: 1px solid rgb(220 38 38 / 0.2);
}
#successContainer {
background-color: #d4edda;
color: #155724;
background-color: rgb(34 197 94 / 0.1);
color: #bbf7d0;
border: 1px solid rgb(34 197 94 / 0.2);
}
/* Modal Display */
#playerSection, #playerModal {
display: none;
}
#playerModal.flex {
display: flex;
}
/* Responsive Design */
@media (max-width: 768px) {
header h1 {
font-size: 2rem;
}
header p {
font-size: 1rem;
}
button {
font-size: 0.9rem;
padding: 0.4rem 0.8rem;
}
form input {
font-size: 0.9rem;
padding: 0.4rem;
}
.video-card h3 {
font-size: 1rem;
}
#playerSection video, #playerModal video {
height: auto;
}
}
/* Tailwind's hidden class */
.hidden {
display: none;
}
/* Updated Video Card Styles */
.video-card {
transition: all 0.3s ease;
background-color: #1a1a2e;
}
.video-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.video-card img.thumbnail {
width: 100%;
height: 100%;
object-fit: cover;
}
/* Modal Styles */
#playerModal {
backdrop-filter: blur(5px);
}
#playerModal .modal-content {
background-color: #1a1a2e;
max-height: 90vh;
overflow-y: auto;
}
#playerModal video {
background-color: #000;
}
/* Aspect Ratio Container */
.aspect-w-16 {
position: relative;
padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
}
.aspect-w-16 > * {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
object-fit: cover;
}
/* Stats Container */
.stats-container {
background-color: rgba(26, 26, 46, 0.8);
backdrop-filter: blur(5px);
border-radius: 0.5rem;
}
/* Progress Bar Animation */
.progress-bar-fill {
transition: width 0.3s ease;
}
#videoList {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 2rem;
padding: 1rem;
}
@media (max-width: 640px) {
#videoList {
grid-template-columns: 1fr;
gap: 1rem;
}
#videoList {
grid-template-columns: 1fr;
gap: 1rem;
}
.container {
padding: 0.75rem;
}
}
.line-clamp-2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.video-card {
transition: all 0.3s ease;
}
.video-card:hover {
transform: translateY(-2px);
}
.video-card h3 {
line-height: 1.4;
}
```

View File

@@ -1,180 +1,288 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>bitvid</title>
<!-- TailwindCSS CDN -->
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BitVid - Decentralized Video Sharing</title>
<!-- App Icons -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="manifest" href="/site.webmanifest" />
<!-- Styles -->
<link
href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css"
rel="stylesheet"
/>
<link href="css/style.css" rel="stylesheet" />
</head>
<body class="bg-gray-100">
<div id="app" class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="mb-8">
<h1 class="text-3xl font-bold text-gray-800">bitvid</h1>
<p class="text-gray-600">Decentralized video sharing</p>
</header>
<!-- Header -->
<header class="mb-8">
<div class="flex items-start">
<img
src="assets/svg/bitvid-logo-light-mode.svg"
alt="BitVid Logo"
class="h-16"
/>
</div>
</header>
<!-- Login Section -->
<div id="loginSection" class="mb-8 flex items-center justify-between">
<div>
<button id="loginButton" class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
Login with Nostr
</button>
<p id="userStatus" class="mt-4 text-gray-500 hidden">Logged in as: <span id="userPubKey"></span></p>
<!-- Login Section -->
<div id="loginSection" class="mb-8 flex items-center justify-between">
<div>
<button
id="loginButton"
class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
>
Login with Nostr
</button>
<p id="userStatus" class="mt-4 text-gray-500 hidden">
Logged in as: <span id="userPubKey"></span>
</p>
</div>
<div>
<button
id="logoutButton"
class="bg-red-500 text-white px-4 py-2 rounded-md hover:bg-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 hidden"
>
Logout
</button>
</div>
</div>
<!-- Error Container -->
<div
id="errorContainer"
class="hidden bg-red-100 text-red-800 p-4 rounded-md mb-4"
>
<!-- Error messages will appear here -->
</div>
<!-- Success Container -->
<div
id="successContainer"
class="hidden bg-green-100 text-green-800 p-4 rounded-md mb-4"
>
<!-- Success messages will appear here -->
</div>
<!-- Video Submission Form -->
<div
class="bg-white p-6 rounded-lg shadow-md mb-8 hidden"
id="videoFormContainer"
>
<h2 class="text-xl font-semibold mb-4">Share a Video</h2>
<form id="submitForm" class="space-y-4">
<div>
<label for="title" class="block text-sm font-medium text-gray-700"
>Title</label
>
<input
type="text"
id="title"
required
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
/>
</div>
<div>
<label for="magnet" class="block text-sm font-medium text-gray-700"
>Magnet Link</label
>
<input
type="text"
id="magnet"
required
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
/>
</div>
<div>
<label
for="thumbnail"
class="block text-sm font-medium text-gray-700"
>Thumbnail URL (optional)</label
>
<input
type="url"
id="thumbnail"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
/>
</div>
<!-- Description Field -->
<div>
<label
for="description"
class="block text-sm font-medium text-gray-700"
>Description (optional)</label
>
<textarea
id="description"
rows="3"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"
></textarea>
</div>
<!-- ADDED FOR PRIVATE LISTINGS -->
<div class="flex items-center space-x-2">
<input
type="checkbox"
id="isPrivate"
class="form-checkbox h-5 w-5"
/>
<span class="text-sm font-medium text-gray-700"
>Private Listing (Encrypt Magnet)</span
>
</div>
<!-- END ADDED FOR PRIVATE LISTINGS -->
<button
type="submit"
class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
>
Share Video
</button>
</form>
</div>
<!-- Video Player Section -->
<div id="playerSection" class="mb-8 hidden">
<video id="video" controls class="w-full rounded-lg shadow-md"></video>
<!-- Status and Stats -->
<div class="mt-4">
<div id="status" class="text-gray-700 mb-2">Initializing...</div>
<div class="w-full bg-gray-300 rounded-full h-2 mb-2">
<div
class="bg-blue-500 h-2 rounded-full"
id="progress"
style="width: 0%"
></div>
</div>
<div class="flex justify-between text-sm text-gray-600">
<span id="peers">Peers: 0</span>
<span id="speed">0 KB/s</span>
<span id="downloaded">0 MB / 0 MB</span>
</div>
</div>
</div>
<!-- Video List -->
<div class="mb-8">
<div
id="videoList"
class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8"
>
<!-- Videos will be dynamically inserted here -->
</div>
</div>
<!-- Improved Video Player Modal -->
<div
id="playerModal"
class="hidden fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50 p-4"
>
<div
class="bg-gray-900 rounded-lg max-w-4xl w-full relative overflow-hidden"
>
<!-- Close button -->
<button
id="closePlayer"
class="absolute top-4 right-4 z-50 text-white bg-gray-800 hover:bg-gray-700 rounded-full p-2"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
<!-- Video container -->
<div class="aspect-w-16 aspect-h-9">
<video id="modalVideo" controls class="w-full rounded-t-lg"></video>
</div>
<!-- Video info section -->
<div class="p-6 text-white">
<!-- Video Title -->
<h2 id="videoTitle" class="text-2xl font-bold mb-2"></h2>
<!-- Video Timestamp -->
<div
class="flex items-center justify-between text-sm text-gray-400 mb-4"
>
<span id="videoTimestamp">just now</span>
<div id="modalStatus" class="text-gray-300">Initializing...</div>
</div>
<div>
<button id="logoutButton" class="bg-red-500 text-white px-4 py-2 rounded-md hover:bg-red-600 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 hidden">
Logout
</button>
<!-- Creator info -->
<div class="flex items-center mb-4 p-4 bg-gray-800 rounded-lg">
<div
id="creatorAvatar"
class="w-12 h-12 rounded-full bg-gray-700 overflow-hidden"
>
<img src="" alt="Creator" class="w-full h-full object-cover" />
</div>
<div class="ml-4">
<h3 id="creatorName" class="font-medium text-lg">
Creator Name
</h3>
<p id="creatorNpub" class="text-sm text-gray-400">npub...</p>
</div>
</div>
</div>
<!-- Error Container -->
<div id="errorContainer" class="hidden bg-red-100 text-red-800 p-4 rounded-md mb-4">
<!-- Error messages will appear here -->
</div>
<!-- Success Container -->
<div id="successContainer" class="hidden bg-green-100 text-green-800 p-4 rounded-md mb-4">
<!-- Success messages will appear here -->
</div>
<!-- Video Submission Form -->
<div class="bg-white p-6 rounded-lg shadow-md mb-8 hidden" id="videoFormContainer">
<h2 class="text-xl font-semibold mb-4">Share a Video</h2>
<form id="submitForm" class="space-y-4">
<div>
<label for="title" class="block text-sm font-medium text-gray-700">Title</label>
<input type="text" id="title" required
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
</div>
<div>
<label for="magnet" class="block text-sm font-medium text-gray-700">Magnet Link</label>
<input type="text" id="magnet" required
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
</div>
<div>
<label for="thumbnail" class="block text-sm font-medium text-gray-700">Thumbnail URL (optional)</label>
<input type="url" id="thumbnail"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500">
</div>
<!-- Description Field -->
<div>
<label for="description" class="block text-sm font-medium text-gray-700">Description (optional)</label>
<textarea id="description" rows="3"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"></textarea>
</div>
<!-- ADDED FOR PRIVATE LISTINGS -->
<div class="flex items-center space-x-2">
<input type="checkbox" id="isPrivate" class="form-checkbox h-5 w-5">
<span class="text-sm font-medium text-gray-700">Private Listing (Encrypt Magnet)</span>
</div>
<!-- END ADDED FOR PRIVATE LISTINGS -->
<button type="submit"
class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
Share Video
</button>
</form>
</div>
<!-- Video Player Section -->
<div id="playerSection" class="mb-8 hidden">
<video id="video" controls class="w-full rounded-lg shadow-md"></video>
<!-- Status and Stats -->
<div class="mt-4">
<div id="status" class="text-gray-700 mb-2">Initializing...</div>
<div class="w-full bg-gray-300 rounded-full h-2 mb-2">
<div class="bg-blue-500 h-2 rounded-full" id="progress" style="width: 0%;"></div>
</div>
<div class="flex justify-between text-sm text-gray-600">
<span id="peers">Peers: 0</span>
<span id="speed">0 KB/s</span>
<span id="downloaded">0 MB / 0 MB</span>
</div>
<!-- Video Description -->
<div class="bg-gray-800 rounded-lg p-4 mb-4">
<p
id="videoDescription"
class="text-gray-300 whitespace-pre-wrap"
>
No description available.
</p>
</div>
</div>
<!-- Video List -->
<div class="mb-8">
<div id="videoList" class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8">
<!-- Videos will be dynamically inserted here -->
<!-- Torrent stats -->
<div class="bg-gray-800 rounded-lg p-4">
<div class="w-full bg-gray-700 rounded-full h-2 mb-2">
<div
class="bg-blue-500 h-2 rounded-full"
id="modalProgress"
style="width: 0%"
></div>
</div>
<div class="flex justify-between text-sm text-gray-400">
<span id="modalPeers">Peers: 0</span>
<span id="modalSpeed">Speed: 0 KB/s</span>
<span id="modalDownloaded">Downloaded: 0 MB / 0 MB</span>
</div>
</div>
</div>
</div>
</div>
<!-- Improved Video Player Modal -->
<div id="playerModal" class="hidden fixed inset-0 bg-black bg-opacity-75 flex items-center justify-center z-50 p-4">
<div class="bg-gray-900 rounded-lg max-w-4xl w-full relative overflow-hidden">
<!-- Close button -->
<button id="closePlayer" class="absolute top-4 right-4 z-50 text-white bg-gray-800 hover:bg-gray-700 rounded-full p-2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
<!-- Video container -->
<div class="aspect-w-16 aspect-h-9">
<video id="modalVideo" controls class="w-full rounded-t-lg"></video>
</div>
<!-- Video info section -->
<div class="p-6 text-white">
<!-- Video Title -->
<h2 id="videoTitle" class="text-2xl font-bold mb-2"></h2>
<!-- Video Timestamp -->
<div class="flex items-center justify-between text-sm text-gray-400 mb-4">
<span id="videoTimestamp">just now</span>
<div id="modalStatus" class="text-gray-300">Initializing...</div>
</div>
<!-- Creator info -->
<div class="flex items-center mb-4 p-4 bg-gray-800 rounded-lg">
<div id="creatorAvatar" class="w-12 h-12 rounded-full bg-gray-700 overflow-hidden">
<img src="" alt="Creator" class="w-full h-full object-cover">
</div>
<div class="ml-4">
<h3 id="creatorName" class="font-medium text-lg">Creator Name</h3>
<p id="creatorNpub" class="text-sm text-gray-400">npub...</p>
</div>
</div>
<!-- Video Description -->
<div class="bg-gray-800 rounded-lg p-4 mb-4">
<p id="videoDescription" class="text-gray-300 whitespace-pre-wrap">No description available.</p>
</div>
<!-- Torrent stats -->
<div class="bg-gray-800 rounded-lg p-4">
<div class="w-full bg-gray-700 rounded-full h-2 mb-2">
<div class="bg-blue-500 h-2 rounded-full" id="modalProgress" style="width: 0%"></div>
</div>
<div class="flex justify-between text-sm text-gray-400">
<span id="modalPeers">Peers: 0</span>
<span id="modalSpeed">Speed: 0 KB/s</span>
<span id="modalDownloaded">Downloaded: 0 MB / 0 MB</span>
</div>
</div>
</div>
</div>
</div>
<!-- Scripts -->
<!-- Load WebTorrent via CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/webtorrent/1.9.7/webtorrent.min.js"></script>
<!-- Load Nostr library -->
<script src="js/libs/nostr.bundle.js"></script>
<!-- Load JavaScript Modules -->
<script type="module" src="js/config.js"></script>
<script type="module" src="js/webtorrent.js"></script>
<script type="module" src="js/nostr.js"></script>
<script type="module" src="js/app.js"></script>
<!-- Scripts -->
<!-- Load WebTorrent via CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/webtorrent/1.9.7/webtorrent.min.js"></script>
<!-- Load Nostr library -->
<script src="js/libs/nostr.bundle.js"></script>
<!-- Load JavaScript Modules -->
<script type="module" src="js/config.js"></script>
<script type="module" src="js/webtorrent.js"></script>
<script type="module" src="js/nostr.js"></script>
<script type="module" src="js/app.js"></script>
</div>
</body>
</body>
</html>

View File

@@ -63,32 +63,26 @@ class bitvidApp {
/**
* Initializes the application by setting up the Nostr client and loading videos.
*/
// app.js
async init() {
try {
// Hide the video player sections initially
this.playerSection.classList.add('hidden');
this.playerModal.classList.add('hidden');
// Initialize Nostr client
// Hide and reset player states
this.playerSection.style.display = 'none';
this.playerModal.style.display = 'none';
this.currentMagnetUri = null;
// Initialize Nostr and check login
await nostrClient.init();
this.log('Nostr client initialized.');
// Check if user is already logged in
const savedPubKey = localStorage.getItem('userPubKey');
if (savedPubKey) {
this.login(savedPubKey, false);
}
// Setup event listeners
this.setupEventListeners();
this.log('Event listeners set up.');
// Load videos
await this.loadVideos();
this.log('Videos loaded.');
} catch (error) {
this.log('Failed to initialize app:', error);
this.showError('Failed to connect to Nostr relay. Please try again later.');
console.error('Init failed:', error);
this.showError('Failed to connect to Nostr relay');
}
}

View File

@@ -48,59 +48,44 @@ class NostrClient {
* Initializes the Nostr client by connecting to relays.
*/
async init() {
if (isDevMode) console.log('Connecting to relays...');
try {
if (isDevMode) console.log('Connecting to relays...');
this.pool = new window.NostrTools.SimplePool();
const testFilter = { kinds: [0], limit: 1 };
const connections = this.relays.map(async url => {
try {
return new Promise((resolve) => {
const sub = this.pool.sub([url], [testFilter]);
let timeout = setTimeout(() => {
sub.unsub();
if (isDevMode) console.log(`Connection timeout for ${url}`);
resolve({ url, success: false });
}, 5000);
sub.on('event', () => {
clearTimeout(timeout);
sub.unsub();
if (isDevMode) console.log(`Received event from ${url}`);
resolve({ url, success: true });
});
sub.on('eose', () => {
clearTimeout(timeout);
sub.unsub();
if (isDevMode) console.log(`EOSE from ${url}`);
resolve({ url, success: true });
});
});
} catch (err) {
if (isDevMode) console.error(`Failed to connect to relay: ${url}`, err.message);
return { url, success: false };
}
});
const results = await Promise.all(connections);
const results = await this.connectToRelays();
const successfulRelays = results.filter(r => r.success).map(r => r.url);
if (successfulRelays.length === 0) {
throw new Error('No relays could be connected.');
}
if (isDevMode) {
console.log(`Connected to ${successfulRelays.length} relay(s):`, successfulRelays);
}
if (successfulRelays.length === 0) throw new Error('No relays connected');
if (isDevMode) console.log(`Connected to ${successfulRelays.length} relay(s)`);
} catch (err) {
console.error('Failed to initialize Nostr client:', err.message);
console.error('Nostr init failed:', err);
throw err;
}
}
// Helper method to handle relay connections
async connectToRelays() {
return Promise.all(this.relays.map(url =>
new Promise(resolve => {
const sub = this.pool.sub([url], [{ kinds: [0], limit: 1 }]);
const timeout = setTimeout(() => {
sub.unsub();
resolve({ url, success: false });
}, 5000);
const succeed = () => {
clearTimeout(timeout);
sub.unsub();
resolve({ url, success: true });
};
sub.on('event', succeed);
sub.on('eose', succeed);
})
));
}
/**
* Logs in the user using a Nostr extension or by entering an NSEC key.
*/