Introduction to JavaScript
JavaScript is a simple, interpreted programming language with object-oriented capabilities. Although it has the word "Java" in its name, it is not particularly related to the Java programming language developed by Sun. It was actually created by Netscape for use on the client-side in their Navigator browser, and on the server-side in their Enterprise server products. Its popularity now resides mostly on the client-side and it offers dynamic website developers the ability to create interactivity without having to request additional pages from the server. In some ways, it can mimic some of Perl's functionality while functioning solely within the browser, and without the aid of a call to the web server. Also, note that like Perl, JavaScript is case-sensitive, so be careful and be consistent in the naming of your variables and functions. It's commonly used for such tasks as:
* Popup Windows
* HTML Form Interaction
* Image Swapping
* Browser Redirection
lastest comment is an interesting idea
relationship of information that builds the community
what does the user get and admin get.
laundry list: news.yahoo.com
email:
send message-
perl talk to send mail... works only with UNIX
perl talk to SMTP -> net::SMTP
sendmail is on the box; SMTP is a trusted machine on the net somewhere.
receiving-
perl talks with pop3 -> net::POP... and many others mail::box....
CPAN is your friend some simple code line for how a module is using.
local folder can be a place for modules
get subject line.... example
token to get text out of the message
using a variable get you around various characters which might effect perls actions.
file
< read a file
>. write
>> append
-s for the size
-e if a file exists
encoding-
type: multipart/mixed
cut and paste can be used from CPAN
friendster model
The Main Concept
Friendster.com is a social networking site developed by Jonathan Abrams with the intention of creating the largest on-line house party - everyone at the party is a "friend of a friend" - which is a common way for people to meet in the real world. Thus, the site is only as interesting as the number of "friends" who agree to sign up. Friendster has already reached that tipping point as over 1.5 million people have signed up just in the past two and a half months. By allowing users to see friends of friends, you can create a somewhat "trusted" social network within which an individual can socialize through messages, photos, match suggestions, introductions, etc. The number of people you have access to is directly proportional to the number of friends you have. From a technical standpoint, some of the main features include:
* Session Management
Like any site with user accounts, Friendster uses session management to uniquely identify a user. One can only edit their profile, photos, friends, etc if they have successfully logged into the site. Once they are logged in, relevant info such as their user ID is stored in the session. Friendster also allows the "Save My Password Info" feature. In this case, extra information is set in the cookie on the user's computer which allows them to "auto-login".
* Creating, Updating, and Display of User Profile
#
One of the main things to do on Friendster is to tell other user's about yourself if they happen upon your name. This is done in one's profile. Users fill out an HTML form, and the information is saved in the Friendster database.
In the database, once can imagine that there is a member_profile table where this information is stored, along with a foreign key, "member_id", which matches a particular profile with a particular member. When someone else goes to look at a user's profile, this information is accessed and formatted for easy reading by the interested person.
for the rest below go to class 07 notes:
* Creating, Deleting, and Display of Friends
* Creating, Deleting, and Display of Testimonials
* Creating, Deleting, and Display of Messages
* Uploading and Deleting of Images
* Connection Determination
* Filterable Display of Users in Social Network
* E-Mail Notification
friends waiting for approval
TABLELAND!!!!! (kekeke)
table linking to direct the infomation in a better way. but in my case there are just a few. Friendster has tooo much stuff going on.
remember the file find widget... looks in to the hard drive to find a file and links in into the code for upload ing and such... (see class05 and 06)
ahhhhhh friends of friends see the connections.
#use strict;
use MIME::Parser;
use MIME::Entity;
use MIME::Base64;
use Net::POP3;
#use Net::POP3_ssl;
use XMLRPC::Lite;
my $username = 'myusername'; ## CHANGE THIS LINE
my $password = 'mypassword'; ## CHANGE THIS LINE
my $pop = Net::POP3->new('mymailserver', Timeout => 15); ## CHANGE THIS LINE
my $max_chars = 70; # Number of chars to allow in a line of text from an incoming message ## CHANGE THIS LINE
my $temp_folder = "/path/to/my/tmp/folder/"; ## CHANGE THIS LINE
my $image_output_folder = "/path/to/where/the/images/or/video/should/be/saved/"; ## CHANGE THIS LINE
my $image_output_folder_relative = "http://servername/relative/path/to/images/or/video/"; ## CHANGE THIS LINE
my $delete_messages = 1;
my $delete_temp_files = 1;
my $print_output = 1;
my $post_to_blog = 1;
my $blog_xmlrpc_url = "http://myserver/path/to/mt/mt-xmlrpc.cgi"; ## CHANGE THIS LINE
my $blog_id = 2; ## CHANGE THIS LINE
my $blog_username = "blogusername"; ## CHANGE THIS LINE
my $blog_password = "blogpassword"; ## CHANGE THIS LINE
my $umask = '0002'; # File creation to 775, 0022 would be 755
$umask = oct($umask) if $umask =~ /^0/;
if ($pop->login($username, $password))
{
umask $umask;
print(localtime() . "\n");
my $parser = MIME::Parser->new;
$parser->output_dir($temp_folder);
my $msgnums = $pop->list; # hashref of msgnum => size
my $messagenum = 0;
foreach my $msgnum (keys %$msgnums)
{
my $msg = $pop->get($msgnum);
###
# TO GET RAW DATA
###
#foreach my $messageline (@$msg)
#{
# chomp($messageline);
# print $messageline;
#}
my $entity = $parser->parse_data($msg);
#my $entity = $parser->parse(\*STDIN); // For testing with message file -- perl myphoto.pl < message
###
# GET MESSAGE HEADER
###
my $msg_head = $entity->head;
my $subject = "";
my $to = "";
my $from = "";
my $body = "";
my $attachment = "";
my $attachment_type = "";
my $attachment_relative = "";
##
# GET MESSAGE SUBJECT
##
if ($msg_head->count('Subject') > 0)
{
$subject = $msg_head->get('Subject');
}
##
# GET MESSAGE FROM
##
if ($msg_head->count('From') > 0)
{
$from = $msg_head->get('From');
if ($from =~ /<(.*)>/)
{
$from = $1;
}
}
##
# GET MESSAGE TO
##
if ($msg_head->count('To') > 0)
{
$to = $msg_head->get('To');
if ($to =~ /<(.*)>/)
{
$to = $1;
}
}
###
# GET MESSAGE PARTS (BODY AND ATTACHMENTS)
###
my @parts=$entity->parts;
my $partnum = 0;
my $mime_message_body;
my $is_mime = 0;
while(my $part = shift(@parts))
{
$is_mime = 1; # Yes we have a mime message
my $type=$part->head->mime_type || $part->head->effective_type;
if ($type =~ /image\/jpeg/ || $type =~ /image\/jpg/)
{
# Give me the entire body as one string (probably bad because these could be BIG images)
my $image = $part->bodyhandle->as_string;
my $file_name = "picture_" . time() . $partnum . $messagenum . ".jpg"; ## Make names uinque
my $image_file = $image_output_folder . $file_name;
my $fh = new FileHandle "> $image_file";
if (defined $fh) {
print $fh $image;
$fh->close;
}
$attachment = $file_name;
$attachment_type = "jpeg";
$attachment_relative = $image_output_folder_relative . $file_name;
}
elsif ($type =~ /text\/plain/i || $type =~ /text\/html/i)
{
# Plain Text portions or attachments
my $message_bodyhandle = $part->bodyhandle;
$mime_message_body = $message_bodyhandle->as_string;
@mime_message_array = split('\n',$mime_message_body);
my $done = 0;
foreach $message_line (@mime_message_array)
{
$message_line =~ s/<.*>//gi; # Strip out any HTML tags
if ($message_line =~ /^\n/ ||
$message_line =~ /^\s*\n/ ||
$message_line !~ /\w/)
{
# Ignore blank lines
}
elsif (length $message_line > $max_chars)
{
# Ignore lines too long to be text messages
}
elsif (!$done)
{
$message_body = $message_line; # Only grabbing first line
$done = 1;
}
}
$body = $message_body;
}
elsif ($type =~ /video\/3gpp/i)
{
# Video Mail
# Give me the entire body as one string (probably bad because these could be BIG)
my $video = $part->bodyhandle->as_string;
my $file_name = "video_" . time() . $partnum . $messagenum . ".3gp"; ## Make names uinque
my $video_file = $image_output_folder . $file_name;
my $fh = new FileHandle "> $video_file";
if (defined $fh) {
print $fh $video;
$fh->close;
}
$attachment = $file_name;
$attachment_type = "3gpp";
$attachment_relative = $image_output_folder_relative . $file_name;
}
else
{
print "Other Types " . $type . "\n\n"; # OUTPUT
}
$partnum++;
}
##
# IF IT ISN'T A MIME MESSAGE (NO ATTACHMENTS)
##
if (!$is_mime)
{
###
# GET MESSAGE BODY LINES
###
$msg_body = $entity->body;
my $message_body = "";
my $done = 0;
foreach $message_line (@$msg_body)
{
if ($message_line =~ /^\n/)
{
}
elsif (!$done)
{
$message_body = $message_line;
$done = 1;
}
}
$body = $message_body;
}
chomp($to);
chomp($from);
chomp($subject);
chomp($body);
if ($post_to_blog)
{
my $attachment_html = "";
if ($attachment_type eq "jpeg")
{
$attachment_html = "";
}
elsif ($attachment_type eq "3gpp")
{
$attachment_html = "
";
}
my $postresult=XMLRPC::Lite
->proxy($blog_xmlrpc_url)
->call('metaWeblog.newPost',$blog_id,$blog_username,$blog_password,
{
'title'=>$subject,
'description'=>$body . $attachment_html,
'mt_allow_comments'=>1,
'mt_allow_pings'=>1
},
1
)
->result;
}
if ($print_output)
{
print "Message To: $to\n";
print "Message From $from\n";
print "Message Subject $subject\n";
print "Message Body $body\n";
print "Message Attachment $attachment\n";
print "--------------------------\n";
}
if ($delete_messages)
{
$pop->delete($msgnum);
}
if ($delete_temp_files)
{
$parser->filer->purge;
}
$messagenum++;
}
}
$pop->quit;
rlelation of primary key one to many versus many to many.
there seems to be a inherant way to organized I guess which i understand which might be different to the way people are explaining.
jeff versus matty, seans stuff?
missed the linking tabls? I am not sure if I need them but I did not have them.
run commands through mysql command first then add to perl!
info.pl chmod 600
Always
#######
#connect to db
#####
blah blah
######
#disconnect
######
do command everything but select!>
null values to enter no information which once can add at a later time.
Now that we have a basic understanding of how to create a simple table, we need to develop a better understanding of how to separate our data into a particular configuration of tables. Database design has evolved to the point where there are specific steps you can take to optimize any database configuration. This process is called normalization and it has three distinct forms.
forms on normalization found on class notes
removing further redundancy deals with many to many relationship tables.
Multiple Table Joins
The whole point of having a relational database is to be able to connect two or more different tables such that we can extract various sets of data. The process of pulling data from two or more related tables is called a join. The most common is the inner join which has two different syntaxes. For our purposes, we will be using the older syntax, which is a bit easier to read. This format is:
SELECT [DISTINCT] column1[,column2]
FROM table1,table2[,table3]
[WHERE "conditions"]
[GROUP BY "column-list" [ASC | DESC] ]
[HAVING "conditions]
[ORDER BY "column-list" [ASC | DESC] ]
[LIMIT [offset,] number-rows]
see extended text to see working function
]]>use CGI::Carp qw(fatalsToBrowser);
# Define the name of the script just for reference
$scriptName = "mysql.cgi";
# Tell the browser what type of data to expect
print "Content-type: text/html\n\n";
#########################################################
# Print HTML
#########################################################
print qq^
"http://www.w3.org/TR/html4/loose.dtd">
This is the structure for the database Puffles:

PrePopulation:

'at the beach' added:

Select command used to find entries older then 2004/04/11:

Results from select command:

Command update:

Delete Command:

Final Population:

^;
exit;
"\" escapes a command in perl. so if you want to use character like $ @ ETC...
don't escape and it will "BARF"
subroutine for perl to receive form in for from html:
################################################
# Takes data from an HTML Form or URL string
################################################
sub input_vars_receive
{ $formData = $ENV{'QUERY_STRING'};
if ($ENV{'REQUEST_METHOD'} eq 'POST')
{ read(STDIN, $formData, $ENV{'CONTENT_LENGTH'});
}
this code allows people post or use the browser line.
persistance:
rewrites to the text field. if you dont the text field will return clear...
fix text
redo code
environment tags...
MySQL
chris' class note's
relational database
Tableis made up of:
columns: fields
rows: entries
if a field set is constant one can create a new table to be called into other table.
one to many relationship Like a book one book many pages, birth place,
Many to many relationship for example an album can thought of a part of many styles, can be called a linking table.
" ' " is MySQL's escape character command
insert add
update change
"LIKE"
]]>Code is in read more
]]>Mind you my server is set up to read perl scripts as .cgi
http://dimitri.negroponte.com/blog/dweb/dynamic.cgi
The code is in read more.
]]>use CGI::Carp
]]>Useful Resources Class Listserv
Perl 5 Reference Guide
Dissected Dynamic Websites
|
static vs dynamic in web-building
music site to look at, WholeNote
Bastardize version... because it is on the web...
-Static
-html
-Script
-perl
-php
-Scriptw/DB
-perl with DB
-php with DB
looked at Wallop
required reading:
learning perl
MySQL in 21 days
class info:
Course Description
How does one move away from creating static websites and toward building active, evolving hubs of activity? This class will cover the design and implementation of the "dynamic" website in two distinct but related contexts: the technical aspects of manipulating content "on the fly", and the end user experience of interacting in this type of setting. Particular attention will be given to social and community-based web interaction. The production environment will consist of the MySQL database and the Perl programming language. Students can expect to develop a firm knowledge of database design and optimization, the SQL query language, and the use of Perl to create dynamic activity of both orthodox and unorthodox nature. Late-semester topics will focus on interfacing this environment with other technologies such as JavaScript and Flash, along with data population and site architecture methodology. Introduction to Computational Media or equivalent programming experience is required. Students are also expected to have fluency in HTML or to come up to speed with it outside of class. Class requirements will include homework assignments to reinforce each week's concepts while simultaneously contributing to the student's "toolkit" of code and design principles. There will also be a midterm project, and a final project of the student's choosing. Given the wide range of applications that would benefit from a web-accessible database, students should feel free to use their project(s) from this class to support or enhance projects from other classes.
Syllabus
1. Introduction and Dynamic Website Theory Basics
2. Perl Basics and CGI: Script-Generated Pages
3. Database Design, MySQL, and the SQL Language - Part 1
4. Database Design, MySQL, and the SQL Language - Part 2
5. Perl Talks to MySQL: The Web to the Database and Back
6. Perl Tricks: The Basic and The Sexy
7. Dissection of a Dynamic Website: Friendster.com
8. Mid-Term Project Presentation
9. Dynamic Web Development on the Client-Side: JavaScript
10. More Client-Side: Interfacing with Flash
11. Dynamic Web Development and Scalability
12. Dissection of Dynamic Websites: DodgeBall, Wallop, WholeNote
13. Final Project Workshop
14. Final Project Presentation
Teacher Biography
Christopher Sung (B.S., Yale; M.P.S., NYU) is the President and CEO of eTonal Media, Inc. which owns and operates the WholeNote.com website for guitarists, the ActiveBass.com website for bassists, and ActiveMusician.com, an on-line retail musician store. eTonal's sites have garnered attention from such publications as The New York Times, Guitar Player magazine, Acoustic Guitar magazine, and Bass Player magazine. Prior to founding eTonal in 1999, he spent stints at Yale's Center for Studies in Music Technology (CSMT), the Banff School of the Arts, MIT Lincoln Laboratory, the Berklee College of Music, Microsoft Research, Interval Research, and Organic. Christopher holds a US patent in the field of music technology, and is active in the New York music scene, playing guitar with ASCAP and MAC-award winners Marcy Heisler and Zina Goldrich in the realm of musical theater, and with the singer/songwriter Talia Paul in the pop/rock sphere.