• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂54 (tree)
時間2008-03-04 23:10:21
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/test/test_xml.rb (revision 53)
+++ trunk/test/test_xml.rb (revision 54)
@@ -55,7 +55,7 @@
5555 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5656 <html lang="ja" xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml">
5757 <head>
58- <title>Title Text</title>
58+ <title>Title&nbsp;Text</title>
5959 <link href="/style.css" rel="stylesheet" type="text/css" />
6060 <script type="text/javascript"></script>
6161 <script type="text/javascript">
@@ -67,8 +67,8 @@
6767 </script>
6868 </head>
6969 <body>
70- <h1 class="title">H1 Text</h1>
71- <p>&quot;a&quot;, &lt;b&gt; and &#039;c&#039;</p>
70+ <h1 class="title">H1&nbsp;Text</h1>
71+ <p>&quot;a&quot;,&nbsp;&lt;b&gt;&nbsp;and&nbsp;&#039;c&#039;</p>
7272 <!--
7373 Comment Text
7474 -->Text<![CDATA[CDATA Text]]>Text</body>
@@ -76,10 +76,10 @@
7676 END
7777
7878 xml =<<END
79-<?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"><html lang="ja" xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml"><head><title>Title Text</title><link href="/style.css" rel="stylesheet" type="text/css" /><script type="text/javascript"></script><script type="text/javascript">function hello() {
79+<?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"><html lang="ja" xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml"><head><title>Title&nbsp;Text</title><link href="/style.css" rel="stylesheet" type="text/css" /><script type="text/javascript"></script><script type="text/javascript">function hello() {
8080 alert('Hello');
8181 }
82-</script></head><body><h1 class="title">H1 Text</h1><p>&quot;a&quot;, &lt;b&gt; and &#039;c&#039;</p><!-- Comment Text -->Text<![CDATA[CDATA Text]]>Text</body></html>
82+</script></head><body><h1 class="title">H1&nbsp;Text</h1><p>&quot;a&quot;,&nbsp;&lt;b&gt;&nbsp;and&nbsp;&#039;c&#039;</p><!-- Comment Text -->Text<![CDATA[CDATA Text]]>Text</body></html>
8383 END
8484
8585 #puts(@xml.to_xml)
--- trunk/test/test_wiki.rb (revision 53)
+++ trunk/test/test_wiki.rb (revision 54)
@@ -64,7 +64,7 @@
6464 </ol>
6565 <dl>
6666 <dt>aaa</dt>
67- <dd>a description</dd>
67+ <dd>a&nbsp;description</dd>
6868 <dt>bbb</dt>
6969 <dd>b:description</dd>
7070 </dl>
@@ -73,7 +73,7 @@
7373 <p>aaabbbccc</p>
7474 <dl>
7575 <dt>aaa</dt>
76- <dd>a description</dd>
76+ <dd>a&nbsp;description</dd>
7777 <dt>bbb</dt>
7878 <dd>b:description</dd>
7979 </dl>
--- trunk/Rakefile (revision 53)
+++ trunk/Rakefile (revision 54)
@@ -469,6 +469,7 @@
469469
470470 def server(name)
471471 model do |m|
472+ m['service'].pub_dir = File.dirname(__FILE__) + '/pub'
472473 Tenarai::Server.new(@config[:server]) do |request, response|
473474 m['service'].dispatch(m, request, response)
474475 m.refresh
--- trunk/webapp/Service.rb (revision 53)
+++ trunk/webapp/Service.rb (revision 54)
@@ -13,7 +13,7 @@
1313 end
1414
1515 class Redirect < Error
16- def initialize(url, code=303)
16+ def initialize(url, code=302)
1717 super()
1818 @code = code
1919 @url = url
@@ -50,7 +50,7 @@
5050 @response = response
5151
5252 method = (@request.method || 'get').downcase
53- ws, rs = {}, {}
53+ ws, rs, qs = {}, {}, {}
5454
5555 if method == 'get'
5656 @request.query
@@ -68,6 +68,8 @@
6868 key = nil
6969 rs[wid] ||= {}
7070 rs[wid] = val
71+ else
72+ qs[key] = val
7173 end
7274 end
7375
@@ -104,7 +106,7 @@
104106 end
105107 end
106108
107- widget.__send__(method, self)
109+ widget.__send__(method, self, qs)
108110 end
109111 rescue Error => err
110112 err.exec(self)
--- trunk/webapp/Widget/HTML.rb (revision 53)
+++ trunk/webapp/Widget/HTML.rb (revision 54)
@@ -15,13 +15,13 @@
1515 case markup
1616 when 'html'
1717 @markup = markup
18- content = 'text/html'
18+ content = 'text/html; charset=utf-8'
1919 when 'css'
2020 @markup = markup
21- content = 'text/css'
21+ content = 'text/css; charset=utf-8'
2222 else
2323 @markup = 'html'
24- content = 'text/html'
24+ content = 'text/html; charset=utf-8'
2525 end
2626
2727 service.response['content-type'] = content
@@ -53,7 +53,6 @@
5353 'lang' => 'ja'
5454 ) do |html|
5555 html.tag('head') do |head|
56- render_html_head(head, builder)
5756 head.tag(
5857 'link',
5958 'rel' => 'stylesheet',
@@ -60,6 +59,7 @@
6059 'type' => 'text/css',
6160 'href' => url('css')
6261 )
62+ render_html_head(head, builder)
6363 end
6464 html.tag('body', 'id' => html_id) do |body|
6565 super(body, builder)
--- trunk/webapp/ServiceTable.rb (revision 53)
+++ trunk/webapp/ServiceTable.rb (revision 54)
@@ -5,6 +5,8 @@
55 class ServiceTable < Tenarai::DB::Table
66 extend Tenarai::ClassLoader
77
8+ attr_accessor :pub_dir
9+
810 def fetch_by_name(name)
911 query('WHERE name = ?', name) do |service|
1012 return service
@@ -13,6 +15,31 @@
1315
1416 def dispatch(model, request, response)
1517 _nil, name, *param = request['path_info'].split('/')
16- fetch_by_name(name || 'index').dispatch(model, param, request, response)
18+ if s = fetch_by_name(name || 'index')
19+ response.code = 200
20+ s.dispatch(model, param, request, response)
21+ else
22+ response.code = 404
23+ if @pub_dir
24+ file = File.expand_path(@pub_dir + request['path_info'])
25+ if %r!^#{@pub_dir}!.match(file) && File.file?(file)
26+ ct = case File.extname(file).downcase
27+ when '.txt'
28+ 'text/plain'
29+ when '.js'
30+ 'text/javascript'
31+ when '.css'
32+ 'text/css'
33+ when '.swf'
34+ 'application/x-shockwave-flash'
35+ end
36+ unless ct.nil?
37+ response.code = 200
38+ response['content-type'] = ct
39+ response.body << File.open(file).read
40+ end
41+ end
42+ end
43+ end
1744 end
1845 end
Show on old repository browser