File: Cgi_ja

package info (click to toggle)
amrita 1.0.2-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 1,880 kB
  • ctags: 1,363
  • sloc: ruby: 9,159; xml: 978; makefile: 111
file content (133 lines) | stat: -rw-r--r-- 3,634 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

= amritaCGIǻȤ

== ά

ΥɥȤϡĤΥץ򼨤amritaCGIǻȤˡޤ
ץȤƥ֥åޡΥƥȤޤ

ΥץϲURLǥǥ⤷Ƥޤ

http://www.walrus-ruby.org/amrita/

== ǥ륯饹

ǽ˥ǥ륯饹ޤ

  :include: sample/cgi/bmmodel.rb

+Item+ Ȥ饹ϥ֥åޡιܤбޤ
Υ饹ˤϡgroup, name, url. Ȥ3ĤΥȥӥ塼Ȥ¸ߤޤ

+BookmarkList+  +Item+ νޤǤ
롼פȤˤĤ +Item+ ݻƤơ
ե¸ɤǤޤ

Υǥ륯饹HTML˴ؤޤǤޤ
ΤᡢźդΥƥȥץȤΤ褦˴ñ˥˥åȥƥȤ򤹤뤳ȤǤޤ

== bookmark.cgi

bookmark.cgi ϥ֥åޡɽơȥ꡼ϤĤޤ

=== ƥץ졼ȥե

bookmark.cgi ϤΥƥץ졼ȤѤޤ

  :include: sample/cgi/bookmark.html

=== 

줬 bookmark.cgi ΥɤǤ

  :include: sample/cgi/bookmark.cgi

=== եǤ

ܤϤΥ롼פϡ
ǸϤ롼̾ǥեȤꤵƤޤ
νԤʤäƤΤϤǤ

    :form => {
      :group_sel=>e(:select, :name=>"group_sel") {
        groups.collect do |g|
          if g == selected_group
            e(:option, :value=>g, :selected=>"selected") { g }
          else
            e(:option, :value=>g) { g }
          end
        end
      },
    }

ΥɤʲHTMLޤ

   <td>
     <select name="group_sel">
       <option value="BBS">BBS</option>
       <option value="Script Languages" selected="selected">Script Languages</option>
       <option value="TestXSS">TestXSS</option>
     </select>
   </td>

HTMLƥץ졼 +group_sel+ бޤ

=== ѥѤ

  Amrita::TemplateFileWithCache::set_cache_dir(CACHE_PATH)
  tmpl = Amrita::TemplateFileWithCache[TEMPLATE_PATH]
  tmpl.use_compiler = true
  tmpl.expand($stdout, make_model_data(bm,group))

Amrita::TemplateFileWithCache  Amrita::TemplateFile 
ѥ뤵줿ɤ򥭥å夷ƺѤ뵡ǽɲäΤǤ

+CACHE_PATH+ +TEMPLATE_PATH+ б륭åǡ¸ߤ
ƥץ졼Ȥ꿷СΥѥ뤵줿ɤưŪ˺Ѥޤ

<em>ա Υǥ쥯ȥ¾Υ桼Ǥʤ褦˳μ¤ꤷƤ</em>

ΥСǤϡamritaϥåƤåޤ
⤷amritaǤդΥɤ¹Ԥ뤳Ȥǽˤʤä˴Ǥ

εҤǤʤϡ<tt>TemplateFileWithCache::set_cache_dir</tt>ϻѤʤǤ

---

== Amrita Script CGIǻѤ

AmritaScriptǽ񤫤줿֥åޡɽץǤ

  :include: sample/cgi/bookmark.ams

apache۲Ǽ¹Ԥˤ

  * httpd.conf<tt>AllowOverride FileInfo</tt>  <tt>Options ExecCGI</tt> +cgi-bin+ ǥ쥯ȥꤷƤ

  * bin/amshandler򤽤Υǥ쥯ȥ˥ԡƤ

  * .htaccess ˰ʲεҤɲäޤ

    AddHandler amrita-script ams
    Action amrita-script /amrita/cgi-bin/amshandler

---

== bookmark.cgi  mod_ruby ǻѤ

bookmark.cgi  mod_ruby۲Ǽ¹Ԥ뤳ȤǤޤ
httpd.conf˲λԤʤäƤ

  LoadModule ruby_module /usr/lib/apache/mod_ruby.so
  RubyRequire apache/ruby-run

  Alias /amrita/cgi-bin/ /home/tnaka/cvswork/amrita/sample/cgi/

  <Location /amrita/cgi-bin>
    Options ExecCGI
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance

    SetEnv AmritaCacheDir /tmp/bookmark # be careful
  </Location>