Skip to content

A self-hosted media server and file management system

add shareable video url and add description column

aminnausinb9f893fe7a30
diff --git a/app/Http/Resources/VideoResource.php b/app/Http/Resources/VideoResource.php
index 595d3e9a..2c76657b 100644
--- a/app/Http/Resources/VideoResource.php
+++ b/app/Http/Resources/VideoResource.php
@@ -22,6 +22,7 @@ class VideoResource extends JsonResource
'date' => $this->date,
'date_raw' => $this->date_raw,
'title' => $this->title ?? $this->name,
+ 'description' => $this->description, // ?? $this->folder->series->description
'duration' => $this->duration,
'episode' => $this->episode,
'season' => $this->season,
diff --git a/app/Models/Video.php b/app/Models/Video.php
index 03bcfaac..52e98e1b 100644
--- a/app/Models/Video.php
+++ b/app/Models/Video.php
@@ -14,6 +14,7 @@ class Video extends Model
protected $fillable = [
'title',
+ 'description',
'duration',
'episode',
'season',
diff --git a/database/migrations/2024_07_29_212739_add_description_to_videos_table.php b/database/migrations/2024_07_29_212739_add_description_to_videos_table.php
new file mode 100644
index 00000000..03baec92
--- /dev/null
+++ b/database/migrations/2024_07_29_212739_add_description_to_videos_table.php
@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('videos', function (Blueprint $table) {
+ $table->string('description')->nullable()->after('title');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('videos', function (Blueprint $table) {
+ $table->dropColumn('description');
+ });
+ }
+};
diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vue
new file mode 100644
index 00000000..d7681582
--- /dev/null
+++ b/resources/js/components/video/VideoInfoPanel.vue
@@ -0,0 +1,81 @@
+<script setup>
+import useMetaData from '../../composables/useMetaData';
+
+import CircumShare1 from '~icons/circum/share-1';
+
+import { watch } from 'vue';
+import { storeToRefs } from 'pinia';
+import { useContentStore } from '../../stores/ContentStore';
+
+
+const defaultDescription = `After defeating the
+ Demon Lord, Himmel the Hero, priest Heiter, dwarf warrior Eisen, and elf mage
+ Frieren return to the royal capital. After their procession, they view a meteor
+ shower and discuss their future plans. Himmel, Heiter, and Eisen are ready to retire
+ from adventuring after their ten-year quest. Frieren, whose lifespan is much longer,
+ considers the ten years to be trivially short and plans to travel and learn new
+ spells. To her colleagues' amusement, she promises to show them a better site to
+ observe the meteor shower at its next occurrence in 50 years. Frieren keeps her word
+ and returns 50 years later to find that Himmel and Heiter have become elderly, and
+ Eisen is middle-aged. The week-long journey to Frieren's viewing site reminds the
+ party of their past adventures. Himmel the Hero dies of old age shortly after the
+ expedition. At his funeral, Frieren tearfully realizes she did not adequately get to
+ know him and decides to learn as much about humans as possible. 20 years later, she
+ visits Heiter to find that he has adopted a war orphan, nine year old Fern. Heiter,
+ suffering from death anxiety in his advanced age, asks Frieren to research
+ life-extending magic and tutor Fern in magic in her spare time. She agrees after
+ seeing Fern is already remarkably skilled despite her youth.`;
+
+const ContentStore = useContentStore();
+const { stateVideo } = storeToRefs(ContentStore);
+const metaData = useMetaData(stateVideo.value.attributes);
+
+
+const handlePropsUpdate = () => {
+ metaData.updateData(stateVideo.value.attributes);
+}
+
+watch(() => stateVideo.value, handlePropsUpdate, {immediate: true});
+</script>
+
+<template>
+ <div
+ class="p-6 w-full mx-auto dark:bg-primary-dark-800 bg-primary-800 rounded-xl shadow-lg flex justify-center sm:justify-between gap-4 flex-wrap sm:flex-nowrap overflow-hidden">
+ <div id="mp4-description" class="hidden sm:flex items-center gap-4 md:w-2/3 ">
+ <img id="folder-thumbnail" class="h-28 object-contain rounded-md shadow-md"
+ :src="stateVideo?.attributes?.thumbnail?.url ?? 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'"
+ alt="Folder Cover Art">
+ <div class="h-full flex flex-col gap-2">
+ <div id="mp4-title" class="text-xl font-medium line">{{ stateVideo?.attributes?.name ?? '[Video Name]' }}
+ </div>
+ <p class="dark:text-slate-400 text-slate-500 line-clamp-3 text-sm">{{ defaultDescription }}</p>
+ </div>
+ </div>
+ <div id="mp4-description-mobile" class="flex sm:hidden items-center gap-4 flex-col ">
+ <div id="mp4-title" class="text-xl font-medium w-full">{{ metaData?.fields.title ?? '[Video Name]' }}</div>
+ <div class="flex items-start gap-4 md:w-2/3">
+ <img id="folder-thumbnail" class="h-28 object-contain rounded-md shadow-sm"
+ :src="stateVideo?.attributes?.thumbnail?.url ?? 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'"
+ alt="Folder Cover Art">
+ <p class="dark:text-slate-400 text-slate-500 line-clamp-3 text-sm">{{ defaultDescription }}</p>
+ </div>
+ </div>
+ <div id="mp4-details"
+ class="container flex sm:w-auto sm:flex-col justify-between lg:min-w-32 items-center sm:items-end gap-3 flex-wrap"
+ role="group">
+ <section class="flex gap-2">
+ <button aria-label="edit details"
+ class="p-2 bg-button-100 dark:bg-button-900 rounded-lg ring-violet-500 hover:ring-violet-700 hover:bg-violet-400/50 ring-[0.125rem] ring-inset shadow">Edit
+ Details</button>
+ <button aria-label="share"
+ class="p-2 bg-button-100 dark:bg-button-900 rounded-lg ring-neutral-700 hover:ring-violet-700 hover:bg-violet-400/50 dark:ring-[0.125rem] hover:ring-[0.125rem] ring-inset shadow">
+ <CircumShare1 height="24" width="24" />
+ </button>
+ </section>
+ <section class="flex gap flex-col items-end text-sm dark:text-slate-400 text-slate-500 justify-between">
+ <p>{{ metaData?.fields.views }}</p>
+ <p class="line-clamp-1 truncate">{{ stateVideo?.tags ?? '#atmospheroc #sad #rocky' }}</p>
+ </section>
+ </div>
+ </div>
+</template>
\ No newline at end of file
diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.js
index 8ba44bd6..53979842 100644
--- a/resources/js/stores/ContentStore.js
+++ b/resources/js/stores/ContentStore.js
@@ -5,12 +5,15 @@ import { ref, watch } from "vue";
import { defineStore, storeToRefs } from "pinia";
import { useAppStore } from "./AppStore";
import { useAuthStore } from "./AuthStore";
+import { useRoute } from "vue-router";
export const useContentStore = defineStore('Content', () => {
const AppStore = useAppStore();
const AuthStore = useAuthStore();
+ const route = useRoute();
+
const folders = ref([]);
const videos = ref([]);
const records = ref([]);
@@ -140,10 +143,19 @@ export const useContentStore = defineStore('Content', () => {
}
function playlistFind(id){
- if(stateVideo.value.id === id) return;
- stateVideo.value = statePlaylist.value.find((video) => {
- return video.id === id
- });
+ let result = statePlaylist.value.length > 0 ? statePlaylist.value[0] : {};
+
+ if(id && stateVideo.value.id === id) return;
+
+ if(!isNaN(parseInt(id))){
+ result = statePlaylist.value.find((video) => {
+ return video.id === id
+ });
+ }
+ // eslint-disable-next-line no-undef
+ if(!result) toastr.error('Selected video cannot be found...');
+ stateVideo.value = result;
+ console.log(document.location.origin + route.path + `?video=${stateVideo.value.id}`);
}
// InitPlaylist (set up playlist with indexes and current video)
@@ -158,8 +170,8 @@ export const useContentStore = defineStore('Content', () => {
statePlaylist.value = stateFolder.value.videos.map((video, index) => { return {index, ...video}; } );
playlistSort();
- stateVideo.value = statePlaylist.value.length > 0 ? statePlaylist.value[0] : {};
searchQuery.value = '';
+ playlistFind(route.query?.video);
}
const playlistSort = (column = 'name', dir = 1) => {
diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vue
index c95a5f7e..83598ce7 100644
--- a/resources/js/views/VideoView.vue
+++ b/resources/js/views/VideoView.vue
@@ -3,24 +3,20 @@ import VideoSidebar from '../components/panels/VideoSidebar.vue';
import LayoutBase from '../components/layout/LayoutBase.vue';
import VideoPlayer from '../components/video/VideoPlayer.vue';
import VideoTable from '../components/video/VideoTable.vue';
-
-import CircumShare1 from '~icons/circum/share-1';
+import VideoInfoPanel from '../components/video/VideoInfoPanel.vue';
import { nextTick, onMounted, watch } from 'vue';
import { useContentStore } from '../stores/ContentStore';
import { useAppStore } from '../stores/AppStore';
import { storeToRefs } from 'pinia';
import { useRoute } from 'vue-router'
-import useMetaData from '../composables/useMetaData';
const route = useRoute();
const appStore = useAppStore();
const ContentStore = useContentStore();
const { selectedSideBar } = storeToRefs(appStore);
-const { stateVideo } = storeToRefs(ContentStore);
const { getFolder, getCategory, getRecords } = ContentStore;
-const metaData = useMetaData(stateVideo.value.attributes);
async function cycleSideBar(state) {
if (state === "history") {
@@ -41,13 +37,8 @@ onMounted(async () => {
getCategory(URL_CATEGORY, URL_FOLDER);
})
-const handlePropsUpdate = () => {
- metaData.updateData(stateVideo.value.attributes);
-}
-
watch(() => route.params.folder, reload, { immediate: false });
watch(() => selectedSideBar.value, cycleSideBar, { immediate: false });
-watch(() => stateVideo.value, handlePropsUpdate, {immediate: true});
</script>
<template>
@@ -59,77 +50,7 @@ watch(() => stateVideo.value, handlePropsUpdate, {immediate: true});
<!-- <hr class=""> -->
- <div
- class="p-6 w-full mx-auto dark:bg-primary-dark-800 bg-primary-800 rounded-xl shadow-lg flex justify-center sm:justify-between gap-4 flex-wrap sm:flex-nowrap overflow-hidden">
- <div id="mp4-description" class="hidden sm:flex items-center gap-4 md:w-2/3 ">
- <img id="folder-thumbnail" class="h-28 object-contain rounded-md shadow-md"
- :src="stateVideo?.attributes?.thumbnail?.url ?? 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'"
- alt="Folder Cover Art">
- <div class="h-full flex flex-col gap-2">
- <div id="mp4-title" class="text-xl font-medium line">{{ stateVideo?.attributes?.name ?? '[Video Name]'}}</div>
- <p class="dark:text-slate-400 text-slate-500 line-clamp-3 text-sm">After defeating the
- Demon Lord, Himmel the Hero, priest Heiter, dwarf warrior Eisen, and elf mage
- Frieren return to the royal capital. After their procession, they view a meteor
- shower and discuss their future plans. Himmel, Heiter, and Eisen are ready to retire
- from adventuring after their ten-year quest. Frieren, whose lifespan is much longer,
- considers the ten years to be trivially short and plans to travel and learn new
- spells. To her colleagues' amusement, she promises to show them a better site to
- observe the meteor shower at its next occurrence in 50 years. Frieren keeps her word
- and returns 50 years later to find that Himmel and Heiter have become elderly, and
- Eisen is middle-aged. The week-long journey to Frieren's viewing site reminds the
- party of their past adventures. Himmel the Hero dies of old age shortly after the
- expedition. At his funeral, Frieren tearfully realizes she did not adequately get to
- know him and decides to learn as much about humans as possible. 20 years later, she
- visits Heiter to find that he has adopted a war orphan, nine year old Fern. Heiter,
- suffering from death anxiety in his advanced age, asks Frieren to research
- life-extending magic and tutor Fern in magic in her spare time. She agrees after
- seeing Fern is already remarkably skilled despite her youth.</p>
- </div>
- </div>
- <div id="mp4-description-mobile" class="flex sm:hidden items-center gap-4 flex-col ">
- <div id="mp4-title" class="text-xl font-medium w-full">{{metaData?.fields.title ?? '[Video Name]'}}</div>
- <div class="flex items-start gap-4 md:w-2/3">
- <img id="folder-thumbnail" class="h-28 object-contain rounded-md shadow-sm"
- :src="stateVideo?.attributes?.thumbnail?.url ?? 'https://m.media-amazon.com/images/M/MV5BMjVjZGU5ZTktYTZiNC00N2Q1LThiZjMtMDVmZDljN2I3ZWIwXkEyXkFqcGdeQXVyMTUzMTg2ODkz._V1_.jpg'"
- alt="Folder Cover Art">
- <p class="dark:text-slate-400 text-slate-500 line-clamp-3 text-sm">After defeating the
- Demon Lord, Himmel the Hero, priest Heiter, dwarf warrior Eisen, and elf mage
- Frieren return to the royal capital. After their procession, they view a meteor
- shower and discuss their future plans. Himmel, Heiter, and Eisen are ready to retire
- from adventuring after their ten-year quest. Frieren, whose lifespan is much longer,
- considers the ten years to be trivially short and plans to travel and learn new
- spells. To her colleagues' amusement, she promises to show them a better site to
- observe the meteor shower at its next occurrence in 50 years. Frieren keeps her word
- and returns 50 years later to find that Himmel and Heiter have become elderly, and
- Eisen is middle-aged. The week-long journey to Frieren's viewing site reminds the
- party of their past adventures. Himmel the Hero dies of old age shortly after the
- expedition. At his funeral, Frieren tearfully realizes she did not adequately get to
- know him and decides to learn as much about humans as possible. 20 years later, she
- visits Heiter to find that he has adopted a war orphan, nine year old Fern. Heiter,
- suffering from death anxiety in his advanced age, asks Frieren to research
- life-extending magic and tutor Fern in magic in her spare time. She agrees after
- seeing Fern is already remarkably skilled despite her youth.</p>
- </div>
- </div>
- <div id="mp4-details"
- class="container flex sm:w-auto sm:flex-col justify-between lg:min-w-32 items-center sm:items-end gap-3 flex-wrap"
- role="group">
- <section class="flex gap-2">
- <button aria-label="edit details"
- class="p-2 bg-button-100 dark:bg-button-900 rounded-lg ring-violet-500 hover:ring-violet-700 hover:bg-violet-400/50 ring-[0.125rem] ring-inset shadow">Edit
- Details</button>
- <button aria-label="share"
- class="p-2 bg-button-100 dark:bg-button-900 rounded-lg ring-neutral-700 hover:ring-violet-700 hover:bg-violet-400/50 dark:ring-[0.125rem] hover:ring-[0.125rem] ring-inset shadow">
- <CircumShare1 height="24" width="24"/>
- </button>
- </section>
- <section
- class="flex gap flex-col items-end text-sm dark:text-slate-400 text-slate-500 justify-between">
- <p>{{ metaData?.fields.views }}</p>
- <p class="line-clamp-1 truncate">{{ stateVideo?.tags ?? '#atmospheroc #sad #rocky' }}</p>
- </section>
- </div>
- </div>
+ <VideoInfoPanel />
</div>
<!-- <hr id='preData'> -->