Skip to content

subaquatic-pierre/postmanager

PostManager

PyPI License: MIT Tests Linting Codecov Latest Documentation

Content manager for all types of content, blog posts, galleries, personal records, etc.


Features - Requirements - Installation - Quick usage - Examples

Features

  • AWS S3 storage: This means you can store your content directly to the cloud with very little configuration out of the box.

  • Local storage: Store all your content on your local system, skip cloud vulnerabilities or use for quick development purposes.

  • Easy media management: Add, Delete or Update any media associated with your content. Receive media data in a browser friendly format for easy image source display.

  • Control your meta data: Meta data each data point has meta data associated which can be in any shape. The user has complete control.

Requirements

Operating system

  • Linux
  • MacOS
  • Windows

Python Version

Python 3.9 or greater

Local Storage

There is very little requirements for local storage

  • User Read / Write privilege to home directory (true by default)

Cloud Storage

It is necessary to have the following configured to use PostManager with AWS S3.

  • AWS Account
  • S3 Bucket with Read/Write access (not necessarily public)
  • AWS CLI installed and configured

Installation

With pip:

pip install postmanager

Quick usage

Setup

from postmanager.manager import PostManager

blog_manager = PostManager.setup_local()

Create

meta_data = {
    "title": "Cool Blog",
    "author": "Jeff"
}

content = {
    "blocks":[
        {"Header"}:"Cool Blog"
    ],
    ...
    ...
}

new_blog = blog_manager.new_post(meta_data,content)

post_manager.save_post(new_blog)

Get

blog_id = 42
bog = blog_manager.get_by_id(blog_id)

return blog.to_json()

Delete

blog_id = 42
blog_manager.delete_post(blog_id)

Add Media

!!! note "Note: Media format" The add_media takes the media bytes in DataUrl format. This is the same as the value returned from JavaScript FileReader.readAsDataURL().

media = {
    "name":"cover_photo",
    "bytes": "data:image/jpeg;base64,iV99JKH...."
}

blog_id = 42
blog = blog_manager.get_by_id(blog_id)

blog.add_media(media["name"],media["bytes"])
blog_manager.save_post(blog)

Examples

Build docs

  1. Install deps
pip3 install -r requirements_docs.txt
  1. Run Build
mkdocs build
  1. Serve site directory
serve site

References

About

Post Manager for posts stored on AWS S3. The project leverages Python boto3 sdk to access AWS services

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published