summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaglfar <rpblc.net>2023-03-21 18:20:30 +0000
committerNaglfar <rpblc.net>2023-03-21 18:20:30 +0000
commit05be095d9944be899c8fa0c1c56ac6b9a6c145f1 (patch)
treefd419c851aeea31a1fc6968dc9cbbd19d45ed16c
parentdefd948c1995f725c4185f96c202274b275e29b3 (diff)
downloadopenwcms-05be095d9944be899c8fa0c1c56ac6b9a6c145f1.tar.gz
Add CGI index of contents in Perl programming language
-rwxr-xr-xindex.cgi78
1 files changed, 78 insertions, 0 deletions
diff --git a/index.cgi b/index.cgi
new file mode 100755
index 0000000..cbcf385
--- /dev/null
+++ b/index.cgi
@@ -0,0 +1,78 @@
+#!/usr/bin/perl -wT
+
+# breaks up a string according to a separator
+@uri = split('/', $ENV{REQUEST_URI});
+if ( $#uri > -1 && -e "/openwcms/data/$uri[1].html" )
+{
+ $request = "$uri[1]";
+}
+else
+{
+ $request = 'main';
+}
+
+require '/openwcms/include/add_items.pl';
+# domain is always the first thing in the string, pick the first element
+$domain = (split /\./, $head[0]{href})[0];
+
+print "Content-type: text/html\n\n";
+print <<eof;
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <meta name="viewport" content="width=device-width" />
+ <link href="favicon.ico" type="image/x-icon" rel="icon" />
+ <title>$head[0]{title} - $domain</title>
+ <meta name="description" content="$head[0]{anchor}" />
+ <link rel="stylesheet" href="/style/openwcms.css" type="text/css" />
+</head>
+<body>
+<div id="body-wrapper">
+
+<div id="header">
+ <div class="branding"></div>
+ <ul>
+eof
+foreach my $i (0 .. $#header)
+{
+ print qq(\t<li><a href="$header[$i]{href}" title="$header[$i]{title}">$header[$i]{anchor}</a></li>\n)
+}
+print <<eof;
+ </ul>
+</div>
+
+<div id="main">
+eof
+open (FH, "/openwcms/data/$request.html");
+while ($line = <FH>)
+{
+ chomp $line; # to remove the last trailing newline
+ print $line;
+}
+close (FH);
+
+print <<eof;
+</div>
+
+<div id="sidebar">
+ <h3><a href='/'>News</a></h3>
+ <ul>
+eof
+foreach my $i (0 .. $#sidebar)
+{
+ print qq(\t<li><a href='$sidebar[$i]{href}' title='$sidebar[$i]{title}' target='_blank'>[ $sidebar[$i]{anchor} ]</a></li>\n)
+}
+print <<eof;
+ </ul>
+</div>
+
+</div>
+
+<div id="footer">
+ <a href="$footer[0]{href}" title="$footer[0]{title}" target="_blank">$footer[0]{anchor}</a>
+</div>
+
+</body>
+</html>
+eof