replacenotes

package
v1.44.2 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoValue = errors.New("no text to replace")

Functions

func Process

func Process(ctx context.Context, db bun.IDB, input Input) *run

Process replaces a text in the content of every live note of the account, through patchnote in one transaction: the locked notes are skipped and counted, and each note changed keeps a version of its text before. TODO: every note goes through patchnote within the 30 s of a request, fine for a few thousand changed; a job if more.

Types

type Input

type Input struct {
	Find       string   `json:"find"`
	Replace    string   `json:"replace"`
	DryRun     bool     `json:"dry_run,omitempty" binding:"optional"`
	Folder     string   `json:"folder,omitempty" binding:"optional"`     // a folder id: only its notes, its subfolders included
	Notes      []string `json:"notes,omitempty" binding:"optional"`      // note ids: only these notes
	Occurrence int      `json:"occurrence,omitempty" binding:"optional"` // with Notes: only that occurrence of each, from 1
}

Input is a plain text, no regex, found with its case. DryRun only counts and lists the occurrences, for the confirmation. Notes and Occurrence narrow it to what the list shows: a note, or one occurrence of it.

type Line added in v1.17.4

type Line struct {
	Line   int    `json:"line"`
	Before string `json:"before"`
	After  string `json:"after"`
}

Line is an occurrence: its line in the note, from 1, and the text of the line around it.

type Match added in v1.17.4

type Match struct {
	ID          string `json:"id"`
	Path        string `json:"path"`
	Occurrences []Line `json:"occurrences"`
}

Match is a note holding the text, with its occurrences in order: their index is the Occurrence of Input.

type Result

type Result struct {
	Notes       int     `json:"notes"`
	Occurrences int     `json:"occurrences"`
	Locked      int     `json:"locked"`
	Matches     []Match `json:"matches,omitempty" binding:"optional"`
}

Result counts the notes holding the text and its occurrences in them; the locked notes are left as they are. A dry run lists the occurrences too, the first maxMatches of them.

Jump to

Keyboard shortcuts

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