Advanced NPDS Topics:

Using HTML With Notepad Server

Introduction:

NPDS is designed to generate and serve Web content without your having any knowledge of HTML or Newtonscript, but it's also able to act as a much more traditional HTTP server in that if Notes you store in your selected WWW folder are written in strict HTML* they'll be served as "files" without any significant changes in their formatting or content.

* NPDS automatically detects whether a page is HTML or plaintext by looking for the presence of any of the following tags: <HTML>, <HEAD>, <BODY>, <FRAMESET>. You can, of course, fool the parser with a phony tag, but why would you want to do that?

Naming:

Although your Notes may indeed be HTML files, they don't have to be named according to traditional file-naming protocols since NoteServ doesn't usually use the file name to retrieve a given Note. (Appendix: The NPDS Pseudo-Filename System covers how NPDS handles files and folders)

Example:

If you have a note about your train collection and it's written in HTML because you need a nicely formatted table of all the types of engines you have, you can name the Note "My Train Collection" and that's perfectly OK. Its URL when displayed in the list of Notes will be something like /html/123456$007.nsd where "123456$007.nsd" is a special identifier NPDS uses to retrieve your particular Note.

Now, there's a neat trick you can do here... the Note is actually a container for a HTML object. What this means is that you write out your HTML page, give it a title between the <TITLE></TITLE> tags, then turn around and give the Note that contains it another title, quite likely the same one you put in the HTML.

If you want to logically link these two titles, put the following Server Side Include (SSI) <NOTE_TITLE> in between the <TITLE> tags in the HTML. When the page is served, the Note title will be substituted into the space between TITLE tags.

In our "My Train Collection" example: A note containing the HTML document is made. In the HEAD of the HTML doc is this code: <TITLE><NOTE_TITLE></TITLE>. The Note is titled "My Trains Collection." Now when the page is served, the name of the Note is substituted in place of the Server Side Include: <TITLE>My Train Collection</TITLE>

Server Side Includes: NPDS Extensions to HTML

As you've seen with the previous example, serving Pages and Data from your Newton doesn't have to be a static experience. You can create living, dynamic documents by writing into your notes variables called Server Side Includes (SSI). These variables are detected when a Note is served and substituted with specific data. You can put in variables for things as mundane as your name and email address to things a bit cooler like your daily schedule! You can also use SSI to access the NPDS formatting preferences. In later sections, you'll even find that you can write Newtonscripts to create your own custom SSI.

Here, grouped by type, are the Server Side Includes currently supported in NPDS and the data they represent.

To use any of these extensions to standard HTML, enclose them in < > like so <CUSTOM_TAG>

User Data | Content Variables | Preferences | Paths

User Environment Variables

USR_POST: Postal Zone

USR_REGION: Current State/Province

TIME: Current Date/Time

USR_TELE: Default Telephone

EMAIL: Current Default Email Address as mailto: hyperlink

USR_CITY: Current City

USR_NAME: Name of Current Owner

USR_ADDR: Current Street Address


NPDS Content Variables

NOTE_LIST: List of Notes Filed in your selected WWW folder

POST_LIST: List of Notes posted via the WWW

NOTE_POST: Insert a link to /html/postnote.html where you can post Notes to your Newton from a browser.
*This obsoletes functionality of the old Whiteboard plugin and its SSI tag "POST"

NAME_SEARCH: Inserts a form for searching the Names database.

AGENDA_DAY: Inserts a table containing the day's Events, Meetings, ToDos.

NOTE_SEARCH: Inserts a form for searching the Notepad and returning a ranked list of hits.

NOTE_TABLE: Table view of Notes sorted in ascending order by creation date

POST_TABLE: Table view of WWW-posted Notes sorted in ascending order by creation date

EVERY_TABLE: Table view of Both WWW-posted and Your Notes sorted in ascending order by creation date

EVERY_LIST: List of Both WWW-posted and Your Notes


NPDS-Wide Preference Variables

DEF_FONT: Font face defined as default

DEF_SIZE: Default Font Size

DEF_COLR: Background color

HI_COLR: Preferred Background Highlight color

MOTD: Admin's Message of the day to his/her visitors

HOME: Inserts a hyperlink to the page defined by admin as the "Home" page.

INSULT: This is a special treat for you, Thou artless, beef-witted hedge pig.

COUNTER: Hit Counter


Content Path Variables

NOTEPAD: Returns a link to NoteServ's /html/index.html

CALENDAR: Returns a link to DateServ's /dates/index.html

CARDFILE: Returns a link to the CardFile Server default page /cards/index.html

PAGER: Returns a link to WebPager's form-based paging interface (/pager/index.html)

CFG: Returns a link to the NPDS Administrator page

 

Real World Example: You've written some pages in HTML and you want want the email address that associates with your current owner card available on each page. Since you have 5 email addresses, this could be a problem, except that you know about the <EMAIL> tag. Insert it where you want your email address to go and the address will always be that of the current owner of the Newton.

Writing You Own Custom Server Side Includes:

Version 2.0 of NPDS contains the Simple Scripting Architecture which allows you to write Newtonscripts that return substantial chunks of text and can be inlined into any NPDS Content by assigning then their own Server Side Includes. For more details and some examples, see the manual section on the "Simple Scripting Architecture".

Making Your Own Default Page for Notepad Server:

When a client accesses the /html/ directory, NoteServ (actually most HTTP servers do) serves a built-in file called "index.html". You can easily over-ride the "index.html" that NoteServ delivers, though. Here's how.

  1. Create a note and give it the title "index.html". Make sure it's filed in your selected WWW directory. You can also open NoteServ and tap the "index.html" button to create a template version of the built-in index page in your web service folder which you can then modify to your hearts content.
  2. Use standard HTML 4.0 and any Server Side Includes you wish to create a properly formatted and syntactically-correct home page.
  3. Keep in mind that most of the formatting will be done when the NPDS Style Sheet is applied to your page so don't go crazy with FONT tags and such.
  4. Any time you change the folder that NoteServ looks in to find pages to serve, you need to re-file this custom note or the built-in index.html file will be served instead