diff --git a/static/resources_list.txt b/static/resources_list.txt index 025742834..7f90d6bfc 100644 --- a/static/resources_list.txt +++ b/static/resources_list.txt @@ -25,6 +25,9 @@ skin/iso6391To3.js skin/isotope.pkgd.min.js skin/index.js skin/taskbar.css +skin/home.css +skin/fonts/Poppins.ttf +skin/fonts/Roboto.ttf skin/block_external.js templates/search_result.html templates/no_search_result.html diff --git a/static/skin/fonts/Poppins.ttf b/static/skin/fonts/Poppins.ttf new file mode 100644 index 000000000..e90e87ed6 Binary files /dev/null and b/static/skin/fonts/Poppins.ttf differ diff --git a/static/skin/fonts/Roboto.ttf b/static/skin/fonts/Roboto.ttf new file mode 100644 index 000000000..3d6861b42 Binary files /dev/null and b/static/skin/fonts/Roboto.ttf differ diff --git a/static/skin/home.css b/static/skin/home.css new file mode 100644 index 000000000..02e0fd214 --- /dev/null +++ b/static/skin/home.css @@ -0,0 +1,292 @@ +@font-face { + font-family: "poppins"; + src: url("{{root}}/skin/fonts/Poppins.ttf") format("truetype"); +} + +@font-face { + font-family: "roboto"; + src: url("{{root}}/skin/fonts/Roboto.ttf") format("truetype"); +} + +*, +*::after, +*::before { + margin: 0; + padding: 0; + box-sizing: inherit; +} + +html { + font-size: 62.5%; +} + +body { + position: relative; + box-sizing: border-box; +} + +::selection { + background-color: #00b4e4; + color: white; +} + +.kiwixNav { + background-color: #f4f6f8; + width: 100%; + padding: 20px 11vw; + height: 17vh; +} + +.kiwixNav__results { + font-size: 1.3rem; + color: #333333; + font-family: poppins; + margin: 10px 0; +} + +.kiwixNav__filters { + display: grid; + grid-gap: 20px; + grid-template-columns: repeat(7, 1fr); + margin: 10px 0; +} + +.kiwixNav__kiwixFilter { + height: 35px; + width: 231px; + border-radius: 100px; + border: solid 1px #b5b2b2; +} + +.kiwixSearch { + height: 35px; + width: 231px; + border-radius: 100px; + border: solid 1px #b5b2b2; +} + +.kiwixHomeBody { + padding: 20px 15vw; + min-height: 79vh; +} + +.book__list { + position: relative; +} + +.book { + text-decoration: none; +} + +.book__wrapper { + color: #444343; + height: 280px; + width: 250px; + margin: 15px; + background-color: #fcfcfc; + box-shadow: 0 0 5px #acacac; + border-radius: 3px; + display: grid; + grid-template-columns: 65px 1fr; + grid-template-rows: 70px 120px 1fr 1fr; + grid-gap: 5px; + transition: transform 0.25s; +} + +.book__wrapper:hover { + transform: scale(1.07); +} + +.book__icon { + display: flex; + align-items: center; + margin: 10px 0 0 10px; +} + +.book__title { + display: flex; + align-items: center; + font-weight: 500; + font-size: 1.3rem; + font-family: poppins; + color: black; + margin: 10px 10px 0 0; +} + +.book__description { + grid-column: 1 / 3; + margin: 1px 10px; + overflow: hidden; + display: -webkit-box; + -webkit-line-clamp: 9; + -webkit-box-orient: vertical; + font-family: roboto; + font-weight: 300; + color: #4d4d4d; +} + +.book__languageTag { + display: flex; + align-items: center; + justify-content: center; + box-shadow: 0 0 2px #acacac; + background-color: #ffffff; + font-weight: bold; + font-family: roboto; + color: black; + height: 25px; + width: 25px; + margin: 10px auto 0 10px; + border-radius: 5px; +} + +.book__tags { + display: flex; + text-align: right; + margin-right: 10px; + margin-top: 10px; + justify-content: end; + font-family: roboto; + color: #909090; +} + +.book__links { + grid-column: 2 / 3; + font-size: 1.1rem; + margin: 10px; +} + +.book__links > a, .book__links > span { + text-decoration: none; + display: flex; + text-align: right; + justify-content: end; + align-items: flex-end; +} + +.book__links > a { + color: #00b4e4; +} + +.book__links > span { + color: #31353e; +} + +.fadeOut { + position: fixed; + display: none; + bottom: 0; + left: 0; + z-index: 1; + background: linear-gradient(180deg, rgba(232, 232, 232, 0) 0%, #ffffff 100%); + height: 80px; + width: 100%; +} + +.noResults { + position: absolute; + top: 48%; + width: 100%; + text-align: center; + font-size: 1.6rem; +} + +.loader-spinner { + position: absolute; + top: -50%; + left: 50%; + border: 5px solid #f3f3f3; + border-radius: 50%; + border-top: 5px solid #3498db; + width: 40px; + height: 40px; + margin: auto; + -webkit-animation: spin 1s linear infinite; /* Safari */ + animation: spin 1s linear infinite; + margin-top: 35px; + margin-bottom: -35px; + z-index: 2; +} + /* Safari */ +@-webkit-keyframes spin { + 0% { -webkit-transform: rotate(0deg); } + 100% { -webkit-transform: rotate(360deg); } +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} + +.loader { + display: none; + position: relative; + height: 70px; + width: 100%; +} + +.kiwixfooter { + display: flex; + width: 100%; + justify-content: center; + text-align: center; + font-size: 1.6rem; + height: 3vh; +} + +.kiwixfooter > a { + width: auto; +} + +@media screen and (max-width: 1100px) { + + .kiwixHomeBody { + padding: 20px 11vw; + } + + .kiwixNav__filters { + grid-template-columns: repeat(3, 1fr); + } +} + +@media screen and (max-width: 650px) { + .kiwixNav__filters { + grid-template-columns: 1fr; + } +} + +@media screen and (max-height: 900px) { + + .kiwixNav { + height: 31vh; + } + + .kiwixHomeBody { + min-height: 64vh; + } + + .kiwixfooter { + height: 5vh; + } + +} + +@media screen and (max-height: 450px) { + + .kiwixNav { + height: 55vh; + } + + .kiwixHomeBody { + min-height: 39vh; + } + + .kiwixfooter { + height: 5vh; + } + + .noResults { + top: 65%; + } + +} \ No newline at end of file diff --git a/static/skin/index.js b/static/skin/index.js index dc1d12e88..58f550a09 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -46,7 +46,7 @@ } function viewPortToCount(){ - return Math.floor(window.innerHeight/100 + 1)*(window.innerWidth>1000 ? 3 : 2); + return Math.floor(window.innerHeight/300 + 1)*(window.innerWidth>1000 ? 4 : 3); } function getInnerHtml(node, query) { @@ -59,8 +59,26 @@ const description = getInnerHtml(book, 'summary'); const id = getInnerHtml(book, 'id'); const iconUrl = getInnerHtml(book, 'icon'); - const articleCount = getInnerHtml(book, 'articleCount'); - const mediaCount = getInnerHtml(book, 'mediaCount'); + const language = getInnerHtml(book, 'language'); + const tags = getInnerHtml(book, 'tags'); + let tagHtml = tags.split(';').filter(tag => { return !(tag.split(':')[1] && tag.split(':')[1] == 'no')}) + .map((tag) => { + tag = tag.split(':'); + if (tag.length === 1) { + return tag[0].replace(/_/, ' '); + } else if (tag[1] !== 'yes') { + return tag[1].replace(/_/, ' '); + } else { + return (tag[0].indexOf('_') === 0 ? tag[0].replace('_', '') : tag[0]).replace(/_/, ' '); + } + }) + .filter((tag, index, tags) => tags.indexOf(tag) === index).join(' | '); + let downloadLink; + try { + downloadLink = book.querySelector('link[type="application/x-zim"]').getAttribute('href'); + } catch { + downloadLink = ''; + } const linkTag = document.createElement('a'); linkTag.setAttribute('class', 'book'); @@ -69,11 +87,12 @@ if (sort) { linkTag.setAttribute('data-idx', bookOrderMap.get(id)); } - linkTag.innerHTML = `
+ linkTag.innerHTML = `
${title}
${description}
-
${articleCount} articles, ${mediaCount} medias
-
`; +
${language.substr(0, 2).toUpperCase()}
+
${tagHtml}
+
`; return linkTag; } @@ -87,7 +106,6 @@ } async function loadBooks() { - const loader = document.querySelector('.loader'); loader.style.display = 'block'; return await fetch(queryUrlBuilder()).then(async (resp) => { const data = new window.DOMParser().parseFromString(await resp.text(), 'application/xml'); @@ -96,12 +114,14 @@ bookOrderMap.set(getInnerHtml(book, 'id'), idx); }); incrementalLoadingParams.start += books.length; - if (parseInt(data.querySelector('totalResults').innerHTML) === bookOrderMap.size) { + const results = parseInt(data.querySelector('totalResults').innerHTML) + if (results === bookOrderMap.size) { incrementalLoadingParams.count = 0; toggleFooter(true); } else { toggleFooter(); } + document.querySelector('.kiwixNav__results').innerHTML = `Results: ${results} items` loader.style.display = 'none'; return books; }); @@ -131,12 +151,14 @@ resetAndFilter(); filterTypes.forEach(key => {document.getElementsByName(key)[0].value = params.get(key) || ''}); }; + loader.setAttribute('style', 'position: absolute; top: 50%'); } return true; } else if (noResultInjected) { noResultInjected = false; document.getElementsByClassName('noResults')[0].remove(); } + loader.removeAttribute('style'); return false; } @@ -223,7 +245,12 @@ return index ? parseInt(index) : Infinity; } }, - sortBy: 'weight' + sortBy: 'weight', + layoutMode: 'cellsByRow', + cellsByRow: { + columnWidth: '.book', + rowHeight: '.book' + } }); footer = document.getElementById('kiwixfooter'); fadeOutDiv = document.getElementById('fadeOut'); diff --git a/static/skin/isotope.pkgd.min.js b/static/skin/isotope.pkgd.min.js index 7ca671cbe..5461054f2 100644 --- a/static/skin/isotope.pkgd.min.js +++ b/static/skin/isotope.pkgd.min.js @@ -9,4 +9,70 @@ */ !function(t,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,s,a){function u(t,e,o){var n,s="$()."+i+'("'+e+'")';return t.each(function(t,u){var h=a.data(u,i);if(!h)return void r(i+" not initialized. Cannot call methods, i.e. "+s);var d=h[e];if(!d||"_"==e.charAt(0))return void r(s+" is not a valid method");var l=d.apply(h,o);n=void 0===n?l:n}),void 0!==n?n:t}function h(t,e){t.each(function(t,o){var n=a.data(o,i);n?(n.option(e),n._init()):(n=new s(o,e),a.data(o,i,n))})}a=a||e||t.jQuery,a&&(s.prototype.option||(s.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=n.call(arguments,1);return u(this,t,e)}return h(this,t),this},o(a))}function o(t){!t||t&&t.bridget||(t.bridget=i)}var n=Array.prototype.slice,s=t.console,r="undefined"==typeof s?function(){}:function(t){s.error(t)};return o(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},o=i[t]=i[t]||[];return o.indexOf(e)==-1&&o.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},o=i[t]=i[t]||{};return o[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var o=i.indexOf(e);return o!=-1&&i.splice(o,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){i=i.slice(0),e=e||[];for(var o=this._onceEvents&&this._onceEvents[t],n=0;n