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 10-26-04
* added "random" sorting method, and "Random 100" to * added "random" sorting method, and "Random 100" to
tab bar. 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. 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. 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> </p>
This system has advantages over existing systems. Here are a few: This system has advantages over existing systems. Here are a few:

View File

@ -1,23 +1,42 @@
<form action="${SCRIPT_NAME}" method="get"> <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="action" value="list" />
<input type="hidden" name="s" value="0" /> <input type="hidden" name="s" value="0" />
<div> <div class="search-container">
<span style="margin-right: 10px;">Search Text:</span> All fields are optional. Choosing a random sort order disables paging.
<input type="text" size="15" name="ss" /> <input type="submit" value="Search" /> Search keywords can be seperated using a coma.
</div> </div>
<span style="margin-right: 10px;"> <div class="search-container">
Sort by: <span class="search-label">Search text:</span>
<span class="search-option"><input type="text" size="20" name="ss" /></span>
</div>
<div class="search-container">
<span class="search-label">Sort by:</span>
<span class="search-option">
<select name="o"> <select name="o">
<option value="date">Date</option> <option value="date">Date</option>
<option value="rating">Rating</option> <option value="rating">Rating</option>
<option value="random">Random</option>
</select> </select>
</span> </span>
</div>
<span> <div class="search-container">
Per page: <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"> <select name="m">
<option value="5">5</option> <option value="5">5</option>
<option value="20">20</option> <option value="20">20</option>
@ -29,4 +48,40 @@
</select> </select>
</span> </span>
</div> </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,13 +1,19 @@
<div class="footer"> <div class="footer">
<span style="float: left;">
<a href="http://validator.w3.org/check?uri=referer">Valid XHTML 1.1</a> <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://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/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"> <a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=121598&amp;type=1" <img src="http://sourceforge.net/sflogo.php?group_id=121598&amp;type=1"
width="88" height="31" alt="SourceForge.net!" /> width="88" height="31" alt="SourceForge.net!" />
</a> </a>
</span>
<span style="float: right;">${KWOTE_COUNT} Live Kwotes, ${KWOTE_BACKUP_COUNT} Deleted Kwotes</span>
</div> </div>
</div> </div>
</body> </body>

View File

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

View File

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

View File

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

View File

@ -1,5 +1,21 @@
#!/usr/bin/perl #!/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"; $DB_TYPE = "mysql";
# dbi database type (only MySQL is # dbi database type (only MySQL is
# supported currently, due to the # supported currently, due to the
@ -18,6 +34,9 @@ $DB_USER = "kwotes";
$DB_PASS = "kw0t3s"; $DB_PASS = "kw0t3s";
# database password # database password
############################
## GENERAL STUFF ##
############################
$SECS_BETWEEN_KWOTES = 60*60; $SECS_BETWEEN_KWOTES = 60*60;
# seconds a user must wait after # seconds a user must wait after
# submitting MAX_KWOTES_PER_IP # submitting MAX_KWOTES_PER_IP

View File

@ -3,8 +3,13 @@
################################################### ###################################################
# -*- kwotes.pl -*- # # -*- kwotes.pl -*- #
################################################### ###################################################
# TOD: Put some interesting shit here, perhaps # # This code is distributed under GPL licensing #
# something about kwotes being GPL # # 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 # bring in the required libs
@ -31,11 +36,13 @@ foreach my $key (keys %ENV) {
$vars{$key} = $ENV{$key}; $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_COUNT} = get_kwote_count();
$vars{KWOTE_BACKUP_COUNT} = get_kwote_backup_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(); send_html_header();
############ ############
@ -127,9 +134,22 @@ if ($action eq "add") {
# search string? # search string?
my $search_string = $FORM{"ss"}; my $search_string = $FORM{"ss"};
# rating requirements?
my $max_rating = $FORM{"maxr"};
my $min_rating = $FORM{"minr"};
# get the kwote # get the kwote
my $dbh = get_db_connection(); 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 # setup these vars
$vars{TITLE} = "Kwotes"; $vars{TITLE} = "Kwotes";
@ -140,26 +160,21 @@ if ($action eq "add") {
$vars{MAX_RECORDS} = $max_records; $vars{MAX_RECORDS} = $max_records;
$vars{SEARCH_STRING} = $search_string; $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 # get the navigation template
my $navigation_template = undef; my $navigation_template = undef;
# forward, no back # 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) { && ($start_index+$max_returned)<$max_records) {
$navigation_template = "html/content-list-navigate-no-back.html"; $navigation_template = "html/content-list-navigate-no-back.html";
# forward and back # 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 ) { && ($start_index+$max_returned)<$max_records ) {
$navigation_template = "html/content-list-navigate.html"; $navigation_template = "html/content-list-navigate.html";
# back only # 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"; $navigation_template = "html/content-list-navigate-no-forward.html";
} }