Skip to content

Commit

Permalink
layout.html update fyrir Google Tag Manager og favicon
Browse files Browse the repository at this point in the history
  • Loading branch information
abjarna committed Jul 2, 2024
1 parent 14ccedb commit dc001b1
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 81 deletions.
57 changes: 31 additions & 26 deletions rit/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,48 @@

{% block htmltitle %}
{% if not embedded and docstitle %}





{# "docstitle" skipt út fyrir "project", sem override-ar "html_title" í conf.py #}

{# >>>>> "docstitle" skipt út fyrir "project", sem override-ar "html_title" í conf.py #}
{%- set titlesuffix = " – "|safe + project|e %}
{% else %}
{%- set titlesuffix = "" %}
{% endif %}






{# Athugar hvort "title" innihaldi </span> tag, sem það gerir bara ef toctree er stillt á :numbered: #}

{# >>>>> Athugar hvort "title" innihaldi </span> tag, sem það gerir bara ef toctree er stillt á :numbered: #}
{%- if '</span>' in title %}





{# Ef </span> tag er til staðar, þá er "title" það sem er fyrir aftan </span> (selector [1]) #}

{# >>>>> Ef </span> tag er til staðar, þá er "title" það sem er fyrir aftan </span> (selector [1]) #}
{%- set cleaned_title = title.split('</span>')[1] %}
{%- else %}
{# >>>>> Ef </span> tag er ekki til staðar, þá er "title" óbreyttur (á bara við ef toctree er ekki stillt á :numbered:) #}
{%- set cleaned_title = title %}
{%- endif %}

{# >>>>> Setja inn favicon tengla og stillingar fyrir Progressive Web App (PWA), sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7 #}
<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48">
<link rel="icon" href="https://rit.rubik.is/_static/favicon/icon.svg" sizes="any" type="image/svg+xml">
<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png">
<link rel="manifest" href="https://rit.rubik.is/_static/site.webmanifest">

{# >>>>> Setja inn leiðréttan "title" #}
<title>{{ cleaned_title|striptags|e }}{{ titlesuffix }}</title>

{# >>>>> Google Tag Manager #}
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PL8JH23F');</script>
{# >>>>> End Google Tag Manager #}

{% endblock %}

{# Ef </span> tag er ekki til staðar, þá er "title" óbreyttur (á bara við ef toctree er ekki stillt á :numbered:) #}
{% block body_tag %}
<body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="{{ default_mode }}">

{%- set cleaned_title = title %}
{%- endif %}
<title>{{ cleaned_title|striptags|e }}{{ titlesuffix }}</title>
{% endblock %}
{# >>>>> Google Tag Manager (noscript) #}
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PL8JH23F"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
{# >>>>> End Google Tag Manager (noscript) #}

<div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">{{ _("Skip to main content") }}</a></div>

{%- endblock %}
14 changes: 0 additions & 14 deletions rit/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
extensions = [
'sphinxcontrib.tikz',
'sphinx_sitemap', # Búa til sitemap.xml skrá
'sphinx_favicon', # Setja inn favicon tengla og stillingar fyrir Progressive Web App (PWA) í <head>
'sphinx_copybutton', # Takki til að taka afrit af kóðablokkum
]

Expand Down Expand Up @@ -442,19 +441,6 @@ def apply_styles(text, styles):



# -- sphinx_favicon configuration --------------------------------------------

favicons = [ # Sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7
{"rel": "icon", "href": "https://rit.rubik.is/_static/favicon/favicon.ico", "sizes": "48x48"}, # Fyrir Safari og gamla IE vafra
{"rel": "icon", "href": "https://rit.rubik.is/_static/favicon/icon.svg", "sizes": "any"}, # Fyrir flesta aðra vafra
{"rel": "apple-touch-icon", "href": "https://rit.rubik.is/_static/favicon/apple-touch-icon.png"}, # Fyrir "Add to Home Screen" í Apple tækjum
{"rel": "manifest", "href": "https://rit.rubik.is/_static/site.webmanifest"}, # JSON skrá fyrir "Home Screen icon" á Android tækjum og með stillingum fyrir Progressive Web App (PWA)
]





# -- Sækja PDF configuration -------------------------------------------------

# Föll fyrir "Sækja PDF" takkann
Expand Down
12 changes: 6 additions & 6 deletions sh/build-dev-dirhtml-latexpdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ cd rit
make clean
sphinx-build -b dirhtml -t dev . _build/html

# Bæta "noindex, nofollow" við <head> í öllum HTML skrám
# Bæta "noindex, nofollow" við <head> í öllum HTML skrám fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e 's/<head>/<head>\n<meta name="robots" content="noindex, nofollow">/' {} +

# Fjarlægja "type" úr favicon.ico og apple-touch-icon.png (sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7)
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48"[^>]*>#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48">#' {} +
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png"[^>]*>#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png">#' {} +

# Breyta slóð á favicon í https://rit-dev.rubik.is/ fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e 's|href="https://rit.rubik.is/|href="https://rit-dev.rubik.is/|g' {} +

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; "
# Fjarlægja Google Tag Manager kóða fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e '/<script>(function(w,d,s,l,i){w\[l\]=w\[l\]\|\|\[\];w\[l\]\.push(/,/GTM-PL8JH23F/ d' {} \;
find _build/html/ -name '*.html' -exec sed -i '' -e '/ <noscript><iframe src="https:\/\/www.googletagmanager.com\/ns.html?id=GTM-PL8JH23F"/,/<\/noscript>/d' {} \;

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; " (sem er skilgreint í "_templates/layout.html")
sed -i '' -e 's#<title>.* &ndash; Ritsafn RÚBIK Reykjavíkur</title>#<title>Ritsafn RÚBIK Reykjavíkur</title>#' _build/html/index.html

# Keyra Prettier á allar HTML skrár
Expand Down
12 changes: 6 additions & 6 deletions sh/build-dev-html-latexpdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ cd rit
make clean
sphinx-build -b html -t dev . _build/html

# Bæta "noindex, nofollow" við <head> í öllum HTML skrám
# Bæta "noindex, nofollow" við <head> í öllum HTML skrám fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e 's/<head>/<head>\n<meta name="robots" content="noindex, nofollow">/' {} +

# Fjarlægja "type" úr favicon.ico og apple-touch-icon.png (sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7)
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48"[^>]*>#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48">#' {} +
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png"[^>]*>#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png">#' {} +

# Breyta slóð á favicon í https://rit-dev.rubik.is/ fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e 's|href="https://rit.rubik.is/|href="https://rit-dev.rubik.is/|g' {} +

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; "
# Fjarlægja Google Tag Manager kóða fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e '/<script>(function(w,d,s,l,i){w\[l\]=w\[l\]\|\|\[\];w\[l\]\.push(/,/GTM-PL8JH23F/ d' {} \;
find _build/html/ -name '*.html' -exec sed -i '' -e '/ <noscript><iframe src="https:\/\/www.googletagmanager.com\/ns.html?id=GTM-PL8JH23F"/,/<\/noscript>/d' {} \;

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; " (sem er skilgreint í "_templates/layout.html")
sed -i '' -e 's#<title>.* &ndash; Ritsafn RÚBIK Reykjavíkur</title>#<title>Ritsafn RÚBIK Reykjavíkur</title>#' _build/html/index.html

# Keyra Prettier á allar HTML skrár
Expand Down
12 changes: 6 additions & 6 deletions sh/build-dev-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ cd rit
make clean
sphinx-build -b html -t dev . _build/html

# Bæta "noindex, nofollow" við <head> í öllum HTML skrám
# Bæta "noindex, nofollow" við <head> í öllum HTML skrám fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e 's/<head>/<head>\n<meta name="robots" content="noindex, nofollow">/' {} +

# Fjarlægja "type" úr favicon.ico og apple-touch-icon.png (sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7)
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48"[^>]*>#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48">#' {} +
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png"[^>]*>#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png">#' {} +

# Breyta slóð á favicon í https://rit-dev.rubik.is/ fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e 's|href="https://rit.rubik.is/|href="https://rit-dev.rubik.is/|g' {} +

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; "
# Fjarlægja Google Tag Manager kóða fyrir DEV
find _build/html/ -name '*.html' -exec sed -i '' -e '/<script>(function(w,d,s,l,i){w\[l\]=w\[l\]\|\|\[\];w\[l\]\.push(/,/GTM-PL8JH23F/ d' {} \;
find _build/html/ -name '*.html' -exec sed -i '' -e '/ <noscript><iframe src="https:\/\/www.googletagmanager.com\/ns.html?id=GTM-PL8JH23F"/,/<\/noscript>/d' {} \;

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; " (sem er skilgreint í "_templates/layout.html")
sed -i '' -e 's#<title>.* &ndash; Ritsafn RÚBIK Reykjavíkur</title>#<title>Ritsafn RÚBIK Reykjavíkur</title>#' _build/html/index.html

# Keyra Prettier á allar HTML skrár
Expand Down
6 changes: 1 addition & 5 deletions sh/build-main-dirhtml-latexpdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ cd rit
make clean
sphinx-build -b dirhtml . _build/html

# Fjarlægja "type" úr favicon.ico og apple-touch-icon.png (sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7)
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48"[^>]*>#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48">#' {} +
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png"[^>]*>#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png">#' {} +

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; "
# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; " (sem er skilgreint í "_templates/layout.html")
sed -i '' -e 's#<title>.* &ndash; Ritsafn RÚBIK Reykjavíkur</title>#<title>Ritsafn RÚBIK Reykjavíkur</title>#' _build/html/index.html

# Keyra Prettier á allar HTML skrár
Expand Down
6 changes: 1 addition & 5 deletions sh/build-main-html-latexpdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ cd rit
make clean
sphinx-build -b html . _build/html

# Fjarlægja "type" úr favicon.ico og apple-touch-icon.png (sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7)
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48"[^>]*>#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48">#' {} +
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png"[^>]*>#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png">#' {} +

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; "
# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; " (sem er skilgreint í "_templates/layout.html")
sed -i '' -e 's#<title>.* &ndash; Ritsafn RÚBIK Reykjavíkur</title>#<title>Ritsafn RÚBIK Reykjavíkur</title>#' _build/html/index.html

# Keyra Prettier á allar HTML skrár
Expand Down
6 changes: 1 addition & 5 deletions sh/build-main-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ cd rit
make clean
sphinx-build -b html . _build/html

# Fjarlægja "type" úr favicon.ico og apple-touch-icon.png (sbr. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7)
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48"[^>]*>#<link rel="icon" href="https://rit.rubik.is/_static/favicon/favicon.ico" sizes="48x48">#' {} +
find _build/html/ -name '*.html' -exec sed -i '' -e 's#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png"[^>]*>#<link rel="apple-touch-icon" href="https://rit.rubik.is/_static/favicon/apple-touch-icon.png">#' {} +

# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; "
# Breyta <title> á forsíðu, með því að fjarlægja "* &ndash; " (sem er skilgreint í "_templates/layout.html")
sed -i '' -e 's#<title>.* &ndash; Ritsafn RÚBIK Reykjavíkur</title>#<title>Ritsafn RÚBIK Reykjavíkur</title>#' _build/html/index.html

# Keyra Prettier á allar HTML skrár
Expand Down
8 changes: 0 additions & 8 deletions txt/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ sphinx-copybutton==0.5.2



# Sphinx Extension adding support for custom favicons
# PYPI: https://pypi.org/project/sphinx-favicon/
# Docs: https://sphinx-favicon.readthedocs.io/

sphinx-favicon==1.0.1



# Sphinx extension for BibTeX style citations
# PYPI: https://pypi.org/project/sphinxcontrib-bibtex/
# Docs: https://sphinxcontrib-bibtex.readthedocs.io/
Expand Down

0 comments on commit dc001b1

Please sign in to comment.