diff --git a/dist/views/admin/assets/scripts.pug b/dist/views/admin/assets/scripts.pug
index 62f9b70..d268914 100644
--- a/dist/views/admin/assets/scripts.pug
+++ b/dist/views/admin/assets/scripts.pug
@@ -1,3 +1,3 @@
script(async defer src="https://buttons.github.io/buttons.js")
//script(src='../js/admin.js')
-script(src="http://localhost:8080/admin.js")
\ No newline at end of file
+script(src="http://localhost:8084/admin.js")
\ No newline at end of file
diff --git a/dist/views/main/assets/scripts.pug b/dist/views/main/assets/scripts.pug
index e942ff5..65e6208 100644
--- a/dist/views/main/assets/scripts.pug
+++ b/dist/views/main/assets/scripts.pug
@@ -1,4 +1,4 @@
// Script JS
//script(src='../js/main.js')
-script(src='http://localhost:8080/main.js')
+script(src='http://localhost:8084/main.js')
script(src="../js/disqus.js")
\ No newline at end of file
diff --git a/dist/views/main/contacts.pug b/dist/views/main/contacts.pug
index b7f1da4..90ab0c0 100644
--- a/dist/views/main/contacts.pug
+++ b/dist/views/main/contacts.pug
@@ -19,7 +19,7 @@ main.main-section
p
strong Контакты
p
- p(style="white-space: pre-wrap;") #{store.contacts}
+ != store.contacts
//- Footer Template
diff --git a/dist/views/main/how-to-buy.pug b/dist/views/main/how-to-buy.pug
index 743a35c..7d727c6 100644
--- a/dist/views/main/how-to-buy.pug
+++ b/dist/views/main/how-to-buy.pug
@@ -19,7 +19,7 @@ main.main-section
p
strong Для того, чтобы купить аккаунты в магазине, нужно проделать следующие шаги:
p
- p(style="white-space: pre-wrap;") #{store.howToBuy}
+ != store.howToBuy
//- Footer Template
diff --git a/dist/views/main/index.pug b/dist/views/main/index.pug
index ee08fae..2214cec 100644
--- a/dist/views/main/index.pug
+++ b/dist/views/main/index.pug
@@ -16,7 +16,7 @@ main.main-section
.information-title
h2.small-title Важная информация:
.information-text
- p(style="white-space: pre-wrap;") #{store.info}
+ != store.info
.information-close
button#information-close.waves-effect.btn.red Закрыть
// Information Block END
@@ -95,7 +95,7 @@ main.main-section
.items-info__title.block-title
i.material-icons info
h3.med-title Информация
- p(style="white-space: pre-wrap;") #{store.infoBottom}
+ != store.infoBottom
// Items Block END
//- Footer Template
diff --git a/dist/views/main/product.pug b/dist/views/main/product.pug
index 6ffa41c..6874c16 100644
--- a/dist/views/main/product.pug
+++ b/dist/views/main/product.pug
@@ -39,15 +39,15 @@ main.main-section
.product-right__title
span Описание:
hr
- p #{description}
+ != description
.product-right__content
h2 Тип аккаунтов #{category}
- p #{type}
+ != type
h2 Формат аккаунтов #{category}
- p #{format}
+ != format
hr
h3 Рекомендации к покупке аккаунтов.
- p #{store.recommendations}
+ != store.recommendations
h3 Отзывы о товаре
#disqus_thread
diff --git a/package-lock.json b/package-lock.json
index 25c05f1..e635a4c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4817,6 +4817,11 @@
"object-visit": "^1.0.0"
}
},
+ "marked": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/marked/-/marked-1.1.0.tgz",
+ "integrity": "sha512-EkE7RW6KcXfMHy2PA7Jg0YJE1l8UPEZE8k45tylzmZM30/r1M1MUXWQfJlrSbsTeh7m/XTwHbWUENvAJZpp1YA=="
+ },
"md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
diff --git a/package.json b/package.json
index 87af4af..ce99c83 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"express-flash": "0.0.2",
"express-session": "^1.17.0",
"log4js": "^6.1.0",
+ "marked": "^1.1.0",
"method-override": "^3.0.0",
"mongodb": "^3.3.4",
"multer": "^1.4.2",
diff --git a/server/routes/main.js b/server/routes/main.js
index 09ffc7d..2b124a4 100644
--- a/server/routes/main.js
+++ b/server/routes/main.js
@@ -1,162 +1,178 @@
-const ObjectID = require('mongodb').ObjectID;
-const nodemailer = require('../config/nodemailer.config');
+const ObjectID = require('mongodb').ObjectID
+const marked = require('marked')
+const nodemailer = require('../config/nodemailer.config')
module.exports = function (server, db) {
- server.get('/', async (req, res) => {
- try {
- const store = await db.collection('content').findOne({});
- db.collection('categories').find().toArray((err, result) => {
- const categories = result.map(category => category.title[0].toUpperCase() + category.title.slice(1));
- res.render('main/index', {
- pageName: 'index',
- title: `${store.title} | Главная`,
- categories,
- store: {
- title: store.title,
- info: store.info,
- infoBottom: store.infoBottom,
- color: store.color
- }
- });
- });
- } catch {
- res.status(500).render('main/404');
- }
- });
- server.get('/how-to-buy', async (req, res) => {
- try {
- const store = await db.collection('content').findOne({});
- res.render('main/how-to-buy', {
- pageName: 'how-to-buy',
- title: `${store.title} | Как купить товар`,
- store: {
- title: store.title,
- howToBuy: store.howToBuy,
- color: store.color
- }
- });
- } catch {
- res.status(500).render('main/404');
- }
- });
- server.get('/contacts', async (req, res) => {
- try {
- const store = await db.collection('content').findOne({});
- res.render('main/contacts', {
- pageName: 'contacts',
- title: `${store.title} | Контакты`,
- store: {
- title: store.title,
- contacts: store.contacts,
- color: store.color
- }
- });
- } catch {
- res.status(500).render('main/404');
- }
- });
- server.get('/comments', async (req, res) => {
- try {
- const store = await db.collection('content').findOne({});
- res.render('main/comments', {
- pageName: 'comments',
- title: `${store.title} | Отзывы`,
- store: {
- title: store.title,
- color: store.color
- }
- });
- } catch {
- res.status(500).render('main/404');
- }
- });
- server.get('/my-orders', async (req, res) => {
- try {
- const store = await db.collection('content').findOne({});
- res.render('main/my-orders', {
- pageName: 'my-orders',
- title: `${store.title} | Мои покупки`,
- store: {
- title: store.title,
- color: store.color
- }
- });
- } catch {
- res.status(500).render('main/404');
- }
- });
- server.get('/product/:id', async (req, res) => {
- const store = await db.collection('content').findOne({});
- const product = new Promise((resolve, reject) => {
- db.collection('items').find({_id: ObjectID(req.params.id)}).toArray()
- .then((items) => {
- const item = items.find(item => item);
- resolve(item);
- });
- });
-
- product.then((item) => {
- return new Promise((resolve, reject) => {
- db.collection('categories').find({title: item.category}).toArray()
- .then((categories) => {
- const category = categories.find(category => category);
- resolve({item, category});
- });
- });
+ server.get('/', async (req, res) => {
+ try {
+ const store = await db.collection('content').findOne({})
+ db.collection('categories')
+ .find()
+ .toArray((err, result) => {
+ const categories = result.map(
+ (category) =>
+ category.title[0].toUpperCase() + category.title.slice(1)
+ )
+ res.render('main/index', {
+ pageName: 'index',
+ title: `${store.title} | Главная`,
+ categories,
+ store: {
+ title: store.title,
+ info: marked(store.info),
+ infoBottom: marked(store.infoBottom),
+ color: store.color,
+ },
+ })
})
- .then(((data) => {
- const item = data.item,
- category = data.category;
- res.render('main/product', {
- title: item.title,
- image: category.img,
- count: item.count,
- category: item.category[0].toUpperCase() + item.category.slice(1),
- price: item.price,
- description: item.description,
- date: item.date,
- id: item._id,
- type: category.type,
- format: category.format,
- store: {
- title: store.title,
- recommendations: store.recommendations,
- color: store.color
- }
- });
- }))
- .catch(() => {
- res.status(500).render('main/404');
- });
- });
- server.post('/my-orders', async (req, res) => {
- const buyers = await db.collection('buyers').find({email: req.body.email}).toArray();
- if (buyers.length > 0) {
- // рендерим html
- const html = buyers.map((buyer) => {
- return `
+ } catch {
+ res.status(500).render('main/404')
+ }
+ })
+ server.get('/how-to-buy', async (req, res) => {
+ try {
+ const store = await db.collection('content').findOne({})
+ res.render('main/how-to-buy', {
+ pageName: 'how-to-buy',
+ title: `${store.title} | Как купить товар`,
+ store: {
+ title: store.title,
+ howToBuy: marked(store.howToBuy),
+ color: store.color,
+ },
+ })
+ } catch {
+ res.status(500).render('main/404')
+ }
+ })
+ server.get('/contacts', async (req, res) => {
+ try {
+ const store = await db.collection('content').findOne({})
+ res.render('main/contacts', {
+ pageName: 'contacts',
+ title: `${store.title} | Контакты`,
+ store: {
+ title: store.title,
+ contacts: marked(store.contacts),
+ color: store.color,
+ },
+ })
+ } catch {
+ res.status(500).render('main/404')
+ }
+ })
+ server.get('/comments', async (req, res) => {
+ try {
+ const store = await db.collection('content').findOne({})
+ res.render('main/comments', {
+ pageName: 'comments',
+ title: `${store.title} | Отзывы`,
+ store: {
+ title: store.title,
+ color: store.color,
+ },
+ })
+ } catch {
+ res.status(500).render('main/404')
+ }
+ })
+ server.get('/my-orders', async (req, res) => {
+ try {
+ const store = await db.collection('content').findOne({})
+ res.render('main/my-orders', {
+ pageName: 'my-orders',
+ title: `${store.title} | Мои покупки`,
+ store: {
+ title: store.title,
+ color: store.color,
+ },
+ })
+ } catch {
+ res.status(500).render('main/404')
+ }
+ })
+ server.get('/product/:id', async (req, res) => {
+ const store = await db.collection('content').findOne({})
+ const product = new Promise((resolve, reject) => {
+ db.collection('items')
+ .find({ _id: ObjectID(req.params.id) })
+ .toArray()
+ .then((items) => {
+ const item = items.find((item) => item)
+ resolve(item)
+ })
+ })
+
+ product
+ .then((item) => {
+ return new Promise((resolve, reject) => {
+ db.collection('categories')
+ .find({ title: item.category })
+ .toArray()
+ .then((categories) => {
+ const category = categories.find((category) => category)
+ resolve({ item, category })
+ })
+ })
+ })
+ .then((data) => {
+ const item = data.item,
+ category = data.category
+ res.render('main/product', {
+ title: item.title,
+ image: category.img,
+ count: item.count,
+ category: item.category[0].toUpperCase() + item.category.slice(1),
+ price: item.price,
+ description: marked(item.description),
+ date: item.date,
+ id: item._id,
+ type: marked(category.type),
+ format: marked(category.format),
+ store: {
+ title: store.title,
+ recommendations: marked(store.recommendations),
+ color: store.color,
+ },
+ })
+ })
+ .catch(() => {
+ res.status(500).render('main/404')
+ })
+ })
+ server.post('/my-orders', async (req, res) => {
+ const buyers = await db
+ .collection('buyers')
+ .find({ email: req.body.email })
+ .toArray()
+ if (buyers.length > 0) {
+ // рендерим html
+ const html = buyers.map((buyer) => {
+ return `
Номер заказа: ${buyer.bill_id}
- Дата оплаты: ${new Date(buyer.date).toLocaleDateString()}
+ Дата оплаты: ${new Date(
+ buyer.date
+ ).toLocaleDateString()}
Данные товара:
${buyer.data.join('
')}
======================================================================
- `; - }); + ` + }) - // высылаем данные покупателю - try { - await nodemailer.transporter.sendMail({ - from: `"Ваши покупки." <${process.env.EMAIL_LOGIN}>`, - to: req.body.email, - subject: "Данные купленных товаров находятся в этом письме.", - html: html.join('') - }); - res.json({status: 'OK'}); - } catch (error) { - res.json({status: 'ERR'}); - } - } else { - res.json({status: 'NF'}); - } - }); + // высылаем данные покупателю + try { + await nodemailer.transporter.sendMail({ + from: `"Ваши покупки." <${process.env.EMAIL_LOGIN}>`, + to: req.body.email, + subject: 'Данные купленных товаров находятся в этом письме.', + html: html.join(''), + }) + res.json({ status: 'OK' }) + } catch (error) { + res.json({ status: 'ERR' }) + } + } else { + res.json({ status: 'NF' }) + } + }) }