From: Daniel Garcia-Sanchez Date: Thu, 2 May 2019 16:23:10 +0000 (+0200) Subject: Add script that sets the canonical link X-Git-Tag: v9.1.0-rc1~79^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7628%2Fhead;p=dealii.git Add script that sets the canonical link --- diff --git a/doc/doxygen/CMakeLists.txt b/doc/doxygen/CMakeLists.txt index c008c0ffd0..285e05806f 100644 --- a/doc/doxygen/CMakeLists.txt +++ b/doc/doxygen/CMakeLists.txt @@ -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 index 0000000000..4d411b0a79 --- /dev/null +++ b/doc/doxygen/scripts/set_canonical_doxygen.py @@ -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 '' in line): + new_text_data += ('' + '\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()