added configuration for site name.

added functionality for random tag lines.
made the search have a lot more options.
change HTML for footer.
added the Changelog to the footer.
updated intro page.
added installation instructions.
This commit is contained in:
briandilley 2004-10-28 06:29:35 +00:00
parent 5e417ac25c
commit 993a045eb4
10 changed files with 273 additions and 59 deletions

View File

@ -1,3 +1,12 @@
10-27-04
* added configuration for site name.
* added functionality for random tag lines.
* made the search have a lot more options.
* change HTML for footer.
* added the Changelog to the footer.
* updated intro page.
* added installation instructions.
10-26-04
* added "random" sorting method, and "Random 100" to
tab bar.

74
INSTALL Executable file
View File

@ -0,0 +1,74 @@
-*- kwotes install instructions -*-
Thanks for trying kwotes. Please forgive how slim this
INSTALL file is... at least there is one :)
WHAT YOU NEED:
--------------------------------------------------------------------------------------
CGI/Perl enabled web server
Mysql
DBI
DBD::Mysql
INSTALLING DBI and DBD:Mysql:
--------------------------------------------------------------------------------------
At a console:
perl -MCPAN -eshell
In the CPAN console:
install Bundle::DBI
install DBD::mysql
EXTRACTING THE TARBALL:
--------------------------------------------------------------------------------------
tar -zxvf kwotes.tar.gz
SETTING UP THE DATABASE:
--------------------------------------------------------------------------------------
Add the required kwotes tables to the database (in the directory where you
extracted kwotes):
mysql -u database_user -D database_name -h database_host_name -p < kwotes.sql
CONFIGURING KWOTES:
--------------------------------------------------------------------------------------
Open kwotes.conf.pl in your favorite text editor and modify as needed. The
only values that you MUST change are in the database section. They are:
$DB_TYPE - the database type (Must be mysql for now)
$DB_NAME - the name of the database on the database server
$DB_HOST - the hostname or ip address of the database server
$DB_USER - the username for connecting to the database
$DB_PASS - the password for connecting to the database
Other options that are cool for tweaking the functionality of kwotes can be
found in the "GENERAL STUFF" section of the configuration file.
SETTING PERMISSIONS:
--------------------------------------------------------------------------------------
Setting everything to 755 (rwxr-xr-x) doesn't hurt:
cd kwotes-directory;
chmod -R 755 *
You can come up with something more restrictive if you like.
CUSTOMIZING:
--------------------------------------------------------------------------------------
Kwotes can be easily customized by editing the files in the "html" directory
directly beneeth the kwotes directory. You can change the "site name" and
tagline (text that apears at the top of every page) by editing kwotes.conf.pl
FEEDBACK:
--------------------------------------------------------------------------------------
"It's broken you mofos!":
sux0r, well... submit a bug report at:
http://sourceforge.net/tracker/?atid=690836&group_id=121598&func=browse
"Hey, you should implement [insert your idea here]!"
sweet, submit a feature request here, and we'll see what we can do:
http://sourceforge.net/tracker/?group_id=121598&atid=690839

View File

@ -1,6 +1,8 @@
<p> Welcome to Kwotes, a chat quote database system with a twist.
<p>
Welcome to Kwotes, a chat quote database system with a twist.
The quotes are publicly moderated, so it's up to YOU to maintain the quality.
All quotes are accepted and if their ranking falls too low for too long, they are deleted.
To better your kwote browsing experience, visit the <a href="?action=search">search</a> page.
</p>
This system has advantages over existing systems. Here are a few:
@ -10,4 +12,4 @@
<li>Users may only submit a limited number of quotes per hour.</li>
<li>A Simple, standards-compliant design that works in all modern browsers(sorry NS4/IE3 users!)</li>
<li>The system is open source. You can download the source code using the link at the bottom of the page.</li>
</ul>
</ul>

View File

@ -1,32 +1,87 @@
<form action="${SCRIPT_NAME}" method="get">
<div style="margin-left: auto; margin-right: auto; width: 400px;">
<div style="margin-left: auto; margin-right: auto; width: 450px;">
<input type="hidden" name="action" value="list" />
<input type="hidden" name="s" value="0" />
<div>
<span style="margin-right: 10px;">Search Text:</span>
<input type="text" size="15" name="ss" /> <input type="submit" value="Search" />
<div class="search-container">
All fields are optional. Choosing a random sort order disables paging.
Search keywords can be seperated using a coma.
</div>
<span style="margin-right: 10px;">
Sort by:
<select name="o">
<option value="date">Date</option>
<option value="rating">Rating</option>
</select>
</span>
<div class="search-container">
<span class="search-label">Search text:</span>
<span class="search-option"><input type="text" size="20" name="ss" /></span>
</div>
<span>
Per page:
<select name="m">
<option value="5">5</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
</span>
<div class="search-container">
<span class="search-label">Sort by:</span>
<span class="search-option">
<select name="o">
<option value="date">Date</option>
<option value="rating">Rating</option>
<option value="random">Random</option>
</select>
</span>
</div>
<div class="search-container">
<span class="search-label">Sort direction:</span>
<span class="search-option">
<select name="so">
<option value="forward">Descending</option>
<option value="reverse">Ascending</option>
</select>
</span>
</div>
<div class="search-container">
<span class="search-label">Per page:</span>
<span class="search-option">
<select name="m">
<option value="5">5</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="200">200</option>
</select>
</span>
</div>
<div class="search-container">
<span class="search-label">Max results:</span>
<span class="search-option">
<select name="mr">
<option value="9999999999">No max</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="300">300</option>
<option value="400">400</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="2000">2000</option>
</select>
</span>
</div>
<div class="search-container">
<span class="search-label">Minimum rating:</span>
<span class="search-option">
<input type="text" size="5" name="minr" />
</span>
</div>
<div class="search-container">
<span class="search-label">Maximum rating:</span>
<span class="search-option">
<input type="text" size="5" name="maxr" />
</span>
</div>
<div class="search-container">
<input type="submit" value="Search" />
</div>
</div>
</form>
</form>

View File

@ -1,15 +1,21 @@
<div class="footer">
<a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.1</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">Valid CSS</a>
<a href="http://sourceforge.net/projects/kwotes/">Project Page</a>
<a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=121598&amp;type=1"
width="88" height="31" alt="SourceForge.net!" />
</a>
<span style="float: right;">${KWOTE_COUNT} Live Kwotes, ${KWOTE_BACKUP_COUNT} Deleted Kwotes</span>
<span style="float: left;">
<a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.1</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">Valid CSS</a>
<a href="http://sourceforge.net/projects/kwotes/">Project Page</a>
<a href="Changelog">Changelog</a>
</span>
<span style="float: right;">
${KWOTE_COUNT} Live Kwotes, ${KWOTE_BACKUP_COUNT} Deleted Kwotes
</span>
<span style="float: right; clear: right;">
<a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=121598&amp;type=1"
width="88" height="31" alt="SourceForge.net!" />
</a>
</span>
</div>
</div>
</body>
</html>
</html>

View File

@ -50,7 +50,7 @@
<span class="id-search">Kwote #&nbsp;<input type="text" size="5" name="id" id="id" /></span>
</div>
</form>
<span class="title">Kwotes - For happy goodness!</span>
<span class="title">${SITE_NAME} - ${TAG_LINE}</span>
</div>
<ul class="tab-menu">

View File

@ -89,6 +89,11 @@ a:hover, a:active
margin-top: 10px;
}
.sf-footer
{
float: right;
}
/* Horizontal Menu */
.tab-list
{

View File

@ -6,6 +6,12 @@ use DBI;
# database connection
my $GLOBAL_DBH = undef;
##
# Returns a random tagline
sub get_tagline {
return $TAG_LINES[ @TAG_LINES*rand() ];
}
##
# Returns the kwote count
sub get_kwote_count {
@ -192,7 +198,7 @@ sub get_kwote {
# Gets a list of kwotes
sub list_kwotes {
my ($dbh, $sort_by, $order_direction, $return_amt,
$start_index, $search_string) = @_;
$start_index, $search_string, $min_rating, $max_rating) = @_;
# clean up the numbers
$return_amt =~ s/[^0-9]//ig;
@ -211,16 +217,26 @@ sub list_kwotes {
my @kws = split(/,/,$search_string);
# build SQL query
my $sql = "SELECT * FROM kwote ";
my $sql = "SELECT * FROM kwote WHERE 1=1 ";
# search stuff
if (defined($search_string)) {
$sql .= "WHERE 1=1 ";
foreach my $kw (@kws) {
$sql.= "AND content LIKE ? ";
}
}
# min rating
if (defined($min_rating)) {
$sql .= "AND rating >= ? ";
}
# max rating
if (defined($max_rating)) {
$sql .= "AND rating <= ? ";
}
# sorting and paging
if (defined($sort_by)) {
$sql .= "ORDER BY $sort_by $order_direction ";
@ -231,14 +247,27 @@ sub list_kwotes {
# prepare
my $sth = $dbh->prepare($sql) or return undef;
my $param_num = 1;
# apply the search criteria
if (defined($search_string)) {
for ($i=0; $i<@kws; $i++) {
$sth->bind_param($i+1, "\%".$kws[$i]."\%");
for (my $i=0; $i<@kws; $i++) {
$sth->bind_param($param_num, "\%".$kws[$i]."\%");
$param_num++;
}
}
# min rating
if (defined($min_rating)) {
$sth->bind_param($param_num, $min_rating);
$param_num++;
}
# max rating
if (defined($max_rating)) {
$sth->bind_param($param_num, $max_rating);
$param_num++;
}
# execute
$sth->execute() or return undef;
@ -282,7 +311,7 @@ sub html_escape {
}
##
# Sends the HTML header
# Sends the HTML header
sub send_html_header {
print STDOUT "Content-type: text/html\n\n";
}
@ -324,7 +353,7 @@ sub parse_form {
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
$FORM{$name} = $value if (length($value)>0);
}
return %FORM;
}

View File

@ -1,5 +1,21 @@
#!/usr/bin/perl
############################
## LOOK N FEEL ##
############################
$SITE_NAME = "Kwotes";
# the name of the site
@TAG_LINES = (
"For happy goodness!",
"The better kwote database.",
"It blows goats!"
);
# tag lines to be randomly displayed
# in the header
############################
## DATABASE CONFIGURATION ##
############################
$DB_TYPE = "mysql";
# dbi database type (only MySQL is
# supported currently, due to the
@ -18,6 +34,9 @@ $DB_USER = "kwotes";
$DB_PASS = "kw0t3s";
# database password
############################
## GENERAL STUFF ##
############################
$SECS_BETWEEN_KWOTES = 60*60;
# seconds a user must wait after
# submitting MAX_KWOTES_PER_IP

View File

@ -3,8 +3,13 @@
###################################################
# -*- kwotes.pl -*- #
###################################################
# TOD: Put some interesting shit here, perhaps #
# something about kwotes being GPL #
# This code is distributed under GPL licensing #
# terms, here's a link to the license and stuff: #
# #
# http://www.gnu.org/licenses/gpl.txt #
# #
# have fun with it, i'm not a major perl monger #
# or anything, so be easy on me :) #
###################################################
# bring in the required libs
@ -31,11 +36,13 @@ foreach my $key (keys %ENV) {
$vars{$key} = $ENV{$key};
}
# add information that is displayed on every page
# add information that can be displayed on every page
$vars{KWOTE_COUNT} = get_kwote_count();
$vars{KWOTE_BACKUP_COUNT} = get_kwote_backup_count();
$vars{SITE_NAME} = $SITE_NAME;
$vars{TAG_LINE} = get_tagline();
# send the HTML header
# send header
send_html_header();
############
@ -127,9 +134,22 @@ if ($action eq "add") {
# search string?
my $search_string = $FORM{"ss"};
# rating requirements?
my $max_rating = $FORM{"maxr"};
my $min_rating = $FORM{"minr"};
# get the kwote
my $dbh = get_db_connection();
my @rows = list_kwotes($dbh, $sort, $sort_order, $max_returned, $start_index, $search_string);
my @rows = list_kwotes(
$dbh,
$sort,
$sort_order,
$max_returned,
$start_index,
$search_string,
$min_rating,
$max_rating
);
# setup these vars
$vars{TITLE} = "Kwotes";
@ -140,26 +160,21 @@ if ($action eq "add") {
$vars{MAX_RECORDS} = $max_records;
$vars{SEARCH_STRING} = $search_string;
# add the search header if it was a search
#if (defined($search_string)) {
# $main_content .= wrap_template("html/content-search.html", %vars);
#}
# get the navigation template
my $navigation_template = undef;
# forward, no back
if ($start_index<=0 && @rows>=$max_returned
if ($FORM{"o"} ne "random" && $start_index<=0 && @rows>=$max_returned
&& ($start_index+$max_returned)<$max_records) {
$navigation_template = "html/content-list-navigate-no-back.html";
# forward and back
} elsif ($start_index>0 && @rows>=$max_returned
} elsif ($FORM{"o"} ne "random" && $start_index>0 && @rows>=$max_returned
&& ($start_index+$max_returned)<$max_records ) {
$navigation_template = "html/content-list-navigate.html";
# back only
} elsif ($start_index>0 && @rows<$max_returned) {
} elsif ($FORM{"o"} ne "random" && $start_index>0 && @rows<$max_returned) {
$navigation_template = "html/content-list-navigate-no-forward.html";
}