From cb71ccd6e471a1d7955efce8eade94a29f6223bd Mon Sep 17 00:00:00 2001 From: Andy Chosak Date: Fri, 2 Aug 2024 15:34:50 -0400 Subject: [PATCH 1/3] Fix pagination bug --- viewer/templates/viewer/page_list.html | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/viewer/templates/viewer/page_list.html b/viewer/templates/viewer/page_list.html index 8d8da84..7fcb9e3 100644 --- a/viewer/templates/viewer/page_list.html +++ b/viewer/templates/viewer/page_list.html @@ -63,19 +63,12 @@

From f40e09acb5e587dbd1787db2835c8eaca62e281c Mon Sep 17 00:00:00 2001 From: Andy Chosak Date: Fri, 2 Aug 2024 15:55:06 -0400 Subject: [PATCH 3/3] Add prettier-plugin-jinja-template plugin +Upgrade Prettier to latest version 3.3.3 --- esbuild.mjs | 2 +- package.json | 18 +- viewer/static_src/css/skip-nav.less | 8 +- viewer/static_src/js/main.js | 2 +- viewer/templates/viewer/base.html | 2 +- viewer/templates/viewer/component_list.html | 45 +-- viewer/templates/viewer/help.html | 367 ++++++++++---------- viewer/templates/viewer/page_detail.html | 169 +++++---- viewer/templates/viewer/page_list.html | 181 +++++----- viewer/templates/viewer/search_form.html | 46 ++- viewer/templates/viewer/search_results.html | 47 +-- yarn.lock | 13 +- 12 files changed, 470 insertions(+), 430 deletions(-) diff --git a/esbuild.mjs b/esbuild.mjs index a0acd49..c48b2dc 100644 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -71,7 +71,7 @@ const postCSSPlugin = ({ plugins = [], lessOptions = {} }) => ({ math: "always", paths: [ ...readdirSync(`${modules}/@cfpb`).map( - (v) => `${modules}/@cfpb/${v}/src` + (v) => `${modules}/@cfpb/${v}/src`, ), `${modules}`, ], diff --git a/package.json b/package.json index 2f3db68..a0ec27b 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,22 @@ "postcss-less": "^6.0.0" }, "devDependencies": { - "prettier": "^2.7.1" + "prettier": "^3.3.3", + "prettier-plugin-jinja-template": "^1.4.1" + }, + "prettier": { + "plugins": [ + "prettier-plugin-jinja-template" + ], + "overrides": [ + { + "files": [ + "*.html" + ], + "options": { + "parser": "jinja-template" + } + } + ] } } diff --git a/viewer/static_src/css/skip-nav.less b/viewer/static_src/css/skip-nav.less index 599fbef..b6a3557 100644 --- a/viewer/static_src/css/skip-nav.less +++ b/viewer/static_src/css/skip-nav.less @@ -10,7 +10,9 @@ width: 1px; overflow: hidden; background: transparent; - transition: transform 1s ease, background 0.5s linear; + transition: + transform 1s ease, + background 0.5s linear; z-index: 11; &:focus { @@ -25,7 +27,9 @@ width: auto; overflow: visible; outline: 0; - transition: transform 0.1s ease, background 0.2s linear; + transition: + transform 0.1s ease, + background 0.2s linear; } &--flush-left:focus { diff --git a/viewer/static_src/js/main.js b/viewer/static_src/js/main.js index 8d6af9e..ecb0a47 100644 --- a/viewer/static_src/js/main.js +++ b/viewer/static_src/js/main.js @@ -3,7 +3,7 @@ import { Expandable } from "@cfpb/cfpb-expandables"; const docElement = document.documentElement; docElement.className = docElement.className.replace( /(^|\s)no-js(\s|$)/, - "$1$2" + "$1$2", ); Expandable.init(); diff --git a/viewer/templates/viewer/base.html b/viewer/templates/viewer/base.html index f4b3823..bd54a79 100644 --- a/viewer/templates/viewer/base.html +++ b/viewer/templates/viewer/base.html @@ -1,6 +1,6 @@ {% load static %} - + diff --git a/viewer/templates/viewer/component_list.html b/viewer/templates/viewer/component_list.html index ed765d7..1709585 100644 --- a/viewer/templates/viewer/component_list.html +++ b/viewer/templates/viewer/component_list.html @@ -1,24 +1,25 @@ -{% extends './base.html' %} {% load humanize %} {% block content %} -
- {{ results | length | intcomma }} total - - CFPB Design System - {% include "external-link.svg" %} - component{{ results | length | pluralize }} -
+{% extends './base.html' %} {% load humanize %} +{% block content %} +
+ {{ results | length | intcomma }} total + + CFPB Design System + {% include "external-link.svg" %} + component{{ results | length | pluralize }} +
-
- -
+
+ +
{% endblock content %} diff --git a/viewer/templates/viewer/help.html b/viewer/templates/viewer/help.html index 5ae5021..1cae09b 100644 --- a/viewer/templates/viewer/help.html +++ b/viewer/templates/viewer/help.html @@ -1,211 +1,216 @@ {% extends './base.html' %} {% load static %} - {% block breadcrumbs %} -{% include "viewer/breadcrumbs.html" %} + {% include "viewer/breadcrumbs.html" %} {% endblock breadcrumbs %} {% block content %} -
-

Common searches

+
+

Common searches

-

- This tool stores a nightly snapshot of consumerfinance.gov web page data - that you can search for all sorts of useful things. Common search examples - are below. You can also - learn more about the data. -

-

- View results in the browser, or export them as a CSV. For those less handy - with Excel, it may be useful to - - learn how to filter out results with query strings - {% include "download.svg" %}. - -

-
- -
-

Title

-

Find all instances of a string in the title of a cf.gov page.

-

Examples

-
    -
  • - You want a list of all pages with the word "Chopra" in the title. - Search "Chopra" -
  • -
-
- -
-

URL

-

Find all instances of a string in the URL of a cf.gov page.

-

Examples

-
    -
  • - Your stakeholder wants a list of all the pages in a given site section. +

    + This tool stores a nightly snapshot of consumerfinance.gov web page data + that you can search for all sorts of useful things. Common search examples + are below. You can also + learn more about the data. +

    +

    + View results in the browser, or export them as a CSV. For those less handy + with Excel, it may be useful to - Search "/about-us/the-bureau/bureau-structure/" - -

  • -
-
- -
-

Components

-

- Search by - class names - of our - - Design System - {% include "external-link.svg" %}components and patterns. Partial searches also work: searching for - "notification" will return pages containing "m-notification", - "m-notification__borderless", etc. -

-

Examples

- -
+

+
-
-

Links

-

- Find all instances of a string in the URLs of links listed on a cf.gov page, - excluding the header and footer. -

-

Examples

- -
+
+

Title

+

Find all instances of a string in the title of a cf.gov page.

+

Examples

+
    +
  • + You want a list of all pages with the word "Chopra" in the title. + Search "Chopra" +
  • +
+
-
-

Full text

-

- Find all instances of a term or exact phrase in the full text of the - <body> of a page, excluding the header and footer. -

-

Examples

-
    -
  • - You're looking for specific phrasing or language that might need to be - updated because of a policy change. - - Search "medical debt" - -
  • -
-
+
+

URL

+

Find all instances of a string in the URL of a cf.gov page.

+

Examples

+ +
-
-

HTML

-

- Find all instances of a string in the HTML of the <body> of a cf.gov - page, excluding the header and footer. -

-

Examples

- -
+ > + components and patterns. Partial searches also work: searching for + "notification" will return pages containing "m-notification", + "m-notification__borderless", etc. +

+

Examples

+ + + +
+

Links

+

+ Find all instances of a string in the URLs of links listed on a cf.gov + page, excluding the header and footer. +

+

Examples

+ +
-
-
-
About the data
+
+

Full text

- This index contains web page data saved from the www.consumerfinance.gov - domain. + Find all instances of a term or exact phrase in the full text of the + <body> of a page, excluding the header and footer.

+

Examples

+
    +
  • + You're looking for specific phrasing or language that might need to be + updated because of a policy change. + + Search "medical debt" + +
  • +
+
+ +
+

HTML

- The index is built using an iterative process that "crawls" every page of - the website, starting at the home page. A web crawler starts on that page, - then follows every link on that page, then follows every link on those - pages, and so on. If a link leaves the www.consumerfinance.gov domain, it - is ignored. In this way, the crawler covers every page on the website that - is linked from any other page. + Find all instances of a string in the HTML of the <body> of a cf.gov + page, excluding the header and footer.

-

The data excludes:

+

Examples

-
+ +
+
+
About the data
+

+ This index contains web page data saved from the www.consumerfinance.gov + domain. +

+

+ The index is built using an iterative process that "crawls" every page + of the website, starting at the home page. A web crawler starts on that + page, then follows every link on that page, then follows every link on + those pages, and so on. If a link leaves the www.consumerfinance.gov + domain, it is ignored. In this way, the crawler covers every page on the + website that is linked from any other page. +

+

The data excludes:

+
    +
  • + Pages on other subdomains, like files.consumerfinance.gov, although it + does track links to those pages. +
  • +
  • + Pages with query parameters, with the exception of the ?page= query + parameter. So, "/about-us/blog/?page=1" is included, but + "/about-us/blog/?title=&topics=financial-education" is not. +
  • +
+
+
{% endblock %} diff --git a/viewer/templates/viewer/page_detail.html b/viewer/templates/viewer/page_detail.html index 56eafe5..7b5fc2d 100644 --- a/viewer/templates/viewer/page_detail.html +++ b/viewer/templates/viewer/page_detail.html @@ -1,109 +1,108 @@ {% extends './base.html' %} - {% block breadcrumbs %} -{% include "viewer/breadcrumbs.html" %} + {% include "viewer/breadcrumbs.html" %} {% endblock breadcrumbs %} {% block content %} -
-

{{ title }}

-
+
+

{{ title }}

+
-
-

{{ url }}

-

(last crawled {{ timestamp }})

-
+
+

{{ url }}

+

(last crawled {{ timestamp }})

+
-
-
- -
-
    - {% for link in links %} -
  • {{ link }}
  • - {% endfor %} -
+ +
+
    + {% for link in links %} +
  • {{ link }}
  • + {% endfor %} +
+
-
-
-
- -
-
    - {% for component in components %} -
  • {{ component }}
  • - {% endfor %} -
+ +
+
    + {% for component in components %} +
  • {{ component }}
  • + {% endfor %} +
+
-
-
-
- -
-
{{ text }}
+ +
+
{{ text }}
+
-
-
-
- -
-
{{ html }}
+ +
+
{{ html }}
+
-
{% endblock content %} diff --git a/viewer/templates/viewer/page_list.html b/viewer/templates/viewer/page_list.html index 7fcb9e3..1738834 100644 --- a/viewer/templates/viewer/page_list.html +++ b/viewer/templates/viewer/page_list.html @@ -4,7 +4,6 @@
- {% if count %} {% include "approved-round.svg" %} {% else %} @@ -13,24 +12,23 @@
{% results_summary %}
{% if count %} - + {% endif %}
@@ -40,93 +38,94 @@

-
{{ page.url }}
-
- Details - - + Details + + {% endfor %} {% if previous or next %} -
- +
{% endif %}
Discover more
{% if crawl_stats.start %} -
- Data last updated: -

{{ crawl_stats.start | format_datetime }}

-
+
+ Data last updated: +

{{ crawl_stats.start | format_datetime }}

+
{% endif %}
  • diff --git a/viewer/templates/viewer/search_form.html b/viewer/templates/viewer/search_form.html index 1265a49..5f156d5 100644 --- a/viewer/templates/viewer/search_form.html +++ b/viewer/templates/viewer/search_form.html @@ -40,63 +40,74 @@

    Search the index

    - + {% if request.query_params.search_type is None or request.query_params.search_type == 'title' %}checked{% endif %} + />
    - +
    - + {% if request.query_params.search_type == 'text' %}checked{% endif %} + />
    - +
    - + {% if request.query_params.search_type == 'components' %}checked{% endif %} + />
    - + {% if request.query_params.search_type == 'html' %}checked{% endif %} + />