Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 2021 22:21:39 GMT
From:      "Danilo G. Baio" <dbaio@FreeBSD.org>
To:        doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org
Subject:   git: e06f3556be - main - website/press: Adjust all links
Message-ID:  <202107152221.16FMLdxK032808@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dbaio:

URL: https://cgit.FreeBSD.org/doc/commit/?id=e06f3556beb198cbaf10136ad54af94e19cebf10

commit e06f3556beb198cbaf10136ad54af94e19cebf10
Author:     Danilo G. Baio <dbaio@FreeBSD.org>
AuthorDate: 2021-07-15 11:48:00 +0000
Commit:     Danilo G. Baio <dbaio@FreeBSD.org>
CommitDate: 2021-07-15 22:09:25 +0000

    website/press: Adjust all links
    
    - Fix RSS/Feed links
    
      They were without the anchor part, causing 404 requests:
        https://www.freebsd.org/press/2021-03:0
      The correct is:
        https://www.freebsd.org/press/#2021-03:0
    
    - Make links unique
    
      When investigating the above issue, we could note that the links were
      not unique. Every time a new press item is added, the entire chain of
      links is changed.
    
      We add the old behavior with this change, which counts press items for
      each month and generates the unique link based on the month and in the
      month counter.
    
      This change also needs to be added to the News and Events items.
    
    Reviewed by:    carlavilla
    Differential Revision: https://reviews.freebsd.org/D31190
---
 website/themes/beastie/layouts/partials/press.html | 13 +++++++++--
 website/themes/beastie/layouts/press/list.html     | 13 ++++++++---
 website/themes/beastie/layouts/press/press.rss.xml | 27 ++++++++++++++--------
 website/themes/beastie/layouts/press/single.html   | 13 ++++++++---
 4 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/website/themes/beastie/layouts/partials/press.html b/website/themes/beastie/layouts/partials/press.html
index ca0e3c1d16..6bca5eece6 100644
--- a/website/themes/beastie/layouts/partials/press.html
+++ b/website/themes/beastie/layouts/partials/press.html
@@ -16,14 +16,23 @@
 
 {{ with $pressData.press }}
   {{ $pressCounter := 0 }}
+  {{ $pressMonthCounter := 1 }}
+  {{ $pressMonthPrev := false }}
   {{ range (sort .press "date" "desc") }}
     {{ if lt $pressCounter 5 }}
+      {{ $pressMonthCur := dateFormat "2006-01" .date }}
+      {{ if eq $pressMonthCur $pressMonthPrev }}
+        {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+      {{ else }}
+        {{ $pressMonthCounter = 1 }}
+      {{ end }}
     <p>
       <span class="txtdate">{{ dateFormat "2006-01" .date }}</span>
       <br />
-      <a href="{{ if $translatedPressEnabled }}{{ .Site.BaseURL | relLangURL }}{{ else }}{{ $.Site.BaseURL }}{{ end }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}">{{ .name }}</a>
+      <a href="{{ if $translatedPressEnabled }}{{ .Site.BaseURL | relLangURL }}{{ else }}{{ $.Site.BaseURL }}{{ end }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}">{{ .name }}</a>
     </p>
+      {{ $pressCounter = add $pressCounter 1 }}
+      {{ $pressMonthPrev = $pressMonthCur }}
     {{ end }}
-    {{ $pressCounter = add $pressCounter 1 }}
   {{ end }}
 {{ end }}
diff --git a/website/themes/beastie/layouts/press/list.html b/website/themes/beastie/layouts/press/list.html
index f34ae7e986..332c4de940 100644
--- a/website/themes/beastie/layouts/press/list.html
+++ b/website/themes/beastie/layouts/press/list.html
@@ -39,7 +39,8 @@
         <!-- Remove duplicates -->
         {{ $yearsMonths = $yearsMonths | uniq }}
 
-        {{ $pressCounter := 0 }}
+        {{ $pressMonthCounter := 1 }}
+        {{ $pressMonthPrev := false }}
         {{ range $year := seq now.Year 2010 }}
           {{ range $month := seq 12 1 }}
             {{ $yearMonth := (printf "%d-%d" $year $month) }}
@@ -50,9 +51,15 @@
                 {{ with $pressData.press }}
                   {{ range (sort .press "date" "desc") }}
                     {{ if eq (dateFormat "2006-1" .date) $yearMonth }}
+                      {{ $pressMonthCur := dateFormat "2006-01" .date }}
+                      {{ if eq $pressMonthCur $pressMonthPrev }}
+                        {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+                      {{ else }}
+                        {{ $pressMonthCounter = 1 }}
+                      {{ end }}
                       <li>
                         <p>
-                          <a id="{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}"></a>
+                          <a id="{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}"></a>
                           <a href="{{ .url }}">
                             <strong>{{ .name }}</strong>
                           </a>
@@ -62,7 +69,7 @@
                           {{ .description | safeHTML}}
                         </p>
                       </li>
-                      {{ $pressCounter = add $pressCounter 1 }}
+                      {{ $pressMonthPrev = $pressMonthCur }}
                     {{ end }}
                   {{ end }}
                 {{ end }}
diff --git a/website/themes/beastie/layouts/press/press.rss.xml b/website/themes/beastie/layouts/press/press.rss.xml
index 98f0348c85..660c49652d 100644
--- a/website/themes/beastie/layouts/press/press.rss.xml
+++ b/website/themes/beastie/layouts/press/press.rss.xml
@@ -12,28 +12,37 @@
       <link>https://www.FreeBSD.org/press/</link>;
     </image>
     <atom:link href="https://www.FreeBSD.org/press/feed.xml" rel="self" type="application/rss+xml"/>
+    {{ $pressMonthPrev := false }}
     {{ $data := index .Site.Data "en" }}
     {{ $pressData := $data.press }}
     {{ with $pressData.press }}
       {{ $pressCounter := 0 }}
-        {{ range (sort .press "date" "desc") }}
-          {{ if lt $pressCounter 10 }}
+      {{ $pressMonthCounter := 1 }}
+      {{ range (sort .press "date" "desc") }}
+        {{ if lt $pressCounter 10 }}
+          {{ $pressMonthCur := dateFormat "2006-01" .date }}
+          {{ if eq $pressMonthCur $pressMonthPrev }}
+            {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+          {{ else }}
+            {{ $pressMonthCounter = 1 }}
+          {{ end }}
             <item>
-              {{ if .name }}
+            {{ if .name }}
                 <title>
                   {{ .name }}
                 </title>
-              {{ end }}
-              {{ if .description }}
+            {{ end }}
+            {{ if .description }}
                 <description>
                   {{ .description }}
                 </description>
-              {{ end }}
-              <link>{{ absLangURL ($.Site.BaseURL) }}press/{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}</link>
-              <guid>{{ absLangURL ($.Site.BaseURL) }}press/{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}</guid>
+            {{ end }}
+              <link>{{ absLangURL ($.Site.BaseURL) }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}</link>
+              <guid>{{ absLangURL ($.Site.BaseURL) }}press/#{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}</guid>
               <pubDate>{{ dateFormat "2006-01-02" .date }}</pubDate>
             </item>
-          {{ end }}
+          {{ $pressMonthPrev = $pressMonthCur }}
+        {{ end }}
         {{ $pressCounter = add $pressCounter 1 }}
       {{ end }}
     {{ end }}
diff --git a/website/themes/beastie/layouts/press/single.html b/website/themes/beastie/layouts/press/single.html
index f34ae7e986..332c4de940 100644
--- a/website/themes/beastie/layouts/press/single.html
+++ b/website/themes/beastie/layouts/press/single.html
@@ -39,7 +39,8 @@
         <!-- Remove duplicates -->
         {{ $yearsMonths = $yearsMonths | uniq }}
 
-        {{ $pressCounter := 0 }}
+        {{ $pressMonthCounter := 1 }}
+        {{ $pressMonthPrev := false }}
         {{ range $year := seq now.Year 2010 }}
           {{ range $month := seq 12 1 }}
             {{ $yearMonth := (printf "%d-%d" $year $month) }}
@@ -50,9 +51,15 @@
                 {{ with $pressData.press }}
                   {{ range (sort .press "date" "desc") }}
                     {{ if eq (dateFormat "2006-1" .date) $yearMonth }}
+                      {{ $pressMonthCur := dateFormat "2006-01" .date }}
+                      {{ if eq $pressMonthCur $pressMonthPrev }}
+                        {{ $pressMonthCounter = add $pressMonthCounter 1 }}
+                      {{ else }}
+                        {{ $pressMonthCounter = 1 }}
+                      {{ end }}
                       <li>
                         <p>
-                          <a id="{{ dateFormat "2006-01" .date }}:{{ $pressCounter }}"></a>
+                          <a id="{{ dateFormat "2006-01" .date }}:{{ $pressMonthCounter }}"></a>
                           <a href="{{ .url }}">
                             <strong>{{ .name }}</strong>
                           </a>
@@ -62,7 +69,7 @@
                           {{ .description | safeHTML}}
                         </p>
                       </li>
-                      {{ $pressCounter = add $pressCounter 1 }}
+                      {{ $pressMonthPrev = $pressMonthCur }}
                     {{ end }}
                   {{ end }}
                 {{ end }}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107152221.16FMLdxK032808>