Removed views

This commit is contained in:
MrFry 2020-02-25 17:08:50 +01:00
parent 8189ddf362
commit f26d61a209
11 changed files with 7 additions and 603 deletions

View file

@ -96,20 +96,7 @@ Load()
// -------------------------------------------------------------- // --------------------------------------------------------------
app.get('/', function (req, res) { app.get('/', function (req, res) {
// req.hostname res.end('hai')
let motd = ''
try {
motd = utils.ReadFile(motdFile)
} catch (e) {
}
res.render('main', {
siteurl: url,
qa: actions.ProcessQA(),
motd: motd
})
res.end()
}) })
app.get('/manual', function (req, res) { app.get('/manual', function (req, res) {
@ -118,76 +105,19 @@ app.get('/manual', function (req, res) {
logger.LogReq(req) logger.LogReq(req)
}) })
app.get('/legacy', function (req, res) {
let qcount = data.Subjects.reduce((acc, currItem) => {
acc += currItem.length
return acc
}, 0)
let scount = data.length
let grouped = data.Subjects.reduce((res, s) => {
let sName = s.getSubjNameWithoutYear()
if (sName) {
if (!res[sName]) {
res[sName] = []
}
res[sName].push(s)
} else {
res.others.push(s)
}
return res
}, {
others: []
})
const ordered = {}
Object.keys(grouped).sort().forEach((key) => {
ordered[key] = grouped[key]
})
res.render('alldata', {
data: data,
orderedData: ordered,
scount: scount,
qcount: qcount,
siteurl: url
})
logger.LogReq(req)
})
app.post('/postfeedback', function (req, res) { app.post('/postfeedback', function (req, res) {
res.redirect('back')
logger.Log('New feedback message', logger.GetColor('bluebg'), true) logger.Log('New feedback message', logger.GetColor('bluebg'), true)
utils.AppendToFile('\n\n' + logger.GetDateString() + ': ' + req.body.message_field, msgFile) utils.AppendToFile('\n\n' + logger.GetDateString() + ': ' + req.body.message_field, msgFile)
}) })
app.get('/postfeedback', function (req, res) {
res.redirect('/')
})
app.get('/lred', function (req, res) { app.get('/lred', function (req, res) {
res.redirect('/legacy') res.redirect('/legacy') // TODO: redirect to react legacy
res.end() res.end()
logger.LogReq(req) logger.LogReq(req)
}) })
app.get('/menuClick', function (req, res) { app.get('/menuClick', function (req, res) {
res.redirect('/') res.redirect('/') // TODO: redirect to react /
res.end()
logger.LogReq(req)
})
// all questions readable
app.get('/allqr', function (req, res) {
res.render('allqr', {
d: data.toString().split('\n')
})
logger.LogReq(req)
})
app.get('/greasy', function (req, res) {
res.redirect('https://greasyfork.org/en/scripts/38999-moodle-elearning-kmooc-test-help')
res.end() res.end()
logger.LogReq(req) logger.LogReq(req)
}) })
@ -205,7 +135,7 @@ app.get('/donate', function (req, res) {
}) })
app.get('/thanks', function (req, res) { app.get('/thanks', function (req, res) {
res.render('thanks', { res.render('thanks', { // TODO: redirect to react thanks
siteurl: url siteurl: url
}) })
res.end() res.end()

View file

@ -1,176 +0,0 @@
<html>
<body bgcolor="#212127">
<head>
<title>All questions</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
td {
font: normal 16px Verdana;
}
td {
font: normal 16px Verdana;
width: 100%;
}
textarea {
font: normal 14px Verdana;
color: #999999;
background-color: #212127;
width: 100%;
height: 700
}
a {
color: #9999ff;
}
.collapsible {
background-color: #232329;
color: #999999;
cursor: pointer;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 13px;
}
.openall {
background-color: #212127;
color: #999999;
cursor: pointer;
border: none;
outline: none;
font-size: 13px;
}
.active,
.collapsible:hover {
background-color: #555;
}
.content {
padding: 0 18px;
display: none;
overflow: hidden;
background-color: #232329;
}
.subjTitle {
text-align: center;
margin: 13px;
font-size: 23px;
}
</style>
</head>
<center>
<h2>
Ennek az oldalnak a tartalma dinamikusan frissül minden beküldött kérdés után
</br>
<%=scount%> tárgy és <%=qcount%> kérdés
</h2>
</p>
<a href="<%=siteurl%>/allqr"> Letöltés </a>
<button class="openall" onclick="openall()"> Összes kinyitása </button>
</center>
<% include aludni.ejs %>
<% Object.keys(orderedData).sort().forEach((key, i) => { %>
<table id=<%=i%>>
<td>
<div class="subjTitle">
<%= key %>
</div>
</td>
<td style="vertical-align:middle;text-align:right">
<%= orderedData[key].reduce((acc, item) => {
acc += item.Questions.length
return acc
}, 0)%>
</td>
</table>
</h2>
<div>
<% orderedData[key].forEach((subj, i) => { %>
<button
class="collapsible"
style='<%= i % 2 === 0 ? "background-color: #2f2f37" : "" %>'
onmouseenter='mouseEnter(this, <%= i %>)'
onmouseleave='mouseLeave(this, <%= i %>)'
>
<h2>
<table id=<%=i%>>
<td>
<%=subj.Name %>
</td>
<td style="vertical-align:middle;text-align:right">
<%=subj.length %>
</td>
</table>
</h2>
</button>
<div class="content">
<% var a = subj.toString().split('\n')%>
<% for (var j = 1; j < a.length; j++) { %>
<% if (a[j][0] == '?') { %>
</br>
<% } %>
<%=a[j] %>
</br>
<% } %>
</div>
<% }) %>
</div>
<% }) %>
<script>
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "block") {
content.style.display = "none";
} else {
content.style.display = "block";
}
});
}
function openall () {
var coll = document.getElementsByClassName("content");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].style.display = "block";
}
}
function mouseEnter (e, i) {
e.style.backgroundColor = "#555"
}
function mouseLeave (e, i) {
if (i % 2 == 0) {
e.style.backgroundColor = "#2f2f37"
} else {
e.style.backgroundColor = "#232329"
}
}
</script>
<% include b.ejs %>
</body>
</html>

View file

@ -1,23 +0,0 @@
<html>
<body bgcolor="#212127">
<head>
<title>All questions</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
</style>
</head>
<% for (var i = 0; i < d.length; i++) { %>
<%= d[i] %>
</br>
<% } %>
</body>
</html>

View file

@ -1,6 +0,0 @@
<% var d = new Date().getHours();
if (d < 6 || d > 22) { %>
<center>
<img src="img/aludni.jpeg" alt="img"/>
</center>
<% } %>

View file

@ -1,35 +0,0 @@
<% function GetRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
} %>
<% if (GetRandom(0, 100) == 1) { %>
<div style="position:fixed;left:0;bottom:0;margin:0;padding:0;" >
<img onclick="playDeer()" width=30% src="img/tiszai.png" alt="img" style="cursor:
pointer"/>
</div>
<script>
var deer = new Audio('sound/deer.mp3');
var deer2 = new Audio('sound/deer2.mp3');
var deer3 = new Audio('sound/deer3.mp3');
var deer4 = new Audio('sound/deer4.mp3');
function GetRandom(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function playDeer() {
var r = GetRandom(0, 3);
if (r == 0) {
deer.play();
} else if (r == 1) {
deer2.play();
} else if (r == 2) {
deer3.play();
} else if (r == 3) {
deer4.play();
}
}
</script>
<% } %>

View file

@ -1,112 +0,0 @@
<html>
<body bgcolor="#212127">
<head>
<title>Question mining</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
td {
vertical-align: top
}
textarea {
font: normal 14px Verdana;
color: #999999;
background-color: #212127;
width: 100%;
height: 700;
}
a {
color: #9999ff;
}
.rainbow {
background: linear-gradient( 92deg, #ff0000, #00ffff);
background: -webkit-linear-gradient( 92deg, #ff0000, #00ffff);
background-size:600vw 600vw;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: textAnimate 5s linear infinite alternate;
}
@keyframes textAnimate {
from {
filter: hue-rotate(0deg);
background-position-x: 0%;
}
to {
filter: hue-rotate(360deg);
background-position-x: 600vw;
}
}
</style>
</head>
</p>
<h2>
<a href="<%= siteurl %>/install">Script install</a> |
<a href="<%= siteurl %>/manual">Manual</a> |
<a href="<%= siteurl %>/legacy">Összes kérdés (Olvasható formátum)</a> |
<a href="<%= siteurl %>/data.json">Összes kérdés (JSON)</a> |
<a href="<%= siteurl %>/servergit">Szerver repó</a> |
<a href="<%= siteurl %>/scriptgit">Userscript repó</a> |
<a href="<%= siteurl %>/classesgit">Classes repó</a> |
<a href="<%= siteurl %>/donate">Donate</a>
</h2>
<hr>
<h3>
<b>MOTD:</b>
<%- motd %>
</h2>
<hr>
<form action="/postfeedback" , method="post">
<div>Észrevételek: (közeledő teszt miatti kérdés-karbantartás, bug, feature vagy egyéb dolog, ami nyomja a lelked)</div>
<textarea type="text" name="message_field" style="width: 100%;box-sizing:border-box;height: 100;"></textarea>
<div>Rengeteg spam-et kapok, nyugodtan küldd el ezerszer, akkor hátha észreveszem a spam
között :)</div>
<button>Küldés</button>
</form>
<hr>
Hibát kiváltó teszt feltöltése
</br>
<form action="/badtestsender" enctype=multipart/form-data method="post">
<input type="file" name="dasfile" />
<input type="submit" value="Upload" />
</form>
</p>
Ha egy kérdésre mindig helytelenül talál választ a userscript (vagy egyéb hibát észlelsz), akkor azon az oldalon nyomj egy ctrl-s -t. Ez lementi a weboldalt úgy ahogy van egy mappába, és egy html fájlba. Ezt a kettőt ha berakod egy .zip-be, és ide feltöltöd, akkor ránézek mi lehet a hiba, és kijavítom. <b> Max 10 MB!
</b> Ha több, elég a .html. Bónusz ha mellékelsz egy readme-t, hogy mit csináljak.
<% include aludni.ejs %>
<table>
<td>
<!-- Kommentek / válaszok -->
<% include qa.ejs %>
</td>
</table>
<center> ... </center>
<% include b.ejs %>
</body>
</html>

View file

@ -23,8 +23,6 @@ tesztjeid kérdéseit és (helyes)válaszait feltölti! Ezzel garantálja, hogy
másnak a legfrissebb adatok állnak rendelkezésre.</b> másnak a legfrissebb adatok állnak rendelkezésre.</b>
<center> <center>
<% include aludni.ejs %>
<h3>Tartalomjegyzék</h3> <h3>Tartalomjegyzék</h3>
</center> </center>
<hr> <hr>
@ -172,5 +170,3 @@ helyesnek vélt válaszok. Fogadott adatok: az összes eddig ismert moodle kérd
document.getElementById("tex").value = "// @resource data file:///" + a; document.getElementById("tex").value = "// @resource data file:///" + a;
} }
</script> </script>
<% include b.ejs %>

View file

@ -1,35 +0,0 @@
<center><h2> Q & A: </h3></center>
<% for (var i = qa.length - 1; i >= 0 ; i--) { %>
<hr>
<table style="width:100%">
<td style="vertical-align:middle;text-align:center;width:5%">
<h2 >
<%= i %>
</h2>
</td>
<td >
<b>
<%= qa[i].q %>
</b>
<p/>
<% if (qa[i].a) { %>
<% for (var j = 0; j < qa[i].a.length; j++) { %>
<% if (j != 0) { %>
<p/>
<% } %>
<%= qa[i].a[j] %>
<% } %>
<% } else { %>
<i> Válasz folyamatban... </i>
<% } %>
</td>
</table>
<% } %>

View file

@ -1,114 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Quicksand&display=swap" rel="stylesheet">
<title>Thank you!</title>
<style>
:root{
--size: 100px;
--bgcolor: #212127;
--color: #fcff4f;
--shadow: rgba(30,2,5,.2);
}
.surface {
position:absolute;
top: 50%;
left: 50%;
transform-style: preserve-3d;
transform: translate(-50%,-50%) rotateX(70deg) rotateZ(300deg);
width: 300px;
height: 300px;
animation: rotatingCoin 1s linear infinite;
}
.coin,
.shadow {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%) rotateX(30deg);
width: 100px;
height: 100px;
background-image: url('https://i.ya-webdesign.com/images/mario-coin-png-19.png');
background-position: center;
background-size: cover;
background-color: var(--color);
border-radius: 50%;
}
.shadow {
width: 90px;
height: 90px;
transform: translate(-50%,-50%) translateZ(-25px);
background: linear-gradient(to bottom, rgba(255,255,255,.2) 0%,var(--bgcolor) 35%);
}
@keyframes rotatingCoin {
from {transform: translate(-50%,-50%) rotateX(70deg) rotateZ(0);}
to {transform: translate(-50%,-50%) rotateX(70deg) rotateZ(360deg);}
}
html,body{
height:100vh;
overflow: hidden;
}
body {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background-color: var(--bgcolor);
}
#text{
font-family: 'Quicksand', sans-serif;
color: white;
font-size: 24px;
text-shadow: 1px 1px 2px rgba(0,0,0,0.6);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-top: 30px;
}
#backbutton{
text-decoration: none;
color: white;
cursor: pointer;
margin: 10px;
background-color: #4bb9bd;
box-shadow: 0px 1px 3px rgba(0,0,0,0.6);
border-radius: 3px;
padding: 3px 10px;
}
#backbutton:hover{
box-shadow: 0px 1px 2px rgba(0,0,0,0.6);
}
.coincontainer {
position: relative;
width: 200px;
height: 200px;
}
@media only screen and (max-width: 600px) {
body {
flex-direction: column;
}
}
</style>
</head>
<body>
<div class="coincontainer"><div class="surface">
<div class="coin"></div>
<div class="shadow"></div>
</div></div>
<center>
<div id="text"><span>Thanks for the gold, kind question miner!</span><a id="backbutton" href="<%= siteurl %>">Return</a></div>
</center>
<div class="coincontainer"><div class="surface">
<div class="coin"></div>
<div class="shadow"></div>
</div></div>
</body>
</html>

View file

@ -1,23 +0,0 @@
<html>
<body bgcolor="#212127">
<head>
<meta name="viewport" content="width=device-width, initial-scale=0.8" />
<meta charset="UTF-8">
<style>
body {
font: normal 14px Verdana;
color: #999999;
}
a {
color: #9999ff;
}
</style>
</head>
fájl feltöltve!
<a href="/"> Vissza</a>
</body>
</html>

View file

@ -20,7 +20,7 @@
const startHTTPS = true const startHTTPS = true
const port = 5000 const port = 5000
const httpsport = 8443 const httpsport = 5001
const express = require('express') const express = require('express')
const vhost = require('vhost') const vhost = require('vhost')
@ -29,6 +29,7 @@ logger.Load()
const utils = require('./utils/utils.js') const utils = require('./utils/utils.js')
const http = require('http') const http = require('http')
const https = require('https') const https = require('https')
const cors = require('cors')
const extraModulesFile = './extraModules.json' const extraModulesFile = './extraModules.json'
const modulesFile = './modules.json' const modulesFile = './modules.json'
@ -52,6 +53,7 @@ try {
} }
const app = express() const app = express()
app.use(cors())
app.use(function (req, res, next) { app.use(function (req, res, next) {
res.on('finish', function () { res.on('finish', function () {