show version before login and link to release

This commit is contained in:
Bruno Windels 2020-03-23 22:46:31 +01:00
parent ae01a65b3c
commit eda4022692
5 changed files with 23 additions and 4 deletions

View file

@ -11,6 +11,9 @@
<link rel="stylesheet" type="text/css" href="src/ui/web/css/main.css"> <link rel="stylesheet" type="text/css" href="src/ui/web/css/main.css">
</head> </head>
<body> <body>
<script id="version" type="disabled">
window.BRAWL_VERSION = "%%VERSION%%";
</script>
<script id="phone-debug-pre" type="disabled"> <script id="phone-debug-pre" type="disabled">
window.DEBUG = true; window.DEBUG = true;
window.debugConsoleBuffer = ""; window.debugConsoleBuffer = "";

View file

@ -24,7 +24,7 @@ async function build() {
await removeDirIfExists(targetDir); await removeDirIfExists(targetDir);
await fs.mkdir(targetDir); await fs.mkdir(targetDir);
await buildHtml(); await buildHtml(version);
await buildJs(); await buildJs();
await buildCss(); await buildCss();
if (offline) { if (offline) {
@ -34,7 +34,7 @@ async function build() {
console.log(`built brawl ${version} successfully`); console.log(`built brawl ${version} successfully`);
} }
async function buildHtml() { async function buildHtml(version) {
// transform html file // transform html file
const devHtml = await fs.readFile(path.join(projectDir, "index.html"), "utf8"); const devHtml = await fs.readFile(path.join(projectDir, "index.html"), "utf8");
const doc = cheerio.load(devHtml); const doc = cheerio.load(devHtml);
@ -45,6 +45,13 @@ async function buildHtml() {
removeOrEnableScript(doc("script#phone-debug-pre"), debug); removeOrEnableScript(doc("script#phone-debug-pre"), debug);
removeOrEnableScript(doc("script#phone-debug-post"), debug); removeOrEnableScript(doc("script#phone-debug-post"), debug);
removeOrEnableScript(doc("script#service-worker"), offline); removeOrEnableScript(doc("script#service-worker"), offline);
const versionScript = doc("script#version");
versionScript.attr("type", "text/javascript");
let vSource = versionScript.contents().text();
vSource = vSource.replace(`"%%VERSION%%"`, `"${version}"`);
versionScript.text(vSource);
if (offline) { if (offline) {
doc("html").attr("manifest", "manifest.appcache"); doc("html").attr("manifest", "manifest.appcache");
doc("head").append(`<link rel="manifest" href="manifest.json">`); doc("head").append(`<link rel="manifest" href="manifest.json">`);

View file

@ -1,4 +1,5 @@
import TemplateView from "../general/TemplateView.js"; import TemplateView from "../general/TemplateView.js";
import {brawlGithubLink} from "./common.js";
export default class LoginView extends TemplateView { export default class LoginView extends TemplateView {
constructor(vm) { constructor(vm) {
@ -20,7 +21,7 @@ export default class LoginView extends TemplateView {
disabled: vm => vm.loading disabled: vm => vm.loading
}, "Log In")), }, "Log In")),
t.div(t.button({onClick: () => vm.cancel()}, ["Pick an existing session"])), t.div(t.button({onClick: () => vm.cancel()}, ["Pick an existing session"])),
t.p(t.a({href: "https://github.com/bwindels/brawl-chat"}, ["Brawl on Github"])) t.p(brawlGithubLink(t))
]); ]);
} }
} }

View file

@ -1,5 +1,6 @@
import ListView from "../general/ListView.js"; import ListView from "../general/ListView.js";
import TemplateView from "../general/TemplateView.js"; import TemplateView from "../general/TemplateView.js";
import {brawlGithubLink} from "./common.js";
function selectFileAsText(mimeType) { function selectFileAsText(mimeType) {
const input = document.createElement("input"); const input = document.createElement("input");
@ -91,7 +92,7 @@ export default class SessionPickerView extends TemplateView {
this._sessionList.mount(), this._sessionList.mount(),
t.p(t.button({onClick: () => this.viewModel.cancel()}, ["Log in to a new session instead"])), t.p(t.button({onClick: () => this.viewModel.cancel()}, ["Log in to a new session instead"])),
t.p(t.button({onClick: async () => this.viewModel.import(await selectFileAsText("application/json"))}, "Import")), t.p(t.button({onClick: async () => this.viewModel.import(await selectFileAsText("application/json"))}, "Import")),
t.p(t.a({href: "https://github.com/bwindels/brawl-chat"}, ["Brawl on Github"])) t.p(brawlGithubLink(t))
]); ]);
} }

View file

@ -0,0 +1,7 @@
export function brawlGithubLink(t) {
if (window.BRAWL_VERSION) {
return t.a({target: "_blank", href: `https://github.com/bwindels/brawl-chat/releases/tag/v${window.BRAWL_VERSION}`}, `Brawl v${window.BRAWL_VERSION} on Github`);
} else {
return t.a({target: "_blank", href: "https://github.com/bwindels/brawl-chat"}, "Brawl on Github");
}
}