Skip to main content

Ortus CMS integration for Flask applications

Project description

Ortus Flask Integration

Ortus CMS integration package for Flask applications to enable:

  • Webhook receiving for blog sync from Ortus CMS
  • Authenticated API for Ortus to fetch blogs
  • EditorJS data support

Installation

pip install ortus-flask

Usage

1. Update your Blog Model

Ensure your Blog model has the required fields:

from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

db = SQLAlchemy()

class Blog(db.Model):
    __tablename__ = 'blogs'
    
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    slug = db.Column(db.String(255), unique=True, nullable=False)
    excerpt = db.Column(db.Text, nullable=False)
    content = db.Column(db.Text, nullable=False)
    image = db.Column(db.String(500))
    author = db.Column(db.String(100))
    tag = db.Column(db.String(50))
    category = db.Column(db.String(50))
    views = db.Column(db.String(20), default="0")
    date = db.Column(db.String(20))
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    editorjs_data = db.Column(db.JSON, nullable=True)

    def to_dict(self):
        return {
            "id": self.id,
            "title": self.title,
            "slug": self.slug,
            "excerpt": self.excerpt,
            "content": self.content,
            "image": self.image,
            "author": self.author,
            "tag": self.tag,
            "category": self.category,
            "views": self.views,
            "date": self.date,
            "editorjs_data": self.editorjs_data
        }

2. Initialize in your Flask app

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from ortus_flask import init_ortus
import os
from dotenv import load_dotenv

load_dotenv()  # Loads ORTUS_WEBHOOK_SECRET and ORTUS_API_KEY

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///yourapp.db'

db = SQLAlchemy(app)
migrate = Migrate(app, db)

# Import your Blog model
from models import Blog

# Initialize Ortus integration
app.config['ORTUS_WEBHOOK_SECRET'] = os.getenv('ORTUS_WEBHOOK_SECRET')
app.config['ORTUS_API_KEY'] = os.getenv('ORTUS_API_KEY')
init_ortus(app, db, Blog)

3. Add to your .env

ORTUS_WEBHOOK_SECRET=your_webhook_secret
ORTUS_API_KEY=your_api_key

API Endpoints

After integration, these endpoints are available:

  • POST /api/webhook/blog - Receive blogs from Ortus
  • GET /api/webhook/config - Get webhook configuration
  • GET /api/sites/1/blogs - Fetch all blogs (authenticated)

Development

Install in editable mode:

pip install -e .

Build package:

python -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ortus_flask-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ortus_flask-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file ortus_flask-0.1.0.tar.gz.

File metadata

  • Download URL: ortus_flask-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ortus_flask-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ca8121a2bce40f3e194200e435b90bb360cddf2d22564ba7a53aabce5e93b1f1
MD5 5d77f948e8bdecb6f50f3978d44d410a
BLAKE2b-256 efccfb2bcf3f11dba9d1a8d85ff1ebcf6fd6d50ff6a64eec27598c3aaa1440e1

See more details on using hashes here.

File details

Details for the file ortus_flask-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ortus_flask-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ortus_flask-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5349913be297df026720ddf2ce050d338c988f31d31ed25b1385d0eda6850972
MD5 ee854de0ea4bd051d9e6605c24841a63
BLAKE2b-256 e614220ea717d1d530a4b3374cc139b23d1a024f4400b97ed90f4773d83170f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page