From 80e0175d369969a11b5718b8bd6cf418cfae4d21 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 2 Mar 2021 22:46:48 +0100 Subject: [PATCH] Make all resource paths relative Closes: https://todo.sr.ht/~emersion/gamja/17 --- commands.js | 2 +- components/app.js | 34 +++++++++++++++++++--------------- components/buffer-header.js | 8 ++++---- components/buffer-list.js | 6 +++--- components/buffer.js | 10 +++++----- components/composer.js | 2 +- components/connect.js | 2 +- components/member-list.js | 4 ++-- components/scroll-manager.js | 2 +- index.html | 6 +++--- keybindings.js | 2 +- lib/index.js | 8 ++++---- lib/linkify.js | 2 +- state.js | 2 +- 14 files changed, 47 insertions(+), 43 deletions(-) diff --git a/commands.js b/commands.js index 048f185..0a5e2c9 100644 --- a/commands.js +++ b/commands.js @@ -1,4 +1,4 @@ -import { SERVER_BUFFER } from "/state.js"; +import { SERVER_BUFFER } from "./state.js"; function getActiveClient(app) { var buf = app.state.buffers.get(app.state.activeBuffer); diff --git a/components/app.js b/components/app.js index c62a08d..395398e 100644 --- a/components/app.js +++ b/components/app.js @@ -1,17 +1,17 @@ -import * as irc from "/lib/irc.js"; -import Client from "/lib/client.js"; -import Buffer from "/components/buffer.js"; -import BufferList from "/components/buffer-list.js"; -import BufferHeader from "/components/buffer-header.js"; -import MemberList from "/components/member-list.js"; -import Connect from "/components/connect.js"; -import Composer from "/components/composer.js"; -import ScrollManager from "/components/scroll-manager.js"; -import { html, Component, createRef } from "/lib/index.js"; -import { strip as stripANSI } from "/lib/ansi.js"; -import { SERVER_BUFFER, BufferType, ReceiptType, NetworkStatus, Unread } from "/state.js"; -import commands from "/commands.js"; -import { setup as setupKeybindings } from "/keybindings.js"; +import * as irc from "../lib/irc.js"; +import Client from "../lib/client.js"; +import Buffer from "./buffer.js"; +import BufferList from "./buffer-list.js"; +import BufferHeader from "./buffer-header.js"; +import MemberList from "./member-list.js"; +import Connect from "./connect.js"; +import Composer from "./composer.js"; +import ScrollManager from "./scroll-manager.js"; +import { html, Component, createRef } from "../lib/index.js"; +import { strip as stripANSI } from "../lib/ansi.js"; +import { SERVER_BUFFER, BufferType, ReceiptType, NetworkStatus, Unread } from "../state.js"; +import commands from "../commands.js"; +import { setup as setupKeybindings } from "../keybindings.js"; const CHATHISTORY_MAX_SIZE = 4000; @@ -189,6 +189,10 @@ export default class App extends Component { if (window.location.protocol != "https:") { proto = "ws:"; } + var path = window.location.pathname || "/"; + if (!window.location.host) { + path = "/"; + } var serverURL; if (params.server) { @@ -198,7 +202,7 @@ export default class App extends Component { serverURL = params.server; } } else { - serverURL = proto + "//" + host + "/socket"; + serverURL = proto + "//" + host + path + "socket"; } this.state.connectParams.serverURL = serverURL; diff --git a/components/buffer-header.js b/components/buffer-header.js index eaab22f..66d717a 100644 --- a/components/buffer-header.js +++ b/components/buffer-header.js @@ -1,7 +1,7 @@ -import { html, Component } from "/lib/index.js"; -import linkify from "/lib/linkify.js"; -import { strip as stripANSI } from "/lib/ansi.js"; -import { BufferType, NetworkStatus } from "/state.js"; +import { html, Component } from "../lib/index.js"; +import linkify from "../lib/linkify.js"; +import { strip as stripANSI } from "../lib/ansi.js"; +import { BufferType, NetworkStatus } from "../state.js"; const UserStatus = { HERE: "here", diff --git a/components/buffer-list.js b/components/buffer-list.js index 2491b98..f8e09f7 100644 --- a/components/buffer-list.js +++ b/components/buffer-list.js @@ -1,6 +1,6 @@ -import * as irc from "/lib/irc.js"; -import { html, Component } from "/lib/index.js"; -import { BufferType, Unread, getBufferURL } from "/state.js"; +import * as irc from "../lib/irc.js"; +import { html, Component } from "../lib/index.js"; +import { BufferType, Unread, getBufferURL } from "../state.js"; function getNetworkName(network) { var bouncerStr = network.isupport.get("BOUNCER"); diff --git a/components/buffer.js b/components/buffer.js index b285b9e..7ef95cf 100644 --- a/components/buffer.js +++ b/components/buffer.js @@ -1,8 +1,8 @@ -import { html, Component } from "/lib/index.js"; -import linkify from "/lib/linkify.js"; -import * as irc from "/lib/irc.js"; -import { strip as stripANSI } from "/lib/ansi.js"; -import { BufferType, getNickURL, getMessageURL } from "/state.js"; +import { html, Component } from "../lib/index.js"; +import linkify from "../lib/linkify.js"; +import * as irc from "../lib/irc.js"; +import { strip as stripANSI } from "../lib/ansi.js"; +import { BufferType, getNickURL, getMessageURL } from "../state.js"; function djb2(s) { var hash = 5381; diff --git a/components/composer.js b/components/composer.js index 985b2f0..14f7506 100644 --- a/components/composer.js +++ b/components/composer.js @@ -1,4 +1,4 @@ -import { html, Component, createRef } from "/lib/index.js"; +import { html, Component, createRef } from "../lib/index.js"; export default class Composer extends Component { state = { diff --git a/components/connect.js b/components/connect.js index bf22889..3dc5635 100644 --- a/components/connect.js +++ b/components/connect.js @@ -1,4 +1,4 @@ -import { html, Component } from "/lib/index.js"; +import { html, Component } from "../lib/index.js"; export default class Connect extends Component { state = { diff --git a/components/member-list.js b/components/member-list.js index 48bdcdf..545c055 100644 --- a/components/member-list.js +++ b/components/member-list.js @@ -1,5 +1,5 @@ -import { html, Component } from "/lib/index.js"; -import { getNickURL } from "/state.js"; +import { html, Component } from "../lib/index.js"; +import { getNickURL } from "../state.js"; class MemberItem extends Component { constructor(props) { diff --git a/components/scroll-manager.js b/components/scroll-manager.js index fa0d175..c204ed7 100644 --- a/components/scroll-manager.js +++ b/components/scroll-manager.js @@ -1,4 +1,4 @@ -import { html, Component } from "/lib/index.js"; +import { html, Component } from "../lib/index.js"; var store = new Map(); diff --git a/index.html b/index.html index 4b6d20a..5789027 100644 --- a/index.html +++ b/index.html @@ -3,15 +3,15 @@ gamja IRC client - + diff --git a/keybindings.js b/keybindings.js index 07dcd98..f5b114f 100644 --- a/keybindings.js +++ b/keybindings.js @@ -1,4 +1,4 @@ -import { ReceiptType, Unread, SERVER_BUFFER } from "/state.js"; +import { ReceiptType, Unread, SERVER_BUFFER } from "./state.js"; export const keybindings = [ { diff --git a/lib/index.js b/lib/index.js index e5e1117..c615ff8 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,8 +1,8 @@ -export * from "/node_modules/preact/dist/preact.module.js"; +export * from "../node_modules/preact/dist/preact.module.js"; -import { h } from "/node_modules/preact/dist/preact.module.js"; -import htm from "/node_modules/htm/dist/htm.module.js"; +import { h } from "../node_modules/preact/dist/preact.module.js"; +import htm from "../node_modules/htm/dist/htm.module.js"; export const html = htm.bind(h); -import "/node_modules/anchorme/dist/browser/anchorme.min.js"; +import "../node_modules/anchorme/dist/browser/anchorme.min.js"; export const anchorme = window.anchorme; diff --git a/lib/linkify.js b/lib/linkify.js index 18a35f2..c9697cd 100644 --- a/lib/linkify.js +++ b/lib/linkify.js @@ -1,4 +1,4 @@ -import { anchorme, html } from "/lib/index.js"; +import { anchorme, html } from "./index.js"; export default function linkify(text) { var links = anchorme.list(text); diff --git a/state.js b/state.js index 9049d9c..199681c 100644 --- a/state.js +++ b/state.js @@ -1,4 +1,4 @@ -import Client from "/lib/client.js"; +import Client from "./lib/client.js"; export const SERVER_BUFFER = "*";