Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/website/content/en/cgi/cgi-style.pl
18093 views
1
#
2
# Perl routines to encapsulate various elements of HTML page style.
3
4
# For future reference, when is now?
5
($se,$mn,$hr,$md,$mo,$yr,$wd,$yd,$dst) = localtime(time);
6
$yr += 1900;
7
$mo += 1;
8
$timestamp = "$mo-$md-$yr";
9
10
if (!defined($hsty_base)) {
11
# $hsty_base should be relative if possible, so that mirrors
12
# serve their local copy instead of going to the main site.
13
# However, if we aren't running as a cgi, or if we're
14
# running on one of the subdomains listed below, use the absolute home path.
15
if (!defined($ENV{'HTTP_HOST'}) ||
16
$ENV{'HTTP_HOST'} =~ /(docs|docs-archive|mail-archive|man|man-dev|people|ports).freebsd.org/i) {
17
18
$hsty_base = 'https://www.FreeBSD.org'
19
} else {
20
$hsty_base = '..';
21
}
22
}
23
if (!defined($hsty_email)) {
24
$hsty_email = 'Contact';
25
}
26
if (!defined($hsty_author)) {
27
$hsty_author = "<a href='$hsty_base/mailto/'>$hsty_email</a>";
28
}
29
30
if (!defined($hsty_date)) {
31
$hsty_date = '';
32
}
33
34
if (!defined($hsty_charset)) {
35
$hsty_charset = 'iso-8859-1';
36
}
37
38
# This can be set to either a string containing an inline CSS stylesheet
39
# or to a <link> element that references an external CSS stylesheet, to
40
# make local modifications to the style of a CGI script's output.
41
$t_style = ""; # Don't allow script to override completely, just
42
# let the script's setting cascade with the master.
43
44
$i_topbar = qq`
45
<div id="containerwrap">
46
<div id="container">
47
<span class="txtoffscreen"><a href="#content"
48
title="Skip site navigation" accesskey="1">Skip site
49
navigation</a> (1)</span><span class="txtoffscreen"><a
50
href="#content" title="Skip section navigation"
51
accesskey="2">Skip section navigation</a> (2)</span>
52
53
<div id="headercontainer">
54
<div id="header">
55
<h2 class="blockhide">Header And Logo</h2>
56
57
<div id="headerlogoleft">
58
<a href="$hsty_base" title="FreeBSD"><img
59
src="$hsty_base/layout/images/banner-red.png" width="457"
60
height="75" alt="FreeBSD" /></a>
61
</div>
62
63
<div id="headerlogoright">
64
<h2 class="blockhide">Peripheral Links</h2>
65
66
<div class="frontdonateroundbox">
67
<div class="frontdonatetop">
68
<div>
69
<b style="display: none;">.</b>
70
</div>
71
</div>
72
<div class="frontdonatecontent">
73
<a href="https://www.FreeBSDFoundation.org/donate/">Donate to FreeBSD</a>
74
</div>
75
<div class="frontdonatebot">
76
<div>
77
<b style="display: none;">.</b>
78
</div>
79
</div>
80
</div>
81
82
<div id="search">
83
<form method="get" id="search-form" action="https://duckduckgo.com/">
84
<h2 class="blockhide"><label for="words">Search</label></h2>
85
<input type="hidden" name="sites" value="FreeBSD.org" />
86
<input type="hidden" name="ka" value="v" />
87
<input type="hidden" name="kt" value="v" />
88
<input type="hidden" name="kh" value="1" />
89
<input type="hidden" name="kj" value="r2" />
90
<input id="words" name="q" type="text" size="20"
91
autocapitalize="none"
92
maxlength="255"
93
onfocus="if( this.value==this.defaultValue ) this.value='';"
94
value="Search" />
95
<span>&nbsp;</span>
96
<input id="submit" name="submit" type="submit" value="Search" />
97
</form>
98
</div>
99
</div>
100
</div>
101
102
<h2 class="blockhide">Site Navigation</h2>
103
104
<div id="menu">
105
<ul class="first">
106
<li><a href="$hsty_base/">Home</a></li>
107
</ul>
108
<ul>
109
<li><a href="$hsty_base/about/">About</a>
110
<ul>
111
<li><a href="$hsty_base/projects/newbies/">Introduction</a></li>
112
<li><a href="$hsty_base/features/">Features</a></li>
113
<li><a href="$hsty_base/advocacy/">Advocacy</a></li>
114
<li><a href="$hsty_base/marketing/">Marketing</a></li>
115
</ul>
116
</li>
117
</ul>
118
<ul>
119
<li><a href="$hsty_base/where/">Get FreeBSD</a>
120
<ul>
121
<li><a href="$hsty_base/releases/">Release Information</a></li>
122
<li><a href="$hsty_base/releng/">Release Engineering</a></li>
123
</ul>
124
</li>
125
</ul>
126
<ul>
127
<li><a href="$hsty_base/docs/">Documentation</a>
128
<ul>
129
<li><a href="https://docs.freebsd.org/en/books/faq/">FAQ</a></li>
130
<li><a href="https://docs.freebsd.org/en/books/handbook/">Handbook</a></li>
131
<li><a href="https://docs.freebsd.org/en/books/porters-handbook/">Porter's Handbook</a></li>
132
<li><a href="https://docs.freebsd.org/en//books/developers-handbook/">Developer's Handbook</a></li>
133
<li><a href="$hsty_base/cgi/man.cgi">Manual Pages</a></li>
134
<li><a href="https://docs.freebsd.org/en/books/fdp-primer/">Documentation Project Primer</a></li>
135
<li><a href="$hsty_base/docs/books/">All Books and Articles</a></li>
136
</ul>
137
</li>
138
</ul>
139
<ul>
140
<li><a href="$hsty_base/community.html">Community</a>
141
<ul>
142
<li><a href="$hsty_base/community/mailinglists.html">Mailing Lists</a></li>
143
<li><a href="https://forums.FreeBSD.org">Forums</a></li>
144
<li><a href="$hsty_base/usergroups.html">User Groups</a></li>
145
<li><a href="$hsty_base/events/events.html">Events</a></li>
146
</ul>
147
</li>
148
</ul>
149
<ul>
150
<li><a href="$hsty_base/projects/index.html">Developers</a>
151
<ul>
152
<li><a href="$hsty_base/projects/ideas/ideas.html">Project Ideas</a></li>
153
<li><a href="https://cgit.FreeBSD.org">GIT Repository</a></li>
154
</ul>
155
</li>
156
</ul>
157
<ul>
158
<li><a href="$hsty_base/support.html">Support</a>
159
<ul>
160
<li><a href="$hsty_base/commercial/commercial.html">Vendors</a></li>
161
<li><a href="https://security.FreeBSD.org/">Security Information</a></li>
162
<li><a href="https://bugs.freebsd.org/search/">Bug Reports</a></li>
163
<li><a href="$hsty_base/support.html">Submit Bug-report</a></li>
164
</ul>
165
</li>
166
</ul>
167
<ul>
168
<li><a href="https://www.freebsdfoundation.org/">Foundation</a>
169
<ul>
170
<li><a href="https://www.freebsdfoundation.org/donate/">Donate</a></li>
171
</ul>
172
</li>
173
</ul>
174
</div> <!-- MENU -->
175
</div>
176
177
<div id="content">
178
`;
179
180
#XXX does anyone use this? I don't know what it should be in the new style.
181
if (!defined($hsty_home)) {
182
$hsty_home = "<a href='$hsty_base/'><img src='$hsty_base/gifs/home.gif'
183
alt='FreeBSD Home Page' border='0' align='right'></a>";
184
}
185
186
sub html_header {
187
local ($title, $xhtml) = @_;
188
189
return short_html_header($title, $xhtml) . "<br/>\n<h1>$title</h1>\n";
190
}
191
192
sub short_html_header {
193
local ($title, $xhtml) = @_;
194
195
$xhtml = 1 unless defined($xhtml);
196
$doctype = $xhtml ? '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' : '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
197
$html = $xhtml ? '<html xmlns="http://www.w3.org/1999/xhtml">' : '<html>';
198
$endslash = $xhtml ? '/' : '';
199
$csshack = (1 || $xhtml) ? '' : q`<style type="text/css">
200
tr, td {
201
margin: 0;
202
padding: 0;
203
font-family: verdana, sans-serif;
204
font-size: 69%;
205
color: #000;
206
}
207
</style>
208
`;
209
210
return qq`Content-type: text/html
211
212
$doctype
213
$html
214
215
<head><title>$title</title>
216
<meta http-equiv='content-type' content='text/html; charset=$hsty_charset' $endslash>
217
<meta name='robots' content='nofollow' $endslash>
218
<link rel="stylesheet" media="screen"
219
href="$hsty_base/layout/css/fixed.css" type="text/css"
220
title="Normal Text" $endslash>
221
<link rel="alternate stylesheet" media="screen"
222
href="$hsty_base/layout/css/fixed_large.css" type="text/css"
223
title="Large Text" $endslash>
224
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
225
<link rel="apple-touch-icon" href="/favicon.ico" type="image/x-icon" />
226
$csshack
227
$t_style
228
</head>
229
<body>
230
$i_topbar
231
`;
232
}
233
234
sub html_footer {
235
return qq`
236
</div>
237
<div id="footer">
238
<a href="$hsty_base/copyright/">Legal Notices</a> | &copy; 1995-2026
239
The FreeBSD Project. All rights reserved.<br />
240
<address>$hsty_author<br />$hsty_date</address>
241
</div>
242
</div>
243
</div>
244
</body>
245
</html>
246
`;
247
248
249
}
250
251
sub get_the_source {
252
return if $ENV{'PATH_INFO'} ne '/get_the_source';
253
254
open(R, $0) || do {
255
print "Oops! open $0: $!\n"; # should not reached
256
exit;
257
};
258
259
print "Content-type: text/plain\n\n";
260
while(<R>) { print }
261
close R;
262
exit;
263
}
264
265
1;
266
267