From ea56219fa1e900d3c06162ae112b4c97adbe3d1b Mon Sep 17 00:00:00 2001 From: nemunaire Date: Wed, 21 Nov 2018 03:10:35 +0100 Subject: [PATCH] frontend: display tags and add new page to filter exercices by tag --- configs/nginx-fic-static.conf | 4 ++++ configs/nginx-frontend-htpasswd.conf | 3 +++ configs/nginx-prod.conf | 5 +++++ frontend/static/js/challenge.js | 23 +++++++++++++++++++++++ frontend/static/views/tag.html | 12 ++++++++++++ frontend/static/views/theme.html | 1 + 6 files changed, 48 insertions(+) create mode 100644 frontend/static/views/tag.html diff --git a/configs/nginx-fic-static.conf b/configs/nginx-fic-static.conf index 1d1e2222..6f5ad1f5 100644 --- a/configs/nginx-fic-static.conf +++ b/configs/nginx-fic-static.conf @@ -31,4 +31,8 @@ server { location /rank { rewrite ^/.*$ /index.html; } + + location /tags/ { + rewrite ^/.*$ /index.html; + } } diff --git a/configs/nginx-frontend-htpasswd.conf b/configs/nginx-frontend-htpasswd.conf index 9d2abc99..f47565ca 100644 --- a/configs/nginx-frontend-htpasswd.conf +++ b/configs/nginx-frontend-htpasswd.conf @@ -28,6 +28,9 @@ server { location /rank { rewrite ^/.*$ /index.html; } + location /tags/ { + rewrite ^/.*$ /index.html; + } location /register { rewrite ^/.*$ /index.html; } diff --git a/configs/nginx-prod.conf b/configs/nginx-prod.conf index cc8a8ff0..391488a7 100644 --- a/configs/nginx-prod.conf +++ b/configs/nginx-prod.conf @@ -68,6 +68,11 @@ server { rewrite ^/.*$ /index.html; } + location /tags/ { + include fic-auth.conf; + + rewrite ^/.*$ /index.html; + } location /register { include fic-auth.conf; diff --git a/frontend/static/js/challenge.js b/frontend/static/js/challenge.js index a90c1c8b..23fd82c3 100644 --- a/frontend/static/js/challenge.js +++ b/frontend/static/js/challenge.js @@ -21,6 +21,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) controller: "VideosController", templateUrl: "views/videos.html" }) + .when("/tags/:tag", { + controller: "TagController", + templateUrl: "views/tag.html" + }) .when("/:theme", { controller: "ExerciceController", templateUrl: "views/theme.html" @@ -466,6 +470,25 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) $location.url("/"); } }) + .controller("TagController", function($scope, $rootScope, $routeParams) { + $rootScope.current_theme = 0; + $rootScope.current_exercice = 0; + $rootScope.title = "Challenges " + $routeParams.tag; + $rootScope.authors = ""; + + $scope.tag = $routeParams.tag; + $scope.exercices = []; + + $scope.$watch("themes", function(themes) { + $scope.exercices = []; + angular.forEach(themes, function(theme, tid) { + angular.forEach(theme.exercices, function(exercice, eid) { + if (exercice.tags.indexOf($scope.tag) >= 0) + $scope.exercices.push({"exercice": exercice, "theme": theme, "eid": eid, "tid": tid}); + }) + }) + }) + }) .controller("RankController", function($scope, $rootScope) { $rootScope.current_theme = 0; $rootScope.current_exercice = 0; diff --git a/frontend/static/views/tag.html b/frontend/static/views/tag.html new file mode 100644 index 00000000..2d887cdd --- /dev/null +++ b/frontend/static/views/tag.html @@ -0,0 +1,12 @@ +
+
+
+
+ {{ex.theme.name}} > + {{ex.exercice.title}} + #{{ tag }} +
+

Sunt omnis est quibusdam aperiam quos minima numquam. Omnis eos corrupti corrupti quia ut.

+
+
+
diff --git a/frontend/static/views/theme.html b/frontend/static/views/theme.html index d2e36fb2..8d781bae 100644 --- a/frontend/static/views/theme.html +++ b/frontend/static/views/theme.html @@ -20,6 +20,7 @@

{{ themes[current_theme].exercices[current_exercice].title }}

+