Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion META.info
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name" : "November",
"version" : "*",
"description" : "A wiki engine written in Perl 6",
"depends" : ["HTML::Template"],
"depends" : ["HTML::Template" , "Digest::MD5", "URI" ],
"repo-type" : "git",
"repo-url" : "git://github.com/viklund/november.git"
}
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ SOURCES = \
lib/November/Storage.pm \
lib/November/Storage/File.pm \
lib/November/Tags.pm \
lib/November/URI.pm \
lib/November/URI/Grammar.pm \
lib/November/Utils.pm \
lib/November/Utils.pm \
lib/Test/CGI.pm \
Expand Down
8 changes: 4 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ See instructions on the Rakudo web site:

<http://rakudo.org/how-to-get-rakudo>

You'll also need the projects listed in deps.proto, presently only
HTML::Template. It is preferrable to build HTML::Template before building
November.
You'll also need the projects listed in META.info including HTML::Template,
Digest::MD5, and URI. It is preferrable to build HTML::Template before
building November.

$ pwd
/tmp
$ git clone git://github.com/viklund/november.git
$ git clone git://github.com/masak/html-template.git
$ export RAKUDO_DIR=$PARROT_DIR/languages/rakudo
$ export PERL6LIB=$RAKUDO_DIR:/tmp/november/lib:/tmp/html-template/lib
$ export PERL6LIB=$RAKUDO_DIR:/tmp/november/lib:/tmp/html-template/lib:/tmp/perl6-digest-md5/lib/:/tmp/uri/lib
$ cd html-template/
$ perl Makefile.PL
$ make
Expand Down
4 changes: 2 additions & 2 deletions lib/November.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class November does November::Session does November::Cache {
['all'], { self.list_all_pages },
];

my @chunks = $cgi.uri.chunks.list;
$d.dispatch(@chunks);
my @segments = $cgi.uri.segments.list;
$d.dispatch(@segments);
}

# RAKUDO: Should `is rw` work with constant defaults? (It doesn't.)
Expand Down
62 changes: 9 additions & 53 deletions lib/November/CGI.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use v6;
use November::URI;
use URI;
use URI::Escape;

class November::CGI {
has %.params;
has %.cookie;
has @.keywords;
has November::URI $.uri;
has URI $.uri;

has $!crlf = "\x[0D]\x[0A]";

Expand Down Expand Up @@ -38,7 +39,7 @@ class November::CGI {
$uri_str ~= ':' ~ %*ENV<SERVER_PORT> if %*ENV<SERVER_PORT>;
$uri_str ~= %*ENV<MODPERL6> ?? %*ENV<PATH_INFO> !! %*ENV<REQUEST_URI>;

$!uri = November::URI.new( uri => $uri_str );
$!uri = URI.new( $uri_str );
}

# For debugging
Expand Down Expand Up @@ -85,11 +86,9 @@ class November::CGI {

method parse_params($string) {
if $string ~~ / '&' | ';' | '=' / {
my @param_values = $string.split(/ '&' | ';' /);

for @param_values -> $param_value {
my @kvs = $param_value.split("=");
self.add_param( @kvs[0], unescape(@kvs[1]) );
my %query_form = URI::split_query($string);
for %query_form.kv -> $k, $v {
self.add_param($k, uri_unescape( item $v ));
}
}
else {
Expand All @@ -98,7 +97,7 @@ class November::CGI {
}

method parse_keywords (Str $string is copy) {
my $kws = unescape($string);
my $kws = uri_unescape($string);
@!keywords = $kws.split(/ \s+ /);
}

Expand All @@ -108,51 +107,8 @@ class November::CGI {

for @param_values -> $param_value {
my @kvs = $param_value.split('=');
%!cookie{ @kvs[0] } = unescape( @kvs[1] );
}
}

our sub unescape($string is copy) {
$string .= subst('+', ' ', :g);
# RAKUDO: This could also be rewritten as a single .subst :g call.
# ...when the semantics of .subst is revised to change $/,
# that is.
# The percent_hack can be removed once the bug is fixed and :g is
# added
while $string ~~ / ( [ '%' <[0..9A..F]>**2 ]+ ) / {
$string .= subst( ~$0,
percent_hack_start( decode_urlencoded_utf8( ~$0 ) ) );
}
return percent_hack_end( $string );
}

sub percent_hack_start($str is rw) {
if $str ~~ '%' {
$str = '___PERCENT_HACK___';
}
return $str;
}

sub percent_hack_end($str) {
return $str.subst('___PERCENT_HACK___', '%', :g);
}

sub decode_urlencoded_utf8($str) {
my $r = '';
my @chars = map { :16($_) }, $str.split('%').grep({$^w});
while @chars {
my $bytes = 1;
my $mask = 0xFF;
given @chars[0] {
when { $^c +& 0xF0 == 0xF0 } { $bytes = 4; $mask = 0x07 }
when { $^c +& 0xE0 == 0xE0 } { $bytes = 3; $mask = 0x0F }
when { $^c +& 0xC0 == 0xC0 } { $bytes = 2; $mask = 0x1F }
}
my @shift = (^$bytes).reverse.map({6 * $_});
my @mask = $mask, 0x3F xx $bytes-1;
$r ~= chr( [+] @chars.splice(0,$bytes) »+&« @mask »+<« @shift );
%!cookie{ @kvs[0] } = uri_unescape( @kvs[1] );
}
return $r;
}

method add_param ( Str $key, $value ) {
Expand Down
120 changes: 0 additions & 120 deletions lib/November/URI.pm

This file was deleted.

27 changes: 0 additions & 27 deletions lib/November/URI/Grammar.pm

This file was deleted.

31 changes: 0 additions & 31 deletions t/cgi/03-urlencoded.t

This file was deleted.

11 changes: 5 additions & 6 deletions t/cgi/cgi_post_test
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/perl6
#!/usr/bin/env perl6
use Test;

use CGI;
my $cgi = CGI.new();
$cgi.init();
use November::CGI;
my $cgi = November::CGI.new();

print _is_deeply( $cgi.params, eval( %*ENV<TEST_RESULT> ) )
# _is_deeply no longer visible from Test.pm so worked around it ...
print $cgi.params eqv eval( %*ENV<TEST_RESULT> )
?? "ok "
!! "not ok \n" ~ "got: " ~ $cgi.param.perl ~
"\nexpected: " ~ %*ENV<TEST_RESULT> ~ "\n";

say "- " ~ %*ENV<TEST_NAME>;
4 changes: 2 additions & 2 deletions t/integration/01-view_page.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Test;
use November;
use Test::CGI;
use November::Config;
use November::URI;
use URI;

my @markups = < Text::Markup::Wiki::MediaWiki >;
my @skins = < CleanAndSoft >;
Expand All @@ -26,7 +26,7 @@ for @markups X @skins -> $m, $s {
my $c = November::Config.new( markup => $m, skin => $s );
my $w = November.new( config => $c );
for %gets.kv -> $page, $description {
my $uri = November::URI.new( uri => 'http://testserver' ~ $page );
my $uri = URI.new( 'http://testserver' ~ $page );
my $cgi = Test::CGI.new( uri => $uri );
$cgi.parse_params( $page );
lives_ok( { $w.handle_request( $cgi ) }, "$m, $s, $description" );
Expand Down
Loading