Skip to content

Commit 4f332d8

Browse files
committed
Add documentation for RFC140
1 parent 8f359b5 commit 4f332d8

File tree

5 files changed

+172
-3
lines changed

5 files changed

+172
-3
lines changed

conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ class WKTLexer(RegexLexer):
408408
r'SMALL|SQUARE|TINY|TRIANGLE|TRUE|TRUETYPE|UC|UL|UNION|UR|UV_ANGLE|UV_MINUS_ANGLE|UV_LENGTH|UV_LENGTH_2|UVRASTER|VECTOR|'
409409
r'WFS|WMS|ALPHA|'
410410
r'GIF|JPEG|JPG|PNG|WBMP|SWF|PDF|GTIFF|PC256|RGB|RGBA|INT16|FLOAT32|GD|'
411-
r'AGG|CAIRO|PNG8|SVG|KML|KMZ|GDAL|UTFGRID|MIXED'
411+
r'AGG|CAIRO|PNG8|SVG|KML|KMZ|GDAL|UTFGRID|MIXED|'
412+
r'MS_INDEX_TEMPLATE_DIRECTORY|TEST_MAPFILE'
412413
r')\b')
413414

414415
keywords = (r'(ALIGN|'

en/images/index-map-page.png

113 KB
Loading

en/images/index-page.png

83.2 KB
Loading

en/output/index-page.txt

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
.. index::
2+
single: INDEX
3+
4+
.. _index-page:
5+
6+
*****************************************************************************
7+
Index Page
8+
*****************************************************************************
9+
10+
:Author: Seth Girvin
11+
:Contact: sethg at geographika.net
12+
:Last Updated: 2025-09-19
13+
14+
15+
Background
16+
==========
17+
18+
MapServer 8.6 introduces an index page, proposed in :ref:`rfc140`.
19+
This feature provides a single HTML page that lists all Mapfiles available in a deployment.
20+
From this page, users can select an individual Mapfile to open a dedicated page containing useful links,
21+
such as WMS capabilities documents and OGC Features API landing pages.
22+
23+
In addition to the HTML pages, the same information is also available as JSON services, enabling programmatic access.
24+
25+
The index pages are driven by the MapServer :ref:`config` file, and use the same template-based approach as the :ref:`OGC APIs <ogcapi>`.
26+
27+
The index pages improves service discoverability for users and gives system administrators better visibility
28+
into which services are exposed by their MapServer instances, making it easier to restrict or disable unneeded options.
29+
30+
Configuration
31+
=============
32+
33+
The index pages require a :ref:`config` file. MapServer uses this file to locate and list all Mapfiles available in the system.
34+
35+
To activate the index pages, the config file needs to set a new ``MS_INDEX_TEMPLATE_DIRECTORY`` parameter.
36+
This parameter specifies the folder containing the HTML templates used to render the index pages.
37+
38+
.. code-block:: mapfile
39+
40+
CONFIG
41+
ENV
42+
MS_INDEX_TEMPLATE_DIRECTORY "/mapserver/share/ogcapi/templates/html-index-bootstrap/"
43+
END
44+
45+
MapServer provides two sets of templates, which may already be included with your deployment (depending on the package source).
46+
If not, they are available in the MapServer repository under `share/ogcapi/templates <https://github.com/MapServer/MapServer/tree/main/share/ogcapi/templates>`__.
47+
48+
- ``html-index-bootstrap`` - HTML templates styled using the Bootstrap framework.
49+
- ``html-index-plain`` - plain HTML templates with no styling.
50+
51+
If your system will only be serving JSON output, the ``MS_INDEX_TEMPLATE_DIRECTORY`` value can be set to an empty string.
52+
53+
.. code-block:: mapfile
54+
55+
CONFIG
56+
ENV
57+
MS_INDEX_TEMPLATE_DIRECTORY ""
58+
END
59+
60+
In this case JSON output remains accessible by appending ``?f=json`` to the request URL,
61+
but if you attempt to access the HTML output MapServer will return the following error.
62+
63+
.. code-block:: json
64+
65+
{"code":"ConfigError","description":"Template directory not set."}
66+
67+
If the configured template folder cannot be found, or if the account running MapServer does not have permission to read it, the following error will be returned:
68+
69+
.. code-block:: json
70+
71+
{"code":"ConfigError","description":"InjaError error. [inja.exception.file_error]
72+
failed accessing file at 'C:\\Missing\\landing.html' (landing.html). (C:\\Missing\\)."}
73+
74+
If ``MS_INDEX_TEMPLATE_DIRECTORY`` is not set, MapServer will behave as in previous versions and return standard messages when accessed without a query:
75+
76+
.. code-block:: bat
77+
78+
loadParams(): Web application error. No query information to decode. QUERY_STRING is set, but empty.
79+
mapserv(): Web application error. Traditional BROWSE mode requires a TEMPLATE in the WEB section, but none was provided.
80+
81+
MapServer Homepage
82+
==================
83+
84+
The homepage is available at the root of your MapServer deployment, for example:
85+
86+
- http://localhost:8080/cgi-bin/mapserv.exe/
87+
- https://example.com/mapserver/
88+
- https://demo.mapserver.org/cgi-bin/mapserv/
89+
90+
The page lists all Mapfiles defined in the :ref:`MAPS <mapfile-config-maps>` section of your ``CONFIG`` file.
91+
For each Mapfile, the page provides:
92+
93+
- the map name
94+
- the number of layers
95+
- links to the Mapfile's individual index page (available in both HTML and JSON formats)
96+
97+
.. image:: ../images/index-page.png
98+
99+
If any Mapfiles referenced in the CONFIG file cannot be loaded, they will be displayed with an error message - "Error loading the map".
100+
In the JSON output, these Mapfiles will include a flag: ``"has-error":true``. This makes it possible to monitor the service programmatically and quickly identify problems with Mapfiles.
101+
102+
The HTML output can be customized using the landing.html template file located in the configured template folder.
103+
104+
Individual Mapfile Homepages
105+
============================
106+
107+
When the index page functionality is enabled, each Mapfile listed in the :ref:`MAPS <mapfile-config-maps>` section of the config file
108+
has its own dedicated index page.
109+
110+
These pages can be accessed directly by appending the Mapfile's key to the MapServer URL.
111+
For example, the ``test.map`` referenced by the ``TEST_MAPFILE`` key in the configuration below can be accessed using URLs such as (keys are not case-sensitive):
112+
113+
- http://localhost:8080/cgi-bin/mapserv.exe/TEST_MAPFILE/
114+
- https://example.com/mapserver/test_mapfile/
115+
- https://demo.mapserver.org/cgi-bin/mapserv/TEST_MAPFILE/
116+
117+
.. code-block:: mapfile
118+
119+
CONFIG
120+
...
121+
MAPS
122+
TEST_MAPFILE "/opt/mapserver/test/test.map"
123+
124+
Each Mapfile homepage lists the services enabled for that Mapfile. The following links may be available:
125+
126+
- **CGI** - link to the inbuilt :ref:`openlayers`.
127+
128+
- Always available unless explicitly disabled via the ``ms_enable_modes`` setting in :ref:`mapfile-web-metadata`.
129+
130+
- **OGC API** - links to the :ref:`OGC APIs <ogcapi>`.
131+
132+
- "OGC API Landing Page" (HTML)
133+
- Root JSON service
134+
- Available if MapServer was compiled with the ``-DWITH_OGCAPI`` option and one of the following :ref:`mapfile-web-metadata` settings is present:
135+
136+
- ``"oga_enable_request" "*"``
137+
- ``"ows_enable_request" "*"``
138+
139+
- **WMS** - links to the :ref:`WMS <wms_server>` GetCapabilities documents for supported versions:
140+
141+
- 1.0.0, 1.1.0, 1.1.1 and 1.3.0
142+
- Available if MapServer was compiled with the ``-DUSE_WMS_SVR`` option, and one of the following :ref:`mapfile-web-metadata` settings:
143+
144+
- ``"wms_enable_request" "*"``
145+
- ``"ows_enable_request" "*"``
146+
147+
- **WFS** - links to the :ref:`WFS <wfs_server>` GetCapabilities documents for supported versions:
148+
149+
- 1.0.0, 1.1.0, and 2.0
150+
- Available if MapServer was compiled with the ``-DUSE_WFS_SVR`` option, and one of the following :ref:`mapfile-web-metadata` settings:
151+
152+
- ``"wfs_enable_request" "*"``
153+
- ``"ows_enable_request" "*"``
154+
155+
- **WCS** - links to the :ref:`WCS <wcs_server>` GetCapabilities documents for supported versions:
156+
157+
- 1.0.0, 1.1.0, 2.0.0, and 2.0.1
158+
- Available if MapServer was compiled with the ``-DUSE_WCS_SVR`` option, and one of the following :ref:`mapfile-web-metadata` settings:
159+
160+
- ``"wcs_enable_request" "*"``
161+
- ``"ows_enable_request" "*"``
162+
163+
.. image:: ../images/index-map-page.png
164+
165+
The HTML output can be customized using the map.html template file located in the configured template folder.
166+
167+
168+

en/output/index.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
idw
1717
imagemaps
1818
kerneldensity
19-
ogr_output
19+
ogr_output
2020
pdf
2121
svg
2222
tile_mode
2323
template_output
2424
kml_output
2525
utfgrid_output
26-
26+
index-page

0 commit comments

Comments
 (0)