diff --git a/.gitignore b/.gitignore index 15445f2..6852bac 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ media # If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/ # in your Git repository. Update and uncomment the following line accordingly. # /staticfiles/ +static/ ### Python ### # Byte-compiled / optimized / DLL files diff --git a/live_share_youtube/settings.py b/live_share_youtube/settings.py index c1f33e9..aa29c5e 100644 --- a/live_share_youtube/settings.py +++ b/live_share_youtube/settings.py @@ -108,7 +108,10 @@ USE_TZ = True STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') MEDIA_URL = '/media/' -MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media') +MEDIA_ROOT = os.path.join(BASE_DIR, 'media') +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, 'static_files'), +] LOGIN_REDIRECT_URL = "/" LOGOUT_REDIRECT_URL = "/" diff --git a/live_share_youtube/urls.py b/live_share_youtube/urls.py index 14dbad9..7cf67ae 100644 --- a/live_share_youtube/urls.py +++ b/live_share_youtube/urls.py @@ -15,8 +15,16 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.conf import settings +from django.contrib.staticfiles import views +from django.urls import re_path urlpatterns = [ path('admin/', admin.site.urls), path('', include('player.urls')), ] + +if settings.DEBUG: + urlpatterns += [ + re_path(r'^static/(?P.*)$', views.serve), + ] diff --git a/player/templates/player/playlist.html b/player/templates/player/playlist.html index ebb4366..c80e4f3 100644 --- a/player/templates/player/playlist.html +++ b/player/templates/player/playlist.html @@ -1,9 +1,20 @@ {% extends "base.html" %} {% load bootstrap4 %} +{% load staticfiles %} {% block title %} - {{playlist.name}}{% endblock %} +{% block js %}{% endblock %} + {% block content %} + +

{{playlist.name}}

@@ -41,135 +52,6 @@ {% bootstrap_form form %} -

Pistes à venir

diff --git a/static_files/js/playlist.js b/static_files/js/playlist.js new file mode 100644 index 0000000..b321f63 --- /dev/null +++ b/static_files/js/playlist.js @@ -0,0 +1,122 @@ + // 2. This code loads the IFrame Player API code asynchronously. +var tag = document.createElement('script'); +var current_link = -1; +tag.src = "https://www.youtube.com/iframe_api"; +var firstScriptTag = document.getElementsByTagName('script')[0]; +firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); +var last_sync = new Date().getTime(); +// 3. This function creates an