aboutsummaryrefslogtreecommitdiffhomepage
path: root/html
diff options
context:
space:
mode:
authorGravatar David Aspinall <da@inf.ed.ac.uk>2002-07-18 12:39:12 +0000
committerGravatar David Aspinall <da@inf.ed.ac.uk>2002-07-18 12:39:12 +0000
commit7f3e8838b42d77fd7577765ddc86a4666346d37a (patch)
tree1bd74d8d1ca6c88a1458b5459b2a87fad85895f7 /html
parent388f59891bdbad0388acc2f885d3182b7fb64bbe (diff)
hack_html: Make internal links use short-cut url if given
Diffstat (limited to 'html')
-rw-r--r--html/functions.php325
1 files changed, 17 insertions, 8 deletions
diff --git a/html/functions.php3 b/html/functions.php3
index 55e6ad64..bf15be94 100644
--- a/html/functions.php3
+++ b/html/functions.php3
@@ -202,7 +202,13 @@ function htmlshow($filename,$text="",$title="") {
$text, $message);
}
-
+function htmlshow_link($filename,$title="") {
+ $urlbits = parse_url($filename);
+ return "htmlshow.php"
+ . "?title=" . urlencode($title)
+ . "&file=" . urlencode($urlbits["path"])
+ . ($urlbits["fragment"]=="" ? "" : "#" . $urlbits["fragment"]);
+}
/* Markup plain text file, by escaping < and > */
@@ -223,8 +229,11 @@ function markup_plain_text($filename) {
the output of texi2html.
*/
-function hack_html($filename,$title="") {
+function hack_html($filename,$title="",$docrooturl="") {
if ($title=="") { $title=$filename; };
+ if ($docrooturl=="") {
+ $docrooturl = "htmlshow.php?title=" . urlencode($title);
+ }
$file = file($filename);
/* Paste style sheet in head */
for($i = 0;$i < count($file);$i++) {
@@ -254,15 +263,15 @@ function hack_html($filename,$title="") {
$urlbits = parse_url($linebits[4]);
if ($urlbits["host"]=="") {
/* Assume a relative link, let's hack it. */
- /* Use same title */
- $newurl = "htmlshow.php?title=" . urlencode($title);
if ($urlbits["path"]=="") {
/* A fragment in same file */
- $newurl = $newurl . "&file="
- . urlencode($filename) . "#" . $urlbits["fragment"];
+ $newurl = $docrooturl . "#" . $urlbits["fragment"];
} else {
- /* Another file */
- $newurl = $newurl . "&file="
+ /* Another file, use same title */
+ /* FIXME: would be nice to deal with split info files
+ here by adding aliases somehow */
+ $newurl = "htmlshow.php?title=" . urlencode($title)
+ . "&file="
. urlencode(dirname($filename) . "/" . $urlbits["path"])
. ($urlbits["fragment"]=="" ? "" : "#" . $urlbits["fragment"]);
};