From f49b878f3126e303773989bc7e4f05706b99a7ea Mon Sep 17 00:00:00 2001 From: josch Date: Sat, 22 Dec 2007 12:30:11 +0000 Subject: [PATCH] deleted notice, derivativework, sharealike, commercialuse and dc.contributor from database tables as they were never used, redirect to video if lucky search or only 1 result, noquery as error message not warning, added http-content-length for downloads, removed status from search, added rights and license and cc support to upload process, redirect to frontpage after successful upload git-svn-id: http://yolanda.mister-muffin.de/svn@219 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/download.pl | 1 + trunk/functions.pl | 12 +--- trunk/init_sql.pl | 12 +--- trunk/locale/en-us.xml | 4 +- trunk/search.pl | 17 ++--- trunk/tools/daemon.pl | 6 +- trunk/upload.pl | 88 ++++++++++++++++++++++---- trunk/uploader.pl | 15 ++--- trunk/video.pl | 9 ++- trunk/xsl/xhtml/upload.xsl | 125 ++++++++++++++++++++++++++++++++++--- 10 files changed, 221 insertions(+), 68 deletions(-) diff --git a/trunk/download.pl b/trunk/download.pl index 08551a4..b76cb22 100644 --- a/trunk/download.pl +++ b/trunk/download.pl @@ -51,6 +51,7 @@ if($query->param('id')) $dbh->do(qq{update videos set downloadcount=downloadcount+1 where id = ? }, undef, $query->param('id')) or die $dbh->errstr; print $query->header(-type=>'application/ogg', + -length=> -s "$root/videos/".$query->param('id'), -attachment=>$title.".ogv"); } diff --git a/trunk/functions.pl b/trunk/functions.pl index 8377a1a..ce1349d 100644 --- a/trunk/functions.pl +++ b/trunk/functions.pl @@ -80,17 +80,11 @@ sub fill_results $page->{'results'}->{'resultcount'} = $resultcount eq '0E0' ? 0 : $resultcount; $page->{'results'}->{'pagesize'} = $pagesize; - if($resultcount eq '0E0') - { - $page->{'message'}->{'type'} = "information"; - $page->{'message'}->{'text'} = "information_no_results"; - } - #get every returned value while (my ($id, $title, $description, $publisher, $timestamp, $creator, - $subject, $contributor, $source, $language, $coverage, $rights, + $subject, $source, $language, $coverage, $rights, $license, $filesize, $duration, $width, $height, $fps, $viewcount, - $downloadcount, $status) = $sth->fetchrow_array()) + $downloadcount) = $sth->fetchrow_array()) { #before code cleanup, this was a really obfuscated array/hash creation push @{ $page->{'results'}->{'result'} }, @@ -98,7 +92,6 @@ sub fill_results 'thumbnail' => $duration == 0 ? "/images/tango/video-x-generic.png" : "/video-stills/$id", 'duration' => $duration, 'viewcount' => $viewcount, - 'status' => $status, 'edit' => $userinfo->{'username'} eq $publisher ? "true" : "false", 'rdf:RDF' => { @@ -110,7 +103,6 @@ sub fill_results 'dc:subject' => [$subject], 'dc:description' => [$description], 'dc:publisher' => [$publisher], - 'dc:contributor' => [$contributor], 'dc:date' => [$timestamp], 'dc:identifier' => ["$domain/video/".urlencode($title)."/$id/" . ($duration == 0 ? "/action=edit" : "")], 'dc:source' => [$source], diff --git a/trunk/init_sql.pl b/trunk/init_sql.pl index e817e9f..7d780ad 100644 --- a/trunk/init_sql.pl +++ b/trunk/init_sql.pl @@ -1,3 +1,5 @@ +require "include.pl"; + #create or resume session CGI::Session->name($session_name); my $session = new CGI::Session; @@ -78,16 +80,11 @@ $dbh->do(qq{create table timestamp bigint not null, creator varchar(255) not null, subject varchar(255) not null, - contributor varchar(255) not null, source varchar(255) not null, language varchar(255) not null, coverage varchar(255) not null, rights varchar(255) not null, license varchar(255) not null, - notice bool not null, - derivativeworks bool not null, - sharealike bool not null, - commercialuse bool not null, status int default 0, primary key (id) ) @@ -103,16 +100,11 @@ $dbh->do(qq{create table timestamp bigint not null, creator varchar(255) not null, subject varchar(255) not null, - contributor varchar(255) not null, source varchar(255) not null, language varchar(255) not null, coverage varchar(255) not null, rights varchar(255) not null, license varchar(255) not null, - notice bool not null, - derivativeworks bool not null, - sharealike bool not null, - commercialuse bool not null, filesize int not null, duration int not null, width smallint not null, diff --git a/trunk/locale/en-us.xml b/trunk/locale/en-us.xml index 1d37fbd..12bb8ed 100755 --- a/trunk/locale/en-us.xml +++ b/trunk/locale/en-us.xml @@ -54,6 +54,7 @@ Please insert a username. Please insert a password. Please repeat your password. + You passed no query string. @@ -67,7 +68,6 @@ There are no results satisfying your query. - You passed no query string. results @@ -128,6 +128,7 @@ Specify the source, preferably by URL. State the language of the video. Specify the time and location covered. + Specify the copyright owner of the video. Specify the license, preferably by URL. Optionally, choose Creative Commons licensing. Permit modification. @@ -174,6 +175,7 @@ language coverage righs holder + license duration viewcount diff --git a/trunk/search.pl b/trunk/search.pl index d11a2f2..c57caac 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -19,17 +19,16 @@ if($query->param('query')) $strquery = $query->param('query'); (@tags) = $strquery =~ /tag:(\w+)/gi; - ($username) = $strquery =~ /user:(\w+)/i; ($orderby) = $strquery =~ /orderby:(\w+)/i; ($sort) = $strquery =~ /sort:(\w+)/i; - $strquery =~ s/(tag|user|orderby|sort):\w+//gi; + $strquery =~ s/(tag|orderby|sort):\w+//gi; $strquery =~ s/^\s*(.*?)\s*$/$1/; #build mysql query $dbquery = "select v.id, v.title, v.description, u.username, - from_unixtime( v.timestamp ), v.creator, v.subject, v.contributor, + from_unixtime( v.timestamp ), v.creator, v.subject, v.source, v.language, v.coverage, v.rights, v.license, filesize, - duration, width, height, fps, viewcount, downloadcount, 1"; + duration, width, height, fps, viewcount, downloadcount"; if($strquery) { @@ -49,10 +48,10 @@ if($query->param('query')) push @args, "@tags"; } - if($username) + if($publisher) { $dbquery .= " and match(u.username) against (? in boolean mode)"; - push @args, "$username"; + push @args, "$publisher"; } if($orderby) @@ -102,6 +101,10 @@ if($query->param('query')) { print $query->redirect("index.pl?warning=warning_no_results"); } + if(@{$page->{'results'}->{'result'}} == 1 or $query->param('lucky')) + { + print $query->redirect(@{$page->{'results'}->{'result'}}[0]->{'rdf:RDF'}->{'cc:Work'}->{'dc:identifier'}[0]); + } else { print output_page(); @@ -109,5 +112,5 @@ if($query->param('query')) } else { - print $query->redirect("index.pl?warning=warning_no_query"); + print $query->redirect("index.pl?error=error_no_query"); } diff --git a/trunk/tools/daemon.pl b/trunk/tools/daemon.pl index df4a50b..2342600 100755 --- a/trunk/tools/daemon.pl +++ b/trunk/tools/daemon.pl @@ -146,8 +146,7 @@ while(1) #add video to videos table $dbh->do(qq{insert into videos select id, title, description, userid, timestamp, creator, - subject, contributor, source, language, coverage, rights, license, notice, - derivativeworks, sharealike, commercialuse, ?, ?, ?, ?, ?, ?, 0, 0 + subject, source, language, coverage, rights, license, ?, ?, ?, ?, ?, ?, 0, 0 from uploaded where id = ?}, undef, $filesize, $duration, $width, $height, $fps, $sha, $id) or interrupt $dbh->errstr; @@ -166,8 +165,7 @@ while(1) #add video to videos table $dbh->do(qq{insert into videos select id, title, description, userid, timestamp, creator, - subject, contributor, source, language, coverage, rights, license, notice, - derivativeworks, sharealike, commercialuse, ?, ?, ?, ?, ?, ?, 0, 0 + subject, source, language, coverage, rights, license, ?, ?, ?, ?, ?, ?, 0, 0 from uploaded where id = ?}, undef, $filesize, $duration, $vwidth, $vheight, $fps, $sha, $id) or interrupt $dbh->errstr; diff --git a/trunk/upload.pl b/trunk/upload.pl index 74d1f00..030b5c3 100644 --- a/trunk/upload.pl +++ b/trunk/upload.pl @@ -11,6 +11,16 @@ $session = new CGI::Session; if($userinfo->{'username'}) { + $page->{'uploadform'}->{'DC.Title'} = $query->param('DC.Title'); + $page->{'uploadform'}->{'DC.Subject'} = $query->param('DC.Subject'); + $page->{'uploadform'}->{'DC.Description'} = $query->param('DC.Description'); + $page->{'uploadform'}->{'DC.Creator'} = $query->param('DC.Creator'); + $page->{'uploadform'}->{'DC.Source'} = $query->param('DC.Source'); + $page->{'uploadform'}->{'DC.Language'} = $query->param('DC.Language'); + $page->{'uploadform'}->{'DC.Coverage'} = $query->param('DC.Coverage'); + $page->{'uploadform'}->{'DC.Rights'} = $query->param('DC.Rights'); + $page->{'uploadform'}->{'DC.License'} = $query->param('DC.License'); + if($query->param('2')) { if($query->param('DC.Title')&&$query->param('DC.Subject')&&$query->param('DC.Description')) @@ -22,7 +32,7 @@ if($userinfo->{'username'}) #build mysql query $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ), v.creator, v.subject, - v.contributor, v.source, v.language, v.coverage, v.rights, + v.source, v.language, v.coverage, v.rights, v.license, filesize, duration, width, height, fps, viewcount, downloadcount, match(v.title, v.description, v.subject) @@ -61,27 +71,81 @@ if($userinfo->{'username'}) } elsif($query->param('4')) { + if($query->param('DC.License') eq 'cc-by') + { + $page->{'uploadform'}->{'remix'} = 'true'; + } + elsif($query->param('DC.License') eq 'cc-by-sa') + { + $page->{'uploadform'}->{'sharealike'} = 'true'; + } + elsif($query->param('DC.License') eq 'cc-by-nd') + { + $page->{'uploadform'}->{'noderivatives'} = 'true'; + } + elsif($query->param('DC.License') eq 'cc-by-nc') + { + $page->{'uploadform'}->{'remix'} = 'true'; + $page->{'uploadform'}->{'noncommercial'} = 'true'; + } + elsif($query->param('DC.License') eq 'cc-by-nc-sa') + { + $page->{'uploadform'}->{'sharealike'} = 'true'; + $page->{'uploadform'}->{'noncommercial'} = 'true'; + } + elsif($query->param('DC.License') eq 'cc-by-nc-nd') + { + $page->{'uploadform'}->{'noderivatives'} = 'true'; + $page->{'uploadform'}->{'noncommercial'} = 'true'; + } + $page->{'uploadform'}->{'page'} = '4'; } elsif($query->param('5')) { + if($query->param('modification') and not $query->param('DC.License')) + { + if($query->param('modification') eq 'remix') + { + if($query->param('noncommercial')) + { + $page->{'uploadform'}->{'DC.License'} = 'cc-by-nc'; + } + else + { + $page->{'uploadform'}->{'DC.License'} = 'cc-by'; + } + } + elsif($query->param('modification') eq 'sharealike') + { + if($query->param('noncommercial')) + { + $page->{'uploadform'}->{'DC.License'} = 'cc-by-nc-sa'; + } + else + { + $page->{'uploadform'}->{'DC.License'} = 'cc-by-sa'; + } + } + elsif($query->param('modification') eq 'noderivatives') + { + if($query->param('noncommercial')) + { + $page->{'uploadform'}->{'DC.License'} = 'cc-by-nc-nd'; + } + else + { + $page->{'uploadform'}->{'DC.License'} = 'cc-by-nd'; + } + } + } + $page->{'uploadform'}->{'page'} = '5'; } - elsif($query->param('6')) - { - $page->{'uploadform'}->{'page'} = '6'; - } else { $page->{'uploadform'}->{'page'} = '1'; } - $page->{'uploadform'}->{'DC.Title'} = $query->param('DC.Title'); - $page->{'uploadform'}->{'DC.Subject'} = $query->param('DC.Subject'); - $page->{'uploadform'}->{'DC.Description'} = $query->param('DC.Description'); - $page->{'uploadform'}->{'DC.Creator'} = $query->param('DC.Creator'); - $page->{'uploadform'}->{'DC.Source'} = $query->param('DC.Source'); - $page->{'uploadform'}->{'DC.Language'} = $query->param('DC.Language'); - $page->{'uploadform'}->{'DC.Coverage'} = $query->param('DC.Coverage'); } else { diff --git a/trunk/uploader.pl b/trunk/uploader.pl index 86e65c6..3ccd6bb 100644 --- a/trunk/uploader.pl +++ b/trunk/uploader.pl @@ -26,11 +26,12 @@ if($userinfo->{'id'} && $query->param("DC.Title") && #make new entry for video into the databse #FIXME: contributor, rights $dbh->do(qq{insert into uploaded (title, description, userid, timestamp, - creator, subject, contributor, source, language, coverage, rights) + creator, subject, source, language, coverage, rights, license) values ( ?, ?, ?, unix_timestamp(), ?, ?, ?, ?, ?, ?, ? )}, undef, $query->param("DC.Title"), $query->param("DC.Description"), $userinfo->{'id'}, - $query->param("DC.Creator"), $query->param("DC.Subject"), '', $query->param("DC.Source"), - $query->param("DC.Language"), $query->param("DC.Coverage"), '') or die $dbh->errstr; + $query->param("DC.Creator"), $query->param("DC.Subject"), $query->param("DC.Source"), + $query->param("DC.Language"), $query->param("DC.Coverage"), + $query->param("DC.Rights"), $query->param("DC.License")) or die $dbh->errstr; #get the id of the inserted db entry $sth = $dbh->prepare(qq{select last_insert_id() }) or die $dbh->errstr; @@ -47,13 +48,9 @@ if($userinfo->{'id'} && $query->param("DC.Title") && } close TEMPFILE; - $page->{'message'}->{'type'} = "information"; - $page->{'message'}->{'text'} = "information_uploaded"; + print $query->redirect("index.pl?information=information_uploaded&value=$domain/video/".urlencode($query->param("DC.Title"))."/$id/"); } else { - $page->{'message'}->{'type'} = "error"; - $page->{'message'}->{'text'} = "error_202c"; + print $query->redirect("index.pl?error=error_202c"); } - -print output_page(); diff --git a/trunk/video.pl b/trunk/video.pl index 9aedd39..ef4f2b5 100644 --- a/trunk/video.pl +++ b/trunk/video.pl @@ -24,7 +24,7 @@ elsif($query->url_param('title') or $query->url_param('id')) { #if id is passed ignore title and check for the id $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ), - v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights, + v.creator, v.subject, v.source, v.language, v.coverage, v.rights, v.license, filesize, duration, width, height, fps, viewcount, downloadcount from videos as v, users as u where v.id = ? and u.id=v.userid"; @@ -34,7 +34,7 @@ elsif($query->url_param('title') or $query->url_param('id')) { #if no id was passed there has to be a title we search for $dbquery = "select v.id, v.title, v.description, u.username, from_unixtime( v.timestamp ), - v.creator, v.subject, v.contributor, v.source, v.language, v.coverage, v.rights, + v.creator, v.subject, v.source, v.language, v.coverage, v.rights, v.license, filesize, duration, width, height, fps, viewcount, downloadcount from videos as v, users as u where v.title = ? and u.id=v.userid"; @@ -49,7 +49,7 @@ elsif($query->url_param('title') or $query->url_param('id')) if($rowcount == 0 and $query->url_param('title')) { $dbquery = "select v.id, v.title, v.description, u.username, - from_unixtime( v.timestamp ), v.creator, v.subject, v.contributor, + from_unixtime( v.timestamp ), v.creator, v.subject, v.source, v.language, v.coverage, v.rights, v.license, filesize, duration, width, height, fps, viewcount, downloadcount, 1"; $dbquery .= ", match(v.title, v.description, v.subject) against( ? in boolean mode) as relevance"; @@ -76,7 +76,7 @@ elsif($query->url_param('title') or $query->url_param('id')) #if there was a single result, display the video my ($id, $title, $description, $publisher, $timestamp, $creator, $subject, - $contributor, $source, $language, $coverage, $rights, $license, + $source, $language, $coverage, $rights, $license, $filesize, $duration, $width, $height, $fps, $viewcount, $downloadcount) = $sth->fetchrow_array(); #finish query @@ -163,7 +163,6 @@ elsif($query->url_param('title') or $query->url_param('id')) 'dc:subject' => [$subject], 'dc:description' => [$description], 'dc:publisher' => [$publisher], - 'dc:contributor' => [$contributor], 'dc:date' => [$timestamp], 'dc:identifier' => ["$domain/video/".urlencode($title)."/$id/"], 'dc:source' => [$source], diff --git a/trunk/xsl/xhtml/upload.xsl b/trunk/xsl/xhtml/upload.xsl index 565d6ec..e000e73 100644 --- a/trunk/xsl/xhtml/upload.xsl +++ b/trunk/xsl/xhtml/upload.xsl @@ -53,6 +53,18 @@ + + + + + + + + + + + +
@@ -158,6 +170,18 @@ + + + + + + + + + + + +
@@ -213,6 +237,18 @@ + + + + + + + + + + + +
@@ -329,12 +365,20 @@
+ +
+ + + + + +

- - - - + + + +
@@ -343,7 +387,13 @@
- + + + + checked + + +
@@ -351,7 +401,13 @@
- + + + + checked + + +
@@ -359,7 +415,13 @@
- + + + + checked + + +
@@ -367,7 +429,13 @@
- + + + + checked + + +
@@ -451,6 +519,16 @@ + + + + + + + + + + @@ -525,8 +603,25 @@ - - + + + + + + + + + + + @@ -575,6 +670,16 @@ + + + + + + + + + +