From 546713b0d6dd6e5d796e9e5544f81249679f3baa Mon Sep 17 00:00:00 2001 From: Uriel Date: Mon, 28 May 2007 04:07:40 +0200 Subject: [PATCH] A bunch of stuff before breaking things up --- bin/controller.rc | 52 ++++++++++++++++++++++++++++++++++++++++--- bin/sidebar.tpl | 1 + etc/initrc | 3 ++- pub/sitemap.txt | 11 ++++++--- pub/style/style.css | 4 ++++ tpl/_inc/sidebar.tpl | 35 ----------------------------- tpl/default.tpl | 13 ++++------- tpl/software/index.md | 1 + tpl/software/xml.md | 5 ++++- 9 files changed, 73 insertions(+), 52 deletions(-) create mode 100644 bin/sidebar.tpl delete mode 100644 tpl/_inc/sidebar.tpl diff --git a/bin/controller.rc b/bin/controller.rc index dfecc35..b67cf95 100755 --- a/bin/controller.rc +++ b/bin/controller.rc @@ -9,6 +9,8 @@ cd .. # config body=index +siteTitle='' +siteSubTitle='' title=Title template=default sidebar=sidebar @@ -17,6 +19,7 @@ sidebar=sidebar if (! ~ $#args 0 && ! ~ $args '') { title=$args($#args) + title=`{echo $title | sed 's/_/ /' } body=`{ echo -n $"args |sed 's, ,/,g' } } @@ -36,9 +39,52 @@ if (test -d tpl/$body) { body=`{echo tpl/^$"body^.md | sed 's, ,/,' } +# Sidebar +fn menu { + ls -F $1 | sed -e 's,^./,,' -e 's,\.md$,,' | grep -v '^_'| awk ' + BEGIN { print "" } + /^([a-zA-Z0-9_\-]+[\/*]?)+$/ && ! /index$/ { + isdir = match($0, "/$") + sub("[*/]$", "") # The '*' makes no sense to me + + if(isdir) + d = "/" + bname = $0 + sub("^(.*/)?([0-9]+_)?", "", bname) + gsub("_", " ", bname) + + bname = bname d + + if(index(ENVIRON["REQUEST_URI"], "/" $0) == 1) { + if(isdir) { + print "
  • » " bname "" + system("rc -c ''menu " $0 "''") + } else { + print "
  • » " bname "" + } + } else + print "
  • › " bname "" + + print "
  • " + + }' + +} + +fn gensidebar { + echo '

    Considered harmful:

    ' + cd tpl + menu . + cd .. +} + + +# Body + template.awk $template | rc -echo '
    '
    -#echo $"args
    -#env
     
    +# Debug junk
    +#echo '
    '
    +#env
    diff --git a/bin/sidebar.tpl b/bin/sidebar.tpl
    new file mode 100644
    index 0000000..8b13789
    --- /dev/null
    +++ b/bin/sidebar.tpl
    @@ -0,0 +1 @@
    +
    diff --git a/etc/initrc b/etc/initrc
    index 67fcf1d..77349ad 100644
    --- a/etc/initrc
    +++ b/etc/initrc
    @@ -1,2 +1,3 @@
     title=cat-v
    -sitetitle=harmful.cat-v.org
    +siteTitle='cat-v'
    +siteSubTitle='Considered harmful'
    diff --git a/pub/sitemap.txt b/pub/sitemap.txt
    index d06b93d..bafe423 100644
    --- a/pub/sitemap.txt
    +++ b/pub/sitemap.txt
    @@ -1,10 +1,15 @@
     http://harmful.cat-v.org/
    +http://harmful.cat-v.org/society/sweden
    +http://harmful.cat-v.org/society/children/
    +http://harmful.cat-v.org/society/children/fuck_the_children
    +http://harmful.cat-v.org/society/children/i_dont_care
     http://harmful.cat-v.org/cat-v/
    +http://harmful.cat-v.org/software/firefox
     http://harmful.cat-v.org/software/
     http://harmful.cat-v.org/software/xml
    -http://harmful.cat-v.org/children/
    -http://harmful.cat-v.org/children/fuck_the_children
    -http://harmful.cat-v.org/children/i_dont_care
    +http://harmful.cat-v.org/software/object_oriented_programming
    +http://harmful.cat-v.org/science/global_warming
    +http://harmful.cat-v.org/economics/intellectual_property
     http://harmful.cat-v.org/economics/subsidies
     http://harmful.cat-v.org/economics/
     http://harmful.cat-v.org/economics/minimum_wage
    diff --git a/pub/style/style.css b/pub/style/style.css
    index 3c160bf..8e38766 100644
    --- a/pub/style/style.css
    +++ b/pub/style/style.css
    @@ -83,6 +83,10 @@ acronym, .titleTip {
       font-style: italic;
     }
     
    +.headerTitle a {
    +    color: black;
    +    text-decoration: none;
    +}
     
     .subHeader {
     display: none;
    diff --git a/tpl/_inc/sidebar.tpl b/tpl/_inc/sidebar.tpl
    deleted file mode 100644
    index 6602701..0000000
    --- a/tpl/_inc/sidebar.tpl
    +++ /dev/null
    @@ -1,35 +0,0 @@
    -echo '

    Considered harmful:

    ' -fn menu { - ls -F $1 | sed -e 's,^./,,' -e 's,\.md$,,' | grep -v '^_'| awk ' - BEGIN { print "
      " } - END { print "
    " } - /^([a-zA-Z0-9_\-]+[\/*]?)+$/ && ! /index$/ { - isdir = match($0, "/$") - sub("[*/]$", "") # The '*' makes no sense to me - - if(isdir) - d = "/" - bname = $0 - sub("^(.*/)?([0-9]+_)?", "", bname) - gsub("_", " ", bname) - - bname = bname d - - if(index(ENVIRON["REQUEST_URI"], "/" $0) == 1) { - if(isdir) { - print "
  • » " bname "" - system("rc -c ''menu " $0 "''") - } else { - print "
  • » " bname "" - } - } else - print "
  • › " bname "" - - print "
  • " - - }' - -} -cd tpl -menu . -cd .. diff --git a/tpl/default.tpl b/tpl/default.tpl index fa41ec1..109a791 100644 --- a/tpl/default.tpl +++ b/tpl/default.tpl @@ -8,11 +8,10 @@ Content-Type: text/html -% echo ''$title'' +% echo ''$"title' - '$"siteTitle'' - - + @@ -37,7 +36,7 @@ Content-Type: text/html
    -

    cat-v Considered harmful

    +%echo '

    '$"siteTitle' '$"siteSubTitle'

    '
    @@ -47,9 +46,8 @@ Content-Type: text/html %if (! ~ $#sidebar 0) {