Add eggs, as well as example egg and config
This commit is contained in:
		| @@ -34,6 +34,10 @@ object config { | ||||
|     var serviceName = "" | ||||
|  | ||||
|     fun getConfig() { | ||||
|         address = "" | ||||
|         port = "" | ||||
|         security = "" | ||||
|         serviceName = "" | ||||
|         val configFile = File("chookchat.config") | ||||
|         try { | ||||
|             val config = configFile.readLines() | ||||
| @@ -395,10 +399,21 @@ fun buildHTML(): String { | ||||
|                 editedhtml += """                    <input type="checkbox" id="securityStatus">""" | ||||
|             } else if (line == """                    <h3>Chookchat</h3>""") { | ||||
|                 editedhtml += """                    <h3>${config.serviceName}</h3>"""  | ||||
|             } else if (line == """                    <!-- Eggs Start Here -->""") { | ||||
|                 val eggsFile = File("chookchat.eggs.config") | ||||
|                 val eggs = eggsFile.readLines() | ||||
|                 for (line in eggs) { | ||||
|                     val eggHTMLFile = File("eggs/$line/index.html") | ||||
|                     if (eggHTMLFile.exists()) { | ||||
|                         val eggHTML = eggHTMLFile.readText() | ||||
|                         editedhtml += eggHTML | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|                 editedhtml += line | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         return(editedhtml) | ||||
|     } catch (e: Exception) { | ||||
|         println(e) | ||||
| @@ -407,6 +422,42 @@ fun buildHTML(): String { | ||||
|     return("dingus") | ||||
| } | ||||
|  | ||||
| fun buildJS(): String { | ||||
|     try { | ||||
|         val eggsFile = File("chookchat.eggs.config") | ||||
|         val eggs = eggsFile.readLines() | ||||
|         val jsFile = File("resources/index.js") | ||||
|         val js = jsFile.readLines() | ||||
|         var editedJS = "" | ||||
|         for (line in js) { | ||||
|             if (line == "            // Egg message logic") { | ||||
|                 for (line in eggs) { | ||||
|                     val eggJSMessageFile = File("eggs/$line/message.js") | ||||
|                     if (eggJSMessageFile.exists()) { | ||||
|                         val eggJSMessage = eggJSMessageFile.readText() | ||||
|                         editedJS += eggJSMessage | ||||
|                     } | ||||
|                 } | ||||
|             } else { | ||||
|                 editedJS += "$line\n" | ||||
|             } | ||||
|         } | ||||
|         //editedJS += js | ||||
|         for (line in eggs) { | ||||
|             val eggJSFile = File("eggs/$line/index.js") | ||||
|             if (eggJSFile.exists()) { | ||||
|                 val eggJS = eggJSFile.readText() | ||||
|                 editedJS += eggJS | ||||
|             } | ||||
|         } | ||||
|         return(editedJS) | ||||
|     } catch (e: Exception) { | ||||
|         println(e) | ||||
|         return("console.log(`There was an error! If you're the server's admin, here are the details: $e`)") | ||||
|     } | ||||
|     return("dingus") | ||||
| } | ||||
|  | ||||
| fun main(args: Array<String>) { | ||||
|     WsSessionManager.peopleOnline.removeAt(0) | ||||
|     WsSessionManager.sessionsList.removeAt(0) | ||||
| @@ -416,6 +467,9 @@ fun main(args: Array<String>) { | ||||
|             ctx.html(buildHTML()) | ||||
|             //ctx.redirect("/index.html")  | ||||
|         } | ||||
|         .get("/index.js") { ctx -> | ||||
|             ctx.result(buildJS()) | ||||
|         } | ||||
|         .get("/api/createaccount/{content}") { ctx -> ctx.result(createAccount(ctx.pathParam("content")))} | ||||
|         .post("/api/upload") { ctx -> | ||||
|             val uploadedFiles = ctx.uploadedFiles() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Maxwell Jeffress
					Maxwell Jeffress