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

remove alll #61

Open
wants to merge 598 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
598 commits
Select commit Hold shift + click to select a range
0756574
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
4bd3ff3
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
8bd3d83
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
1cbe27a
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
02658e0
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
c229e49
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
12d53dc
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
38010af
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
5eb1db5
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
784be9a
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
8a28dbb
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
3c03db4
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
ab40aeb
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
154a252
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
2ab1b70
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
f229a05
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
3cae0a6
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
30110af
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
e0d5ec3
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
516ab37
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
15ece5c
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
c4ae468
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
788f436
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
9b47722
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
7ff4b3f
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
c04e114
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
712c64a
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
0f345da
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
77ba140
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
e01c255
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
3e875dd
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
5eb2c9c
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
2fd0ad3
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
c4c67ea
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
6d41316
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
e31d909
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
f2342e7
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
fcbb075
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
4fce825
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
b49d1ee
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
bb5e836
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
84e0803
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
bf180c3
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
23af58a
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
33a3b95
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
c10603e
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
bb56d7b
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
48e7825
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
98a9971
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
5c705c2
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
dd7ba30
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
2ffb592
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
c5e67b8
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
0265d30
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
8ef59f6
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
54bbabd
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
b48e3c9
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
2f89418
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
96071c1
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
430fefa
[imad-console] Updates ui/index.html
golua94 Nov 4, 2016
9554c79
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
c915efa
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
0d1b150
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
0a3174c
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
480c911
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
f29378a
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
9a26444
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
389649d
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
9fd10e0
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
78f5337
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
df84a9e
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
3f633a8
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
df16bbc
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
08c89e8
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
50ac3b0
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
57b5900
[imad-console] Updates ui/style.css
golua94 Nov 4, 2016
2627768
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
7caba34
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
c71c1db
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
a9e5973
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
7020321
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
4de9322
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
d98c03c
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
8ad176d
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
0354fc2
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
149f9db
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
6d7993a
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
9023e9b
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
545b230
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
1f52230
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
a8e0d81
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
a33e054
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
a5aa82c
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
07bf9ef
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
deb2405
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
b784820
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
85f676d
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
765319c
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
1460970
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
fff0ce9
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
551aae6
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
82122ef
[imad-console] Updates server.js
golua94 Nov 12, 2016
1ead5b8
[imad-console] Updates server.js
golua94 Nov 12, 2016
461b59c
[imad-console] Updates server.js
golua94 Nov 12, 2016
93a1534
[imad-console] Updates server.js
golua94 Nov 12, 2016
82d7193
[imad-console] Updates ui/style.css
golua94 Nov 12, 2016
33e5c73
[imad-console] Updates ui/index.html
golua94 Nov 12, 2016
d39a3c5
[imad-console] Updates server.js
golua94 Nov 12, 2016
29a309e
[imad-console] Updates server.js
golua94 Nov 12, 2016
a69219b
[imad-console] Updates server.js
golua94 Nov 12, 2016
0ae717a
[imad-console] Updates server.js
golua94 Nov 12, 2016
c75cc28
[imad-console] Updates server.js
golua94 Nov 12, 2016
c88f53c
[imad-console] Updates server.js
golua94 Nov 12, 2016
ca4b830
[imad-console] Updates server.js
golua94 Nov 12, 2016
25aaf98
[imad-console] Updates server.js
golua94 Nov 12, 2016
d49ecec
[imad-console] Updates server.js
golua94 Nov 12, 2016
bb0933f
[imad-console] Updates server.js
golua94 Nov 12, 2016
faf39d2
[imad-console] Updates server.js
golua94 Nov 12, 2016
3b814fb
[imad-console] Updates server.js
golua94 Nov 12, 2016
6505a69
[imad-console] Updates server.js
golua94 Nov 12, 2016
81f6c39
[imad-console] Updates server.js
golua94 Nov 12, 2016
b8b110b
[imad-console] Updates server.js
golua94 Nov 12, 2016
b0c30e4
[imad-console] Updates server.js
golua94 Nov 12, 2016
67b39cf
[imad-console] Updates server.js
golua94 Nov 12, 2016
e672f8f
[imad-console] Updates server.js
golua94 Nov 12, 2016
3d278a4
[imad-console] Updates server.js
golua94 Nov 12, 2016
2c0b63b
[imad-console] Updates server.js
golua94 Nov 12, 2016
7541d5f
[imad-console] Updates server.js
golua94 Nov 12, 2016
6bf9c49
[imad-console] Updates server.js
golua94 Nov 12, 2016
b4af5d1
[imad-console] Updates server.js
golua94 Nov 12, 2016
74c87fb
[imad-console] Updates server.js
golua94 Nov 12, 2016
0d952aa
[imad-console] Updates server.js
golua94 Nov 12, 2016
bbe961d
[imad-console] Updates server.js
golua94 Nov 18, 2016
46ba111
[imad-console] Updates server.js
golua94 Nov 18, 2016
c8caf6d
[imad-console] Updates server.js
golua94 Nov 18, 2016
f8e66a0
[imad-console] Updates server.js
golua94 Nov 18, 2016
167c160
[imad-console] Updates server.js
golua94 Nov 18, 2016
ff7705d
[imad-console] Updates server.js
golua94 Nov 18, 2016
097d666
[imad-console] Updates server.js
golua94 Nov 18, 2016
92d81f2
[imad-console] Updates server.js
golua94 Nov 18, 2016
029a64e
[imad-console] Updates server.js
golua94 Nov 18, 2016
cc94917
[imad-console] Updates server.js
golua94 Nov 18, 2016
6a4d018
[imad-console] Updates server.js
golua94 Nov 18, 2016
414f76f
[imad-console] Updates server.js
golua94 Nov 18, 2016
d27dd3b
[imad-console] Updates server.js
golua94 Nov 18, 2016
0a6cea8
[imad-console] Updates server.js
golua94 Nov 18, 2016
c2e224a
[imad-console] Updates server.js
golua94 Nov 19, 2016
6f2aca8
[imad-console] Updates server.js
golua94 Nov 19, 2016
dcb30dd
[imad-console] Updates server.js
golua94 Nov 19, 2016
f25e95f
[imad-console] Updates server.js
golua94 Nov 19, 2016
6411710
[imad-console] Updates server.js
golua94 Nov 19, 2016
27afd2e
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
88759f1
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
88148b2
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
3e62382
[imad-console] Updates server.js
golua94 Nov 19, 2016
6cac720
[imad-console] Updates server.js
golua94 Nov 19, 2016
c1d75d5
[imad-console] Updates server.js
golua94 Nov 19, 2016
3679145
[imad-console] Updates server.js
golua94 Nov 19, 2016
c243fa4
[imad-console] Updates ui/style.css
golua94 Nov 19, 2016
61abe19
[imad-console] Updates ui/style.css
golua94 Nov 19, 2016
c90f0ed
[imad-console] Updates server.js
golua94 Nov 19, 2016
2e2f750
[imad-console] Updates server.js
golua94 Nov 19, 2016
00b9906
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
0dc1b6a
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
aadb2cb
[imad-console] Updates server.js
golua94 Nov 19, 2016
c0408a2
[imad-console] Updates server.js
golua94 Nov 19, 2016
e6b4112
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
d5860f8
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
733e2d7
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
183750e
[imad-console] Updates server.js
golua94 Nov 19, 2016
22701c0
[imad-console] Updates server.js
golua94 Nov 19, 2016
4bb15a9
[imad-console] Updates server.js
golua94 Nov 19, 2016
a5bac10
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
4fd3018
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
b719902
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
a4a6d45
[imad-console] Updates server.js
golua94 Nov 19, 2016
096f0b3
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
b61a34f
[imad-console] Updates server.js
golua94 Nov 19, 2016
b29f920
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
7d9d9ee
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
31a7786
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
b988683
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
8f6e390
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
4f6376a
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
a50e198
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
7e73a9d
[imad-console] Updates ui/main.js
golua94 Nov 19, 2016
827bf39
[imad-console] Updates ui/index.html
golua94 Nov 19, 2016
51fdae4
[imad-console] Updates ui/index.html
golua94 Nov 20, 2016
b47184d
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
68b2250
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
ebcb7b3
[imad-console] Updates ui/index.html
golua94 Nov 20, 2016
9b1bc83
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
baa12d0
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
9d9bd1c
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
52e7098
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
01cabaf
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
389e5fc
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
38ff741
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
bdd1662
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
58ce01b
[imad-console] Updates server.js
golua94 Nov 20, 2016
dba72f1
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
e3c171e
[imad-console] Updates server.js
golua94 Nov 20, 2016
6d812d7
[imad-console] Updates ui/main.js
golua94 Nov 20, 2016
0f7dd64
[imad-console] Updates server.js
golua94 Nov 20, 2016
5c957c5
[imad-console] Updates server.js
golua94 Nov 20, 2016
abb107d
[imad-console] Updates server.js
golua94 Nov 20, 2016
faea7f9
[imad-console] Updates server.js
golua94 Nov 20, 2016
f5cec43
[imad-console] Updates server.js
golua94 Nov 20, 2016
d160bf5
updated index viku
golua94 Nov 26, 2016
b16d81e
added new file on 27 nov
golua94 Nov 26, 2016
4bae3aa
kk the don
golua94 Nov 26, 2016
1e314f6
chutiyappa on the floor
golua94 Nov 26, 2016
41087c4
kk boys
golua94 Nov 26, 2016
aa76b35
Delete server.js
golua94 Nov 26, 2016
29f770c
Add files via upload
golua94 Nov 26, 2016
1b3c06c
Delete package.json
golua94 Nov 26, 2016
8ef83bf
Delete .gitignore
golua94 Nov 26, 2016
12ce889
Add files via upload
golua94 Nov 26, 2016
edb27b6
Add files via upload
golua94 Nov 26, 2016
0bd1c3b
Delete server.js
golua94 Nov 26, 2016
1afd141
Delete package.json
golua94 Nov 26, 2016
5a7d29b
Add files via upload
golua94 Nov 26, 2016
3880b81
[imad-console] Updates server.js
golua94 Nov 27, 2016
6b6032e
[imad-console] Updates server.js
golua94 Nov 27, 2016
ac520d2
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
e6d5b26
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
cf62e5a
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
6aec35c
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
ffadf58
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
cfd0765
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
ab94068
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
754848b
[imad-console] Updates ui/index.html
golua94 Nov 27, 2016
1db6deb
[imad-console] Updates server.js
golua94 Nov 27, 2016
1b0c2dc
[imad-console] Updates server.js
golua94 Nov 27, 2016
89a8ffe
[imad-console] Updates ui/style.css
golua94 Nov 27, 2016
64eac08
[imad-console] Updates server.js
golua94 Nov 27, 2016
35a30da
[imad-console] Updates server.js
golua94 Nov 27, 2016
799eec7
[imad-console] Updates ui/article.js
golua94 Nov 27, 2016
4a30468
[imad-console] Updates ui/main.js
golua94 Nov 27, 2016
95e8b53
[imad-console] Updates ui/main.js
golua94 Nov 27, 2016
da954d5
[imad-console] Updates ui/main.js
golua94 Nov 27, 2016
721fd4c
[imad-console] Updates ui/main.js
golua94 Nov 27, 2016
cee4d77
[imad-console] Updates ui/style.css
golua94 Nov 27, 2016
9fb816b
[imad-console] Updates ui/style.css
golua94 Nov 27, 2016
a5e31ca
[imad-console] Updates ui/style.css
golua94 Nov 27, 2016
eb27d4f
[imad-console] Updates ui/style.css
golua94 Nov 27, 2016
7279941
[imad-console] Updates server.js
golua94 Nov 27, 2016
a771a3e
[imad-console] Updates ui/style.css
golua94 Nov 27, 2016
60170f0
[imad-console] Updates ui/index.html
golua94 Nov 28, 2016
5e66625
[imad-console] Updates ui/index.html
golua94 Nov 28, 2016
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
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules/
node_modules/
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"morgan": "^1.7.0"
"express-session": "^1.14.2",
"morgan": "^1.7.0",
"pg": "^6.1.0"
}
}
252 changes: 248 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,268 @@
var express = require('express');
var morgan = require('morgan');
var path = require('path');
var Pool = require('pg').Pool;
var crypto = require('crypto');
var bodyParser = require('body-parser');
var session = require('express-session');


var config={
user : 'golua94',
database :'golua94',
host:'db.imad.hasura-app.io',
port:'5432',
password:process.env.DB_PASSWORD
};





var app = express();
app.use(morgan('combined'));
app.use(bodyParser.json());
app.use(session({
secret: 'someRandomSecretValue',
cookie: { maxAge: 1000 * 60 * 60 * 24 * 30}
}));

function createTemplate (data) {
var title = data.title;
var date = data.date;
var heading = data.heading;
var content = data.content;

var htmlTemplate = `
<html>
<head>
<title>
${title}
</title>
<meta name="viewport" content="width=device-width, initial-scale=1" http-equiv="Content-Type" content="text/html" charset="utf-8"/>
<link href="/ui/style.css" rel="stylesheet" />
</head>
<body>
<div id="container">


<div id="menu">

${heading}



</div>

<div id="content">
<div class="container">
<div id="home">
<a style="font-size:30px; color:white; text-align:left " href="/">Home</a>
</div>
<hr/>
<br/>
<br/>
<h3>

</h3>
<div>
${date.toDateString()}
</div>

<br/>
<br/>
<div id="articlecontent">
${content}
</div>
<hr/>
<br/>
<br/>

<div id="comment_form">
</div>
<br/>
<div id="comments">
<center>Loading comments...</center>

</div>
<br/>
</div>
<script type="text/javascript" src="/ui/article.js"></script>

</div>
</body>
</html>
`;
return htmlTemplate;
}

app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'ui', 'index.html'));
});

app.get('/ui/style.css', function (req, res) {
res.sendFile(path.join(__dirname, 'ui', 'style.css'));

function hash (input, salt) {
// How do we create a hash?
var hashed = crypto.pbkdf2Sync(input, salt, 10000, 512, 'sha512');
return ["pbkdf2", "10000", salt, hashed.toString('hex')].join('$');
}


app.get('/hash/:input', function(req, res) {
var hashedString = hash(req.params.input, 'this-is-some-random-string');
res.send(hashedString);
});

app.post('/create-user', function (req, res) {
// username, password
// {"username": "tanmai", "password": "password"}
// JSON
var username = req.body.username;
var password = req.body.password;
var salt = crypto.randomBytes(128).toString('hex');
var dbString = hash(password, salt);
pool.query('INSERT INTO "user" (username, password) VALUES ($1, $2)', [username, dbString], function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
res.send('User successfully created: ' + username);
}
});
});

app.post('/login', function (req, res) {
var username = req.body.username;
var password = req.body.password;

pool.query('SELECT * FROM "user" WHERE username = $1', [username], function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
if (result.rows.length === 0) {
res.status(403).send('username/password is invalid');
} else {
// Match the password
var dbString = result.rows[0].password;
var salt = dbString.split('$')[2];
var hashedPassword = hash(password, salt); // Creating a hash based on the password submitted and the original salt
if (hashedPassword === dbString) {

// Set the session
req.session.auth = {userId: result.rows[0].id};
// set cookie with a session id
// internally, on the server side, it maps the session id to an object
// { auth: {userId }}

res.send('credentials correct!');

} else {
res.status(403).send('username/password is invalid');
}
}
}
});
});

app.get('/ui/madi.png', function (req, res) {
res.sendFile(path.join(__dirname, 'ui', 'madi.png'));
app.get('/check-login', function (req, res) {
if (req.session && req.session.auth && req.session.auth.userId) {
// Load the user object
pool.query('SELECT * FROM "user" WHERE id = $1', [req.session.auth.userId], function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
res.send(result.rows[0].username);
}
});
} else {
res.status(400).send('You are not logged in');
}
});

app.get('/logout', function (req, res) {
delete req.session.auth;
res.send('<html><body>Logged out!<br/><br/><a href="/">Back to home</a></body></html>');
});

var pool = new Pool(config);

app.get('/get-articles', function (req, res) {
// make a select request
// return a response with the results
pool.query('SELECT * FROM article ORDER BY date DESC', function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
res.send(JSON.stringify(result.rows));
}
});
});

app.get('/get-comments/:articleName', function (req, res) {
// make a select request
// return a response with the results
pool.query('SELECT comment.*, "user".username FROM article, comment, "user" WHERE article.title = $1 AND article.id = comment.article_id AND comment.user_id = "user".id ORDER BY comment.timestamp DESC', [req.params.articleName], function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
res.send(JSON.stringify(result.rows));
}
});
});

app.post('/submit-comment/:articleName', function (req, res) {
// Check if the user is logged in
if (req.session && req.session.auth && req.session.auth.userId) {
// First check if the article exists and get the article-id
pool.query('SELECT * from article where title = $1', [req.params.articleName], function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
if (result.rows.length === 0) {
res.status(400).send('Article not found');
} else {
var articleId = result.rows[0].id;
// Now insert the right comment for this article
pool.query(
"INSERT INTO comment (comment, article_id, user_id) VALUES ($1, $2, $3)",
[req.body.comment, articleId, req.session.auth.userId],
function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
res.status(200).send('Comment inserted!')
}
});
}
}
});
} else {
res.status(403).send('Only logged in users can comment');
}
});

app.get('/articles/:articleName', function (req, res) {
// SELECT * FROM article WHERE title = '\'; DELETE WHERE a = \'asdf'
pool.query("SELECT * FROM article WHERE title = $1", [req.params.articleName], function (err, result) {
if (err) {
res.status(500).send(err.toString());
} else {
if (result.rows.length === 0) {
res.status(404).send('Article not found');
} else {
var articleData = result.rows[0];
res.send(createTemplate(articleData));
}
}
});
});

app.get('/ui/:fileName', function (req, res) {
res.sendFile(path.join(__dirname, 'ui', req.params.fileName));
});


var port = 8080; // Use 8080 for local development because you might already have apache running on 80
app.listen(8080, function () {
console.log(`IMAD course app listening on port ${port}!`);
});

Binary file added ui/CV1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ui/Imad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ui/LinkedIn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ui/NPTEL1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading