mirror of
https://github.com/ION606/rpi-utils.git
synced 2026-05-14 21:06:54 +00:00
migrated to express.js
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
.calDownload {
|
||||||
|
color: #e7e5e5;
|
||||||
|
background-color: #2d63c8;
|
||||||
|
font-size: 19px;
|
||||||
|
border: 1px solid #2d63c8;
|
||||||
|
padding: 15px 50px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.calDownload:hover {
|
||||||
|
color: #2d63c8;
|
||||||
|
background-color: #e7e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.ogCal {
|
||||||
|
color: #e7e5e5;
|
||||||
|
background-color: #c82d31;
|
||||||
|
font-size: 20px;
|
||||||
|
border: 1px solid #2d63c8;
|
||||||
|
padding: 10px 45px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.ogCal:hover {
|
||||||
|
color: #c82d31;
|
||||||
|
background-color: #e7e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
text-align: center;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 120;
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
body {
|
||||||
|
/* color: rgb(148, 0, 0); */
|
||||||
|
color: rgb(252, 252, 252);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background-color: rgb(110, 110, 110)
|
||||||
|
}
|
||||||
|
|
||||||
|
.topnav {
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #333;
|
||||||
|
text-align: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topnav a {
|
||||||
|
/* float: left; */
|
||||||
|
color: #f2f2f2;
|
||||||
|
text-align: center;
|
||||||
|
padding: 20px 20px;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topnav a:hover {
|
||||||
|
background-color: #ddd;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topnav a.active {
|
||||||
|
background-color: #aa0404;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" type="text/css" href="/calendar.css" defer>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/navbar.css" defer>
|
||||||
|
<title>RPI Academic Calendar to ics</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="topnav">
|
||||||
|
<a href="/">Home</a>
|
||||||
|
<a class="active" href="calendar">Calendar</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1>Academic Calendar</h1>
|
||||||
|
<div style="margin-top: 50px; text-align: center;">
|
||||||
|
<a class="calDownload" href="/createCalendar/" download="rpievents.ics">Download ICS file</a>
|
||||||
|
<br style="margin-bottom: 70px;">
|
||||||
|
<a class="ogCal" href="https://info.rpi.edu/registrar/academic-calendar">RPI Web Page</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" type="text/css" href="/main.css" defer>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/navbar.css" defer>
|
||||||
|
|
||||||
|
<title>RPI Utils Website</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="topnav">
|
||||||
|
<a class="active" href="/">Home</a>
|
||||||
|
<a href="calendar">Calendar</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<h1>Welcome to RPI Utils!</h1>
|
||||||
|
<h2>The place with the tools to withstand RPI's terrible online presence!</h2>
|
||||||
|
|
||||||
|
<br style="margin-top: 30px;">
|
||||||
|
<script type="text/javascript" src="https://cdnjs.buymeacoffee.com/1.0.0/button.prod.min.js" data-name="bmc-button" data-slug="ion606" data-color="#FFDD00" data-emoji="" data-font="Cookie" data-text="Buy me a coffee" data-outline-color="#000000" data-font-color="#000000" data-coffee-color="#ffffff"></script>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -2,15 +2,18 @@ const axios = require('axios');
|
|||||||
const cheerio = require('cheerio');
|
const cheerio = require('cheerio');
|
||||||
const ics = require('ics');
|
const ics = require('ics');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const express = require('express');
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
app.use('/CSS', express.static('./CSS'));
|
||||||
|
app.use('/HTML', express.static('./HTML'));
|
||||||
const url = "https://info.rpi.edu/registrar/academic-calendar";
|
const url = "https://info.rpi.edu/registrar/academic-calendar";
|
||||||
|
|
||||||
|
|
||||||
|
async function createIcs() {
|
||||||
|
return new Promise(async (resolve) => {
|
||||||
const m = new Map();
|
const m = new Map();
|
||||||
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
// const data = await fetch(url);
|
|
||||||
// console.log(await data.text());
|
|
||||||
await axios.get(url)
|
await axios.get(url)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const $ = cheerio.load(res.data)
|
const $ = cheerio.load(res.data)
|
||||||
@@ -79,12 +82,43 @@ async function main() {
|
|||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(`${__dirname}/rpievents.ics`, value)
|
// console.log(value);
|
||||||
|
resolve(value);
|
||||||
|
// fs.writeFileSync(`${__dirname}/rpievents.ics`, value)
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
// console.log(m.entries().next());
|
// console.log(m.entries().next());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
res.sendFile('index.html', {root: 'HTML'});
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/calendar', (req, res) => {
|
||||||
|
res.sendFile('calendar.html', {root: 'HTML'});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
app.get('/calendar.css', (req, res) => {
|
||||||
|
return res.sendFile('calendar.css', { root: 'CSS' });
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/main.css', (req, res) => {
|
||||||
|
return res.sendFile('main.css', { root: 'CSS' });
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/navbar.css', (req, res) => {
|
||||||
|
return res.sendFile('navbar.css', { root: 'CSS' });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.get('/createCalendar', async (req, res) => {
|
||||||
|
res.set({'Content-Disposition': 'attachment; rpievents.ics','Content-Type': 'text/ics'});
|
||||||
|
res.send(await createIcs())
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(5000);
|
||||||
Reference in New Issue
Block a user