Skip to main content

The Most Beautiful CMS - A metadata-driven, zero-duplicate-code content management system

Project description

Focomy

世界一美しいCMS - メタデータ駆動 / 重複コードゼロ / リレーション完璧

要件

  • Python 3.10+
  • PostgreSQL 13+

インストール

pip install focomy

クイックスタート

# 1. サイト作成
focomy init mysite
cd mysite

# 2. PostgreSQL データベース作成
createdb mysite

# 3. 初期ユーザー作成
focomy createuser -e admin@example.com -n Admin -r admin

# 4. サーバー起動
focomy serve

# 5. 管理画面にアクセス
open http://localhost:8000/admin

CLI コマンド

コマンド 説明
focomy init <name> 新規サイト作成
focomy serve 開発サーバー起動
focomy createuser -e <email> ユーザー作成
focomy migrate マイグレーション実行
focomy makemigrations -m "msg" マイグレーション生成
focomy validate コンテンツタイプ定義検証
focomy update 最新版に更新
focomy update --check 更新確認のみ
focomy backup バックアップ作成
focomy backup --include-db DB含めてバックアップ
focomy restore <file> バックアップ復元

createuser オプション

focomy createuser -e <email> [-n <name>] [-r <role>] [-p <password>]

# -e, --email    : メールアドレス(必須)
# -n, --name     : 表示名(デフォルト: Admin)
# -r, --role     : 権限 admin/editor/author(デフォルト: admin)
# -p, --password : パスワード(省略時は対話入力、12文字以上)

serve オプション

focomy serve [--host <host>] [--port <port>] [--reload]

# --host   : バインドホスト(デフォルト: 0.0.0.0)
# --port   : ポート番号(デフォルト: 8000)
# --reload : 自動リロード有効

環境変数

変数 必須 説明
FOCOMY_DATABASE_URL PostgreSQL接続URL postgresql+asyncpg://user:pass@localhost:5432/dbname
FOCOMY_SECRET_KEY セッション暗号化キー ランダム文字列(32文字以上推奨)
FOCOMY_DEBUG - デバッグモード true / false

.env ファイルで設定可能(focomy init で自動生成)

ディレクトリ構造

mysite/
├── .env                 # 環境変数
├── config.yaml          # サイト設定
├── relations.yaml       # リレーション定義
├── content_types/       # コンテンツタイプ定義
│   ├── post.yaml
│   ├── page.yaml
│   └── category.yaml
├── themes/              # テーマ
│   └── default/
├── uploads/             # アップロードファイル
└── static/              # 静的ファイル

設定ファイル

config.yaml

site:
  name: "My Site"
  tagline: "A beautiful CMS"
  url: "https://example.com"
  language: "ja"
  timezone: "Asia/Tokyo"

admin:
  path: "/admin"
  per_page: 20

security:
  secret_key: "your-secret-key"
  session_expire: 86400

media:
  upload_dir: "uploads"
  max_size: 10485760
  image:
    max_width: 1920
    quality: 85
    format: webp

コンテンツタイプ定義

content_types/post.yaml:

name: post
label: 投稿
path_prefix: /blog
fields:
  - name: title
    type: string
    required: true
  - name: slug
    type: slug
    unique: true
  - name: body
    type: blocks
  - name: status
    type: select
    options: [draft, published]
    default: draft

リレーション定義

relations.yaml:

post_categories:
  from: post
  to: category
  type: many_to_many
  label: カテゴリ

post_author:
  from: post
  to: user
  type: many_to_one
  required: true
  label: 著者

デプロイ

Fly.io

fly launch
fly postgres create --name mysite-db
fly postgres attach mysite-db
fly secrets set FOCOMY_SECRET_KEY="your-secret-key"
fly deploy

Docker

docker-compose up -d

開発(ソースから)

git clone https://github.com/makoronu/focomy.git
cd focomy
pip install -e ".[dev]"

# 開発サーバー起動
cd core && uvicorn main:app --reload --port 8000

設計思想

詳細は focomy_specification.md を参照。

3つの抽象で全てを表現:

  1. Entity - 全コンテンツは統一エンティティ
  2. Field - メタデータ駆動フィールド定義
  3. Relation - リレーションは第一級市民

ライセンス

MIT License - LICENSE

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

focomy-0.1.1.tar.gz (272.9 kB view details)

Uploaded Source

Built Distribution

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

focomy-0.1.1-py3-none-any.whl (310.2 kB view details)

Uploaded Python 3

File details

Details for the file focomy-0.1.1.tar.gz.

File metadata

  • Download URL: focomy-0.1.1.tar.gz
  • Upload date:
  • Size: 272.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for focomy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 59a0afd7e58ccb29811ee0343027c4cd73008cc1b0c788e112812a62b6fd79b7
MD5 41499a95d7a584d92ba10e95ba6eef08
BLAKE2b-256 6f513be0d04f2d488a38c59c9c909c236618f6bf70c6ee3b618a8d0f461f0f49

See more details on using hashes here.

File details

Details for the file focomy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: focomy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 310.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for focomy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c2e5536c93bbd09c3e951ef9003580749e9b7e593ee5885c946cbbf8046b1d2
MD5 2cf1981f9d4376dbc83a21ddae70d412
BLAKE2b-256 26dba5242fcd60b03b46d90ba3c05376f022bc000d637af50eaabf9f0c74d23b

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