Skip to content

Add note templates with rendering#14

Open
Intina47 wants to merge 11 commits intomainfrom
mamba/add-lightweight-templating-system-for-notes
Open

Add note templates with rendering#14
Intina47 wants to merge 11 commits intomainfrom
mamba/add-lightweight-templating-system-for-notes

Conversation

@Intina47
Copy link
Copy Markdown
Owner

Motivation

  • Provide a lightweight templating system so users can quickly scaffold structured notes (daily, meeting, RFC) from the CLI.
  • Allow custom templates to live in a config directory and override built-ins to support project/user-specific note formats.

Description

  • Add jot new --template <name> to render a template and write a dated markdown file in the current directory and jot templates to list available templates by name; implementation added in main.go (jotNew, jotTemplates).
  • Implement template registry and rendering: built-in templates (daily, meeting, rfc), custom template discovery under the config templates dir (falling back to ~/.jot/templates), template loading helpers (templateDir, loadTemplates, loadCustomTemplates, builtinTemplates) and rendering (renderTemplate), plus repository name detection (repoName).
  • Documented usage and variables ({{date}}, {{time}}, {{datetime}}, {{repo}}) and custom template path in README.md.
  • Add unit tests for custom template discovery and template rendering in main_test.go.

Testing

  • Ran unit tests with go test ./... and all tests passed.
  • Added and ran tests verifying custom template override and renderTemplate output, which succeeded.

Codex Task

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f75be4309

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

main.go Outdated
Comment on lines +187 to +190
filename := fmt.Sprintf("%s-%s.md", currentTime.Format("2006-01-02"), templateName)
path := filepath.Join(mustGetwd(), filename)
if err := os.WriteFile(path, []byte(rendered), 0o600); err != nil {
return err
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid overwriting existing notes on same day

The filename is always YYYY-MM-DD-<template>.md and os.WriteFile truncates existing files, so running jot new --template meeting (or any template) more than once in the same day silently overwrites the previous note. This can cause user data loss for templates intended to be used multiple times per day. Consider checking for an existing file and erroring, or add a uniqueness suffix (time or counter).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex fix issue

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Switched template note creation to exclusive file creation and emit a clear error when a note already exists to prevent overwrites. main.goL171-L205
  • Added a test ensuring jot new refuses to overwrite an existing note and preserves its contents. main_test.goL160-L198

Testing

  • go test ./...

View task →

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex a users can have more than one meeting in a day so they might need to record each meeting notes in different templates etc, we need to add an option that allows the user to create a new jot with a template and they specify the name of the template for example jot new --template meeting -n "Team Sync-Up"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Testing

  • go test ./...

View task →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant