From e1137a95de51ddcbc393c5a147d3450cf95c695c Mon Sep 17 00:00:00 2001 From: josch Date: Sat, 1 Dec 2007 18:04:28 +0000 Subject: [PATCH] cleaned url generation (slashes at the end, proper encoding), added apache.conf git-svn-id: http://yolanda.mister-muffin.de/svn@192 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/apache.conf | 25 +++++++++++++++++++++++++ trunk/functions.pl | 12 ++++++++++-- trunk/style/default.css | 2 +- trunk/video.pl | 6 +++--- trunk/xsl/xhtml/video.xsl | 38 ++++++++++++++++++-------------------- 5 files changed, 57 insertions(+), 26 deletions(-) create mode 100644 trunk/apache.conf diff --git a/trunk/apache.conf b/trunk/apache.conf new file mode 100644 index 0000000..7bd178f --- /dev/null +++ b/trunk/apache.conf @@ -0,0 +1,25 @@ +NameVirtualHost * + + ServerAdmin webmaster@localhost + + DocumentRoot /var/www/yolanda/ + + Options FollowSymLinks + AllowOverride None + + + AllowEncodedSlashes On + + RewriteEngine On + RewriteRule ^/video/(.*)/([0-9]*)/(.*)$ /video.pl?title=$1&id=$2&$3 + RewriteRule ^/embedded/(.*)/([0-9]*)/(.*)$ /video.pl?title=$1&id=$2&embed=true&$3 + RewriteRule ^/download/([0-9]+)/(.*)$ /download.pl?id=$1&$2 + + ErrorLog /var/log/apache2/error.log + + LogLevel warn + + CustomLog /var/log/apache2/access.log combined + ServerSignature On + + diff --git a/trunk/functions.pl b/trunk/functions.pl index 12337ff..67f0c60 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -127,7 +127,7 @@ sub fill_results { 'cc:Work' => { - 'rdf:about' => "$domain/download/$id", + 'rdf:about' => "$domain/download/$id/", 'dc:title' => [$title], 'dc:creator' => [$creator], 'dc:subject' => [$subject], @@ -135,7 +135,7 @@ sub fill_results 'dc:publisher' => [$publisher], 'dc:contributor' => [$contributor], 'dc:date' => [$timestamp], - 'dc:identifier' => ["$domain/video/$title/$id" . ($duration == 0 ? "/action=edit" : "")], + 'dc:identifier' => ["$domain/video/".urlencode($title)."/$id/" . ($duration == 0 ? "/action=edit" : "")], 'dc:source' => [$source], 'dc:language' => [$language], 'dc:coverage' => [$coverage], @@ -155,3 +155,11 @@ sub fill_results #close db $dbh->disconnect() or die $dbh->errstr; } + +#replace chars in url as said in this rfc: http://www.rfc-editor.org/rfc/rfc1738.txt +sub urlencode +{ + my ($url) = @_[0]; + $url =~ s/([^A-Za-z0-9_\$\-.+!*'()])/sprintf("%%%02X", ord($1))/eg; + return $url; +} diff --git a/trunk/style/default.css b/trunk/style/default.css index ce32447..d2d939b 100755 --- a/trunk/style/default.css +++ b/trunk/style/default.css @@ -241,4 +241,4 @@ table.videometadata td { vertical-align: top; -} \ No newline at end of file +} diff --git a/trunk/video.pl b/trunk/video.pl index 148f21f..16befcf 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -59,7 +59,7 @@ elsif($query->url_param('title') or $query->url_param('id')) $dbquery .= " from videos as v, users as u where u.id = v.userid"; $dbquery .= " and match(v.title, v.description, v.subject) against( ? in boolean mode)"; - @args = ($query->url_param('title')); + @args = ($query->url_param('title'), $query->url_param('title')); $sth = $dbh->prepare($dbquery); $rowcount = $sth->execute(@args) or die $dbh->errstr; @@ -140,7 +140,7 @@ elsif($query->url_param('title') or $query->url_param('id')) { 'cc:Work' => { - 'rdf:about' => "$domain/download/$id", + 'rdf:about' => "$domain/download/$id/", 'dc:title' => [$title], 'dc:creator' => [$creator], 'dc:subject' => [$subject], @@ -148,7 +148,7 @@ elsif($query->url_param('title') or $query->url_param('id')) 'dc:publisher' => [$publisher], 'dc:contributor' => [$contributor], 'dc:date' => [$timestamp], - 'dc:identifier' => ["$domain/video/$title/$id"], + 'dc:identifier' => ["$domain/video/".urlencode($title)."/$id/"], 'dc:source' => [$source], 'dc:language' => [$language], 'dc:coverage' => [$coverage], diff --git a/trunk/xsl/xhtml/video.xsl b/trunk/xsl/xhtml/video.xsl index 2ca0420..0d070e9 100644 --- a/trunk/xsl/xhtml/video.xsl +++ b/trunk/xsl/xhtml/video.xsl @@ -62,10 +62,10 @@ - + - + @@ -90,7 +90,7 @@ - + @@ -137,35 +137,33 @@ - +
- +