Fossil SCM
Teach link-tester.js to be able to run when invoked from /doc/branchname/test.
Commit
6ede23a1ab3d708bae252cae00a0d9056a350f4d016335d82ec8b56231655909
Parent
3eef0e230dfbe98…
1 file changed
+21
-13
+21
-13
| --- test/link-tester.js | ||
| +++ test/link-tester.js | ||
| @@ -22,25 +22,33 @@ | ||
| 22 | 22 | eIframe.setAttribute('src', so.value || so.innerText); |
| 23 | 23 | } |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | 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. | |
| 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. | |
| 33 | 31 | */ |
| 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); | |
| 40 | 48 | for( const o of eSelect.options ){ |
| 41 | - o.value = top + (o.value || o.innerText); | |
| 49 | + o.value = urlTop + (o.value || o.innerText); | |
| 42 | 50 | } |
| 43 | 51 | |
| 44 | 52 | const eBtnPrev = E('#btn-prev'); |
| 45 | 53 | const eBtnNext = E('#btn-next'); |
| 46 | 54 | |
| 47 | 55 |
| --- 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 |