@@ -12,6 +12,7 @@ import { query, escapeForText } from "./result";
12
12
import { createToolbar , createCloseButton } from "./toolbar" ;
13
13
import { initResizer , windowResized } from "./resizer" ;
14
14
import { getHashQuery } from "./hash" ;
15
+ import { getBasePath } from "./util" ;
15
16
16
17
type PadRef = {
17
18
id : string ;
@@ -47,7 +48,8 @@ function getPadURL() {
47
48
const url = new URL ( window . location . href ) ;
48
49
url . search = "" ;
49
50
url . hash = "" ;
50
- url . pathname = `/t/${ encodeURIComponent ( ep_weave . title ) } ` ;
51
+ const basePath = getBasePath ( ) ;
52
+ url . pathname = `${ basePath } /t/${ encodeURIComponent ( ep_weave . title ) } ` ;
51
53
return url . toString ( ) ;
52
54
}
53
55
@@ -83,10 +85,11 @@ function overrideEmbedCommand(toolbar: AceToolbar) {
83
85
}
84
86
85
87
function refreshNavbar ( navbar : JQuery , title : string ) {
88
+ const basePath = getBasePath ( ) ;
86
89
navbar . empty ( ) ;
87
90
navbar . append (
88
91
$ ( "<a>" )
89
- . attr ( "href" , "/" )
92
+ . attr ( "href" , ` ${ basePath } /` )
90
93
. text ( "Index" )
91
94
. addClass ( "hashview-path-segment hashview-path-index" )
92
95
) ;
@@ -99,7 +102,7 @@ function refreshNavbar(navbar: JQuery, title: string) {
99
102
$ ( "<a>" )
100
103
. addClass ( "hashview-path-segment" )
101
104
. text ( segment )
102
- . attr ( "href" , `/t/${ encodeURIComponent ( parentPath ) } ` )
105
+ . attr ( "href" , `${ basePath } /t/${ encodeURIComponent ( parentPath ) } ` )
103
106
) ;
104
107
navbar . append ( $ ( "<span>" ) . addClass ( "hashview-path-separator" ) . text ( "/" ) ) ;
105
108
}
@@ -129,14 +132,15 @@ function getCurrentSort() {
129
132
}
130
133
131
134
function createMenuItem ( ) {
135
+ const basePath = getBasePath ( ) ;
132
136
const changeTitleButton = $ ( "<button></button>" )
133
137
. addClass ( "hashview-change-title btn" )
134
138
. on ( "click" , ( ) => {
135
139
if ( ! changedTitle ) {
136
140
return ;
137
141
}
138
142
$ . ajax ( {
139
- url : `/ep_weave/hashes?${ new URLSearchParams ( {
143
+ url : `${ basePath } /ep_weave/hashes?${ new URLSearchParams ( {
140
144
oldtitle : changedTitle . oldtitle ,
141
145
newtitle : changedTitle . newtitle ,
142
146
} ) } `,
@@ -175,8 +179,9 @@ function createMenuItem() {
175
179
return ;
176
180
}
177
181
duplicatedPads . forEach ( ( pad ) => {
182
+ const basePath = getBasePath ( ) ;
178
183
console . debug ( logPrefix , "Open pad" , pad ) ;
179
- window . open ( `/p/${ pad . id } ` , "_blank" ) ;
184
+ window . open ( `${ basePath } /p/${ pad . id } ` , "_blank" ) ;
180
185
} ) ;
181
186
} ) ;
182
187
return $ ( "<li></li>" )
@@ -332,10 +337,11 @@ async function loadHashView(
332
337
( await Promise . all ( hashViews ) ) . forEach ( ( hashView ) => {
333
338
container . append ( hashView ) ;
334
339
} ) ;
340
+ const basePath = getBasePath ( ) ;
335
341
const titledPadExists = docs . some ( ( doc ) => doc . title === hash . substring ( 1 ) ) ;
336
342
if ( title !== hash . substring ( 1 ) && ! titledPadExists ) {
337
343
const anchor = $ ( "<a></a>" )
338
- . attr ( "href" , `/t/${ hash . substring ( 1 ) } ` )
344
+ . attr ( "href" , `${ basePath } /t/${ hash . substring ( 1 ) } ` )
339
345
. text ( hash . substring ( 1 ) ) ;
340
346
const createClass = "hash-create" ;
341
347
const hashLink = $ ( "<div></div>" )
@@ -505,7 +511,8 @@ exports.postToolbarInit = (hook: any, context: PostToolbarInit) => {
505
511
title += "/" ;
506
512
}
507
513
title += query ;
508
- window . open ( `/t/${ encodeURIComponent ( title ) } ` , "_blank" ) ;
514
+ const basePath = getBasePath ( ) ;
515
+ window . open ( `${ basePath } /t/${ encodeURIComponent ( title ) } ` , "_blank" ) ;
509
516
} ,
510
517
} ) . prepend ( $ ( "<div>" ) . text ( ">" ) . addClass ( "hashview-toolbar-child-marker" ) )
511
518
)
@@ -577,9 +584,10 @@ export function aceCreateDomLine(
577
584
if ( ! hashTitle ) {
578
585
throw new Error ( `Unexpected error: ${ searchHash_ } , ${ hash } , ${ link } ` ) ;
579
586
}
587
+ const basePath = getBasePath ( ) ;
580
588
return [
581
589
{
582
- extraOpenTags : `<a href="/t/${ encodeURIComponent ( hashTitle ) } ">` ,
590
+ extraOpenTags : `<a href="${ basePath } /t/${ encodeURIComponent ( hashTitle ) } ">` ,
583
591
extraCloseTags : "</a>" ,
584
592
cls : modifiedCls ,
585
593
} ,
0 commit comments