Skip to content

Commit

Permalink
Merge pull request #4940 from freelawproject/4815-new-base.html
Browse files Browse the repository at this point in the history
feat(redesign): introduce new_base.html with waffle flag
  • Loading branch information
mlissner authored Jan 26, 2025
2 parents f278a9d + 414380a commit cdbf894
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 0 deletions.
185 changes: 185 additions & 0 deletions cl/assets/templates/new_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{% load static %}{% load humanize %}{% load widget_tweaks %}{% load extras %}{% load waffle_tags %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="Content-Language" content="en"/>
<meta name="language" content="en_us"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>

{% block meta %}
<meta name="description" content="{% block description %}Create alerts, search for and browse the latest case law, PACER documents, judges, and oral arguments. Updated automatically with the latest court documents. An initiative of Free Law Project.{% endblock %}"/>

{# Open Search Plugin #}
<link rel="search"
type="application/opensearchdescription+xml"
title="CourtListener"
href="{% static "xml/opensearch.xml" %}" />

{# MS Application Icons #}
<meta name="application-name" content="CourtListener"/>
<meta name="msapplication-tooltip" content="Create alerts, search for and browse the latest case law."/>
<meta name="msapplication-starturl" content="https://www.courtlistener.com"/>
<meta name="msapplication-navbutton-color" content="#6683B7"/>

{# Twitter #}
<meta name="twitter:card" content="{% block twitter_card_type %}summary{% endblock %}">
<meta name="twitter:creator" content="@freelawproject">
<meta name="twitter:site" content="@courtlistener">

{# Facebook #}
<meta property="og:type" content="website"/>
<meta property="og:title" content="{% block og_title %}CourtListener{% endblock %}"/>
<meta property="og:description"
content="{% block og_description %}Create alerts, search for and browse the latest case law, PACER documents, judges, and oral arguments. Updated automatically with the latest court documents. An initiative of Free Law Project.{% endblock %}">
<meta property="og:url" content="{% block og_url %}{% get_full_host %}{{ request.path }}{% endblock %}"/>
<meta property="og:site_name" content="CourtListener"/>
<meta property="og:image"
content="{% block og_image %}{% static "png/og-image-1200x630.png" %}{% endblock %}"/>
<meta property="og:image:type" content="{% block og_image_type %}image/png{% endblock %}"/>
<meta property="twitter:image:alt"
content="{% block og_image_alt %}The CourtListener logo{% endblock %}"/>
<meta property="og:image:width" content="{% block og_image_width %}1200{% endblock %}"/>
<meta property="og:image:height" content="{% block og_image_height %}630{% endblock %}"/>
{% endblock %}

{% block icons %}
{# Touch icons, etc from: https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs #}
<link rel="icon" href="{% static "ico/favicon.ico" %}" sizes="32x32">
<link rel="icon" href="{% static "svg/favicon.svg" %}" type="image/svg+xml">
<link rel="apple-touch-icon" href="{% static "png/apple-touch-icon.png" %}">
{# Add hashes to manifest by hand. They're the first 12 chars of the MD5 of the file. #}
<link rel="manifest" href="{% static "json/manifest.json" %}">
{% endblock %}

<link href="{% static "css/font-awesome.css" %}" rel="stylesheet">

{% block privacy %}
{% if private %}
<meta name="robots" content="noindex, noodp, noarchive, noimageindex" />
{% elif private == None %}
<!-- This bit of invalid HTML is to give developers a loud warning. -->
<h1>You did not supply the "private" variable to your template.
Please indicate if it is True or False to remove this
awful message.</h1>
{% endif %}
{% endblock %}
<title>{% block title %}CourtListener.com{% endblock %}</title>
{% block head %}{% endblock %}
{% block canonical %}{% endblock %}
<link rel="stylesheet" href="{% static "css/override.css" %}" type="text/css"
media="screen, projection">
</head>

<body class="{% block body-classes %}{% endblock %}">
<div class="container round-bottom">
{% block header %}
<header class="row">
New design MVP
</header>
{% endblock %}

{% block messages %}
{% include "includes/messages.html" %}
{% endblock %}

<div class="row content">
{% block sidebar %}
<div class="col-sm-3" id="sidebar"></div>
{% endblock %}

{# for the settings pages #}
{% block nav %}{% endblock %}

{% block content %}
<p>Your content seems to be missing! This is never good.</p>
{% endblock %}
</div>

{% block newsletter %}
<div class="row base-newsletter hidden-print">
<div class="col-sm-6">
<p class="bold bottom">Newsletter</p>
<p>Sign up to receive the Free Law Project newsletter with tips and announcements.</p>
</div>
<div class="col-sm-6 right">
<a href="https://donate.free.law/np/clients/freelawproject/subscribe.jsp?forwardedFromSecureDomain=1&subscription=9"
class="btn btn-default"
tabindex="10000">
<i class="fa fa-newspaper-o"></i>&nbsp;Subscribe
</a>
</div>
</div>
{% endblock %}

{% block footer %}
<footer class="row hidden-print">
</footer>
{% endblock %}
</div>

{% block social %}
<div class="text-center hidden-print" id="social-container">
<a href="https://free.law/"
class="fa-stack fa-lg"
tabindex="12000">
<i class="fa fa-circle fa-stack-2x gray"></i>
<i class="fa fa-link fa-stack-1x fa-inverse"></i>
</a>
<a href="https://x.com/freelawproject"
rel="noreferrer"
class="fa-stack fa-lg"
tabindex="12001">
<i class="fa fa-circle fa-stack-2x gray"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</a>
<a href="https://donate.free.law/np/clients/freelawproject/subscribe.jsp?subscription=9"
class="fa-stack fa-lg"
tabindex="12002">
<i class="fa fa-circle fa-stack-2x gray"></i>
<i class="fa fa-newspaper-o fa-stack-1x fa-inverse"></i>
</a>
<a href="https://github.com/freelawproject/courtlistener"
rel="noreferrer"
class="fa-stack fa-lg"
tabindex="12003">
<i class="fa fa-circle fa-stack-2x gray"></i>
<i class="fa fa-github fa-stack-1x fa-inverse"></i>
</a>
</div>
{% endblock %}

{% if DEBUG %}
<script type="text/javascript"
src="{% static "js/jquery/jquery-3.4.1.js" %}"></script>
{% else %}
<script type="text/javascript"
src="{% static "js/jquery/jquery-3.4.1.min.js" %}"></script>
{% endif %}

<script type="text/javascript" src="{% static "js/base.js" %}"></script>
<script type="text/javascript" nonce="{{ request.csp_nonce }}">
{# Default values are to ensure JS parsing even if 500 error thrown #}
var isMember = {{ user.profile.is_member|yesno:"true,false" }},
userAlertCount = {{ user.docket_alerts.subscriptions.count|default:"0" }},
priceRtAlerts = parseFloat({{ MIN_DONATION.rt_alerts|default:0 }}),
maxFreeDocketAlerts = {{ MAX_FREE_DOCKET_ALERTS|default:0 }},
recapBonusAlerts = {{ DOCKET_ALERT_RECAP_BONUS|default:0 }};

</script>

{# Allows your own scripts in the footer. #}
{% block footer-scripts %}{% endblock %}

{# Record stats for non-superusers 1/10 times to save money #}
{% if not user.is_superuser %}
{% random_int 0 9 as rand %}
{% if rand == 0 %}
<script
defer
data-domain="courtlistener.com"
src="https://plausible.io/js/plausible.js"></script>
{% endif %}
{% endif %}
</body>
</html>
33 changes: 33 additions & 0 deletions cl/lib/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from asgiref.sync import iscoroutinefunction, markcoroutinefunction
from django.http import HttpRequest, HttpResponseBase
from django.template.response import TemplateResponse
from waffle import flag_is_active


class RobotsHeaderMiddleware:
Expand Down Expand Up @@ -56,3 +57,35 @@ def process_template_response(
"noindex, noarchive, noimageindex"
)
return response


class IncrementalNewTemplateMiddleware:
"""
Checks waffle flag for new design and changes the old template
with the new one if it exists.
To identify the new template we prepend "v2_" to the old template name.
Note this means if the old template_name includes a dir, like
"help/index.html", the new template should be in "v2_help/index.html"
and NOT in "help/v2_index.html".
TODO: Remove this middleware once new design is completely rolled out.
"""

def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
response = self.get_response(request)
return response

def process_template_response(self, request, response):
use_new_design = flag_is_active(request, "use_new_design")

if use_new_design and isinstance(response, TemplateResponse):
old_template = response.template_name
if isinstance(old_template, str):
new_template = f"v2_{old_template}"
response.template_name = [new_template, old_template]

return response
1 change: 1 addition & 0 deletions cl/settings/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"waffle.middleware.WaffleMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"cl.lib.middleware.RobotsHeaderMiddleware",
"cl.lib.middleware.IncrementalNewTemplateMiddleware",
"pghistory.middleware.HistoryMiddleware",
]

Expand Down
78 changes: 78 additions & 0 deletions cl/simple_pages/templates/v2_help/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{% extends "new_base.html" %}

{% block title %}Getting Help – CourtListener.com{% endblock %}
{% block footer-scripts %}
{% include "includes/anchors.html" %}
{% endblock %}
{% block sidebar %}{% endblock %}


{% block content %}
<div class="hidden-xs col-sm-2 col-md-3"></div>
<div class="col-xs-12 col-sm-8 col-md-6">
<h1>Getting Help on CourtListener</h1>
<p class="lead">The following help articles are currently available:</p>
<ol>
<li><p><a href="{% url "alert_help" %}">Help with search and docket alerts</a></p></li>
<li><p><a href="{% url "pray_and_pay_help" %}">Help with Pray and Pay project</a></p></li>
<li><p><a href="{% url "recap_email_help" %}">Help with @recap.email</a></p></li>
<li><p><a href="{% url "advanced_search" %}">Help with advanced search parameters</a></p></li>
<li><p><a href="{% url "tag_notes_help" %}">Learn how to tag dockets and save notes</a></p></li>
<li><p><a href="{% url "feeds_info" %}">Learn about RSS feeds</a></p></li>
<li><p><a href="{% url "podcasts" %}">Learn about our Podcasts</a></p></li>
<li><p><a href="{% url "markdown_help" %}">Help formatting with Markdown</a></p></li>
<li><p><a href="{% url "donation_help" %}">Help with your donations</a></p></li>
<li><p><a href="{% url "delete_help" %}">Help deleting your account</a></p></li>
</ol>

<h2 class="v-offset-above-3">About our Data</h2>
<p class="lead">We've built some of the biggest open datasets in the world. Learn more about them:</p>
<ol>
<li><p><a href="{% url "coverage" %}">Coverage Homepage</a></p></li>
<li><p><a href="{% url "coverage_recap" %}">PACER Data Coverage</a></p></li>
<li><p><a href="{% url "coverage_opinions" %}">Case Law Coverage</a></p></li>
<li><p><a href="{% url "coverage_fds" %}">Financial Disclosure Coverage</a></p></li>
<li><p><a href="https://free.law/projects/judge-db" target="_blank">Judge Coverage</a></p></li>
<li><p><a href="{% url "coverage_oa" %}">Oral Argument Recording Coverage</a></p></li>
</ol>

<h2 class="v-offset-above-3">Developer Documentation</h2>
<p class="lead">The following documentation is available for developers:</p>
<ol>
<li><p>API Documentation</p></li>
<ul>
<li><p><a href="{% url "rest_docs" %}">REST API Overview</a></p></li>
<li><p><a href="{% url "citation_lookup_api" %}">Citation Lookup API</a></p></li>
<li><p><a href="{% url "search_api_help" %}">Search API</a></p></li>
<li><p><a href="{% url "case_law_api_help" %}">Case Law APIs</a></p></li>
<li><p><a href="{% url "pacer_api_help" %}">PACER Data APIs</a></p></li>
<li><p><a href="{% url "recap_api_help" %}">RECAP APIs</a></p></li>
<li><p><a href="{% url "judge_api_help" %}">Judge APIs</a></p></li>
<li><p><a href="{% url "financial_disclosures_api_help" %}">Financial Disclosure APIs</a></p></li>
<li><p><a href="{% url "citation_api_help" %}">Citation APIs</a></p></li>
<li><p><a href="{% url "alert_api_help" %}">Alert APIs</a></p></li>
<li><p><a href="{% url "visualization_api_help" %}">Supreme Court Visualization APIs</a></p></li>
</ul>
<li><p>Webhook Documentation</p></li>
<ul>
<li><p><a href="{% url "webhooks_docs" %}">Webhook Overview</a></p></li>
<li><p><a href="{% url "webhooks_getting_started" %}">Getting Started</a></p></li>
</ul>
<li><p><a href="{% url "bulk_data_index" %}">Bulk Data Documentation</a></p></li>
<li><p><a href="{% url "replication_docs" %}">Replication Documentation</a></p></li>
<li><p><a href="{% url "api_index" %}">Data Services on CourtListener</a></p></li>
</ol>

<h2 class="v-offset-above-3">Removing Content</h2>
<p>We will not remove content from our systems absent a valid court order, but we will usually remove content from public search engines like Google, upon request.
</p>
<p><a href="{% url "terms" %}#removal" class="btn btn-default">Read our removal policy to learn more</a></p>

<h2 class="v-offset-above-3">More Help?</h2>
<p>If you're unable to find what you're looking for above you have a few more options:</p>
<p>
<a href="{% url "faq" %}" class="btn btn-default btn-lg col-xs-4 col-xs-push-1"><span class="hidden-xs">Try our </span>FAQs</a>
<a href="{% url "contact" %}" class="btn btn-primary btn-lg col-xs-4 col-xs-push-2">Contact Us</a>
</p>
</div>
{% endblock %}

0 comments on commit cdbf894

Please sign in to comment.