diff --git a/Pages/dance/uuid.php b/Pages/dance/uuid.php new file mode 100644 index 0000000..e0a521f --- /dev/null +++ b/Pages/dance/uuid.php @@ -0,0 +1,48 @@ +RunOneSelect( + queryBuilder: SQLQueryBuilderWrapper::SELECT_ONE( + table: 'Dances', + id: $_GET["dance-id"] + ) + ->cols(cols: [ + 'SUM(CASE WHEN T_DR.Rating = 1 THEN 1 ELSE 0 END) AS Likes', + 'SUM(CASE WHEN T_DR.Rating = -1 THEN 1 ELSE 0 END) AS Dislikes', + ]) + ->join( + join: 'LEFT', + spec: 'DanceRatings AS T_DR', + cond: 'T.ID=T_DR.DanceID', + ) +); + +$danceSteps = $db->RunSelect( + queryBuilder: SQLQueryBuilderWrapper::SELECT( + table: 'DanceSteps' + ) + ->where(cond: 'T.DanceID=:__dance_id__') + ->orderBy(spec: [ + 'T.BarCountAtStart ASC', + ]) + ->bindValue(name: '__dance_id__', value: $_GET["dance-id"]) +); + + +TwigWrapper::RenderTwig( + target: "Pages/dance/uuid.html.twig", + arguments: [ + "DanceDetails"=>$danceDetails, + "DanceSteps"=>$danceSteps, + ] +); + diff --git a/Public/Static/JS/General/AlgoliaInteractions.js b/Public/Static/JS/General/AlgoliaInteractions.js index e910044..29964d0 100644 --- a/Public/Static/JS/General/AlgoliaInteractions.js +++ b/Public/Static/JS/General/AlgoliaInteractions.js @@ -68,3 +68,28 @@ function searchTunes(query) { resultsDiv.innerHTML = "

An error occurred. Please try again later.

"; }); } + +function searchDances(query) { + const resultsDiv = document.getElementById("AlgoliaResults"); + + resultsDiv.innerHTML = ""; + + danceIndex.search(query).then(({ hits }) => { + if (hits.length > 0) { + hits.forEach(hit => { + const danceDiv = document.createElement("div"); + danceDiv.className = "AlgoliaDanceHit"; + danceDiv.innerHTML = ` +

${hit.title}

+ +`; + resultsDiv.appendChild(danceDiv); + }); + } else { + resultsDiv.innerHTML = "

No dances found. Try a different search!

"; + } + }).catch(err => { + console.error('Error searching Algolia:', err); + resultsDiv.innerHTML = "

An error occurred. Please try again later.

"; + }); +} diff --git a/Routing/Router.php b/Routing/Router.php index 403d192..44cd938 100644 --- a/Routing/Router.php +++ b/Routing/Router.php @@ -77,6 +77,16 @@ elseif ($requestElements[0] === "tune-set" && isset($requestElements[1])) return true; } } +elseif ($requestElements[0] === "dance" && isset($requestElements[1])) +{ + $_GET['dance-id'] = $requestElements[1]; + + if (count($requestElements) === 2) + { + require_once __DIR__ . '/../Pages/dance/uuid.php'; + return true; + } +} elseif ($requestElements[0] === "create" && isset($requestElements[1])) { switch($requestElements[1]) diff --git a/Templates/Pages/dance/uuid.html.twig b/Templates/Pages/dance/uuid.html.twig new file mode 100644 index 0000000..dcf1694 --- /dev/null +++ b/Templates/Pages/dance/uuid.html.twig @@ -0,0 +1,84 @@ +{% extends "/Bases/StandardWebPage.html.twig" %} + +{% block content %} + + + +
+
+
+
+
+

{{ "Dance Overview"|translate }}

+
+
{{ "Number of Steps"|translate }}
+
{{ DanceSteps|length }}
+
+
+
+

{{ "Rating"|translate }}

+
+ {% if _SESSION_.IS_LOGGED_IN %} + + + {% else %} + {{ "Log in to vote"|translate }} + {% endif %} +
+
+ | + 👎 {{ DanceDetails.Dislikes }} + | + 👍 {{ DanceDetails.Likes }} + | + {{ DanceDetails.Bookmarks }} + | +
+
+
+
+ + + + + + + + + + {% for step in DanceSteps %} + + + + + + {% endfor %} + +
bar frombar untilstep
{{ step.BarCountAtStart }}{{ step.BarCountAtEnd }}{{ step.Description }}
+
+
+
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/Templates/Pages/dances.html.twig b/Templates/Pages/dances.html.twig index 5a8443b..725d036 100644 --- a/Templates/Pages/dances.html.twig +++ b/Templates/Pages/dances.html.twig @@ -1,7 +1,22 @@ {% extends "/Bases/StandardWebPage.html.twig" %} {% block content %} + +

Dance Search

+ +
+ + {% endblock %} \ No newline at end of file diff --git a/Templates/Pages/tune/uuid.html.twig b/Templates/Pages/tune/uuid.html.twig index 341d1ac..137fa1e 100644 --- a/Templates/Pages/tune/uuid.html.twig +++ b/Templates/Pages/tune/uuid.html.twig @@ -73,9 +73,7 @@

{{ "ABC Notation"|translate }}

-
-
-                
+