SomethingGeneric / flaskpress

Wordpress but it's actually Python + Flask
GNU General Public License v3.0
0 stars 0 forks source link

Implement saving a post as markdown #7

Closed sweep-ai[bot] closed 1 year ago

sweep-ai[bot] commented 1 year ago

Description

This PR implements the functionality to save a post as a markdown file in the Flaskpress application. It modifies the post() function in main.py to handle incoming POST requests with a markdown text attribute. The markdown text is extracted from the request, and a unique filename is generated for the new post. The markdown file is then saved in the pages/ directory. If the pages/ directory does not exist, it is created. After saving the markdown file, the post() function returns a redirect to the new post's page.

Summary of Changes

Fixes #6.


To checkout this PR branch, run the following command in your terminal:

git checkout sweep/save-post-as-markdown

šŸŽ‰ Latest improvements to Sweep:


šŸ’” To get Sweep to edit this pull request, you can:

SomethingGeneric commented 1 year ago

This is awesome! If you could first attempt to name the post with a provided request attribute called "filename" or "post_name", that would be awesome. Having the timestamp as a fallback, though, if filename is omitted, is fantastic.

sweep-ai[bot] commented 1 year ago

This is awesome! If you could first attempt to name the post with a provided request attribute called "filename" or "post_name", that would be awesome. Having the timestamp as a fallback, though, if filename is omitted, is fantastic.

Hi @SomethingGeneric,

I decided to make the following changes:

File Path Proposed Changes
main.py Modify main.py with contents:
ā€¢ In the post() function, check for the presence of the "filename" or "post_name" attribute in the request.
ā€¢ If the attribute is present, use its value as the filename for the new post.
ā€¢ If the attribute is not present, fallback to using the current timestamp to generate a unique filename.