Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives URL
authorCΓ©lestin Matte <gitlab@cmatte.me>
Sat, 15 Jan 2022 17:20:04 +0000 (18:20 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sat, 15 Jan 2022 17:37:42 +0000 (18:37 +0100)
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
pgweb/settings.py
templates/search/listsearch.html

index 56733c82d871e330bf3878a38e139f338a6cc823..9c0bc6ac6a32533d8a6af47df18283e876c87fa2 100644 (file)
@@ -133,6 +133,7 @@ def search(request):
                 'listid': listid,
                 'dates': dateoptions,
                 'dateval': dateval,
+                'archives_root': settings.ARCHIVES_FRONT_ADDRESS,
             })
         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_FRONT_ADDRESS,
             'pagelinks': "&nbsp;".join(
                 generate_pagelinks(pagenum,
                                    (totalhits - 1) // hitsperpage + 1,
index 0e39099b617519137998273857dbb14a170b598e..41323be48251753b7e621de1ed739eb44b9d9add 100644 (file)
@@ -167,6 +167,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 = "https://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
index 4d07ded37ff17221b5f783ecf5114279c383efbe..fb3b241da6c107459fd052de4b210e16fe442ad1 100644 (file)
     <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="{{ 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="{{ archives_root }}/message-id/{{hit.messageid}}">{{ archives_root }}/message-id/{{hit.messageid}}</a><br/>
       <br/>
     {%endfor%}
     {%if pagelinks %}Result pages: {{pagelinks|safe}}<br/><br/>{%endif%}