Skip to content
This repository has been archived by the owner on Sep 22, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkawamoto committed Mar 10, 2019
2 parents 69143bf + 5c89de3 commit 1d79a80
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.1
current_version = 0.3.0
commit = True
tag = False

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# file-share-desktop
# Goobox file share desktop
[![Build Status](https://travis-ci.org/GooBox/file-share-desktop.svg?branch=master)](https://travis-ci.org/GooBox/file-share-desktop)

[![Code style](https://img.shields.io/badge/code%20style-airbnb-brightgreen.svg)](https://github.com/airbnb/javascript)
[![Release](https://img.shields.io/badge/release-0.2.1-brightgreen.svg)](https://github.com/GooBox/file-share-desktop/releases/tag/v0.2.1)
[![Release](https://img.shields.io/badge/release-0.3.0-brightgreen.svg)](https://github.com/GooBox/file-share-desktop/releases/tag/v0.3.0)
[![GPLv3](https://img.shields.io/badge/license-GPLv3-blue.svg)](https://www.gnu.org/copyleft/gpl.html)

Goobox file share desktop allows users to share files using a installed electron desktop application, which is especially handy in case of browser incompatibility.
Goobox file share desktop allows users to share files using an installed electron desktop application, which is especially handy in case of browser incompatibility.
8 changes: 4 additions & 4 deletions ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ brew install pixeldrain
pd -v


WIN_ID=$(basename $(pd upload dist/GooboxFileShare-0.2.1-setup_x64.exe))
WIN_ID=$(basename $(pd upload dist/GooboxFileShare-0.3.0-setup_x64.exe))
echo "Dev build for Windows has been uploaded at ${WIN_ID}"

MAC_ID=$(basename $(pd upload dist/GooboxFileShare-0.2.1.dmg))
MAC_ID=$(basename $(pd upload dist/GooboxFileShare-0.3.0.dmg))
echo "Dev build for MacOS has been uploaded at ${MAC_ID}"

LINUX_ID=$(basename $(pd upload dist/GooboxFileShare-0.2.1.AppImage))
LINUX_ID=$(basename $(pd upload dist/GooboxFileShare-0.3.0.AppImage))
echo "Dev build for Linux has been uploaded at ${LINUX_ID}"

LIST_URL=$(pd create-list -t "GooboxFileShare-0.2.1" ${WIN_ID}:GooboxFileShare-0.2.1-setup_x64.exe ${MAC_ID}:GooboxFileShare-0.2.1.dmg ${LINUX_ID}:GooboxFileShare-0.2.1.AppImage)
LIST_URL=$(pd create-list -t "GooboxFileShare-0.3.0" ${WIN_ID}:GooboxFileShare-0.3.0-setup_x64.exe ${MAC_ID}:GooboxFileShare-0.3.0.dmg ${LINUX_ID}:GooboxFileShare-0.3.0.AppImage)
echo "Download page for the dev builds are set up at ${LIST_URL}"

curl -XPOST -H 'Content-Type:application/json' $DISCORD_WEBHOOK -d @- <<EOF
Expand Down
1 change: 0 additions & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ files:
- "!src"
- "src/assets/goobox.ico"
mac:
target: "dmg"
category: "public.app-category.productivity"
icon: "src/assets/goobox.icns"
type: "development"
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "GooboxFileShare",
"version": "0.2.1",
"version": "0.3.0",
"description": "Goobox File Share App",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -55,7 +55,6 @@
"husky": "^1.3.1",
"lint-staged": "^8.1.5",
"npm-run-all": "^4.1.5",
"opn": "^5.4.0",
"prettier": "^1.16.4",
"svg-url-loader": "^2.3.2",
"updates": "^7.2.1",
Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export const BaseURL = "https://goobox.io/";
export const AppURL = `${BaseURL}?standalone=true`;
export const DefaultWidth = 800;
export const DefaultHeight = 600;

export const DebugModeKey = "goobox.debug";
71 changes: 64 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,45 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import {app, BrowserWindow} from "electron";
import * as opn from "opn";
import {app, BrowserWindow, shell} from "electron";
import * as log from "electron-log";
import {
AppName,
AppURL,
BaseURL,
DebugModeKey,
DefaultHeight,
DefaultWidth,
} from "./constants";
import {createMenu} from "./menu";
import {updateMenu} from "./menu";
import {getItem, setItem} from "./storage";
import {checkForUpdatesAndNotify} from "./updater";

const logLevel = {
"-1": "debug",
"0": "info",
"1": "warn",
"2": "error",
};

const strToBool = str => str && str.toLowerCase() === "true";

const onShowLog = () => {
if (!shell.openItem(log.transports.file.file)) {
log.warn("failed to open the log file");
}
};

const onOpenDownload = () => {
if (!shell.openItem(app.getPath("downloads"))) {
log.warn("failed to open downloads folder");
}
};

if (!app.requestSingleInstanceLock()) {
app.quit();
}

app.on("ready", async () => {
let width = DefaultWidth;
if (process.env.DEV_TOOLS) {
Expand All @@ -41,25 +68,55 @@ app.on("ready", async () => {
resizable: true,
fullscreenable: true,
title: AppName,
backgroundColor: "#313131",
webPreferences: {
nodeIntegration: false,
},
});
mainWindow.loadURL(AppURL);
app.on("second-instance", () => {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.focus();
});
app.on("window-all-closed", () => app.quit());

mainWindow.loadURL(AppURL);
if (process.env.DEV_TOOLS) {
mainWindow.toggleDevTools();
}

mainWindow.webContents.on("will-navigate", (e, url) => {
const wc = mainWindow.webContents;
wc.on("will-navigate", (e, url) => {
if (url === BaseURL) {
e.preventDefault();
mainWindow.loadURL(AppURL);
}
});
wc.on("console-message", (e, level, msg) => {
e.preventDefault();
msg = msg.replace(/%c/g, "");
msg = msg.replace(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\s*/, "");
log[logLevel[level.toString()]](msg);
});

createMenu(() => mainWindow.close(), () => opn(app.getPath("downloads")));
app.on("window-all-closed", () => app.quit());
const onToggleDebugMode = async debug => {
await setItem(wc, DebugModeKey, debug);
updateMenu(debug, {
onQuit: () => mainWindow.close(),
onOpenDownload,
onShowLog,
onToggleDebugMode,
});
wc.reload();
};

updateMenu(strToBool(await getItem(wc, DebugModeKey)), {
onQuit: () => mainWindow.close(),
onOpenDownload,
onShowLog,
onToggleDebugMode,
});

await checkForUpdatesAndNotify();
});
56 changes: 33 additions & 23 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,43 @@ import {Menu} from "electron";
import openAboutWindow from "./about";
import {AppName} from "./constants";

export const createMenu = (onQuit, onOpenDownload) => {
const editMenu = {
label: "Edit",
submenu: [
{label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:"},
{label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:"},
{type: "separator"},
{label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:"},
{label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:"},
{label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:"},
{
label: "Select All",
accelerator: "CmdOrCtrl+A",
selector: "selectAll:",
},
],
};

const debugMenuLabel = debug => {
if (debug) {
return "Disable Debug Mode";
}
return "Enable Debug Mode";
};

export const updateMenu = (
debug,
{onQuit, onOpenDownload, onShowLog, onToggleDebugMode}
) => {
const template = [
{
label: AppName,
submenu: [
{label: "About Goobox", click: openAboutWindow},
{label: "Show Log", click: onShowLog},
{label: debugMenuLabel(debug), click: () => onToggleDebugMode(!debug)},
{type: "separator"},
{
label: "Download",
click: onOpenDownload,
},

{label: "Open Downloads Folder", click: onOpenDownload},
{type: "separator"},
{
label: `Quit ${AppName}`,
Expand All @@ -39,24 +64,9 @@ export const createMenu = (onQuit, onOpenDownload) => {
},
],
},
{
label: "Edit",
submenu: [
{label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:"},
{label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:"},
{type: "separator"},
{label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:"},
{label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:"},
{label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:"},
{
label: "Select All",
accelerator: "CmdOrCtrl+A",
selector: "selectAll:",
},
],
},
editMenu,
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
};

export default createMenu;
export default updateMenu;
22 changes: 22 additions & 0 deletions src/storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2019 Junpei Kawamoto
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export const getItem = async (wc, key) =>
wc.executeJavaScript(`window.localStorage.getItem('${key}');`);

export const setItem = async (wc, key, value) =>
wc.executeJavaScript(`window.localStorage.setItem('${key}', '${value}');`);
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3602,11 +3602,6 @@ is-windows@^1.0.1, is-windows@^1.0.2:
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==

is-wsl@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=

isarray@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
Expand Down Expand Up @@ -4573,13 +4568,6 @@ onetime@^2.0.0:
dependencies:
mimic-fn "^1.0.0"

opn@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/opn/-/opn-5.4.0.tgz#cb545e7aab78562beb11aa3bfabc7042e1761035"
integrity sha512-YF9MNdVy/0qvJvDtunAOzFw9iasOQHpVthTCvGzxt61Il64AYSGdK+rYwld7NAfk9qJ7dt+hymBNSc9LNYS+Sw==
dependencies:
is-wsl "^1.1.0"

optionator@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
Expand Down

0 comments on commit 1d79a80

Please sign in to comment.