Add download page
This commit is contained in:
parent
865c751c91
commit
607ae5cd62
|
@ -1,2 +1,3 @@
|
||||||
node_modules
|
node_modules
|
||||||
.env
|
.env
|
||||||
|
out
|
|
@ -5,9 +5,12 @@ setTimeout(() => {
|
||||||
server = require("./lib/express");
|
server = require("./lib/express");
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
setTimeout(() => {
|
let mode = process.env.MODE || "client";
|
||||||
require("./lib/electron");
|
if (mode == "client") {
|
||||||
}, 1000);
|
setTimeout(() => {
|
||||||
|
require("./lib/electron");
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== "production") {
|
if (process.env.NODE_ENV !== "production") {
|
||||||
const chokidar = require("chokidar");
|
const chokidar = require("chokidar");
|
||||||
|
|
|
@ -20,7 +20,7 @@ const debug = require("debug")("express");
|
||||||
const fileUpload = require("express-fileupload");
|
const fileUpload = require("express-fileupload");
|
||||||
|
|
||||||
let ssbServer;
|
let ssbServer;
|
||||||
let mode = process.env.MODE || "server";
|
let mode = process.env.MODE || "client";
|
||||||
|
|
||||||
let homeFolder =
|
let homeFolder =
|
||||||
process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
|
process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
|
||||||
|
@ -60,27 +60,20 @@ app.use(async (req, res, next) => {
|
||||||
req.context = {};
|
req.context = {};
|
||||||
res.locals.context = req.context;
|
res.locals.context = req.context;
|
||||||
try {
|
try {
|
||||||
if (mode == "client") {
|
const identities = await ssbServer.identities.list();
|
||||||
const whoami = await server.whoami();
|
const key = req.cookies["ssb_key"];
|
||||||
req.context.profile = await queries.getProfile(server, whoami.id);
|
if (!key) return next();
|
||||||
|
|
||||||
next();
|
const parsedKey = JSON.parse(key);
|
||||||
} else {
|
if (!identities.includes(parsedKey.id)) {
|
||||||
const identities = await ssbServer.identities.list();
|
const filename = await nextIdentityFilename(ssbServer);
|
||||||
const key = req.cookies["ssb_key"];
|
|
||||||
if (!key) return next();
|
|
||||||
|
|
||||||
const parsedKey = JSON.parse(key);
|
writeKey(key, `/identities/${filename}`);
|
||||||
if (!identities.includes(parsedKey.id)) {
|
ssbServer.identities.refresh();
|
||||||
const filename = await nextIdentityFilename(ssbServer);
|
|
||||||
|
|
||||||
writeKey(key, `/identities/${filename}`);
|
|
||||||
ssbServer.identities.refresh();
|
|
||||||
}
|
|
||||||
req.context.profile = await queries.getProfile(ssbServer, parsedKey.id);
|
|
||||||
|
|
||||||
next();
|
|
||||||
}
|
}
|
||||||
|
req.context.profile = await queries.getProfile(ssbServer, parsedKey.id);
|
||||||
|
|
||||||
|
next();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
next(e);
|
next(e);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +118,7 @@ router.get("/", async (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/login", (_req, res) => {
|
router.get("/login", (_req, res) => {
|
||||||
res.render("login");
|
res.render("login", { mode });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post("/login", async (req, res) => {
|
router.post("/login", async (req, res) => {
|
||||||
|
@ -148,6 +141,10 @@ router.post("/login", async (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.get("/download", (_req, res) => {
|
||||||
|
res.render("download");
|
||||||
|
});
|
||||||
|
|
||||||
router.get("/logout", async (_req, res) => {
|
router.get("/logout", async (_req, res) => {
|
||||||
res.clearCookie("ssb_key");
|
res.clearCookie("ssb_key");
|
||||||
res.redirect("/");
|
res.redirect("/");
|
||||||
|
@ -158,7 +155,7 @@ router.get("/signup", (req, res) => {
|
||||||
return res.redirect("/");
|
return res.redirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render("signup");
|
res.render("signup", { mode });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post("/signup", async (req, res) => {
|
router.post("/signup", async (req, res) => {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,11 +4,13 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "SSB_PORT=8009 EXPRESS_PORT=3000 electron .",
|
"start": "MODE=server SSB_PORT=8009 electron .",
|
||||||
|
"start:client": "electron .",
|
||||||
"start:user-2": "SSB_PORT=8010 EXPRESS_PORT=3001 CONFIG_FOLDER=social-user2 electron .",
|
"start:user-2": "SSB_PORT=8010 EXPRESS_PORT=3001 CONFIG_FOLDER=social-user2 electron .",
|
||||||
"start:user-3": "SSB_PORT=8011 EXPRESS_PORT=3002 CONFIG_FOLDER=social-user3 electron .",
|
"start:user-3": "SSB_PORT=8011 EXPRESS_PORT=3002 CONFIG_FOLDER=social-user3 electron .",
|
||||||
"clear": "rm -rf ~/.social; rm -rf ~/.social-user2; rm -rf ~/.social-user3",
|
"clear": "rm -rf ~/.social; rm -rf ~/.social-user2; rm -rf ~/.social-user3",
|
||||||
"start:prod": "NODE_ENV=production electron ."
|
"start:prod": "NODE_ENV=production electron .",
|
||||||
|
"package": "electron-packager . --platform=darwin --arch=x64 --out out/ --overwrite"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
@ -17,6 +19,7 @@
|
||||||
"cookie-parser": "^1.4.5",
|
"cookie-parser": "^1.4.5",
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"ejs": "^3.0.2",
|
"ejs": "^3.0.2",
|
||||||
|
"electron-packager": "^14.2.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-fileupload": "^1.1.7-alpha.3",
|
"express-fileupload": "^1.1.7-alpha.3",
|
||||||
"pull-stream": "^3.6.14",
|
"pull-stream": "^3.6.14",
|
||||||
|
@ -41,4 +44,4 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^8.2.0"
|
"electron": "^8.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,9 @@ body {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
button,
|
button,
|
||||||
a.button,
|
a.button,
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<%- include('_header') %>
|
||||||
|
|
||||||
|
<div style="max-width: 800px; margin: 0 auto">
|
||||||
|
<h1 style="padding-top: 50px">Download the app</h1>
|
||||||
|
|
||||||
|
<p style="padding: 20px 0">
|
||||||
|
If you don't trust this server to hold your credentials, download the app version,
|
||||||
|
it keeps all the data local, which means your credentials never leave your computer,
|
||||||
|
plus you can use Social offline
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a class="button" href="https://github.com/rogeriochaves/social/releases" style="padding: 12px 15px;">Go to downloads page</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%- include('_footer') %>
|
|
@ -14,7 +14,15 @@
|
||||||
Or paste it here: <br />
|
Or paste it here: <br />
|
||||||
<textarea name="ssb_key" style="max-width: 300px"></textarea>
|
<textarea name="ssb_key" style="max-width: 300px"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<input class="button-big" type="submit" value="Login" />
|
<p>
|
||||||
|
<input class="button-big" type="submit" value="Login" />
|
||||||
|
</p>
|
||||||
|
<% if (mode == "server") { %>
|
||||||
|
<p>or</p>
|
||||||
|
<p>
|
||||||
|
<a href="/download">I don't trust this server</a>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,15 @@
|
||||||
<input type="text" name="name" />
|
<input type="text" name="name" />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<input class="button-big" type="submit" value="Sign up" />
|
<p>
|
||||||
|
<input class="button-big" type="submit" value="Sign up" />
|
||||||
|
</p>
|
||||||
|
<% if (mode == "server") { %>
|
||||||
|
<p>or</p>
|
||||||
|
<p>
|
||||||
|
<a href="/download">I don't trust this server</a>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue