Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first step #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules/
node_modules/
.idea/
52 changes: 52 additions & 0 deletions Backend/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Created by chaika on 09.02.16.
*/
var Pizza_List = require('./data/Pizza_List');
var LIQPAY_PUBLIC_KEY = 'i44678216860';
var LIQPAY_PRIVATE_KEY = 'PQwLmIFcKU0XiVqVTgzFBLRTDAfNjtUkg0wwAAWQ';
var data;
var signature;
var crypto = require('crypto');

function sha1(string) {
var sha1 = crypto.createHash('sha1');
sha1.update(string);
return sha1.digest('base64');
}

function base64(str) {
return new Buffer(str).toString('base64');
}

exports.getPizzaList = function(req, res) {
res.send(Pizza_List);
};

exports.createOrder = function(req, res) {
var order_info = req.body;
console.log("Creating Order", order_info);
var pizzas = '';
for (var i = 0; i < order_info.pizza.length; i++) {
pizzas += '\n - ' + order_info.pizza[i].quantity + 'шт. [' + order_info.pizza[i].size + '] ' + order_info.pizza[i].name_pizza + ' ' + order_info.pizza[i].price + ' грн;';
}
var order = {
version: 3,
public_key: LIQPAY_PUBLIC_KEY,
action: "pay",
amount: order_info.price,
currency: "UAH",
description: "Замовлення піци: " + order_info.name + "\n Адреса доставки: " + order_info.address + "\n Телефон: " + order_info.phone + "\n Замовлення: " + pizzas + "\n Сума: " + order_info.price + " грн.",
order_id: Math.random(),
sandbox: 1
};
data = base64(JSON.stringify(order));
signature = sha1(LIQPAY_PRIVATE_KEY + data + LIQPAY_PRIVATE_KEY);
res.send({
success: true,
name: order_info.name,
address: order_info.address,
phone: order_info.phone,
data: data,
signature: signature
});
};
177 changes: 177 additions & 0 deletions Backend/data/Pizza_List.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/**
* Created by diana on 12.01.16.
*/

var pizza_info = [
{
id:1,
icon:'assets/images/pizza_7.jpg',
title: "Імпреза",
type: 'М’ясна піца',
content: {
meat: ['балик', 'салямі'],
chicken: ['куриця'],
cheese: ['сир моцарелла', 'сир рокфорд'],
pineapple: ['ананаси'],
additional: ['томатна паста', 'петрушка']
},
small_size:{
weight: 370,
size: 30,
price: 99
},
big_size:{
weight: 660,
size: 40,
price: 169
},
is_new:true,
is_popular:true

},
{
id:2,
icon:'assets/images/pizza_2.jpg',
title: "BBQ",
type: 'М’ясна піца',
content: {
meat: ['мисливські ковбаски', 'ковбаски папероні', 'шинка'],
cheese: ['сир домашній'],
mushroom: ['шампінйони'],
additional: ['петрушка', 'оливки']
},
small_size:{
weight: 460,
size: 30,
price: 139
},
big_size:{
weight: 840,
size: 40,
price: 199
},
is_popular:true
},
{
id:3,
icon:'assets/images/pizza_1.jpg',
title: "Міксовий поло",
type: 'М’ясна піца',
content: {
meat: ['вітчина', 'куриця копчена'],
cheese: ['сир моцарелла'],
pineapple: ['ананаси'],
additional: ['кукурудза', 'петрушка', 'соус томатний']
},
small_size:{
weight: 430,
size: 30,
price: 115
},
big_size:{
weight: 780,
size: 40,
price: 179
}
},
{
id:4,
icon:'assets/images/pizza_5.jpg',
title: "Сициліано",
type: 'М’ясна піца',
content: {
meat: ['вітчина', 'салямі'],
cheese: ['сир моцарелла'],
mushroom: ['шампінйони'],
additional: ['перець болгарський', 'соус томатний']
},
small_size:{
weight: 450,
size: 30,
price: 111
},
big_size:{
weight: 790,
size: 40,
price: 169
}
},
{
id:5,
icon:'assets/images/pizza_3.jpg',
title: "Маргарита",
type: 'Вега піца',
content: {
cheese: ['сир моцарелла', 'сир домашній'],
tomato: ['помідори'],
additional: ['базилік', 'оливкова олія', 'соус томатний']
},
small_size:{
weight: 370,
size: 30,
price: 89
}
},
{
id:6,
icon:'assets/images/pizza_6.jpg',
title: "Мікс смаків",
type: 'М’ясна піца',
content: {
meat: ['ковбаски'],
cheese: ['сир моцарелла'],
mushroom: ['шампінйони'],
pineapple: ['ананаси'],
additional: ['цибуля кримська', 'огірки квашені', 'соус гірчичний']
},
small_size:{
weight: 470,
size: 30,
price: 115
},
big_size:{
weight: 780,
size: 40,
price: 180
}
},
{
id:7,
icon:'assets/images/pizza_8.jpg',
title: "Дольче Маре",
type: 'Морська піца',
content: {
ocean: ['криветки тигрові', 'мідії', 'ікра червона', 'філе червоної риби'],
cheese: ['сир моцарелла'],
additional: ['оливкова олія', 'вершки']
},
big_size:{
weight: 845,
size: 40,
price: 399
}
},
{
id:8,
icon:'assets/images/pizza_4.jpg',
title: "Россо Густо",
type: 'Морська піца',
content: {
ocean: ['ікра червона', 'лосось копчений'],
cheese: ['сир моцарелла'],
additional: ['оливкова олія', 'вершки']
},
small_size:{
weight: 400,
size: 30,
price: 189
},
big_size:{
weight: 700,
size: 40,
price: 299
}
}
];

module.exports = pizza_info;
53 changes: 53 additions & 0 deletions Backend/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Created by chaika on 09.02.16.
*/
var express = require('express');
var path = require('path');
var morgan = require('morgan');
var bodyParser = require('body-parser');

function configureEndpoints(app) {
var pages = require('./pages');
var api = require('./api');

//Налаштування URL за якими буде відповідати сервер
//Отримання списку піц
app.get('/api/get-pizza-list/', api.getPizzaList);
app.post('/api/create-order/', api.createOrder);

//Сторінки
//Головна сторінка
app.get('/', pages.mainPage);

//Сторінка замовлення
app.get('/order.html', pages.orderPage);

//Якщо не підійшов жоден url, тоді повертаємо файли з папки www
app.use(express.static(path.join(__dirname, '../Frontend/www')));
}

function startServer(port) {
//Створюється застосунок
var app = express();

//Налаштування директорії з шаблонами
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

//Налаштування виводу в консоль списку запитів до сервера
app.use(morgan('dev'));

//Розбір POST запитів
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

//Налаштовуємо сторінки
configureEndpoints(app);

//Запуск додатка за вказаним портом
app.listen(port, function () {
console.log('My Application Running on http://localhost:'+port+'/');
});
}

exports.startServer = startServer;
15 changes: 15 additions & 0 deletions Backend/pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Created by chaika on 09.02.16.
*/
exports.mainPage = function(req, res) {
res.render('mainPage', {
pageTitle: 'Вибір Піци'
});
};

exports.orderPage = function(req, res) {
//TODO: implement
res.render('orderPage', {
pageTitle: 'Оформлення замовлення'
})
};
9 changes: 9 additions & 0 deletions Backend/views/common/footer.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="bottom-discount">
<div class="title-discount">цього тижня на все</div>
<div class="content-discount">-20%</div>
<img id="discountsecond" src="assets/images/discount.svg">
</div>
<div class="footer">
<p>Pizza.22 - практичний проект в межах курсу JavaScript в Києво-Могилянській Академії</p>
<p>Доставка піци не здійснюється</p>
</div>
22 changes: 22 additions & 0 deletions Backend/views/common/header.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="top-panel">
<div class="row top-info">
<div class="col-lg-3 visible-xs-inline-block visible-sm-inline-block visible-md-inline-block visible-lg-inline-block number">
(044) 222 5 222
</div>
<div class="col-lg-3 visible-lg-inline-block visible-md-inline-block time-work">
24 години/7 днів на тиждень
</div>
<div class="col-lg-3 visible-lg-inline-block price-deliver">
Безкоштовна доставка піци
</div>
<span class="btn btn-warning enter">Ввійти</span>
</div>
<div class="pizza-link">
<a class="hidden-xs" href="/">Піца</a>
</div>
<div class="top-discount">
<a href="/">PIZZA</a>
KMA
<img id="discount" src="assets/images/discount.svg">
</div>
</div>
8 changes: 8 additions & 0 deletions Backend/views/common/mainFooter.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!-- jQuery JavaScript -->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!--Bootsrap JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!--Own JavaScript -->
<script type="text/javascript" src="assets/js/main.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions Backend/views/common/mainHeader.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= pageTitle %> - Pizza</title>
<!-- Bootsrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- LESS основний файл -->
<link rel="stylesheet/less" type="text/css" href="assets/less/main.less" />
<!-- LESS JavaScript компілятор -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.5.3/less.min.js"></script>
</head>
<body>
11 changes: 11 additions & 0 deletions Backend/views/common/orderFooter.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- jQuery JavaScript -->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!--Bootsrap JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<!--Own JavaScript -->
<script type="text/javascript" src="assets/js/main.js"></script>
<script type="text/javascript" src="assets/js/main_order.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCbXpGzmh0GlvWnCQLOIn6fJ9uclIczpo8"></script>
<script src="//static.liqpay.com/libjs/checkout.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions Backend/views/common/orderHeader.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= pageTitle %> - Pizza</title>
<!-- Bootsrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- LESS основний файл -->
<link rel="stylesheet/less" type="text/css" href="assets/less/main_order.less" />
<!-- LESS JavaScript компілятор -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.5.3/less.min.js"></script>
</head>
<body>
Loading