Skip to content

Commit

Permalink
Fixed EJS view rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtrendence committed Sep 25, 2020
1 parent 2925f3e commit 0dc9496
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const appPort = 1998;
const scriptPath = process.cwd() + "\\server.js";

const electron = require("electron");
const { app, BrowserWindow, screen, ipcMain, dialog, shell, Menu, globalShortcut } = electron;

const express = require("express");
const localExpress = express();
Expand All @@ -19,7 +20,7 @@ const glob = require("glob");
const metadata = require("music-metadata");
const body_parser = require("body-parser");

const dataDirectory = path.join(__dirname, "./data/");
const dataDirectory = path.join(app.getPath("userData"), "X-Music/");
const settingsFile = dataDirectory + "settings.json";
const playlistsFile = dataDirectory + "playlists.json";

Expand All @@ -40,8 +41,6 @@ if(!fs.existsSync(playlistsFile)) {
fs.writeFileSync(playlistsFile, "");
}

const { app, BrowserWindow, screen, ipcMain, dialog, shell, Menu, globalShortcut } = electron;

app.requestSingleInstanceLock();
app.name = "X:/Music";

Expand Down Expand Up @@ -79,8 +78,6 @@ app.on("ready", function() {
}
});

localWindow.loadURL("http://127.0.0.1:" + localPort);

if(process.platform === "darwin") {
globalShortcut.register("Command+Q", () => {
app.quit();
Expand All @@ -91,10 +88,13 @@ app.on("ready", function() {
});
}

localExpress.set("views", path.join(__dirname, "views"));
localExpress.set("view engine", "ejs");
localExpress.use("/assets", express.static("assets"));
localExpress.use("/assets", express.static(path.join(__dirname, "assets")));
localExpress.use(body_parser.urlencoded({ extended:true }));
localExpress.use(body_parser.json({ limit:"512mb" }));

localWindow.loadURL("http://127.0.0.1:" + localPort);

localExpress.get("/", (req, res) => {
res.render("index");
Expand Down Expand Up @@ -451,8 +451,9 @@ app.on("ready", function() {
(process.platform === "darwin") ? app.hide() : app.quit();
});

appExpress.set("views", path.join(__dirname, "views"));
appExpress.set("view engine", "ejs");
appExpress.use("/assets", express.static("assets"));
appExpress.use("/assets", express.static(path.join(__dirname, "assets")));
appExpress.use(body_parser.urlencoded({ extended:true }));
appExpress.use(body_parser.json({ limit:"1mb" }));

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"build": {
"appId": "com.xtrendence.x-music",
"asar": true,
"dmg": {
"contents": [
{
Expand Down

0 comments on commit 0dc9496

Please sign in to comment.