Add download page
This commit is contained in:
parent
865c751c91
commit
607ae5cd62
|
@ -1,2 +1,3 @@
|
|||
node_modules
|
||||
.env
|
||||
.env
|
||||
out
|
|
@ -5,9 +5,12 @@ setTimeout(() => {
|
|||
server = require("./lib/express");
|
||||
}, 500);
|
||||
|
||||
setTimeout(() => {
|
||||
require("./lib/electron");
|
||||
}, 1000);
|
||||
let mode = process.env.MODE || "client";
|
||||
if (mode == "client") {
|
||||
setTimeout(() => {
|
||||
require("./lib/electron");
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
const chokidar = require("chokidar");
|
||||
|
|
|
@ -20,7 +20,7 @@ const debug = require("debug")("express");
|
|||
const fileUpload = require("express-fileupload");
|
||||
|
||||
let ssbServer;
|
||||
let mode = process.env.MODE || "server";
|
||||
let mode = process.env.MODE || "client";
|
||||
|
||||
let homeFolder =
|
||||
process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
|
||||
|
@ -60,27 +60,20 @@ app.use(async (req, res, next) => {
|
|||
req.context = {};
|
||||
res.locals.context = req.context;
|
||||
try {
|
||||
if (mode == "client") {
|
||||
const whoami = await server.whoami();
|
||||
req.context.profile = await queries.getProfile(server, whoami.id);
|
||||
const identities = await ssbServer.identities.list();
|
||||
const key = req.cookies["ssb_key"];
|
||||
if (!key) return next();
|
||||
|
||||
next();
|
||||
} else {
|
||||
const identities = await ssbServer.identities.list();
|
||||
const key = req.cookies["ssb_key"];
|
||||
if (!key) return next();
|
||||
const parsedKey = JSON.parse(key);
|
||||
if (!identities.includes(parsedKey.id)) {
|
||||
const filename = await nextIdentityFilename(ssbServer);
|
||||
|
||||
const parsedKey = JSON.parse(key);
|
||||
if (!identities.includes(parsedKey.id)) {
|
||||
const filename = await nextIdentityFilename(ssbServer);
|
||||
|
||||
writeKey(key, `/identities/${filename}`);
|
||||
ssbServer.identities.refresh();
|
||||
}
|
||||
req.context.profile = await queries.getProfile(ssbServer, parsedKey.id);
|
||||
|
||||
next();
|
||||
writeKey(key, `/identities/${filename}`);
|
||||
ssbServer.identities.refresh();
|
||||
}
|
||||
req.context.profile = await queries.getProfile(ssbServer, parsedKey.id);
|
||||
|
||||
next();
|
||||
} catch (e) {
|
||||
next(e);
|
||||
}
|
||||
|
@ -125,7 +118,7 @@ router.get("/", async (req, res) => {
|
|||
});
|
||||
|
||||
router.get("/login", (_req, res) => {
|
||||
res.render("login");
|
||||
res.render("login", { mode });
|
||||
});
|
||||
|
||||
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) => {
|
||||
res.clearCookie("ssb_key");
|
||||
res.redirect("/");
|
||||
|
@ -158,7 +155,7 @@ router.get("/signup", (req, res) => {
|
|||
return res.redirect("/");
|
||||
}
|
||||
|
||||
res.render("signup");
|
||||
res.render("signup", { mode });
|
||||
});
|
||||
|
||||
router.post("/signup", async (req, res) => {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,11 +4,13 @@
|
|||
"description": "",
|
||||
"main": "index.js",
|
||||
"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-3": "SSB_PORT=8011 EXPRESS_PORT=3002 CONFIG_FOLDER=social-user3 electron .",
|
||||
"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": "",
|
||||
"license": "ISC",
|
||||
|
@ -17,6 +19,7 @@
|
|||
"cookie-parser": "^1.4.5",
|
||||
"debug": "^4.1.1",
|
||||
"ejs": "^3.0.2",
|
||||
"electron-packager": "^14.2.1",
|
||||
"express": "^4.17.1",
|
||||
"express-fileupload": "^1.1.7-alpha.3",
|
||||
"pull-stream": "^3.6.14",
|
||||
|
@ -41,4 +44,4 @@
|
|||
"devDependencies": {
|
||||
"electron": "^8.2.0"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@ body {
|
|||
word-wrap: break-word;
|
||||
font-size: 16px;
|
||||
}
|
||||
a {
|
||||
color: #666;
|
||||
}
|
||||
button,
|
||||
a.button,
|
||||
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 />
|
||||
<textarea name="ssb_key" style="max-width: 300px"></textarea>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -21,7 +21,15 @@
|
|||
<input type="text" name="name" />
|
||||
</label>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue