shithub: werc

Download patch

ref: 76e8e46c46f9df6b92fd71fa286d93d113a95128
parent: 34b35d8c322ecb483aea09e4816b21da70767756
author: uriel <uriel@engel.se.cat-v.org>
date: Fri Mar 13 09:04:25 EDT 2009

Reorg headers, http headers now are echo-ed from werc.rc instead of being part of headers.tpl.
This fixes some bugs in the handling HEAD and makes things a bit more clear.

--- a/apps/blagh/app.rc
+++ b/apps/blagh/app.rc
@@ -35,10 +35,10 @@
 <link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" />'
         }
         if not if(~ $req_path $blagh_uri^index.atom)
-            blagh_setup_feed_handlers atom.tpl
+            blagh_setup_feed_handlers atom.tpl 'application/atom+xml'
 
         if not if(~ $req_path $blagh_uri^index.rss)
-            blagh_setup_feed_handlers rss20.tpl
+            blagh_setup_feed_handlers rss20.tpl 'text/xml; charset=utf-8'
 
         if not if(~ $req_path $blagh_uri^new_post && ! ~ $#editor_mode 0) {
             handler_body_main=( tpl_handler `{get_lib_file blagh/new_post.tpl apps/blagh/new_post.tpl} )
@@ -56,6 +56,7 @@
 fn blagh_setup_feed_handlers {
     handler_body_main=NOT_USED_by_blagh_feeds
     res_tail=()
+    http_content_type=$2
     headers=()
     master_template=apps/blagh/$1 # Should we allow tempalte override?
 }
--- a/apps/blagh/atom.tpl
+++ b/apps/blagh/atom.tpl
@@ -1,5 +1,3 @@
-Content-Type: application/atom+xml
-
 <?xml version="1.0" encoding="utf-8"?>
 
 %{
--- a/apps/blagh/rss20.tpl
+++ b/apps/blagh/rss20.tpl
@@ -1,5 +1,3 @@
-Content-Type: text/xml; charset=utf-8
-
 <?xml version="1.0" encoding="UTF-8"?>
 
 %{
--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -19,6 +19,7 @@
 
 headers=lib/headers.tpl
 res_tail='</body></html>'
+http_content_type='text/html'
 ll_add handlers_bar_left nav_tree
 werc_apps=( apps/* )
 werc_root=`{pwd}
@@ -112,9 +113,16 @@
 
     setup_handlers
 
+    for(h in $extraHttpHeaders)
+        echo $h
+    echo 'Content-Type: '^$http_content_type
+    if(~ $REQUEST_METHOD HEAD)
+        exit
+
     if(! ~ $#debug 0)
         dprint $"SERVER_NAME^$"REQUEST_URI - $"HTTP_USER_AGENT - $"REQUEST_METHOD - $"handler_body_main - $"master_template
 
+    
     template $headers $master_template | awk_buffer
     echo $res_tail
 }
--- a/lib/default_master.tpl
+++ b/lib/default_master.tpl
@@ -1,4 +1,3 @@
-
 <div id="header">
     <div class="superHeader">
 % cat `{ get_lib_file top_bar.inc }
--- a/lib/headers.tpl
+++ b/lib/headers.tpl
@@ -1,8 +1,3 @@
-% for(h in $extraHttpHeaders) echo $h
-Content-Type: text/html
-% if(~ $REQUEST_METHOD HEAD)
-%   exit
-
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -11,7 +6,13 @@
 
     <title>%($pageTitle%)</title>
 
+    <link rel="stylesheet" href="/pub/style/style.css" type="text/css" media="screen, handheld" title="default" />
+    <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />
+% if(test -f $sitedir/_werc/pub/style.css)
+%    echo '    <link rel="stylesheet" href="/_werc/pub/style.css" type="text/css" media="screen" title="default" />'
+
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+
     <meta name="author" content="k" />
 
 % if(! ~ $#meta_description 0)
@@ -18,11 +19,6 @@
 %   echo '    <meta name="description" content="'$"meta_description'" />'
 % if(! ~ $#meta_keywords 0)
 %   echo '    <meta name="keywords" content="'$"meta_keywords'" />'
-
-    <link rel="stylesheet" href="/pub/style/style.css" type="text/css" media="screen, handheld" title="default" />
-    <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />
-% if(test -f $sitedir/_werc/pub/style.css)
-%    echo '    <link rel="stylesheet" href="/_werc/pub/style.css" type="text/css" media="screen" title="default" />'
 
 % h = `{get_lib_file headers.inc}
 % if(! ~ $#h 0)