From 3453ab92ef205eb430cb3ae2dce4d8c0d4292b93 Mon Sep 17 00:00:00 2001 From: Meutel Date: Sat, 7 Jan 2017 21:19:45 +0100 Subject: [PATCH] Author page and links --- Makefile | 4 +-- author.html | 63 ++++++++++++++++++++++++++++++++ author.js | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++ book.html | 8 ++++- index.html | 11 ++++-- 5 files changed, 181 insertions(+), 6 deletions(-) create mode 100644 author.html create mode 100644 author.js diff --git a/Makefile b/Makefile index 10cd56e..b1ded72 100644 --- a/Makefile +++ b/Makefile @@ -60,8 +60,8 @@ sinclude GNUmakefile.local DATABASE = metadata.db OBJS = db.o json.o main.o -HTMLS = index.html book.html -JSMINS = index.min.js book.min.js +HTMLS = index.html book.html author.html +JSMINS = index.min.js book.min.js author.min.js EXTJS = externals/vue.min.js CSS = externals/bootstrap.min.css FONTS = externals/fonts/* diff --git a/author.html b/author.html new file mode 100644 index 0000000..bbf84e1 --- /dev/null +++ b/author.html @@ -0,0 +1,63 @@ + + + + Auteur | Bouquins + + + + + + + + + +
+ + + + +
+
+ +
+
+
+
+
    +
  • + {{ series.name }} +
  • +
+
+
+
+
+ +
+
+
+ + + + + diff --git a/author.js b/author.js new file mode 100644 index 0000000..cf93f51 --- /dev/null +++ b/author.js @@ -0,0 +1,101 @@ +var app = new Vue({ + el: '#app', + 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
+