public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
6+ messages / 2 participants
[nested] [flat]

* [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
@ 2021-10-26 14:34 Célestin Matte <[email protected]>
  2021-10-27 09:21 ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Magnus Hagander <[email protected]>
  2021-10-27 09:58 ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
  0 siblings, 2 replies; 6+ messages in thread

From: Célestin Matte @ 2021-10-26 14:34 UTC (permalink / raw)
  To: PostgreSQL WWW <[email protected]>

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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
  2021-10-26 14:34 [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
@ 2021-10-27 09:21 ` Magnus Hagander <[email protected]>
  2021-10-27 09:45   ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
  1 sibling, 1 reply; 6+ messages in thread

From: Magnus Hagander @ 2021-10-27 09:21 UTC (permalink / raw)
  To: Célestin Matte <[email protected]>; +Cc: PostgreSQL WWW <[email protected]>

On Tue, Oct 26, 2021 at 4:34 PM Célestin Matte <[email protected]>
wrote:

> 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.
>

This patch adds a new parameter ARCHIVES_FRONT_ADDRESS, which is then never
used. Instead it passes in ARCHIVES_SEARCH_SERVER into the templates.

I'm pretty sure that's not intentional? They should both b
ARCHIVES_FRONT_ADDRESS?

-- 
 Magnus Hagander
 Me: https://www.hagander.net/ <http://www.hagander.net/;
 Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
  2021-10-26 14:34 [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
  2021-10-27 09:21 ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Magnus Hagander <[email protected]>
@ 2021-10-27 09:45   ` Célestin Matte <[email protected]>
  2022-01-15 17:38     ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Magnus Hagander <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Célestin Matte @ 2021-10-27 09:45 UTC (permalink / raw)
  To: [email protected]

> This patch adds a new parameter ARCHIVES_FRONT_ADDRESS, which is then never used. Instead it passes in ARCHIVES_SEARCH_SERVER into the templates.
> 
> I'm pretty sure that's not intentional? They should both b ARCHIVES_FRONT_ADDRESS?

Oops, indeed, this is the product of a failed git merge --squash.

Fixed patch attached.
-- 
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 237ab289165e34b77a20e1d1c152cc935892118e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]>
Date: Wed, 27 Oct 2021 11:41:45 +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..9c0bc6ac 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_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,
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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
  2021-10-26 14:34 [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
  2021-10-27 09:21 ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Magnus Hagander <[email protected]>
  2021-10-27 09:45   ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
@ 2022-01-15 17:38     ` Magnus Hagander <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Magnus Hagander @ 2022-01-15 17:38 UTC (permalink / raw)
  To: Célestin Matte <[email protected]>; +Cc: [email protected]

On Wed, Oct 27, 2021 at 11:45 AM Célestin Matte
<[email protected]> wrote:
>
> > This patch adds a new parameter ARCHIVES_FRONT_ADDRESS, which is then never used. Instead it passes in ARCHIVES_SEARCH_SERVER into the templates.
> >
> > I'm pretty sure that's not intentional? They should both b ARCHIVES_FRONT_ADDRESS?
>
> Oops, indeed, this is the product of a failed git merge --squash.
>
> Fixed patch attached.

Finally cycling back to this one, sorry about the long delay. This
does look much better, applied with th modification that it should
take the whole URL and not just the hostname -- which maks it work
better in development for example.

-- 
 Magnus Hagander
 Me: https://www.hagander.net/
 Work: https://www.redpill-linpro.com/





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
  2021-10-26 14:34 [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
@ 2021-10-27 09:58 ` Célestin Matte <[email protected]>
  2022-01-15 17:38   ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Magnus Hagander <[email protected]>
  1 sibling, 1 reply; 6+ messages in thread

From: Célestin Matte @ 2021-10-27 09:58 UTC (permalink / raw)
  To: [email protected]

Hello,

Here's a similar patch for pgarchives, in which the search forms also point to www.postgresql.org.

I'm adding this patch to the same thread to avoid spreading the discussion.

Cheers,
-- 
Célestin Matte

Attachments:

  [text/x-patch] 0001-Add-PGWEB_ADDRESS-setting-to-remove-hardcoded-search.patch (3.5K, 2-0001-Add-PGWEB_ADDRESS-setting-to-remove-hardcoded-search.patch)
  download | inline diff:
From a5579bda500bbb083bdeb1fb31da34be1d1987e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]>
Date: Wed, 27 Oct 2021 11:50:18 +0200
Subject: [PATCH] Add PGWEB_ADDRESS setting to remove hardcoded search form
 address

Search forms currently point to the hardcoded address of www.postgresql.org.
Add a parameter in the settings to make it possible to configure the domain
hosting the /search/ function.
---
 django/archives/mailarchives/templates/searchform.html | 4 ++--
 django/archives/mailarchives/views.py                  | 4 ++++
 django/archives/settings.py                            | 2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/django/archives/mailarchives/templates/searchform.html b/django/archives/mailarchives/templates/searchform.html
index 4855de2..8fef61b 100644
--- a/django/archives/mailarchives/templates/searchform.html
+++ b/django/archives/mailarchives/templates/searchform.html
@@ -1,6 +1,6 @@
 <h3>Search the Archives</h3>
 
-<form method="get" action="/search/">
+<form method="get" action="https://{{ PGWEB_ADDRESS }}/search/">
   <input type="hidden" name="m" value="1">
   {%if searchform_listname%} <input type="hidden" name="ln" value="{{searchform_listname}}"/>{%endif%}
   <div class="row">
@@ -17,7 +17,7 @@
         <small class="form-text text-muted">(enter a message-id to go directly to that message)</small>
       </div>
       <div class="input-group">
-        <a href="https://www.postgresql.org/search/?m=1{%if searchform_listname%}&amp;ln={{searchform_listname}}{%endif%}">Advanced Search</a>
+        <a href="https://{{ PGWEB_ADDRESS }}/search/?m=1{%if searchform_listname%}&amp;ln={{searchform_listname}}{%endif%}">Advanced Search</a>
       </div>
     </div><!-- /.col-lg-6 -->
   </div><!-- /.row -->
diff --git a/django/archives/mailarchives/views.py b/django/archives/mailarchives/views.py
index f711ce4..51fa21d 100644
--- a/django/archives/mailarchives/views.py
+++ b/django/archives/mailarchives/views.py
@@ -207,6 +207,7 @@ def index(request):
     (groups, listgroupid) = get_all_groups_and_lists(request)
     return render_nav(NavContext(request, all_groups=groups), 'index.html', {
         'groups': [{'groupname': g['groupname'], 'lists': g['lists']} for g in groups],
+        'PGWEB_ADDRESS': settings.PGWEB_ADDRESS,
     })
 
 
@@ -219,6 +220,7 @@ def groupindex(request, groupid):
 
     return render_nav(NavContext(request, all_groups=groups, expand_groupid=groupid), 'index.html', {
         'groups': mygroups,
+        'PGWEB_ADDRESS': settings.PGWEB_ADDRESS,
     })
 
 
@@ -234,6 +236,7 @@ def monthlist(request, listname):
     return render_nav(NavContext(request, l.listid, l.listname), 'monthlist.html', {
         'list': l,
         'months': months,
+        'PGWEB_ADDRESS': settings.PGWEB_ADDRESS,
     })
 
 
@@ -285,6 +288,7 @@ def _render_datelist(request, l, d, datefilter, title, queryproc):
         'title': title,
         'daysinmonth': daysinmonth,
         'yearmonth': yearmonth,
+        'PGWEB_ADDRESS': settings.PGWEB_ADDRESS,
     })
     if settings.PUBLIC_ARCHIVES:
         r['xkey'] = ' '.join(['pgam_{0}/{1}/{2}'.format(l.listid, year, month) for year, month in allyearmonths])
diff --git a/django/archives/settings.py b/django/archives/settings.py
index 906d91b..162122c 100644
--- a/django/archives/settings.py
+++ b/django/archives/settings.py
@@ -143,6 +143,8 @@ API_CLIENTS = ('127.0.0.1',)
 PUBLIC_ARCHIVES = False
 ALLOW_RESEND = False
 
+PGWEB_ADDRESS = 'www.postgresql.org'
+
 try:
     from .settings_local import *
 except ImportError:
-- 
2.33.1



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives
  2021-10-26 14:34 [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
  2021-10-27 09:58 ` Re: [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
@ 2022-01-15 17:38   ` Magnus Hagander <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Magnus Hagander @ 2022-01-15 17:38 UTC (permalink / raw)
  To: Célestin Matte <[email protected]>; +Cc: [email protected]

On Wed, Oct 27, 2021 at 11:58 AM Célestin Matte
<[email protected]> wrote:
>
> Hello,
>
> Here's a similar patch for pgarchives, in which the search forms also point to www.postgresql.org.
>
> I'm adding this patch to the same thread to avoid spreading the discussion.

Thanks!

This also looks like a good idea,  but I instead choose to put it in
NavContext to be consistent with allow_resend which also just maps a
setting from settings.py -> the templates.

It should also be the full url and not hardcoded to https, same as the
one for the main website. Fixed as well.

Finally it was also not updating the form for the general search,
which should of course be treated by the same setting.


-- 
 Magnus Hagander
 Me: https://www.hagander.net/
 Work: https://www.redpill-linpro.com/






^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2022-01-15 17:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 14:34 [PATCH] pgweb: Add ARCHIVES_FRONT_ADDRESS to allow configuration of archives Célestin Matte <[email protected]>
2021-10-27 09:21 ` Magnus Hagander <[email protected]>
2021-10-27 09:45   ` Célestin Matte <[email protected]>
2022-01-15 17:38     ` Magnus Hagander <[email protected]>
2021-10-27 09:58 ` Célestin Matte <[email protected]>
2022-01-15 17:38   ` Magnus Hagander <[email protected]>

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