diff --git a/app/content/get-started.md b/app/content/get-started.md index c9668e70c..7846c0fe6 100644 --- a/app/content/get-started.md +++ b/app/content/get-started.md @@ -1,27 +1,23 @@ -

Get started

+# Get started -
    -
  1. -

    Check if Notify.gov is right for you

    + +1. ## Check if Notify.gov is right for you

    Read about our features, pricing and roadmap.

    -
  2. -
  3. -

    Create an account

    + +2. ## Create an account {% if not current_user.is_authenticated %}

    Create an account for free and add your first Notify service. When you add a new service it will start in trial mode.

    {% else %}

    Create an account for free and add your first Notify service. When you add a new service, it will start in trial mode.

    {% endif %} -
  4. -
  5. -

    Write some messages

    +3. ## Write some messages + {% if True %}

    Add message templates with examples of the content you plan to send. You can use our guidance to help you.

    -
  6. + {% endif %} -
  7. -

    Set up your service

    +4. ## Set up your service {% if not current_user.is_authenticated or not current_service %}

    Review your settings to add message branding and sender information.

    Add team members and check their permissions.

    @@ -29,22 +25,19 @@

    Review your settings to add message branding and sender information.

    Add team members and check their permissions.

    {% endif %} -
  8. - -
  9. -

    Start sending messages

    +5. ## Start sending messages {% if not current_user.is_authenticated or not current_service %}

    When you’re ready to send messages to people outside your team, go to the Settings page and select Request to go live. We’ll approve your request within one working day.

    {% else %}

    You should request to go live when you’re ready to send messages to people outside your team. We’ll approve your request within one working day.

    {% endif %} - -
  10. -
+ + + diff --git a/app/formatters.py b/app/formatters.py index 4ea5d5104..ed4198395 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -12,6 +12,7 @@ import dateutil import humanize import markdown import pytz +from bs4 import BeautifulSoup from flask import Markup, render_template_string, url_for from flask.helpers import get_root_path from notifications_utils.field import Field @@ -24,6 +25,25 @@ from app.utils.csv import get_user_preferred_timezone from app.utils.time import parse_naive_dt +def apply_html_class(tags, html_file): + + new_html = html_file + + for tag in tags: + + element = tag[0] + class_name = tag[1] + + soup = BeautifulSoup(new_html, 'html.parser') + + for xtag in soup.find_all(element): + xtag['class'] = class_name + + new_html = str(soup) + + return new_html + + def convert_markdown_template(mdf, test=False): content_text = "" @@ -37,10 +57,11 @@ def convert_markdown_template(mdf, test=False): else: content_text = mdf - md_render = markdown.markdown(content_text) - jn_render = render_template_string(md_render) + jn_render = render_template_string(content_text) + md_render = markdown.markdown(jn_render) - return jn_render + + return md_render def convert_to_boolean(value): diff --git a/app/main/views/index.py b/app/main/views/index.py index d6d08150d..ef5c1a5da 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -2,7 +2,7 @@ from flask import abort, redirect, render_template, request, url_for from flask_login import current_user from app import status_api_client -from app.formatters import convert_markdown_template +from app.formatters import apply_html_class, convert_markdown_template from app.main import main from app.main.views.pricing import CURRENT_SMS_RATE from app.main.views.sub_navigation_dictionaries import features_nav, using_notify_nav @@ -138,10 +138,16 @@ def get_started_old(): @main.route("/using-notify/get-started") @user_is_logged_in def get_started(): + markdown = convert_markdown_template('get-started') + html_style = apply_html_class([['ol', 'usa-process-list'], + ['li', 'usa-process-list__item padding-bottom-4 margin-top-2'], + ['h2', 'usa-process-list__heading line-height-sans-3']], + markdown) + return render_template( "views/get-started.html", navigation_links=using_notify_nav(), - content=convert_markdown_template('get-started') + content=html_style ) diff --git a/tests/app/main/test_formatters.py b/tests/app/main/test_formatters.py index eeded8c13..f50bd71ff 100644 --- a/tests/app/main/test_formatters.py +++ b/tests/app/main/test_formatters.py @@ -7,6 +7,7 @@ from freezegun import freeze_time from app.formatters import ( convert_markdown_template, + apply_html_class, email_safe, format_datetime_relative, format_delta, @@ -181,3 +182,7 @@ def test_markdown_format(fake_markdown_file): app = Flask("app") with app.app_context(): assert convert_markdown_template(fake_markdown_file, test=True) == "

Test

" + +@pytest.mark.usefixtures("fake_soup_template") +def test_soup_format(fake_soup_template): + assert apply_html_class([['h1', 'testClass']], fake_soup_template) == '

Test

' diff --git a/tests/conftest.py b/tests/conftest.py index 936bb8a79..5a9057cf3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3606,3 +3606,9 @@ def fake_markdown_file(): def fake_jinja_template(): input = "{% if True %}True{% endif %}" return input + + +@pytest.fixture() +def fake_soup_template(): + input = "

Test

" + return input