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
This commit is contained in:
josch 2007-12-22 12:30:11 +00:00
parent 1c7d1d82aa
commit f49b878f31
10 changed files with 221 additions and 68 deletions

View file

@ -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");
}

View file

@ -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],

View file

@ -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,

View file

@ -54,6 +54,7 @@
<string id="error_insert_username">Please insert a username.</string>
<string id="error_insert_password">Please insert a password.</string>
<string id="error_repeat_password">Please repeat your password.</string>
<string id="error_no_query">You passed no query string.</string>
<string id=""></string>
<!-- information -->
@ -67,7 +68,6 @@
<!-- warnings -->
<string id="warning_no_results">There are no results satisfying your query.</string>
<string id="warning_no_query">You passed no query string.</string>
<!-- results page-->
<string id="results_heading_1">results</string>
@ -128,6 +128,7 @@
<string id="instruction_source">Specify the source, preferably by URL.</string>
<string id="instruction_language">State the language of the video.</string>
<string id="instruction_coverage">Specify the time and location covered.</string>
<string id="instruction_rights">Specify the copyright owner of the video.</string>
<string id="instruction_license">Specify the license, preferably by URL.</string>
<string id="instruction_license_cc">Optionally, choose Creative Commons licensing.</string>
<string id="instruction_license_cc_remix">Permit modification.</string>
@ -174,6 +175,7 @@
<string id="DC.Language">language</string>
<string id="DC.Coverage">coverage</string>
<string id="DC.Rights">righs holder</string>
<string id="DC.License">license</string>
<string id="duration">duration</string>
<string id="viewcount">viewcount</string>

View file

@ -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");
}

View file

@ -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;

View file

@ -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
{

View file

@ -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();

View file

@ -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],

View file

@ -53,6 +53,18 @@
</xsl:attribute>
</input>
<input name="DC.Rights" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Rights" />
</xsl:attribute>
</input>
<input name="DC.License" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.License" />
</xsl:attribute>
</input>
<fieldset>
<xsl:value-of select="$locale_strings[@id='instruction_title']" />
@ -158,6 +170,18 @@
</xsl:attribute>
</input>
<input name="DC.Rights" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Rights" />
</xsl:attribute>
</input>
<input name="DC.License" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.License" />
</xsl:attribute>
</input>
<fieldset>
<input type="submit" name="3">
@ -213,6 +237,18 @@
</xsl:attribute>
</input>
<input name="DC.Rights" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Rights" />
</xsl:attribute>
</input>
<input name="DC.License" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.License" />
</xsl:attribute>
</input>
<fieldset>
<xsl:value-of select="$locale_strings[@id='instruction_creator']" />
@ -329,12 +365,20 @@
</xsl:attribute>
</input>
<fieldset>
<xsl:value-of select="$locale_strings[@id='instruction_rights']" />
<br />
<input name="DC.Rights" type="text" size="30">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Rights" />
</xsl:attribute>
</input>
<br />
<xsl:value-of select="$locale_strings[@id='instruction_license']" />
<br />
<input name="License" type="text" size="30">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.License" />
</xsl:attribute>
<input name="DC.License" type="text" size="30">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.License" />
</xsl:attribute>
</input>
<br />
<xsl:value-of select="$locale_strings[@id='instruction_license_cc']" />
@ -343,7 +387,13 @@
<div class="cc-license-chooser">
<img src="./images/cc/cc-remix.png" />
<input type="radio" name="modification" value="remix" />
<input type="radio" name="modification" value="remix">
<xsl:if test="//uploadform/@remix='true'">
<xsl:attribute name="checked">
checked
</xsl:attribute>
</xsl:if>
</input>
<br />
<span class="protip">
<xsl:value-of select="$locale_strings[@id='instruction_license_cc_remix']" />
@ -351,7 +401,13 @@
<br />
<img src="./images/cc/cc-sharealike.png" />
<input type="radio" name="modification" value="ShareAlike" />
<input type="radio" name="modification" value="sharealike">
<xsl:if test="//uploadform/@sharealike='true'">
<xsl:attribute name="checked">
checked
</xsl:attribute>
</xsl:if>
</input>
<br />
<span class="protip">
<xsl:value-of select="$locale_strings[@id='instruction_license_cc_sharealike']" />
@ -359,7 +415,13 @@
<br />
<img src="./images/cc/cc-noderivatives.png" />
<input type="radio" name="modification" value="noncommercial" />
<input type="radio" name="modification" value="noderivatives">
<xsl:if test="//uploadform/@noderivatives='true'">
<xsl:attribute name="checked">
checked
</xsl:attribute>
</xsl:if>
</input>
<br />
<span class="protip">
<xsl:value-of select="$locale_strings[@id='instruction_license_cc_noderivatives']" />
@ -367,7 +429,13 @@
<br />
<img src="./images/cc/cc-noncommercial.png" />
<input type="checkbox" name="noncommercial" value="CommercialUse" />
<input type="checkbox" name="noncommercial" value="CommercialUse">
<xsl:if test="//uploadform/@noncommercial='true'">
<xsl:attribute name="checked">
checked
</xsl:attribute>
</xsl:if>
</input>
<br />
<span class="protip">
<xsl:value-of select="$locale_strings[@id='instruction_license_cc_noncommercial']" />
@ -451,6 +519,16 @@
<xsl:value-of select="//uploadform/@DC.Coverage" />
</xsl:attribute>
</input>
<input name="DC.Rights" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Rights" />
</xsl:attribute>
</input>
<input name="DC.License" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.License" />
</xsl:attribute>
</input>
<table class="videometadata">
<tr>
@ -525,8 +603,25 @@
<xsl:value-of select="$locale_strings[@id='button_page_3']" />
</xsl:attribute>
</input>
<xsl:call-template name="cclicense"/>
<table class="videometadata">
<tr>
<td class="leftcell">
<xsl:value-of select="$locale_strings[@id='DC.Rights']" />:
</td>
<td class="rightcell">
<xsl:value-of select="//uploadform/@DC.Rights" />
</td>
</tr>
<tr>
<td class="leftcell">
<xsl:value-of select="$locale_strings[@id='DC.License']" />:
</td>
<td class="rightcell">
<xsl:value-of select="//uploadform/@DC.License" />
</td>
</tr>
</table>
<input type="submit" name="4">
<xsl:attribute name="value">
@ -575,6 +670,16 @@
<xsl:value-of select="//uploadform/@DC.Coverage" />
</xsl:attribute>
</input>
<input name="DC.Rights" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.Rights" />
</xsl:attribute>
</input>
<input name="DC.License" type="hidden">
<xsl:attribute name="value">
<xsl:value-of select="//uploadform/@DC.License" />
</xsl:attribute>
</input>
<fieldset>
<xsl:value-of select="$locale_strings[@id='instruction_file']" />
<br />