application

package
v0.0.0-...-c5b2db7 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FrontMatter

func FrontMatter(markdown []byte) (models.FrontMatter, string, error)

FrontMatter parses the front matter and body content from a given markdown byte slice. The front matter is expected to be enclosed in "---" delimiters at the beginning of the markdown. This function returns a FrontMatter struct containing the parsed front matter, a string containing the body content of the markdown (excluding the front matter), and an error if the front matter cannot be parsed into the struct. If no front matter is present, the function returns the entire markdown content as the body with an empty FrontMatter struct and no error.

Parameters: - markdown: A byte slice containing the markdown content to be parsed.

Returns: - A models.FrontMatter struct containing the parsed front matter. - A string containing the body content of the markdown. - An error if the parsing fails, nil otherwise.

func MarkdownToHTML

func MarkdownToHTML(bytes []byte) (string, error)

MarkdownToHTML converts a markdown byte slice into sanitized HTML. It uses the Blackfriday Markdown processor and the Bluemonday sanitizer to safely convert markdown content to HTML. The function preserves classes on fenced code blocks for syntax highlighting and applies additional security and formatting policies using Bluemonday. It returns the HTML as a string and an error if the conversion process fails.

Parameters: - bytes: A byte slice containing the markdown content to be converted.

Returns: - A string containing the sanitized HTML representation of the markdown. - An error if the conversion fails, nil otherwise.

Notes:

  • The function configures Bluemonday to allow class attributes matching "language-[a-zA-Z0-9]+" on "code" elements, requires parseable URLs, and adds target="_blank" to fully qualified links.
  • For more information on Bluemonday's policy configuration, visit: https://pkg.go.dev/github.com/microcosm-cc/bluemonday

Types

type Application

type Application struct {
	S3Client        *s3.Client
	DynamoClient    *dynamodb.Client
	SQSClient       *sqs.Client
	Blog            models.Posts
	S3BucketName    string
	DynamoTableName string
	SQSQueueURL     string
}

Application is a struct that holds AWS clients and application data

func NewApplication

func NewApplication(posts models.Posts, s3Client *s3.Client, dynamoClient *dynamodb.Client, sqsClient *sqs.Client, s3BucketName, dynamoTableName, sqsQueueURL string) *Application

NewApplication returns an instantiated instance of Application

func (*Application) About

func (a *Application) About(c echo.Context) error

About is the handler for the /about route

func (*Application) Contact

func (a *Application) Contact(c echo.Context) error

Contact is the handler for the /contact route

func (*Application) CustomErrorHandler

func (a *Application) CustomErrorHandler(err error, c echo.Context)

CustomErrorHandler is the handler for custom errors

func (*Application) GetTime

func (a *Application) GetTime(c echo.Context) error

func (*Application) Health

func (a *Application) Health(c echo.Context) error

func (*Application) Home

func (a *Application) Home(c echo.Context) error

Home is the handler for the / route

func (*Application) Plan

func (a *Application) Plan(c echo.Context) error

Plan is the handler for the /plan route

func (*Application) PollSQS

func (a *Application) PollSQS(ctx context.Context)

PollSQS continuously polls the SQS queue for messages

func (*Application) Post

func (a *Application) Post(c echo.Context) error

Post is the handler for an individual post

func (*Application) Posts

func (a *Application) Posts(c echo.Context) error

Posts is the handler for the /posts route

func (*Application) ProcessS3Upload

func (a *Application) ProcessS3Upload(ctx context.Context, key string) error

ProcessS3Upload handles a new file upload to S3

func (*Application) PwBot

func (a *Application) PwBot(c echo.Context) error

PwBot is the handler for the /pwbot route

func (*Application) ReloadPosts

func (a *Application) ReloadPosts(ctx context.Context) error

ReloadPosts will initiate a read from the DynamoDB table and reload all posts in memory.

func (*Application) SearchPosts

func (a *Application) SearchPosts(c echo.Context) error

SearchPosts is the handler for the post searching feature

func (*Application) SiteMap

func (a *Application) SiteMap(c echo.Context) error

SiteMap is the handler for the site map

func (*Application) TimeBot

func (a *Application) TimeBot(c echo.Context) error

TimeBot is the handler for the /timebot route

func (*Application) TimeUpdate

func (a *Application) TimeUpdate(c echo.Context) error

func (*Application) Utils

func (a *Application) Utils(c echo.Context) error

About is the handler for the /about route

Jump to

Keyboard shortcuts

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