Skip to content

Commit

Permalink
optimisation of website wave 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreaubert committed May 12, 2024
1 parent bfa7486 commit a9c756b
Show file tree
Hide file tree
Showing 37 changed files with 614 additions and 820 deletions.
13 changes: 0 additions & 13 deletions .eslintignore

This file was deleted.

12 changes: 0 additions & 12 deletions .eslintrc.js

This file was deleted.

9 changes: 4 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ repos:
hooks:
- id: csslint
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v9.0.0-rc.0' # Use the sha / tag you want to point at
rev: 'v9.2.0' # Use the sha / tag you want to point at
hooks:
- id: eslint
additional_dependencies:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- eslint
- eslint-loader
- eslint-prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v4.0.0-alpha.8' # Use the sha / tag you want to point at
hooks:
Expand Down
11 changes: 0 additions & 11 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc.toml

This file was deleted.

6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2024-05-10 pierrre <pierrre@PAR03240>

* optimisation of website: removed handlebars, replaced by js templates
* optimisation of website: removed fontawesome, replace by a selection of icons in svg format
* optimisation of website: added a service worker to improve caching

2023-11-12 pierre <[email protected]>

* tests/test_go.py: tests are not passing for mysterious reasons
Expand Down
42 changes: 21 additions & 21 deletions datas/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12455,28 +12455,8 @@ class Speaker(SpeakerRequired, total=False):
"price": "25000",
"amount": "pair",
"shape": "floorstanders",
"default_measurement": "vendor-v2-20230503",
"default_measurement": "eac",
"measurements": {
"vendor-v2-20230503": {
"origin": "Vendors-KEF",
"format": "rew_text_dump",
"review_published": "20230503",
"notes": note_kef_data,
"quality": "medium",
"reviews": {
"white_paper": "https://assets.kef.com/documents/reference/KEF_Blade_Ref_Meta_Tech_Paper.pdf",
},
},
"vendor-v1-20220217": {
"origin": "Vendors-KEF",
"format": "webplotdigitizer",
"review_published": "20220217",
"notes": note_kef_data,
"quality": "medium",
"reviews": {
"white_paper": "https://assets.kef.com/documents/reference/KEF_Blade_Ref_Meta_Tech_Paper.pdf",
},
},
"eac": {
"origin": "ErinsAudioCorner",
"format": "klippel",
Expand All @@ -12503,6 +12483,26 @@ class Speaker(SpeakerRequired, total=False):
"weight": 35.3,
},
},
"vendor-v2-20230503": {
"origin": "Vendors-KEF",
"format": "rew_text_dump",
"review_published": "20230503",
"notes": note_kef_data,
"quality": "medium",
"reviews": {
"white_paper": "https://assets.kef.com/documents/reference/KEF_Blade_Ref_Meta_Tech_Paper.pdf",
},
},
"vendor-v1-20220217": {
"origin": "Vendors-KEF",
"format": "webplotdigitizer",
"review_published": "20220217",
"notes": note_kef_data,
"quality": "medium",
"reviews": {
"white_paper": "https://assets.kef.com/documents/reference/KEF_Blade_Ref_Meta_Tech_Paper.pdf",
},
},
},
},
"KEF Ci3160RL-THX": {
Expand Down
22 changes: 22 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import js from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";

import globals from "globals";

export default [
js.configs.recommended,
{
rules: {
"no-unused-vars": "error",
"no-undef": "warn"
},
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.browser
}
}
},
eslintConfigPrettier,
];
40 changes: 25 additions & 15 deletions generate_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ def generate_speakers(mako, dataframe, meta, site, use_search, versions):


def main():
# create some directories
for dir in (
cpaths.CPATH_DOCS,
cpaths.CPATH_DOCS_JS,
cpaths.CPATH_DOCS_JS3RD,
cpaths.CPATH_DOCS_JSON,
cpaths.CPATH_DOCS_CSS
):
os.makedirs(dir, mode=0o755, exist_ok=True)

# load all metadata from generated json file
metadata_json_filename, eqdata_json_filename = find_metadata_file()
metadata_json_chunks = find_metadata_chunks()
Expand Down Expand Up @@ -459,21 +469,21 @@ def main():
shutil.copy(file_in, file_out)

# cleanup flow directives: currently unused
flow_bin = "./node_modules/.bin/flow-remove-types"
flow_param = "" # "--pretty --sourcemaps"

flow_command = "{} {} {} {} {}".format(
flow_bin,
flow_param,
cpaths.CPATH_WEBSITE,
"--out-dir",
cpaths.CPATH_BUILD_WEBSITE,
)
status = subprocess.run(
[flow_command], shell=True, check=True, capture_output=True # noqa: S602
)
if status.returncode != 0:
print("flow failed")
# flow_bin = "./node_modules/.bin/flow-remove-types"
# flow_param = "" # "--pretty --sourcemaps"
#
# flow_command = "{} {} {} {} {}".format(
# flow_bin,
# flow_param,
# cpaths.CPATH_WEBSITE,
# "--out-dir",
# cpaths.CPATH_BUILD_WEBSITE,
# )
# status = subprocess.run(
# [flow_command], shell=True, check=True, capture_output=True # noqa: S602
# )
# if status.returncode != 0:
# print("flow failed")

# copy css/js files
logger.info("Copy js files to %s", cpaths.CPATH_DOCS_JS)
Expand Down
4 changes: 2 additions & 2 deletions generate_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,8 @@ def dump_metadata(meta):
metadir = cpaths.CPATH_DOCS
metafile = cpaths.CPATH_DOCS_METADATA_JSON
eqfile = cpaths.CPATH_DOCS_EQDATA_JSON
if not os.path.isdir(metadir):
os.makedirs(metadir)
os.makedirs(metadir, mode=0o755, exist_ok=True)
os.makedirs(cpaths.CPATH_DOCS_JSON, mode=0o755, exist_ok=True)

def check_link(hashed_filename):
# add a link to make it easier for other scripts to find the metadata
Expand Down
1 change: 1 addition & 0 deletions generate_peqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def compute_peqs_sequential(df_all_speakers, optim_config, speaker_name):
)
continue

logger.debug('starting optim for %s', current_speaker_name)
status, (_, results_iter, scores) = optim_save_peq_seq(
current_speaker_name,
default_origin,
Expand Down
31 changes: 10 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
{
"dependencies": {
"bulma.js": "^0.0.1",
"bulmajs": "^0.0.2",
"fnm": "^0.0.0",
"eslint": "^9.2.0",
"fuse.js": "^7.0.0",
"handlebars": "^4.7.8",
"html-validate": "^7.13.2",
"html-validator": "^5.1.18",
"html-validator-cli": "^2.0.0",
"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"
"plotly.js-dist-min": "^2.32.0",
"terser": "^5.31.0",
"vite": "^5.2.11",
"vitest": "^1.6.0",
"w3c-html-validator": "^1.8.1",
"workbox-cli": "^7.1.0",
"workbox-window": "^7.1.0"
},
"devDependencies": {
"critical": "^7.1.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"flow": "^0.2.3",
"flow-remove-types": "^2.232.0",
"prettier": "^3.1.0",
"pyright": "^1.1.356",
"standard": "^17.1.0",
"terser": "^5.30.3",
"w3c-html-validator": "^1.7.0",
"workbox-cli": "^7.1.0",
"workbox-window": "^7.1.0"
"prettier": "^3.2.5"
}
}
11 changes: 11 additions & 0 deletions prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import("prettier").Config} */
const config = {
trailingComma: "es5",
useTabs: false,
semi: true,
singleQuote: true,
printWidth: 128,
parser: "flow"
};

module.exports = config;
2 changes: 1 addition & 1 deletion scripts/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ rm -fr /tmp/ray
rm -fr ./__pycache__ ./*/__pycache__ ./*/*/__pycache__
rm -fr ./.mypy_cache ./*/.mypy_cache ./*/*/.mypy_cache
rm -fr ./.pytest_cache ./*/.pytest_cache ./*/*/.pytest_cache
rm -f cache.*.h5
rm -f .cache/*.h5
rm -fr **/results_*.csv
# node stuff
rm -fr ./node_modules
Expand Down
3 changes: 3 additions & 0 deletions src/spinorama/auto_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def optim_save_peq_seq(
if not optim_config["force"] and os.path.exists(eq_name):
if optim_config["verbose"]:
logger.info("eq %s already exist!", eq_name)
logger.debug('Skipping %s since EQ already exist!', current_speaker_name)
return False, ("", (0, 0, 0), [{}])

# do we have CEA2034 data
Expand Down Expand Up @@ -216,9 +217,11 @@ def optim_save_peq_seq(

score = {}
if use_score:
logger.debug('Computing init score for %s', current_speaker_name)
_, _, score = scores_apply_filter(df_speaker, [])

# compute pref score from speaker if possible
logger.debug('Calling strategy for %s', current_speaker_name)
auto_status, (auto_score, auto_results, auto_peq, auto_config) = optim_strategy(
current_speaker_name, df_speaker, optim_config, use_score
)
Expand Down
1 change: 1 addition & 0 deletions src/spinorama/constant_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# where the generated files go
CPATH_DOCS = "{}/{}".format(CPATH, "docs")
CPATH_DOCS_JS = "{}/{}".format(CPATH_DOCS, "js")
CPATH_DOCS_JS3RD = "{}/{}".format(CPATH_DOCS, "js3rd")
CPATH_DOCS_CSS = "{}/{}".format(CPATH_DOCS, "css")
CPATH_DOCS_JSON = "{}/{}".format(CPATH_DOCS, "json")
CPATH_DOCS_METADATA_JSON = "{}/{}.json".format(CPATH_DOCS_JSON, "metadata")
Expand Down
2 changes: 1 addition & 1 deletion src/website/compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="level-item px-1 py-1">
<div class="box px-1 py-1">
<p class="title is-5 has-text-centered">Speaker ${name}</p>
% for label, field in (("Pick a brand and model:", "speaker"), ("Where does the measurement come from?", "origin"), ("Which version (with eq, v1 or v2, etc)?", "version")):
% for label, field in (("Pick a brand and model!", "speaker"), ("Where does the measurement come from?", "origin"), ("Which version (with eq, v1 or v2, etc)?", "version")):
<fieldset id="compare-fieldset-${field}${number}">
<div class="field">
<p class="help">${label}</p>
Expand Down
8 changes: 5 additions & 3 deletions src/website/compare.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// -*- coding: utf-8 -*-
// A library to display spinorama charts
//
// Copyright (C) 2020-23 Pierre Aubert pierreaubert(at)yahoo(dot)fr
// Copyright (C) 2020-2024 Pierre Aubert pierreaubert(at)yahoo(dot)fr
//
// 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
Expand All @@ -18,9 +18,11 @@

/*eslint no-undef: "error"*/

import Plotly from '/js3rd/plotly-${versions["PLOTLY"]}${min}.mjs';

import {
urlSite
} from '/js/meta-${versions["CACHE"]}${min}.js';
} from '/js/meta-${versions["CACHE"]}${min}.mjs';
import {
getMetadata,
assignOptions,
Expand Down Expand Up @@ -391,7 +393,7 @@ getMetadata()
speakersSelector[0].focus();
} else if (key === 'b' || key === '2') {
speakersSelector[1].focus();
} else if (key === 'g' || key === 'c') {
} else if (key === 'g' || key === 'c' || key === '3') {
graphsSelector.focus();
}
});
Expand Down
10 changes: 4 additions & 6 deletions src/website/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import {
urlSite,
metadataFilename,
metadataFilenameHead,
metadataFilenameChunks,
eqdataFilename,
Expand Down Expand Up @@ -140,11 +139,6 @@ export function getMetadataHead() {
return fetchDataAndMap(url, 'bz2, zip, deflate');
}

export function getMetadata() {
const url = urlSite + metadataFilename;
return fetchDataAndMap(url, 'bz2, zip, deflate');
}

export function getMetadataTail(metadataHead) {
const promisedChunks = [];
for (let i in metadataFilenameChunks) {
Expand All @@ -162,6 +156,10 @@ export function getMetadataTail(metadataHead) {
});
}

export function getMetadata() {
return getMetadataHead().then((data) => getMetadataTail(data));
}

export function getEQdata() {
const metaDataPromise = getMetadata();
const url = urlSite + eqdataFilename;
Expand Down
1 change: 1 addition & 0 deletions src/website/eqs.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<title>Anechoic EQ for loudspeakers</title>
<%include file="head.html"/>
<%include file="head_handlebars.html"/>
</head>
<body>
<%include file="symbols.html"/>
Expand Down
Loading

0 comments on commit a9c756b

Please sign in to comment.