*********************************** Add About Page and Disclaimer Modal *********************************** **Last Updated:** January 2023 In this tutorial you will add an About page and a disclaimer modal. The requirements for the About page include a fixed width content area, two columns with text on the left and images on the right, and a list of sponsor logos at the bottom. The Disclaimer modal needs to be available from any page in the app and should also include the sponsor logos. The following topics will be reviewed in this tutorial: * Adding a new view to your app * Responsive web design using Bootstrap * Bootstrap Grid System * Bootstrap Non-Fluid and Fixed Containers * Bootstrap Modals * Custom styling with CSS * Linking to other pages and navigation * Placeholder content for development: lorem ipsum and images .. figure:: ./resources/about_page_solution.png :width: 800px :align: center 0. Start From Previous Solution (Optional) ========================================== If you wish to use the previous solution as a starting point: .. parsed-literal:: git clone https://github.com/tethysplatform/tethysapp-earth_engine.git cd tethysapp-earth_engine git checkout -b home-page-solution home-page-solution-|version| 1. Create new Template and Controller for About Page ==================================================== The first step to adding a new page to the app is to create a new controller and template for the page. 1. Create new :file:`templates/earth_engine/about.html` template: .. code-block:: html+django {% extends "tethys_apps/app_header_content.html" %} {% load static %} {% block app_content %}

This is the About Page

{% endblock %} 2. Create new ``about`` controller in :file:`controllers.py`: .. code-block:: python @controller def about(request): """ Controller for the app about page. """ context = {} return render(request, 'earth_engine/about.html', context) 3. Navigate to ``_ and verify that the new page loads. You should see the "This is the About Page" text. 2. Modify Header Buttons to Navigate between About Page and Home Page ===================================================================== In this step you will add a new button to the page header that will link to the new About page. This button will be added in the base template so the About link is available from any page that inherits from it, including the Viewer page. You'll also add it to the Home and About pages because they inherit from different base templates. To minimize the amount of code that is duplicated, you will create a new :file:`header_buttons.html` template and use the Django ``include`` tag to insert it in each page. 1. Create a new template :file:`templates/earth_engine/header_buttons.html` with the following contents: .. code-block:: html+django
2. Add the following lines to the :file:`templates/earth_engine/base.html`, :file:`templates/earth_engine/home.html`, and :file:`templates/earth_engine/about.html` templates: .. code-block:: html+django {% block header_buttons %} {% include "earth_engine/header_buttons.html" %} {% endblock %} 3. The Home button is included in :file:`header_buttons.html` and provided by :file:`base.html`, so it will be removed from :file:`viewer.html`. Delete the ``header_buttons`` block in :file:`templates/earth_engine/viewer.html`: .. code-block:: diff -{% block header_buttons %} -
- -
-{% endblock %} 4. Navigate to ``_ and verify that the Home and About buttons in the header function as expected. Also navigate to the viewer page and verify that the Home and About buttons appear on that page as well. 3. Build out About Page ======================= In this step you'll build out the layout of the About page using the `Bootstrap Grid System `_ as you did with the Home page. However, the about page will use the more rigid ``container`` element instead of a ``container-fluid`` element that was used on the Home page. The ``container`` element has a fixed width with wide margins that gives it a classic website look. The width of a ``container-fluid`` element, on the other hand, resizes dynamically or fluidly with the window. 1. Create a ``
`` element with class ``container`` in the ``app_content`` block: .. code-block:: html+django :emphasize-lines: 2-3 {% block app_content %}
{% endblock %} 2. Create a ``
`` element with class ``page-header`` and the following contents inside the ``container`` ``
``: .. code-block:: html+django :emphasize-lines: 3-6 {% block app_content %}
{% endblock %} 3. Add two ``
`` elements with class ``row``: .. code-block:: html+django :emphasize-lines: 7-10 {% block app_content %}
{% endblock %} 4. The upper ``row`` should have two columns for the About page content. The bottom row should have a single full-width column that will contain the sponsor logos. Add column ``
`` elements to each ``row`` ``
`` as follows: .. code-block:: html+django :emphasize-lines: 2-9, 12-13
5. It is helpful to use placeholder text and images while you are developing a website (lorem ipsum). Add the following placeholder content to the columns in the **first** ``row``: .. code-block:: html+django :emphasize-lines: 4-11, 16-20

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Euismod nisi porta lorem mollis. Congue quisque egestas diam in arcu cursus euismod. Auctor neque vitae tempus quam pellentesque nec nam. Erat imperdiet sed euismod nisi porta lorem. Nunc eget lorem dolor sed viverra ipsum nunc aliquet bibendum. Sed blandit libero volutpat sed cras ornare. Convallis tellus id interdum velit laoreet id. Amet mauris commodo quis imperdiet massa tincidunt. Mi bibendum neque egestas congue quisque egestas diam in. Enim nec dui nunc mattis enim ut tellus elementum sagittis. Cursus mattis molestie a iaculis at erat pellentesque. Ut tellus elementum sagittis vitae et leo.

Eu Consequat ac Felis

Eu consequat ac felis donec et odio. Eget arcu dictum varius duis at consectetur lorem. Lorem ipsum dolor sit amet consectetur. Turpis egestas integer eget aliquet nibh praesent. Mattis rhoncus urna neque viverra justo nec. Iaculis urna id volutpat lacus laoreet non curabitur gravida arcu. Convallis posuere morbi leo urna molestie at elementum eu. Fermentum et sollicitudin ac orci phasellus egestas tellus. Convallis aenean et tortor at risus. Morbi tristique senectus et netus et malesuada fames ac. Sed vulputate mi sit amet mauris commodo quis. Nisi quis eleifend quam adipiscing vitae proin sagittis nisl. Id venenatis a condimentum vitae sapien pellentesque habitant morbi tristique. Id cursus metus aliquam eleifend mi in nulla. Proin fermentum leo vel orci porta non pulvinar neque laoreet. Lobortis mattis aliquam faucibus purus in massa tempor. Varius vel pharetra vel turpis nunc.

Mauris rhoncus aenean vel elit: Blandit aliquam etiam erat velit. Auctor neque vitae tempus quam pellentesque nec nam. Augue mauris augue neque gravida in fermentum et. Tempus urna et pharetra pharetra. Vel turpis nunc eget lorem. Vitae nunc sed velit dignissim. Enim tortor at auctor urna nunc id. Pellentesque habitant morbi tristique senectus et netus et. Tellus integer feugiat scelerisque varius morbi enim nunc faucibus.

Blandit turpis cursus in hac habitasse platea: Tellus elementum sagittis vitae et leo duis ut diam quam. Amet nisl purus in mollis nunc sed. Ac feugiat sed lectus vestibulum. Suscipit adipiscing bibendum est ultricies integer quis. Tortor pretium viverra suspendisse potenti nullam ac tortor. Blandit turpis cursus in hac. Id porta nibh venenatis cras sed felis eget velit. Fermentum posuere urna nec tincidunt praesent semper feugiat nibh sed. Pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at. Sapien et ligula ullamcorper malesuada proin libero nunc consequat. Aliquet enim tortor at auctor urna nunc id. Fringilla ut morbi tincidunt augue interdum velit euismod in. In arcu cursus euismod quis viverra nibh. Vulputate ut pharetra sit amet. Purus in massa tempor nec. Pellentesque massa placerat duis ultricies lacus sed. Integer feugiat scelerisque varius morbi enim. Vitae tempus quam pellentesque nec nam.

Sed cras ornare arcu dui vivamus arcu: Pellentesque adipiscing commodo elit at. Fusce id velit ut tortor pretium viverra. Nunc vel risus commodo viverra. Dui faucibus in ornare quam viverra orci sagittis eu volutpat. Aliquet nibh praesent tristique magna. Purus sit amet volutpat consequat. Gravida neque convallis a cras. Aenean euismod elementum nisi quis eleifend. At tellus at urna condimentum mattis pellentesque id nibh tortor. Sit amet massa vitae tortor. Volutpat lacus laoreet non curabitur gravida arcu ac. Vulputate dignissim suspendisse in est ante. Tempor commodo ullamcorper a lacus vestibulum. Quis vel eros donec ac odio tempor. Lacus sed turpis tincidunt id aliquet risus feugiat in ante. Metus aliquam eleifend mi in.

'
6. Add the following content to the column in the **second** ``row``: .. code-block:: html+django :emphasize-lines: 3-12
7. Navigate to ``_ and verify that the content renders as expected. Resize the window to see how the normal Bootstrap ``container`` differs from the ``container-fluid`` that was used on the home page. 4. Customize the About Page Styles ================================== As with the Home page, the Bootstrap Grid System does a good job providing the base layout for the page, but there are a few tweaks that need to be made to finish the About page. In this step you will create a stylesheet for the About page and use it to polish the page styles. 1. Create a new :file:`public/earth_engine/about.css` stylesheet. 2. Include the new :file:`about.css` by adding the ``styles`` block to the :file:`templates/earth_engine/about.html`: .. code-block:: html+django {% block styles %} {{ block.super }} {% endblock %} 3. Add the following contents to :file:`public/earth_engine/about.css` to customize the style of the page header: .. code-block:: css .page-header h1 { text-align: center; font-size: 48pt; color: black; } 4. Navigate to ``_ and verify that the header is centered on the page and in a larger font. Hard-refresh the page if necessary (:kbd:`CTRL-SHIFT-R` or :kbd:`CTRL-F5`). 5. Add the following contents to :file:`public/earth_engine/about.css` to style the images to fit in their column in the About page content: .. code-block:: css .about-img { width: 100%; max-width: 360px; margin-bottom: 20px; } 6. Navigate to ``_ and verify the images fit within the column appropriately. Hard-refresh the page if necessary (:kbd:`CTRL-SHIFT-R` or :kbd:`CTRL-F5`). 7. Add the following contents to :file:`public/earth_engine/about.css` to style the footer of the About page: .. code-block:: css .about-footer-content { text-align: center; margin: 50px 0 100px 0; } .about-footer-content h3 { margin-bottom: 26px; } .about-footer-content img { margin: 0 5px; } 8. Navigate to ``_ and verify that the sponsor images are centered. Hard-refresh the page if necessary (:kbd:`CTRL-SHIFT-R` or :kbd:`CTRL-F5`). 5. Create the Disclaimer Modal ============================== In this step you will create a new modal that will contain a disclaimer for the app. This modal will need to be available on all pages, so a similar strategy will be used as was used with the header buttons. 1. Create a new :file:`templates/earth_engine/disclaimer.html` with the following contents: .. code-block:: html+django 2. Add a header button to launch the modal in :file:`templates/earth_engine/header_buttons.html`: .. code-block:: html+django
3. Add the following lines to the :file:`templates/earth_engine/base.html`, :file:`templates/earth_engine/home.html`, and :file:`templates/earth_engine/about.html` templates: .. code-block:: html+django {% block after_app_content %} {{ block.super }} {% include "earth_engine/disclaimer.html" %} {% endblock %} 4. Navigate to ``_ and verify that the modal opens when the Disclaimer header button is pressed. 5. Navigate to ``_ and attempt to open the disclaimer modal. It doesn't work, because the ``viewer.html`` template overrides the ``after_app_content`` block with its own modals for the functionality on the viewer page. 6. Include the ``block.super`` content in the ``after_app_content`` block of :file:`templates/earth_engine/viewer.html` to include the disclaimer modal from the ``base.html`` template when overriding the block in the ``viewer`` template: .. code-block:: html+django :emphasize-lines: 3 {# Use the after_app_content block for modals #} {% block after_app_content %} {{ block.super }}
{% endblock %} 6. Navigate to ``_ and verify that the modal opens when the Disclaimer header button is pressed. Press the **Plot AOI** button to verify that the *Area of Interest* modal still opens as well. 7. Add the following content to the ``modal-body`` ``
`` element in :file:`templates/earth_engine/disclaimer.html`: .. code-block:: html+django 8. Add the following content to the ``modal-footer`` ``
`` element in :file:`templates/earth_engine/disclaimer.html`: .. code-block:: html+django 9. Navigate to ``_ and verify that new content appears in the disclaimer modal. 6. Customize the Disclaimer Modal Styles ======================================== In this step, you will add a new stylesheet for the disclaimer modal and add styles to adjust the presetnation of the modal and sponsor images. 1. Add the following `` 2. Navigate to ``_ and verify the style changes worked. Hard-refresh the page if necessary (:kbd:`CTRL-SHIFT-R` or :kbd:`CTRL-F5`). Open the Disclaimer modal on the other pages of the app to verify that the modal looks the same on all pages. 7. Solution =========== This concludes this portion of the GEE Tutorial. You can view the solution on GitHub at ``_ or clone it as follows: .. parsed-literal:: git clone https://github.com/tethysplatform/tethysapp-earth_engine.git cd tethysapp-earth_engine git checkout -b about-page-solution about-page-solution-|version|