Interesting

Place to discuss anything, almost. No politics, religion, Microsoft, or anything else that I (the nazi censor) deem inappropriate.

Interesting

Postby Void Main » Mon Jan 02, 2006 9:48 pm

Small things impress me:

Cool Site
Code: Select all
  ___ ___         __     __   _______         __       
 |   |   |.-----.|__|.--|  | |   |   |.---.-.|__|.-----.
 |   |   ||  _  ||  ||  _  | |       ||  _  ||  ||     |
  \_____/ |_____||__||_____| |__|_|__||___._||__||__|__|
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby worker201 » Tue Jan 03, 2006 1:03 pm

The page you linked to was generated by some sort of script.

I'd be interested in seeing that script...
worker201
guru
guru
 
Posts: 668
Joined: Sun Jun 13, 2004 6:38 pm
Location: Hawaii

Postby Void Main » Tue Jan 03, 2006 1:33 pm

Me too! Maybe we could figure out how to write our own. I can actually think of an easy way to do it although I'll bet there is a cooler way to do it than what I am thinking of.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby ZiaTioN » Wed Jan 04, 2006 9:19 am

I found a perl version called Figlet-CGI. I also found a debian command line package written in C here. The CGI version does not look like the one you found Void, but maybe they tweaked theirs a bit to display like it is.

Code: Select all
#!/usr/bin/perl -w
#Figlet-CGI 0.1 by Matthew Borowski
#(C)1999 WorldServe Consulting http://www.worldserve.net
#License: BSD
#Make sure to set the variables below
#
#use the CGI.pm object-oriented module
use strict;
use CGI;
my ($query, $text, $fontname, $fontpath, $maxfontname, $maxtext, $figlet, $fontnameext, @newtext);
#set your font path here (directory with your .flf files) with trailing slash
$fontpath = "/usr/local/share/figlet/";
#set the full path to figlet here
$figlet = "/usr/local/bin/figlet";
#set the maximum length of $fontname
$maxfontname = "30";
#set the maximum length of $text
$maxtext = "50";
#
#
#process the query (either GET or POST)
$query = new CGI;
#print the content-type out
print $query->header;

#make sure font is specified, else quit
unless ($query->param('fontname')){
   #print the starting html
   print $query->start_html("Figlet Error");
   print "<p>Sorry, you didn't select a fontname.\n";
   exit;
}
else {
   #set the text variable
   $fontname = $query->param('fontname');
   #escape out the single-quotes so we can enclose in single quote below
   $fontname =~ s:\':\'\\'\':g;
}
#if font is longer than $maxfontname characters, quit
if (length($query->param('fontname')) > $maxfontname){
   #print the starting html
   print $query->start_html("Figlet Error");
   print "<p>Sorry, your text is too long (longer than $maxfontname characters).\n";
   exit;
}
#if fontname doesn't end in .flf, then quit
$fontnameext = substr($fontname, -4);
unless ($fontnameext eq ".flf"){
   print $query->start_html("Figlet Error");
   print "<p>Sorry, your fontname does not end in .flf\n";
   exit;
}
#unless we can open the file, exit
unless(-r "$fontpath$fontname"){
   print $query->start_html("Figlet Error");
   print "<p>Invalid font. Cannot open $fontname.\n";
   exit;
}
   
#make sure text is specified, else quit
unless ($query->param('text')){
   #print the starting html
   print $query->start_html("Figlet Error");
   print "<p>Sorry, you didn't specify any text.\n";
   exit;
}
else {
   #set the text variable
   $text = $query->param('text');
   #escape out the single-quotes so we can enclose in single quote below
   $text =~ s:\':\'\\'\':g;
}
#if text is longer than $maxtext characters, quit
if (length($query->param('text')) > $maxtext){
   #print the starting html
   print $query->start_html("Figlet Error");
   print "<p>Sorry, your text is too long (longer than $maxtext characters).\n";
   exit;
}
#print the starting html
print $query->start_html("Figlet: $text");

#print the main part of the page
print <<END;

<h1>Figlet Results:</h1>
<p>Processing '$text' with font $fontname
<hr>
END

#newtext variable becomes the output of the figlet command
@newtext=`echo '$text' | $figlet -f '$fontpath$fontname'`;
#turn the < and > signs into proper HTML formatting (&lt; and &gt;)
s/</&lt;/g for @newtext;
s/>/&gt;/g for @newtext;

print "<p><pre>\n @newtext</pre>\n";
print "<hr>\n";

print "<p><font size=-1>Script $ENV{'SCRIPT_NAME'} requested with method $ENV{'REQUEST_METHOD'} by $ENV{'REMOTE_USER'} $ENV{'REMOTE_HOST'} ($ENV{'REMOTE_ADDR'}) with $ENV{'HTTP_USER_AGENT'}</font>\n";
print $query->end_html;

#END
ZiaTioN
administrator
administrator
 
Posts: 460
Joined: Tue Apr 08, 2003 3:28 pm

Postby Void Main » Wed Jan 04, 2006 10:21 am

Found the source and some related stuff here:
http://www.netsw.org/graphic/ascii/

It seems to work pretty well. For some reason there was an erroneous character in figlet.c. Just delete the first character in that file and it will make.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby Void Main » Mon Jan 09, 2006 11:47 pm

Actually there is a project web site for this:

http://www.figlet.org/

And there was Dag/Dries RPM that I added a bunch of extra fonts to and fixed the license (they have it listed as GPL but it's Artistic). Here are the new RPMS:

http://voidmain.is-a-geek.net/files/RPMS/figlet/

A web page I just whipped up to enter text/font:
http://voidmain.is-a-geek.net/files/mis ... gfonts.php
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA


Return to The Lounge

Who is online

Users browsing this forum: No registered users and 1 guest

cron