diff --git a/src/routes/util.ts b/src/routes/util.ts index 1da4bcd..944a3cd 100644 --- a/src/routes/util.ts +++ b/src/routes/util.ts @@ -253,6 +253,7 @@ export function adminAuth (req: Request, res: Response, next: NextFunction) { // Render a page export function renderPage(req: Request, res: Response, page: string, options: any) { options = options || {}; + options.url = req.originalUrl; services.MetaService.getMeta('Version', (version) => { options.version = version; if (!req.session || !req.session.sessionId) { diff --git a/src/static/css/main.css b/src/static/css/main.css index 171af9a..7173e3d 100644 --- a/src/static/css/main.css +++ b/src/static/css/main.css @@ -157,6 +157,10 @@ footer .footer-list-link { padding: 0px 20px; } +#index .card-link { + text-decoration: none; +} + #index .thumbnail { width: 250px; height: 250px; diff --git a/src/static/js/index.js b/src/static/js/index.js index 2e7629f..73c638d 100644 --- a/src/static/js/index.js +++ b/src/static/js/index.js @@ -14,62 +14,67 @@ function deleteLastBook() { function addBook(book) { var courseNumber = book.coursenumber ? ' ' + book.coursenumber : ''; //
- var newBook = document.createElement('div'); - newBook.classList.add('card-container', 'col-12', 'col-md-6', 'col-lg-4', 'mb-4'); - //
- var newCard = document.createElement('div'); - newCard.classList.add('card'); - newCard.style = 'width: 18rem;'; - var imgLink = document.createElement('a'); - imgLink.href = `/book/${book.bookid}` - newCard.appendChild(imgLink) - // ... - var newImg = document.createElement('img'); - newImg.src = book.imageurl; - newImg.classList.add('card-img-top', 'thumbnail', 'p-1', 'pt-3'); - newImg.alt = '...'; - imgLink.appendChild(newImg); - //
- var cardBody = document.createElement('div'); - cardBody.classList.add('card-body'); - //
- var spaceBetween = document.createElement('div'); - spaceBetween.classList.add('space-between'); - // - var bookLink = document.createElement('a'); - bookLink.href = `/book/${book.bookid}`; - // ${book.title} - var bookTitle = document.createElement('span'); - bookTitle.classList.add('title'); - bookTitle.innerText = book.title; + var newBookLink = document.createElement('a'); + newBookLink.classList.add('card-link'); + newBookLink.href = `/book/${book.bookid}`; + var newBook = document.createElement('div'); + newBook.classList.add('card-container', 'col-12', 'col-md-6', 'col-lg-4', 'mb-4'); + //
+ var newCard = document.createElement('div'); + newCard.classList.add('card'); + newCard.style = 'width: 18rem;'; + var imgLink = document.createElement('a'); + imgLink.href = `/book/${book.bookid}`; + newCard.appendChild(imgLink); + // ... + var newImg = document.createElement('img'); + newImg.src = book.imageurl; + newImg.classList.add('card-img-top', 'thumbnail', 'p-1', 'pt-3'); + newImg.alt = '...'; + imgLink.appendChild(newImg); + //
+ var cardBody = document.createElement('div'); + cardBody.classList.add('card-body'); + //
+ var spaceBetween = document.createElement('div'); + spaceBetween.classList.add('space-between'); + // + var bookLink = document.createElement('a'); + bookLink.href = `/book/${book.bookid}`; + // ${book.title} + var bookTitle = document.createElement('span'); + bookTitle.classList.add('title'); + bookTitle.innerText = book.title; + // + bookLink.appendChild(bookTitle); + // + spaceBetween.appendChild(bookLink); + // $${book.price} + var cardPrice = document.createElement('span'); + cardPrice.classList.add('card-price'); + cardPrice.innerText = `$${book.price}`; // - bookLink.appendChild(bookTitle); - // - spaceBetween.appendChild(bookLink); - // $${book.price} - var cardPrice = document.createElement('span'); - cardPrice.classList.add('card-price'); - cardPrice.innerText = `$${book.price}`; - // - spaceBetween.appendChild(cardPrice); + spaceBetween.appendChild(cardPrice); + //
+ cardBody.appendChild(spaceBetween); + //
By: ${book.author} + var authorDiv = document.createElement('div'); + authorDiv.innerText = `By: ${book.author}`; + //
+ cardBody.appendChild(authorDiv); + //
${book.department}${courseNumber} + var departmentDiv = document.createElement('div'); + departmentDiv.innerText = book.department + courseNumber; + //
+ cardBody.appendChild(departmentDiv); //
- cardBody.appendChild(spaceBetween); - //
By: ${book.author} - var authorDiv = document.createElement('div'); - authorDiv.innerText = `By: ${book.author}`; - //
- cardBody.appendChild(authorDiv); - //
${book.department}${courseNumber} - var departmentDiv = document.createElement('div'); - departmentDiv.innerText = book.department + courseNumber; - //
- cardBody.appendChild(departmentDiv); + newCard.appendChild(cardBody); //
- newCard.appendChild(cardBody); + newBook.appendChild(newCard); //
- newBook.appendChild(newCard); - //
- document.getElementById('index').appendChild(newBook); + newBookLink.appendChild(newBook); + // + document.getElementById('index').appendChild(newBookLink); } // Load more books using AJAX diff --git a/src/views/layouts/default.html b/src/views/layouts/default.html index cd5b8f4..1db3943 100644 --- a/src/views/layouts/default.html +++ b/src/views/layouts/default.html @@ -3,14 +3,21 @@ - + + + + + + {{#if title}} - {{title}} - Norse Books + + {{title}} - NorseBooks {{else}} - Norse Books + + NorseBooks {{/if}}