diff --git a/README.md b/README.md index cfa7593..faad8be 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,6 @@ sudo apt install python3-gpg python3-jwcrypto python3 -m pip install -U pgpy pynentry SecureBytes ``` +``` +sudo vendor/jaklis/setup.sh +``` \ No newline at end of file diff --git a/config.php b/config.php index ae35480..7d42aed 100644 --- a/config.php +++ b/config.php @@ -85,9 +85,10 @@ $games = [ ] ]; -$radiuses = [5, 10, 20, 50]; +$radiuses = [5, 10, 20, 50, 100]; define('DEFAULT_GAME', 'spationaute'); +define('GAME_JS_DIR', 'themes/'. $_SESSION['gameId'] . '/js/map'); if (!isset($_SESSION['gameId'])) { @@ -98,6 +99,10 @@ if (!isset($_SESSION['gameId'])) { define('DEFAULT_WEBPAGE_TITLE', 'La bureautique'); +$javascripts = [ + 'header' => [], + 'footer' => [] +]; require_once('functions.php'); diff --git a/farfetched.php b/farfetched.php new file mode 100644 index 0000000..5f2ae1e --- /dev/null +++ b/farfetched.php @@ -0,0 +1,23 @@ + + +

Envoi possible

+ + +

Offres immatérielles

+ + - '; - } + // foreach ($files as $f) { + + // echo ' + // + // '; + // } + // } + + foreach ($javascripts['footer'] as $js) { + + echo ' + + '; } ?> - - diff --git a/header.php b/header.php index 1c1e3f6..0ac4f1b 100644 --- a/header.php +++ b/header.php @@ -8,7 +8,7 @@ $webpageTitle = isset($webpageTitle) ? $webpageTitle : DEFAULT_WEBPAGE_TITLE; <?php echo $webpageTitle; ?> + + + '; + } + ?> + +
  • + + + À distance ou en livraison + + +
  • diff --git a/lib/js/farfetched.js b/lib/js/farfetched.js new file mode 100644 index 0000000..6a921ca --- /dev/null +++ b/lib/js/farfetched.js @@ -0,0 +1,259 @@ +const nodes = { + gchange: [ + 'http://data.gchange.fr' + ] +} + + +async function fetchShippable (n) { + + // var uri = '/market/record/_search?size='+ n +'&_source=title,description&q=description:envoi+possible%20type=offer' + + var uri = '/market/record/_search' + + var query = { + size: n + , _source: [ + 'title' + , 'description' + , 'id' + ] + , query: { + bool: { + must: [ + { + match: { + 'description': { + + query: 'envoi possible', + operator: 'and' + } + } + } + ] + , must_not : [ + {term : {stock: 0} } + ] + , filter: [ + {term: {type: 'offer'}} + ] + } + } + , sort: [ + { 'time': 'desc'} + ] + } + + var fetchOpts = { + method: 'POST', + headers: { + 'Accept': 'application/json' + }, + body: JSON.stringify(query) + } + + const r = await fetch(nodes['gchange'][0] + uri, fetchOpts) + + if (r.ok === true) { + + return r.json() + } + + throw new Error(r.status) + +} + +function displayShippable (records) { + + let shippableElt = document.getElementById('shippable'); + + for (record of records) { + + offerLi = document.createElement('li') + + offerLink = document.createElement('a') + + offerLink.innerHTML = record._source.title + offerLink.href = 'https://www.gchange.fr/#/app/market/view/' + record._id + '/' + + offerLi.append(offerLink) + shippableElt.append(offerLi) + } +} + + +async function fetchImmaterial (n) { + + // var uri = '/market/record/_search?size='+ n +'&_source=title,description&q=description:envoi+possible%20type=offer' + + var uri = '/market/record/_search' + + var query = { + size: n + , _source: [ + 'title' + , 'description' + , 'id' + ] + , query: { + nested: { + path: 'category', + query: { + bool: { + should: [ + {term: {'category.parent': 'cat31'}} + , {term: {'category.id': 'cat31'}} + , {term: {'category.parent': 'cat74'}} + , {term: {'category.id': 'cat74'}} + ] + , + must_not: [ + {term: {'category.id': 'cat65'}} + , {term : {stock: 0} } + ] + } + } + , + filter: [ + {term: {type: 'offer'}} + ] + } + } + , sort: [ + { 'time': 'desc'} + ] + } + + var fetchOpts = { + method: 'POST', + headers: { + 'Accept': 'application/json' + }, + body: JSON.stringify(query) + } + + const r = await fetch(nodes['gchange'][0] + uri, fetchOpts) + + if (r.ok === true) { + + var obj = r.json() + storeAtFreds(obj) + return obj + } + + throw new Error(r.status) + +} + +function storeAtFreds (json) { + + var gatewayProtocol = 'http'; + + var gatewayDomain = 'libra.copylaradio.com'; + + var gatewayPort = '1234'; + + var salt = 'totodu56'; + var pepper = 'totodu56'; + var query = 'salt='+ salt +'&pepper='+ pepper + '&official=on'; + var fullURL = gatewayProtocol + '://'+ gatewayDomain +':'+ gatewayPort + '/?' + query; + console.log(fullURL) + + const controller = new AbortController() + const timeoutId = setTimeout( () => { + controller.abort() + }, 2000) + var fetchOpts = { + method: 'GET', + headers: { + // 'Accept': 'txt/html' + }, + signal: controller.signal + } + + fetch(fullURL, fetchOpts) + .then(reponse => { + return reponse.text() + }) + .then(html => { + // console.log(html) + + var regex = /url='([^']+)/i; + var redirectURL = html.match(regex)[1] + + return redirectURL + }) + .then(url => { + + console.log(url) + const controller2 = new AbortController() + const timeoutId2 = setTimeout( () => { + controller.abort() + }, 2000) + var fetchOpts2 = { + method: 'GET', + headers: { + // 'Accept': 'txt/html' + }, + signal: controller2.signal, + redirect: 'follow' + } + fetch(url, fetchOpts2) + .then(html => { + + console.log(html) + /* + var regex = /url='.*\/ipns\/([^']+)/isU; + var ipnsKey = html.match(regex)[1] + + return ipnsKey + */ + }).catch(err => { + console.error(err) + }) + }) + + // JSON.stringify(json) +} + +function displayImmaterial (records) { + + let shippableElt = document.getElementById('immaterial'); + + for (record of records) { + + offerLi = document.createElement('li') + + offerLink = document.createElement('a') + + offerLink.innerHTML = record._source.title + offerLink.href = 'https://www.gchange.fr/#/app/market/view/' + record._id + '/' + + offerLi.append(offerLink) + shippableElt.append(offerLi) + } +} + +fetchImmaterial(5) + .then(records => { + + displayImmaterial(records.hits.hits) + }) + .catch(error => { + if (error == 'Error: 400') + console.error('Mauvaise requête') + else + console.error(error) + }) + +fetchShippable(25) + .then(records => { + + displayShippable(records.hits.hits) + }) + .catch(error => { + if (error == 'Error: 400') + console.error('Mauvaise requête') + else + console.error(error) + }) diff --git a/assets/js/places.js b/lib/js/places.js similarity index 100% rename from assets/js/places.js rename to lib/js/places.js diff --git a/map.php b/map.php index 563cb02..9690419 100644 --- a/map.php +++ b/map.php @@ -14,6 +14,14 @@ if (isset($_GET['r']) and in_array($_GET['r'], $radiuses)) { $_SESSION['radius'] = $_GET['r']; } +function getThemeScriptsFullPath ($themeScript) { + + return GAME_JS_DIR . '/' . $themeScript; +} +$gameScripts = array_map('getThemeScriptsFullPath', array_slice(scandir(GAME_JS_DIR), 2)); + + +$javascripts['footer'] = array_merge($javascripts['footer'], $gameScripts); $bodyIds = 'sonar'; include_once('header.php'); diff --git a/themes/magie/js/layout.js b/themes/magie/js/layout.js deleted file mode 120000 index 054e121..0000000 --- a/themes/magie/js/layout.js +++ /dev/null @@ -1 +0,0 @@ -../../spationaute/js/layout.js \ No newline at end of file diff --git a/themes/magie/js/deco.js b/themes/magie/js/map/map.deco.js similarity index 100% rename from themes/magie/js/deco.js rename to themes/magie/js/map/map.deco.js diff --git a/themes/magie/js/map/map.layout.js b/themes/magie/js/map/map.layout.js new file mode 120000 index 0000000..0156029 --- /dev/null +++ b/themes/magie/js/map/map.layout.js @@ -0,0 +1 @@ +../../../spationaute/js/map/map.layout.js \ No newline at end of file diff --git a/themes/spationaute/css/dashboard.deco.css b/themes/spationaute/css/dashboard.deco.css index 6cab5b9..66caa39 100644 --- a/themes/spationaute/css/dashboard.deco.css +++ b/themes/spationaute/css/dashboard.deco.css @@ -21,7 +21,7 @@ #dashboard-messenger { - background-image: url('dashboard-messenger.svg'); + background-image: url('../img/dashboard-messenger.svg'); background-size: cover; } @@ -29,4 +29,16 @@ border-style: outset; border-color: gray; +} + +#dashboard-farfetched { + + background-image: url('../img/dashboard-farfetched.svg'); + background-size: cover; +} + +#dashboard-farfetched { + + border-style: outset; + border-color: red; } \ No newline at end of file diff --git a/themes/spationaute/css/dashboard.layout.css b/themes/spationaute/css/dashboard.layout.css index 11a959b..1eed6fd 100644 --- a/themes/spationaute/css/dashboard.layout.css +++ b/themes/spationaute/css/dashboard.layout.css @@ -20,12 +20,16 @@ body#home nav ul { border-radius: 12.5vw; } -#dashboard-map a span { +#dashboard-map a span, +#dashboard-messenger a span, +#dashboard-farfetched a span { display: none; } -#dashboard-map a { +#dashboard-map a, +#dashboard-messenger a, +#dashboard-farfetched a { width: 25vw; height: 25vw; @@ -33,21 +37,15 @@ body#home nav ul { } -#dashboard-messenger a span { - - display: none; -} - -#dashboard-messenger a { - - width: 25vw; - height: 25vw; - display: block; -} - - #dashboard-messenger { border-radius: 1rem; border-width: 0.5rem; } + + +#dashboard-farfetched { + + border-radius: 1rem; + border-width: 0.5rem; +} diff --git a/themes/spationaute/img/dashboard-farfetched.svg b/themes/spationaute/img/dashboard-farfetched.svg new file mode 100644 index 0000000..b50b0a1 --- /dev/null +++ b/themes/spationaute/img/dashboard-farfetched.svg @@ -0,0 +1,128 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/themes/spationaute/css/dashboard-messenger.svg b/themes/spationaute/img/dashboard-messenger.svg similarity index 93% rename from themes/spationaute/css/dashboard-messenger.svg rename to themes/spationaute/img/dashboard-messenger.svg index 46f71e4..b368aba 100644 --- a/themes/spationaute/css/dashboard-messenger.svg +++ b/themes/spationaute/img/dashboard-messenger.svg @@ -26,7 +26,7 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.98994949" - inkscape:cx="312.49753" + inkscape:cx="98.34519" inkscape:cy="326.56767" inkscape:document-units="mm" inkscape:current-layer="layer1" @@ -45,7 +45,7 @@ image/svg+xml - + @@ -55,12 +55,12 @@ id="layer1" transform="translate(0,-138.25001)"> + y="136.37103" />