rssgenerator

package
v0.0.0-...-17a79ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2026 License: AGPL-3.0 Imports: 14 Imported by: 1

Documentation

Overview

Package rssgenerator contains functions for generating RSS feeds.

Index

Constants

This section is empty.

Variables

View Source
var Registry = echo.NewKVxData[RSS, any]().
	Add(`article`, echo.T(`文章`), echo.KVxOptX[RSS, any](RSS{Do: articleRSS}))

Functions

func CDATA

func CDATA(s string) string

CDATA wraps a string with CDATA tags, which are used to escape special characters in XML. See https://www.w3.org/TR/REC-xml/#sec-cdata for more information.

func Handle

func Handle(ctx echo.Context) error

Handle RSS handler

This function is used to generate RSS feeds. You can use it in your route by calling it with the context and the group name of the RSS feed.

For example:

echo.Get("/rss/:group", rssgenerator.Handle)

This will generate RSS feeds for the given group name.

If no group name is provided, it will use the default group name "article".

func HandleWith

func HandleWith(ctx echo.Context, f func(echo.Context, *feeds.RssFeed) error) error

HandleWith is a helper function that takes a context and a function to generate an RSS feed. It creates a new RSS feed with the site name, slogan, and link, and then calls the given function with the context and the feed. If the given function returns an error, it will be returned. Otherwise, it will write the RSS feed to the response and set the content type to "application/rss+xml; charset=utf-8". It is useful for generating RSS feeds for different groups of items.

func MarkdownToHTML

func MarkdownToHTML(md string) string

MarkdownToHTML 将 Markdown 字符串转换为 HTML 字符串。 该函数将 Markdown 字符串解析成 HTML 字符串,并将结果返回。 该函数使用了以下 Markdown 语法扩展项:

  • NoIntraEmphasis:忽略单词内部的强调标记
  • Tables:解析表格语法
  • FencedCode:解析围栏代码块
  • Strikethrough:支持删除线语法
  • HardLineBreak:将换行符(\n)转换为 <br> 标签
  • Footnotes:支持脚注语法
  • MathJax:支持 MathJax 数学公式语法
  • SuperSubscript:支持上标和下标语法
  • EmptyLinesBreakList:允许两个空行中断列表

func NewFeed

func NewFeed(title, slogan, host, authorName, authorEmail string) *feeds.Feed

NewFeed creates a new feeds.Feed instance.

title is the title of the rss feed.

slogan is the slogan of the rss feed.

host is the hostname of the rss feed.

authorName and authorEmail are the name and email of the author of the rss feed.

The function returns a new feeds.Feed instance with the Title, Description, Created, Items, and Author fields set.

func NewRssFeed

func NewRssFeed(title, slogan, host, authorName string) *feeds.RssFeed

NewRssFeed creates a new feeds.RssFeed instance.

title is the title of the rss feed.

slogan is the slogan of the rss feed.

host is the hostname of the rss feed.

authorName is the name of the author, it is optional.

The function returns a pointer to the new feeds.RssFeed instance.

func Register

func Register(k, v string, x RSS)

Register registers a rss generator with the given key and value. The value is a RSS struct which contains a Do function that is used to generate the RSS feed. The key is used to identify the RSS generator and the value is used to generate the RSS feed.

func RegisterRoute

func RegisterRoute(r echo.RouteRegister)

RegisterRoute registers RSS endpoints to the given router. It registers endpoints for fetching RSS feeds of all articles and for fetching RSS feeds of articles in a group. The endpoints are `/rss` and `/rss/:group` respectively.

func T2s

func T2s(t time.Time) string

T2s converts a time.Time into a string in RFC1123Z format (e.g. "2006-01-02T15:04:05Z07:00").

Types

type RSS

type RSS struct {
	Do func(ctx echo.Context, feed *feeds.RssFeed) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL