Skip to content

Commit

Permalink
Merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienCozeDev committed Dec 14, 2023
2 parents 929e018 + 853b733 commit 113d0b7
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 105 deletions.
5 changes: 2 additions & 3 deletions pod/completion/static/js/caption_maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ document.addEventListener("DOMContentLoaded", function () {

send_form_data(url, data, "processProxyVttResponse");
} else {
document.getElementById(
"captionFilename",
).value = `${file_prefix}_captions_${Date.now()}`;
document.getElementById("captionFilename").value =
`${file_prefix}_captions_${Date.now()}`;
}

let placeholder = gettext(
Expand Down
5 changes: 5 additions & 0 deletions pod/main/static/css/pod.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
--third-background-color: var(--pod-background-neutre1-bloc) !important;
}

.progress,
.progress-stacked {
--bs-progress-bar-bg: var(--pod-primary);
}

:root[data-dyslexia="on"] {
--bs-body-font-family: var(--pod-font-family-dyslexie);
}
Expand Down
1 change: 1 addition & 0 deletions pod/main/templates/admin/base_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// Set the body data-theme attribute to match the local storage item
document.documentElement.dataset.theme = currentTheme?currentTheme:"light";
document.documentElement.dataset.bsTheme = currentTheme?currentTheme:"light";
document.documentElement.dataset.colorScheme = currentTheme?currentTheme:"light";
</script>
{% endif %}

Expand Down
3 changes: 3 additions & 0 deletions pod/main/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ <h1 class="page_title">{{page_title|capfirst}}</h1>
// Set the body data-theme attribute to match the local storage item
document.documentElement.dataset.theme = currentTheme?currentTheme:"light";
document.documentElement.dataset.bsTheme = currentTheme?currentTheme:"light";
document.documentElement.dataset.colorScheme = currentTheme?currentTheme:"light";
// If the current theme is dark, check the theme toggle
if (currentTheme === "dark") {
themeToggle.checked = true;
Expand All @@ -236,10 +237,12 @@ <h1 class="page_title">{{page_title|capfirst}}</h1>
if (e.target.checked) {
document.documentElement.dataset.theme = "dark";
document.documentElement.dataset.bsTheme = "dark";
document.documentElement.dataset.colorScheme = "dark";
localStorage.setItem("theme", "dark");
} else {
document.documentElement.dataset.theme = "light";
document.documentElement.dataset.bsTheme = "light";
document.documentElement.dataset.colorScheme = "light";
localStorage.setItem("theme", "light");
}
}
Expand Down
84 changes: 74 additions & 10 deletions pod/peer_to_peer/static/peer_to_peer/js/p2p-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,53 @@ console.log('P2P SCRIPT LOADED');

console.log('player', player);

let videoSlug = '47858-rabbit-and-others' // TODO Set the true identifier
/**
* Video identifier for the current session.
* @type {string}
* @default string // TODO Set true ID
*/
let videoSlug = '47858-rabbit-and-others';

/**
* List of URLs related to the video.
* @type {Array}
* @default []
*/
let urlList = [];

/**
* Cache for storing core data associated with URLs.
* @type {Object}
* @default {}
*/
let coreCache = [];

let peer; // TODO Update this ?
/**
* Peer object for peer-to-peer communication.
* @type {Peer}
* @default undefined // TODO Update this ?
*/
let peer;

/**
* Flag indicating whether it's the first time performing an action.
* @type {boolean}
* @default false
*/
let firstTime = false;

/**
* The connected identifier.
* @type {string}
* @default ""
*/
let connectedId = "";


/**
* Establishes a peer-to-peer connection using the provided options.
* @param {Object} options - Configuration options for the Peer object.
* @returns {void}
*/
async function startConnect(options) {
console.log('[p2p-script.js] startConnect()');
let uuid = crypto.randomUUID();
Expand All @@ -23,6 +57,7 @@ async function startConnect(options) {
console.log("Peer:", peer);

const idList = await getIds();
console.log('idList', idList);
if (idList.length <= 1) {
// TODO Make CDN live function and call this here
} else {
Expand All @@ -49,14 +84,16 @@ async function startConnect(options) {

peer.on('connection', function (conn) {
console.log('CONNECTION');
conn.on('data', function(data) {
conn.on('data', function (data) {
console.log(data);
});
});
}

/**
* Get the peer identifiers.
* Retrieves peer identifiers associated with the current video.
* @async
* @returns {Array} - A list of peer identifiers.
*/
async function getIds() {
console.log('[p2p-script.js] getIds()');
Expand All @@ -80,6 +117,11 @@ async function getIds() {
return idList;
}

/**
* Stores URLs associated with the current peer's ID on the server.
* @async
* @returns {void}
*/
async function storeUrlsId() {
console.log('[p2p-script.js] storeUrlsId()');
let fetch_status;
Expand Down Expand Up @@ -114,8 +156,20 @@ async function storeUrlsId() {

// TODO Call the function

/**
* Sets up event hooks and overrides XHR behavior when the 'xhr-hooks-ready' event is triggered on the video player.
* @listens player#xhr-hooks-ready
* @returns {void}
*/
player.on('xhr-hooks-ready', () => {
console.log('[p2p-script.js] xhr-hooks-ready event');

/**
* Handles the response hook for XHR requests.
* @param {Object} request - The XHR request object.
* @param {Object} error - The XHR error object.
* @param {Object} response - The XHR response object.
*/
const playerOnResponseHook = (request, error, response) => {
// console.log('[p2p-script.js] Inside playerOnResponseHook');
// console.log('[p2p-script.js] content_type:', content_type);
Expand All @@ -133,6 +187,11 @@ player.on('xhr-hooks-ready', () => {
// }
}

/**
* Handles the request hook for XHR requests.
* @param {Object} options - The XHR options object.
* @returns {Object} - Modified XHR options object.
*/
const playerOnRequestHook = (options) => {
let headers = options['headers'];
if (headers && headers['Range']) {
Expand All @@ -144,8 +203,14 @@ player.on('xhr-hooks-ready', () => {
}

console.log('[p2p-script.js] player.tech().vhs.xhr:', player.tech().vhs.xhr);
player.tech().vhs.xhr = function(urlC, callback) {
// console.log("URLC CALLLLLLLL", urlC, callback);

/**
* Overrides the XHR behavior on the video player.
* @param {string|Object} urlC - The URL or XHR options.
* @param {Function} callback - The XHR callback function.
* @returns {Object} - XHR result.
*/
player.tech().vhs.xhr = function (urlC, callback) {
let url = '';
// console.log('[p2p-script.js] player.tech().vhs.xhr');
if (typeof urlC === 'object') {
Expand All @@ -171,7 +236,7 @@ player.on('xhr-hooks-ready', () => {
videojs.Vhs.xhr.onResponse(playerOnResponseHook);
return videojs.Vhs.xhr(urlC, callback);
}
// } else {
// } else {
// url = urlC.url;
// videojs.Vhs.xhr.onResponse(playerOnResponseHook);
// return videojs.Vhs.xhr(urlC, callback);
Expand All @@ -187,5 +252,4 @@ player.on('xhr-hooks-ready', () => {
});


startConnect({host:"127.0.0.1", port:"9000", path: '/', key: 'peerjs', debug:3});

startConnect({ host: "127.0.0.1", port: "9000", path: '/', key: 'peerjs', debug: 3 });
56 changes: 14 additions & 42 deletions pod/playlist/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ class PlaylistFormTest(TestCase):

@override_settings(USE_PLAYLIST=True)
def test_valid_data_for_public_playlist(self):
"""
Test the form with valid data for a public playlist.
"""
"""Test the form with valid data for a public playlist."""
form = PlaylistForm(
data={
"name": "Test Playlist",
Expand All @@ -42,9 +40,7 @@ def test_valid_data_for_public_playlist(self):

@override_settings(USE_PLAYLIST=True)
def test_valid_data_for_private_playlist(self):
"""
Test the form with valid data for a private playlist.
"""
"""Test the form with valid data for a private playlist."""
form = PlaylistForm(
data={
"name": "Test Playlist",
Expand All @@ -60,9 +56,7 @@ def test_valid_data_for_private_playlist(self):

@override_settings(USE_PLAYLIST=True)
def test_valid_data_for_protected_playlist(self):
"""
Test the form with valid data for a protected playlist.
"""
"""Test the form with valid data for a protected playlist."""
form = PlaylistForm(
data={
"name": "Test Playlist",
Expand All @@ -78,9 +72,7 @@ def test_valid_data_for_protected_playlist(self):

@override_settings(USE_PLAYLIST=True)
def test_invalid_data_for_protected_playlist(self):
"""
Test the form with invalid data for a protected playlist.
"""
"""Test the form with invalid data for a protected playlist."""
form = PlaylistForm(
data={
"name": "Test Playlist",
Expand All @@ -96,9 +88,7 @@ def test_invalid_data_for_protected_playlist(self):

@override_settings(USE_PLAYLIST=True)
def test_name_validation_for_public_playlist(self):
"""
Test if the name validation works correctly for a public playlist.
"""
"""Test if the name validation works correctly for a public playlist."""
valid_form = PlaylistForm(
data={
"name": "Valid Name",
Expand All @@ -121,9 +111,7 @@ def test_name_validation_for_public_playlist(self):

@override_settings(USE_PLAYLIST=True)
def test_name_validation_for_private_playlist(self):
"""
Test if the name validation works correctly for a private playlist.
"""
"""Test if the name validation works correctly for a private playlist."""
valid_form = PlaylistForm(
data={
"name": "Valid Name",
Expand All @@ -146,9 +134,7 @@ def test_name_validation_for_private_playlist(self):

@override_settings(USE_PLAYLIST=True)
def test_name_validation_for_protected_playlist(self):
"""
Test if the name validation works correctly for a protected playlist.
"""
"""Test if the name validation works correctly for a protected playlist."""
valid_form = PlaylistForm(
data={
"name": "Valid Name",
Expand All @@ -173,9 +159,7 @@ def test_name_validation_for_protected_playlist(self):

@override_settings(USE_PLAYLIST=True)
def test_blank_data_for_public_playlist(self):
"""
Test the form with blank data for a public playlist.
"""
"""Test the form with blank data for a public playlist."""
form = PlaylistForm(data={})
self.assertFalse(form.is_valid())
self.assertLessEqual(1, len(form.errors))
Expand All @@ -192,18 +176,14 @@ class PlaylistRemoveFormTest(TestCase):

@override_settings(USE_PLAYLIST=True)
def test_valid_data(self):
"""
Test the form with valid data.
"""
"""Test the form with valid data."""
form = PlaylistRemoveForm(data={"agree": True})
self.assertTrue(form.is_valid())
print(" ---> test_valid_data ok")

@override_settings(USE_PLAYLIST=True)
def test_agree_required(self):
"""
Test the form with agree field not selected and not provided.
"""
"""Test the form with agree field not selected and not provided."""
agree_not_selected_form = PlaylistRemoveForm(data={"agree": False})
agree_not_provided_form = PlaylistRemoveForm(data={})
self.assertFalse(agree_not_selected_form.is_valid())
Expand All @@ -220,9 +200,7 @@ def test_agree_required(self):

@override_settings(USE_PLAYLIST=True)
def test_blank_data(self):
"""
Test the form with empty data.
"""
"""Test the form with empty data."""
form = PlaylistRemoveForm(data={})
self.assertFalse(form.is_valid())
self.assertEqual(len(form.errors), 1)
Expand All @@ -240,18 +218,14 @@ class PlaylistPasswordFormTests(TestCase):

@override_settings(USE_PLAYLIST=True)
def test_valid_data(self):
"""
Test the form with valid data.
"""
"""Test the form with valid data."""
form = PlaylistPasswordForm(data={"password": PWD})
self.assertTrue(form.is_valid())
print(" ---> test_valid_data ok")

@override_settings(USE_PLAYLIST=True)
def test_password_required(self):
"""
Test the form with password field empty and not provided.
"""
"""Test the form with password field empty and not provided."""
password_not_provided_form = PlaylistPasswordForm(data={})
empty_password_form = PlaylistPasswordForm(data={"password": ""})
self.assertFalse(password_not_provided_form.is_valid())
Expand All @@ -268,9 +242,7 @@ def test_password_required(self):

@override_settings(USE_PLAYLIST=True)
def test_blank_data(self):
"""
Test the form with empty data.
"""
"""Test the form with empty data."""
form = PlaylistPasswordForm(data={})
self.assertFalse(form.is_valid())
self.assertEqual(len(form.errors), 1)
Expand Down
10 changes: 8 additions & 2 deletions pod/recorder/studio_urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Opencast Studio urls for Esup-Pod Integration."""
from django.conf.urls import url
from .views import studio_pod, studio_static, settings_toml, info_me_json
from .views import studio_pod, studio_static, studio_root_file
from .views import ingest_createMediaPackage, ingest_addDCCatalog
from .views import ingest_addAttachment, ingest_addTrack
from .views import ingest_addCatalog, ingest_ingest
from .views import presenter_post
from .views import presenter_post, settings_toml, info_me_json

app_name = "recorder"
urlpatterns = [
Expand Down Expand Up @@ -32,6 +33,11 @@
studio_static,
name="studio_static",
),
url(
r"^(?P<file>[a-zA-Z0-9\.]*)$",
studio_root_file,
name="studio_root_file",
),
url(
r"^ingest/createMediaPackage$",
ingest_createMediaPackage,
Expand Down
Loading

0 comments on commit 113d0b7

Please sign in to comment.