Skip to content

Commit

Permalink
added role routing and role htmls
Browse files Browse the repository at this point in the history
  • Loading branch information
PeanutBrrutter committed Jun 26, 2024
1 parent 9687385 commit 47c5d9b
Show file tree
Hide file tree
Showing 9 changed files with 596 additions and 47 deletions.
Binary file modified EduSync.exe
Binary file not shown.
11 changes: 1 addition & 10 deletions auth.go → authHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,7 @@ func AuthHandler(router *mux.Router, config *Config) {
}).Methods("GET")

router.HandleFunc("/login", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/index.html")
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
}
t.Execute(res, false)
}).Methods("GET")

router.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/home.html")
t, err := template.ParseFiles("templates/login.html")
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ func main() {
}

router := mux.NewRouter()

// Serving static files
fs := http.FileServer(http.Dir("assets"))
router.PathPrefix("/assets").Handler(http.StripPrefix("/assets", fs))
//http.Handle("/resources/", http.StripPrefix("/resources", fs))

// Set up authentication routes
AuthHandler(router, config)
RoleHandler(router)

log.Println("listening on localhost:8080")
err = http.ListenAndServeTLS(":8080", "cert.pem", "key.pem", router)
Expand Down
46 changes: 46 additions & 0 deletions roleHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"html/template"
"net/http"

"github.com/gorilla/mux"
)

func RoleHandler(router *mux.Router) {
router.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/index.html")
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
}
t.Execute(res, false)
}).Methods("GET")

router.HandleFunc("/admin", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/admin/index.html")
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
}
t.Execute(res, nil)
}).Methods("GET")

router.HandleFunc("/student", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/student/index.html")
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
}
t.Execute(res, nil)
}).Methods("GET")

router.HandleFunc("/instructor", func(res http.ResponseWriter, req *http.Request) {
t, err := template.ParseFiles("templates/instructor/index.html")
if err != nil {
http.Error(res, err.Error(), http.StatusInternalServerError)
return
}
t.Execute(res, nil)
}).Methods("GET")
}
170 changes: 170 additions & 0 deletions templates/admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<!DOCTYPE html>
<html>
<head>
<title>EduSync</title>
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="/assets/css/owl.carousel.css">
<link rel="stylesheet" type="text/css" href="/assets/css/inner-page-style.css">
<link rel="stylesheet" type="text/css" href="/assets/css/style.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,500,600,700" rel="stylesheet">
</head>
<body>
<div id="page" class="site" itemscope itemtype="http://schema.org/LocalBusiness">
<header class="site-header">
<div class="top-header">
<div class="container">
<div class="top-header-left">
<div class="top-header-block">
<a href="mailto:[email protected]" itemprop="email"><i class="fas fa-envelope"></i> [email protected]</a>
</div>
<div class="top-header-block">
<a href="https://nkr.sg/" itemprop="globe"><i class="fas fa-globe"></i> Visit Website</a>
</div>
</div>
<div class="top-header-right">
<div class="social-block">
<ul class="social-list">
<li><a href="https://api.whatsapp.com/send?phone=6580391455&text=Hi,%20I%27d%20like%20to%20enquire%20about%20your%20robotics%20and%20coding%20programmes"><i class="fab fa-viber"></i></a></li>
<li><a href="https://www.facebook.com/NKRobotics/"><i class="fab fa-facebook-square"></i></a></li>
<li><a href="https://www.instagram.com/nk.robotics/"><i class="fab fa-instagram"></i></a></li>
<li><a href="https://sg.linkedin.com/company/nk-robotics"><i class="fab fa-linkedin"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
<!-- Top header Close -->
<div class="main-header">
<div class="container">
<div class="logo-wrap" itemprop="logo">
<img src="/assets/images/site-logo.jpg" alt="Logo Image" style="width: 120px; height: auto;">
<!-- <h1>Education</h1> -->
</div>
<div class="nav-wrap">
<nav class="nav-desktop">
<ul class="menu-list">
<li><a href="#">Home</a></li>
<li class="menu-parent">Attendance
<ul class="sub-menu">
<li><a href="#">Child</a></li>
<li><a href="#">Child</a></li>
</ul>
</li>
<li class="menu-parent">Students
<ul class="sub-menu">
<li><a href="#">Child</a></li>
<li><a href="#">Child</a></li>
<li class="menu-parent">Child
<ul class="sub-menu">
<li><a href="">Grand-child</a></li>
<li><a href="">Grand-child</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="">Parents</a></li>
<li><a href="">Users</a></li>
</ul>
</nav>
<div id="bar">
<i class="fas fa-bars"></i>
</div>
<div id="close">
<i class="fas fa-times"></i>
</div>
</div>
</div>
</div>
</header>
<!-- Header Close -->
<div class="banner">
<div class="owl-four owl-carousel" itemprop="image">
<img src="/assets/images/page-banner.jpg" alt="Image of Bannner">
<img src="/assets/images/page-banner2.jpg" alt="Image of Bannner">
<img src="/assets/images/page-banner3.jpg" alt="Image of Bannner">
</div>
<div class="container" itemprop="description">
<h1>Welcome Admin to EduSync</h1>
<h3>Managing education with ease...</h3>
</div>
<div id="owl-four-nav" class="owl-nav"></div>
</div>
<!-- Banner Close -->

<section class="query-section">
<div class="container">
<p>Need assistance? Contact us at <a href="mailto:[email protected]"><i class="fas fa-envelope"></i> [email protected]</a></p>
</div>
</section>
<!-- End of Query Section -->

<footer class="page-footer" itemprop="footer" itemscope itemtype="http://schema.org/WPFooter">
<div class="footer-first-section">
<div class="container">
<div class="box-wrap" itemprop="about">
<header>
<h1>About EduSync for Admins</h1>
</header>
<p>EduSync provides administrative tools and functionalities to streamline educational management tasks.</p>

<h4><a href="https://nkr.sg/"><i class="fas fa-globe"></i> Visit EduSync Website</a></h4>
<h4><a href="mailto:[email protected]"><i class="fas fa-envelope"></i> Contact Us</a></h4>
<h4><a href="https://www.google.com/maps/search/?api=1&query=Singapore"><i class="fas fa-map-marker-alt"></i> Singapore, Singapore</a></h4>
</div>

<div class="box-wrap">
<header>
<h1>Admin Tools</h1>
</header>
<ul>
<li><a href="#">User Management</a></li>
<li><a href="#">Content Management</a></li>
<li><a href="#">Analytics and Reports</a></li>
</ul>
</div>

<div class="box-wrap">
<header>
<h1>Quick Contact</h1>
</header>
<section class="quick-contact">
<input type="email" name="email" placeholder="Your Email*">
<textarea placeholder="Type your message*"></textarea>
<button>Send Message</button>
</section>
</div>
</div>
</div>
<!-- End of box-Wrap -->

<div class="footer-second-section">
<div class="container">
<hr class="footer-line">
<ul class="social-list">
<li><a href=""><i class="fab fa-facebook-square"></i></a></li>
<li><a href=""><i class="fab fa-twitter"></i></a></li>
<li><a href=""><i class="fab fa-skype"></i></a></li>
<li><a href=""><i class="fab fa-youtube"></i></a></li>
<li><a href=""><i class="fab fa-instagram"></i></a></li>
</ul>
<hr class="footer-line">
</div>
</div>

<div class="footer-last-section">
<div class="container">
<p>&copy; 2024 EduSync. All rights reserved.</p>
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="/assets/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/assets/js/all.js"></script>
<script type="text/javascript" src="/assets/js/isotope.pkgd.min.js"></script>
<script type="text/javascript" src="/assets/js/owl.carousel.js"></script>
<script type="text/javascript" src="/assets/js/jquery.flexslider.js"></script>
<script type="text/javascript" src="/assets/js/jquery.rateyo.js"></script>
<script type="text/javascript" src="/assets/js/custom.js"></script>
</body>
</html>
Loading

0 comments on commit 47c5d9b

Please sign in to comment.