Fossil SCM

Teach link-tester.js to be able to run when invoked from /doc/branchname/test.

stephan 2025-06-20 12:48 trunk
Commit 6ede23a1ab3d708bae252cae00a0d9056a350f4d016335d82ec8b56231655909
1 file changed +21 -13
--- test/link-tester.js
+++ test/link-tester.js
@@ -22,25 +22,33 @@
2222
eIframe.setAttribute('src', so.value || so.innerText);
2323
}
2424
});
2525
2626
/*
27
- Prepend the fossil instance's URL to each link so that this script
28
- works when run from a non-localhost "fossil ui/server" instance.
29
- We _assume_ that this script is run from /uv or /ext, with no
30
- subsequent dirs after /uv or /ext. To run from deeper levels the
31
- following logic needs to be adjusted to guess where the fossil
32
- instance's CGI script is.
27
+ Prepend the fossil instance's URL to each link. We have to guess
28
+ which part of the URL is the fossil CGI/server instance. The
29
+ following works when run (A) from under /uv or /ext and (B) from
30
+ /doc/branchname/test/link-tester.html.
3331
*/
34
- let top = (''+window.location).split('/');
35
- top.pop(); // this file name
36
- top.pop(); // parent dir
37
- /* We're hopefully now at the top-most fossil-served
38
- URL. */
39
- top = top.join('/');
32
+ let urlTop;
33
+ let loc = (''+window.location);
34
+ let aLoc = loc.split('/')
35
+ aLoc.pop(); /* this file name */
36
+ const rxDoc = /.*\/doc\/[^/]+\/.*/;
37
+ //console.log(rxDoc, loc, aLoc);
38
+ if( loc.match(rxDoc) ){
39
+ /* We're hopefully now at the top-most fossil-served
40
+ URL. */
41
+ aLoc.pop(); aLoc.pop(); /* /doc/foo */
42
+ aLoc.pop(); /* current dir name */
43
+ }else{
44
+ aLoc.pop(); /* current dir name */
45
+ }
46
+ urlTop = aLoc.join('/');
47
+ //console.log(urlTop, aLoc);
4048
for( const o of eSelect.options ){
41
- o.value = top + (o.value || o.innerText);
49
+ o.value = urlTop + (o.value || o.innerText);
4250
}
4351
4452
const eBtnPrev = E('#btn-prev');
4553
const eBtnNext = E('#btn-next');
4654
4755
--- test/link-tester.js
+++ test/link-tester.js
@@ -22,25 +22,33 @@
22 eIframe.setAttribute('src', so.value || so.innerText);
23 }
24 });
25
26 /*
27 Prepend the fossil instance's URL to each link so that this script
28 works when run from a non-localhost "fossil ui/server" instance.
29 We _assume_ that this script is run from /uv or /ext, with no
30 subsequent dirs after /uv or /ext. To run from deeper levels the
31 following logic needs to be adjusted to guess where the fossil
32 instance's CGI script is.
33 */
34 let top = (''+window.location).split('/');
35 top.pop(); // this file name
36 top.pop(); // parent dir
37 /* We're hopefully now at the top-most fossil-served
38 URL. */
39 top = top.join('/');
 
 
 
 
 
 
 
 
 
 
40 for( const o of eSelect.options ){
41 o.value = top + (o.value || o.innerText);
42 }
43
44 const eBtnPrev = E('#btn-prev');
45 const eBtnNext = E('#btn-next');
46
47
--- test/link-tester.js
+++ test/link-tester.js
@@ -22,25 +22,33 @@
22 eIframe.setAttribute('src', so.value || so.innerText);
23 }
24 });
25
26 /*
27 Prepend the fossil instance's URL to each link. We have to guess
28 which part of the URL is the fossil CGI/server instance. The
29 following works when run (A) from under /uv or /ext and (B) from
30 /doc/branchname/test/link-tester.html.
 
 
31 */
32 let urlTop;
33 let loc = (''+window.location);
34 let aLoc = loc.split('/')
35 aLoc.pop(); /* this file name */
36 const rxDoc = /.*\/doc\/[^/]+\/.*/;
37 //console.log(rxDoc, loc, aLoc);
38 if( loc.match(rxDoc) ){
39 /* We're hopefully now at the top-most fossil-served
40 URL. */
41 aLoc.pop(); aLoc.pop(); /* /doc/foo */
42 aLoc.pop(); /* current dir name */
43 }else{
44 aLoc.pop(); /* current dir name */
45 }
46 urlTop = aLoc.join('/');
47 //console.log(urlTop, aLoc);
48 for( const o of eSelect.options ){
49 o.value = urlTop + (o.value || o.innerText);
50 }
51
52 const eBtnPrev = E('#btn-prev');
53 const eBtnNext = E('#btn-next');
54
55

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button