public inbox for overseers@sourceware.org
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Mark Wielaard <mark@klomp.org>
Cc: Joel Brobecker <brobecker@adacore.com>,
	Pedro Alves <pedro@palves.net>,
	Overseers mailing list <overseers@sourceware.org>,
	simon.marchi@polymtl.ca, eliz@gnu.org,
	Mike Frysinger <vapier@gentoo.org>
Subject: Re: setting up sim project web space
Date: Sun, 5 Dec 2021 14:51:04 +0400	[thread overview]
Message-ID: <YayZmFrf9umpF0hJ@adacore.com> (raw)
In-Reply-To: <YaPzIywf5RN+WMYw@wildebeest.org>

[-- Attachment #1: Type: text/plain, Size: 1371 bytes --]

Hello,

> On Thu, Nov 25, 2021 at 06:00:47AM +0400, Joel Brobecker wrote:
> > > For savannah you are unfortunately stuck with CVS for webpages. But you
> > > can just install a redirect to https://sourceware.org/gdb/ so you don't
> > > need to keep mirroring it in two places.
> > 
> > Sounds like an interesting idea.
> > 
> > One of the things I'm concerned about is perhaps people having
> > bookmarks of old pages. Or perhaps have every one of the current
> > pages be a redirect to the corresponding page?
> > 
> > Something like this?
> > 
> > <!DOCTYPE html>
> > <html>
> >    <head>
> >       <title>Redirecting to </title>
> >       <meta http-equiv = "refresh" content = "3; url = https://https://www.sourceware.org/gdb/" />
> >    </head>
> >    <body>
> >       <p>Redirecting to sourceware.org</p>
> >    </body>
> > </html>
> 
> That should work for html pages. It is what e.g. gnutls uses.  They
> keep the page itself in place (so if there is any delay in the
> redirection the user at least sees the old contents), and they just
> add the meta http-equiv tag right after the head tag with a
> content="0; (to make the redirect instantanious).
> 
> This requires a little scripting to update all pages (let me know if
> you can use help with that).

I've added the redirects, with the help of the attached script.
Pretty crude, but did the job.

-- 
Joel

[-- Attachment #2: add-redirect.py --]
[-- Type: text/x-python, Size: 1629 bytes --]

#! /usr/bin/env python3

import os

def redirect_url(dirname, filename):
    # Use a path which is relative
    dirname = os.path.relpath(dirname)

    result = os.path.join(
        "https://www.sourceware.org/gdb",
        dirname,
    )
    if filename == "index.html":
        # This is the default file for this directory. Omit the file,
        # but still end the URL with a '/'; not necessary, but helps
        # indicate that the target is a directory.
        result += "/"
    else:
        result = os.path.join(result, filename)
    return result


def redirect_tag(dirname, filename):
    url = redirect_url(dirname, filename)
    return f'<meta http-equiv = "refresh" content = "0; url = {url}" />'


def fixup(dirname, filename):
    file_path = os.path.join(dirname, filename)
    with open(file_path, 'rb') as f:
        contents = f.read()

    redirect_inserted_p = False
    with open(file_path, "wb") as f:
        for line in contents.splitlines(keepends=True):
            f.write(line)
            if not redirect_inserted_p and b"<head>" in line.lower():
                f.write(redirect_tag(dirname, filename).encode())
                f.write(b"\n")
                redirect_inserted_p = True


for dirname, _, files in os.walk("."):
    for filename in files:
        _, filename_ext = os.path.splitext(filename)

        if filename_ext.lower() not in (".htm", ".html"):
            # Not an HTML file, keep going.
            continue

        if os.path.join(dirname, filename) == "./bugs/index.html":
            # Already converted. Skip.
            continue

        fixup(dirname, filename)

  reply	other threads:[~2021-12-05 10:51 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10  4:17 Mike Frysinger
2021-09-10 12:06 ` Frank Ch. Eigler
2021-11-18  0:50   ` Mike Frysinger
2021-11-18  0:56     ` Frank Ch. Eigler
2021-11-18  1:38       ` Mike Frysinger
2021-11-18 15:03         ` Mark Wielaard
2021-11-19  8:31           ` Mike Frysinger
2021-11-19  8:42             ` Mike Frysinger
2021-11-19 10:08               ` Mark Wielaard
2021-11-19 11:15                 ` Mike Frysinger
2021-11-19 15:49                   ` Pedro Alves
2021-11-21 13:59                     ` Joel Brobecker
2021-11-24 10:02                       ` Mark Wielaard
2021-11-24 11:16                         ` Mike Frysinger
2022-10-24 16:19                           ` Mike Frysinger
2022-10-24 23:47                             ` Frank Ch. Eigler
2022-12-30 16:44                               ` Mark Wielaard
2023-01-04  8:18                                 ` Mike Frysinger
2023-01-05 22:38                                   ` Mark Wielaard
2023-01-05 22:43                                     ` Mark Wielaard
2023-01-06  6:22                                       ` Joel Brobecker
2023-01-10 18:27                                         ` Frank Ch. Eigler
2023-01-10 20:18                                           ` Mark Wielaard
2023-01-11  5:36                                             ` Joel Brobecker
2023-01-11 23:56                                               ` Mark Wielaard
2023-01-12  5:12                                                 ` broken current onlinedocs Mike Frysinger
2023-01-12  7:30                                                   ` Mark Wielaard
2023-01-16  3:42                                                   ` Joel Brobecker
2023-01-15 22:00                                               ` setting up sim project web space Mike Frysinger
2023-01-16  3:17                                                 ` Joel Brobecker
2021-11-25  2:00                         ` Joel Brobecker
2021-11-28 21:22                           ` Mark Wielaard
2021-12-05 10:51                             ` Joel Brobecker [this message]
2021-12-22  7:08                               ` Mike Frysinger
2021-12-24  3:01                                 ` Joel Brobecker

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YayZmFrf9umpF0hJ@adacore.com \
    --to=brobecker@adacore.com \
    --cc=eliz@gnu.org \
    --cc=mark@klomp.org \
    --cc=overseers@sourceware.org \
    --cc=pedro@palves.net \
    --cc=simon.marchi@polymtl.ca \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).