Changeset 23419
- Timestamp:
- 11/12/08 21:50:52 (5 years ago)
- Location:
- lang/perl/MENTA/trunk
- Files:
-
- 1 added
- 5 modified
-
app/index.cgi (modified) (1 diff)
-
app/tmpl/index.html (modified) (1 diff)
-
app/tmpl/users.html (modified) (1 diff)
-
lib/MENTA.pm (modified) (4 diffs)
-
lib/MENTA/Builder.pm (modified) (1 diff)
-
out/static/jquery.js (added)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/MENTA/trunk/app/index.cgi
r23415 r23419 21 21 # あなたのアプリの設定 22 22 application => { 23 title => "MENTA サンプルアプリ", 23 docroot => '', 24 title => 'MENTA サンプルアプリ', 24 25 }, 25 26 }); -
lang/perl/MENTA/trunk/app/tmpl/index.html
r23372 r23419 1 % my $docroot = config()->{application}->{docroot} 2 % my $title = config()->{application}->{title} 1 3 <!doctype html> 2 <title><%= config()->{application}->{title}%></title>3 <link rel="stylesheet" type="text/css" href=" /static/style-sites.css">4 <script type="text/javascript" src=" /static/jquery-latest.js"></script>5 <script type="text/javascript"> 4 <title><%= $title %></title> 5 <link rel="stylesheet" type="text/css" href="<%= $docroot %>static/style-sites.css"> 6 <script type="text/javascript" src="<%= $docroot %>static/jquery.js"></script> 7 <script type="text/javascript"><!-- 6 8 $(function() { 7 9 var $this = $('h1'); 8 10 $this.css({background : 'orange'}).text($this.text().replace('MENTA', 'めんた')); 9 11 }); 10 </script> 11 <h1><%= config()->{application}->{title} %></h1> 12 //--></script> 13 14 <h1><%= $title %></h1> 12 15 <p><%= localtime time %></p> -
lang/perl/MENTA/trunk/app/tmpl/users.html
r23414 r23419 1 % my $docroot = config()->{application}->{docroot} 2 % my $title = config()->{application}->{title} . ' users' 1 3 <!doctype html> 2 <title><%= config()->{application}->{title} %></title> 3 <link rel="stylesheet" type="text/css" href="/static/style-sites.css"> 4 <h1><%= config()->{application}->{title} %></h1> 4 <title><%= $title %></title> 5 <link rel="stylesheet" type="text/css" href="<%= $docroot %>static/style-sites.css"> 6 7 <h1><%= $title %></h1> 5 8 <table border="1"> 6 <% for my $a (@{$_[0]}) { %> 7 <tr>8 <td><%= $a->{id} %></td><td><%= $a->{name} %></td>9 </tr>10 <% } %> 9 % for my $a (@{$_[0]}) { 10 <tr> 11 <td><%= $a->{id} %></td><td><%= $a->{name} %></td> 12 </tr> 13 % } 11 14 </table> -
lang/perl/MENTA/trunk/lib/MENTA.pm
r23408 r23419 30 30 my $config = config(); 31 31 if (! $config) { 32 die "config() でアプリケーション設定がされていません!";32 die "config() でアプリケーション設定がされていません!"; 33 33 } 34 34 … … 56 56 } 57 57 58 my $static_file = $ENV{PATH_INFO} || ''; 59 $static_file =~ s!^/*!!g; 60 if ($static_file !~ /index\.cgi/ && -f $static_file) { 61 if (open my $fh, '<', $static_file) { 62 printf "Content-Type: %s\n\n", guess_mime_type($static_file); 63 print do { local $/; <$fh> }; 64 close $fh; 65 } else { 66 die "ファイルが見つかりません"; 58 if (my $static_file = $ENV{PATH_INFO}) { 59 $static_file =~ s!^/+!!g; 60 if ($static_file !~ /\bindex\.cgi\b/ && -f $static_file) { 61 if (open my $fh, '<', $static_file) { 62 printf "Content-Type: %s\r\n\r\n", guess_mime_type($static_file); 63 print do { local $/; <$fh> }; 64 close $fh; 65 return 1; 66 } else { 67 die "ファイルが開きません"; 68 } 69 } 70 } 71 72 my $mode = $MENTA::REQ->{mode} || 'index'; 73 my $meth = "do_$mode"; 74 if (my $code = main->can($meth)) { 75 $code->($MENTA::REQ); 76 unless ($MENTA::FINISHED) { 77 die "なにも出力してません"; 67 78 } 68 79 } else { 69 my $mode = $MENTA::REQ->{mode} || 'index'; 70 my $meth = "do_$mode"; 71 if (my $code = main->can($meth)) { 72 $code->($MENTA::REQ); 73 unless ($MENTA::FINISHED) { 74 die "なにも出力してません"; 75 } 76 } else { 77 die "'$mode' というモードは存在しません"; 78 } 80 die "「$mode」というモードは存在しません"; 79 81 } 80 82 }; … … 91 93 if ($config->{menta}->{kcatch_mode}) { 92 94 $err = escape_html($err); 93 qq{<html><body style="background: red; color: white "><p>500 Internal Server Error: $err</p></body></html>\n};95 qq{<html><body style="background: red; color: white; font-weight: bold"><p><span style="font-size: xx-large; color: black">☠</span> 500 Internal Server Error <span style="font-size: xx-large; color: black">☠</span>: $err</p></body></html>\n}; 94 96 } else { 95 qq{<html><body style="background: red; color: white"><p>500 Internal Server Error</p></body></html>\n};97 qq{<html><body><p style="color: red">500 Internal Server Error</p></body></html>\n}; 96 98 } 97 99 }; … … 143 145 $out = $tmplcode->(@params); 144 146 } else { 145 die " $tmplfnameという名前のテンプレートファイルは見つかりません" unless -f $tmplfname;147 die "「$tmplfname」という名前のテンプレートファイルは見つかりません" unless -f $tmplfname; 146 148 require MENTA::Template; 147 149 my $tmplsrc = read_file($tmplfname); -
lang/perl/MENTA/trunk/lib/MENTA/Builder.pm
r23408 r23419 35 35 my $one_level = 4; 36 36 my $indent = ' ' x ($indent_level*$one_level); 37 "{\n$indent" . join("\n$indent", split("\n", read_file($fname))) . "\n" . (' ' x (($indent_level-1)*$one_level)) . "}\n"; 37 "{\n" . join("\n", grep { /^\s*$/ or $_ = $indent . $_; 1 } 38 split("\n", read_file($fname))) 39 . "\n" . (' ' x (($indent_level-1)*$one_level)) . "}\n"; 38 40 } 39 41
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)