Просмотр исходного кода

feat(ui): emit lang attribute on rendered article surfaces

Renders lang="..." on the entry title (<h1> in detail view, <h2> in every
list view) and on the entry content <article>. The attribute prefers the
entry-level language and falls back to the feed-level language; if both
are empty, no lang= attribute is emitted (rather than lang="").
Bram Duvigneau 1 месяц назад
Родитель
Сommit
6dcb815c25

+ 1 - 1
internal/template/templates/views/category_entries.html

@@ -95,7 +95,7 @@
             tabindex="-1"
         >
             <header class="item-header" dir="auto">
-                <h2 id="entry-title-{{ .ID }}" class="item-title">
+                <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                     <a
                         {{ if $.showOnlyUnreadEntries }}
                         href="{{ routePath "/unread/category/%d/entry/%d" .Feed.Category.ID .ID }}"

+ 2 - 2
internal/template/templates/views/entry.html

@@ -44,7 +44,7 @@
 {{ define "page_header"}}
 <section class="entry" data-id="{{ .entry.ID }}" aria-labelledby="page-header-title">
     <header class="entry-header">
-        <h1 id="page-header-title" dir="auto">
+        <h1 id="page-header-title" dir="auto" {{ with or .entry.Language .entry.Feed.Language }}lang="{{ . }}"{{ end }}>
             <a href="{{ .entry.URL | untrustedURL }}" {{ if $.user.OpenExternalLinksInNewTab }}target="_blank"{{ else }}rel="noopener"{{ end }}>{{ .entry.Title }}</a>
         </h1>
         {{ if .user }}
@@ -236,7 +236,7 @@
 </div>
 {{ end }}
 {{ end }}
-<article class="entry-content {{ if ne $.user.GestureNav "none" }}gesture-nav-{{ $.user.GestureNav }}{{ end }}" dir="auto">
+<article class="entry-content {{ if ne $.user.GestureNav "none" }}gesture-nav-{{ $.user.GestureNav }}{{ end }}" dir="auto" {{ with or .entry.Language .entry.Feed.Language }}lang="{{ . }}"{{ end }}>
     {{ if not .entry.Feed.NoMediaPlayer }}
         {{ $mediaPlayerEnclosure := .entry.Enclosures.FindMediaPlayerEnclosure }}
 

+ 1 - 1
internal/template/templates/views/feed_entries.html

@@ -104,7 +104,7 @@
             tabindex="-1"
         >
             <header class="item-header" dir="auto">
-                <h2 id="entry-title-{{ .ID }}" class="item-title">
+                <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                     <a
                         {{ if $.showOnlyUnreadEntries }}
                         href="{{ routePath "/unread/feed/%d/entry/%d" .Feed.ID .ID }}"

+ 1 - 1
internal/template/templates/views/history_entries.html

@@ -45,7 +45,7 @@
             tabindex="-1"
         >
             <header class="item-header" dir="auto">
-                <h2 id="entry-title-{{ .ID }}" class="item-title">
+                <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                     <a href="{{ routePath "/history/entry/%d" .ID }}" {{ if and $.user.AlwaysOpenExternalLinks $.user.OpenExternalLinksInNewTab }}target="_blank"{{ end }}>
                         {{ if ne .Feed.Icon.IconID 0 }}
                         <img src="{{ routePath "/feed-icon/%s" .Feed.Icon.ExternalIconID }}" width="16" height="16" loading="lazy" alt="">

+ 1 - 1
internal/template/templates/views/search.html

@@ -32,7 +32,7 @@
                 aria-labelledby="entry-title-{{ .ID }}"
             >
                 <header class="item-header" dir="auto">
-                    <h2 id="entry-title-{{ .ID }}" class="item-title">
+                    <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                         <a href="{{ routePath "/search/entry/%d" .ID }}{{ queryString (dict "q" $.searchQuery "unread" $.searchUnreadOnly) }}" {{ if and $.user.AlwaysOpenExternalLinks $.user.OpenExternalLinksInNewTab }}target="_blank"{{ end }}>
                             {{ if ne .Feed.Icon.IconID 0 }}
                             <img src="{{ routePath "/feed-icon/%s" .Feed.Icon.ExternalIconID }}" width="16" height="16" loading="lazy" alt="{{ .Feed.Title }}">

+ 1 - 1
internal/template/templates/views/shared_entries.html

@@ -45,7 +45,7 @@
             tabindex="-1"
         >
             <header class="item-header" dir="auto">
-                <h2 id="entry-title-{{ .ID }}" class="item-title">
+                <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                     <a href="{{ routePath "/history/entry/%d" .ID }}" {{ if and $.user.AlwaysOpenExternalLinks $.user.OpenExternalLinksInNewTab }}target="_blank"{{ end }}>
                         {{ if ne .Feed.Icon.IconID 0 }}
                         <img src="{{ routePath "/feed-icon/%s" .Feed.Icon.ExternalIconID }}" width="16" height="16" loading="lazy" alt="">

+ 1 - 1
internal/template/templates/views/starred_entries.html

@@ -26,7 +26,7 @@
             tabindex="-1"
         >
             <header class="item-header" dir="auto">
-                <h2 id="entry-title-{{ .ID }}" class="item-title">
+                <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                     <a href="{{ routePath "/starred/entry/%d" .ID }}" {{ if and $.user.AlwaysOpenExternalLinks $.user.OpenExternalLinksInNewTab }}target="_blank"{{ end }}>
                         {{ if ne .Feed.Icon.IconID 0 }}
                         <img src="{{ routePath "/feed-icon/%s" .Feed.Icon.ExternalIconID }}" width="16" height="16" loading="lazy" alt="">

+ 1 - 1
internal/template/templates/views/tag_entries.html

@@ -26,7 +26,7 @@
             tabindex="-1"
         >
             <header class="item-header" dir="auto">
-                <h2 id="entry-title-{{ .ID }}" class="item-title">
+                <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                     <a href="{{ routePath "/tags/%s/entry/%d" (urlEncode $.tagName) .ID }}" {{ if and $.user.AlwaysOpenExternalLinks $.user.OpenExternalLinksInNewTab }}target="_blank"{{ end }}>
                         {{ if ne .Feed.Icon.IconID 0 }}
                         <img src="{{ routePath "/feed-icon/%s" .Feed.Icon.ExternalIconID }}" width="16" height="16" loading="lazy" alt="">

+ 1 - 1
internal/template/templates/views/unread_entries.html

@@ -53,7 +53,7 @@
             tabindex="-1"
         >
             <header class="item-header" dir="auto">
-                <h2 id="entry-title-{{ .ID }}" class="item-title">
+                <h2 id="entry-title-{{ .ID }}" class="item-title" {{ with or .Language .Feed.Language }}lang="{{ . }}"{{ end }}>
                     <a href="{{ routePath "/unread/entry/%d" .ID }}" {{ if and $.user.AlwaysOpenExternalLinks $.user.OpenExternalLinksInNewTab }}target="_blank"{{ end }}>
                         {{ if ne .Feed.Icon.IconID 0 -}}
                         <img src="{{ routePath "/feed-icon/%s" .Feed.Icon.ExternalIconID }}" width="16" height="16" loading="lazy" alt="">