Skip to content

notque/vexjoy-agent / skills/content/content

content

Unverified

Content operations: editorial calendar, marketing, publishing, social media management.

FileKindSize
SKILL.mdskill md11.5 KB
references/at-protocol-api.mdmarkdown7.6 KB
references/at-protocol-preferred-patterns.mdmarkdown8.5 KB
references/batch-edit-examples.mdmarkdown6.9 KB
references/batch-edit-operation-types.mdmarkdown7.0 KB
references/batch-edit-regex-patterns.mdmarkdown5.4 KB
references/batch-edit-safety-checklist.mdmarkdown6.0 KB
references/batch-edit.mdmarkdown9.9 KB
references/calendar-format.mdmarkdown3.5 KB
references/campaign-planning.mdmarkdown17.5 KB
references/classification-prompt.mdmarkdown5.9 KB
references/content-engine.mdmarkdown8.7 KB
references/content-engine/error-handling.mdmarkdown7.8 KB
references/content-engine/phase-playbook.mdmarkdown8.3 KB
references/content-engine/platform-specs.mdmarkdown10.9 KB
references/content-strategy.mdmarkdown14.5 KB
references/email-sequences.mdmarkdown15.8 KB
references/error-handling.mdmarkdown8.2 KB
references/headlines.mdmarkdown5.9 KB
references/image-audit-alt-text-examples.mdmarkdown6.8 KB
references/image-audit-format-selection.mdmarkdown5.8 KB
references/image-audit-report-templates.mdmarkdown3.8 KB
references/image-audit-size-guidelines.mdmarkdown4.2 KB
references/image-audit.mdmarkdown10.4 KB
references/link-audit-false-positives.mdmarkdown4.1 KB
references/link-audit-fix-strategies.mdmarkdown7.1 KB
references/link-audit-graph-metrics.mdmarkdown5.0 KB
references/link-audit.mdmarkdown7.8 KB
references/llm-marketing-failure-modes.mdmarkdown18.7 KB
references/marketing.mdmarkdown20.4 KB
references/metrics.mdmarkdown7.4 KB
references/news-collection.mdmarkdown5.2 KB
references/operations.mdmarkdown5.8 KB
references/outline-examples.mdmarkdown11.2 KB
references/outline-structure-templates.mdmarkdown6.4 KB
references/outline.mdmarkdown8.9 KB
references/pagespeed-insights.mdmarkdown10.4 KB
references/pipeline-stages.mdmarkdown3.3 KB
references/pre-publish-checklist.mdmarkdown7.4 KB
references/pre-publish-hugo-frontmatter.mdmarkdown5.3 KB
references/pre-publish-seo-guidelines.mdmarkdown4.1 KB
references/pre-publish.mdmarkdown10.8 KB
references/reddit-moderate.mdmarkdown7.9 KB
references/script-commands.mdmarkdown3.7 KB
references/seo-audit.mdmarkdown16.4 KB
references/seo-guidelines.mdmarkdown5.5 KB
references/seo-keyword-placement.mdmarkdown6.0 KB
references/seo-title-patterns.mdmarkdown5.6 KB
references/seo.mdmarkdown8.9 KB
references/series-planner.mdmarkdown11.7 KB
references/series-planner/cadence-guidelines.mdmarkdown6.8 KB
references/series-planner/cross-linking.mdmarkdown7.2 KB
references/series-planner/output-format.mdmarkdown3.8 KB
references/series-planner/series-types.mdmarkdown7.6 KB
references/taxonomy-audit-report-format.mdmarkdown3.2 KB
references/taxonomy-consolidation-rules.mdmarkdown6.7 KB
references/taxonomy-examples.mdmarkdown9.7 KB
references/taxonomy-guidelines.mdmarkdown5.5 KB
references/taxonomy.mdmarkdown9.0 KB
references/topic-brainstormer.mdmarkdown10.1 KB
references/topic-brainstormer/content-filter.mdmarkdown7.1 KB
references/topic-brainstormer/priority-scoring.mdmarkdown8.1 KB
references/topic-brainstormer/topic-sources.mdmarkdown7.6 KB
references/wordpress-upload.mdmarkdown11.2 KB
references/x-api.mdmarkdown7.8 KB
scripts/publish/link_scanner.pyscript21.4 KB
scripts/publish/pagespeed.pyscript15.3 KB
scripts/publish/tests/test_load_env_file.pyscript3.8 KB
scripts/publish/tests/test_wordpress_inline_urls.pyscript4.4 KB
scripts/publish/tests/test_wordpress_media_upload.pyscript1.5 KB
scripts/publish/tests/test_wordpress_scraper.pyscript4.1 KB
scripts/publish/wordpress-edit-post.pyscript21.2 KB
scripts/publish/wordpress-media-upload.pyscript8.7 KB
scripts/publish/wordpress-scraper.pyscript23.4 KB
scripts/publish/wordpress-upload.pyscript44.2 KB
scripts/reddit-moderate/reddit-automod-cron.shscript3.9 KB
scripts/reddit-moderate/reddit-mod.pyscript83.0 KB
scripts/reddit-moderate/tests/test_reddit_mod.pyscript31.3 KB

scripts/publish/wordpress-media-upload.py

View on GitHub
#!/usr/bin/env python3
"""
WordPress REST API media uploader.

Uploads images and other media files to WordPress media library.

Usage:
    python3 skills/content/content/scripts/publish/wordpress-media-upload.py --file image.jpg
    python3 skills/content/content/scripts/publish/wordpress-media-upload.py --file image.jpg --alt "Alt text" --caption "Caption"
    python3 skills/content/content/scripts/publish/wordpress-media-upload.py --file image.jpg --title "Image Title"

Environment Variables (from ~/.env):
    WORDPRESS_SITE         WordPress site URL (e.g., https://your-blog.com)
    WORDPRESS_USER         WordPress username
    WORDPRESS_APP_PASSWORD Application password from WordPress admin

Exit codes:
    0 = success
    1 = error
"""

from __future__ import annotations

import argparse
import base64
import json
import mimetypes
import os
import sys
from pathlib import Path
from typing import Any


def load_env_file(env_path: Path | None = None) -> dict[str, str]:
    """Load environment variables from .env file."""
    if env_path is None:
        env_path = Path.home() / ".env"

    env_vars: dict[str, str] = {}

    if not env_path.exists():
        return env_vars

    with open(env_path) as f:
        for line in f:
            line = line.strip()
            if not line or line.startswith("#"):
                continue
            if "=" in line:
                key, value = line.split("=", 1)
                value = value.strip()
                # Strip one pair of matching surrounding quotes.
                if len(value) >= 2 and value[0] == value[-1] and value[0] in ('"', "'"):
                    value = value[1:-1]
                env_vars[key.strip()] = value

    return env_vars


def get_config() -> dict[str, str]:
    """Get WordPress configuration from environment."""
    env_vars = load_env_file()

    config = {
        "site": os.environ.get("WORDPRESS_SITE", env_vars.get("WORDPRESS_SITE", "")),
        "user": os.environ.get("WORDPRESS_USER", env_vars.get("WORDPRESS_USER", "")),
        "password": os.environ.get("WORDPRESS_APP_PASSWORD", env_vars.get("WORDPRESS_APP_PASSWORD", "")),
    }

    return config


def validate_config(config: dict[str, str]) -> list[str]:
    """Validate configuration, return list of errors."""
    errors = []

    if not config["site"]:
        errors.append("WORDPRESS_SITE not set")
    if not config["user"]:
        errors.append("WORDPRESS_USER not set")
    if not config["password"]:
        errors.append("WORDPRESS_APP_PASSWORD not set")

    if config["site"] and not config["site"].startswith("https://"):
        errors.append("WORDPRESS_SITE must use HTTPS for Application Passwords")

    return errors


def _sanitize_header_filename(name: str) -> str:
    """Strip characters unsafe in a Content-Disposition filename parameter.

    Removes CR, LF, double quotes, and backslashes so the name cannot break
    out of a quoted-string header value.

    Args:
        name: Raw file name.

    Returns:
        Sanitized name safe for use inside a double-quoted header value.
    """
    return name.translate({0x0D: None, 0x0A: None, 0x22: None, 0x5C: None})


def upload_media(
    config: dict[str, str],
    file_path: Path,
    title: str | None = None,
    alt_text: str | None = None,
    caption: str | None = None,
    description: str | None = None,
) -> dict[str, Any]:
    """Upload media file to WordPress."""
    try:
        import requests
    except ImportError:
        return {
            "status": "error",
            "error": "requests library not installed. Run: pip install requests",
        }

    if not file_path.exists():
        return {
            "status": "error",
            "error": f"File not found: {file_path}",
        }

    # Determine content type
    content_type, _ = mimetypes.guess_type(str(file_path))
    if not content_type:
        content_type = "application/octet-stream"

    # Build API URL
    api_url = f"{config['site'].rstrip('/')}/wp-json/wp/v2/media"

    # Create Basic Auth header
    credentials = f"{config['user']}:{config['password']}"
    token = base64.b64encode(credentials.encode()).decode("utf-8")

    # Use the file name as title if not provided
    filename = file_path.name
    if title is None:
        title = file_path.stem  # filename without extension

    headers = {
        "Authorization": f"Basic {token}",
        "Content-Type": content_type,
        "Content-Disposition": f'attachment; filename="{_sanitize_header_filename(filename)}"',
    }

    try:
        # Read file content
        with open(file_path, "rb") as f:
            file_data = f.read()

        # Upload the file
        response = requests.post(api_url, headers=headers, data=file_data, timeout=60)

        if response.status_code == 201:
            data = response.json()
            media_id = data.get("id")

            # Update metadata if provided
            if alt_text or caption or description or title:
                update_data: dict[str, Any] = {}
                if title:
                    update_data["title"] = title
                if alt_text:
                    update_data["alt_text"] = alt_text
                if caption:
                    update_data["caption"] = caption
                if description:
                    update_data["description"] = description

                if update_data:
                    update_url = f"{api_url}/{media_id}"
                    update_headers = {
                        "Authorization": f"Basic {token}",
                        "Content-Type": "application/json",
                    }
                    requests.post(update_url, headers=update_headers, json=update_data, timeout=30)

            return {
                "status": "success",
                "media_id": media_id,
                "url": data.get("source_url"),
                "title": data.get("title", {}).get("rendered", ""),
                "media_type": data.get("media_type"),
                "mime_type": data.get("mime_type"),
            }
        else:
            error_data = {}
            try:
                error_data = response.json()
            except Exception:
                pass

            return {
                "status": "error",
                "http_status": response.status_code,
                "error": error_data.get("message", response.text[:500]),
                "code": error_data.get("code", "unknown"),
            }

    except requests.exceptions.ConnectionError as e:
        return {
            "status": "error",
            "error": f"Connection failed: {e}",
        }
    except requests.exceptions.Timeout:
        return {
            "status": "error",
            "error": "Request timed out after 60 seconds",
        }
    except Exception as e:
        return {
            "status": "error",
            "error": f"Unexpected error: {e}",
        }


def main() -> int:
    parser = argparse.ArgumentParser(
        description="Upload media files to WordPress",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=__doc__,
    )

    parser.add_argument(
        "--file",
        "-f",
        required=True,
        help="Path to media file to upload",
    )
    parser.add_argument(
        "--title",
        "-t",
        help="Media title (defaults to filename)",
    )
    parser.add_argument(
        "--alt",
        help="Alt text for the media",
    )
    parser.add_argument(
        "--caption",
        help="Caption for the media",
    )
    parser.add_argument(
        "--description",
        help="Description for the media",
    )
    parser.add_argument(
        "--json",
        action="store_true",
        help="Output as JSON (default)",
    )
    parser.add_argument(
        "--human",
        action="store_true",
        help="Output human-readable format",
    )

    args = parser.parse_args()

    # Load and validate config
    config = get_config()
    errors = validate_config(config)

    if errors:
        result = {
            "status": "error",
            "error": "Configuration errors",
            "details": errors,
        }
        print(json.dumps(result, indent=2))
        return 1

    # Upload media
    file_path = Path(args.file)
    result = upload_media(
        config=config,
        file_path=file_path,
        title=args.title,
        alt_text=args.alt,
        caption=args.caption,
        description=args.description,
    )

    # Output
    if args.human and result["status"] == "success":
        print("Media uploaded successfully!")
        print(f"  ID: {result['media_id']}")
        print(f"  URL: {result['url']}")
        print(f"  Type: {result['mime_type']}")
    else:
        print(json.dumps(result, indent=2))

    return 0 if result["status"] == "success" else 1


if __name__ == "__main__":
    sys.exit(main())
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall