Răsfoiți Sursa

Remove learn content.

Lee Morgan 4 ani în urmă
părinte
comite
f439628760

+ 0 - 356
controllers/learn.js

@@ -1,356 +0,0 @@
-const Uploader = require("../models/uploader.js");
-const Course = require("../models/course.js");
-const {Lecture, Question, Answer} = require("../models/lecture.js");
-
-const createId = require("./createId.js");
-
-const axios = require("axios");
-const queryString = require("querystring");
-
-module.exports = {
-    /*
-    POST: create a new course
-    req.body = {
-        uploaderId: String,
-        password: String,
-        title: String
-        thumbNail: String,
-        description: String
-    }
-    redirect to home
-    */
-    createCourse: function(req, res){
-        Uploader.findOne({_id: req.body.uploaderId})
-            .then((uploader)=>{
-                if(uploader === null) throw "uploader";
-                if(req.body.password !== uploader.password) throw "pass";
-                let imgString = `/thumbNails/${req.files.thumbNail.name}`;
-                req.files.thumbNail.mv(`${__dirname}/..${imgString}`);
-
-                let course = new Course({
-                    owner: uploader._id,
-                    title: req.body.title,
-                    thumbNail: imgString,
-                    description: req.body.description
-                });
-
-                return course.save();
-            })
-            .then((course)=>{
-                return res.redirect("/");
-            })
-            .catch((err)=>{
-                if(err === "uploader") return res.json("Uploader doesn't exist");
-                if(err === "pass") return res.json("Incorrect password");
-                return res.json("Something went wrong on the backend");
-            });
-    },
-
-    /*
-    POST: create a new lecture
-    req.body = {
-        uploader: String
-        password: String
-        course: String
-        title: String
-        video: String
-        description: String
-        furtherReading: [{
-            text: String
-            link: String
-        }]
-        exercises: [String]
-        documents: [{
-            title: String
-            link: String
-        }],
-        date: Date
-    }
-    redirects to edited lecture
-    */
-    createLecture: function(req, res){
-        Course.findOne({_id: req.body.course})
-            .populate("owner")
-            .then((course)=>{
-                if(course === null) throw "noCourse";
-                if(req.body.uploader !== course.owner._id.toString()) throw "badOwner";
-                if(req.body.password !== course.owner.password) throw "badPass";
-
-
-                let exercises = req.body.exercises.split("\r\n");
-                exercises.splice(exercises.length - 1, 1);
-
-                let furtherReading = req.body.furtherReading.split("\r\n");
-                furtherReading.splice(furtherReading.length-1, 1);
-                let readings = [];
-                for(let i = 0; i < furtherReading.length; i+=2){
-                    readings.push({
-                        text: furtherReading[i],
-                        link: furtherReading[i+1]
-                    });
-                }
-
-                let lecture = new Lecture({
-                    course: course._id,
-                    title: req.body.title,
-                    video: req.body.video,
-                    description: req.body.description,
-                    furtherReading: readings,
-                    exercises: exercises,
-                    documents: [],
-                    createdDate: new Date(req.body.date)
-                });
-
-                
-                if(req.files !== null){
-                    let files = req.files.documents;
-                    if(files.length === undefined){
-                        let fileId = createId(25);
-                        let fileParts = files.name.split(".");
-                        let fileString = `/documents/${fileId}.${fileParts[1]}`;
-                        files.mv(`${__dirname}/..${fileString}`);
-                        lecture.documents.push({
-                            name: files.name,
-                            link: fileString
-                        })
-                    }else{
-                        for(let i = 0; i < files.length; i++){
-                            let fileId = createId(25);
-                            let fileParts = files[i].name.split(".");
-                            let fileString = `/documents/${fileId}.${fileParts[1]}`;
-                            files[i].mv(`${__dirname}/..${fileString}`);
-                            lecture.documents.push({
-                                name: files[i].name,
-                                link: fileString
-                            });
-                        }
-                    }
-                }
-                
-                return lecture.save();
-            })
-            .then((lecture)=>{
-                return res.redirect(`/learn/lectures/${lecture._id}`);
-            })
-            .catch((err)=>{
-                if(err === "noCourse") return res.json("Course does not exist");
-                if(err === "badOwner") return res.json("You do not own this course");
-                if(err === "badPass") return res.json("Incorrect password");
-                return res.redirect("/");
-            });
-    },
-
-    /*
-    POST: updates a lecture
-    req.body = {
-        uploader: String,
-        password: String
-        title: String
-        video: String
-        description: String
-        furtherReading: String (\r\n delimited)
-        exercises; String (\r\n delimited)
-        date: Date
-    }
-    req.params.id = String (lecture id)
-    redirects to updated lecture
-    */
-    updateLecture: function(req, res){
-        Lecture.findOne({_id: req.params.id})
-            .then((lecture)=>{
-                if(lecture === null) throw "notFound";
-
-                let furtherReading = req.body.furtherReading.split("\r\n");
-                furtherReading.splice(furtherReading.length - 1, 1);
-                let readings = [];
-                for(let i = 0; i < furtherReading.length; i+=2){
-                    readings.push({
-                        text: furtherReading[i],
-                        link: furtherReading[i+1]
-                    });
-                }
-
-                let exercises = req.body.exercises.split("\r\n");
-                exercises.splice(exercises.length - 1, 1);
-
-                lecture.title = req.body.title;
-                lecture.video = req.body.video;
-                lecture.description = req.body.description;
-                lecture.furtherReading = readings;
-                lecture.exercises = exercises;
-                lecture.updatedDate = new Date(req.body.date);
-
-                return lecture.save();
-            })
-            .then((lecture)=>{
-                return res.redirect(`/learn/lectures/${lecture._id}`);
-            })
-            .catch((err)=>{
-                return res.redirect(`/learn/lectures/edit/${lecture._id}`);
-            });
-    },
-
-    /*
-    DELETE: remove the lecture
-    req.params.id = lecture to remove
-    redirects to home
-    */
-    removeLecture: function(req, res){
-        Lecture.deleteOne({_id: req.params.id})
-            .then((lecture)=>{
-                return res.redirect("/");
-            })
-            .catch((err)=>{
-                return res.redirect(`/learn/lectures/edit/${req.params.id}`);
-            })
-    },
-
-    getCourses: function(req, res){
-        Course.find()
-            .then((courses)=>{
-                return res.json(courses);
-            })
-            .catch((err)=>{
-                return res.json("Could not retrieve courses");
-            });
-    },
-
-    /*
-    GET: get a list of lectures from a course
-    req.params.id = String (course id)
-    response = {
-        course: Course,
-        lectures: [Lecture]
-    }
-    */
-    getLectures: function(req, res){
-        let course = Course.findOne({_id: req.params.id});
-        let lectures = Lecture.find({course: req.params.id});
-
-        Promise.all([course, lectures])
-            .then((response)=>{
-                return res.json({course: response[0], lectures: response[1]});
-            })
-            .catch((err)=>{
-                return res.json("Could not retrieve lectures");
-            });
-    },
-
-    /*
-    GET: get data for a single lecture
-    req.params.id = String (lecture id)
-    response = Lecture
-    */
-    getLecture: function(req, res){
-        Lecture.findOne({_id: req.params.id})
-            .populate("course")
-            .then((lecture)=>{
-                return res.json(lecture);
-            })
-            .catch((err)=>{
-                return res.json("Could not retrieve lecture");
-            });
-    },
-
-    /*
-    POST: create a new question
-    req.body = {
-        lecture: String (Lecture id)
-        name: String
-        title: String
-        content: String
-    }
-    response: Question
-    */
-    createQuestion: function(req, res){
-        let question = new Question({
-            name: req.body.name,
-            title: req.body.title,
-            content: req.body.content,
-            answers: []
-        });
-
-        Lecture.findOne({_id: req.body.lecture})
-            .then((lecture)=>{
-                lecture.questions.push(question);
-
-                axios({
-                    method: "post",
-                    url: "https://api.mailgun.net/v3/mg.leemorgan.io/messages",
-                    headers: {
-                        "Content-Type": "application/x-www-form-urlencoded"
-                    },
-                    auth: {
-                        username: "api",
-                        password: process.env.MG_PERSONAL_APIKEY
-                    },
-                    data: queryString.stringify({
-                        from: "Lee Morgan <learn@leemorgan.io>",
-                        to: "me@leemorgan.io",
-                        subject: question.title,
-                        text: `Lecture: ${lecture._id}\nQuestion: ${question._id}\n${question.content}`
-                    })
-                })
-                .catch((err)=>{
-                    console.error(err);
-                });
-
-                lecture.save();
-            })
-            .then((lecture)=>{
-
-                return res.json(question);
-            })
-            .catch((err)=>{
-                console.error(err);
-                return res.json("ERROR: unable to save the question");
-            });
-    },
-
-    /*
-    POST: creates a new answer to a question
-    req.body = {
-        uploader: String (Uploader id)
-        password: String
-        lecture: String (Lecture id)
-        question: String (Question id)
-        name: String
-        content: String
-    }
-    redirect: /learn/lecture/:id
-    */
-    createAnswer: function(req, res){
-        let answer = new Answer({
-            name: req.body.name,
-            content: req.body.content
-        });
-
-        let uploader = Uploader.findOne({_id: req.body.uploader});
-        let lecture = Lecture.findOne({_id: req.body.lecture});
-
-        Promise.all([uploader, lecture])
-            .then((response)=>{
-                let lecture = response[1];
-                let uploader = response[0];
-
-                if(uploader === null || uploader.password !== req.body.password) throw "auth";
-
-                let question = lecture.questions.id(req.body.question);
-
-                question.answers.push(answer);
-                
-                lecture.save();
-            })
-            .then((lecture)=>{
-                return res.redirect(`/learn/lectures/${req.body.lecture}`);
-            })
-            .catch((err)=>{
-                switch(err){
-                    case "auth": return res.redirect(`/learn/lectures/${req.body.lecture}`);
-                    default:
-                        console.error(err);
-                        return res.json("ERROR: unable to create new question");
-                }
-            });
-    }
-}

+ 0 - 23
models/course.js

@@ -1,23 +0,0 @@
-const mongoose = require("mongoose");
-
-const CourseSchema = new mongoose.Schema({
-    owner: {
-        type: mongoose.Schema.Types.ObjectId,
-        ref: "Uploader",
-        required: true
-    },
-    title: {
-        type: String,
-        required: true
-    },
-    thumbNail: {
-        type: String,
-        required: true
-    },
-    description: {
-        type: String,
-        required: true
-    }
-});
-
-module.exports = mongoose.model("Course", CourseSchema);

+ 0 - 79
models/lecture.js

@@ -1,79 +0,0 @@
-const mongoose = require("mongoose");
-
-const AnswerSchema = new mongoose.Schema({
-    name: {
-        type: String,
-        required: true
-    },
-    content: {
-        type: String,
-        required: true
-    },
-    createdAt: {
-        type: Date,
-        default: new Date()
-    }
-});
-
-const QuestionSchema = new mongoose.Schema({
-    name: String,
-    title: {
-        type: String,
-        required: true
-    },
-    content: {
-        type: String,
-        required: true,
-        minlength: 15
-    },
-    answers: [AnswerSchema],
-    createdAt: {
-        type: Date,
-        default: new Date()
-    }
-});
-
-const LectureSchema = new mongoose.Schema({
-    course: {
-        type: mongoose.Schema.Types.ObjectId,
-        ref: "Course",
-        required: true
-    },
-    title: {
-        type: String,
-        required: true
-    },
-    video: {
-        type: String,
-        required: true
-    },
-    description: {
-        type: String,
-        required: true,
-    },
-    furtherReading: [{
-        text: String,
-        link: String
-    }],
-    documents: [{
-        name: String,
-        link: String
-    }],
-    exercises: [String],
-    createdDate: {
-        type: Date,
-        default: new Date(),
-        required: true
-    },
-    updatedDate: {
-        type: Date,
-        required: false
-    },
-    questions: [QuestionSchema]
-});
-
-module.exports = {
-    Lecture: mongoose.model("Lecture", LectureSchema),
-    Question: mongoose.model("Question", QuestionSchema),
-    Answer: mongoose.model("Answer", AnswerSchema)
-};

+ 0 - 26
routes.js

@@ -1,5 +1,4 @@
 const gallery = require("./controllers/gallery.js");
-const learn = require("./controllers/learn.js");
 const blog = require("./controllers/blog.js");
 const currency = require("./controllers/currency.js");
 
@@ -58,30 +57,6 @@ module.exports = function(app){
     app.get("/gallery/json/:id", gallery.getGallery);
     app.get("/gallery/:id", (req, res)=>{res.sendFile(`${views}/gallery/index.html`)});
 
-    //LEARN
-    app.get("/learn/style", (req, res)=>{res.sendFile(`${views}/learn/index.css`)});
-    
-    app.get("/learn/courses/new", (req, res)=>{res.sendFile(`${views}/learn/newCourse.html`)});
-    app.post("/learn/courses/new", learn.createCourse);
-    app.get("/learn/courses/json", learn.getCourses);
-    app.get("/learn/courses/:id", (req, res)=>{res.sendFile(`${views}/learn/course.html`)});
-    app.get("/learn", (req, res)=>{res.sendFile(`${views}/learn/courses.html`)});
-    app.get("/learn/answers/new/", (req, res)=>{res.sendFile(`${views}/learn/newAnswer.html`)});
-
-    app.get("/learn/lectures/new", (req, res)=>{res.sendFile(`${views}/learn/newLecture.html`)});
-    app.post("/learn/lectures/new", learn.createLecture);
-    app.get("/learn/lectures/edit/:id", (req, res)=>{res.sendFile(`${views}/learn/editLecture.html`)});
-    app.post("/learn/lectures/edit/:id", learn.updateLecture);
-    app.delete("/learn/lectures/:id", learn.removeLecture);
-    app.get("/learn/lectures/json/:id", learn.getLectures);
-    app.get("/learn/lectures/:id", (req, res)=>{res.sendFile(`${views}/learn/lecture.html`)});
-    app.get("/learn/lectures/json/one/:id", learn.getLecture);
-
-    app.post("/learn/questions/create", learn.createQuestion);
-    app.post("/learn/answers/create", learn.createAnswer);
-
-    app.post("/htmltest", (req, res)=>{res.send(`Hi ${req.body.name} from ${req.body.place}`)});
-
     //CURRENCY
     app.get("/currency/new", (req, res)=>{res.sendFile(`${views}/currency/new.html`)});
     
@@ -90,7 +65,6 @@ module.exports = function(app){
 
     //CONTENT
     app.get("/thumbNails/*", (req, res)=>{res.sendFile(`${__dirname}${req.url}`)});
-    app.get("/documents/*", (req, res)=>{res.download(`${__dirname}${req.url}`)});
     app.get("/galleryImages/*", (req, res)=>{res.sendFile(`${__dirname}${req.url}`)});
     app.get("/currencyimages/*", (req, res)=>res.sendFile(`${__dirname}${req.url}`));
 }

+ 0 - 50
views/learn/course.html

@@ -1,50 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>Lee Morgan -course-</title>
-        <link rel="icon" type="img/ico" href="/images/favicon">
-        <link rel="stylesheet" href="/learn/style">
-    </head>
-    <body>
-        <h1 id="title"></h1>
-
-        <div id="lectures" class="cardContainer"></div>
-
-        <template id="template">
-            <a class="card">
-                <img>
-
-                <div>
-                    <h2></h2>
-
-                    <p></p>
-                </div>
-            </a>
-        </template>
-
-        <script>
-            let id = window.location.href.split("/");
-            id = id[id.length-1];
-
-            fetch(`/learn/lectures/json/${id}`)
-                .then(response => response.json())
-                .then((response)=>{
-                    document.getElementById("title").innerText = response.course.title;
-                    let container = document.getElementById("lectures");
-                    let template = document.getElementById("template").content.children[0];
-
-                    for(let i = 0; i < response.lectures.length; i++){
-                        let card = template.cloneNode(true);
-                        card.href = `/learn/lectures/${response.lectures[i]._id}`;
-                        card.children[0].src = response.course.thumbNail;
-                        card.children[0].alt = `${response.course.thumbNail} thumbnail`;
-                        card.children[1].children[0].innerText = response.lectures[i].title;
-                        card.children[1].children[1].innerText = response.lectures[i].description;
-                        container.appendChild(card)
-                    }
-                })
-                .catch((err)=>{});
-        </script>
-    </body>
-</html>

+ 0 - 46
views/learn/courses.html

@@ -1,46 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>Lee Morgan -courses-</title>
-        <link rel="icon" type="img/ico" href="/images/favicon">
-        <link rel="stylesheet" href="/learn/style">
-    </head>
-    <body>
-        <h1>Courses</h1>
-
-        <div id="container" class="cardContainer"></div>
-
-        <template id="template">
-            <a class="card">
-                <img>
-
-                <div>
-                    <h2></h2>
-
-                    <p></p>
-                </div>
-            </a>
-        </template>
-
-        <script>
-            fetch("/learn/courses/json")
-                .then(response => response.json())
-                .then((response)=>{
-                    let container = document.getElementById("container");
-                    let template = document.getElementById("template").content.children[0];
-
-                    for(let i = 0; i < response.length; i++){
-                        let course = template.cloneNode(true);
-                        course.href = `/learn/courses/${response[i]._id}`;
-                        course.children[0].src = response[i].thumbNail;
-                        course.children[0].alt = `${response[i].title} thumbnail`;
-                        course.children[1].children[0].innerText = response[i].title;
-                        course.children[1].children[1].innerText = response[i].description;
-                        container.appendChild(course);
-                    }
-                })
-                .catch((err)=>{});
-        </script>
-    </body>
-</html>

+ 0 - 152
views/learn/editLecture.html

@@ -1,152 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>Lee Morgan</title>
-        <link rel="icon" type="img/ico" href="/images/favicon">
-        <style>
-            form{
-                display: flex;
-                flex-direction: column;
-            }
-
-            #deleteButton{
-                background: red;
-                color: white;
-                margin-top: 100px;
-            }
-        </style>
-    </head>
-    <body>
-        <form id="form" method="post" enctype="multipart/form-data">
-            <label>Uploader
-                <input name="uploader" type="text" required>
-            </label>
-
-            <label>Password
-                <input name="password" type="password" required>
-            </label>
-
-            <label>Title
-                <input id="titleInput" name="title" type="text" required>
-            </label>
-
-            <label>Video
-                <input id="videoInput" name="video" type="text" required>
-            </label>
-
-            <label>Description
-                <textarea id="descriptionInput" name="description"></textarea>
-            </label>
-
-            <h2>Further Reading</h2>
-            <button id="readingButton" type="button">Add Link</button>
-            <div id="reading">
-                <template id="readingItem">
-                    <div class="readingItem">
-                        <input type="text">
-                        <input type="text">
-                        <button type="button">remove</button>
-                    </div>
-                </template>
-            </div>
-
-            <h2>Exercises</h2>
-            <button id="exercisesButton" type="button">Add Exercise</button>
-            <div id="exercises">
-                <template id="exercisesItem">
-                    <div class="exercisesItem">
-                        <textarea></textarea>
-                        <button type="button">remove</button>
-                    </div>
-                </template>
-            </div>
-
-            <input id="readingHidden" name="furtherReading" type="hidden">
-            <input id="exerciseHidden" name="exercises" type="hidden">
-            <input id="dateInput" name="date" type="hidden">
-
-            <input type="submit" value="Submit">
-        </form>
-
-        <button id="deleteButton">DELETE</button>
-
-        <script>
-            let id = window.location.href.split("/");
-            id = id[id.length-1];
-
-            fetch(`/learn/lectures/json/one/${id}`)
-                .then(response => response.json())
-                .then((response)=>{
-                    document.getElementById("titleInput").value = response.title;
-                    document.getElementById("videoInput").value = response.video;
-                    document.getElementById("descriptionInput").innerText = response.description;
-
-                    let readingDiv = document.getElementById("reading");
-                    let readingTemplate = document.getElementById("readingItem").content.children[0];
-                    for(let i = 0; i < response.furtherReading.length; i++){
-                        let div = readingTemplate.cloneNode(true);
-                        div.children[0].value = response.furtherReading[i].text;
-                        div.children[1].value = response.furtherReading[i].link;
-                        div.children[2].onclick = ()=>{div.parentElement.removeChild(div)};
-                        readingDiv.appendChild(div);
-                    }
-
-                    let exerciseDiv = document.getElementById("exercises");
-                    let exerciseTemplate = document.getElementById("exercisesItem").content.children[0];
-                    for(let i = 0; i < response.exercises.length; i++){
-                        let div = exerciseTemplate.cloneNode(true);
-                        div.children[0].innerText = response.exercises[i];
-                        div.children[1].onclick = ()=>{div.parentElement.removeChild(div)};
-                        exerciseDiv.appendChild(div);
-                    }
-
-                    document.getElementById("readingButton").onclick = ()=>{
-                        let div = readingTemplate.cloneNode(true);
-                        div.children[2].onclick = ()=>{div.parentElement.removeChild(div)};
-                        readingDiv.appendChild(div);
-                    };
-
-                    document.getElementById("exercisesButton").onclick = ()=>{
-                        let div = exerciseTemplate.cloneNode(true);
-                        div.children[1].onclick = ()=>{div.parentElement.removeChild(div)};
-                        exerciseDiv.appendChild(div);
-                    };
-                })
-                .catch((err)=>{});
-
-                let form = document.getElementById("form");
-                form.onsubmit = ()=>{
-                    event.preventDefault();
-
-                    let readingDiv = document.getElementById("reading").children;
-                    let readingText = "";
-                    for(let i = 1; i < readingDiv.length; i++){
-                        readingText += `${readingDiv[i].children[0].value}\n${readingDiv[i].children[1].value}\n`;
-                    }
-                    document.getElementById("readingHidden").value = readingText;
-
-                    let exerciseDivs = document.getElementById("exercises").children;
-                    let exerciseText = "";
-                    for(let i = 1; i < exerciseDivs.length; i++){
-                        exerciseText += `${exerciseDivs[i].children[0].value}\n`;
-                    }
-                    document.getElementById("exerciseHidden").value = exerciseText;
-
-                    document.getElementById("dateInput").value = new Date();
-
-                    form.submit();
-                }
-
-                document.getElementById("deleteButton").onclick = ()=>{
-                    fetch(`/learn/lectures/${id}`,{
-                        method: "delete"
-                    })
-                        .then((response)=>{
-                            window.location.href;
-                        })
-                        .catch((err)=>{});
-                }
-        </script>
-    </body>
-</html>

+ 0 - 182
views/learn/index.css

@@ -1,182 +0,0 @@
-*{margin:0;padding:0;}
-
-body{
-    background: rgb(196, 198, 192);
-    padding: 25px;
-    padding-top: 0;
-}
-
-h1{
-    text-align: center;
-}
-
-button{
-    height: 35px;
-    width: 175px;
-    border: 1px solid black;
-    background: white;
-    margin: 10px;
-    cursor: pointer;
-    box-shadow: 0 0 1px black;
-}
-
-button:hover{
-    background: rgb(196, 198, 192);
-}
-
-.cardContainer{
-    width: 90%;
-    padding: 25px;
-}
-
-.card{
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-    margin: 15px auto;
-    height: 150px;
-    background: white;
-    padding-right:15px;
-    text-decoration: none;
-}
-
-    .card:hover{
-        box-shadow: 0 0 3px black;
-    }
-
-    .card div{
-        align-items: center;
-        color: black;
-        height: 100%;
-        flex-grow: 2;
-    }
-
-    .card img{
-        height: 100%;
-    }
-
-    .card h2{
-        text-align: center;
-        margin: 10px 0;
-    }
-
-    .card p{
-        text-align:center;
-        width: 75%;
-        margin: auto;
-    }
-
-#lectureBody, html{
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-    min-height: 100vh;
-    max-width: 100vw;
-}
-
-    #video{
-        margin: 50px;
-    }
-
-    #lectureData{
-        margin-right: auto;
-        padding-left: 100px;
-    }
-
-        #lectureData > *{
-            margin: 15px 0;
-        }
-
-        #lectureData h2{
-            margin: 35px 0 0 0;
-        }
-
-        #documents{
-            display: flex;
-            flex-direction: column;
-        }
-
-        #exercises{
-            padding-left: 15px;
-            margin-top: 0;
-        }
-
-    .liPad{
-        margin: 10px;
-    }
-
-    #questionContainer{
-        display: flex;
-        flex-direction: column;
-        align-items: center;
-        width: 100%;
-    }
-
-    .question{
-        display: flex;
-        flex-direction: column;
-        align-items: center;
-        background: white;
-        width: 50%;
-        margin: 15px;
-        padding: 10px;
-    }
-
-        .questHead{
-            display: flex;
-            align-items: center;
-            font-size: 12px;
-            margin-bottom: 25px;
-        }
-
-            .questHead p{
-                margin: 0 5px;
-            }
-
-    #questionForm{
-        flex-direction: column;
-        height: 100vh;
-        width: 100vw;
-        z-index: 2;
-        position: fixed;
-        background: rgb(196, 198, 192);
-        padding: 100px;
-        box-sizing: border-box;
-    }
-
-        #questionForm label{
-            display: flex;
-            flex-direction: column;
-            margin: 15px;
-        }
-
-        #questionForm input{
-            width: 50%;
-        }
-
-        #questionForm textarea{
-            height: 25vh;
-        }
-
-#answerContainer{
-    width: 50%;
-}
-
-    .answer{
-        width: 100%;
-        padding: 10px;
-        display: flex;
-        flex-direction: column;
-        align-items: center;
-        background:rgb(196, 198, 192);
-        margin: 10px;
-    }
-
-        .answerHeader{
-            display: flex;
-            font-size: 12px;
-        }
-
-            .answerHeader > *{
-                margin: 5px;
-            }

+ 0 - 218
views/learn/lecture.html

@@ -1,218 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>Lee Morgan -lecture-</title>
-        <link rel="icon" type="img/ico" href="/images/favicon">
-        <link rel="stylesheet" href="/learn/style">
-    </head>
-    <body id="lectureBody">
-        <h1 id="title"></h1>
-
-        <h3 id="course"></h3>
-
-        <h6 id="date"></h6>
-
-        <iframe id="video"></iframe>
-
-        <div id="lectureData">
-            <h2 id="exerciseTitle">Exercises</h2>
-            <ol id="exercises"></ol>
-
-            <h2 id="readingTitle">Further Reading</h2>
-            <ul id="readings"></ul>
-            
-            <h2 id="resourceTitle">Resources</h2>
-            <div id="documents"></div>
-        </div>
-
-        <h1>Q&A</h1>
-        <button id="questionButton">Ask a question</button>
-        <div id="questionContainer">
-            <template id="question">
-                <div class="question">
-                    <h2 class="questTitle"></h2>
-                    <div class="questHead">
-                        <p class="questName"></p>
-                        <p>at</p>
-                        <p class="questDate"></p>
-                    </div>
-                    <p class="questContent"></p>
-                    <div class="answerContainer"></div>
-                </div>
-            </template>
-
-            <template id="answer">
-                <div class="answer">
-                    <div class="answerHeader">
-                        <p class="answerName"></p>
-                        <p>at</p>
-                        <p class="answerDate"></p>
-                    </div>
-                    <p class="answerContent"></p>
-                </div>
-            </template>
-        </div>
-
-        <form id="questionForm" style="display:none" method="post">
-            <h1 id="questionHeader"></h1>
-
-            <label>Your name
-                <input id="questionName" type="text">
-            </label>
-
-            <label>Title
-                <input id="questionTitle" type="text">
-            </label>
-
-            <label>Question
-                <textarea id="questionContent" minlength="15" required></textarea>
-            </label>
-
-            <button id="questionAsk" type="button">Ask</button>
-
-            <button id="questionCancel" type="button">Cancel</button>
-        </form>
-            
-        <script>
-            let video = document.getElementById("video");
-
-            let sizeIframe = ()=>{
-                let width = window.innerWidth;
-                let height = window.innerHeight;
-                video.width = width * 0.75;
-                video.height = height * 0.75;
-            }
-
-            video.onload = sizeIframe();
-            let id = window.location.href.split("/");
-            id = id[id.length-1];
-
-            fetch(`/learn/lectures/json/one/${id}`)
-                .then(response => response.json())
-                .then((response)=>{
-                    let date = new Date(response.createdDate);
-
-                    document.getElementById("title").innerText = response.title;
-                    document.getElementById("course").innerText = response.course.title;
-                    document.getElementById("date").innerText = date.toDateString();
-                    video.src = response.video;
-
-                    let documents = document.getElementById("documents");
-                    if(response.documents.length === 0) document.getElementById("resourceTitle").style.display = "none";
-                    for(let i = 0; i < response.documents.length; i++){
-                        let a = document.createElement("a");
-                        a.classList.add("liPad");
-                        a.href = response.documents[i].link;
-                        a.innerText = response.documents[i].name.replaceAll("_", " ");
-                        documents.appendChild(a);
-                    }
-                    
-                    let exercises = document.getElementById("exercises");
-                    if(response.exercises.length === 0) document.getElementById("exerciseTitle").style.display = "none";
-                    for(let i = 0; i < response.exercises.length; i++){
-                        let li = document.createElement("li");
-                        li.classList.add("liPad");
-                        li.innerText = response.exercises[i];
-                        exercises.appendChild(li);
-                    }
-
-                    let readings = document.getElementById("readings");
-                    if(response.furtherReading.length === 0) document.getElementById("readingTitle").style.display = "none";
-                    for(let i = 0; i < response.furtherReading.length; i++){
-                        let li = document.createElement("li");
-                        li.classList.add("liPad");
-                        readings.appendChild(li);
-
-                        let a = document.createElement("a");
-                        a.href = response.furtherReading[i].link;
-                        a.innerText = response.furtherReading[i].text;
-                        li.appendChild(a);
-                    }
-
-                    //Populate questions
-                    let template = document.getElementById("question").content.children[0];
-                    let answerTemplate = document.getElementById("answer").content.children[0];
-                    let questionContainer = document.getElementById("questionContainer");
-                    response.questions.reverse();
-                    for(let i = 0; i < response.questions.length; i++){
-                        let date = new Date(response.questions[i].createdAt);
-                        date = date.toLocaleString("en-US");
-                        
-                        let question = template.cloneNode(true);
-                        question.querySelector(".questTitle").innerText = response.questions[i].title;
-                        question.querySelector(".questName").innerText = response.questions[i].name;
-                        question.querySelector(".questDate").innerText = date;
-                        question.querySelector(".questContent").innerText = response.questions[i].content;
-                        questionContainer.appendChild(question);
-
-                        //Populate answers
-                        response.questions[i].answers.reverse();
-                        for(let j = 0; j < response.questions[i].answers.length; j++){
-                            let answer = response.questions[i].answers[j];
-                            let answerDate = new Date(answer.createdAt);
-                            answerDate = answerDate.toLocaleString("en-US");
-
-                            let elem = answerTemplate.cloneNode(true);
-                            elem.querySelector(".answerName").innerText = answer.name;
-                            elem.querySelector(".answerDate").innerText = answerDate;
-                            elem.querySelector(".answerContent").innerText = answer.content;
-                            question.querySelector(".answerContainer").appendChild(elem);
-                        }
-                    }
-                })
-                .catch((err)=>{});
-
-                //New Question
-                let form = document.getElementById("questionForm");
-                let formTitle = document.getElementById("questionHeader");
-                let lecture = window.location.href.split("/");
-                lecture = lecture[lecture.length-1];
-
-                document.getElementById("questionCancel").onclick = ()=>{form.style.display = "none"};
-
-                document.getElementById("questionButton").onclick = ()=>{
-                    form.style.display = "flex";
-                    form.route = "/learn/questions/create";
-                    formTitle.innerText = "Ask a Question";
-                };
-
-                document.getElementById("questionAsk").onclick = ()=>{
-                    event.preventDefault();
-                    form.style.display = "none";
-
-                    let data = {
-                        lecture: lecture,
-                        name: document.getElementById("questionName").value,
-                        title: document.getElementById("questionTitle").value,
-                        content: document.getElementById("questionContent").value
-                    };
-                    
-                    fetch(form.route, {
-                        method: "post",
-                        headers: {
-                            "Content-Type": "application/json"
-                        },
-                        body: JSON.stringify(data)
-                    })
-                        .then(response => response.json())
-                        .then((response)=>{
-                            if(typeof(response) !== "string"){
-                                let template = document.getElementById("question").content.children[0];
-                                let questionContainer = document.getElementById("questionContainer");
-                                let date = new Date(response.createdAt);
-                                date = date.toLocaleString("en-US");
-
-                                let question = template.cloneNode(true);
-                                question.querySelector(".questTitle").innerText = response.title;
-                                question.querySelector(".questName").innerText = response.name;
-                                question.querySelector(".questDate").innerText = date;
-                                question.querySelector(".questContent").innerText = response.content;
-                                questionContainer.insertBefore(question, questionContainer.firstChild);
-                            }
-                        })
-                        .catch((err)=>{});
-                }
-        </script>
-    </body>
-</html>

+ 0 - 51
views/learn/newAnswer.html

@@ -1,51 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>New Answer</title>
-        <link rel="icon" type="img/ico" href="/images/favicon">
-        <style>
-            form{
-                display: flex;
-                flex-direction: column;
-            }
-
-            form > *{
-                margin: 15px;
-            }
-
-            input[type=submit]{
-                width: 250px;
-            }
-        </style>
-    </head>
-    <body>
-        <form action="/learn/answers/create" method="post">
-            <label>Uploader
-                <input name="uploader" type="text" required>
-            </label>
-
-            <label>Password
-                <input name="password" type="password" required>
-            </label>
-
-            <label>Lecture
-                <input name="lecture" type="text" required>
-            </label>
-
-            <label>Question
-                <input name="question" type="text" required>
-            </label>
-
-            <label>Name
-                <input name="name" type="text" required>
-            </label>
-
-            <label>Content
-                <textarea name="content" required></textarea>
-            </label>
-
-            <input type="Submit">
-        </form>
-    </body>
-</html>

+ 0 - 49
views/learn/newCourse.html

@@ -1,49 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>Create Course</title>
-        <link rel="icon" type="img/ico" href="/images/favicon">
-        <style>
-            form{
-                display: flex;
-                flex-direction: column;
-            }
-
-            form > *{
-                margin: 10px 0;
-            }
-
-            input[type=submit]{
-                max-width: 250px;
-            }
-        </style>
-    </head>
-    <body>
-        <h1>Enter course details</h1>
-
-        <form action="/learn/courses/new" method="post" encType="multipart/form-data">
-            <label>Uploader ID
-                <input name="uploaderId" type="text" required>
-            </label>
-
-            <label>Password
-                <input name="password" type="password" required>
-            </label>
-
-            <label>Course Title
-                <input name="title" type="text" required>
-            </label>
-
-            <label>ThumbNail (max 1mb)
-                <input name="thumbNail" type="file" required>
-            </label>
-            
-            <label>Description
-                <textarea name="description" minlength="25" required></textarea>
-            </label>
-
-            <input type="submit" value="Submit">
-        </form>
-    </body>
-</html>

+ 0 - 162
views/learn/newLecture.html

@@ -1,162 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-    <head>
-        <meta charset="utf-8">
-        <title>Lee Morgan -create lecture-</title>
-        <link rel="icon" type="img/ico" href="/images/favicon">
-        <style>
-            form{
-                display: flex;
-                flex-direction: column;
-            }
-
-            form > *{
-                margin: 10px 0;
-            }
-
-            input[type=submit]{
-                max-width: 250px;
-            }
-
-            button{
-                max-width: 250px;
-            }
-
-            #exercises, #furtherReading{
-                display: flex;
-                flex-direction: column;
-            }
-
-            #exercises > *{
-                margin: 10px 0;
-            }
-
-            #exercises input{
-                margin-left: 5px;
-            }
-        </style>
-    </head>
-    <body>
-        <h1>Create New Lecture</h1>
-
-        <form
-            id="form"
-            action="/learn/lectures/new"
-            method="post"
-            encType="multipart/form-data"
-        >
-            <label>Uploader ID
-                <input name="uploader" type="text" required>
-            </label>
-
-            <label>Uploader Password
-                <input name="password" type="password" required>
-            </label>
-
-            <label>Course
-                <select id="course" name="course" required></select>
-            </label>
-
-            <label>Title
-                <input name="title" type="text" required>
-            </label>
-
-            <label>Video Link
-                <input name="video" type="text" required>
-            </label>
-
-            <label>Description
-                <textarea name="description" required></textarea>
-            </label>
-            
-            <label>Documents
-                <input name="documents" type="file" multiple>
-            </label>
-
-            <h2>Exercises</h2>
-            <button id="exerciseButton" type="button">Add Exercise</button>
-            <div id="exercises"></div>
-
-            <h2>Further Reading</h2>
-            <button id="furtherButton" type="button">Add Link</button>
-            <div id="furtherReading"></div>
-
-            <input id="hidden" name="exercises" type="hidden">
-            <input id="readingsHidden" name="furtherReading" type="hidden">
-            <input id="date" name="date" type="hidden">
-
-            <input type="submit" value="Submit">
-        </form>
-
-        <script>
-            //Get Available Courses
-            fetch("/learn/courses/json")
-                .then(response => response.json())
-                .then((response)=>{
-                    let select = document.getElementById("course");
-
-                    for(let i = 0; i < response.length; i++){
-                        let option = document.createElement("option");
-                        option.innerText = response[i].title;
-                        option.value = response[i]._id;
-                        select.appendChild(option);
-                    }
-                })
-                .catch((err)=>{});
-
-            //Add exercises
-            let count = 0;
-            let div = document.getElementById("exercises");
-
-            document.getElementById("exerciseButton").onclick = ()=>{
-                count++;
-                let label = document.createElement("label");
-                label.innerText = `Exercise ${count}`;
-                div.appendChild(label);
-
-                let input = document.createElement("textarea");
-                label.appendChild(input);
-            }
-
-            //Add further reading
-            let furtherCount = 0;
-            let furtherDiv = document.getElementById("furtherReading");
-
-            document.getElementById("furtherButton").onclick = ()=>{
-                furtherCount++;
-                let label = document.createElement("label");
-                label.innerText = `Link ${furtherCount}`;
-                furtherDiv.appendChild(label);
-
-                let inputText = document.createElement("input");
-                inputText.type = "text";
-                label.appendChild(inputText);
-
-                let inputLink = document.createElement("input");
-                inputLink.type = "text";
-                label.appendChild(inputLink);
-            }
-
-            //Submit
-            let form = document.getElementById("form");
-            form.onsubmit = ()=>{
-                event.preventDefault();
-                let exercises = "";
-                for(let i = 0; i < div.children.length; i++){
-                    exercises += `${div.children[i].children[0].value}\n`;
-                }
-
-                let readings = ""
-                for(let i = 0; i < furtherDiv.children.length; i++){
-                    readings += `${furtherDiv.children[i].children[0].value}\n${furtherDiv.children[i].children[1].value}\n`;
-                }
-
-                document.getElementById("hidden").value = exercises;
-                document.getElementById("readingsHidden").value = readings;
-                document.getElementById("date").value = new Date();
-                
-                form.submit();
-            }
-        </script>
-    </body>
-</html>

+ 0 - 9
views/main/index.html

@@ -48,15 +48,6 @@
                 <p>Gallery</p>
             </button>
 
-            <button id="learnButton">
-                <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                    <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path>
-                    <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path>
-                </svg>
-
-                <p>Learn</p>
-            </button>
-
             <button id="currencyButton">
                 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                     <line x1="12" y1="1" x2="12" y2="23"></line>