emacs-packages: rss, publication date & github link

This commit is contained in:
Pavel Korytov 2023-12-26 02:02:16 +03:00
parent 763feaf213
commit f8ad17a4cd
7 changed files with 94 additions and 3 deletions

View file

@ -2,6 +2,7 @@
title = "My Emacs packages" title = "My Emacs packages"
author = ["Pavel Korytov"] author = ["Pavel Korytov"]
draft = false draft = false
norss = true
+++ +++
- [Lyrics Fetcher](/packages/lyrics-fetcher) - [Lyrics Fetcher](/packages/lyrics-fetcher)

View file

@ -6,6 +6,8 @@
{{- else -}} {{- else -}}
{{- $pages = $pctx.Pages -}} {{- $pages = $pctx.Pages -}}
{{- end -}} {{- end -}}
{{- $pages = where $pages "Section" "!=" "configs" -}}
{{- $pages = where $pages ".Params.norss" "!=" "true" -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}} {{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}} {{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}} {{- $pages = $pages | first $limit -}}
@ -25,7 +27,7 @@
{{- with .OutputFormats.Get "RSS" -}} {{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}} {{- end -}}
{{ range where $pages "Section" "!=" "configs" }} {{ range $pages }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>

View file

@ -0,0 +1,41 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}}
{{ range where $pages "Section" "!=" "configs" }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<content type="html">
{{ .Content | html }}
</content>
</item>
{{ end }}
</channel>
</rss>

View file

@ -0,0 +1,28 @@
{{ define "main" }}
<script defer language="javascript" type="text/javascript" src="{{ "/js/dynamic-toc.js" | urlize | relURL }}"></script>
<div class="root">
<h1 id="title-small-screen">
{{ .Title }}
{{ if .Params.repo }}
<iframe src="https://ghbtns.com/github-btn.html?user=SqrtMinusOne&repo={{ .Params.repo }}&type=star&count=true" frameborder="0" scrolling="0" width="150" height="20" title="GitHub"></iframe>
{{ end }}
</h1>
<div class="container" id="actual-content">
<h1 id="title-large-screen" class="dotfiles-title">
{{ .Title }}
{{ if .Params.repo }}
<iframe src="https://ghbtns.com/github-btn.html?user=SqrtMinusOne&repo={{ .Params.repo }}&type=star&count=true" frameborder="0" scrolling="0" width="150" height="20" title="GitHub"></iframe>
{{ end }}
</h1>
{{ .Content }}
</div>
<div class="table-of-contents">
<div class="table-of-contents-text">
<b><a href="#">Table of Contents</a></b>
{{ .TableOfContents }}
</div>
<a id="unhide-all-button" class="hidden">&lt;Expand&gt;</a>
<a id="hide-all-button" class="hidden">&lt;Collapse&gt;</a>
</div>
</div>
{{ end }}

View file

@ -1,5 +1,6 @@
#+HUGO_BASE_DIR: ../.. #+HUGO_BASE_DIR: ../..
#+HUGO_SECTION: #+HUGO_SECTION:
#+TITLE: My Emacs packages #+TITLE: My Emacs packages
#+HUGO_CUSTOM_FRONT_MATTER: :norss true
- [[/packages/lyrics-fetcher][Lyrics Fetcher]] - [[/packages/lyrics-fetcher][Lyrics Fetcher]]

@ -1 +1 @@
Subproject commit 4cf7f342127b8acae8cbd4d8387a3b40f065300c Subproject commit 3707e8c53feb066c6985c20eef51d240d7073c02

View file

@ -119,8 +119,26 @@
(expand-file-name (expand-file-name
(format "%s/repos/%s/img" root package)) (format "%s/repos/%s/img" root package))
(format "./static/%s-img" package) t t)) (format "./static/%s-img" package) t t))
(with-temp-buffer (with-current-buffer (generate-new-buffer "tmp")
(insert-file-contents (format "./%s.org" package)) (insert-file-contents (format "./%s.org" package))
(goto-char (point-min))
(insert
"#+HUGO_CUSTOM_FRONT_MATTER: :repo "
(let ((default-directory (format "%s/repos/%s/" root package)))
(string-trim
(shell-command-to-string
"git remote get-url origin | sed 's/.*SqrtMinusOne\\/\\(.*\\)\\.git/\\1/'")))
"\n")
(when-let
(published-at
(with-temp-buffer
(insert-file-contents (format "%s/repos/%s/%s.el" root package package))
(goto-char (point-min))
(when (re-search-forward (rx bol ";; Published-At:" (0+ space) (group (1+ nonl))) nil t)
(substring-no-properties
(match-string 1)))))
(insert
"#+DATE: " published-at "\n"))
(replace-string (replace-string
"./img/" (format "./static/%s-img/" package) nil (point-min) (point-max)) "./img/" (format "./static/%s-img/" package) nil (point-min) (point-max))
(setq-local buffer-file-name (format "./%s.org" package)) (setq-local buffer-file-name (format "./%s.org" package))