Skip to content

Commit

Permalink
Make everything even more minimallistic
Browse files Browse the repository at this point in the history
  • Loading branch information
szwacz committed Apr 9, 2021
1 parent c639492 commit 0a2e18c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# electron-boilerplate

A minimalistic boilerplate for [Electron runtime](https://www.electronjs.org/). Tested on Windows, macOS and Linux.
Minimalistic, very easy to understand boilerplate for [Electron runtime](https://www.electronjs.org/). Tested on Windows, macOS and Linux.

This project contains only bare minimum of tooling and dependencies to provide you with simple to understand and extensible base (but still, this is fully functional Electron environment). The boilerplate doesn't impose on you any frontend technologies, so feel free to pick your favourite.

Expand Down
45 changes: 21 additions & 24 deletions app/app.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Electron Boilerplate</title>
</head>
<body>
<head>
<meta charset="utf-8" />
<title>Electron Boilerplate</title>
</head>
<body>
<div id="app" class="container" style="display: none;">
<h1 id="greet"></h1>
<p>
Welcome to
<a href="https://www.electronjs.org/" class="electron-website-link">
Electron
</a>
app running on this <strong id="os"></strong> machine.
</p>
<p>App author: <strong id="author"></strong></p>
<p>Environment: <strong id="env"></strong></p>
<p>Electron version: <strong id="electron-version"></strong></p>
</div>

<div id="app" class="container" style="display: none;">
<h1 id="greet"></h1>
<p>
Welcome to <a href="https://www.electronjs.org/" class="js-external-link">Electron</a> app running on this <strong id="os"></strong> machine.
</p>
<p>
App author: <strong id="author"></strong>
</p>
<p>
Environment: <strong id="env"></strong>
</p>
<p>
Electron version: <strong id="electron-version"></strong>
</p>
</div>

<script src="app.js"></script>
</body>
<script src="app.js"></script>
</body>
</html>
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"release": "npm test && webpack --config=build/webpack.app.config.js --env=production && electron-builder"
},
"dependencies": {
"electron-context-menu": "^2.5.0",
"fs-jetpack": "^4.1.0"
},
"devDependencies": {
Expand Down
14 changes: 9 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import "./stylesheets/main.css";

// Small helper you might want to keep
import "./helpers/external_links_renderer.js";

// ----------------------------------------------------------------------------
// Everything below is just a demo. You can delete all of it.
// ----------------------------------------------------------------------------

import { ipcRenderer } from "electron";
import jetpack from "fs-jetpack";
Expand Down Expand Up @@ -34,3 +29,12 @@ ipcRenderer.on("app-path", (event, appDirPath) => {
document.querySelector("#author").innerHTML = manifest.author;
});
ipcRenderer.send("need-app-path");

document.querySelector(".electron-website-link").addEventListener(
"click",
event => {
ipcRenderer.send("open-external-link", event.target.href);
event.preventDefault();
},
false
);
7 changes: 0 additions & 7 deletions src/helpers/external_links.js

This file was deleted.

40 changes: 0 additions & 40 deletions src/helpers/external_links_renderer.js

This file was deleted.

10 changes: 4 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

import path from "path";
import url from "url";
import contextMenu from "electron-context-menu";
import { app, Menu, ipcMain } from "electron";
import { app, Menu, ipcMain, shell } from "electron";
import appMenuTemplate from "./menu/app_menu_template";
import editMenuTemplate from "./menu/edit_menu_template";
import devMenuTemplate from "./menu/dev_menu_template";
import externalLinks from "./helpers/external_links";
import createWindow from "./helpers/window";

// Special module holding environment variables which you declared
Expand Down Expand Up @@ -38,11 +36,11 @@ const initIpc = () => {
ipcMain.on("need-app-path", (event, arg) => {
event.reply("app-path", app.getAppPath());
});
ipcMain.on("open-external-link", (event, href) => {
shell.openExternal(href);
});
};

contextMenu();
externalLinks();

app.on("ready", () => {
setApplicationMenu();
initIpc();
Expand Down

0 comments on commit 0a2e18c

Please sign in to comment.