Lemur zaprasza
Red Hat Linux Unleashed rhl56.htm Introduction to the Web Introduction to Mosaic Where To Get Mosaic for Linux Hypertext Document and HTML Basics Hyperlinks Inline Images Where To Get More Help on HTML Netscape Where To Get Netscape SLIP Connections dip slattach Using Mosaic Document Title, URL, and Globe Viewing Area Bottom Control Panel The Cursor and Displaying Hyperlink URLs Shortcuts and Keyboard Options Writing a Hypertext Document URLs Using Other Browsers Summary 56 Using Mosaic and Netscape This chapter is a brief introduction to the World Wide Web and Mosaic and Netscape. We will cover the following topics in this chapter: A brief introduction to the Web. How to get Mosaic for Linux. How to set up Mosaic on your Linux machine. How to get and set up Netscape for your Linux machine. How to configure a SLIP connection for dialup and dedicated lines using Linux. Getting started with an HTML document. You will learn the basics of writing your own Web documents. Introduction to the Web The World Wide Web (WWW) is a fairly new invention. In 1989, researchers at CERN (a European Lab for Particle Physics) wanted to share information between nodes on their network. The researchers automated the process of locating files on remote machines and then copying the required information to their local machines. This retrieval process had to be done with a standard interface, regardless of the type of data or the means of getting this data. This meant that the interface had to include almost all the data retrieval tools such as FTP, Gopher, and so on, and be able to handle graphical, text, and binary files with a consistent interface. The resulting network was such a success that the method caught on with users worldwide and gave us the World Wide Web. The letters WWW are now synonymous with the word Internet. The number of sites offering Web services is growing every day. Although the Red Hat distribution that accompanies this book includes a copy of the Arena Web browser, Arena lacks much of the functionality provided by browsers such as Mosaic and Netscape. This chapter is included to show you how to download and install these more powerful browsers so that you can take advantage of the capabilities they offer. Introduction to Mosaic To access the services on the Web, you need a browser. A browser is an application that knows how to interpret and display documents it finds on the Web. Documents on the Web are encoded in the HyperText Markup Language (HTML). Hypertext documents contain special codes that tell the browser how to locate information on the Web. How the browser interprets the codes is left as a local issue. Some browsers such as Lynx ignore any requests for inline images; some older Mosaic browsers ignore the interactive Forms that a user can fill in while online. The hypertext Home Page about NCSA has the following information: "Established in 1985 with a National Science Foundation grant, the National Center for Supercomputing Applications (NCSA) opened to the national research community in January 1986. NCSA is a high-performance computing and communications facility designed to serve U.S. computational science and engineering communities. Located on the campus of the University of Illinois at Urbana-Champaign (UIUC), NCSA is funded by the National Science Foundation, the Advanced Research Projects Agency, other federal agencies, the state of Illinois, the University of Illinois, and industrial partners." Enough said. Mosaic includes the following features: The capability to display plain text, HTML documents, and audio The capability to display inline graphics and images A customizable graphical user interface The capability to track previous sites with lists in a History and Hotlist The capability to find items via search commands within a document and over the Internet Extendability via third-party viewers for a type of graphical data format Where To Get Mosaic for Linux The latest version is available from the Internet at the following FTP sites: sunsite.unc.edu in the directory /pub/Linux/system/Network/info-systems/Mosaic. There are several files in here with version numbers 2.0 and higher. The 2.5 version was the most recent stable one on my system at the time I wrote this chapter. Your mileage may vary. I used the file Mosaic-2.5.bin.tar.gz as my starting point. FTP to this site and get the latest version for yourself. tsx-11.mit.edu is a mirror site for sunsite. Use this site if sunsite appears to be very busy. Another excellent site for Web documents is the FTP site ftp.ncsa.uiuc.edu. Look under the /Web directory tree for a whole forest of documents on the Web, source code, and versions of Mosaic. If you have access to the Web already through another source, you should look at http://www.w3.org for information about the Web, latest source code, and other Web-related documents. After you get the files from these sources, you have to unzip the files via GNU's gunzip program. The gunzip program removes the .gz extension after it unzips a file. The commands to do this are shown next. Substitute the name of the Mosaic version you get for the word myfile here. $ ls myfile* myfile.tar.gz $ gunzip file.tar.gz $ ls myfile* myfile.tar $ tar -xf myfile.tar ... After the dust settles from the tar extraction command (the -x option is for extract), you have the file Mosaic in your directory. Along with these files, you also have some app-defaults files that you can use to customize your copy of Mosaic. As with other X applications, almost all of Mosaic's features can be customized using the Xdefaults file with the Mosaic resource. For example, to set the home page use this line: Mosaic*HomePage : "http://www.another.nicer.site.com/myfile" Alternatively, you can set the WWW_HOME environment variable to the path shown above. Using the environment variable is more consistent with other UNIX platforms. The distributions from NCSA include the app-defaults files for each version of Mosaic. After you have installed Mosaic on your machine, edit these files to customize your own files. Read the app-defaults files for all the resources that are available to you for your version of Mosaic. Now, you can fire up Mosaic from within an xterm with the command Mosaic. (It's probably best to have Mosaic run in the background so as not to tie up your xterm.) When Mosaic is up, it attempts to load its default hypertext document called the Home Page. Basically, the Home Page is the first document you start off with and the one document that you know that you can always load if you get lost while browsing the Web. Before you go browsing the Web, let's first talk about hypertext documents. Once you know how hypertext documents work, you'll find it easier to browse the Web. Be patient; the next section is worth your time to read. Hypertext Document and HTML Basics Hypertext documents contain links to other documents on the Web. Links are often called hyper-links. They enable you to access other documents and services on the Internet. You surf the Net by accessing other documents through these links. It's fairly easy to create these hypertext documents with links, so you can create your own documents with sites that you regularly visit and find interesting. To create a hypertext document for display on a Web server, you have to learn the HyperText Markup Language (HTML), which is a collection of styles that define the various components of a document. HTML is based on SGML (Standardized General Markup Language), a superset standard of marking documents. So why write your own Web page? There are many reasons that you would want to create your own HTML documents. The first reason is for exposure. Your own document on the Internet can have information about you or topics that you find interesting. You can have a page about your business, because a Web address on a business card does look cool. Just remember not to spam your page's address on the Internet; it's not polite. (Spamming is the slang word for posting multiple copies of a message to many unrelated newsgroups.) Second, a Web page can be a repository of your favorite sites on the Internet. While cruising the Net, if you come across a decent page or two, you can simply edit your own Web page to add this site. Then, it's simply a matter of bringing up your favorite page to get back to the old sites again. Last, you may decide to dump Mosaic and go with a newer, better browser that doesn't read the hotlists you created from Mosaic. For example, you have to jump through hoops to get your Windows browsers' hotlists into UNIX Mosaic, or vice versa. When all your data is in a Web document, all you have to do is load the document in there, and you are doneno formats, hoops, and magic potions. Mosaic can display ASCII text files. Therefore, you really don't need to know HTML to write up an HTML document. Any old file will do. However, if you want to have a document formatted when accessed by a viewer such as Mosaic, you must code it with HTML. HTML documents are also called source files. Source files are in plain text format and can be created using any text editor. Let's get into a bit more detail about HTML formatting codes, called tags. HTML tags consist of a left angle bracket (<), followed by some coding (called the directive), and closed by a right angle bracket (>). HTML tags are generally paired, as with <H1> and </H1>. The ending tag looks just like the starting tag except a slash (/) precedes the directive within the brackets. For example, <H1> tells the viewer to start formatting a top-level heading, and </H1> tells the viewer that the heading is complete. HTML tags are inserted in the source files to tell Mosaic (or some other Web viewer) how to interpret or display the coded information. For example, citation tags are defined by Mosaic to be displayed in italics. Each time you enclose a book title between <cite> and </cite> tags, Mosaic automatically displays the text in italics. This is known as a logical style, because it is configured by the viewer. Viewers can interpret a logical style in different ways. Hyperlinks The chief power of HTML comes from its capability to link regions of text (and also images) to another document (or an image, movie, or audio file). These regions are highlighted to indicate that they are hypertext links. To create a hyperlink, a special HTML code is entered that includes the Uniform Resource Locator (URL). A URL is the way of telling your Web browser where and how to get the information. You can jump directly to URLs to see whether they are valid by using the URL command from the File menu. Enter the URL in the dialog box, and Mosaic attempts to get it for you. (See Figure 56.1.) Figure 56.1. Jumping hyperlinks via URLs. At the same time, text or a graphic is designated to serve as the anchor (the information that is displayed in color or underlined and clicked on). A hyperlink may be made to a remote or local server, depending on how the URL is encoded. You can keep a history of information space navigation, which tracks where you've been. You now have quick access to frequently used documents via a personal list. (See Figure 56.2.) History lists are valid for a current session only. Hotlists are those lists that you want to keep for all future sessions. (See Figure 56.3.) You should enter those places here that you may like to visit in a future session. Figure 56.2. The Mosaic History dialog box. Figure 56.3. The Mosaic Hotlist dialog box. Inline Images Mosaic can display images inside documents, making it a highly visual medium for your information. However, each image requires processing time, which slows down the initial display of the document. Using a particular image multiple times in a document causes very little performance degradation compared to using the image only once. An image is sized before it is included in a document. Images can fill a screen. Or, they can be small images that save time when Mosaic displays the document, but are still large enough to present information and be a teaser for the larger image displayed in a separate window. An image tag is coded into the source file to tell Mosaic that an image is to be displayed. The image tag is an HTML extension, first implemented in Mosaic. You can test your Web pages by loading this file locally to see how it looks. You don't necessarily have to be connected to the Internet to do this. Where To Get More Help on HTML When you have Mosaic, you have access to online help for writing your own HTML documents. To get The Beginner's Guide to HTML select On HTML... from the help menu. You have to be on the Internet for this to work, because Mosaic accesses the Web to get the latest copy for you. This file provides up-to-date information in far greater detail than what you are reading right now. You should print this guide out for future reference. See also Teach Yourself Web Publishing with HTML in 14 Days (Sams Publishing). Netscape The authors of the first NCSA Mosaic have formed their own company called Netscape Communications. Their new brainchild is called Netscape, and you can get a Linux version of it for yourself. The format for using Netscape is very similar to that of Motif. You can use URLs to type your destination name or use the point-and-click method to navigate HTML documents. The options buttons include the ability to turn on and off the button bar, URL locator, and the bottom status bars. This way, you can customize your screens to suit your preferences. A sample of the preferences file is shown in Listing 56.1. Listing 56.1. A sample Netscape preferences file. # Netscape Preferences File # Version: 1.1N # This is a generated file! Do not edit. SHOW_TOOLBAR: True SHOW_URL: True SHOW_DIRECTORY_BUTTONS: False AUTOLOAD_IMAGES: True FTP_FILE_INFO: True SHOW_SECURITY_BAR: False TOOLBAR_ICONS: False TOOLBAR_TEXT: True HOME_DOCUMENT: http://www.ikra.com/ FONT_SIZE: 2 UNDERLINE_LINKS: True HISTORY_FILE: /home/khusain/.netscape-history HISTORY_EXPIRATION: 30 BOOKMARKS_FILE: /home/khusain/.netscape-bookmarks.html TMPDIR: /tmp TN3270: xterm -e tn3270 %h TELNET: xterm -e telnet %h %p RLOGIN: xterm -e rlogin %h RLOGIN_USER: xterm -e rlogin %h -l %u NNTPSERVER: news NEWSRC_DIR: /home/khusain NEWS_MAX_ARTICLES: 100 REAL_NAME: Jonathan Doe Husain EMAIL_ADDRESS: khusain@ikra.com ORGANIZATION: Hardly any mps inc. SIGNATURE_FILE: /home/khusain/.signature SIGNATURE_DATE: 0 8BIT_MAIL_AND_NEWS: True MAILHOST: localhost SOCKS_HOST: FTP_PROXY: HTTP_PROXY: HTTPS_PROXY: GOPHER_PROXY: WAIS_PROXY: NO_PROXY: MEMORY_CACHE_SIZE: 2000 DISK_CACHE_SIZE: 5000 SOCKET_BUFFER_SIZE: 32 MAX_CONNECTIONS: 4 CACHE_DIR: /home/khusain/.netscape-cache LICENSE_ACCEPTED: 501 1.1N DITHER_IMAGES: True STREAMING_IMAGES: True VERIFY_DOCUMENTS: 0 MIME_TYPES: /usr/local/lib/netscape/mime.types PERSONAL_MIME_TYPES: /home/khusain/.mime.types MAILCAP: /usr/local/lib/netscape/mailcap PERSONAL_MAILCAP: /home/khusain/.mailcap WARN_ENTER_SECURE: False WARN_LEAVE_SECURE: False WARN_MIXED_SECURE: False WARN_SUBMIT_INSECURE: False ADD_URLS: BOOKMARK_MENU: PRINT_COMMAND: lpr PRINT_REVERSED: False PRINT_COLOR: True PRINT_LANDSCAPE: False PRINT_PAPER: 0 Even though this file states "do not edit," you can get away with a few changes via a text editor. Keep in mind though, that any changes you make through the preferences dialog in the main screen may override what you edited manually. The "N" display at the top right-hand corner of your display shows shooting stars as files are downloaded. If you want to stop any further transfers, you can click your mouse on this icon. The bookmark feature is a bit more intuitive than for Mosaic. In fact, for some people, it's a bit easier to use and edit. Netscape creates a .netscape_cache directory in your home directory, primarily for keeping track of images for HTML files. The size of this directory can get quite big after a few sessions of Netscape. Once in a while, if you are short of disk space, delete the files in this directory and the history file called .netscape-history file. Another file of interest would be the .netscape-history file. This file can get large, too, after a few months of Web browsing, because this is where Netscape tracks where you have been. You can use this file as a guide to hunt for that special location that you just cannot remember now. If only my memory were this easily accessible. Where To Get Netscape You can get netscape from www.netscape.com, the home site for Netscape Communications. Read the license agreements carefully. All you get is a 90-day evaluation period if you are not a student or are using it for commercial, as opposed to personal, reasons. Installation is easy. Get the file from the www.netscape.com site and un-tar it. You will have all the executables and associated files in a subdirectory. If you are using Netscape Version 1.1, you will get an error or warning message that the environment variable XNLSPATH does not contain the correct config files. This causes the program to crash if you cut and paste text in its text fields. The included files have to be placed in /usr/X386/lib/X11/nls, or you should set XNLSPATH to the nls subdirectory where you installed netscape. Your best course of action would be to get Netscape 2.01 (or the latest version) from the Web site at http://www.mcom.com/comprod/mirror/index.html. SLIP Connections Setting up a SLIP connection is necessary if you are not already on the Internet. To get a dialup SLIP connection you have to use the /sbin/dip program. The dip stands for Dialup Internet Protocol. For a dedicated connection you should use the slattach program. If you are already connected to the Internet through another means, skip this section entirely. dip The dip program uses a script file to connect you to a SLIP account. You need a SLIP account to use Mosaic. Using dip with a -t option can also let you run in interactive mode for debugging, but in most cases you use it with a script file. A script file is basically a file that handles your login and setup for you. You invoke /sbin/dip with the script name as an argument. A sample script file to work with my Internet SLIP account is shown in Listing 56.2. Your Internet provider should provide a script for you. If it does not provide one, ask for it. Let's look at this sample script file in Listing 56.2. Listing 56.2. A sample dip script file. main: # # Get the local and remote names for the network # get $remote remote # # # default get $mtu 1500 port cua1 speed 38400 modem HAYES flush reset send +++ sleep 1 send ate1v1m1q0\r wait OK 2 if $errlvl != 0 goto error send atdt5551212\r if $errlvl != 0 goto error # wait CONNECT 60 login: sleep 3 wait login: 30 if $errlvl != 0 goto error send johndoe\r wait ord: 5 send doa+sol!\r wait TERM 10 send dumb\r wait $ 10 send dslip\r wait Your 10 # # get $remote remote # get $local remote # # Ask for the remote site's IP address interactively from the user # get $remote ask # cannot do this dec $remote done: print LOCAL address is $local print CONNECTED to $remote print GATEWAY address $remote default mode CSLIP goto exit error: print SLIP to $remote failed exit: Listing 56.2 shows how to access an Internet service provider via a dialup SLIP account. This script gives you an example of how to log into the remote system and get your local address, and even asks you for the remote IP address. Normally, you run the SLIP script as root. You can set the permissions on the files in /etc/dip for all user access and not have to run as root. For debugging purposes, the -v option echoes all the script lines as they are executed. The echo on and echo off commands in script files turn the echoing on or off while executing. The -v option is like having the echo on command set as the first line in the script file. The modem command in the scripts for dip only supports the HAYES parameter. You can set the speed with the speed command. For other parameters of your modem, use the Hayes command set. For example, send ate1v1m1q0\r sends the accompanying string to the modem to initialize it. You can send output to the modem (and remote host) with the send command. To wait for a specific string, use the wait command with part of the string you are waiting for. Beware though, that if the string you are waiting for never appears, you can hang forever. The sleep command simply pauses the shell execution for the specified number of seconds. All variables for dip must be lowercase and preceded with a dollar sign. The dip program recognizes the following special variables: $remote for remote host name $rmtip for remote host IP address $local for local host name $locip for local host IP address $mtu contains the MTU value for the connection. _ You get this value from your internet provider. The get command is dip's way of setting a variable. The following line requests the name of the remote host from the user. The ask parameter tells dip to prompt the user for the input. get $remote ask The local address for this script is derived when you log into your service provider. The remote host prints out a string of the form Your IP address is zzz.yyy.xxx.www. So the script waits for the Your string and then gets the last word on the line. Some SLIP service providers assign you a different address every time you log in, so you have to do this. The way to do this is as follows: # # Get local address from this string. # wait Your 10 get $local remote The default command tells dip to route all default message traffic points to the SLIP link. The default command should be executed just before the mode command. The mode command recognizes either SLIP or CSLIP as a parameter. CSLIP is the compressed SLIP mode. If all goes well, the dip program goes into daemon mode. The dip program executes the ifconfig program to automatically configure your interface as a point-to-point link. Finally, to kill an existing dip process, you can use /sbin/dip with the -k option. You should do this when you turn off your machine or log out to free up your phone line. Read Chapter 42, "Networking," to set your /etc/hosts file. Also, if you are not familiar with the ifconfig and traceroute commands, read the man pages for them. The ifconfig program configures and maintains kernel resident network interfaces. The traceroute command is useful in tracking messages as they come and go from your machine on the SLIP link. It is an invaluable tool for debugging. slattach The slattach file is used to connect on a dedicated line to a remote server. If your modem is on /dev/cua2, the command to configure a CSLIP connection is run as root: # slattach /dev/cua2 & You can put this in your rc.inet files if you like. If your service provider does not support CSLIP, you can use the -p slip option to get the uncompressed SLIP mode. Just make sure that you run the same mode as your service provider. Then, you execute the following commands: # ifconfig sl0 localhost pointtopoint myrichISP # route add myrichISP # route add default gw myrichISP The first command connects you as a point-to-point to a SLIP connection. (The sl0 is ess el zero.) The next two commands add the node myrichISP (the Internet service provider) as the default route. To kill this connection, you must issue the following commands: # route del default # route del myrichISP # ifconfig sl0 down # kill -9 (slAttachPID) In this case, slAttachPID is the process ID of the slattach process. For more information on setting up SLIP connections, see Chapter 42. Using Mosaic The Mosaic Document View screen is where you see all the HTML documents on the Web. (See Figure 56.4.) Figure 56.4. The Mosaic main screen. The Document View window has five pull-down menus: File, Options, Navigate, Annotate, and Help. The main portion of the screen is taken up by the viewing area for the data. Mosaic shows the title of the document and its URL under the menu bar. To navigate the Web of information, a single click of your left mouse button on the words or images shown in color or underlined, which are the hyperlinks between documents, starts the transfer. Document Title, URL, and Globe The Document Title field displays the title assigned to the document you are viewing. Not all authors include document titles when they prepare files. Therefore, sometimes there is a default entry in the Document Title field showing basic information about the document and its source. Under the title is the Document URL field, which lists the server type and location, and the path of the document currently being viewed. In the upper-right corner of the Mosaic screen is a globe superimposed on a stylized S. This is the official logo for NCSA Mosaic. This globe icon serves two purposes: When a hyperlink is activated by clicking on the word or image, the globe spins and beams of light travel along the segments of the S toward the globe. This movement signifies that your document is being retrieved. You can abort any current document retrieval process by clicking on the globe. The beams of light usually stop when you do this, which in turn indicates that the current transfer has been aborted. The status line then displays the message. If part of the file was already retrieved without the inline images, the Document View window contains the new document; click the Back button at the bottom of the window to return to the document containing the hyperlink. Viewing Area Below the Document URL field is the viewing area, which displays the contents of the current document file. The highlighted or underlined words or images within the viewing area are actually hyperlinks to other files. Use the scroll bar on the right side of the viewing area to move up and down in the file contents. Some hyperlinks open in separate windows because they depend on external viewers to display the file contents. This is generally true for movies and for some graphics. To alert you that this is the case, Mosaic displays the message Spawning external viewer in the information line at the bottom of the window. If Mosaic attempts to spawn an external viewer that is not installed, an error message may be displayed on the console (xterm) from which Mosaic was executed. NCSA Mosaic may ask you to enter a filename to save the current unidentifiable document. The Document View window also displays the status of the current retrieval process in the information line. Somewhere between the document viewing area and the bottom row of control buttons is an area that Mosaic uses to let you know specific information such as the status of your retrieval of a file, the use of an external viewer, and the URL of a linked file. Bottom Control Panel Nine buttons form the bottom control panel: Back, Forward, Home, Reload, Open, Save As, Clone, New Window, and Close Window. The buttons provide shortcut access to items contained within the five pull-down menus. If your Document View window is not wide enough, all nine buttons are not displayed. Because the function of each button is also offered in a pull-down menu, no functionality is lost if you open a narrow Document View window. The following list discusses each button, and notes the corresponding pull-down menu option. Back Returns to the previous document in the Document View window history (such as you have followed a hyperlink or selected a menu item). No action can be performed if you have only viewed one document so far. Also available on the Navigate menu. Forward Returns to the document that preceded the current document. This button is dimmed if you have not moved backward yet. For example, if you move from Document 1 to Document 2 and return to Document 1 with Back, Forward brings up Document 2 again. Also available on the Navigate menu. Home Moves to your home document or home page. The default home document is the Mosaic Home Page. Also available on the Navigate menu. Reload Reloads the current document from the server, thus displaying any file changes made and saved since the last loading. (This is particularly useful if you are editing a document file.) Also available on the File menu as Reload Current. Open Opens the Open Document window to enter the URL for a file to be viewed. Also available as Open URL_ on the File menu. Save As Opens the Save Document window that lets you save the current document to your local system in different formats. Also available on the File menu. Clone Opens a duplicate of the window being viewed. This is a useful choice if you want to keep a window open for reference but also want to select another hyperlink or open another file. Also available on the File menu as Clone Window. New Window Opens a new Document View window. The content of the new window is your default home page. There is no limit on the number of windows you can open. Also available on the File menu. Close Window Closes the current Document View window. If you only have one window open, the entire application exits. Also available on the File menu. The Cursor and Displaying Hyperlink URLs The cursor in Mosaic is generally a standard short arrow pointing slightly to the left of twelve o'clock. The cursor changes its configuration depending on where you are in the Document View window. It is the arrow configuration unless it is pointing to a hyperlink. When the cursor rests on a hyperlink, it changes to a small hand icon pointing to the left. At the same time that the cursor changes its configuration, the hyperlink's URL is displayed in the information line. This tells you what will be retrieved if you select the hyperlink. The URL may also tell you the format of the document. For example, suppose the URL http://www.ncsa.uiuc.edu/Pubs/access/accessDir.html is displayed in the information line. This tells you that the document will be retrieved from the NCSA WWW server (www.ncsa.uiuc.edu). If you see the CERN WWW server (info.cern.ch) and an image file extension (.gif), you can surmise that the hyperlink is an image being retrieved from Switzerland and might take longer to download than a local text file. (Of course, your access to the Internet plays a part in the retrieval speed; but in general, you should expect links from overseas, as well as image files, to take slightly longer to display.) Shortcuts and Keyboard Options Each underlined letter is a shortcut to the same action as the corresponding menu item after the menu is open on your screen. You must have first selected a menu for the underlined shortcuts to work. While your mouse pointer is in the hypertext viewing area, the following hotkeys (keyboard shortcuts for common actions) are active. As Table 56.1 shows, in most instances Mosaic accepts either case for the hotkey. Table 56.1. Mosaic hotkeys. Equivalent Action a or A Annotate this window b or B Back to previous URL c or C Clone this window (make a new copy for reference) d or D Document source; shows the HTML document f or F Forward to next URL H Show the Hotlist m or M Mail to; you are better off using mailx or pine n or N New window starts a new session l or L Open a local HTML file o or O Open URL p or P R Refresh r Reload s or S Search/find in document h Window history EXC Close current window You can select text from the viewing area as though you are in a normal workstation or editor window. Cut and paste into other X Window system windows as usual by pressing the left mouse button to begin selecting text, and then holding the button down and dragging. Alternatively, release the left mouse button and use the right mouse button to complete the selection. The Fancy Selections setting under the Options menu causes the paste function to imitate the formatted display in the NCSA Mosaic viewing area. Writing a Hypertext Document Writing a document in HTML is fairly easy if you are a programmer. All you need is a text editor to create and edit a file. From then on, it's a matter of putting the Uniform Resource Locators (URLs) in the file and testing it out. URLs A URL is a way of specifying where a resource exists in the Internet. A resource can be a file, FTP site, database, image, newsgroup, archive, and other such goodies. Pointing to a document means telling your local program, such as Mosaic, the location and name of a resource and how to get it. See Appendix A, "Linux FTP Sites and Newsgroups," for a list of Web pages for Linux. Try to edit an existing HTML document instead of writing one from scratch. Save an interesting Web document with the File menu and then edit it with your favorite text editor. You'll save a lot of time writing an HTML document this way. A URL is composed of three parts: action://sitename/pathname The action part can be at least one of the following. It's not limited to these, of course, but these are the most common ways of getting the files that you see: http For HTML documents gopher For starting a gopher session ftp For starting an ftp session file For getting a raw file that may or may not be an HTML file A browser program then attempts to use this action on the sitename and pathname in the URL. Given this information, you can also write your own HTML documents. You use text anchors to attach links to an HTML document. An anchor is simply a region of text that is reserved as a pointer to another place. In Mosaic these anchors are displayed as underlined text. Other Web viewers may display a link in a different font, a different color, or both. The beauty of HTML is that different viewers can show an HTML document in their own style. You are not limited to one type of display with all viewers. HTML anchors take the following form: <a href="htmlfile">GoDocument</a> In this form, <a and /a> are tags that mark the location pointed to by this HTML anchor. Tags are usually paired, with the ending tag having an extra /. The href token specifies the file to get, and the text between the > and < is what you see in dashed boxes. Tags are not case-sensitive, so <a> is equal to <A>. In a hypertext document, you can use the following example to mark a link to the "official" list of WWW servers at CERN: For List servers at CERN, <a href="http://www.w3.org/hypertext/DataSources/WWW/Servers.html" >GoCERN</a> With a browser you see the following line: For List servers at CERN, GoCERN. In this example, the GoCERN text is underlined when it appears on-screen. An HTML document uses tags to specify special areas of the text. The format of an HTML document is loosely described as follows: <HTML> <HEAD> <TITLE>This is a Home Page</TITLE> <HEAD> <BODY> .... tags ... text .... etc. etc. </BODY> </HTML> There can be only one pair of <BODY> and </BODY> tags in the entire HTML document. These are used to store the text for the HTML document. The <HEAD> and </HEAD> tags show the title in the heading section of a viewer. You generally have only one such pair in an HTML document because the text in the </HEAD> applies to the whole document. For example, to show the title in an HTML document, use the following tag: <TITLE>This is a Home Page For Mosaic!</TITLE> Tags are not case-sensitive, and any formatting in between the tags is almost always ignored. So the previous title could also be written as follows: <TITLE> This is a Home Page For Mosaic! </TITLE> Paragraphs in an HTML document are introduced with a <P> tag and ended with a </P> tag. To break a line in the middle, you use the <BR> tag to add a line break. HTML enables you to use up to six levels of headings, numbered H1 through H6; H1 is the leftmost (highest) heading, and H6 is the lowest heading. To define a heading use the following: <H1>heading 1</H1> Most Mosaic servers define a different point size for the level of heading you are supposed to be on. Don't skip heading titles when writing a document (for instance, don't use level 5 after level 1). It's not considered a good writing style and does not show up well on Mosaic viewers. You won't get any errors, but the document will look sloppy. The following tags can be used to specify how to display the text on a viewer: <I> </I> italicize the text in between <B> </B> bold face the text in between <U> </U> underline the text in between HTML supports unordered lists of items with the, <LI>, </LI>, and </UL> tags. To specify such a list, use the following construct: <LI> Eat the cake</LI> <LI> Swim with the fish</LI> <LI> Start the BBQ </LI> <LI> Write a chapter </LI> </UL> This list is displayed with each item between the <LI> and </LI> as a bulleted item. Unordered lists are generally used as menu items from which a user can choose an item. To display a numbered list, use an ordered list with <OL> and </OL> to enclose the list. Technically, you do not need to use the </LI> for each item, but some browsers may not support it. The previous list could be shown as follows: <OL> <LI> Eat the cake</LI> <LI> Swim with the fish</LI> <LI> Start the BBQ </LI> <LI> Write a chapter </LI> </OL> HTML documents enable you to keep a glossary between <DL> and </DL> tags. Each glossary item contains a pair of <DT> and <DD> tags. The syntax for the glossary is as follows: <DL> <DT>Item<DD>Description of this item in one line. <DT>Another item <DD>Another One Line Description </DL> The <DT> tag indicates the beginning of an element within a glossary, followed by the description after the <DD> tag. The glossary item is displayed flushed left on a line by itself, followed by the description with a tab in front of it. If you really want to include source listings and the like, you can put the text between <PRE> and </PRE> tags. The text between these two tags is displayed literally by your browser. Other types of tags supported by Mosaic include the following: <BR> Produce a line break <HR> Draw a horizontal line <EM> </EM> Emphasize in different font (italics in Mosaic) <STRONG> </STRONG> Boldface in Mosaic, another font with other browsers. You can also place images in your document with the <IMG> tag. For example, the construct <IMG SRC=http://dont.inhale.com/graphics/billy.gif> gets the image billy.gif from the site dont.inhale.com and has the browser display it for you. (If you want to get a better image editor for HTML documents, try mapedit at sunsite.unc.edu in the /pub/packages/info-systems directory.) If you do not specify a full address for the image, the browser uses the current page's directory and site. Images that are declared one after another are placed side by side on the user's screen. You can introduce line breaks with the <BR> or <P> tags. You can also annotate the images with the text ALIGN keyword: <IMG SRC="local.gif" ALIGN="bottom"> annotation The keywords for the ALIGN keyword are top, middle, and bottom for aligning the annotation text position. In the previous example, the text will be shown on the bottom of the figure. Some text-based browsers are not capable of displaying images that enable you to specify a special character that is displayed instead of the image. The attribute for this special character is the ALT keyword. <IMG SRC="local.gif" ALIGN="middle" ALT="$"> annotation This shows a dollar sign where the image would be shown on a graphic browser. You can link images to actions within a link pair. For example, the following action gets you an HTML document by clicking or selecting the figure: <A HREF="bozo.html" <IMG SRC="clown.gif"> </A> That's about all I can put in this space about writing HTML documents. You can always find more interesting documents on the Web as you surf. Save these and see how others do their documents. Most of the information on the Web is very helpful in teaching you how to write your own Web documents. Avoid the temptation to put large GIF images in your HTML documents. The time needed to download these large GIF files on 14.4 modems (still a limitation for a lot of dialup users) is very long. No one wants to wait 12 minutes or so for a pretty 1MB image to come down, when he or she could be looking at other sites with a faster download. Be considerate of your reader's time and keep the sizes of any included images to a reasonable size, say not more than 20KB. You'll still have enough resolution to put your pictures in there. Using Other Browsers If you can use Mosaic, you can use just about any other browser. All browsers are based on the same basic principles of retrieving and displaying a file by checking the type of data in it. Once you know how to navigate using URLs, surfing the Net becomes a task of learning how to use the special keys for your browser to help you customize its functions to best suit your needs. There are many browsers already available for surfing the Net. Also, enhancements are being made to those that already have been out for a while. For example, as we go to print the Netscape 2.0 port to Linux is being completed. You will then have access to more features, including Sun Microsystems' JAVA language with multimedia support. Summary After a brief introduction to the Web, the following items were covered in this chapter: Where to get Mosaic for Linux, which versions to use, and how to debug common problems in Mosaic. How to install Mosaic on your machine after you have FTPed it. How to surf the Web with Mosaic and use its controls to get around documents. A brief introduction to connecting your Linux node via SLIP to an Internet service provider. Some of the basics on HTML and how to write your own HTML documents for the Web. After reading this chapter, you should be able to write your own files and read HTML documents from other sites. Happy surfin'. |