Market Gaps
-Find a profitable difference between the price of the set and the price of the sum of it's parts.
+{{t.title}}
+{{t.description}}
diff --git a/.gitignore b/.gitignore index b2c48e4..f4511b8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ node_modules .DS_Store .vscode .env -public/index.html +public/*.html diff --git a/README.md b/README.md index 09657ae..ccac798 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ Список Прайм предметов: https://warframe.fandom.com/wiki/Prime Маркет: https://warframe.market + +Документация API маркета: https://warframe.market/api_docs diff --git a/ecosystem.config.js b/ecosystem.config.js index 46c2429..58a1044 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -3,7 +3,7 @@ module.exports = { name: 'warframe-market-bot', script: './src/index.js', watch: true, - ignore_watch: ['node_modules', 'index.html'], + ignore_watch: ['node_modules', 'public/*'], restart_delay: 600000 }] } diff --git a/public/assets/languages/de.png b/public/assets/languages/de.png new file mode 100644 index 0000000..08bb6ee Binary files /dev/null and b/public/assets/languages/de.png differ diff --git a/public/assets/languages/en.png b/public/assets/languages/en.png new file mode 100644 index 0000000..b88a70a Binary files /dev/null and b/public/assets/languages/en.png differ diff --git a/public/assets/languages/fr.png b/public/assets/languages/fr.png new file mode 100644 index 0000000..3891f14 Binary files /dev/null and b/public/assets/languages/fr.png differ diff --git a/public/assets/languages/ru.png b/public/assets/languages/ru.png new file mode 100644 index 0000000..e61ed36 Binary files /dev/null and b/public/assets/languages/ru.png differ diff --git a/public/assets/languages/ua.png b/public/assets/languages/ua.png new file mode 100644 index 0000000..001b9c4 Binary files /dev/null and b/public/assets/languages/ua.png differ diff --git a/public/style.css b/public/style.css index e98ae30..1b6f211 100644 --- a/public/style.css +++ b/public/style.css @@ -94,6 +94,24 @@ a { right: 0; } +.languages { + position: absolute; + left: 0; + top: 0; +} + +.languages > a { + position: relative; + display: block; + margin: 10px; + padding: 10px; + height: 32px; +} + +.languages img { + max-height: 100%; +} + .controls { margin: 32px auto; display: flex; diff --git a/src/output/OutputItem.js b/src/output/ListingSet.js similarity index 85% rename from src/output/OutputItem.js rename to src/output/ListingSet.js index 9b90e7c..b7d435d 100644 --- a/src/output/OutputItem.js +++ b/src/output/ListingSet.js @@ -1,4 +1,4 @@ -module.exports = class OutputItem { +module.exports = class ListingSet { constructor (name, parts, set) { this.name = name + ' prime' this.parts = parts diff --git a/src/output/i18n.json b/src/output/i18n.json new file mode 100644 index 0000000..403ab7d --- /dev/null +++ b/src/output/i18n.json @@ -0,0 +1,22 @@ +{ + "en": { + "title": "Market Gaps", + "description": "Find a profitable difference between the price of the set and the price of the sum of it's parts.", + "filter_by_difference": "Filter by difference:", + "name": "Name", + "parts_price": "Parts price", + "set_price": "Set price", + "difference": "Difference", + "generated_at": "Generated at" + }, + "ru": { + "title": "Market Gaps", + "description": "Находите выгоду между покупкой сета по отдельности и продажей его в собранном виде.", + "filter_by_difference": "Фильтровать по разнице:", + "name": "Название", + "parts_price": "Стоимость частей", + "set_price": "Стоимость сета", + "difference": "Разница", + "generated_at": "Сгенерировано в" + } +} \ No newline at end of file diff --git a/src/output/index.js b/src/output/index.js index ab06236..125c95c 100644 --- a/src/output/index.js +++ b/src/output/index.js @@ -1,6 +1,7 @@ const fs = require('fs') const Handlebars = require('handlebars') -const OutputItem = require('./OutputItem') +const ListingSet = require('./ListingSet') +const i18n = require('./i18n.json') class Output { constructor () { @@ -9,18 +10,15 @@ class Output { } addItem (...p) { - this.items.push(new OutputItem(...p)) + this.items.push(new ListingSet(...p)) } - async compileTemplate () { + async _compileTemplate () { const templateFile = await fs.readFileSync('./src/output/template.hbs', 'utf8') - const template = Handlebars.compile(templateFile) - return template(this) + return Handlebars.compile(templateFile) } - async writeToFile (content) { - const filename = './public/index.html' - + async _writeToFile (filename, content) { try { await fs.unlinkSync(filename) } catch { @@ -31,8 +29,16 @@ class Output { async submit () { this.timestamp = new Date() - const content = await this.compileTemplate() - await this.writeToFile(content) + const template = await this._compileTemplate() + + Object.keys(i18n).forEach(locale => { + const filename = locale === 'en' ? 'index' : locale + this._writeToFile(`./public/${filename}.html`, template({ + ...this, + t: i18n[locale], + languages: Object.keys(i18n).filter(language => language !== locale) + })) + }) } } diff --git a/src/output/template.hbs b/src/output/template.hbs index 267fc1f..83df8b4 100644 --- a/src/output/template.hbs +++ b/src/output/template.hbs @@ -28,16 +28,24 @@
Find a profitable difference between the price of the set and the price of the sum of it's parts.
+{{t.description}}
+
+
+
+ {{/each}}
+ | Name | -Parts price | -Set price | -Difference | +{{t.name}} | +{{t.parts_price}} | +{{t.set_price}} | +{{t.difference}} |
|---|