diff --git a/babel.config.json b/babel.config.json deleted file mode 100644 index 1320b9a327..0000000000 --- a/babel.config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@babel/preset-env"] -} diff --git a/datas/metadata.py b/datas/metadata.py index f78c8cf040..7dc744a2e7 100644 --- a/datas/metadata.py +++ b/datas/metadata.py @@ -4348,6 +4348,40 @@ class Speaker(SpeakerRequired, total=False): }, }, }, + "Dayton Audio OPAL1": { + "skip": True, + "brand": "Dayton Audio", + "model": "OPAL1", + "type": "passive", + "price": "800", + "amount": "pair", + "shape": "bookshelves", + "default_measurement": "eac", + "measurements": { + "eac": { + "origin": "ErinsAudioCorner", + "format": "klippel", + "reviews": { + "eac": "https://www.erinsaudiocorner.com/loudspeakers/dayton_opal1/", + "yt": "https://youtu.be/BDv222LHNM0", + }, + "review_published": "202404xx", + "specifications": { + "sensitivity": 78.5, + "impedance": 4.3, + "SPL": { + "peak": 102, + }, + "size": { + "height": 356, + "width": 178, + "depth": 241, + }, + "weight": 9.4, + }, + }, + }, + }, "DB Audiotechnik 8S": { "brand": "DB Audiotechnik", "model": "8S", @@ -22542,6 +22576,41 @@ class Speaker(SpeakerRequired, total=False): }, }, }, + "Wharfedale Super Denton": { + "skip": True, + "brand": "Wharfedale", + "model": "Super Denton", + "type": "passive", + "price": "1400", + "amount": "pair", + "shape": "bookshelves", + "default_measurement": "eac", + "measurements": { + "eac": { + "origin": "ErinsAudioCorner", + "format": "klippel", + "reviews": { + "eac": "https://www.erinsaudiocorner.com/loudspeakers/wharfedale_super_denton/", + "yt": "https://youtu.be/5Xb9Ku0Fy_E", + }, + "review_published": "202404xx", + "specifications": { + "sensitivity": 87, + "impedance": 3.4, + "SPL": { + "peak": 103, + }, + "size": { + "height": 360, + "width": 246, + "depth": 295, + }, + "weight": 9.2, + }, + }, + }, + }, + "Wilson Audio TuneTot": { "brand": "Wilson Audio", "model": "TuneTot", diff --git a/datas/template.py b/datas/template.py new file mode 100644 index 0000000000..e3f1259c30 --- /dev/null +++ b/datas/template.py @@ -0,0 +1,36 @@ + "": { + "skip": True, + "brand": "", + "model": "", + "type": "passive", + "price": "", + "amount": "pair", + "shape": "bookshelves", + "default_measurement": "eac", + "measurements": { + "eac": { + "origin": "ASR", + "origin": "ErinsAudioCorner", + "format": "klippel", + "reviews": { + "asr": "", + "eac": "", + "yt": "", + }, + "review_published": "202404xx", + "specifications": { + "sensitivity": , + "impedance": , + "SPL": { + "peak": , + }, + "size": { + "height": , + "width": , + "depth": , + }, + "weight": , + }, + }, + }, + }, diff --git a/generate_html.py b/generate_html.py index 3778abbd53..d37bc34e54 100755 --- a/generate_html.py +++ b/generate_html.py @@ -284,7 +284,7 @@ def main(): meta = json.load(f) # load versions for various css and js files - versions = get_versions("./update_3rdparties.sh") + versions = get_versions("{}/update_3rdparties.sh".format(cpaths.CPATH_SCRIPTS)) # only build a dictionnary will all graphs main_df = {} @@ -316,7 +316,8 @@ def main(): # configure Mako mako_templates = TemplateLookup( - directories=["src/website"], module_directory="./build/mako_modules" + directories=[cpaths.CPATH_WEBSITE, cpaths.CPATH_BUILD_WEBSITE], + module_directory=cpaths.CPATH_BUILD_MAKO, ) # write index.html @@ -436,37 +437,25 @@ def main(): "pmc.png", "revel.png", "spin.svg", - "volume-0.svg", - "volume-1.svg", - "volume-2.svg", - "volume-3.svg", - "volume-4.svg", - "volume-5.svg", - "volume-danger-0.svg", - "volume-danger-1.svg", - "volume-danger-2.svg", - "volume-danger-3.svg", - "volume-info-0.svg", - "volume-info-1.svg", - "volume-info-2.svg", - "volume-info-3.svg", - "volume-success-0.svg", - "volume-success-1.svg", - "volume-success-2.svg", - "volume-success-3.svg", - "volume.svg", ]: file_in = cpaths.CPATH_DATAS_ICONS + "/" + f - file_out = cpaths.CPATH_DOCS + "/" + f + file_out = cpaths.CPATH_DOCS + "/pictures/" + f shutil.copy(file_in, file_out) # copy custom css for f in [ "spinorama.css", + ]: + file_in = cpaths.CPATH_WEBSITE + "/" + f + file_out = cpaths.CPATH_DOCS + "/css/" + f + shutil.copy(file_in, file_out) + + # copy manifest + for f in [ "manifest.json", ]: file_in = cpaths.CPATH_WEBSITE + "/" + f - file_out = cpaths.CPATH_DOCS + "/svg" + f + file_out = cpaths.CPATH_DOCS + "/" + f shutil.copy(file_in, file_out) # cleanup flow directives: currently unused @@ -478,7 +467,7 @@ def main(): flow_param, cpaths.CPATH_WEBSITE, "--out-dir", - cpaths.CPATH_DOCS, + cpaths.CPATH_BUILD_WEBSITE, ) status = subprocess.run( [flow_command], shell=True, check=True, capture_output=True # noqa: S602 @@ -487,7 +476,7 @@ def main(): print("flow failed") # copy css/js files - logger.info("Copy js files to %s", cpaths.CPATH_DOCS) + logger.info("Copy js files to %s", cpaths.CPATH_DOCS_JS) try: for item in ( "compare", @@ -498,6 +487,7 @@ def main(): "meta", "misc", "onload", + "pagination", "plot", "scores", "search", @@ -532,21 +522,26 @@ def main(): min=".min" if flag_optim else "", versions=versions, ) - item_filename = "{}/{}-{}.js".format(cpaths.CPATH_DOCS, item, CACHE_VERSION) - write_if_different(item_content, item_filename, force=False) + item_filename = "{}/{}-1-gen.js".format(cpaths.CPATH_BUILD_WEBSITE, item) + write_if_different(item_content, item_filename, force=True) # compress files with terser if flag_optim: - terser_command = "{0} {1}/{2} > {1}/{3}".format( + terser_command = "{0} {1}/{2} > {3}/{4}".format( "./node_modules/.bin/terser", - cpaths.CPATH_DOCS, - "{}-{}.js".format(item, CACHE_VERSION), + cpaths.CPATH_BUILD_WEBSITE, + "{}-1-gen.js".format(item), + cpaths.CPATH_DOCS_JS, "{}-{}.min.js".format(item, CACHE_VERSION), ) - status = subprocess.run( - [terser_command], shell=True, check=True, capture_output=True # noqa: S602 - ) - if status.returncode != 0: - print("terser failed for item {}".format(item)) + # print(terser_command) + try: + status = subprocess.run( + [terser_command], shell=True, check=True, capture_output=True # noqa: S602 + ) + if status.returncode != 0: + print("terser failed for item {}".format(item)) + except subprocess.CalledProcessError as e: + print("terser failed for item {} with {}".format(item, e)) # optimise files with critical if flag_optim: pass @@ -573,7 +568,7 @@ def main(): ) item_filename = cpaths.CPATH_DOCS + "/" + item_name # ok for robots but likely doesn't work for sitemap - write_if_different(item_content, item_filename, force=False) + write_if_different(item_content, item_filename, force=True) except KeyError as key_error: print("Generating various html files failed with {}".format(key_error)) sys.exit(1) diff --git a/package.json b/package.json index 02e1e445fa..15e53cf6d8 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "dependencies": { "bulmajs": "^0.0.2", "fnm": "^0.0.0", + "fuse.js": "^7.0.0", "handlebars": "^4.7.8", "html-validate": "^7.13.2", "html-validator": "^5.1.18", @@ -9,6 +10,7 @@ "node": "^21.1.0", "npm": "^10.2.3", "plotly": "^1.0.6", + "plotly.js": "^2.32.0", "sass": "^1.58.0", "typescript-language-server": "^3.3.2" }, @@ -24,6 +26,6 @@ "terser": "^5.30.3", "w3c-html-validator": "^1.7.0", "workbox-cli": "^7.0.0", - "workbox-window": "^7.0.0" + "workbox-window": "^7.1.0" } } diff --git a/check_404.sh b/scripts/check_404.sh similarity index 95% rename from check_404.sh rename to scripts/check_404.sh index a5ea9532e7..5a578225c0 100755 --- a/check_404.sh +++ b/scripts/check_404.sh @@ -19,7 +19,7 @@ pylinkvalidate.py -P https://www.spinorama.org -for f in docs/speakers/*/*/*/*.html; do +for f in ./docs/speakers/*/*/*/*.html; do name=${f#docs/} u=${name// /%20} pylinkvalidate.py -P "https://www.spinorama.org/$u" diff --git a/check_html.sh b/scripts/check_html.sh similarity index 100% rename from check_html.sh rename to scripts/check_html.sh diff --git a/check_meta.py b/scripts/check_meta.py similarity index 100% rename from check_meta.py rename to scripts/check_meta.py diff --git a/check_peqs.py b/scripts/check_peqs.py similarity index 100% rename from check_peqs.py rename to scripts/check_peqs.py diff --git a/cleanup.sh b/scripts/cleanup.sh similarity index 100% rename from cleanup.sh rename to scripts/cleanup.sh diff --git a/cleanup_docs.sh b/scripts/cleanup_docs.sh similarity index 100% rename from cleanup_docs.sh rename to scripts/cleanup_docs.sh diff --git a/scripts/update_kef.py b/scripts/kef_dataimport_meta.py similarity index 100% rename from scripts/update_kef.py rename to scripts/kef_dataimport_meta.py diff --git a/scripts/kefcomplete.py b/scripts/kefdata_join.py similarity index 100% rename from scripts/kefcomplete.py rename to scripts/kefdata_join.py diff --git a/setup.sh b/scripts/setup.sh similarity index 100% rename from setup.sh rename to scripts/setup.sh diff --git a/scripts/svg2symbols.py b/scripts/svg2symbols.py index 6096dce9a9..4e5bace04b 100755 --- a/scripts/svg2symbols.py +++ b/scripts/svg2symbols.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!python3 from glob import glob from os.path import basename @@ -31,7 +31,7 @@ def process(filename, xml): if __name__ == "__main__": svg_paths = [ - "src/website/icons/*.svg", + "src/website/svg/*.svg", ] xml_pre() diff --git a/scripts/h_and_v.sh b/scripts/swap_h_and_v.sh similarity index 100% rename from scripts/h_and_v.sh rename to scripts/swap_h_and_v.sh diff --git a/scripts/update_3rdparties.sh b/scripts/update_3rdparties.sh new file mode 100755 index 0000000000..ce86223bd5 --- /dev/null +++ b/scripts/update_3rdparties.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +# warning this section is read by a python script (generate_html) to grab the versions + +PLOTLY=2.32.0 +HANDLEBARS=4.7.8 +BULMA=1.0.0 +FUSE=7.0.0 +WORKBOX=7.0.0 + +# end section + +ASSETS=./docs +ASSETS_JS=${ASSETS}/js3rd +ASSETS_CSS=${ASSETS}/css + +# BULMA +if ! test -f "${ASSETS}/handlebars-${HANDLEBARS}.min.js"; then + wget -O${ASSETS_JS}/handlebars-${HANDLEBARS}.min.js https://cdn.jsdelivr.net/npm/handlebars@${HANDLEBARS}/dist/handlebars.min.js +fi +if ! test -f "${ASSETS}/bulma-${BULMA}.min.css"; then + wget -O${ASSETS_CSS}/bulma-${BULMA}.min.css https://cdn.jsdelivr.net/npm/bulma@${BULMA}/css/bulma.min.css +fi + +# PLOTLY +if ! test -f "${ASSETS}/plotly-${PLOTLY}.min.js"; then + wget -O${ASSETS_JS}/plotly-${PLOTLY}.min.js https://cdn.plot.ly/plotly-${PLOTLY}.min.js +fi + +# FUSE.JS +npm install fuse.js +cp node_modules/fuse.js/dist/fuse.min.mjs ${ASSETS_JS}/fuse-${FUSE}.min.mjs + +# WORKBOX +npm install workbox-window +cp node_modules/workbox-window/build/workbox-window.prod.mjs ${ASSETS_JS}/workbox-window-${WORKBOX}.min.js +cp node_modules/workbox-window/build/workbox-window.prod.mjs.map ${ASSETS_JS}/workbox-window-${WORKBOX}.min.js.map + diff --git a/scripts/update_api.sh b/scripts/update_api.sh index 2fbddaeff0..39335f2b1b 100755 --- a/scripts/update_api.sh +++ b/scripts/update_api.sh @@ -1,23 +1,38 @@ #!/bin/bash +# A library to display spinorama charts +# +# Copyright (C) 2020-2024 Pierre Aubert pierre(at)spinorama(dot)org +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . -TARGET=/var/www/html/spinorama-api +echo "Update starts" +export PYTHONPATH=src:src/website:src/spinorama:. -cp ./datas/metadata.py $TARGET -cp ./scripts/gunicorn_start.sh $TARGET -cp ./requirements-api.txt $TARGET +DIST=/var/www/html/spinorama-api -cp ./src/api/__init__.py $TARGET -cp ./src/api/main.py $TARGET -cp ./src/api/openapi.yml $TARGET +cp ./scripts/gunicorn_start.sh $DIST +cp requirements-api.txt $DIST +cp datas/metadata.py $DIST/datas +cp docs/assets/metadata.json $DIST/datas +for source in "__init__.py" "main.py" "ai-plugin.json"; do + cp ./src/api/$source $DIST; +done -mkdir -p $TARGET/.well-known -cp ./src/api/.well-known/ai-plugin.json $TARGET/.well-known -cp ./src/api/.well-known/readme.md $TARGET/.well-known +cd $DIST && source .venv/bin/activate && pip install -U -r requirements-api.txt -# make it writable for the group -chmod 775 $TARGET/*.sh -chmod 664 $TARGET/*.py -chmod 664 $TARGET/*.txt +echo "you may need to restart gunicorn and possibly reload nginx:" +echo "sudo supervisorctl restart spinorama-api" +echo "sudo nginx -s reload" -# reload -sudo supervisorctl restart spinorama-api +exit 0; diff --git a/update_brands.sh b/scripts/update_brands.sh similarity index 87% rename from update_brands.sh rename to scripts/update_brands.sh index be467d046f..95f3ad3b1f 100755 --- a/update_brands.sh +++ b/scripts/update_brands.sh @@ -17,10 +17,11 @@ # along with this program. If not, see . export LOCALE=C -json_pp < ./docs/metadata.json | \ +mkdir -p build/website +json_pp < ./docs/json/metadata.json | \ grep '"brand" : ' | \ cut -d: -f 2 | \ cut -b 2- | \ sed -e 's/[,"]//g' | \ sort -s -V -f -u | \ - awk '{brand=$0; gsub("&", "&", $0) ; printf("\n", brand, $0);}' > src/website/brands.html + awk '{brand=$0; gsub("&", "&", $0) ; printf("\n", brand, $0);}' > build/website/brands.html diff --git a/update_dev.sh b/scripts/update_dev.sh similarity index 100% rename from update_dev.sh rename to scripts/update_dev.sh diff --git a/update_pictures.sh b/scripts/update_pictures.sh similarity index 96% rename from update_pictures.sh rename to scripts/update_pictures.sh index 82d978c222..d126b3c864 100755 --- a/update_pictures.sh +++ b/scripts/update_pictures.sh @@ -20,7 +20,6 @@ # convert is from imagemagick package sourcedir=datas targetdir=docs -mkdir -p ${targetdir}/icons mkdir -p ${targetdir}/pictures mkdir -p ${targetdir}/help_pictures for d in "${sourcedir}/pictures"; do @@ -50,8 +49,7 @@ for d in "${sourcedir}/pictures"; do done done # copy logs -mkdir -p docs/icons -cp datas/icons/* docs/icons +cp datas/icons/* docs/pictures # copy help pictures find ./src/website/help_pictures -type f -name '*.png'| while read pict; do smaller=$targetdir/help_pictures/`basename $pict` diff --git a/update_prod.sh b/scripts/update_prod.sh similarity index 100% rename from update_prod.sh rename to scripts/update_prod.sh diff --git a/update_reviewers.sh b/scripts/update_reviewers.sh similarity index 88% rename from update_reviewers.sh rename to scripts/update_reviewers.sh index 58913ddb6e..aada8919b7 100755 --- a/update_reviewers.sh +++ b/scripts/update_reviewers.sh @@ -26,10 +26,12 @@ if test "$OS" = "Darwin" -a "$ARCH" = "arm64" ; then SED=gsed fi -json_pp < docs/metadata.json | \ +mkdir -p build/website + +json_pp < docs/json/metadata.json | \ grep -e '"misc-' | \ grep -v default | \ $SED -e s'/[ \t"":{"]//g' | \ $SED -e 's/misc-//' -e 's/-horizontal//g' -e 's/-vertical//g' -e 's/-sealed//g' -e 's/-ported//g' | \ sort -s -f -u | \ - $AWK -f ./scripts/update_reviewers.awk > src/website/reviewers.html + $AWK -f ./scripts/update_reviewers.awk > build/website/reviewers.html diff --git a/scripts/vituix2spin.sh b/scripts/vituix2spin.sh old mode 100644 new mode 100755 diff --git a/src/spinorama/constant_paths.py b/src/spinorama/constant_paths.py index bf8b8c66e0..62ff949979 100644 --- a/src/spinorama/constant_paths.py +++ b/src/spinorama/constant_paths.py @@ -21,6 +21,7 @@ CPATH_SRC = "{}/{}".format(CPATH, "src") CPATH_PYTHON = "{}/{}".format(CPATH_SRC, "spinorama") CPATH_WEBSITE = "{}/{}".format(CPATH_SRC, "website") +CPATH_SCRIPTS = "{}/{}".format(CPATH, "scripts") # where the metadata around the speakers are CPATH_DATAS = "{}/{}".format(CPATH, "datas") @@ -29,14 +30,20 @@ CPATH_DATAS_SPEAKERS = "{}/{}".format(CPATH_DATAS, "measurements") CPATH_DATAS_EQ = "{}/{}".format(CPATH_DATAS, "eq") +# where the temporay files go +CPATH_BUILD = "{}/{}".format(CPATH, "build") +CPATH_BUILD_WEBSITE = "{}/{}".format(CPATH_BUILD, "website") +CPATH_BUILD_MAKO = "{}/{}".format(CPATH_BUILD, "mako_modules") + # where the generated files go CPATH_DOCS = "{}/{}".format(CPATH, "docs") -CPATH_DOCS_METADATA_JSON = "{}/{}".format(CPATH_DOCS, "metadata.json") -CPATH_DOCS_EQDATA_JSON = "{}/{}".format(CPATH_DOCS, "eqdata.json") +CPATH_DOCS_JS = "{}/{}".format(CPATH_DOCS, "js") +CPATH_DOCS_CSS = "{}/{}".format(CPATH_DOCS, "css") +CPATH_DOCS_JSON = "{}/{}".format(CPATH_DOCS, "json") +CPATH_DOCS_METADATA_JSON = "{}/{}.json".format(CPATH_DOCS_JSON, "metadata") +CPATH_DOCS_EQDATA_JSON = "{}/{}.json".format(CPATH_DOCS_JSON, "eqdata") CPATH_DOCS_SPEAKERS = "{}/{}".format(CPATH_DOCS, "speakers") CPATH_DOCS_PICTURES = "{}/{}".format(CPATH_DOCS, "pictures") -CPATH_DOCS_SVG = "{}/{}".format(CPATH_DOCS, "svg") -CPATH_DOCS_WEBFONTS = "{}/{}".format(CPATH_DOCS, "webfonts") # midrange defintion MIDRANGE_MIN_FREQ = 300 diff --git a/src/website/brands.html b/src/website/brands.html deleted file mode 100644 index fd6ed930dd..0000000000 --- a/src/website/brands.html +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/website/compare.html b/src/website/compare.html index 16f9b7bfb0..41684fc9aa 100644 --- a/src/website/compare.html +++ b/src/website/compare.html @@ -58,7 +58,7 @@
- + <%include file="footer.html"/> diff --git a/src/website/compare.js b/src/website/compare.js index f862f34ae4..80214005b7 100644 --- a/src/website/compare.js +++ b/src/website/compare.js @@ -16,11 +16,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -/*global Plotly */ /*eslint no-undef: "error"*/ -import { urlSite } from './meta-${versions["CACHE"]}${min}.js'; -import { getMetadata, assignOptions, getAllSpeakers, getSpeakerData } from './download-${versions["CACHE"]}${min}.js'; +import { + urlSite +} from '/js/meta-${versions["CACHE"]}${min}.js'; +import { + getMetadata, + assignOptions, + getAllSpeakers, + getSpeakerData +} from '/js/download-${versions["CACHE"]}${min}.js'; import { knownMeasurements, setContour, @@ -29,7 +35,7 @@ import { setCEA2034, setRadar, setSurface, -} from './plot-${versions["CACHE"]}${min}.js'; +} from '/js/plot-${versions["CACHE"]}${min}.js'; function updateVersion(metaSpeakers, speaker, selector, origin, version) { // update possible version(s) for matching speaker and origin diff --git a/src/website/download.js b/src/website/download.js index 499329258f..928b8c230a 100644 --- a/src/website/download.js +++ b/src/website/download.js @@ -22,8 +22,8 @@ import { metadataFilenameHead, metadataFilenameChunks, eqdataFilename, -} from './meta-${versions["CACHE"]}${min}.js'; -import { getID } from './misc-${versions["CACHE"]}${min}.js'; +} from '/js/meta-${versions["CACHE"]}${min}.js'; +import { getID } from '/js/misc-${versions["CACHE"]}${min}.js'; function processOrigin(origin) { if (origin.includes('Vendors-')) { diff --git a/src/website/eqs.html b/src/website/eqs.html index 0493f102aa..dad1f99d04 100644 --- a/src/website/eqs.html +++ b/src/website/eqs.html @@ -5,7 +5,7 @@ <%include file="head.html"/> - <%include file="icons.html"/> + <%include file="symbols.html"/> <%include file="nav_search.html"/> <%namespace name="util" module="website.utils" import="*"/> @@ -338,7 +338,7 @@
- +
diff --git a/src/website/eqs.js b/src/website/eqs.js index b649abc05a..1c710e6de8 100644 --- a/src/website/eqs.js +++ b/src/website/eqs.js @@ -19,9 +19,9 @@ /*global Handlebars*/ /*eslint no-undef: "error"*/ -import { getEQdata } from './download-${versions["CACHE"]}${min}.js'; -import { openModal, closeModal, getPeq, getID } from './misc-${versions["CACHE"]}${min}.js'; -import { process, urlParameters2Sort } from './search-${versions["CACHE"]}${min}.js'; +import { getEQdata } from '/js/download-${versions["CACHE"]}${min}.js'; +import { openModal, closeModal, getPeq, getID } from '/js/misc-${versions["CACHE"]}${min}.js'; +import { process, urlParameters2Sort } from '/js/search-${versions["CACHE"]}${min}.js'; function getPictureEqCompare(brand, model, suffix) { return encodeURI('speakers/' + brand + ' ' + model + '/eq_compare.' + suffix); diff --git a/src/website/graph.html b/src/website/graph.html index a4a3c7a69e..2663ef32a9 100644 --- a/src/website/graph.html +++ b/src/website/graph.html @@ -7,12 +7,13 @@ <%include file="nav_simple.html"/> + <%include file="graph_tip.html"/> <%! def space2url(text): return text.replace(' ', '%20') %>
- + + + diff --git a/src/website/icons.html b/src/website/icons.html deleted file mode 100644 index ae19ef4d14..0000000000 --- a/src/website/icons.html +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/website/favicon-16x16.png b/src/website/icons/favicon-16x16.png similarity index 100% rename from src/website/favicon-16x16.png rename to src/website/icons/favicon-16x16.png diff --git a/src/website/favicon.ico b/src/website/icons/favicon.ico similarity index 100% rename from src/website/favicon.ico rename to src/website/icons/favicon.ico diff --git a/src/website/icons/volume-0.svg b/src/website/icons/volume-0.svg deleted file mode 100644 index 383b324a6a..0000000000 --- a/src/website/icons/volume-0.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/src/website/icons/volume-1.svg b/src/website/icons/volume-1.svg deleted file mode 100644 index 313598bc03..0000000000 --- a/src/website/icons/volume-1.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/src/website/icons/volume-2.svg b/src/website/icons/volume-2.svg deleted file mode 100644 index 0b37dc5182..0000000000 --- a/src/website/icons/volume-2.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/src/website/icons/volume-3.svg b/src/website/icons/volume-3.svg deleted file mode 100644 index 156b6be484..0000000000 --- a/src/website/icons/volume-3.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/src/website/icons/volume-4.svg b/src/website/icons/volume-4.svg deleted file mode 100644 index 691da3fe3a..0000000000 --- a/src/website/icons/volume-4.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - diff --git a/src/website/icons/volume-5.svg b/src/website/icons/volume-5.svg deleted file mode 100644 index f1e150bfe6..0000000000 --- a/src/website/icons/volume-5.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - diff --git a/src/website/icons/volume-danger-0.svg b/src/website/icons/volume-danger-0.svg deleted file mode 100644 index 75c22abe4f..0000000000 --- a/src/website/icons/volume-danger-0.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/src/website/icons/volume-danger-1.svg b/src/website/icons/volume-danger-1.svg deleted file mode 100644 index b479a411ad..0000000000 --- a/src/website/icons/volume-danger-1.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/src/website/icons/volume-danger-2.svg b/src/website/icons/volume-danger-2.svg deleted file mode 100644 index 1549472b97..0000000000 --- a/src/website/icons/volume-danger-2.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/src/website/icons/volume-danger-3.svg b/src/website/icons/volume-danger-3.svg deleted file mode 100644 index 7fc89d3dc3..0000000000 --- a/src/website/icons/volume-danger-3.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/src/website/icons/volume-info-0.svg b/src/website/icons/volume-info-0.svg deleted file mode 100644 index 9f271e7380..0000000000 --- a/src/website/icons/volume-info-0.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/src/website/icons/volume-info-1.svg b/src/website/icons/volume-info-1.svg deleted file mode 100644 index 4898606401..0000000000 --- a/src/website/icons/volume-info-1.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/src/website/icons/volume-info-2.svg b/src/website/icons/volume-info-2.svg deleted file mode 100644 index d1f619fb8a..0000000000 --- a/src/website/icons/volume-info-2.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/src/website/icons/volume-info-3.svg b/src/website/icons/volume-info-3.svg deleted file mode 100644 index eff2155382..0000000000 --- a/src/website/icons/volume-info-3.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/src/website/icons/volume-success-0.svg b/src/website/icons/volume-success-0.svg deleted file mode 100644 index 8ffc137761..0000000000 --- a/src/website/icons/volume-success-0.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - diff --git a/src/website/icons/volume-success-1.svg b/src/website/icons/volume-success-1.svg deleted file mode 100644 index cf128ecc3e..0000000000 --- a/src/website/icons/volume-success-1.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - diff --git a/src/website/icons/volume-success-2.svg b/src/website/icons/volume-success-2.svg deleted file mode 100644 index 253fa755d4..0000000000 --- a/src/website/icons/volume-success-2.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/src/website/icons/volume-success-3.svg b/src/website/icons/volume-success-3.svg deleted file mode 100644 index 75bdbafd7a..0000000000 --- a/src/website/icons/volume-success-3.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - diff --git a/src/website/icons/volume.svg b/src/website/icons/volume.svg deleted file mode 100644 index e2d9625c8d..0000000000 --- a/src/website/icons/volume.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/website/index.html b/src/website/index.html index 944001a9dc..4ad74947cc 100644 --- a/src/website/index.html +++ b/src/website/index.html @@ -5,7 +5,7 @@ <%include file="head.html"/> - <%include file="icons.html"/> + <%include file="symbols.html"/> <%include file="nav_search.html"/> <%include file="nav_counters.html"/> <%namespace name="util" module="website.utils" import="*"/> @@ -145,7 +145,7 @@ - + <%include file="footer.html"/> diff --git a/src/website/index.js b/src/website/index.js index 8f81d54d5f..3a63b4d1f2 100644 --- a/src/website/index.js +++ b/src/website/index.js @@ -18,8 +18,7 @@ /*eslint no-undef: "error"*/ -// import Handlebars from './handlebars-${versions["HANDLEBARS"]}.min.js'; -import { getMetadata, getMetadataHead, getMetadataTail } from './download-${versions["CACHE"]}${min}.js'; +import { getMetadataHead, getMetadataTail } from '/js/download-${versions["CACHE"]}${min}.js'; import { getPrice, getID, @@ -28,8 +27,9 @@ import { getDecoding, getScore, getReviews, -} from './misc-${versions["CACHE"]}${min}.js'; -import { process, urlParameters2Sort, setupEventListener } from './search-${versions["CACHE"]}${min}.js'; +} from '/js/misc-${versions["CACHE"]}${min}.js'; +import { process, urlParameters2Sort, setupEventListener } from '/js/search-${versions["CACHE"]}${min}.js'; +import { pagination } from '/js/pagination-${versions["CACHE"]}${min}.js'; function getMeasurementCount(metadata) { let count = 0; @@ -107,89 +107,6 @@ function display(data, speakerHtml, parentDiv) { parentDiv.appendChild(fragment); } -const navigationContainer = document.querySelector('#pagination'); - -function urlChangePage(url, newpage) { - const newUrl = new URL(url); - newUrl.searchParams.set('page', newpage); - return newUrl.toString(); -} - -function navigation(numberSpeakers) { - // the ${} for mako is replaced by ${"$"} because mako is ran twice on this file - const navHeader = ''; - - const url = new URL(window.location); - const params = urlParameters2Sort(url); - const currentPage = params[3].page; - const perPage = params[3].count; - const maxPage = Math.floor(numberSpeakers / perPage); - const prevPage = Math.max(currentPage - 1, 1); - const nextPage = Math.min(currentPage + 1, maxPage); - - console.log('currentPage='+currentPage+' perPage='+perPage+' maxPage='+maxPage+' prevPage='+prevPage+' nextPage='+nextPage); - - let html = navHeader; - if (currentPage <= 3) { - let disabled = ''; - if (currentPage == 1) { - disabled = 'is-disabled'; - } - html += 'Prev'; - html += 'Next'; - html += '
    '; - for (let i = 1; i <= Math.min(3, maxPage); i++) { - let current = ''; - if (i === currentPage) { - current = 'is-current'; - } - html += - '
  • ${'$'}{i}
  • `; - } - if (maxPage > 5) { - html += '
  • '; - html += - '
  • ${'$'}{maxPage}
  • `; - } - html += '
'; - } else if (maxPage - currentPage <= 3) { - html += 'Prev'; - html += 'Next'; - html += '
    '; - for (let i = 1; i <= Math.min(3, maxPage); i++) { - let current = ''; - if (i === currentPage) { - current = 'is-current'; - } - html += - '
  • ${'$'}{i}
  • `; - } - if (maxPage > 5) { - html += '
  • '; - html += - '
  • ${'$'}{maxPage}
  • `; - } - html += '
'; - } else { - } - html += navFooter; - const divNavigation = document.createElement('div'); - while (divNavigation.firstChild) { - divNavigation.removeChild(divNavigation.firstChild); - } - divNavigation.innerHTML = html; - navigationContainer.appendChild(divNavigation); -} - getMetadataHead() .then((metadataHead) => { const url = new URL(window.location); @@ -216,7 +133,7 @@ getMetadataHead() if (url.pathname !== '' && url.pathname !== 'index.html') { display(metadata, printSpeaker, speakerContainer); } - navigation(metadata.size); + pagination(metadata.size); }) .catch((error) => { console.log(error); diff --git a/src/website/manifest.json b/src/website/manifest.json index 74379b6c67..5768655281 100644 --- a/src/website/manifest.json +++ b/src/website/manifest.json @@ -8,22 +8,22 @@ "description": "Speaker measurements", "icons": [ { - "src": "icons/icon-bookshelves-48x48.png", + "src": "/pictures/icon-bookshelves-48x48.png", "sizes": "48x48", "type": "image/png" }, { - "src": "icons/icon-bookshelves-144x144.png", - "sizes": "144x144", + "src": "/pictures/icon-bookshelves-144x144.png", + "sizes": "144x115", "type": "image/png" }, { - "src": "icons/icon-bookshelves.svg", + "src": "/pictures/icon-bookshelves.svg", "sizes": "640x512", "type": "image/svg+xml" }, { - "src": "icons/icon-bookshelves.png", + "src": "/pictures/icon-bookshelves.png", "sizes": "640x512", "type": "image/png" } diff --git a/src/website/nav_search.html b/src/website/nav_search.html index 2df4d06415..f5bd7bd3fc 100644 --- a/src/website/nav_search.html +++ b/src/website/nav_search.html @@ -13,12 +13,12 @@ - + +
diff --git a/src/website/nav_simple.html b/src/website/nav_simple.html index 58cb9e7289..4bf49e0219 100644 --- a/src/website/nav_simple.html +++ b/src/website/nav_simple.html @@ -1,4 +1,4 @@ -<%include file="icons.html"/> +<%include file="symbols.html"/>
-
- SPINorama -
+ + diff --git a/src/website/onload.js b/src/website/onload.js index f282caedb6..05a1dd43ea 100644 --- a/src/website/onload.js +++ b/src/website/onload.js @@ -17,6 +17,7 @@ // along with this program. If not, see . window.onload = () => { + const navbarBurger = document.querySelector('#navbar-burger'); const navbarMenu = document.querySelector('.navbar-menu'); @@ -43,6 +44,15 @@ window.onload = () => { }); } + const tips = document.querySelectorAll('.speaker-tip'); + if (tips) { + tips.forEach( (tip) => { + tip.addEventListener('click', () => { + tip.classList.toggle('hidden'); + }); + }); + } + const filters = document.querySelector('#filters-dropdown'); if (filters) { const trigger = filters.querySelector('#filters-dropdown-trigger'); @@ -54,4 +64,17 @@ window.onload = () => { menu.classList.toggle('hidden'); }); } + + const navtabs = document.querySelector('#navtab'); + if (navtabs) { + const tabs = document.querySelectorAll('.tab-pane'); + tabs.forEach( (tab) => { + console.info(tab.id); + if (tab.id === 'pane-2') { + tab.style.display = 'block'; + } else { + tab.style.display = 'none'; + } + }); + } }; diff --git a/src/website/pagination.js b/src/website/pagination.js new file mode 100644 index 0000000000..85ea1d13d1 --- /dev/null +++ b/src/website/pagination.js @@ -0,0 +1,119 @@ +// -*- coding: utf-8 -*- +// A library to display spinorama charts +// +// Copyright (C) 2020-2024 Pierre Aubert pierre(at)spinorama(dot)org +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/*eslint no-undef: "error"*/ + +import { urlParameters2Sort } from '/js/search-${versions["CACHE"]}${min}.js'; + +function urlChangePage(url, newpage) { + const newUrl = new URL(url); + newUrl.searchParams.set('page', newpage); + return newUrl.toString(); +} + +export function pagination(numberSpeakers) { + // the ${} for mako is replaced by ${"$"} because mako is ran twice on this file + const navigationContainer = document.querySelector('#pagination'); + const navHeader = ''; + + const url = new URL(window.location); + const params = urlParameters2Sort(url); + const currentPage = params[3].page; + const perPage = params[3].count; + const maxPage = Math.floor(numberSpeakers / perPage); + const prevPage = Math.max(currentPage - 1, 1); + const nextPage = Math.min(currentPage + 1, maxPage); + + console.log('currentPage='+currentPage+' perPage='+perPage+' maxPage='+maxPage+' prevPage='+prevPage+' nextPage='+nextPage); + + let html = navHeader; + if (currentPage <= 3) { + let disabled = ''; + if (currentPage == 1) { + disabled = ' is-disabled'; + } + html += 'Prev'; + html += 'Next'; + html += '
    '; + for (let i = 1; i <= Math.min(3, maxPage); i++) { + let current = ''; + if (i === currentPage) { + current = 'is-current'; + } + html += + '
  • ${'$'}{i}
  • `; + } + if (maxPage > 5) { + html += '
  • '; + html += '
  • '+maxPage+'
  • '; + } + html += '
'; + } else if (maxPage - currentPage <= 3) { + let disabled = ''; + if (currentPage == maxPage) { + disabled = ' is-disabled'; + } + html += 'Prev'; + html += 'Next'; + html += '
    '; + if (maxPage > 5) { + html += '
  • 1
  • '; + html += '
  • '; + } + for (let i = Math.max(1, maxPage-3); i <= maxPage; i++) { + let current = ''; + if (i === currentPage) { + current = 'is-current'; + } + html += + '
  • '+i+'
  • '; + } + html += '
'; + } else { + html += 'Prev'; + html += 'Next'; + html += '
    '; + html += '
  • 1
  • '; + html += '
  • '; + for (let i = currentPage-2; i <= currentPage+2; i++) { + let current = ''; + if (i === currentPage) { + current = 'is-current'; + } + if (i !== currentPage-1 && i !== currentPage+1) { + html += '
  • '+i+'
  • '; + } + } + html += '
  • '; + html += '
  • '+maxPage+'
  • '; + html += '
'; + } + html += navFooter; + const divNavigation = document.createElement('div'); + while (divNavigation.firstChild) { + divNavigation.removeChild(divNavigation.firstChild); + } + divNavigation.innerHTML = html; + navigationContainer.appendChild(divNavigation); +} + diff --git a/src/website/plot.js b/src/website/plot.js index ca228900f2..44a285a451 100644 --- a/src/website/plot.js +++ b/src/website/plot.js @@ -247,7 +247,7 @@ function setGraphOptions(spin, windowWidth, windowHeight, nb_graphs) { } }); let i = 0; - mins.forEach((min_freq, speaker_name) => { + mins.forEach((min_freq, _) => { if (min_freq > 40) { let shape = { type: 'rect', diff --git a/src/website/reviewers.html b/src/website/reviewers.html deleted file mode 100644 index 670b1b0be4..0000000000 --- a/src/website/reviewers.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/src/website/scores.html b/src/website/scores.html index 67a70dd0fe..0fdd9738b0 100644 --- a/src/website/scores.html +++ b/src/website/scores.html @@ -5,7 +5,7 @@ <%include file="head.html"/> - <%include file="icons.html"/> + <%include file="symbols.html"/> <%include file="nav_search.html"/>