public inbox for [email protected]  
help / color / mirror / Atom feed
From: Célestin Matte <[email protected]>
To: PostgreSQL WWW <[email protected]>
Subject: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
Date: Tue, 26 Oct 2021 16:34:47 +0200
Message-ID: <[email protected]> (raw)

Hello,

Domain of messages in pgweb's search is currently hardcoded as postgresql.org
in templates/search/listsearch.html. This patch allows to use another domain
for links to messages in archives in the search function.
Since pgarchives' domain can differ from pgweb's one, a new variable is defined
for that purpose instead of using SITE_ROOT.

Cheers,
-- 
Célestin Matte

Attachments:

  [text/x-patch] 0001-Add-ARCHIVES_FRONT_ADDRESS-to-allow-configuration-of.patch (3.7K, 2-0001-Add-ARCHIVES_FRONT_ADDRESS-to-allow-configuration-of.patch)
  download | inline diff:
From 219ba92f849b1058f53c8aeae1680ec41daad900 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]>
Date: Tue, 26 Oct 2021 16:27:38 +0200
Subject: [PATCH] Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
 messages URL

Domain of messages in pgweb's search is currently hardcoded as postgresql.org
in templates/search/listsearch.html. This patch allows to use another domain
for links to messages in archives in the search function.
Since pgarchives' domain can differ from pgweb's one, a new variable is defined
for that purpose instead of using SITE_ROOT.
---
 pgweb/search/views.py            | 2 ++
 pgweb/settings.py                | 1 +
 templates/search/listsearch.html | 4 ++--
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/pgweb/search/views.py b/pgweb/search/views.py
index 56733c82..20699ac3 100644
--- a/pgweb/search/views.py
+++ b/pgweb/search/views.py
@@ -133,6 +133,7 @@ def search(request):
                 'listid': listid,
                 'dates': dateoptions,
                 'dateval': dateval,
+                'archives_root': settings.ARCHIVES_SEARCH_SERVER,
             })
         else:
             return render(request, 'search/sitesearch.html', {
@@ -236,6 +237,7 @@ def search(request):
             'firsthit': firsthit,
             'lasthit': min(totalhits, firsthit + hitsperpage - 1),
             'query': request.GET['q'],
+            'archives_root': settings.ARCHIVES_SEARCH_SERVER,
             'pagelinks': "&nbsp;".join(
                 generate_pagelinks(pagenum,
                                    (totalhits - 1) // hitsperpage + 1,
diff --git a/pgweb/settings.py b/pgweb/settings.py
index 6c1cb24e..5df7e395 100644
--- a/pgweb/settings.py
+++ b/pgweb/settings.py
@@ -164,6 +164,7 @@ VARNISH_PURGERS = ()                                        # Extra servers that
 DO_ESI = False                                              # Generate ESI tags
 ARCHIVES_SEARCH_SERVER = "archives.postgresql.org"          # Where to post REST request for archives search
 ARCHIVES_SEARCH_PLAINTEXT = False                           # Contact ARCHIVES_SEARCH_SERVER with http instead of https
+ARCHIVES_FRONT_ADDRESS = "www.postgresql.org"               # Domain to read archives messages
 FRONTEND_SMTP_RELAY = "magus.postgresql.org"                # Where to relay user generated email
 OAUTH = {}                                                  # OAuth providers and keys
 PGDG_ORG_ID = -1                                            # id of the PGDG organisation entry
diff --git a/templates/search/listsearch.html b/templates/search/listsearch.html
index 4d07ded3..42adcdb8 100644
--- a/templates/search/listsearch.html
+++ b/templates/search/listsearch.html
@@ -53,10 +53,10 @@
     <h2>Results {{firsthit}}-{{lasthit}} of {%if hitcount == 1000%}more than 1000{%else%}{{hitcount}}{%endif%}.</h2>
     {%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%}
     {%for hit in hits %}
-      {{forloop.counter0|add:firsthit}}. <a href="https://www.postgresql.org/message-id/{{hit.messageid}}">{{hit.subject}}</a> [{{hit.rank|floatformat:2}}]<br/>
+      {{forloop.counter0|add:firsthit}}. <a href="https://{{ archives_root }}/message-id/{{hit.messageid}}">{{hit.subject}}</a> [{{hit.rank|floatformat:2}}]<br/>
       From {{hit.author}} on {{hit.date}}.<br/>
       {{hit.abstract|safe}}<br/>
-      <a href="https://www.postgresql.org/message-id/{{hit.messageid}}">https://www.postgresql.org/message-id/{{hit.messageid}}</a><br/>
+      <a href="https://{{ archives_root }}/message-id/{{hit.messageid}}">https://{{ archives_root }}/message-id/{{hit.messageid}}</a><br/>
       <br/>
     {%endfor%}
     {%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%}
-- 
2.33.1



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox