Changeset 10322 for lang/perl/Moxy/branches
- Timestamp:
- 04/24/08 17:38:41 (5 years ago)
- Location:
- lang/perl/Moxy/branches/hsw
- Files:
-
- 4 modified
-
assets/plugins/QRCode/panel.tt (modified) (1 diff)
-
lib/Moxy.pm (modified) (4 diffs)
-
lib/Moxy/Plugin/LocationBar.pm (modified) (1 diff)
-
t/Plugin-Server-rewrite.t (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Moxy/branches/hsw/assets/plugins/QRCode/panel.tt
r10133 r10322 2 2 function __MOXY_insert_image() { 3 3 var qrdiv = document.getElementById('qrcode_placeholder'); 4 var url = "http://" + location.host + "/ ?moxy_q=" + encodeURIComponent("http://qrcode.moxy/[% current | uri %]");4 var url = "http://" + location.host + "/" + encodeURIComponent("http://qrcode.moxy/[% current | uri %]"); 5 5 qrdiv.innerHTML = "<img src='" + url + "' />"; 6 6 return false; -
lang/perl/Moxy/branches/hsw/lib/Moxy.pm
r10133 r10322 110 110 for my $node ( $tree->findnodes("//$tag") ) { 111 111 if ( my $attr = $node->attr($attr_name) ) { 112 my $uri = URI->new($attr)->abs($base_url);113 if ($tag eq 'form') {114 my $query = +{ $uri->query_form };115 while (my ($key, $val) = each %$query) {116 my $element = HTML::Element->new(117 'input',118 type => 'hidden',119 name => $key,120 value => $val121 );122 $node->push_content($element);123 }124 $uri->query_form({}); # strip query.125 }126 112 $node->attr( 127 $attr_name => sprintf( qq{%s ?moxy_q=%s},113 $attr_name => sprintf( qq{%s%s%s}, 128 114 $base, 129 uri_escape( $uri ) ) 115 ($base =~ m{/$} ? '' : '/'), 116 uri_escape( URI->new($attr)->abs($base_url) ) ) 130 117 ); 131 118 } … … 164 151 </head> 165 152 <body> 166 <form method="get" action="$base" >167 <input type="text" size="40" name="moxy_q"id="moxy_url" />153 <form method="get" action="$base" onsubmit="location.href=location.href+encodeURIComponent(document.getElementById('moxy_url').value);return false;"> 154 <input type="text" size="40" id="moxy_url" /> 168 155 <input type="submit" value="go" /> 169 156 </form> … … 194 181 my $auth = decode_base64($1); 195 182 $self->log(debug => "auth: $auth"); 196 my $url = uf_uristr(+{$uri->query_form()}->{moxy_q}); 183 (my $url = $uri->path_query) =~ s!^/!!; 184 $url = uf_uristr(uri_unescape $url); 197 185 $self->log(info => "REQUEST $auth, @{[ $url || '' ]}"); 198 186 my $response = $self->_make_response( … … 243 231 $location->port($uri->port); 244 232 } 245 $res->header( 'Location' => $base_url . '/ ?moxy_q=' . uri_escape( $location ) );233 $res->header( 'Location' => $base_url . '/' . uri_escape( $location ) ); 246 234 $self->log(debug => "redirect to " . $res->header('Location')); 247 235 } else { -
lang/perl/Moxy/branches/hsw/lib/Moxy/Plugin/LocationBar.pm
r10320 r10322 21 21 22 22 return sprintf(<<"...", encode_entities($current_url)); 23 <form method="get" style="width: 100%%;"> 24 <input type="text" value="\%s" size="40" name="moxy_q" /> 23 <script> 24 var moxy_base = location.protocol.replace(':', '') + '://' + location.host; 25 </script> 26 <form method="get" onsubmit="location.href=moxy_base +'/'+encodeURIComponent(document.getElementById('moxy_url').value);return false;"> 27 <input type="text" value="\%s" size="40" id="moxy_url" style="width:90%%;" /> 25 28 <input type="submit" value="go" /> 26 29 </form> -
lang/perl/Moxy/branches/hsw/t/Plugin-Server-rewrite.t
r10133 r10322 29 29 <a href="http://example.com/foo" title="foo">bar</a> 30 30 --- expected 31 <html><a href="http://localhost:9999/ ?moxy_q=http%3A%2F%2Fexample.com%2Ffoo" title="foo">bar</a></html>31 <html><a href="http://localhost:9999/http%3A%2F%2Fexample.com%2Ffoo" title="foo">bar</a></html> 32 32 33 33 === relative … … 35 35 <a href="/foo" title="foo">bar</a> 36 36 --- expected 37 <html><a href="http://localhost:9999/ ?moxy_q=http%3A%2F%2Frelative.example.jp%2Ffoo" title="foo">bar</a></html>37 <html><a href="http://localhost:9999/http%3A%2F%2Frelative.example.jp%2Ffoo" title="foo">bar</a></html> 38 38 39 39 === upper case tag … … 41 41 <A href="http://example.com/foo" title="foo">bar</A> 42 42 --- expected 43 <html><a href="http://localhost:9999/ ?moxy_q=http%3A%2F%2Fexample.com%2Ffoo" title="foo">bar</a></html>43 <html><a href="http://localhost:9999/http%3A%2F%2Fexample.com%2Ffoo" title="foo">bar</a></html> 44 44 45 45 === … … 47 47 <a href="http://example.com/foo">bar</a> 48 48 --- expected 49 <html><a href="http://localhost:9999/ ?moxy_q=http%3A%2F%2Fexample.com%2Ffoo">bar</a></html>49 <html><a href="http://localhost:9999/http%3A%2F%2Fexample.com%2Ffoo">bar</a></html> 50 50 51 51 === no href. … … 59 59 <form method="post" action="http://example.com/search"><input type="submit" value="go" /></form> 60 60 --- expected 61 <html><form action="http://localhost:9999/?moxy_q=http%3A%2F%2Fexample.com%2Fsearch" method="post"><input type="submit" value="go" /></form></html> 62 63 === form with query 64 --- input 65 <form method="post" action="http://example.com/search?k=foo"><input type="submit" value="go" /></form> 66 --- expected 67 <html><form action="http://localhost:9999/?moxy_q=http%3A%2F%2Fexample.com%2Fsearch" method="post"><input type="submit" value="go" /><input name="k" type="hidden" value="foo" /></form></html> 61 <html><form action="http://localhost:9999/http%3A%2F%2Fexample.com%2Fsearch" method="post"><input type="submit" value="go" /></form></html> 68 62 69 63 === relative … … 71 65 <form method="post" action="/search"><input type="submit" value="go" /></form> 72 66 --- expected 73 <html><form action="http://localhost:9999/ ?moxy_q=http%3A%2F%2Frelative.example.jp%2Fsearch" method="post"><input type="submit" value="go" /></form></html>67 <html><form action="http://localhost:9999/http%3A%2F%2Frelative.example.jp%2Fsearch" method="post"><input type="submit" value="go" /></form></html> 74 68 75 69 === relative img … … 77 71 <img src="/foo.jpg" /> 78 72 --- expected 79 <html><img src="http://localhost:9999/ ?moxy_q=http%3A%2F%2Frelative.example.jp%2Ffoo.jpg" /></html>73 <html><img src="http://localhost:9999/http%3A%2F%2Frelative.example.jp%2Ffoo.jpg" /></html> 80 74 81 75 === abs img … … 83 77 <img src="http://example.com/bar.jpg"> 84 78 --- expected 85 <html><img src="http://localhost:9999/ ?moxy_q=http%3A%2F%2Fexample.com%2Fbar.jpg" /></html>79 <html><img src="http://localhost:9999/http%3A%2F%2Fexample.com%2Fbar.jpg" /></html> 86 80
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)