diff --git a/assets/js/author.js b/assets/js/author.js index cf93f51..bcf899c 100644 --- a/assets/js/author.js +++ b/assets/js/author.js @@ -1,83 +1,9 @@ -var app = new Vue({ - el: '#app', +var author = new Vue({ + el: '#author', data: { - urlParams: {}, - author: {}, tab: "books" }, methods: { - urlParse: function() { - var match, - pl = /\+/g, // Regex for replacing addition symbol with a space - search = /([^&=]+)=?([^&]*)/g, - decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, - query = window.location.search.substring(1); - while (match = search.exec(query)) - this.urlParams[decode(match[1])] = decode(match[2]); - }, - sendQuery: function(url, error, success) { - var xmh = new XMLHttpRequest(); - var v; - - xmh.onreadystatechange = function() { - v = xmh.responseText; - if (xmh.readyState === 4 && xmh.status === 200) { - var res; - try { - res = JSON.parse(v); - } catch (err) { - if (null !== error) - error(err.name, err.message); - } - if (null !== success) - success(res); - } else if (xmh.readyState === 4) { - if (null !== error) - error(xmh.status, v); - } - }; - - xmh.open('GET', url, true); - xmh.send(null); - }, - stdError: function(code, resp) { - console.log('ERROR ' + code + ': ' + resp); - }, - authorSuccess: function(resp) { - this.author = resp; - document.title = this.author.name +' | Bouquins'; - this.author.series=[]; - this.author.authors=[]; - if (this.author.books) { - var series = []; - var authors = []; - for (var i=0;i 0) { - series.sort(); - this.author.series = [series[0]]; - for (var i=1;i 0) { - authors.sort(); - for (var i=0;i +
{{ if .Id }}
@@ -27,33 +27,32 @@ {{ end }}
+ {{ if gt (len .Series) 0 }}
- {{ range .Books }} - {{/* FIXME unicity */}} - {{ with .Series }} + {{ range .Series }} {{ end }} - {{ end }}
+ {{ end }} + {{ if gt (len .CoAuthors) 0 }}
- {{ range .Books }} - {{ range .Authors }} + {{ range .CoAuthors }} {{ end }} - {{ end }}
+ {{ end }} {{ else }} {{ end }} diff --git a/templates/footer.html b/templates/footer.html index 0699545..fa0fc93 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,3 +1,6 @@ + {{ if .PageJs }} + + {{ end }} diff --git a/templates/header.html b/templates/header.html index 84e90e0..c8280cb 100644 --- a/templates/header.html +++ b/templates/header.html @@ -5,6 +5,12 @@ + + + {{ if .PageJs }} + + + {{ end }}