From 9749546af55dd39b5f4ce082bd4ac37bd6f3d882 Mon Sep 17 00:00:00 2001
From: Sting <loic.allegre@ensiie.fr>
Date: Tue, 22 Sep 2020 22:28:17 +0200
Subject: [PATCH] MISC: Moved app entrypoint to toplevel dir, and made some
 renaming

---
 instance/index.html |  2 +-
 instance/index.js   |  9 -------
 instance/main.js    | 60 ++++++---------------------------------------
 main.js             | 55 +++++++++++++++++++++++++++++++++++++++++
 package.json        |  2 +-
 5 files changed, 64 insertions(+), 64 deletions(-)
 delete mode 100644 instance/index.js
 create mode 100644 main.js

diff --git a/instance/index.html b/instance/index.html
index 89eda1f..216db04 100644
--- a/instance/index.html
+++ b/instance/index.html
@@ -7,7 +7,7 @@
         <link rel="stylesheet" href="../style/bootstrap-4.5.2-dist/css/bootstrap.min.css">
         <script src="../style/jquery/jquery-3.5.1.js"></script>
         <script src="../style/bootstrap-4.5.2-dist/js/bootstrap.min.js"></script>
-        <script src="./index.js"></script>
+        <script src="./main.js"></script>
     </head>
     <body>
         <div class="card">
diff --git a/instance/index.js b/instance/index.js
deleted file mode 100644
index eb0e3e1..0000000
--- a/instance/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-const {ipcRenderer} = require('electron');
-
-
-window.onload = function(){
-    const closeApp = document.getElementById("closeButton");
-    closeApp.addEventListener('click', () => {
-        ipcRenderer.send('close-app')
-    });
-}
\ No newline at end of file
diff --git a/instance/main.js b/instance/main.js
index 36f9258..eb0e3e1 100644
--- a/instance/main.js
+++ b/instance/main.js
@@ -1,55 +1,9 @@
-const electron = require('electron')
-const { app, BrowserWindow } = require('electron')
-const {ipcMain} = require('electron')
+const {ipcRenderer} = require('electron');
 
 
-/** Creates the main window and process for the admin interface
- * 
- */
-function createInstanceWindow () {
-  // Create the browser window.
-  const win = new BrowserWindow({
-    width: 800,
-    height: 600,
-    frame: false,
-    webPreferences: {
-      nodeIntegration: true
-    }
-  })
-
-  // and load the index.html of the app.
-  win.loadFile('instance/index.html');
-  
-}
-
-/** Creates the main process for the Express app
- *  which runs the local server and handles public
- *  clients
- */
-function createExpressClient (){ 
-  const win = new BrowserWindow({ 
-    show: false,
-    webPreferences: {
-      nodeIntegration: true
-    }
-  });
-
-  win.loadFile('client/index.html');
-
-  // Useful for debugging, use with "show: true"
-  //win.webContents.openDevTools();
-}
-
-
-
-
-ipcMain.on('close-app', (evt, arg) => {
-  app.quit()
-})
-
-
-app.on('ready', () => {
-  console.log('Ready');
-  createInstanceWindow();
-  createExpressClient();
-});
+window.onload = function(){
+    const closeApp = document.getElementById("closeButton");
+    closeApp.addEventListener('click', () => {
+        ipcRenderer.send('close-app')
+    });
+}
\ No newline at end of file
diff --git a/main.js b/main.js
new file mode 100644
index 0000000..e62b5dd
--- /dev/null
+++ b/main.js
@@ -0,0 +1,55 @@
+const electron = require('electron')
+const { app, BrowserWindow } = require('electron')
+const {ipcMain} = require('electron')
+
+
+/** Creates the main window and process for the admin interface
+ * 
+ */
+function createInstanceWindow () {
+  // Create the browser window.
+  const win = new BrowserWindow({
+    width: 800,
+    height: 600,
+    frame: false,
+    webPreferences: {
+      nodeIntegration: true
+    }
+  })
+
+  // and load the index.html of the app.
+  win.loadFile('instance/index.html');
+
+}
+
+/** Creates the main process for the Express app
+ *  which runs the local server and handles public
+ *  clients
+ */
+function createExpressClient (){ 
+  const win = new BrowserWindow({ 
+    show: false,
+    webPreferences: {
+      nodeIntegration: true
+    }
+  });
+
+  win.loadFile('client/index.html');
+
+  // Useful for debugging, use with "show: true"
+  //win.webContents.openDevTools();
+}
+
+
+
+
+ipcMain.on('close-app', (evt, arg) => {
+  app.quit()
+})
+
+
+app.on('ready', () => {
+  console.log('Ready');
+  createInstanceWindow();
+  createExpressClient();
+});
diff --git a/package.json b/package.json
index 1c878c2..cc174ac 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "lektor-app",
   "version": "0.1.0",
-  "main": "instance/main.js",
+  "main": "main.js",
   "description": "A lektord manipulation tool, an 'instance'",
   "repository": "git@git.iiens.net:bakaclub/lektor-app.git",
   "author": "Kubat <mael.martin31@gmail.com>",
-- 
GitLab