" }' > $'tpl.include.tw.page'
365
366 } else {
367
368 tpl.var.tw.node = $'tbl_page.k_node'
369
370 # If page exists but its description begins with '-' then do not
371 # display it to non-editors.
372
373 if (!~ ,$TNS_AUTH_GRP, *,editor,* && ~ $'tbl_page.p_descr' -*) {
374
375 if (csaIsFullPath --exists --quiet $CSA_TPL_ROOT/tw-hidden-page.txt) {
376 # hidden-page custom template.
377 tpl.include.html.body = $CSA_TPL_ROOT/tw-hidden-page.txt
378 } else {
379 # hidden-page default template.
380 tpl.include.html.body = $tw_dstem/tw-hidden-page.txt
381 }
382
383 } else {
384
385 # If page exists but is empty use a different template. Note the
386 # use of grep(1) here instead of test(1), as tidy(1) always writes
387 # at least one newline in the page, which is then never completely
388 # zeroed.
389
390 if (!grep -qEe '(>[^<>]+|[^<>]+<)' $'tpl.include.tw.page') {
391
392 if (csaIsFullPath --exists \
393 --quiet $CSA_TPL_ROOT/tw-empty-page.txt) {
394 # empty-page custom template.
395 tpl.include.html.body = $CSA_TPL_ROOT/tw-empty-page.txt
396 } else {
397 # empty-page default template.
398 tpl.include.html.body = $tw_dstem/tw-empty-page.txt
399 }
400 }
401 }
402
403 # Pingback specs recommend that an HTTP header is used, but not every
404 # client support this so I also insert a element in the
405 # response body. If both headers are present the specs madate that the
406 # header one prevail.
407
408 csaHttp.header --deferred X-Pingback \
409 $CSA_RPC_URS/$CSA_ID/$CSA_LANG/$'tbl_group.g_uri'/$'tbl_page.p_uri'^'/ping?PUT'
410
411 tpl.var.tw.page.ping.url = ''
412 }
413
414 . $CSA_ROOT/lib/tpl-stuff.rc
415
416 if (!~ $'cgi.wikilinks' ()) {
417 csaMkTemp outfile
418 infile = $'tpl.include.tw.page'
419 tpl.include.tw.page = $outfile
420 }
421
422 if (~ $CSA_PGM(1) CSA2) {
423 tpl.include.tw.page = $'tpl.include.tw.page':p
424 } else tpl.include.tw.page = $'tpl.include.tw.page':c
425
426 # Create page widgets if necessary.
427
428 # Set target year/month for the calendar widget
429 if (~ $'tbl_page.p_vtime' ()) {
430 gencal_month = ($CSA_TIME_LOCAL(1) $CSA_TIME_LOCAL(2))
431 } else {
432 * = ``(-,){echo -n $'tbl_page.p_vtime'}
433 ~ $#* 4 && shift # strip ranking
434 gencal_month = $*
435 }
436
437 gencal_xml = $tw_gstem/cal-$gencal_month(1)^-$gencal_month(2)^+xml
438 genarch_xml = $tw_gstem/year-links+xml
439 gencat_xml = $tw_gstem/cat-links+xml
440
441 if (!csaIsFullPath --exists --quiet $gencal_xml $genarch_xml $gencat_xml) {
442
443 # Set Principal Lock Semaphore(s) (PLS).
444 csaLock $tw_gstem/page+dat || csaExit.fault
445 pls_set = true
446
447 # Create main table if it does not yet exist.
448 if (!csaIsFullPath --exists --quiet $tw_gstem/page+dat) {
449 maketable --input \
450 $CSA_ROOT/lib/page.xrf > $tw_gstem/page+dat ||
451 csaExit.fault 0003 maketable
452 }
453
454 gencal_rcs = $tw_gstem/RCS/cal-$gencal_month(1)^-$gencal_month(2)^+xml,v
455 genarch_rcs = $tw_gstem/RCS/year-links+xml,v
456 gencat_rcs = $tw_gstem/RCS/cat-links+xml,v
457
458 gencat_mt = $tw_gstem/cat-mt+xml
459 gencat_mw = $tw_gstem/cat-mw+xml
460
461 gencat_mt_rcs = $tw_gstem/RCS/cat-mt+xml,v
462 gencat_mw_rcs = $tw_gstem/RCS/cat-mw+xml,v
463
464 widget_input = $tw_gstem/page+dat
465
466 . $CSA_ROOT/lib/widgets.rc
467 }
468
469 tpl.include.tw.related = $tw_gstem/$'cgi.page'-rel+xml
470
471 # (re)build the "related links" view if necessary.
472 if (!~ $'tbl_page.k_page' () &&
473 csaIsFullPath --exists --quiet $tw_gstem/tag+dat && {
474 !csaIsFullPath --exists --quiet $'tpl.include.tw.related' || \
475 test $tw_gstem/tag+dat -nt $'tpl.include.tw.related'}) {
476
477 # Set Principal Lock Semaphore(s) (PLS) if not done yet.
478 csaTrue $pls_set || csaLock $tw_gstem/page+dat || csaExit.fault
479 pls_set = true
480
481 csaTrapFile $tw_gstem/RCS/$'cgi.page'-rel+xml,v
482 csaOpen --relaxed --fast $'tpl.include.tw.related' || csaExit.fault
483 tmp2 = $CSA_RESULT
484
485 csaAwkCmd pageRelatedPages.awk
486
487 # Note that the relation is established over *all* tags,
488 # whether they are keywords, geo- or local tags, with the
489 # latters being case-sensitive. It may be possible to
490 # handle correlations over local tags case-insensitively
491 # by using "sorttable -f" and "jointable -i", but this needs
492 # to be worked upon. This code needs to be extended to select
493 # the desired topology among the supported ones (keywords,
494 # geo-tag, etc.). This will be done by filtering the input
495 # tags based on the desired topology, and in case this is
496 # geo-tagging the '_awk' script below will compute the vector
497 # of each g:x:y tag and append an additional "tag_topology"
498 # column containing something like g:1234567. The resulting
499 # value will then be zeroed on the least significant digits,
500 # possibly based on a group+cf var that specifies the desired
501 # approximation, and turned into, say, g:1230000, so that
502 # "sorttable" can do its grouping work. This should do the trick.
503 # The "sorttable -u k_page" will probably have to be changed into
504 # "sorttable tag_topology", with "pageRelatedPages.awk" handling
505 # uniqueness internally. For other then geo topology, the
506 # "tag_topology" column will contain the relevant tag unchanged.
507
508 _awk '-vtags_='$'tbl_page.p_tags' -- 'BEGIN{
509 print "\001k_tag"
510 split(tags_,t_,/ +/)
511 for (i_ in t_) print t_[i_]
512 }' /dev/null | sorttable | jointable $tw_gstem/tag+dat |
513 sorttable -u k_page | $CSA_RESULT > $tmp2 ||
514 csaExit.fault 0003 _awk/sorttable/jointable/sorttable/AWK
515
516 do_commit = true
517 }
518
519 # Commit widget creation if necessary.
520 ~ $do_commit () || csaCommit || csaExit.fault
521
522 #if (~ $tpl_name tw-*) {
523 #
524 # # Page names beginning with tw-* are reserved for TW use, and usually
525 # # refer to views that do not correspond to actual pages on disk, so
526 # # we need to toggle unapplicable sections in templates.
527 #
528 # tpl.if.tw.ispage = '(::DEL:)'
529 # tpl.fi.tw.ispage = '(:DEL::)'
530 # tpl.if.tw.editor = '(::DEL:)'
531 # tpl.fi.tw.editor = '(:DEL::)'
532 #}
533
534 # Make sure no-replace mode is used on the page body by prepending
535 # its name with '-', or any user-supplied CSA tags in the text will
536 # be happily parsed by _envtoxml() !!
537
538 tpl.include.tw.page = -$'tpl.include.tw.page'
539
540 if (!~ $CSA_PGM(1) CSA2) {
541 csaMkTemp tpl.include.tw.page.^(header footer)
542 csaExit.ok $tpl_file
543 }
544
545 # RPC2 mode detected, behave accordingly.
546
547 if (~ $'cgi.numeric' ()) {
548 tpl.var.tw.node = ''$CSA_LANG/$'tpl.var.tw.group.unx'/$'tpl.var.tw.page.unx'^''
549 } else tpl.var.tw.node = ''$'tbl_page.k_node'^''
550
551 csaMkTemp tpl.include.tw.rpc
552
553 switch ($CSA_PGM($#CSA_PGM)) {
554
555 case blogger.*
556
557 cat <<'EOF' > $'tpl.include.tw.rpc' || csaExit.fault 0003 cat
558
559
560 content
561 $[tpl.include.tw.page]
562
563
564 userId
565 $[tpl.var.tw.page.creau:x]
566
567
568 postId
569 $[tpl.var.tw.node]
570
571
572 dateCreated
573 $[tpl.var.tw.page.ctime:x]
574
575
576 EOF
577
578 case metaWeblog.getPost
579
580 cat <<'EOF' > $'tpl.include.tw.rpc' || csaExit.fault 0003 cat
581
582
583 categories
584
585 $[tpl.var.tw.page.subcat:x]
586
587
588
589 description
590 $[tpl.include.tw.page]
591
592
593 link
594 $[tpl.var.tw.link:x]
595
596
597 userId
598 $[tpl.var.tw.page.creau:x]
599
600
601 postId
602 $[tpl.var.tw.node]
603
604
605 dateCreated
606 $[tpl.var.tw.page.ctime:x]
607
608
609 EOF
610
611 case mt.setPostCategories
612
613 # Although this is implemented as a dummy method (see below),
614 # strictly speaking it requires editing privileges.
615 ~ ,$TNS_AUTH_GRP, *,editor,* || csaExit.needauth
616 }
617
618 # Take a default OK exit even if none of the above switch cases matches,
619 # that is also in the case I have been called as mt.setPostCategories ,
620 # which TW implements as a dummy method.
621
622 csaExit.ok
623
624 # End of program.