notezero

package module
v0.0.0-...-ee747d0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 25 Imported by: 0

README

NoteZero

View your nostr articles at Ixian

  • Articles with no headers will not be shows.
  • Articles with no identifier will not be shows.

TODO

  • Implement CLI to publish articles.
  • Filter articles that have incorrect format and list them to user.

Documentation

Overview

templ: version: v0.2.590

templ: version: v0.2.590

templ: version: v0.2.590

templ: version: v0.2.590

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArticleTemplate

func ArticleTemplate(params ArticleParams) templ.Component

func ContentTemplate

func ContentTemplate(params ArticleParams) templ.Component

func IndexTemplate

func IndexTemplate() templ.Component

func ListArticleTemplate

func ListArticleTemplate(params ListArticleParams) templ.Component

func NewEventService

func NewEventService(db eventstore.Store, cache *badger.Cache, relays []string) eventService

func NewLogging

func NewLogging(log *slog.Logger, next EventService) logging

func ReplaceReferences

func ReplaceReferences(text string) (string, error)

text := "Click [me](nostr:nevent17915d512457e4bc461b54ba95351719c150946ed4aa00b1d83a263deca69dae) to" replacement := `<a href="#" hx-get="article/$2" hx-push-url="true" hx-target="body" hx-swap="outerHTML">$1</a>`

Types

type ArticleParams

type ArticleParams struct {
	Event    EnhancedEvent
	Metadata ProfileMetadata
	Details  DetailsParams
	Content  template.HTML // Highlights are encoded into the content
}

type BaseEventPageParams

type BaseEventPageParams struct {
}

type Data

type Data struct {
	TemplateId TemplateID
	Event      EnhancedEvent
	Metadata   ProfileMetadata // Obviously always needs the author profile data
	Notes      []EnhancedEvent // For example, if the parent is an article, the children will be highlights
	Npub       string
	Naddr      string
	NaddrNaked string
	CreatedAt  string
	ModifiedAt string
	Kind       string
	Content    string
}

Has a parent event and a set of children: 1. Parent is 30023 - Children is 9802 2. Parent is 0 - Children is 30023

type DetailsParams

type DetailsParams struct {
	HideDetails     bool
	CreatedAt       string
	EventJSON       template.HTML
	Metadata        ProfileMetadata
	Nevent          string
	Nprofile        string
	SeenOn          []string
	Kind            int
	KindNIP         string
	KindDescription string
	Extra           templ.Component
}

type EnhancedEvent

type EnhancedEvent struct {
	*nostr.Event
	Relays []string
}

func (EnhancedEvent) CreatedAtStr

func (s EnhancedEvent) CreatedAtStr() string

func (EnhancedEvent) HashTags

func (s EnhancedEvent) HashTags() []string

func (EnhancedEvent) ModifiedAtStr

func (s EnhancedEvent) ModifiedAtStr() string

func (EnhancedEvent) Naddr

func (s EnhancedEvent) Naddr() string

func (EnhancedEvent) Nevent

func (s EnhancedEvent) Nevent() string

func (EnhancedEvent) Npub

func (s EnhancedEvent) Npub() string

func (EnhancedEvent) NpubShort

func (s EnhancedEvent) NpubShort() string

func (EnhancedEvent) Title

func (s EnhancedEvent) Title() string

type EventService

type EventService interface {
	RequestEvent(ctx context.Context, code string) (*nostr.Event, error)
	AuthorArticles(ctx context.Context, npub string) ([]*nostr.Event, error)
	ArticleHighlights(ctx context.Context, kind int, pubkey, identifier string) ([]*nostr.Event, error)
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(log *slog.Logger, es EventService) *Handler

func (*Handler) ArticleHandler

func (s *Handler) ArticleHandler(w http.ResponseWriter, r *http.Request)

Poplated the data.Notes field with a list of requested notes based on the search field.

func (*Handler) CodeHandler

func (s *Handler) CodeHandler(w http.ResponseWriter, r *http.Request)

Poplated the data.Notes field with a list of requested notes based on the search field.

func (*Handler) ContentHandler

func (s *Handler) ContentHandler(w http.ResponseWriter, r *http.Request)

1. Highlights are encoded into data.Notes 2. Process the highlights into the data.Content string

func (*Handler) Homepage

func (s *Handler) Homepage(w http.ResponseWriter, r *http.Request)

func (*Handler) RedirectFromPSlash

func (s *Handler) RedirectFromPSlash(w http.ResponseWriter, r *http.Request)

func (*Handler) RedirectSearch

func (s *Handler) RedirectSearch(w http.ResponseWriter, r *http.Request)

type ListArticleParams

type ListArticleParams struct {
	Notes []EnhancedEvent
}

type ProfileMetadata

type ProfileMetadata struct {
	PubKey     string `json:"pubkey,omitempty"`
	Name       string `json:"name,omitempty"`
	About      string `json:"about,omitempty"`
	Website    string `json:"website,omitempty"`
	Picture    string `json:"picture,omitempty"`
	Banner     string `json:"banner,omitempty"`
	Identifier string `json:"identifier,omitempty"`
}

func ParseMetadata

func ParseMetadata(e nostr.Event) (*ProfileMetadata, error)

func (ProfileMetadata) Npub

func (s ProfileMetadata) Npub() string

func (ProfileMetadata) String

func (s ProfileMetadata) String() string

type SpinnerParams

type SpinnerParams struct {
	Id string
}

type TemplateID

type TemplateID int
const (
	Profile TemplateID = iota
	ListArticle
	ListHighlight
	Article
	Highlight
	Unkown
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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