Skip to content

Add redirects for the gtk-doc based plugins documentation

Thibault Saunier requested to merge thiblahute/www:plugins_redirect into master

Generated with:

#!/usr/bin/python3
import json
import subprocess
import sys
import urllib
from urllib import request

# From gst-build/subprojects:
# ./redirect.py $(find -name gst_plugins_cache.json)
for j in sys.argv[1:]:
  r = json.load(open(j))
  module_name = j.split('/')[1]
  for pname, plugin in r.items():
    print("Redirect \"/data/doc/gstreamer/stable/%s-plugins/html/%s-plugins-plugin-%s.html\" \"/documentation/%s-1.0/index.html\"" % (module_name, module_name, pname, pname))
    elements = plugin['elements']
    unique = len(elements) == 1
    for element in elements:
      if unique:
          pagename = 'index.html'
      else:
        pagename = element + '.html'

      # print("Redirect \"/data/doc/gstreamer/stable/%s-plugins/html/%s-plugins-%s.html\" \"/documentation/%s-1.0/%s\"" % (module_name, module_name, element, pname, pagename))

      old = "/data/doc/gstreamer/stable/%s-plugins/html/%s-plugins-%s.html" % (module_name, module_name, element)
      new = "/documentation/%s-1.0/%s" % (pname, pagename)

      works = True
      for i in [old, new]:
        try:
          request.urlopen('https://gstreamer.freedesktop.org/%s' % i)
        except urllib.error.HTTPError:
          works = False
          print("%s failed." % i, file=sys.stderr)

      if works:
        print("Redirect \"%s\" \"%s\"" % (old, new))

It seems all right.

Edited by Tim-Philipp Müller

Merge request reports