remove cryptput integration for now - too messy
This commit is contained in:
parent
f19fff72e5
commit
b080679ec9
15
PLUMBING.md
15
PLUMBING.md
|
|
@ -21,19 +21,6 @@ plumb to denote
|
|||
plumb start Denote $0
|
||||
```
|
||||
|
||||
## Encryption support
|
||||
|
||||
```
|
||||
plumb to cryptget
|
||||
|
||||
# open encrypted files with CryptGet
|
||||
# https://github.com/lneely/acme-crypt
|
||||
type is text
|
||||
data matches '(.+)\.(gpg|GPG|pgp|PGP|asc|ASC)'
|
||||
plumb to cryptget
|
||||
plumb start CryptGet $0
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Once configured, you can right-click (button 3) on any text matching the pattern:
|
||||
|
|
@ -44,6 +31,4 @@ denote:20251103T165653
|
|||
|
||||
Or simply right click an identifier in the `Denote` window. You may use the `denote:` pattern to cross-link notes.
|
||||
|
||||
If you set up the plumbing rule for `CryptGet`, this will also enable support for opening encrypted notes (e.g., if the underlying file is a `.md.gpg` file). To maintain encryption, remember to use `CryptPut` instead of `Put` to save the file.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -112,10 +112,6 @@ By default notes are markdown files with YAML frontmatter:
|
|||
|
||||
You may change this by changing `ftype` in main.go.
|
||||
|
||||
## Encryption Support
|
||||
|
||||
This program supports encrypted notes by integrating with [acme-crypt](https://github.com/lneely/acme-crypt). Set up the [plumbing rules](./PLUMBING.md) to read encrypted notes, and use `CryptPut` to write them.
|
||||
|
||||
## Signature Support
|
||||
|
||||
Denote supports an optional signature component in filenames: `ID==SIGNATURE--TITLE__TAGS.ext`. Signatures are useful for sequential numbering, context markers, or priorities.
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ func HandleUpdateEvent(f *client.Fsys, identifier, denoteDir string) error {
|
|||
}
|
||||
|
||||
// After updating content, check if a rename is needed
|
||||
// Extract the FULL extension from original path (preserves .gpg, .txt.gpg, etc.)
|
||||
dir := filepath.Dir(path)
|
||||
if dir == "." {
|
||||
dir = denoteDir
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ func ExtractMetadata(path string) (*metadata.Metadata, error) {
|
|||
|
||||
// Check if we should try to read file content for title
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
// Don't read encrypted files or unsupported types
|
||||
if ext == ".gpg" || (ext != ".org" && ext != ".md" && ext != ".txt") {
|
||||
// Don't read unsupported file types
|
||||
if ext != ".org" && ext != ".md" && ext != ".txt" {
|
||||
return note, nil
|
||||
}
|
||||
|
||||
|
|
@ -46,11 +46,6 @@ func ExtractMetadata(path string) (*metadata.Metadata, error) {
|
|||
func ExtractFrontMatter(path string) (*metadata.FrontMatter, error) {
|
||||
ext := strings.ToLower(filepath.Ext(path))
|
||||
|
||||
// Don't try to parse front matter from encrypted files
|
||||
if ext == ".gpg" {
|
||||
return &metadata.FrontMatter{}, nil
|
||||
}
|
||||
|
||||
content, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read file: %w", err)
|
||||
|
|
|
|||
35
main.go
35
main.go
|
|
@ -117,7 +117,7 @@ func handleNewEvent(f *client.Fsys, identifier, denoteDir string) error {
|
|||
return fmt.Errorf("failed to update path in metadata: %w", err)
|
||||
}
|
||||
|
||||
// Check if file already exists (CryptPut or manual creation case)
|
||||
// Check if file already exists (manual creation case)
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -148,9 +148,6 @@ func handleNewEvent(f *client.Fsys, identifier, denoteDir string) error {
|
|||
win.Ctl("dot=addr")
|
||||
win.Ctl("show")
|
||||
|
||||
// Start event watcher for CryptPut detection
|
||||
go watchNoteWindow(win, path)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -576,37 +573,7 @@ func applyIndexChanges(f *client.Fsys, current, updated metadata.Results) error
|
|||
}
|
||||
|
||||
var identifierPattern = regexp.MustCompile(`^\d{8}T\d{6}$`)
|
||||
var denoteFilePattern = regexp.MustCompile(`^(\d{8}T\d{6})--`)
|
||||
|
||||
func isIdentifier(s string) bool {
|
||||
return identifierPattern.MatchString(s)
|
||||
}
|
||||
|
||||
func watchNoteWindow(win *acme.Win, path string) {
|
||||
defer win.CloseFiles()
|
||||
|
||||
for e := range win.EventChan() {
|
||||
switch e.C2 {
|
||||
case 'x', 'X':
|
||||
// Update metadata path when CryptPut is used
|
||||
if string(e.Text) == "CryptPut" {
|
||||
// Extract identifier from path
|
||||
filename := filepath.Base(path)
|
||||
matches := denoteFilePattern.FindStringSubmatch(filename)
|
||||
if len(matches) >= 2 {
|
||||
identifier := matches[1]
|
||||
encryptedPath := path + ".gpg"
|
||||
p9client.With9P(func(f *client.Fsys) error {
|
||||
return p9client.WriteFile(f, "n/"+identifier+"/path", encryptedPath)
|
||||
})
|
||||
}
|
||||
|
||||
win.WriteEvent(e)
|
||||
} else {
|
||||
win.WriteEvent(e)
|
||||
}
|
||||
default:
|
||||
win.WriteEvent(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue