Skip to content

Commit e106def

Browse files
Hugh Isaacs IIHugh Isaacs II
authored andcommitted
Another one
1 parent 2526f2e commit e106def

3 files changed

Lines changed: 33 additions & 25 deletions

File tree

electron app/resources/datpart/launch.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var dev = false;
1+
var dev = true;
22

33
if (typeof process === 'object') {
44
if (typeof process.versions === 'object') {
@@ -7,6 +7,7 @@ if (typeof process === 'object') {
77
const {app, BrowserWindow, Menu, Tray} = require('electron')
88
const path = require('path')
99
const url = require('url')
10+
const fs = require('fs');
1011

1112
// Keep a global reference of the window object, if you don't, the window will
1213
// be closed automatically when the JavaScript object is garbage collected.
@@ -16,6 +17,11 @@ let tray = null
1617
var versionNumber = app.getVersion();
1718
var appName = app.getName();
1819
var appIcon = __dirname+'/logo_128.png';
20+
var appPath = app.getAppPath();
21+
22+
if (fs.existsSync(appPath + "/dats/")) {
23+
fs.mkdir(appPath + "/dats/");
24+
}
1925

2026
app.on('ready', () => {
2127
tray = new Tray(appIcon)

electron app/resources/datpart/package.json

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"productName": "DatPart",
44
"description": "Load Dat's in your web browser.",
55
"homepage": "https://github.com/HughIsaacs2/DatPart",
6-
"repository": { "type" : "git", "url" : "https://github.com/HughIsaacs2/DatPart.git" },
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/HughIsaacs2/DatPart.git"
9+
},
710
"version": "0.0.5",
811
"author": "Hugh Isaacs II <hughisaacs@acrylicstyle.com>",
912
"license": "MIT",
@@ -13,16 +16,20 @@
1316
"dat-node": "^3.5.4",
1417
"node-dat-archive": "^1.5.0"
1518
},
16-
"build":{
17-
"appId": "com.electron.${name}",
18-
"win": {
19-
"target": [{
20-
"target": "zip",
21-
"arch": [
22-
"ia32"
23-
]
24-
}],
25-
"icon": "favicon.ico"
26-
}
19+
"build": {
20+
"win": {
21+
"target": [
22+
{
23+
"target": "zip",
24+
"arch": [
25+
"ia32"
26+
]
27+
}
28+
],
29+
"icon": "favicon.ico"
30+
}
31+
},
32+
"devDependencies": {
33+
"electron": "1.7.9"
2734
}
2835
}

electron app/resources/datpart/server_script.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"use strict";
22

3+
// content of index.js
4+
const {shell} = require('electron');
5+
const http = require('http');
6+
var dat = require('dat-node');
7+
38
var host = "127.0.0.1";
49
var port = "9989";
510

@@ -8,19 +13,11 @@
813

914
var rootDir = null;
1015
var packDir = null;
11-
12-
if (typeof process === 'object') {
13-
if (typeof process.versions === 'object') {
14-
if (typeof process.versions['electron'] !== 'undefined') {
15-
16-
// content of index.js
17-
const {shell} = require('electron');
18-
const http = require('http');
19-
var dat = require('dat-node');
2016

2117
//var versionNumber = app.getVersion();
2218
//var appName = app.getName();
2319
//var appIcon = __dirname+'/logo_128.png';
20+
//app.getAppPath()
2421

2522
document.querySelectorAll("a.external-link").forEach(function (el) {
2623
el.onclick = function(){shell.openExternal(el.href);return false;};
@@ -47,7 +44,7 @@ const requestHandler = (request, response) => {
4744
}
4845
*/
4946

50-
dat( __dirname + '/dats/'+currentURLhostNoTLD, {
47+
dat( __dirname + '/../../dats/'+currentURLhostNoTLD, {
5148
// 2. Tell Dat what link I want
5249
key: currentURLhostNoTLD, temp: false, sparse: true // (a 64 character hash from above)
5350
}, function (err, dat) {
@@ -95,5 +92,3 @@ server.listen(port, (err) => {
9592

9693
console.log(`server is listening on ${port}`);
9794
});
98-
99-
}}}

0 commit comments

Comments
 (0)