Showing
13 changed files
with
139 additions
and
19 deletions
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | "@babel/core": "^7.14.0", | 15 | "@babel/core": "^7.14.0", |
16 | "@babel/node": "^7.13.13", | 16 | "@babel/node": "^7.13.13", |
17 | "@babel/preset-env": "^7.14.1", | 17 | "@babel/preset-env": "^7.14.1", |
18 | + "axios": "^0.21.1", | ||
18 | "express": "^4.17.1", | 19 | "express": "^4.17.1", |
19 | "morgan": "^1.10.0", | 20 | "morgan": "^1.10.0", |
20 | "nodemon": "^2.0.7", | 21 | "nodemon": "^2.0.7", | ... | ... |
1 | -export const handleHome = (req,res)=>{ | 1 | +import axios from "axios"; |
2 | - const list1 = [1,2,3,4,5] | 2 | + |
3 | - res.render("home",{pageTitle:"Home",list1}); | 3 | +const getQuote = async (req,res) =>{ |
4 | + const url = "http://quotes.stormconsultancy.co.uk/random.json"; | ||
5 | + const quoteData = await axios.get(url).then(function(response){ | ||
6 | + return response.data; | ||
7 | + }); | ||
8 | + const quote = quoteData.quote; | ||
9 | + const author = quoteData.author; | ||
10 | + return {quote,author}; | ||
11 | +} | ||
12 | + | ||
13 | +export const handleHome = async (req,res)=>{ | ||
14 | + const quote = await getQuote(); | ||
15 | + res.render("home",{pageTitle:"Home", quote:quote.quote, author:quote.author}); | ||
16 | +} | ||
17 | + | ||
18 | + | ||
19 | +export const getUserDetail = async (req,res) =>{ | ||
20 | + const quote = await getQuote(); | ||
21 | + res.render("userDetail",{pagetTitle:"User Detail", quote:quote.quote, author:quote.author}) | ||
4 | } | 22 | } |
5 | 23 | ||
24 | +export const getEditProfile = (req,res)=> res.render("editProfile",{pageTitle:"Edit Profile"}); | ||
25 | + | ||
26 | +export const postEditProfile = (req,res) =>{ | ||
27 | + console.log(req.body); | ||
28 | + res.redirect("/users/edit-profile"); | ||
29 | +}; | ||
30 | + | ||
31 | + | ||
32 | +export const getJoin = (req,res)=>{ | ||
33 | + res.render("join",{pageTitle: "Join"}); | ||
34 | +}; | ||
35 | + | ||
36 | +export const getLogin = (req,res)=>{ | ||
37 | + res.render("login",{pageTitle: "Login"}); | ||
38 | +}; | ||
39 | + | ||
6 | export const handleUsers = (req,res)=>{ | 40 | export const handleUsers = (req,res)=>{ |
7 | res.render("users",{pageTitle:"Users"}); | 41 | res.render("users",{pageTitle:"Users"}); |
8 | } | 42 | } | ... | ... |
1 | import express from "express"; | 1 | import express from "express"; |
2 | -import { handleHome } from "../controllers/userController"; | 2 | +import { getJoin, getLogin, handleHome } from "../controllers/userController"; |
3 | + | ||
3 | 4 | ||
4 | 5 | ||
5 | const globalRouter = express.Router(); | 6 | const globalRouter = express.Router(); |
6 | 7 | ||
7 | globalRouter.get("/",handleHome); | 8 | globalRouter.get("/",handleHome); |
8 | -globalRouter.get("/join",(req,res)=>res.render("join")); | 9 | +globalRouter.get("/join", getJoin); |
9 | -globalRouter.get("/login",(req,res)=>res.render("login")); | 10 | +globalRouter.get("/login",getLogin); |
10 | 11 | ||
11 | 12 | ||
12 | export default globalRouter; | 13 | export default globalRouter; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | import express from "express"; | 1 | import express from "express"; |
2 | -import { handleUsers } from "../controllers/userController"; | 2 | +import { getEditProfile, getUserDetail, handleUsers, postEditProfile } from "../controllers/userController"; |
3 | 3 | ||
4 | 4 | ||
5 | const userRouter = express.Router(); | 5 | const userRouter = express.Router(); |
6 | 6 | ||
7 | userRouter.get("/",handleUsers); | 7 | userRouter.get("/",handleUsers); |
8 | -userRouter.get("/edit-profile",(req,res)=>res.render("editProfile")); | 8 | + |
9 | -userRouter.get("/:id",(req,res)=>res.render("userDetail")); | 9 | +userRouter.get("/edit-profile", getEditProfile); |
10 | +userRouter.post("/edit-profile", postEditProfile); | ||
11 | + | ||
12 | +userRouter.get("/:id", getUserDetail); | ||
10 | 13 | ||
11 | 14 | ||
12 | export default userRouter; | 15 | export default userRouter; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -13,6 +13,8 @@ app.set("view engine","pug"); | ... | @@ -13,6 +13,8 @@ app.set("view engine","pug"); |
13 | app.set("views", path.join(__dirname, "views")); | 13 | app.set("views", path.join(__dirname, "views")); |
14 | app.use(express.static(path.join(__dirname, "static"))); | 14 | app.use(express.static(path.join(__dirname, "static"))); |
15 | app.use(morgan("dev")); | 15 | app.use(morgan("dev")); |
16 | +app.use(express.json()); | ||
17 | +app.use(express.urlencoded({ extended: true })); | ||
16 | 18 | ||
17 | 19 | ||
18 | app.use(localsMiddleware); | 20 | app.use(localsMiddleware); |
... | @@ -24,3 +26,4 @@ app.use("/users", userRouter); | ... | @@ -24,3 +26,4 @@ app.use("/users", userRouter); |
24 | const handleListening = () => console.log(`✅ Server running : http://localhost:${PORT}`); | 26 | const handleListening = () => console.log(`✅ Server running : http://localhost:${PORT}`); |
25 | 27 | ||
26 | app.listen(PORT, handleListening); | 28 | app.listen(PORT, handleListening); |
29 | + | ... | ... |
1 | -h1 edit Profile | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +extends layouts/main | ||
2 | + | ||
3 | +block content | ||
4 | + .form-container | ||
5 | + form(action="/users/edit-profile", method="POST", enctype="application/json") | ||
6 | + .fileUpload | ||
7 | + label(for="picture") Picture | ||
8 | + input(type="file", id="picture", name="picture", accept="image/*") | ||
9 | + input(type="text", placeholder="Name", name="name") | ||
10 | + input(type="text", placeholder="Github Id", name="githubId") | ||
11 | + input(type="email", placeholder="Email", name="email") | ||
12 | + input(type="text", placeholder="School", name="school") | ||
13 | + textarea(name="tech", placeholder="Add your Tech") | ||
14 | + textarea(name="career", placeholder="Add your Career") | ||
15 | + textarea(name="introduction", placeholder="Self introduction") | ||
16 | + input(type="submit", value="Update Profile") | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | extends layouts/main | 1 | extends layouts/main |
2 | 2 | ||
3 | block content | 3 | block content |
4 | - h1 Welcome | ||
5 | - each item in list1 | ||
6 | - span=item | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
4 | + .home | ||
5 | + .home-title | ||
6 | + h2 Develop your value | ||
7 | + h1 -Developer Profile- | ||
8 | + h2=quote | ||
9 | + h3=author | ||
10 | + .home-link | ||
11 | + a(href="/join") Join | ||
12 | + a(href="/login") Login | ... | ... |
1 | -h1 join | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +extends layouts/main | ||
2 | + | ||
3 | +block content | ||
4 | + i.fas.fa-location-arrow | ||
5 | + h3 Start with GitHub! | ||
6 | + button.login-github | ||
7 | + a(href="#") | ||
8 | + span | ||
9 | + i.fab.fa-github | ||
10 | + |Join with GitHub | ||
11 | + | ||
12 | + | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | - | ||
2 | doctype html | 1 | doctype html |
3 | html | 2 | html |
4 | head | 3 | head |
5 | link(rel="stylesheet", href="https://use.fontawesome.com/releases/v5.15.2/css/all.css", integrity="sha384-vSIIfh2YWi9wW0r9iZe7RJPrKwp6bG+s9QZMoITbCckVJqGCCRhc+ccxNcdpHuYu", crossorigin="anonymous") | 4 | link(rel="stylesheet", href="https://use.fontawesome.com/releases/v5.15.2/css/all.css", integrity="sha384-vSIIfh2YWi9wW0r9iZe7RJPrKwp6bG+s9QZMoITbCckVJqGCCRhc+ccxNcdpHuYu", crossorigin="anonymous") |
5 | + meta(charset="UTF-8") | ||
6 | title #{pageTitle} | #{siteName} | 6 | title #{pageTitle} | #{siteName} |
7 | - link(rel="stylesheet", href="/static/main.css") | 7 | + link(rel="stylesheet", href="https://unpkg.com/mvp.css") |
8 | body | 8 | body |
9 | include ../partials/header | 9 | include ../partials/header |
10 | main | 10 | main |
11 | block content | 11 | block content |
12 | include ../partials/footer | 12 | include ../partials/footer |
13 | //- script(src="/static/main.js") | 13 | //- script(src="/static/main.js") |
14 | + | ... | ... |
1 | -h1 Login | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +extends layouts/main | ||
2 | + | ||
3 | +block content | ||
4 | + i.fas.fa-location-arrow | ||
5 | + h3 Login with GitHub! | ||
6 | + button.login-github | ||
7 | + a(href="#") | ||
8 | + span | ||
9 | + i.fab.fa-github | ||
10 | + |Login with GitHub | ||
11 | + | ||
12 | + | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | footer.footer | 1 | footer.footer |
2 | .footer__icon | 2 | .footer__icon |
3 | i.fas.fa-code-branch | 3 | i.fas.fa-code-branch |
4 | - span.footer__text dev-profile #{new Date().getFullYear()} © | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
4 | + span.footer__text © dev-profile #{new Date().getFullYear()} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -3,6 +3,10 @@ header.header | ... | @@ -3,6 +3,10 @@ header.header |
3 | .header__column | 3 | .header__column |
4 | ul | 4 | ul |
5 | li | 5 | li |
6 | + a(href="/") Home | ||
7 | + li | ||
6 | a(href="/join") Join | 8 | a(href="/join") Join |
7 | li | 9 | li |
8 | a(href="/login") Log In | 10 | a(href="/login") Log In |
11 | + li | ||
12 | + a(href="/users/edit-profile") Edit Profile | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -h1 User Detail | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +extends layouts/main | ||
2 | + | ||
3 | +block content | ||
4 | + h1 User Detail | ||
5 | + .user-quote | ||
6 | + h2=quote | ||
7 | + h3=author | ||
8 | + .user-profile | ||
9 | + .user-profile__column | ||
10 | + img(src="#") | ||
11 | + .user-profile__link | ||
12 | + a(href="#") Github | ||
13 | + a(href="#") Blog | ||
14 | + .user-profile__column | ||
15 | + .user-profile__info | ||
16 | + h3 NAME | ||
17 | + h3 GITHUB NICKNAME | ||
18 | + h3 EMAIL | ||
19 | + h3 SCHOOL | ||
20 | + h3 TECH | ||
21 | + h3 CAREER | ||
22 | + h3 SELF-INTRODUCTION | ||
23 | + .user-status | ||
24 | + .user-status__contributions | ||
25 | + img(src="http://ghchart.rshah.org/lsj8706" alt="Name Your Github chart") | ||
26 | + .user-status__character | ||
27 | + h3 Your step | commit numbers | ||
28 | + img(src="https://preview.free3d.com/img/2019/12/2269306250288170045/1oe8ymrc-900.jpg" alt="character" style="height:200px; width:250px;") | ||
29 | + .user-repositories | ||
30 | + .user-repo | ||
31 | + h3 REPO 1 | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment