summaryrefslogtreecommitdiff
path: root/templates/du2html.xsl
diff options
context:
space:
mode:
Diffstat (limited to 'templates/du2html.xsl')
-rw-r--r--templates/du2html.xsl92
1 files changed, 55 insertions, 37 deletions
diff --git a/templates/du2html.xsl b/templates/du2html.xsl
index 3d703c8..86e0088 100644
--- a/templates/du2html.xsl
+++ b/templates/du2html.xsl
@@ -1,7 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE x:stylesheet [
-<!ENTITY nav-fields "field[field_name='prev' or field_name='next' or field_name='contents' or field_name='index' or field_name='glossary' or field_name='copyright' or field_name='start' or field_name='chapter' or field_name='section' or field_name='subsection' or field_name='appendix' or field_name='help']/field_body" >
-]>
<x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:e="http://exslt.org/common"
@@ -17,6 +14,14 @@
<x:param name="path"/>
<x:param name="filename"/>
+ <x:variable name="locale">
+ <x:choose>
+ <x:when test="$language = 'it'">it_IT</x:when>
+ <x:when test="$language = 'en'">en_GB</x:when>
+ <x:otherwise><!-- uh? --><x:value-of select="$language"/></x:otherwise>
+ </x:choose>
+ </x:variable>
+
<x:variable name="langs-rtf">
<x:choose>
<x:when test="$language = 'it'">
@@ -160,15 +165,37 @@
<link rel="alternate" type="application/atom+xml" href="{$url}feed.{$language}.xml"/>
</x:template>
- <x:template match="image[contains(concat(' ',normalize-space(string(@classes)),' '),' twitter ')]" mode="twitter-card">
+ <x:template match="image[contains(concat(' ',normalize-space(string(@classes)),' '),' preview ')]" mode="og-meta">
<x:variable name="uri-with-slash" select="wc:dst-uri-for(@uri,/document/@source)" />
<!-- dst-uri-for appends a / at the end :( -->
- <meta name="twitter:image" content="https://www.thenautilus.net{substring($uri-with-slash,1,string-length($uri-with-slash) - 1)}" />
+ <x:variable name="uri" select="substring($uri-with-slash,1,string-length($uri-with-slash) - 1)" />
+ <meta name="twitter:image" content="https://www.thenautilus.net{$uri}" />
<x:if test="@alt">
<meta name="twitter:image:alt" content="{@alt}" />
</x:if>
+ <meta property="og:image" content="https://www.thenautilus.net{$uri}" />
+ <x:if test="@alt">
+ <meta property="og:image:alt" content="{@alt}" />
+ </x:if>
+ </x:template>
+ <x:template match="image" mode="og-meta" priority="-1" />
+
+ <x:template match="/document" mode="og-description">
+ <x:choose>
+ <x:when test="subtitle">
+ <x:value-of select="normalize-space(subtitle)" />
+ </x:when>
+ <x:otherwise>
+ <x:variable name="content">
+ <x:apply-templates select="paragraph[1]"/>
+ </x:variable>
+ <x:value-of select="substring(normalize-space($content),0,200)"/>
+ <x:if test="string-length(normalize-space($content)) &gt; 200">
+ <x:text>…</x:text>
+ </x:if>
+ </x:otherwise>
+ </x:choose>
</x:template>
- <x:template match="image" mode="twitter-card" priority="-1" />
<x:template match="video">
<video controls="true" playsinline="true">
@@ -193,7 +220,7 @@
<x:template match="/document">
<html xml:lang="{$language}" lang="{$language}">
- <head>
+ <head prefix="og: https://ogp.me/ns#">
<title><x:value-of select="normalize-space(title)"/></title>
<x:apply-templates select="." mode="stylesheet" />
<link rel="icon" type="image/png" href="/favicon.png" />
@@ -205,25 +232,20 @@
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@dakkar" />
<meta name="twitter:title" content="{normalize-space(title)}" />
- <x:apply-templates select="//image" mode="twitter-card" />
+ <meta property="og:site_name" content="the Nautilus" />
+ <meta property="og:title" content="{normalize-space(title)}" />
+ <x:apply-templates select="//image" mode="og-meta" />
<meta name="twitter:description">
<x:attribute name="content">
- <x:choose>
- <x:when test="subtitle">
- <x:value-of select="normalize-space(subtitle)" />
- </x:when>
- <x:otherwise>
- <x:variable name="content">
- <x:apply-templates/>
- </x:variable>
- <x:value-of select="substring(normalize-space($content),0,200)"/>
- <x:if test="string-length(normalize-space($content)) &gt; 200">
- <x:text>…</x:text>
- </x:if>
- </x:otherwise>
- </x:choose>
+ <x:apply-templates select="." mode="og-description" />
</x:attribute>
</meta>
+ <meta property="og:description">
+ <x:attribute name="content">
+ <x:apply-templates select="." mode="og-description" />
+ </x:attribute>
+ </meta>
+ <meta property="og:locale" content="{$locale}" />
</head>
<body>
<div id="wrapper">
@@ -308,7 +330,6 @@
<x:template match="/document" mode="sidebar">
<x:apply-templates select="." mode="navblock"/>
<x:apply-templates select="." mode="navtags"/>
- <x:apply-templates select="." mode="twitter"/>
<x:apply-templates select="." mode="amazon"/>
</x:template>
@@ -322,6 +343,7 @@
<ul>
<li><x:call-template name="taglink"><x:with-param name="tag">hardware</x:with-param></x:call-template></li>
<li><x:call-template name="taglink"><x:with-param name="tag">software</x:with-param></x:call-template></li>
+ <li><x:call-template name="taglink"><x:with-param name="tag">review</x:with-param></x:call-template></li>
<x:if test="$language = 'it'"> <!-- non ci sono racconti in inglese, per ora -->
<li><x:call-template name="taglink"><x:with-param name="tag">racconti</x:with-param></x:call-template></li>
</x:if>
@@ -330,21 +352,17 @@
</ul>
<a href="{wc:dst-uri-for('/tags/')}"><x:value-of select="$const-tr[@t='alltags' and @l=$language]"/></a>
<hr />
- <a href="{wc:dst-uri-for('/contacts/')}"><x:apply-templates select="wc:title-for($language,$filename,'/contacts/')/node()" /></a>
+ <p>
+ <a href="{wc:dst-uri-for('/contacts/')}"><x:apply-templates select="wc:title-for($language,$filename,'/contacts/')/node()" /></a>
+ </p>
+ <p>
+ <a href="https://s.thenautilus.net/@dakkar" rel="me" class="icon-link"><img src="/fedi.svg" /></a>
+ <a href="https://twitter.com/dakkar" rel="me" class="icon-link"><img src="/twitter.svg" /></a>
+ <a href="https://instagram.com/dakkarinsta" rel="me" class="icon-link"><img src="/instagram.svg" /></a>
+ </p>
</div>
</x:template>
- <x:template match="/document" mode="twitter">
- <a class="twitter-timeline"
- data-dnt="true"
- href="https://twitter.com/dakkar"
- data-widget-id="545965003442900992"
- data-chrome="nofooter transparent"
- data-theme="dark"
- >Tweets by @dakkar</a>
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
- </x:template>
-
<x:template match="/document" mode="amazon">
<div id="amazon-wishlist">
<a href="//www.amazon.co.uk/registry/wishlist/INP247PNKQSZ">
@@ -507,7 +525,7 @@
</x:if>
</x:template>
- <x:template match="&nav-fields;" mode="nav-block">
+ <x:template match="field[field_name='prev' or field_name='next' or field_name='contents' or field_name='index' or field_name='glossary' or field_name='copyright' or field_name='start' or field_name='chapter' or field_name='section' or field_name='subsection' or field_name='appendix' or field_name='help']/field_body" mode="nav-block">
<x:variable name="rel"><x:value-of select="normalize-space(parent::field/field_name)" /></x:variable>
<x:variable name="label">
<x:copy-of select="$link-names[@rel=$rel and @lang=$language]/node()" />
@@ -524,7 +542,7 @@
<x:template match="field/field_name|field/field_body" mode="nav-block" priority="-1" />
- <x:template match="&nav-fields;" mode="nav-links">
+ <x:template match="field[field_name='prev' or field_name='next' or field_name='contents' or field_name='index' or field_name='glossary' or field_name='copyright' or field_name='start' or field_name='chapter' or field_name='section' or field_name='subsection' or field_name='appendix' or field_name='help']/field_body" mode="nav-links">
<link rel="{normalize-space(parent::field/field_name)}"
href="{normalize-space(.)}"
title="{normalize-space(wc:title-for($langs,ancestor::document/@source,normalize-space(.)))}"