Molecular Biomedical Informatics 分子生醫資訊實驗室 Social Web Design & Research 社群網站設計 & 研究 Social Web Design & Research 1.

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

Social Web Design 1 Darby Chang Social Web Design.
Molecular Biomedical Informatics Web Programming 1.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
1 CGICGI Common Gateway Interface Server-side Programming Lecture.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
DT228/3 Web Development WWW and Client server model.
Social Web Design 社群網站設計 1 Darby Chang 張天豪 Social Web Design 社群網站設計.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
Languages for Dynamic Web Documents
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Server-Side vs. Client-Side Scripting Languages
AJAX Presented by: Dickson Fu Dimas Ariawan Niels Andreassen Ryan Dial Jordan Nielson CMPUT 410 University of Alberta 2006.
HTML Form Processing Learning Web Design – Chapter 9, pp Squirrel Book – Chapter 11, pp
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
Python and Web Programming
Does Ajax suck? CS575 Spring 2007 Chanwit Suebsureekul.
Guide To UNIX Using Linux Third Edition
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
Chapter 6: Hostile Code Guide to Computer Network Security.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Web Programming 網際網路程式設計 1.
CGI Programming Languages Web Based Software Development July 21, 2005 Song, JaeHa.
Social Web Design 社群網站設計 1 Darby Chang 張天豪 Social Web Design 社群網站設計.
Molecular Biomedical Informatics 分子生醫資訊實驗室 Social Web Design & Research 社群網站設計 & 研究 Social Web Design & Research 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
UFCEKG-20-2 Data, Schemas & Applications Lecture 4 Server Side Scripting & PHP.
INTRODUCTION TO WEB DATABASE PROGRAMMING
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
JavaScript & jQuery the missing manual Chapter 11
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Ruth Betcher Ruth Christie
Lecture 12 – AJAX SFDV3011 – Advanced Web Development Reference: 1.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Instructor, Dr. Khalili Bahram Jeevan Kumar Gogineni.
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
Chapter 9: Perl and CGI Programming CGI Programming Acknowledgement: Some materials are taken from Teach Yourself CGI Programming with PERL 5 in a Week.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
Building Rich Web Applications with Ajax Linda Dailey Paulson IEEE – Computer, October 05 (Vol.38, No.10) Presented by Jingming Zhang.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Intermediate CGI & CGI.pm Webmaster II - Fort Collins, CO Copyright © XTR Systems, LLC CGI Programming & The CGI.pm Perl Module Instructor: Joseph DiVerdi,
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
the acronym for Asynchronous JavaScript and XML.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Fall 2000C.Watters1 World Wide Web and E-Commerce Servers & Server Side Processing.
JQuery and AJAX WEB Technologies : PHP Programming Language.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
University of Kansas Department of Electrical Engineering and Computer Science Dr. Susan Gauch April 21, 2005 I T T C Introduction to Web Technologies.
Javascript and Dynamic Web Pages: Client Side Processing
JavaScript and Ajax (Ajax Tutorial)
CS 330 Class 7 Comments on Exam Programming plan for today:
AJAX and REST.
AJAX.
AJAX.
Web Application Development Using PHP
Presentation transcript:

Molecular Biomedical Informatics 分子生醫資訊實驗室 Social Web Design & Research 社群網站設計 & 研究 Social Web Design & Research 1

CGI 2 Social Web Design & Research

Common Gateway Interface (CGI) Common – 通用 Gateway – 閘道 Interface – 介面 Social Web Design & Research 3

4

It’s an interface It allows browsers (and thus users) to communicate with web servers –In brief, an interface is a bulk of rules. If you program follows these rules, you can communicate with browsers. A program that fits these rules is called a CGI program. –CGI is over HTTP A CGI program is just a program where the only thing need to know is how its IO related to browsers’ IO Social Web Design & Research 5 Browser CGI Program Web Server HTML FormEnvironment Standard OutputHTML

HTML form Passing data to the server side Boy Girl Submit HTML Forms and Input You know HTML, and thus you know the browsers' IO Social Web Design & Research 6

CGI program CGI is not a language. If you follow the rules, you can use any programming language to implement a CGI program. But please don’t try any… –Perl is a widely used language in CGI programming. In addition to Perl, shell script, Python, Ruby, PHP, Tcl, C/C++ and Visual Basic can be used for CGI programming  by 通用網關 介面 - 維基百科,自由的百科全書 通用網關 介面 - 維基百科,自由的百科全書 Social Web Design & Research 7

8 Job trends

c, java, javascript, c++, perl perl, php, jquery, python, ruby, objective-c Social Web Design & Research 9

CGI IO in Perl # input use CGI; my $cgi = new CGI; my $nick = $cgi->param('nick'); my $color = $cgi->param('color'); # output print "Content-type: text/html\n\n"; # HTTP header print "Hello World! "; # any valid HTML print "$nick likes $color!"; # any valid HTML Easy? Let’s see other languages Social Web Design & Research 10

HTTP header Chapter 10. HTTP Headers 好文 : HTTP 流程 與 HTTP Header 入門 好文 : HTTP 流程 與 HTTP Header 入門 HTTP Header 入門详解 HTTP Header 入門详解 You can use this to change the way that browsers parse your response, to return binary files (for download) and to specify the filename Social Web Design & Research 11

CGI IO in PHP Hello World! Social Web Design & Research 12

CGI IO in Ruby # input require 'cgi' cgi = CGI.new nick = cgi['nick'] color = cgi['color'] # output puts "Content-type: text/html"; puts # HTTP header puts "Hello World! "; # any valid HTML puts "#{nick} likes #{color}!"; # any valid HTML Social Web Design & Research 13

CGI IO in JSP Hello World! Social Web Design & Research 14

CGI IO in C #include #include int main(void) { // input char * query; char nick[256], color[256]; // dangerous data = getenv('QUERY_STRING'); sscanf(query, "nick=%s&color=%s", &nick, &color); // output printf("Content-type: text/html\n\n"); // HTTP header printf("Hello World! "); // any valid HTML printf("%s likes %s!", nick, color); # any valid HTML return 0; } 永遠的 UNIX > CGI 之 C 語言篇 永遠的 UNIX > CGI 之 C 語言篇 So just don’t use it Social Web Design & Research 15

16 How to change the content type in a server-side scripting language such as PHP? Social Web Design & Research

Test (debug) CGI programs Pass input data via the URL &color=blue Actually, browsers do the same thing while submitting a HTML form Social Web Design & Research 17

Any Questions? Social Web Design & Research 18

Ajax 19 Asynchronous JAvascript XML 非同步的 JavaScript 與 XML 技術 Social Web Design & Research

Ajax Ajax is a combination of multiple existing technologies –use HTML+CSS for expression –use JavaScript to operate DOM objects for dynamic effects –use XML for data exchange –use XMLHttpRequest for asynchronous connection with web server –use JavaScript to bind them all Ajax does not refer to a single technology but to organically using a series of related technologies Social Web Design & Research 20

A traditional web app Social Web Design & Research 21 Tell users to fill HTML forms and to request the server for each form. The server receives and processes the requested form and response the result page.

Innovation from existing technologies The above process wastes much bandwidth, since usually the result page is very similar to the request page. Namely, most HTML code are the same in the two pages. –in short, only very tiny part need to update We have such technologies for a long time. For example, we have already used JavaScript to update partial page (such as a marquee) or used XML to transfer data (but not web page) –actually, if someone thought to use JavaScript to update web page according to the transferred data, he got Ajax  the importance of idea Social Web Design & Research 22

Ajax Social Web Design & Research 23 Update a little 只改一點點

Killer applications Traditional web mails – Modern web mails – –Ajax requires JavaScript, thus some kind web sites would provide a non-Ajax version that does not depend on JavaScript – 浅谈 Gmail 邮箱发展历史 浅谈 Gmail 邮箱发展历史 – 回顾 Gmail 历史 —— 猛击网页邮箱的 G 点! 回顾 Gmail 历史 —— 猛击网页邮箱的 G 点! BTW, Ajax is regarded invented in 1998 by the Outlook Web Access team of Microsoft  the importance of idea –AJAX - 维基百科AJAX - 维基百科 Social Web Design & Research 24

Other Google applications Google Google Calendar Google Docs Google Maps The so-called rich interface application (RIA). Since each time only a tiny part is updated, the content could be very complicated. The entire page wouldn’t be reloaded. –some are too rich to provide a non-Ajax version Social Web Design & Research 25

Common Ajax-dependent components Auto complete ( 自動完成 ) –Ajax Autocomplete for jQueryAjax Autocomplete for jQuery –FCBKcompleteFCBKcomplete –ajax autocomplete - Google 搜尋ajax autocomplete - Google 搜尋 Tooltip ( 工具提示 ) –40+ Tooltips Scripts With AJAX, JavaScript & CSS40+ Tooltips Scripts With AJAX, JavaScript & CSS –tooltip - Google 搜尋tooltip - Google 搜尋 Upload ( 上傳 ) – –upload - Google 搜尋upload - Google 搜尋 Human is slow. Leak a partial content for the users to read (or let them to input something) first. The response time of human is very enough for machines to do the actual work. Don’t waste such time. Social Web Design & Research 26

A simple Ajax example Design logic –users fill a HTML form and submit it –after submitting, the client does not wait the response of the server and the control returns to the users immediately  this behavior is the so-called asynchronous ( 非同步 ) –change the content to ‘loading’, which makes the users comfortable –after receiving the server response, display the results Social Web Design & Research 27

Notes in HTML The design of HTML form should follow the conventions of the non-Ajax version, in case that you need a non-Ajax one Usually you need to set the id attribute of the DOM objects to update for manipulating them easily Social Web Design & Research 28

Notes in JavaScript An event to activate the Ajax Get the input data Invoke the Ajax –set the data (some transformation may be needed) –the CGI URL – After Ajax, you got two asynchronous program flows –after submitting, display messages to make users comfortable –after server response, display the results Social Web Design & Research 29

Any Questions? Social Web Design & Research 30

Today’s assignment 今天的任務 Social Web Design & Research 31

Make your web site memorable Implement at least one cross-computer (namely you cannot implement with only JavaScript) interaction with CGI, or even better, Ajax Reference –Ajax – jQuery APIAjax – jQuery API –Ajaxload - Ajax loading gif generatorAjaxload - Ajax loading gif generator –Preloaders.net - AJAX loading GIF and APNG spinners, bars and 3D animations generatorPreloaders.net - AJAX loading GIF and APNG spinners, bars and 3D animations generator –5 Ways to Make Ajax Calls with jQuery5 Ways to Make Ajax Calls with jQuery Your web site ( will be checked not before 23:59 4/9 (Tue). You may send a report (such as some important modifications) to me in case I did not notice your features. Social Web Design & Research 32

Appendix 附錄 33 Social Web Design & Research

If we have time… I’m sure that we won’t have spare time today :p We won’t have enough time to finish Perl in the whole semester so that I can only teach specific functions But I’m not sure what functions you need, so please think about it and feel free to discuss with me via any media Social Web Design & Research 34

Social Web Design & Research 35

Perl Script language The most advantages are string manipulation and hash The first line must be –#!/usr/bin/perl -w use strict; –be sure to include this line –Perl is an untyped ( 無型態 ) language where variables can be used without declaration, but the harm is larger (bugs) than the convenience You can use any language such as PHP, but try to prevent using C/C++ for CGI programming –native support, string manipulation, protection… –Perl can call C/C++ programs Social Web Design & Research 36

File IO in Perl open FH, 'res/member' or die; # open a file while ( ) { # each line chomp; # truncate the last "\n" character my ( $_name, $_nick ) = split "\t"; # split by tab $_nick eq $nick and $name = $_name and last; # compare } close FH; # close the file $_ = `/bin/cat _hello.html`; # use Linux command s/{name}/$name/g; # replace print "Content-type: text/html\n\n$_"; # output The magic $_ variable –using it well will largely reduce the code (but less readable for rookies) Sometime Perl looks like English Call outer programs/commands The concept of template ( 模板 ) Social Web Design & Research 37

Some tips Set CGI programs to executable –$ chmod 755 do You may debug as a Perl program –$./do # remember to fix the input There is a module to help output error messages to browser –use CGI::Carp "fatalsToBrowser"; Writable file –$ chmod 666 filename # make it writable to web server –open FH, ">filename" or die; –open FH, ">>filename" or die; Perl 學習手札 Perl 學習手札 Perl - 維基百科,自由的百科全書 Perl - 維基百科,自由的百科全書 Social Web Design & Research 38

Script/interpreted languages Interpreted Languages: PHP, Perl, Python, Ruby (Sheet One) Interpreted Languages: PHP, Perl, Python, Ruby (Sheet One) Interpreted Languages: PHP, Perl, Python, Ruby (Sheet Two) Interpreted Languages: PHP, Perl, Python, Ruby (Sheet Two) Social Web Design & Research 39