diff --git a/trunk/download.pl b/trunk/download.pl index 69cf23a..08551a4 100644 --- a/trunk/download.pl +++ b/trunk/download.pl @@ -50,7 +50,7 @@ if($query->param('id')) #video is being downloaded - update downloadcount $dbh->do(qq{update videos set downloadcount=downloadcount+1 where id = ? }, undef, $query->param('id')) or die $dbh->errstr; - print $query->header(-type=>'application/x-download', + print $query->header(-type=>'application/ogg', -attachment=>$title.".ogv"); } diff --git a/trunk/functions.pl b/trunk/functions.pl index 6971718..8377a1a 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -30,22 +30,6 @@ sub get_page_array if($userinfo->{'username'}) { $page->{'locale'} = $userinfo->{'locale'}; - - #prepare query - my $sth = $dbh->prepare(qq{select id, title, status from uploaded where userid = ? and status != 0}) or die $dbh->errstr; - - #execute it - $sth->execute($userinfo->{'id'}) or die $dbh->errstr; - - while(my ($id, $title, $status) = $sth->fetchrow_array()) - { - $page->{'message'}->{'type'} = "error"; - $page->{'message'}->{'text'} = "error_202c"; - #TODO: delete from uploaded where id = $id - } - - #finish query - $sth->finish() or die $dbh->errstr; } #else get the locale from the http server variable else @@ -71,7 +55,11 @@ sub fill_results #execute it $resultcount = $sth->execute(@_) or die $dbh->errstr; - $pagesize = $query->param('pagesize') or $pagesize = $userinfo->{'pagesize'} or $pagesize = 5; + #set pagesize by query or usersettings or default + $pagesize = $query->param('pagesize') or $pagesize = $userinfo->{'pagesize'} or $pagesize = $defaultpagesize; + + #if pagesize is more than maxpagesize reduce to maxpagesize + $pagesize = $pagesize > $maxpagesize ? $maxpagesize : $pagesize; #rediculous but funny round up, will fail with 100000000000000 results per page #on 0.0000000000001% of all queries - this is a risk we can handle @@ -160,7 +148,7 @@ sub output_page #let the xslt param choose other stylesheets or default to xhtml.xsl my $param_xslt = $query->param('xslt'); - $param_xslt =~ s/[^a-z]//gi; + $param_xslt =~ s/[^\w]//gi; if( -f "$root/xsl/$param_xslt.xsl") { @@ -187,6 +175,7 @@ sub output_page ) ); + #send everything including http headers to the user - if xslt chosen is xspf set download filename return $session->header( -type=>'text/xml', -charset=>'UTF-8' diff --git a/trunk/include.pl b/trunk/include.pl index f5af8fc..0b2baed 100644 --- a/trunk/include.pl +++ b/trunk/include.pl @@ -25,5 +25,7 @@ $stylesheet = "/style/default.css"; $xmlns_dc = "http://purl.org/dc/elements/1.1/"; $xmlns_cc = "http://web.resource.org/cc/"; $xmlns_rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; +$defaultpagesize = 20; +$maxpagesize = 500; $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass); 1; diff --git a/trunk/index.pl b/trunk/index.pl index e205d66..26ec628 100644 --- a/trunk/index.pl +++ b/trunk/index.pl @@ -13,15 +13,21 @@ $page->{frontpage} = ['']; if($query->param('information')) { - $page->{'message'}->{'type'} = "information"; $page->{'message'}->{'text'} = $query->param('information'); + $page->{'message'}->{'value'} = $query->param('value'); } elsif($query->param('error')) { - $page->{'message'}->{'type'} = "error"; $page->{'message'}->{'text'} = $query->param('error'); + $page->{'message'}->{'value'} = $query->param('value'); +} +elsif($query->param('warning')) +{ + $page->{'message'}->{'type'} = "warning"; + $page->{'message'}->{'text'} = $query->param('warning'); + $page->{'message'}->{'value'} = $query->param('value'); } diff --git a/trunk/locale/en-us.xml b/trunk/locale/en-us.xml index 1f63ac1..1d37fbd 100755 --- a/trunk/locale/en-us.xml +++ b/trunk/locale/en-us.xml @@ -64,9 +64,10 @@ Your comment has been submitted. Your account has been created. Your file has been uploaded. - There are no results satisfying your query. + There are no results satisfying your query. + You passed no query string. results @@ -122,7 +123,7 @@ Specify the file you want to upload. State the title of the video. Specify the creator of the video. - State some keywords, separated by commas. + State some keywords, separated by spaces. Describe the video in natural language. Specify the source, preferably by URL. State the language of the video. diff --git a/trunk/search.pl b/trunk/search.pl index 0a6811a..d11a2f2 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -10,10 +10,8 @@ $session = new CGI::Session; @page = get_page_array(@userinfo); #check if query is set -if($query->param('query') or $query->param('orderby')) +if($query->param('query')) { - #TODO: clean up scriptname, argument, value only being there because of - #TODO: account.pl also calling fill_results() which will be changed $page->{'search'} = ['']; $page->{'results'}->{'query'} = $query->param('query'); @@ -22,7 +20,9 @@ if($query->param('query') or $query->param('orderby')) $strquery = $query->param('query'); (@tags) = $strquery =~ /tag:(\w+)/gi; ($username) = $strquery =~ /user:(\w+)/i; - $strquery =~ s/(tag|title|user):\w+//gi; + ($orderby) = $strquery =~ /orderby:(\w+)/i; + ($sort) = $strquery =~ /sort:(\w+)/i; + $strquery =~ s/(tag|user|orderby|sort):\w+//gi; $strquery =~ s/^\s*(.*?)\s*$/$1/; #build mysql query @@ -55,29 +55,29 @@ if($query->param('query') or $query->param('orderby')) push @args, "$username"; } - if($query->param('orderby')) + if($orderby) { - if($query->param('orderby') eq 'filesize') + if($orderby eq 'filesize') { $dbquery .= " order by v.filesize"; } - elsif($query->param('orderby') eq 'duration') + elsif($orderby eq 'duration') { $dbquery .= " order by v.duration"; } - elsif($query->param('orderby') eq 'viewcount') + elsif($orderby eq 'viewcount') { $dbquery .= " order by v.viewcount"; } - elsif($query->param('orderby') eq 'downloadcount') + elsif($orderby eq 'downloadcount') { $dbquery .= " order by v.downloadcount"; } - elsif($query->param('orderby') eq 'timestamp') + elsif($orderby eq 'timestamp') { $dbquery .= " order by v.timestamp"; } - elsif($query->param('orderby') eq 'relevance' and $query->param('query')) + elsif($orderby eq 'relevance' and $strquery) { $dbquery .= " order by relevance"; } @@ -86,22 +86,28 @@ if($query->param('query') or $query->param('orderby')) $dbquery .= " order by v.id"; } - if($query->param('sort') eq "asc") + if($sort eq "ascending") { - $dbquery .= " asc" + $dbquery .= " asc"; } - else + elsif($sort eq "descending") { - $dbquery .= " desc" + $dbquery .= " desc"; } } fill_results(@args); + + if(@{$page->{'results'}->{'result'}} == 0) + { + print $query->redirect("index.pl?warning=warning_no_results"); + } + else + { + print output_page(); + } } else { - $page->{'message'}->{'type'} = "error"; - $page->{'message'}->{'text'} = "error_202c"; + print $query->redirect("index.pl?warning=warning_no_query"); } - -print output_page(); diff --git a/trunk/site/main.xml b/trunk/site/main.xml index 7363891..73f05a2 100755 --- a/trunk/site/main.xml +++ b/trunk/site/main.xml @@ -17,13 +17,13 @@ http://yolanda.mister-muffin.de/trac/browser/trunk /register.pl http://yolanda.mister-muffin.de/trac/newticket - search.pl?query= + /search.pl?query= http://localhost/ /upload.pl - uploader.pl - search.pl?query=&orderby=timestamp&sort=desc - search.pl?query=&orderby=downloadcount&sort=desc - search.pl?query=&orderby=viewcount&sort=desc + /uploader.pl + /search.pl?query=orderby:timestamp%20sort:descending + /search.pl?query=orderby:downloadcount%20sort:descending + /search.pl?query=orderby:viewcount%20sort:descending diff --git a/trunk/xsl/xhtml.xsl b/trunk/xsl/xhtml.xsl index b1a98ee..481133d 100755 --- a/trunk/xsl/xhtml.xsl +++ b/trunk/xsl/xhtml.xsl @@ -79,12 +79,15 @@ - + - &xslt=rss + + &pagesize= + &page= + &xslt=rss