inteface fixes + tagcloud

git-svn-id: http://yolanda.mister-muffin.de/svn@172 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
josch 2007-11-02 12:12:44 +00:00
parent de6e466797
commit ba705058f1
6 changed files with 87 additions and 24 deletions

View file

@ -173,7 +173,7 @@ while(1)
}
#write status 1 to uploaded table
$dbh->do(qq{update uploaded set status = ? where id = ?}, undef, 1, $id) or interrupt $dbh->errstr;
$dbh->do(qq{delete from uploaded where id = ?}, undef, $id) or interrupt $dbh->errstr;
}
}
}

View file

@ -30,7 +30,7 @@
<str id="query_latestadditions">latest additions</str>
<str id="query_mostdownloads">most downloads</str>
<str id="query_bestrated">best rated</str>
<str id="query_mostviews">most views</str>
<!-- errors -->
<str id="error_202c">Error 202c - Access forbidden by government.</str>

View file

@ -16,6 +16,11 @@ if($username)
{
$page->{'message'}->{'type'} = "error";
$page->{'message'}->{'text'} = "error_already_registered";
#print xml http header along with session cookie
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
}
#if username and password are passed put them into the database
elsif($query->param('user') and $query->param('pass') and $query->param('pass_repeat'))
@ -31,16 +36,19 @@ elsif($query->param('user') and $query->param('pass') and $query->param('pass_re
#disconnect db
$dbh->disconnect() or die $dbh->errstr;
#print a little confirmation
$page->{'message'}->{'type'} = "information";
$page->{'message'}->{'text'} = "information_registered";
print $query->redirect("index.pl?information=information_registered");
}
else
{
$page->{'registerform'} = [''];
$page->{'message'}->{'type'} = "error";
$page->{'message'}->{'text'} = "error_passwords_do_not_match";
#print xml http header along with session cookie
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
}
}
elsif(not $query->param('user') and ($query->param('pass') or $query->param('pass_repeat')))
@ -48,25 +56,40 @@ elsif(not $query->param('user') and ($query->param('pass') or $query->param('pas
$page->{'registerform'} = [''];
$page->{'message'}->{'type'} = "error";
$page->{'message'}->{'text'} = "error_insert_username";
#print xml http header along with session cookie
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
}
elsif(not $query->param('pass') and ($query->param('user') or $query->param('pass_repeat')))
{
$page->{'registerform'} = [''];
$page->{'message'}->{'type'} = "error";
$page->{'message'}->{'text'} = "error_insert_password";
#print xml http header along with session cookie
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
}
elsif(not $query->param('pass_repeat') and ($query->param('user') or $query->param('pass')))
{
$page->{'registerform'} = [''];
$page->{'message'}->{'type'} = "error";
$page->{'message'}->{'text'} = "error_repeat_password";
#print xml http header along with session cookie
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
}
else
{
$page->{'registerform'} = [''];
#print xml http header along with session cookie
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');
}
#print xml http header along with session cookie
print $session->header(-type=>'text/xml', -charset=>'UTF-8');
print XMLout($page, KeyAttr => {}, XMLDecl => $XMLDecl, RootName => 'page', AttrIndent => '1');

View file

@ -27,6 +27,8 @@
<str id="page_upload">/upload.pl</str>
<str id="page_uploader">uploader.pl</str>
<str id="page_query_latestadditions">search.pl?query=&amp;orderby=timestamp&amp;sort=desc</str>
<str id="page_query_mostdownloads">search.pl?query=&amp;orderby=downloadcount&amp;sort=desc</str>
<str id="page_query_mostviews">search.pl?query=&amp;orderby=viewcount&amp;sort=desc</str>
</strings>

33
trunk/tagcloud.pl Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/perl -w
use DBI;
use Data::Dumper::Simple;
$database = 'yolanda';
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass);
$sth = $dbh->prepare("select subject from videos");
$sth->execute();
while(($subject) = $sth->fetchrow_array())
{
@subject = split(',', $subject);
foreach my $val (@subject)
{
$val =~ s/^\s*(.*?)\s*$/$1/;
%hash->{$val}++;
}
}
$sth->finish();
@sorted = sort {$hash{$b} cmp $hash{$a}} keys %hash;
$dbh->do("delete from tagcloud");
$sth = $dbh->prepare("insert into tagcloud (text, count) values (?, ?)");
for($i=0;$i<20 and $i<=$#sorted;$i++)
{
$sth->execute( $sorted[$i], %hash->{$sorted[$i]} );
}

View file

@ -17,11 +17,11 @@
omit-xml-declaration="no"
/>
<xsl:include href="/xsl/xhtml/results.xsl"/>
<xsl:include href="/xsl/xhtml/video.xsl"/>
<xsl:include href="../xsl/xhtml/results.xsl"/>
<xsl:include href="../xsl/xhtml/video.xsl"/>
<xsl:variable name="site_strings" select="document('../site/main.xml')//strings/str" />
<xsl:variable name="locale_strings" select="document(concat('../locale/',/page/@locale,'.xml'))//strings/str" />
<xsl:variable name="locale_strings" select="document('../locale/en-us.xml')//strings/str" />
<!-- this kills 99% of the processed XML... sorry Tim Bray.... -->
<xsl:template match="@*|node()">
@ -240,9 +240,19 @@
<xsl:value-of select="$locale_strings[@id='query_latestadditions']" />
</a>
<xsl:value-of select="$locale_strings[@id='separator']" />
<a href="about:blank"><xsl:value-of select="$locale_strings[@id='query_mostdownloads']" /></a>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='page_query_mostdownloads']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='query_mostdownloads']" />
</a>
<xsl:value-of select="$locale_strings[@id='separator']" />
<a href="about:blank"><xsl:value-of select="$locale_strings[@id='query_bestrated']" /></a>
<a>
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='page_query_mostviews']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='query_mostviews']" />
</a>
</div>
<xsl:call-template name="tagcloud"/>
@ -300,19 +310,14 @@
</xsl:template>
<xsl:template name="tagcloud">
<xsl:variable name="max" select="//tagcloud/tag/count[not(//tagcloud/tag/count &gt; .)]" />
<xsl:variable name="min" select="//tagcloud/tag/count[not(//tagcloud/tag/count &lt; .)]" />
<div class="tagcloud">
<xsl:for-each select="//tagcloud/tag">
<xsl:sort select="text" order="ascending" data-type="text" />
<a class="tag">
<xsl:attribute name="style">
<xsl:choose>
<xsl:when test="count &gt;= 64">font-size:32px</xsl:when>
<xsl:when test="count &lt;= 28">font-size:14px</xsl:when>
<xsl:otherwise>
font-size:<xsl:value-of select="round(number(count)div 2)" />px
</xsl:otherwise>
</xsl:choose>
font-size:<xsl:value-of select="round((32-12)*(number(count)-number($min))div (number($max)-number($min)))+12" />px
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='page_results']" />