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

Imad #100

Open
wants to merge 72 commits into
base: master
Choose a base branch
from
Open

Imad #100

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7436a67
[imad-console] Updates ui/index.html
froztedfate Aug 4, 2017
8dddfe7
[imad-console] Updates ui/index.html
froztedfate Aug 4, 2017
e386cdd
[imad-console] Updates server.js
froztedfate Aug 5, 2017
0ef5ef8
Create Article-one.html
froztedfate Aug 5, 2017
c4779ca
[imad-console] Updates Article-one.html
froztedfate Aug 5, 2017
5122d2d
[imad-console] Updates server.js
froztedfate Aug 5, 2017
bb2bf71
[imad-console] Updates server.js
froztedfate Aug 5, 2017
9b0d7d5
Rename Article-one.html to article-one.html
froztedfate Aug 5, 2017
b9dcd3f
[imad-console] Updates server.js
froztedfate Aug 5, 2017
fb1a906
[imad-console] Updates server.js
froztedfate Aug 5, 2017
26cdff7
Create article-1.html
froztedfate Aug 5, 2017
6b0540d
[imad-console] Updates server.js
froztedfate Aug 5, 2017
79a0e46
[imad-console] Updates server.js
froztedfate Aug 5, 2017
2239229
Delete article-one.html
froztedfate Aug 5, 2017
4ebe82e
Update style.css
froztedfate Aug 5, 2017
131d2a8
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
8525551
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
1e126e2
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
317ed30
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
eb9cea3
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
e5c0e06
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
dea7e85
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
ca4be8f
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
76d1228
[imad-console] Updates ui/style.css
froztedfate Aug 5, 2017
4be273e
[imad-console] Updates ui/article-1.html
froztedfate Aug 5, 2017
8993119
Create article-2.html
froztedfate Aug 5, 2017
b83096a
Create article-3.html
froztedfate Aug 5, 2017
1941b42
Update article-2.html
froztedfate Aug 5, 2017
1480333
Update article-3.html
froztedfate Aug 5, 2017
bb27d67
[imad-console] Updates server.js
froztedfate Aug 5, 2017
1930a8f
[imad-console] Updates ui/article-1.html
froztedfate Aug 6, 2017
466b967
[imad-console] Updates ui/article-1.html
froztedfate Aug 6, 2017
86f89b9
[imad-console] Updates ui/article-1.html
froztedfate Aug 6, 2017
700ba49
[imad-console] Updates ui/article-1.html
froztedfate Aug 6, 2017
209fac0
[imad-console] Updates ui/article-2.html
froztedfate Aug 9, 2017
c6ba7d1
[imad-console] Updates ui/article-3.html
froztedfate Aug 9, 2017
38689bb
[imad-console] Updates ui/article-1.html
froztedfate Aug 9, 2017
122bcba
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
8a1a183
[imad-console] Updates ui/article-2.html
froztedfate Aug 9, 2017
4cc0598
[imad-console] Updates ui/article-3.html
froztedfate Aug 9, 2017
5f1f98f
[imad-console] Updates ui/article-2.html
froztedfate Aug 9, 2017
498078c
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
94ebab8
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
ab9e51b
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
895365d
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
5ed226c
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
cc6e076
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
bf72ec5
[imad-console] Updates server.js
froztedfate Aug 9, 2017
627afdd
[imad-console] Updates server.js
froztedfate Aug 9, 2017
3a8e2e4
[imad-console] Updates ui/style.css
froztedfate Aug 9, 2017
c1e3c23
[imad-console] Updates server.js
froztedfate Aug 9, 2017
5120cd3
Delete article-1.html
froztedfate Aug 9, 2017
d4cf8ba
Delete article-2.html
froztedfate Aug 9, 2017
b2bd09d
Delete article-3.html
froztedfate Aug 9, 2017
df91c50
[imad-console] Updates server.js
froztedfate Aug 11, 2017
cd17128
[imad-console] Updates server.js
froztedfate Aug 11, 2017
66eff3d
[imad-console] Updates server.js
froztedfate Aug 11, 2017
c724330
[imad-console] Updates server.js
froztedfate Aug 11, 2017
79f30bb
[imad-console] Updates server.js
froztedfate Aug 11, 2017
3ef04ce
[imad-console] Updates server.js
froztedfate Aug 11, 2017
8fddc17
[imad-console] Updates server.js
froztedfate Aug 11, 2017
c058da9
[imad-console] Updates ui/index.html
froztedfate Aug 11, 2017
a721bb8
[imad-console] Updates server.js
froztedfate Aug 11, 2017
38ffe73
[imad-console] Updates server.js
froztedfate Aug 11, 2017
c6712c2
[imad-console] Updates ui/index.html
froztedfate Aug 15, 2017
e63efcd
[imad-console] Updates ui/index.html
froztedfate Aug 15, 2017
55c3bda
[imad-console] Updates server.js
froztedfate Aug 15, 2017
89ea860
[imad-console] Updates server.js
froztedfate Aug 15, 2017
e5f47e2
[imad-console] Updates ui/index.html
froztedfate Aug 15, 2017
3c92842
[imad-console] Updates ui/main.js
froztedfate Aug 15, 2017
d3513b6
[imad-console] Updates ui/main.js
froztedfate Aug 15, 2017
7fdb721
[imad-console] Updates ui/main.js
froztedfate Aug 15, 2017
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
91 changes: 90 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,103 @@ var path = require('path');
var app = express();
app.use(morgan('combined'));


var articles = {
'article-one': {
title: 'Article one .. Im Varun',
heading: 'Article One',
date: 'August 5,2017',
content: `
<p>
This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.
</p>
<p>
This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.
</p>
<p>
This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.This is the conent for my first article.
</p>`
},
'article-two': {
title: 'Article Two .. Im Varun',
heading: 'Article Two',
date: 'August 10,2017',
content: `
<p>
This is the conent for my second article.
</p>`

},
'article-three': {
title: 'Article Three .. Im Varun',
heading: 'Article Three',
date: 'August 23,2017',
content: `
<p>
This is the conent for my third article.
</p>`

}
};

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" />
<link href="/ui/style.css" rel="stylesheet" />
</head>
<body>
<div class="container">
<div>
<a href="/">Home</a>
</div>
<hr/>
<h3>
${heading}
</h3>
<div>
${date}
</div>
<div>
${content}
</div>
</div>
</body>
</html>
`;
return htmlTemplate;
}

app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'ui', 'index.html'));
});
var counter=0;
app.get('/counter', function(req,res) {
counter = counter + 1;
res.send(counter.toString());
});

app.get('/:articleName', function (req, res){
var articleName = req.params.articleName;
res.send(createTemplate(articles[articleName]));
});


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

app.get('/ui/main.js', function (req, res) {
res.sendFile(path.join(__dirname, 'ui', 'main.js'));
});
app.get('/ui/madi.png', function (req, res) {
res.sendFile(path.join(__dirname, 'ui', 'madi.png'));
});
Expand Down
29 changes: 21 additions & 8 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@
<link href="/ui/style.css" rel="stylesheet" />
</head>
<body>
<div class="center">
<img src="/ui/madi.png" class="img-medium"/>
</div>
<br>
<div class="center text-big bold">
Hi! I am your webapp.
</div>
<script type="text/javascript" src="/ui/main.js">
<div class="container">
<div class="center">
<img src="https://pbs.twimg.com/profile_images/897500022043951109/-2zvt4S7_400x400.jpg" class="img-medium"/>
</div>

<br>
<h3>Personal</h3>
<div>
Hiii all .. I'm Varun !!
</div>
<hr/>
<h3>Hobbies</h3>
<div>
I love photgraphy !!!
</div>
<hr/>
<div class="footer">
This button <button id="counter">Click me !!</button> has been clicked <span id="count">0</span> times ..
</div>
</div>
<script type="text/javascript" src="/ui/main.js">
</script>
</body>
</html>
16 changes: 15 additions & 1 deletion ui/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
console.log('Loaded!');
// counter code

var button = document.getElementById('counter');
var counter = 0;
button.onclick=function () {

// make a req to counter end point

// capture a response and store it in a variable

// rendee the variable in the correct span
counter = counter + 1;
var span = document.getElementById('count');
span.innerHTML = counter.toString();
};
14 changes: 11 additions & 3 deletions ui/style.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
body {
font-family: sans-serif;
background-color: lightgrey;
margin-top: 75px;
margin-top: 60px;
}

.center {
text-align: center;
}

.text-big {
font-size: 300%;
font-size: 350%;
}

.bold {
Expand All @@ -20,3 +19,12 @@ body {
height: 200px;
}

.container {
max-width: 800px;
margin: 0 auto;
color: #00000ee;
font-family: Segoe Script;
padding-right: 20px;
padding-left: 20px;
}