Fossil SCM

Make the default header and footer a bit more dynamic.

mistachkin 2012-09-18 00:06 UTC trunk
Commit 6cea1e492076c5650b561c5580e77a8dc022e0bc
1 file changed +77 -4
+77 -4
--- src/style.c
+++ src/style.c
@@ -310,28 +310,83 @@
310310
*/
311311
void style_sidebox_end(void){
312312
@ </div>
313313
}
314314
315
-/* @-comment: // */
316315
/*
317316
** The default page header.
318317
*/
319318
const char zDefaultHeader[] =
320319
@ <html>
321320
@ <head>
322
-@ <base href="$baseurl/$current_page">
321
+@ <base href="$baseurl/$current_page" />
323322
@ <title>$<project_name>: $<title></title>
324323
@ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
325324
@ href="$home/timeline.rss" />
326325
@ <link rel="stylesheet" href="$home/style.css?default" type="text/css"
327326
@ media="screen" />
328327
@ </head>
329328
@ <body>
330329
@ <div class="header">
331330
@ <div class="logo">
332
-@ <img src="$home/logo" alt="logo" />
331
+@ <th1>
332
+@ #
333
+@ # NOTE: The purpose of this procedure is to take the base URL of the
334
+@ # Fossil project and return the root of the entire web site using
335
+@ # the same URI scheme as the base URL (e.g. http or https).
336
+@ #
337
+@ proc getLogoUrl { baseurl } {
338
+@ set idx(first) [string first // $baseurl]
339
+@ if {$idx(first) != -1} {
340
+@ set idx(first+1) [expr {$idx(first) + 2}]; # NOTE: Skip second slash.
341
+@ #
342
+@ # NOTE: (part 1) The [string first] command does NOT actually support
343
+@ # the optional startIndex argument as specified in the TH1
344
+@ # manual; therefore, we fake it by using [string range] and then
345
+@ # adding the necessary offset to the resulting index manually
346
+@ # (below).
347
+@ #
348
+@ # set idx(next) [string first / $baseurl $idx(first+1)]
349
+@ set idx(next) [string first / [string range $baseurl $idx(first+1) end]]
350
+@ if {$idx(next) != -1} {
351
+@ #
352
+@ # NOTE: (part 2) Add the necessary offset to the result of the
353
+@ # search for the next slash (i.e. the one after the initial
354
+@ # search for the two slashes).
355
+@ #
356
+@ set idx(next) [expr {$idx(next) + $idx(first+1)}]
357
+@ #
358
+@ # NOTE: Back up one character from the next slash.
359
+@ #
360
+@ set idx(next-1) [expr {$idx(next) - 1}]
361
+@ #
362
+@ # NOTE: Extract the URI scheme and host from the base URL.
363
+@ #
364
+@ set scheme [string range $baseurl 0 $idx(first)]
365
+@ set host [string range $baseurl $idx(first+1) $idx(next-1)]
366
+@ #
367
+@ # NOTE: Try to stay in SSL mode if we are there now.
368
+@ #
369
+@ if {[string compare $scheme http:/] == 0} {
370
+@ set scheme "http://"
371
+@ } else {
372
+@ set scheme "https://"
373
+@ }
374
+@ set logourl "$scheme$host/"
375
+@ } else {
376
+@ set logourl $baseurl
377
+@ }
378
+@ } else {
379
+@ set logourl $baseurl
380
+@ }
381
+@ return $logourl
382
+@ }
383
+@ set logourl [getLogoUrl $baseurl]
384
+@ </th1>
385
+@ <a href="$logourl">
386
+@ <img src="$baseurl/logo" border="0" alt="$project_name">
387
+@ </a>
333388
@ </div>
334389
@ <div class="title"><small>$<project_name></small><br />$<title></div>
335390
@ <div class="status"><th1>
336391
@ if {[info exists login]} {
337392
@ puts "Logged in as $login"
@@ -375,11 +430,29 @@
375430
/*
376431
** The default page footer
377432
*/
378433
const char zDefaultFooter[] =
379434
@ <div class="footer">
380
-@ Fossil version $release_version $manifest_version $manifest_date
435
+@ <th1>
436
+@ proc getTclVersion {} {
437
+@ if {[catch {tclEval info patchlevel} tclVersion] == 0} {
438
+@ return "<a href=\"http://www.tcl.tk/\">Tcl</a> version $tclVersion"
439
+@ }
440
+@ return ""
441
+@ }
442
+@ proc getVersion { version } {
443
+@ set length [string length $version]
444
+@ return [string range $version 1 [expr {$length - 2}]]
445
+@ }
446
+@ set version [getVersion $manifest_version]
447
+@ set tclVersion [getTclVersion]
448
+@ set fossilUrl http://www.fossil-scm.org
449
+@ </th1>
450
+@ <a href="$fossilUrl/">Fossil</a>
451
+@ version $release_version $tclVersion
452
+@ <a href="$fossilUrl/index.html/info/$version">$manifest_version</a>
453
+@ <a href="$fossilUrl/fossil/timeline?c=$manifest_date&y=ci">$manifest_date</a>
381454
@ </div>
382455
@ </body></html>
383456
;
384457
385458
/*
386459
--- src/style.c
+++ src/style.c
@@ -310,28 +310,83 @@
310 */
311 void style_sidebox_end(void){
312 @ </div>
313 }
314
315 /* @-comment: // */
316 /*
317 ** The default page header.
318 */
319 const char zDefaultHeader[] =
320 @ <html>
321 @ <head>
322 @ <base href="$baseurl/$current_page">
323 @ <title>$<project_name>: $<title></title>
324 @ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
325 @ href="$home/timeline.rss" />
326 @ <link rel="stylesheet" href="$home/style.css?default" type="text/css"
327 @ media="screen" />
328 @ </head>
329 @ <body>
330 @ <div class="header">
331 @ <div class="logo">
332 @ <img src="$home/logo" alt="logo" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333 @ </div>
334 @ <div class="title"><small>$<project_name></small><br />$<title></div>
335 @ <div class="status"><th1>
336 @ if {[info exists login]} {
337 @ puts "Logged in as $login"
@@ -375,11 +430,29 @@
375 /*
376 ** The default page footer
377 */
378 const char zDefaultFooter[] =
379 @ <div class="footer">
380 @ Fossil version $release_version $manifest_version $manifest_date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381 @ </div>
382 @ </body></html>
383 ;
384
385 /*
386
--- src/style.c
+++ src/style.c
@@ -310,28 +310,83 @@
310 */
311 void style_sidebox_end(void){
312 @ </div>
313 }
314
 
315 /*
316 ** The default page header.
317 */
318 const char zDefaultHeader[] =
319 @ <html>
320 @ <head>
321 @ <base href="$baseurl/$current_page" />
322 @ <title>$<project_name>: $<title></title>
323 @ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
324 @ href="$home/timeline.rss" />
325 @ <link rel="stylesheet" href="$home/style.css?default" type="text/css"
326 @ media="screen" />
327 @ </head>
328 @ <body>
329 @ <div class="header">
330 @ <div class="logo">
331 @ <th1>
332 @ #
333 @ # NOTE: The purpose of this procedure is to take the base URL of the
334 @ # Fossil project and return the root of the entire web site using
335 @ # the same URI scheme as the base URL (e.g. http or https).
336 @ #
337 @ proc getLogoUrl { baseurl } {
338 @ set idx(first) [string first // $baseurl]
339 @ if {$idx(first) != -1} {
340 @ set idx(first+1) [expr {$idx(first) + 2}]; # NOTE: Skip second slash.
341 @ #
342 @ # NOTE: (part 1) The [string first] command does NOT actually support
343 @ # the optional startIndex argument as specified in the TH1
344 @ # manual; therefore, we fake it by using [string range] and then
345 @ # adding the necessary offset to the resulting index manually
346 @ # (below).
347 @ #
348 @ # set idx(next) [string first / $baseurl $idx(first+1)]
349 @ set idx(next) [string first / [string range $baseurl $idx(first+1) end]]
350 @ if {$idx(next) != -1} {
351 @ #
352 @ # NOTE: (part 2) Add the necessary offset to the result of the
353 @ # search for the next slash (i.e. the one after the initial
354 @ # search for the two slashes).
355 @ #
356 @ set idx(next) [expr {$idx(next) + $idx(first+1)}]
357 @ #
358 @ # NOTE: Back up one character from the next slash.
359 @ #
360 @ set idx(next-1) [expr {$idx(next) - 1}]
361 @ #
362 @ # NOTE: Extract the URI scheme and host from the base URL.
363 @ #
364 @ set scheme [string range $baseurl 0 $idx(first)]
365 @ set host [string range $baseurl $idx(first+1) $idx(next-1)]
366 @ #
367 @ # NOTE: Try to stay in SSL mode if we are there now.
368 @ #
369 @ if {[string compare $scheme http:/] == 0} {
370 @ set scheme "http://"
371 @ } else {
372 @ set scheme "https://"
373 @ }
374 @ set logourl "$scheme$host/"
375 @ } else {
376 @ set logourl $baseurl
377 @ }
378 @ } else {
379 @ set logourl $baseurl
380 @ }
381 @ return $logourl
382 @ }
383 @ set logourl [getLogoUrl $baseurl]
384 @ </th1>
385 @ <a href="$logourl">
386 @ <img src="$baseurl/logo" border="0" alt="$project_name">
387 @ </a>
388 @ </div>
389 @ <div class="title"><small>$<project_name></small><br />$<title></div>
390 @ <div class="status"><th1>
391 @ if {[info exists login]} {
392 @ puts "Logged in as $login"
@@ -375,11 +430,29 @@
430 /*
431 ** The default page footer
432 */
433 const char zDefaultFooter[] =
434 @ <div class="footer">
435 @ <th1>
436 @ proc getTclVersion {} {
437 @ if {[catch {tclEval info patchlevel} tclVersion] == 0} {
438 @ return "<a href=\"http://www.tcl.tk/\">Tcl</a> version $tclVersion"
439 @ }
440 @ return ""
441 @ }
442 @ proc getVersion { version } {
443 @ set length [string length $version]
444 @ return [string range $version 1 [expr {$length - 2}]]
445 @ }
446 @ set version [getVersion $manifest_version]
447 @ set tclVersion [getTclVersion]
448 @ set fossilUrl http://www.fossil-scm.org
449 @ </th1>
450 @ <a href="$fossilUrl/">Fossil</a>
451 @ version $release_version $tclVersion
452 @ <a href="$fossilUrl/index.html/info/$version">$manifest_version</a>
453 @ <a href="$fossilUrl/fossil/timeline?c=$manifest_date&y=ci">$manifest_date</a>
454 @ </div>
455 @ </body></html>
456 ;
457
458 /*
459

Keyboard Shortcuts

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