File: autohandler

package info (click to toggle)
libhtml-mason-perl 1%3A1.26-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,636 kB
  • ctags: 1,260
  • sloc: perl: 13,880; sh: 154; makefile: 47
file content (87 lines) | stat: -rw-r--r-- 2,359 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Mason: <% $title %></title>
<link rel="alternate stylesheet" title="Dark" type="text/css" href="lib/dark.css">
<link rel="stylesheet" title="Light" type="text/css" href="lib/light.css">
</head>
<body>
<h1><% $title %></h1>

% if ($m->request_comp->source_file !~ m|/index.html$|) {
<p> <a href="./">Back to index</a> </p>
% }

<div class=outer>
<div class=component>
% $m->call_next;
</div>
</div>

<hr>
<table width="100%" class=footertable><tr valign=top><td align=left>
<div class=poweredby>
<a href="http://www.masonhq.com/"><img width="88" height="31" border="0" src="http://www.masonhq.com/i/powered_by_mason.jpg" alt="Powered by Mason"></a>
</div>
</td><td align=right>
<div class=footer>
% if ($ENV{REMOTE_USER}) {
You are logged in as &quot;<% $r->connection->user |h%>&quot;<br>
% }
#<% $ENV{UNIQUE_ID} %>
</div>
</td></tr></table>

</body>
</html>

<%init>
 my $next = $m->request_comp;
 # On mod_perl, $r->content_type contains Apache's (well, mod_mime's) idea of the content type
 if ($m->isa('HTML::Mason::Request::ApacheHandler')) {
   return $m->call_next if ($r->content_type eq 'text/css' || $next->attr_exists('no_autoheader'));
 }
 else {
   # Otherwise, use CGI variables and assumptions about file mapping to do this
   if ($ENV{REQUEST_URI} =~ /\.css/ || $next->attr_exists('no_autoheader')) {
     $r->content_type("text/css");
     return $m->call_next;
   }
 }
 my $title = $next->attr_exists("title") ? $next->attr("title") : $ENV{REQUEST_URI};
 $r->content_type("text/html; charset=utf-8");
</%init>

<%def .negotiate_content>
<%args>
$accept
%provide
</%args>
<%init>
my $q = 1;
my %accept_items;
my %result_items;
for my $el (split(/, */, $accept)) {
  my $item;
  if ($el =~ m/^(\S+); *q=([0-9.]+)/) {
    $item = $1;
    $q = $2;
  }
  else {
    $item = $el;
  }
  $accept_items{lc($item)} = $q;
}
for my $item (sort keys %provide) {
  if ($accept_items{$item}) {
    $result_items{$item} = $provide{$item}*$accept_items{$item};
  }
  elsif ($accept_items{'*'}) {
    $result_items{$item} = $provide{$item}*$accept_items{'*'};
  }
}
my @result = sort { $result_items{$b} <=> $result_items{$a} } keys %result_items;
$r->log->debug("Chose '$result[0]' from '$accept'");
return $result[0];
</%init>
</%def>