]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add script that sets the canonical link 7628/head
authorDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Thu, 2 May 2019 16:23:10 +0000 (18:23 +0200)
committerDaniel Garcia-Sanchez <daniel.garcia-sanchez@insp.upmc.fr>
Thu, 2 May 2019 16:23:10 +0000 (18:23 +0200)
doc/doxygen/CMakeLists.txt
doc/doxygen/scripts/set_canonical_doxygen.py [new file with mode: 0755]

index c008c0ffd0f998afa2121d1d104864d6f538cd94..285e05806fec44fd4c29c6cea7e65ffdd65a5de1 100644 (file)
@@ -303,6 +303,10 @@ ADD_CUSTOM_TARGET(doxygen ALL
   )
 ADD_DEPENDENCIES(documentation doxygen)
 
+# Set the canonical link for the doxygen webpages
+ADD_CUSTOM_COMMAND(TARGET doxygen POST_BUILD
+    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/set_canonical_doxygen.py)
+
 INSTALL(FILES
   ${CMAKE_CURRENT_BINARY_DIR}/deal.tag
   DESTINATION ${DEAL_II_DOCHTML_RELDIR}/doxygen
diff --git a/doc/doxygen/scripts/set_canonical_doxygen.py b/doc/doxygen/scripts/set_canonical_doxygen.py
new file mode 100755 (executable)
index 0000000..4d411b0
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/env python3
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2019 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+# This script sets the canonical webpage for all the webpages of the
+# doxygen documentation. For more information see
+# https://en.wikipedia.org/wiki/Canonical_link_element
+#
+# This script is invoked by CMake. To add the canonical link to the webpages of
+# the deal.ii repository you can use the script
+# contrib/utilities/set_canonical_webpages.py
+
+import glob
+
+filenames = glob.iglob('**/*html', recursive=True)
+
+for filename in filenames:
+    file = open(filename, 'r')
+    new_text_data = str()
+    if '<link rel="canonical"' not in file.read():
+        file.seek(0)
+        for line in file.readlines():
+            # Do not add the canonical link twice
+            canonical_link_added = False
+            new_text_data += line
+            if (not canonical_link_added) and ('<head>' in line):
+                new_text_data += ('<link rel="canonical" href="https://www.dealii.org/current/doxygen/deal.II/'
+                                  + filename + '" />' + '\n')
+                canonical_link_added = True
+        file.close()
+
+        # Truncate the file and write the new text
+        file = open(filename, 'w+')
+        file.write(new_text_data)
+        file.close()

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.