diff --git a/src/main/java/org/forkalsrud/album/web/AlbumServlet.java b/src/main/java/org/forkalsrud/album/web/AlbumServlet.java index 8a22191..484b05d 100644 --- a/src/main/java/org/forkalsrud/album/web/AlbumServlet.java +++ b/src/main/java/org/forkalsrud/album/web/AlbumServlet.java @@ -215,6 +215,14 @@ public class AlbumServlet return; } + if ("/_roots.json".equals(pathInfo)) { + res.setContentType("application/json"); + res.setCharacterEncoding("UTF-8"); + PrintWriter out = res.getWriter(); + out.append("[\"").append(base.getName()).append("\"]"); + return; + } + long now = System.currentTimeMillis(); if (now > nextCacheRefresh) { cachedRootNode = null; diff --git a/src/main/webapp/album.js b/src/main/webapp/album.js index e7896f1..1748e91 100644 --- a/src/main/webapp/album.js +++ b/src/main/webapp/album.js @@ -1,13 +1,29 @@ var album = angular.module("album", [ ]); -album.controller("AlbumController", ["$http", "$log", function($http, $log) { +album.controller("AlbumController", ["$http", "$log", "$scope", function($http, $log, $scope) { var alb = this; + this.roots = [ ]; this.items = [ ]; this.update = function() { $log.info("updating..."); - $http.get("/photo/album/Downloads.json").success(function(data) { - alb.items = data.contents; - }); + if (alb.roots.length == 0) { + $http.get("/photo/album/_roots.json").success(function(data) { + alb.roots = data; + alb.update(); + }); + } else { + $http.get("/photo/album/" + alb.roots[0] + ".json").success(function(data) { + alb.items = data.contents; + for (var i = 0; i < alb.items.length; i++) { + if (alb.items[i].type == "movie") { + alb.items[i].path += ".frame"; + } + } + }); + } } + $scope.$watch('$viewContentLoaded', function(){ + alb.update(); + }); }]); diff --git a/src/main/webapp/ang.html b/src/main/webapp/ang.html index 338f614..b0d8375 100644 --- a/src/main/webapp/ang.html +++ b/src/main/webapp/ang.html @@ -3,11 +3,18 @@
+ -