forked from mystiq/hydrogen-web
show version before login and link to release
This commit is contained in:
parent
ae01a65b3c
commit
eda4022692
5 changed files with 23 additions and 4 deletions
|
@ -11,6 +11,9 @@
|
|||
<link rel="stylesheet" type="text/css" href="src/ui/web/css/main.css">
|
||||
</head>
|
||||
<body>
|
||||
<script id="version" type="disabled">
|
||||
window.BRAWL_VERSION = "%%VERSION%%";
|
||||
</script>
|
||||
<script id="phone-debug-pre" type="disabled">
|
||||
window.DEBUG = true;
|
||||
window.debugConsoleBuffer = "";
|
||||
|
|
|
@ -24,7 +24,7 @@ async function build() {
|
|||
await removeDirIfExists(targetDir);
|
||||
await fs.mkdir(targetDir);
|
||||
|
||||
await buildHtml();
|
||||
await buildHtml(version);
|
||||
await buildJs();
|
||||
await buildCss();
|
||||
if (offline) {
|
||||
|
@ -34,7 +34,7 @@ async function build() {
|
|||
console.log(`built brawl ${version} successfully`);
|
||||
}
|
||||
|
||||
async function buildHtml() {
|
||||
async function buildHtml(version) {
|
||||
// transform html file
|
||||
const devHtml = await fs.readFile(path.join(projectDir, "index.html"), "utf8");
|
||||
const doc = cheerio.load(devHtml);
|
||||
|
@ -45,6 +45,13 @@ async function buildHtml() {
|
|||
removeOrEnableScript(doc("script#phone-debug-pre"), debug);
|
||||
removeOrEnableScript(doc("script#phone-debug-post"), debug);
|
||||
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) {
|
||||
doc("html").attr("manifest", "manifest.appcache");
|
||||
doc("head").append(`<link rel="manifest" href="manifest.json">`);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import TemplateView from "../general/TemplateView.js";
|
||||
import {brawlGithubLink} from "./common.js";
|
||||
|
||||
export default class LoginView extends TemplateView {
|
||||
constructor(vm) {
|
||||
|
@ -20,7 +21,7 @@ export default class LoginView extends TemplateView {
|
|||
disabled: vm => vm.loading
|
||||
}, "Log In")),
|
||||
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))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import ListView from "../general/ListView.js";
|
||||
import TemplateView from "../general/TemplateView.js";
|
||||
import {brawlGithubLink} from "./common.js";
|
||||
|
||||
function selectFileAsText(mimeType) {
|
||||
const input = document.createElement("input");
|
||||
|
@ -91,7 +92,7 @@ export default class SessionPickerView extends TemplateView {
|
|||
this._sessionList.mount(),
|
||||
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.a({href: "https://github.com/bwindels/brawl-chat"}, ["Brawl on Github"]))
|
||||
t.p(brawlGithubLink(t))
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
7
src/ui/web/login/common.js
Normal file
7
src/ui/web/login/common.js
Normal 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");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue