feat: add models module, API helpers, and Post refactoring#46
Open
svaningelgem wants to merge 1 commit intoma2za:mainfrom
Open
feat: add models module, API helpers, and Post refactoring#46svaningelgem wants to merge 1 commit intoma2za:mainfrom
svaningelgem wants to merge 1 commit intoma2za:mainfrom
Conversation
- Add models.py with Byline, PostMetadata, ScheduledRelease dataclasses - Add schedule_release(), get_post_metadata(), make_post_free() to Api - Extract _authenticate() and _resolve_publication() from __init__ - Add _get/_post/_put/_delete HTTP helpers, refactor all methods to use them - Add _handle_response allow_empty param with proper error chaining - Add _PRODUCTION_SUBDOMAINS safety guard - publish_draft now auto-runs prepublish validation - Use pathlib.Path instead of os.path/open for file operations - Post: dispatch table _ADD_HANDLERS replaces if/elif chain - Post: add paywall() and add_subscribe_button() methods - Post: extract _parse_markdown_blocks, _upload_or_passthrough, _render_image - Post: code_block uses match/case, _process_line handles inline headings - Refactored from_markdown() with HR support and better line merging - MCP: remove separate prepublish_draft tool (now automatic) - Add type annotations throughout all modules Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
bf2208d to
84edaa5
Compare
Author
|
I'm using this API as it is here, so it's tested in the wild already. And I backported my vendorized version to yours. There were also quite a few issues in markdown that I fixed: "---" -> horizontal line, subscriber button vs subscriber widget, grouping of paragraphs, headerizing everything (although that might have been my own intermediate implementation) Plus I made the code follow a bit more modern python standards. Enjoy 😉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
models.pywithByline,PostMetadata,ScheduledReleasedataclasses for typed API responsesschedule_release(),get_post_metadata(),make_post_free()high-level API methods_authenticate()/_resolve_publication()fromApi.__init__for clarity_get()/_post()/_put()/_delete()HTTP helpers to reduce boilerplate_handle_response(allow_empty=...)for endpoints that return empty bodies on successpublish_draft()now auto-runs prepublish validation (matches browser flow)pathlib.Pathinstead ofos.path/openfor file I/O_PRODUCTION_SUBDOMAINSsafety guard (empty by default)paywall()andadd_subscribe_button()to Post builderPost.add()to use dispatch table instead of if/elif chain_parse_markdown_blocks(),_upload_or_passthrough(),_render_image()fromfrom_markdown()from_markdown()with horizontal rule support, line merging, and inline heading handlingcode_block()usesmatch/caseprepublish_drafttool (now automatic)Test plan
Generated with Claude Code