Amaya

## Saving and publishing documents

You can save (X)HTML documents either in (X)HTML or as plain text. Other documents (SVG, MathML, XML or CSS) are saved according to their original format. You can save both remote and local documents with three different commands, Save, Save as, and Save all.

In addition, you can change a number of publishing options using the Publishing Preferences dialog. Open this dialog by choosing Preferences / Publishing from the Edit menu (or amaya / Preferences on Mac OS X).

Amaya does not provide any global view of a set of pages installed on a server. However, you can save the server files in the same way you save local files, using Save and Save as commands.

During these operations, Amaya is also able to save the resources you have associated with the document (images, style sheets, scripts).

### The Save command

The Save command saves the current document to its original location, be it local or remote. You can access the Save command by choosing Save from the File menu (`Ctrl-s`) or clicking the Save button .

You can fetch a web document by specifying only a server directory name. The default file name is omitted (index.html or Overview.html). This may be useful when browsing, but the file name is required for publishing.

Usually Amaya uses the HTTP `Content-Location` provided by the server when the document is loaded. If the file name is not provided in the HTTP header, Amaya asks you to provide one when saving.

Newly added local resources are saved in the same directory automatically. The list of saved files is proposed to the user, so he/she can remove some files in the list.

If you want to save new added resources into another directory, you have to use the Save as command.

### Web site update

You can use Amaya to update your web site, even if the server doesn't support HTTP Put or WebDAV methods. When the editing of a remote document is done, you use the usual Save command.

When the command fails, Amaya proposes to keep a local copy of the edited document with the same server hierarchy. If several documents of the same site are edited, they are saved with the same relative positions.

Once the Amaya edit is done, you can update your web site by transferring local copies, as they are, to the server with your usual method (ftp or upload).

### The Save all command

The Save all command allows you to save all documents open in Amaya that have been modified and not saved yet. It works exactly like the Save command, but for all the modified documents, not only the current one.

This command may be called from the File menu or by clicking the button on the button bar.

### The Save as command

Choosing Save As (`Ctrl-Shift-s`) from the File menu opens the Save As dialog, which allows you to save the current document with a different format and to a different location.

You can:

- save the document alone or with its resources (images, objects, style, scripts) to a local disk or to a remote web server;
- embedded images and objects can be saved into the same directory as the document or to a different location;
- embedded style (including imported style sheets and images) and scripts can be saved into the same directory as the document or to a different location;
- all URIs used in the document can be updated to take into account the new location of the document and its associated resources.

The dialog box contains two tabs and two buttons. The first tab is about the document itself. The second tab is about its associated resources (images, styles sheets, scripts, etc.).

The Document tab contains:

- The Document location field indicates where the document file has to be written. This can be in the local file system (for example, `/pub/html/welcome.html`) or a remote URI (for example, `http://www.w3.org/pub/WWW/Welcome.html`).

  Note: Use a complete path for the URI. You should also make sure that you have the rights to do a `PUT` method if it is a remote location. Refer to the page on configuring your server to accept the PUT method or ask your Web administrator.

- The Document format menu offers a choice between HTML, XML (XHTML) and Text for HTML documents. This submenu is not shown when saving a SVG, MathML, CSS, or XML document. By default, Amaya keeps the current document format.

  Entry Text removes the HTML mark-up and produces a plain text document.

- Options menu:
  - The Transform URLs toggle transforms all current URIs into relative URIs when possible. Of course, if the document is saved in a local file and URIs point to remote files, URIs will be absolute. This ensures that all the links in the document are preserved by the copy.

    If you save the document locally to publish it by ftp just because your provider or your Webmaster does not allow you to use the HTTP Put method, you must disable this option to not alterate links computed when the document was on the http server.

  - The Copy Images toggle indicates whether the images and objects embedded in the current document must be copied along with the document to a new location. You have to keep this switch on when you want to generate a complete copy of the document.

    When images and objects are copied, Amaya updates automatically all src and data attributes to point new locations. New locations are relative URIs.

  - The Copy resources (styles, scripts, ...) toggle indicates whether style sheets (including imported style sheets and images) and scripts embedded in the current document must be copied along with the document to a new location. You have to keep this switch on when you want to generate a complete copy of the document.

    When these resources are copied, Amaya updates automatically all links and processing instructions to point to these new resource locations. New locations are relative URIs.

- The Charset field allows you to choose the charset of the document. This option only works with documents that support the notion of charset, such as HTML and XML documents, but it is not proposed when saving from the source view. This option is available when saving both remote and local documents.

  Very often the charset of Web documents is controlled by the server. It depends either on the document suffix (html, xml, xhtml, svg, mml), or on instructions given in the `.htaccess` file.

- The Mime Type field allows you to select the MIME type of the document. If the MIME type you are looking for is not listed, you can type it in yourself. This menu is only active when saving a document to a remote web server (local file systems do not store the MIME metadata information).

The Images, Styles and Scripts tab contains:

- The field Where to save images allows you to specify the directory where images and objects have to be saved. This may be a directory on a remote web server. When the Copy Images button is selected, this field is initialized with the directory of the saved document.
- The field Where to save resources allows you to specify the directory where style sheets and scripts have to be saved. This may be a directory on a remote web server. When the Copy resources (styles and scripts) button is selected, this field is initialized with the name of the saved document directory.

Two buttons complete this dialog:

- The Save button starts the process of saving the document. If you have chose to save associated resources too, a list of these resources is displayed and you can choose to remove some resources from the list: they will not be saved.

  When saving to a remote location, check that the http_proxy is not set, or that the proxy server and the target server are configured to work with the HTTP Put method.

- The Cancel button terminates the command without doing anything.

### Saving and characters encoding (charset)

Three standard encodings are considered:

- `us-ascii` is a 7-bit code that represents 96 printable characters (positions 32 through 127 decimal).
- `iso-8859-1` is a 8-bit code that represents the same characters as `us-ascii`, at the same positions, plus 95 additional printable characters, commonly used in various European languages.
- `utf-8` is a variable length encoding scheme for the Universal Character Set - UCS (ISO10646 aka Unicode). UCS represents thousands of characters. Note that the 96 first characters have the same positions in UCS as in `us-ascii` (and then as in `iso-8859-1`).

If an XML or HTML document contains a character that is not available in the character set (charset) available with the encoding, a special representation is required. XML offers two such representations of characters:

1. Character references represent the position (in decimal or hexadecimal) of the character in the UCS. For example, the greek letter α (alpha) is represented as `&#x3b1;` (hexadecimal) or `&#945;` (decimal)
2. Entity references use a name to represent a content (in that case a character). For example the greek letter α is represented as `&alpha;`

Character references may be used in any XML or HTML document, but entity references are allowed only if the document itself contains a means to resolve the name.

Entity name resolution is provided by the Document type definition which refers to the DTD where names and their associated contents are defined. Practically, this means that you can use entity references only if the `<!DOCTYPE ...>` is present and refers to a DTD that defines the names you use.

By default, Amaya preserves the initial encoding of the document, that is the encoding that was associated with the document at loading time. You can check this encoding with command Views/Document info (Charset field). The Save and Save all commands save the document with that encoding, while the Save As command allows you to choose another encoding (Charset field).

When saving a document (Save, Save all, or Save As commands), all characters that are available in the charset of the encoding are just written using the encoding. Only the other characters are written using character or entity references. The choice between these two options is made according to the `doctype`. If there is a `doctype` that refers to a DTD that defines a name for the character, an entity reference is used (i.e. a name), otherwise Amaya generates a character reference in hexadecimal.

Note: command Tools/Change doctype allows you to associate, to change or to remove the `doctype` of a document at any time. This allows you to make Amaya generate either character references or entity references.

### Saving documents as text

You can save your document as plain text using the Save as command from the File menu. HTML mark-up is replaced by spaces, new lines, and so on. A list of all URIs used in the document is appended to the file.

To save your document as text:

1. Choose Save as from the File menu to open the Save as dialog box.

2. Click the Text button in the Document format section to save the document in text format.