Linked backend to frontend and fixed basic formatting in few files
This commit is contained in:
+17
-16
@@ -3,14 +3,15 @@
|
||||
/// Creates base routes and runs ///
|
||||
/// respective functions ///
|
||||
////////////////////////////////////////////
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
//require “routes.php”;
|
||||
require "../vendor/autoload.php";
|
||||
include "timelineData.php";
|
||||
include "projectData.php";
|
||||
use api\projectData;
|
||||
use api\timelineData;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
// Start slim
|
||||
$app = AppFactory::create();
|
||||
@@ -22,15 +23,15 @@ $errorMiddleware = $app->addErrorMiddleware(true, true, true);
|
||||
|
||||
$app->setBasePath("/api");
|
||||
|
||||
$timelineData = new TimelineData();
|
||||
$projectData = new ProjectData();
|
||||
$timelineData = new timelineData();
|
||||
$projectData = new projectData();
|
||||
|
||||
$app->get("/timelineData/{timeline}", function (Request $request, Response $response, array $args)
|
||||
{
|
||||
global $timelineData;
|
||||
$json = $result = "";
|
||||
|
||||
//check if route is available if it is get the data
|
||||
|
||||
//check if route is available if it is get the data
|
||||
//otherwise return an error
|
||||
if($args["timeline"] == "edu")
|
||||
{
|
||||
@@ -40,19 +41,19 @@ $app->get("/timelineData/{timeline}", function (Request $request, Response $resp
|
||||
{
|
||||
$result = $timelineData->getWorkData();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$result = array(array("errorMessage" => "Error, timeline data not found"));
|
||||
}
|
||||
|
||||
|
||||
$json = json_encode($result);
|
||||
|
||||
$response->getBody()->write($json);
|
||||
|
||||
//if it is an error give a 404 code since it can't find the data
|
||||
if(array_key_exists("errorMessage", $result[0]))
|
||||
|
||||
//if it is an error give a 403 code since it can't find the data
|
||||
if(array_key_exists("errorMessage", $result[-1]))
|
||||
{
|
||||
$response = $response->withStatus(404);
|
||||
$response = $response->withStatus(403);
|
||||
}
|
||||
|
||||
//use content type json to indicate json data on frontend.
|
||||
@@ -69,9 +70,9 @@ $app->get('/projectData', function (Request $request, Response $response)
|
||||
|
||||
$response->getBody()->write($json);
|
||||
|
||||
if(array_key_exists("errorMessage", $result[0]))
|
||||
if(array_key_exists("errorMessage", $result[-1]))
|
||||
{
|
||||
$response = $response->withStatus(404);
|
||||
$response = $response->withStatus(403);
|
||||
}
|
||||
|
||||
//use content type json to indicate json data on frontend.
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<?php
|
||||
namespace api;
|
||||
use PDO;
|
||||
|
||||
require_once "./config.php";
|
||||
|
||||
/**
|
||||
* TimelineData class
|
||||
* Define all functions which either get, update, create or delete timeline data
|
||||
*/
|
||||
class TimelineData
|
||||
class timelineData
|
||||
{
|
||||
function getEduData()
|
||||
{
|
||||
@@ -46,4 +49,4 @@ class TimelineData
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -1,30 +1,30 @@
|
||||
/****** CV Styles *******/
|
||||
|
||||
section#curriculumvitae{
|
||||
section#curriculumVitae{
|
||||
background-color: var(--primaryDefault);
|
||||
color: #FFFFFF;
|
||||
padding: 2em 0;
|
||||
}
|
||||
|
||||
section#curriculumvitae .cvGrid {
|
||||
section#curriculumVitae .cvGrid {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
padding: 0 1.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
section#curriculumvitae .cvGrid > div {
|
||||
section#curriculumVitae .cvGrid > div {
|
||||
width: 45%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
section#curriculumvitae .cvGrid h2 {
|
||||
section#curriculumVitae .cvGrid h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
section#curriculumvitae .timeline {
|
||||
section#curriculumVitae .timeline {
|
||||
position: relative;
|
||||
max-width: 30em;
|
||||
gap: 1em;
|
||||
@@ -33,11 +33,11 @@ section#curriculumvitae .timeline {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
section#curriculumvitae #work {
|
||||
section#curriculumVitae #work {
|
||||
margin: 0 auto 0 8rem;
|
||||
}
|
||||
|
||||
section#curriculumvitae .timeline:before {
|
||||
section#curriculumVitae .timeline:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
@@ -46,13 +46,13 @@ section#curriculumvitae .timeline:before {
|
||||
top: 0;
|
||||
}
|
||||
|
||||
section#curriculumvitae .timeline:after {
|
||||
section#curriculumVitae .timeline:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
section#curriculumvitae .timelineItem {
|
||||
section#curriculumVitae .timelineItem {
|
||||
border: 2px solid var(--timelineItemBrdr);
|
||||
-webkit-border-radius: 10px;
|
||||
-moz-border-radius: 10px;
|
||||
@@ -63,12 +63,12 @@ section#curriculumvitae .timelineItem {
|
||||
background-color: var(--primaryHover);
|
||||
}
|
||||
|
||||
section#curriculumvitae .timelineItem:before, .timelineItem:after {
|
||||
section#curriculumVitae .timelineItem:before, .timelineItem:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
section#curriculumvitae .timelineItem:before{
|
||||
section#curriculumVitae .timelineItem:before{
|
||||
content: '';
|
||||
right: -20px;
|
||||
top: calc(50% - 5px);
|
||||
@@ -77,20 +77,20 @@ section#curriculumvitae .timelineItem:before{
|
||||
border-width: 20px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
section#curriculumvitae .timelineItem:nth-child(2n) {
|
||||
section#curriculumVitae .timelineItem:nth-child(2n) {
|
||||
margin-left: 21em;
|
||||
}
|
||||
|
||||
section#curriculumvitae .timelineItem:nth-child(2n):before {
|
||||
section#curriculumVitae .timelineItem:nth-child(2n):before {
|
||||
right: auto;
|
||||
left: -20px;
|
||||
border-color: transparent transparent var(--timelineItemBrdr) var(--timelineItemBrdr);
|
||||
}
|
||||
|
||||
section#curriculumvitae .timelineItem h3 {
|
||||
section#curriculumVitae .timelineItem h3 {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
section#curriculumvitae .timelineItem span {
|
||||
section#curriculumVitae .timelineItem span {
|
||||
color: hsl(0, 0%, 90%);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
+8
-58
@@ -28,7 +28,7 @@
|
||||
|
||||
<ul>
|
||||
<li><a href="#about" class="textShadow active"><span><</span>about<span>></span></a></li>
|
||||
<li><a href="#curriculumvitae" class="textShadow"><span><</span>cv<span>></span></a></li>
|
||||
<li><a href="#curriculumVitae" class="textShadow"><span><</span>cv<span>></span></a></li>
|
||||
<li><a href="#projects" class="textShadow"><span><</span>projects<span>></span></a></li>
|
||||
<li><a href="#contact" class="textShadow"><span><</span>contact<span>></span></a></li>
|
||||
<li><a href="#" class="textShadow"><span><</span>blog<span>></span></a></li>
|
||||
@@ -57,7 +57,7 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="curriculumvitae">
|
||||
<section id="curriculumVitae">
|
||||
<h1>curriculum vitae</h1>
|
||||
<div class="cvGrid">
|
||||
<!-- https://codepen.io/keithwyland/pen/wqNqvy -->
|
||||
@@ -75,64 +75,14 @@
|
||||
</section>
|
||||
|
||||
<section id="projects">
|
||||
<div class="mainProj">
|
||||
<h1>project title to be generated</h1>
|
||||
<div>
|
||||
<img src="imgs/1000x800.jpg" alt="">
|
||||
<div class="flexRow">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus dolorem dolores esse itaque
|
||||
iure iusto libero molestias nobis nostrum placeat praesentium quia quo reprehenderit,
|
||||
repudiandae.</p>
|
||||
<div class="flexCol">
|
||||
<a href="" class="btn btnPrimary boxShadowIn boxShadowOut" disabled="disabled">testing</a>
|
||||
<a href="" class="btn btnOutline boxShadowIn boxShadowOut">testing</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mainProj" id="mainProj">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="otherProj">
|
||||
<div class="otherProj" id="otherProj">
|
||||
<h1>other projects</h1>
|
||||
<div>
|
||||
<div class="oProjItem">
|
||||
<img src="imgs/500x400.jpg" alt="">
|
||||
<div class="flexCol">
|
||||
<div>
|
||||
<p>Adipisci aspernatur consectetur debitis fugiat minus mollitia rem ullam,
|
||||
voluptate.</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="" class="btn btnPrimary boxShadowIn boxShadowOut">View Project</a>
|
||||
<a href="" class="btn btnOutline boxShadowIn boxShadowOut">Github</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oProjItem">
|
||||
<img src="imgs/500x400.jpg" alt="">
|
||||
<div class="flexCol">
|
||||
<div>
|
||||
<p>Adipisci aspernatur consectetur debitis fugiat minus mollitia rem ullam,
|
||||
voluptate.</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="" class="btn btnPrimary boxShadowIn boxShadowOut">View Project</a>
|
||||
<a href="" class="btn btnOutline boxShadowIn boxShadowOut">Github</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oProjItem">
|
||||
<img src="imgs/500x400.jpg" alt="">
|
||||
<div class="flexCol">
|
||||
<div>
|
||||
<p>Adipisci aspernatur consectetur debitis fugiat minus mollitia rem ullam,
|
||||
voluptate.</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="" class="btn btnPrimary boxShadowIn boxShadowOut">View Project</a>
|
||||
<a href="" class="btn btnOutline boxShadowIn boxShadowOut">Github</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<a href="" class="btn btnPrimary boxShadowIn boxShadowOut">View More</a>
|
||||
</div>
|
||||
@@ -179,11 +129,11 @@
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<footer class="flexRow">
|
||||
<p>© 2021 Rohit Pai all rights reserved</p>
|
||||
<button class="goBackToTop"></button>
|
||||
</footer>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -150,6 +150,58 @@ function getTimelineData()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* getProjectData function
|
||||
* Gets the project data from the backend route and appends the data on to the timeline.
|
||||
*/
|
||||
function getProjectData()
|
||||
{
|
||||
fetch("/api/projectData").then(res =>
|
||||
{
|
||||
res.json().then(json =>
|
||||
{
|
||||
if (res.ok)
|
||||
{
|
||||
json.forEach(item =>
|
||||
{
|
||||
if (item["isMainProject"] === "1")
|
||||
{
|
||||
document.getElementById("mainProj").innerHTML = `
|
||||
<h1>${item["title"]}</h1>
|
||||
<div>
|
||||
<img src="imgs/1000x800.jpg" alt="">
|
||||
<div class="flexRow">
|
||||
<p>${item["information"]}</p>
|
||||
<div class="flexCol">
|
||||
<a href="${(item["projectLink"] === "N/A") ? "#" : item["projectLink"]}" class="btn btnPrimary boxShadowIn boxShadowOut" ${(item["projectLink"] === "N/A") ? "disabled=\"disabled\"" : ""}>View Project</a>
|
||||
<a href="${(item["githubLink"] === "N/A") ? "#" : item["gitubLink"]}" class="btn btnOutline boxShadowIn boxShadowOut" ${(item["githubLink"] === "N/A") ? "disabled=\"disabled\"" : ""}>GitHub</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
return null;
|
||||
}
|
||||
|
||||
document.querySelector("#otherProj div").innerHTML += `
|
||||
<div class="oProjItem">
|
||||
<img src="imgs/500x400.jpg" alt="">
|
||||
<div class="flexCol">
|
||||
<div>
|
||||
<p>${item["information"]}</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="${(item["projectLink"] === "N/A") ? "#" : item["projectLink"]}" class="btn btnPrimary boxShadowIn boxShadowOut"${(item["projectLink"] === "N/A") ? "disabled=\"disabled\"" : ""}>View Project</a>
|
||||
<a href="${(item["githubLink"] === "N/A") ? "#" : item["gitubLink"]}" class="btn btnOutline boxShadowIn boxShadowOut">${(item["githubLink"] === "N/A") ? "disabled=\"disabled\"" : ""}Github</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () =>
|
||||
{
|
||||
// start the text animation
|
||||
@@ -157,4 +209,7 @@ document.addEventListener('DOMContentLoaded', () =>
|
||||
|
||||
// get timeline data and add it to the timeline
|
||||
getTimelineData();
|
||||
|
||||
// get projectData
|
||||
getProjectData();
|
||||
});
|
||||
Reference in New Issue
Block a user