feat(tags): Add database schema and tags module (v1.3.0 Phase 1)
Implements tag/category system backend following microformats2 p-category specification. Database changes: - Migration 008: Add tags and note_tags tables - Normalized tag storage (case-insensitive lookup, display name preserved) - Indexes for performance New module: - starpunk/tags.py: Tag management functions - normalize_tag: Normalize tag strings - get_or_create_tag: Get or create tag records - add_tags_to_note: Associate tags with notes (replaces existing) - get_note_tags: Retrieve note tags (alphabetically ordered) - get_tag_by_name: Lookup tag by normalized name - get_notes_by_tag: Get all notes with specific tag - parse_tag_input: Parse comma-separated tag input Model updates: - Note.tags property (lazy-loaded, prefer pre-loading in routes) - Note.to_dict() add include_tags parameter CRUD updates: - create_note() accepts tags parameter - update_note() accepts tags parameter (None = no change, [] = remove all) Micropub integration: - Pass tags to create_note() (tags already extracted by extract_tags()) - Return tags in q=source response Per design doc: docs/design/v1.3.0/microformats-tags-design.md Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -318,7 +318,8 @@ def handle_create(data: dict, token_info: dict):
|
||||
content=content,
|
||||
published=True, # Micropub posts are published by default
|
||||
created_at=published_date,
|
||||
custom_slug=custom_slug
|
||||
custom_slug=custom_slug,
|
||||
tags=tags if tags else None # Pass tags to create_note (v1.3.0)
|
||||
)
|
||||
|
||||
# Build permalink URL
|
||||
@@ -403,9 +404,9 @@ def handle_query(args: dict, token_info: dict):
|
||||
if note.title:
|
||||
mf2["properties"]["name"] = [note.title]
|
||||
|
||||
# Tags not implemented in V1, skip category property
|
||||
# if hasattr(note, 'tags') and note.tags:
|
||||
# mf2["properties"]["category"] = note.tags
|
||||
# Add tags if present (v1.3.0)
|
||||
if note.tags:
|
||||
mf2["properties"]["category"] = [tag["display_name"] for tag in note.tags]
|
||||
|
||||
return jsonify(mf2), 200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user