Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57f34f0fc7 | |||
| 58a9641b94 | |||
| 16c068b4b0 | |||
| de869c2b5d | |||
| b8cd0253e1 | |||
| c3899b65d3 | |||
| 7777ffca32 | |||
| 90340dd499 | |||
| 7747fef50e | |||
| 3586ce7661 | |||
| 83dc2fa013 | |||
| 9544f4f0bb | |||
| 288dbb2240 | |||
| 37b32a56b3 | |||
| 3b501719ff | |||
| 5325293db4 | |||
| 06b27095ab | |||
| 362ce47e71 | |||
| 911aac785b | |||
| 865a877f99 | |||
| 1acb7f3778 | |||
| f8d1934d14 | |||
| 435d4e8392 | |||
| dc53ef48d1 | |||
| 1f76d7d2e9 | |||
| 7262506d8e | |||
| 12074b71c3 | |||
| 949f58506c | |||
| e23ddf9344 | |||
| 5c86bdc24c | |||
| e25c6a9885 | |||
| 39d9d6fe1d | |||
| b57910f63b | |||
| 77cac8c8c3 | |||
| 430d6a79f4 | |||
| bf835e9063 | |||
| 044bcdae76 | |||
| 226fb84dd4 | |||
| b2e2630d44 | |||
| f0c79b3f32 | |||
| fe3ac2f54a | |||
| dabce55cc7 | |||
| 6d477d9f23 | |||
| 5d3da335f3 | |||
| c463950990 | |||
| f90e0954f0 | |||
| 7a57b001e3 | |||
| 6cba84bde5 | |||
| 5b8aa86357 | |||
| 9982a4bffd | |||
| cf7fd55eca | |||
| 994cbf2701 | |||
| 4e0c776c70 | |||
| 207ad9c2c6 | |||
| 973f83dc32 | |||
| 55596a1024 | |||
| 73d8425130 | |||
| 50152524b9 | |||
| b4d8ff3336 | |||
| 003bd1624a | |||
| 13b6cf2016 | |||
| d70acbc35d | |||
| 3b089f8d72 | |||
| fc57c51004 | |||
| 3b1b0e8844 | |||
| e31552259d | |||
| 97915d9f30 | |||
| 2872ae2b97 | |||
| 3664f547ee | |||
| 6521edaab9 | |||
| 3f6f286ffe | |||
| 342f6fa3b8 | |||
| 2f60ede713 | |||
| 8fba003d64 | |||
| 76dfa177c4 | |||
| 4edc5a4765 | |||
| a67a2a3c5d | |||
| 9bbf2a74fb | |||
| 04e7720268 | |||
| d4c2ff00c3 | |||
| 559b9ca30c | |||
| 7e4cce51de | |||
| a2e2a60dea |
@@ -1,83 +0,0 @@
|
||||
# MokoSuiteCross
|
||||
|
||||
Cross-posting Joomla content to social media, email marketing, and chat platforms with plugin-based services.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| **Package** | `pkg_mokosuitecross` |
|
||||
| **Language** | PHP 8.1+ |
|
||||
| **Branch** | develop on `dev`, merge to `main` (protected) |
|
||||
| **Wiki** | [MokoSuiteCross Wiki](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteCross/wiki) |
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
make build # Build package ZIP
|
||||
make lint # Run linters
|
||||
make validate # Validate structure
|
||||
make release # Full release pipeline
|
||||
make clean # Clean build artifacts
|
||||
composer install # Install PHP dependencies
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
Joomla **package** with core extensions + pluggable service plugins:
|
||||
|
||||
### com_mokosuitecross (Component)
|
||||
- Admin backend: dashboard, services, post queue, templates, logs
|
||||
- Joomla 5/6 MVC: Dashboard, Services, Posts, Logs (list/edit each)
|
||||
- Namespace: `Joomla\Component\MokoSuiteCross\Administrator`
|
||||
|
||||
### plg_system_mokosuitecross (System Plugin)
|
||||
- Hooks `onContentAfterSave` to trigger cross-posting on article publish
|
||||
- Dispatches to registered service plugins via `mokosuitecross` plugin group
|
||||
|
||||
### plg_content_mokosuitecross (Content Plugin)
|
||||
- Adds cross-post status badges to articles via `onContentBeforeDisplay`
|
||||
|
||||
### plg_webservices_mokosuitecross (WebServices Plugin)
|
||||
- REST API endpoints for posts and services
|
||||
|
||||
### Service Plugins (mokosuitecross group)
|
||||
Each platform is a separate plugin implementing `MokoSuiteCrossServiceInterface`:
|
||||
- `plg_mokosuitecross_facebook` — Facebook/Meta Graph API
|
||||
- `plg_mokosuitecross_twitter` — X/Twitter API v2
|
||||
- `plg_mokosuitecross_linkedin` — LinkedIn Share API
|
||||
- `plg_mokosuitecross_mastodon` — Mastodon API
|
||||
- `plg_mokosuitecross_bluesky` — Bluesky AT Protocol
|
||||
- `plg_mokosuitecross_mailchimp` — Mailchimp Campaigns API
|
||||
- `plg_mokosuitecross_telegram` — Telegram Bot API
|
||||
- `plg_mokosuitecross_discord` — Discord Webhooks
|
||||
- `plg_mokosuitecross_slack` — Slack Incoming Webhooks
|
||||
|
||||
### Database Schema
|
||||
|
||||
- `#__mokosuitecross_services` — service configs (credentials as individual fields, not JSON)
|
||||
- `#__mokosuitecross_posts` — post queue (status: queued/posting/posted/failed/scheduled)
|
||||
- `#__mokosuitecross_templates` — message templates per service type
|
||||
- `#__mokosuitecross_logs` — activity logs with level and context
|
||||
|
||||
## Rules
|
||||
|
||||
- **Never commit** `.claude/`, `.mcp.json`, `TODO.md`, `*.min.css`/`*.min.js`
|
||||
- **Never commit** API keys, tokens, or credentials — these go in Joomla's encrypted params
|
||||
- **Attribution**: `Authored-by: Moko Consulting`
|
||||
- **Workflow directory**: `.mokogitea/` (not `.gitea/` or `.github/`)
|
||||
- **Minification**: handled at build time (CI)
|
||||
- **Wiki**: documentation lives in the Gitea wiki, not `docs/` files
|
||||
- **Standards**: [MokoStandards](https://git.mokoconsulting.tech/MokoConsulting/mokoplatform/wiki/Home)
|
||||
- **UX**: service credentials as individual form fields, not JSON blobs; dashboard link in toolbar
|
||||
|
||||
## Coding Standards
|
||||
|
||||
- PHP 8.1+ minimum
|
||||
- Joomla 5/6 DI container pattern: `services/provider.php` → Extension class
|
||||
- Legacy stub `.php` file required for plugin loader but empty
|
||||
- `SubscriberInterface` for event subscription (not `on*` method naming)
|
||||
- `bind() → check() → store()` for Table operations (not `save()`)
|
||||
- Language file placement: site (no `folder`) vs admin (`folder="administrator"`)
|
||||
- SPDX license headers on all PHP files
|
||||
- Service plugins MUST implement `MokoSuiteCrossServiceInterface`
|
||||
@@ -1,251 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: moko-platform.Automation
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||
# PATH: /.gitea/workflows/branch-protection.yml
|
||||
# BRIEF: Apply standardised branch protection rules to all governed repositories
|
||||
#
|
||||
# +========================================================================+
|
||||
# | BRANCH PROTECTION SETUP |
|
||||
# +========================================================================+
|
||||
# | |
|
||||
# | Applies protection rules for: main, dev, rc, beta, alpha |
|
||||
# | |
|
||||
# | main — Require PR, block rejected reviews, no force push |
|
||||
# | dev — Allow push, no force push, no delete |
|
||||
# | rc — Allow push, no force push, no delete |
|
||||
# | beta — Allow push, no force push, no delete |
|
||||
# | alpha — Allow push, no force push, no delete |
|
||||
# | |
|
||||
# | jmiller has override authority on all branches. |
|
||||
# | |
|
||||
# +========================================================================+
|
||||
|
||||
name: Branch Protection Setup
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 2 * * 1' # Weekly Monday 02:00 UTC
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
description: 'Preview mode (no changes)'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
repos:
|
||||
description: 'Comma-separated repo names (empty = all governed repos)'
|
||||
required: false
|
||||
type: string
|
||||
default: ''
|
||||
|
||||
env:
|
||||
GITEA_URL: https://git.mokoconsulting.tech
|
||||
GITEA_ORG: MokoConsulting
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
protect:
|
||||
name: Apply Branch Protection Rules
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Determine target repos
|
||||
id: repos
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||
run: |
|
||||
API="${GITEA_URL}/api/v1"
|
||||
|
||||
# Platform/standards/infra repos to exclude
|
||||
EXCLUDE="gitea-org-config org-profile gitea-private .mokogitea-private MokoStandards moko-platform MokoTesting"
|
||||
EXCLUDE="$EXCLUDE MokoStandards-Template-Client MokoStandards-Template-Dolibarr MokoStandards-Template-Generic MokoStandards-Template-Joomla MokoDoliProjTemplate"
|
||||
|
||||
if [ -n "${{ inputs.repos }}" ]; then
|
||||
# User-specified repos
|
||||
REPOS=$(echo "${{ inputs.repos }}" | tr ',' ' ')
|
||||
else
|
||||
# Fetch all org repos
|
||||
PAGE=1
|
||||
REPOS=""
|
||||
while true; do
|
||||
BATCH=$(curl -sS \
|
||||
-H "Authorization: token ${GA_TOKEN}" \
|
||||
"${API}/orgs/${GITEA_ORG}/repos?page=${PAGE}&limit=50" \
|
||||
| jq -r '.[].name // empty')
|
||||
[ -z "$BATCH" ] && break
|
||||
REPOS="$REPOS $BATCH"
|
||||
PAGE=$((PAGE + 1))
|
||||
done
|
||||
|
||||
# Filter out excluded repos
|
||||
FILTERED=""
|
||||
for REPO in $REPOS; do
|
||||
SKIP=false
|
||||
for EX in $EXCLUDE; do
|
||||
if [ "$REPO" = "$EX" ]; then
|
||||
SKIP=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$SKIP" = "false" ]; then
|
||||
FILTERED="$FILTERED $REPO"
|
||||
fi
|
||||
done
|
||||
REPOS="$FILTERED"
|
||||
fi
|
||||
|
||||
echo "repos=$REPOS" >> "$GITHUB_OUTPUT"
|
||||
COUNT=$(echo "$REPOS" | wc -w)
|
||||
echo "📋 Target repos (${COUNT}): $REPOS"
|
||||
|
||||
- name: Apply protection rules
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||
DRY_RUN: ${{ inputs.dry_run || 'false' }}
|
||||
run: |
|
||||
API="${GITEA_URL}/api/v1"
|
||||
REPOS="${{ steps.repos.outputs.repos }}"
|
||||
|
||||
SUCCESS=0
|
||||
FAILED=0
|
||||
SKIPPED=0
|
||||
|
||||
# ── Rule definitions ──────────────────────────────────────
|
||||
# Only the CI bot (jmiller token) can push directly.
|
||||
# All human contributors must use PRs.
|
||||
# Force push disabled on all branches.
|
||||
|
||||
RULE_MAIN='{
|
||||
"rule_name": "main",
|
||||
"enable_push": true,
|
||||
"enable_push_whitelist": true,
|
||||
"push_whitelist_usernames": ["jmiller"],
|
||||
"enable_force_push": false,
|
||||
"enable_force_push_allowlist": false,
|
||||
"force_push_allowlist_usernames": [],
|
||||
"enable_merge_whitelist": false,
|
||||
"required_approvals": 0,
|
||||
"dismiss_stale_approvals": true,
|
||||
"block_on_rejected_reviews": true,
|
||||
"block_on_outdated_branch": false,
|
||||
"priority": 1
|
||||
}'
|
||||
|
||||
RULE_DEV='{
|
||||
"rule_name": "dev",
|
||||
"enable_push": true,
|
||||
"enable_push_whitelist": true,
|
||||
"push_whitelist_usernames": ["jmiller"],
|
||||
"enable_force_push": false,
|
||||
"enable_force_push_allowlist": false,
|
||||
"force_push_allowlist_usernames": [],
|
||||
"enable_merge_whitelist": false,
|
||||
"required_approvals": 0,
|
||||
"block_on_rejected_reviews": false,
|
||||
"priority": 2
|
||||
}'
|
||||
|
||||
RULE_RC='{
|
||||
"rule_name": "rc",
|
||||
"enable_push": true,
|
||||
"enable_push_whitelist": true,
|
||||
"push_whitelist_usernames": ["jmiller"],
|
||||
"enable_force_push": false,
|
||||
"enable_force_push_allowlist": false,
|
||||
"force_push_allowlist_usernames": [],
|
||||
"enable_merge_whitelist": false,
|
||||
"required_approvals": 0,
|
||||
"block_on_rejected_reviews": false,
|
||||
"priority": 3
|
||||
}'
|
||||
|
||||
RULE_BETA='{
|
||||
"rule_name": "beta",
|
||||
"enable_push": true,
|
||||
"enable_push_whitelist": true,
|
||||
"push_whitelist_usernames": ["jmiller"],
|
||||
"enable_force_push": false,
|
||||
"enable_force_push_allowlist": false,
|
||||
"force_push_allowlist_usernames": [],
|
||||
"enable_merge_whitelist": false,
|
||||
"required_approvals": 0,
|
||||
"block_on_rejected_reviews": false,
|
||||
"priority": 4
|
||||
}'
|
||||
|
||||
RULE_ALPHA='{
|
||||
"rule_name": "alpha",
|
||||
"enable_push": true,
|
||||
"enable_push_whitelist": true,
|
||||
"push_whitelist_usernames": ["jmiller"],
|
||||
"enable_force_push": false,
|
||||
"enable_force_push_allowlist": false,
|
||||
"force_push_allowlist_usernames": [],
|
||||
"enable_merge_whitelist": false,
|
||||
"required_approvals": 0,
|
||||
"block_on_rejected_reviews": false,
|
||||
"priority": 5
|
||||
}'
|
||||
|
||||
RULES=("$RULE_MAIN" "$RULE_DEV" "$RULE_RC" "$RULE_BETA" "$RULE_ALPHA")
|
||||
RULE_NAMES=("main" "dev" "rc" "beta" "alpha")
|
||||
|
||||
# ── Apply rules to each repo ──────────────────────────────
|
||||
for REPO in $REPOS; do
|
||||
echo ""
|
||||
echo "═══ ${REPO} ═══"
|
||||
|
||||
for i in "${!RULES[@]}"; do
|
||||
RULE="${RULES[$i]}"
|
||||
NAME="${RULE_NAMES[$i]}"
|
||||
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo " [DRY RUN] Would apply rule: ${NAME}"
|
||||
SKIPPED=$((SKIPPED + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Delete existing rule if present (idempotent recreate)
|
||||
ENCODED_NAME=$(echo "$NAME" | sed 's|/|%2F|g')
|
||||
curl -sS -o /dev/null -w "" \
|
||||
-X DELETE \
|
||||
-H "Authorization: token ${GA_TOKEN}" \
|
||||
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections/${ENCODED_NAME}" 2>/dev/null || true
|
||||
|
||||
# Create rule
|
||||
RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: token ${GA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$RULE" \
|
||||
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections")
|
||||
|
||||
HTTP=$(echo "$RESPONSE" | tail -1)
|
||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||
|
||||
if [ "$HTTP" = "201" ]; then
|
||||
echo " ✅ ${NAME}"
|
||||
SUCCESS=$((SUCCESS + 1))
|
||||
else
|
||||
echo " ❌ ${NAME} (HTTP ${HTTP}): $(echo "$BODY" | jq -r '.message // .' 2>/dev/null | head -1)"
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# ── Summary ───────────────────────────────────────────────
|
||||
echo ""
|
||||
echo "════════════════════════════════════════"
|
||||
echo " ✅ Success: ${SUCCESS}"
|
||||
echo " ❌ Failed: ${FAILED}"
|
||||
echo " ⏭️ Skipped: ${SKIPPED}"
|
||||
echo "════════════════════════════════════════"
|
||||
|
||||
if [ "$FAILED" -gt 0 ]; then
|
||||
echo "::warning::${FAILED} rule(s) failed to apply"
|
||||
fi
|
||||
+7
-12
@@ -1,26 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mokoplatform xmlns="https://standards.mokoconsulting.tech/mokoplatform/1.0" schema-version="1.0">
|
||||
<moko-platform xmlns="https://standards.mokoconsulting.tech/moko-platform/1.0" schema-version="1.0">
|
||||
<identity>
|
||||
<name>MokoSuiteCross</name>
|
||||
<display-name>Package - MokoSuiteCross</display-name>
|
||||
<name>MokoJoomCross</name>
|
||||
<org>MokoConsulting</org>
|
||||
<description>Cross-posting Joomla content to social media, email marketing, and chat platforms</description>
|
||||
<version>01.01.02</version>
|
||||
<version>01.00.06-dev-dev</version>
|
||||
<version>01.00.13</version>
|
||||
<license spdx="GPL-3.0-or-later">GNU General Public License v3</license>
|
||||
</identity>
|
||||
<governance>
|
||||
<platform>joomla</platform>
|
||||
<standards-version>05.00.00</standards-version>
|
||||
<standards-source>https://git.mokoconsulting.tech/MokoConsulting/mokoplatform</standards-source>
|
||||
<standards-source>https://git.mokoconsulting.tech/MokoConsulting/moko-platform</standards-source>
|
||||
</governance>
|
||||
<build>
|
||||
<language>PHP</language>
|
||||
<package-type>joomla-extension</package-type>
|
||||
<entry-point>source/</entry-point>
|
||||
<entry-point>src/</entry-point>
|
||||
</build>
|
||||
<licensing>
|
||||
<enabled>true</enabled>
|
||||
<dlid>true</dlid>
|
||||
<update-server>https://git.mokoconsulting.tech/{org}/{repo}/updates.xml</update-server>
|
||||
</licensing>
|
||||
</mokoplatform>
|
||||
</moko-platform>
|
||||
|
||||
@@ -1,66 +1,85 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: moko-platform.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||
# PATH: /.mokogitea/workflows/auto-bump.yml
|
||||
# VERSION: 09.02.00
|
||||
# BRIEF: Auto patch-bump version on every push to dev (skips merge commits)
|
||||
|
||||
name: "Universal: Auto Version Bump"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- rc
|
||||
- 'feature/**'
|
||||
- 'patch/**'
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
name: Version Bump
|
||||
runs-on: release
|
||||
if: >-
|
||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||
!contains(github.event.head_commit.message, '[skip bump]') &&
|
||||
!startsWith(github.event.head_commit.message, 'Merge pull request')
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup moko-platform tools
|
||||
run: |
|
||||
if ! command -v composer &> /dev/null; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||
fi
|
||||
if [ -d "/opt/moko-platform/cli" ]; then
|
||||
echo "MOKO_CLI=/opt/moko-platform/cli" >> "$GITHUB_ENV"
|
||||
else
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/MokoConsulting/moko-platform.git" \
|
||||
/tmp/moko-platform-api
|
||||
cd /tmp/moko-platform-api && composer install --no-dev --no-interaction --quiet
|
||||
echo "MOKO_CLI=/tmp/moko-platform-api/cli" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Bump version
|
||||
run: |
|
||||
php ${MOKO_CLI}/version_auto_bump.php \
|
||||
--path . --branch "${GITHUB_REF_NAME}" \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
--repo-url "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: moko-platform.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||
# PATH: /.mokogitea/workflows/auto-bump.yml
|
||||
# VERSION: 09.02.00
|
||||
# BRIEF: Auto patch-bump version on every push to dev (skips merge commits)
|
||||
|
||||
name: "Universal: Auto Version Bump"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
name: Version Bump
|
||||
runs-on: release
|
||||
if: >-
|
||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||
!contains(github.event.head_commit.message, '[skip bump]') &&
|
||||
!startsWith(github.event.head_commit.message, 'Merge pull request')
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup moko-platform tools
|
||||
run: |
|
||||
if ! command -v composer &> /dev/null; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||
fi
|
||||
if [ -d "/opt/moko-platform/cli" ]; then
|
||||
echo "MOKO_CLI=/opt/moko-platform/cli" >> "$GITHUB_ENV"
|
||||
else
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/MokoConsulting/moko-platform.git" \
|
||||
/tmp/moko-platform-api
|
||||
cd /tmp/moko-platform-api && composer install --no-dev --no-interaction --quiet
|
||||
echo "MOKO_CLI=/tmp/moko-platform-api/cli" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Bump version
|
||||
run: |
|
||||
BUMP=$(php ${MOKO_CLI}/version_bump.php --path . 2>&1) || true
|
||||
echo "$BUMP"
|
||||
|
||||
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null) || true
|
||||
[ -z "$VERSION" ] && { echo "No version found — skipping"; exit 0; }
|
||||
|
||||
# Propagate to platform manifests with -dev suffix
|
||||
php ${MOKO_CLI}/version_set_platform.php \
|
||||
--path . --version "$VERSION" --branch dev --stability dev 2>/dev/null || true
|
||||
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
||||
VERSION="${VERSION}-dev"
|
||||
|
||||
# Commit if anything changed
|
||||
if git diff --quiet && git diff --cached --quiet; then
|
||||
echo "No version changes to commit"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||
git config --local user.name "gitea-actions[bot]"
|
||||
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||
git add -A
|
||||
git commit -m "chore(version): auto-bump patch ${VERSION} [skip ci]" \
|
||||
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
||||
git push origin dev
|
||||
echo "Bumped to ${VERSION}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: mokoplatform.Release
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/mokoplatform
|
||||
# INGROUP: moko-platform.Release
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/moko-platform
|
||||
# PATH: /templates/workflows/universal/auto-release.yml.template
|
||||
# VERSION: 05.00.00
|
||||
# BRIEF: Universal build & release � detects platform from manifest.xml
|
||||
@@ -17,7 +17,7 @@
|
||||
# | Reads manifest.xml (joomla|dolibarr|generic) to branch logic. |
|
||||
# | |
|
||||
# | Platform-specific: |
|
||||
# | joomla: XML manifest, type-prefixed packages |
|
||||
# | joomla: XML manifest, updates.xml, type-prefixed packages |
|
||||
# | dolibarr: mod*.class.php, update.txt, dev version reset |
|
||||
# | generic: README-only, no update stream |
|
||||
# | |
|
||||
@@ -51,12 +51,12 @@ permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
# ── PR Opened → Rename branch to RC and build RC release ─────────────────────
|
||||
# ── Draft PR → Promote highest pre-release to RC ─────────────────────────────
|
||||
promote-rc:
|
||||
name: Promote to RC
|
||||
name: Promote Pre-Release to RC
|
||||
runs-on: release
|
||||
if: >-
|
||||
(github.event.action == 'opened' && github.event.pull_request.merged != true) ||
|
||||
(github.event.action == 'opened' && github.event.pull_request.draft == true) ||
|
||||
(github.event_name == 'workflow_dispatch' && inputs.action == 'promote-rc')
|
||||
|
||||
steps:
|
||||
@@ -66,54 +66,45 @@ jobs:
|
||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup mokoplatform tools
|
||||
- name: Setup moko-platform tools
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
run: |
|
||||
if [ -f /opt/mokoplatform/cli/version_bump.php ] && [ -f /opt/mokoplatform/vendor/autoload.php ]; then
|
||||
echo Using pre-installed /opt/mokoplatform
|
||||
echo MOKO_CLI=/opt/mokoplatform/cli >> $GITHUB_ENV
|
||||
else
|
||||
echo Falling back to fresh clone
|
||||
if ! command -v composer > /dev/null 2>&1; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokoplatform-api
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokoplatform.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokoplatform-api
|
||||
cd /tmp/mokoplatform-api
|
||||
composer install --no-dev --no-interaction --quiet
|
||||
echo MOKO_CLI=/tmp/mokoplatform-api/cli >> $GITHUB_ENV
|
||||
if ! command -v composer &> /dev/null; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||
fi
|
||||
# Always fetch latest CLI tools — never use stale cache from previous runs
|
||||
rm -rf /tmp/moko-platform-api
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||
/tmp/moko-platform-api
|
||||
cd /tmp/moko-platform-api
|
||||
composer install --no-dev --no-interaction --quiet
|
||||
|
||||
- name: Rename branch to rc
|
||||
- name: Promote to release-candidate
|
||||
run: |
|
||||
php ${MOKO_CLI}/branch_rename.php \
|
||||
--from "${{ github.event.pull_request.head.ref || 'dev' }}" --to rc \
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php /tmp/moko-platform-api/cli/release_promote.php \
|
||||
--from auto --to release-candidate \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
--api-base "${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}" \
|
||||
--pr "${{ github.event.pull_request.number }}"
|
||||
--api-base "${API_BASE}" \
|
||||
--branch "${{ github.event.pull_request.head.ref || 'dev' }}"
|
||||
|
||||
- name: Checkout rc and configure git
|
||||
- name: Cascade lesser channels
|
||||
continue-on-error: true
|
||||
run: |
|
||||
git fetch origin rc
|
||||
git checkout rc
|
||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||
git config --local user.name "gitea-actions[bot]"
|
||||
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||
|
||||
- name: Publish RC release
|
||||
run: |
|
||||
php ${MOKO_CLI}/release_publish.php \
|
||||
--path . --stability rc --bump minor --branch rc \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}"
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php /tmp/moko-platform-api/cli/release_cascade.php \
|
||||
--stability release-candidate \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
--api-base "${API_BASE}"
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
run: |
|
||||
echo "## Promoted to Release Candidate" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Branch renamed to rc, minor bump, RC release built" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Draft PR opened — promoted highest pre-release to RC" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# ── Merged PR → Build & Release (or promote RC to stable) ────────────────────
|
||||
release:
|
||||
@@ -136,80 +127,288 @@ jobs:
|
||||
git config --local user.name "gitea-actions[bot]"
|
||||
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||
|
||||
- name: Check for merge conflict markers
|
||||
run: |
|
||||
CONFLICTS=$(grep -rn '<<<<<<< \|>>>>>>> \|^=======$' --include='*.php' --include='*.xml' --include='*.css' --include='*.js' --include='*.json' --include='*.md' --include='*.yml' --include='*.yaml' --include='*.ini' --include='*.txt' . 2>/dev/null | grep -v '.git/' || true)
|
||||
if [ -n "$CONFLICTS" ]; then
|
||||
echo "::error::Merge conflict markers found — aborting release"
|
||||
echo "## Release Blocked: Conflict Markers" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
echo "$CONFLICTS" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
exit 1
|
||||
fi
|
||||
echo "No conflict markers found"
|
||||
|
||||
- name: Setup mokoplatform tools
|
||||
- name: Setup moko-platform tools
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_MIRROR_TOKEN }}"}}'
|
||||
run: |
|
||||
if [ -f /opt/mokoplatform/cli/version_bump.php ] && [ -f /opt/mokoplatform/vendor/autoload.php ]; then
|
||||
echo Using pre-installed /opt/mokoplatform
|
||||
echo MOKO_CLI=/opt/mokoplatform/cli >> $GITHUB_ENV
|
||||
else
|
||||
echo Falling back to fresh clone
|
||||
if ! command -v composer > /dev/null 2>&1; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokoplatform-api
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokoplatform.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokoplatform-api
|
||||
cd /tmp/mokoplatform-api
|
||||
composer install --no-dev --no-interaction --quiet
|
||||
echo MOKO_CLI=/tmp/mokoplatform-api/cli >> $GITHUB_ENV
|
||||
# Ensure PHP + Composer are available
|
||||
if ! command -v composer &> /dev/null; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||
fi
|
||||
# Always fetch latest CLI tools — never use stale cache from previous runs
|
||||
rm -rf /tmp/moko-platform-api
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||
/tmp/moko-platform-api
|
||||
cd /tmp/moko-platform-api
|
||||
composer install --no-dev --no-interaction --quiet
|
||||
|
||||
- name: "Publish stable release"
|
||||
|
||||
# -- PLATFORM DETECTION ---------------------------------------------------
|
||||
- name: Detect platform
|
||||
id: platform
|
||||
run: |
|
||||
php ${MOKO_CLI}/release_publish.php \
|
||||
--path . --stability stable --bump minor --branch main \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}"
|
||||
php /tmp/moko-platform-api/cli/manifest_read.php --path . --github-output
|
||||
MANIFEST=$(find . -maxdepth 3 -name "*.xml" ! -path "./.git/*" -exec grep -l '<extension' {} \; 2>/dev/null | head -1 || true)
|
||||
MOD_FILE=$(find . -maxdepth 4 -name "mod*.class.php" ! -path "./.git/*" -exec grep -l 'extends DolibarrModules' {} \; 2>/dev/null | head -1 || true)
|
||||
echo "manifest=${MANIFEST}" >> "$GITHUB_OUTPUT"
|
||||
echo "mod_file=${MOD_FILE}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Update release notes from CHANGELOG.md
|
||||
- name: "Step 1: Read version"
|
||||
id: version
|
||||
run: |
|
||||
VERSION=$(php /tmp/moko-platform-api/cli/version_read.php --path .)
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "::error::No VERSION in README.md"
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
# Strip any pre-release suffix merged from dev (e.g. 01.02.20-dev → 01.02.20)
|
||||
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
||||
MAJOR=$(echo "$VERSION" | cut -d. -f1)
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "release_tag=stable" >> "$GITHUB_OUTPUT"
|
||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||
echo "branch=main" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# -- CHECK FOR RC PROMOTION ------------------------------------------------
|
||||
- name: "Check for RC release"
|
||||
id: rc
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
run: |
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
RC_JSON=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
"${API_BASE}/releases/tags/release-candidate" 2>/dev/null || echo "{}")
|
||||
RC_ID=$(echo "$RC_JSON" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('id',''))" 2>/dev/null || true)
|
||||
|
||||
# Extract [Unreleased] section from changelog
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
||||
[ -z "$NOTES" ] && NOTES="Stable release"
|
||||
if [ -n "$RC_ID" ] && [ "$RC_ID" != "None" ] && [ "$RC_ID" != "" ]; then
|
||||
echo "promote=true" >> "$GITHUB_OUTPUT"
|
||||
echo "release_id=${RC_ID}" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice::RC release found (id: ${RC_ID}) — will promote to stable"
|
||||
else
|
||||
NOTES="Stable release"
|
||||
echo "promote=false" >> "$GITHUB_OUTPUT"
|
||||
echo "::notice::No RC release — full build pipeline"
|
||||
fi
|
||||
|
||||
# Update release body via API
|
||||
RELEASE_ID=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
"${API_BASE}/releases/tags/stable" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
||||
- name: "Step 1b: Minor bump version"
|
||||
id: bump
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.rc.outputs.promote != 'true'
|
||||
run: |
|
||||
MOKO_API="/tmp/moko-platform-api/cli"
|
||||
php ${MOKO_API}/version_bump.php --path . --minor 2>&1 || true
|
||||
VERSION=$(php ${MOKO_API}/version_read.php --path .)
|
||||
# Strip any pre-release suffix — stable releases have no suffix
|
||||
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "Bumped to: ${VERSION}"
|
||||
|
||||
if [ -n "$RELEASE_ID" ]; then
|
||||
python3 -c "
|
||||
import json, urllib.request
|
||||
body = open('/dev/stdin').read()
|
||||
payload = json.dumps({'body': body}).encode()
|
||||
req = urllib.request.Request(
|
||||
'${API_BASE}/releases/${RELEASE_ID}',
|
||||
data=payload, method='PATCH',
|
||||
headers={
|
||||
'Authorization': 'token ${{ secrets.MOKOGITEA_TOKEN }}',
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
urllib.request.urlopen(req)
|
||||
" <<< "$NOTES"
|
||||
echo "Release notes updated from CHANGELOG.md"
|
||||
- name: Check if already released
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
id: check
|
||||
run: |
|
||||
TAG="${{ steps.version.outputs.release_tag }}"
|
||||
BRANCH="${{ steps.version.outputs.branch }}"
|
||||
|
||||
TAG_EXISTS=false
|
||||
BRANCH_EXISTS=false
|
||||
|
||||
git rev-parse "$TAG" >/dev/null 2>&1 && TAG_EXISTS=true
|
||||
git ls-remote --heads origin "$BRANCH" 2>/dev/null | grep -q "$BRANCH" && BRANCH_EXISTS=true
|
||||
|
||||
echo "tag_exists=$TAG_EXISTS" >> "$GITHUB_OUTPUT"
|
||||
echo "branch_exists=$BRANCH_EXISTS" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Tag and branch may persist across patch releases — never skip
|
||||
echo "already_released=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# -- SANITY CHECKS -------------------------------------------------------
|
||||
- name: "Sanity: Pre-release validation"
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.check.outputs.already_released != 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
php /tmp/moko-platform-api/cli/release_validate.php \
|
||||
--path . --version "$VERSION" --output-summary --github-output || true
|
||||
|
||||
# -- STEP 2: Create or update version/XX.YY archive branch ---------------
|
||||
# Always runs — every version change on main archives to version/XX.YY
|
||||
- name: "Step 2: Version archive branch"
|
||||
if: steps.check.outputs.already_released != 'true'
|
||||
run: |
|
||||
BRANCH="${{ steps.version.outputs.branch }}"
|
||||
IS_MINOR="${{ steps.version.outputs.is_minor }}"
|
||||
PATCH="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
PATCH_NUM=$(echo "$PATCH" | awk -F. '{print $3}')
|
||||
|
||||
# Check if branch exists
|
||||
if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
|
||||
git push origin HEAD:"$BRANCH" --force
|
||||
echo "Updated archive branch: ${BRANCH} (patch ${PATCH_NUM})" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
git checkout -b "$BRANCH" 2>/dev/null || git checkout "$BRANCH"
|
||||
git push origin "$BRANCH" --force
|
||||
echo "Created archive branch: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
# -- STEP 3: Set platform version ----------------------------------------
|
||||
- name: "Step 3: Set platform version"
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.check.outputs.already_released != 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
php /tmp/moko-platform-api/cli/version_set_platform.php \
|
||||
--path . --version "$VERSION" --branch main
|
||||
|
||||
# -- STEP 4: Update version badges ----------------------------------------
|
||||
- name: "Step 4: Update version badges"
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
php /tmp/moko-platform-api/cli/badge_update.php --path . --version "${VERSION}" 2>/dev/null || true
|
||||
php /tmp/moko-platform-api/cli/version_check.php --path . --fix 2>/dev/null || true
|
||||
|
||||
# Step 5 (updates.xml) moved after Step 8 to include SHA-256 checksum
|
||||
|
||||
- name: "Step 4b: Promote and prune CHANGELOG"
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.check.outputs.already_released != 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
MOKO_API="/tmp/moko-platform-api/cli"
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
php ${MOKO_API}/changelog_promote.php --path . --version "$VERSION" 2>&1 || true
|
||||
php ${MOKO_API}/changelog_prune.php --path . --keep 5 2>&1 || true
|
||||
fi
|
||||
|
||||
- name: Commit release changes
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.check.outputs.already_released != 'true'
|
||||
run: |
|
||||
if git diff --quiet && git diff --cached --quiet; then
|
||||
echo "No changes to commit"
|
||||
exit 0
|
||||
fi
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
git add -A
|
||||
git commit -m "chore(release): build ${VERSION} [skip ci]" \
|
||||
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
||||
# Detached HEAD on PR merge — push explicitly to main
|
||||
git push origin HEAD:refs/heads/main
|
||||
|
||||
# -- STEP 6: Create tag ---------------------------------------------------
|
||||
- name: "Step 6: Create git tag"
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true'
|
||||
run: |
|
||||
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
|
||||
# Only create the major release tag if it doesn't exist yet
|
||||
if ! git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
|
||||
git tag "$RELEASE_TAG"
|
||||
git push origin "$RELEASE_TAG"
|
||||
echo "Tag created: ${RELEASE_TAG}" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "Tag ${RELEASE_TAG} already exists" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
echo "Tag: ${TAG}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# -- STEP 7a: Promote RC to stable (skip build) ----------------------------
|
||||
- name: "Step 7a: Promote RC to stable"
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.rc.outputs.promote == 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php /tmp/moko-platform-api/cli/release_promote.php \
|
||||
--from release-candidate --to stable \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
--api-base "${API_BASE}" \
|
||||
--path . --branch main
|
||||
echo "Promoted RC → stable (${VERSION})" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# -- STEP 7b: Create or update Gitea Release (full build path) -------------
|
||||
- name: "Step 7b: Gitea Release"
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.rc.outputs.promote != 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php /tmp/moko-platform-api/cli/release_create.php \
|
||||
--path . --version "$VERSION" --tag "$RELEASE_TAG" \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||
--repo "${GITEA_REPO}" --branch main
|
||||
echo "Release created: ${VERSION}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# -- STEP 8: Build packages and upload to release ----------------------------
|
||||
- name: "Step 8: Build package and upload"
|
||||
id: package
|
||||
if: >-
|
||||
steps.version.outputs.skip != 'true' &&
|
||||
steps.rc.outputs.promote != 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php /tmp/moko-platform-api/cli/release_package.php \
|
||||
--path . --version "$VERSION" --tag "$RELEASE_TAG" \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||
--repo "${GITEA_REPO}" --output /tmp || true
|
||||
|
||||
# -- STEP 5: Write update stream (after build so SHA-256 is available) -----
|
||||
- name: "Step 5: Write update stream"
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||
|
||||
# Fetch latest updates.xml from main so preserve logic has all channels
|
||||
GITEA_TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
||||
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
|
||||
curl -sf -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/contents/updates.xml?ref=main" 2>/dev/null | \
|
||||
python3 -c "import sys,json,base64; print(base64.b64decode(json.load(sys.stdin)['content']).decode())" \
|
||||
> updates.xml 2>/dev/null || true
|
||||
|
||||
SHA_FLAG=""
|
||||
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
||||
|
||||
php /tmp/moko-platform-api/cli/updates_xml_build.php \
|
||||
--path . --version "${VERSION}" --stability stable \
|
||||
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
||||
${SHA_FLAG} --github-output
|
||||
|
||||
# Commit updates.xml if changed
|
||||
if ! git diff --quiet updates.xml 2>/dev/null; then
|
||||
git add updates.xml
|
||||
git commit -m "chore: update stable channel ${VERSION} [skip ci]" \
|
||||
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
||||
git push origin HEAD:refs/heads/main 2>&1 || true
|
||||
fi
|
||||
|
||||
# -- STEP 8b: Update release description with changelog ----------------------
|
||||
- name: "Step 8b: Update release body"
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
|
||||
php /tmp/moko-platform-api/cli/release_body_update.php \
|
||||
--path . --version "${VERSION}" --tag "${RELEASE_TAG}" \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
||||
2>&1 || true
|
||||
echo "Release body updated" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# -- STEP 9: Mirror to GitHub (stable only) --------------------------------
|
||||
- name: "Step 9: Mirror release to GitHub"
|
||||
if: >-
|
||||
@@ -221,7 +420,7 @@ jobs:
|
||||
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
|
||||
GH_REPO="${{ vars.GH_MIRROR_REPO || github.repository }}"
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php ${MOKO_CLI}/release_mirror.php \
|
||||
php /tmp/moko-platform-api/cli/release_mirror.php \
|
||||
--version "$VERSION" --tag "$RELEASE_TAG" \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||
--gh-token "${{ secrets.GH_MIRROR_TOKEN }}" --gh-repo "$GH_REPO" \
|
||||
@@ -245,18 +444,26 @@ jobs:
|
||||
&& echo "main branch pushed to GitHub mirror" \
|
||||
|| echo "WARNING: GitHub mirror push failed"
|
||||
|
||||
- name: "Step 11: Delete rc branch and recreate dev from main"
|
||||
# -- Clean up lesser pre-releases (cascade) ---------------------------------
|
||||
# stable → deletes all | rc → beta,alpha,dev | beta → alpha,dev | alpha → dev
|
||||
- name: "Delete lesser pre-release channels"
|
||||
continue-on-error: true
|
||||
run: |
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php /tmp/moko-platform-api/cli/release_cascade.php \
|
||||
--stability stable \
|
||||
--version "${VERSION}" \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
--api-base "${API_BASE}" 2>/dev/null || true
|
||||
|
||||
- name: "Step 11: Delete and recreate dev branch from main"
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
||||
|
||||
# Delete rc branch (ephemeral — created by promote-rc)
|
||||
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" \
|
||||
"${API_BASE}/branches/rc" 2>/dev/null \
|
||||
&& echo "Deleted rc branch" || echo "rc branch not found"
|
||||
|
||||
# Delete dev branch
|
||||
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" \
|
||||
"${API_BASE}/branches/dev" 2>/dev/null && echo "Deleted dev branch"
|
||||
@@ -267,7 +474,7 @@ jobs:
|
||||
"${API_BASE}/branches" \
|
||||
-d '{"new_branch_name":"dev","old_branch_name":"main"}' 2>/dev/null && echo "Recreated dev from main"
|
||||
|
||||
echo "Pre-release branches cleaned, dev reset from main" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Dev branch reset from main (keeps dev ahead after release)" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: "Step 12: Create version branch from main"
|
||||
if: steps.version.outputs.skip != 'true'
|
||||
@@ -295,7 +502,7 @@ jobs:
|
||||
continue-on-error: true
|
||||
run: |
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
php ${MOKO_CLI}/version_reset_dev.php \
|
||||
php /tmp/moko-platform-api/cli/version_reset_dev.php \
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "${API_BASE}" \
|
||||
--branch dev --path . 2>&1 || true
|
||||
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: MokoStandards.Universal
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||
# PATH: /.mokogitea/workflows/branch-cleanup.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Delete feature branches after PR merge
|
||||
|
||||
name: "Branch Cleanup"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
name: Delete merged branch
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
github.event.pull_request.merged == true &&
|
||||
github.event.pull_request.head.ref != 'dev' &&
|
||||
github.event.pull_request.head.ref != 'main'
|
||||
|
||||
steps:
|
||||
- name: Delete source branch
|
||||
run: |
|
||||
BRANCH="${{ github.event.pull_request.head.ref }}"
|
||||
API="${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}/api/v1/repos/${{ github.repository }}/branches"
|
||||
ENCODED=$(php -r "echo rawurlencode('${BRANCH}');")
|
||||
|
||||
STATUS=$(curl -sf -o /dev/null -w "%{http_code}" -X DELETE \
|
||||
-H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
"${API}/${ENCODED}" 2>/dev/null || true)
|
||||
|
||||
if [ "$STATUS" = "204" ]; then
|
||||
echo "Deleted branch: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
|
||||
elif [ "$STATUS" = "404" ]; then
|
||||
echo "Branch already deleted: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "::warning::Failed to delete branch ${BRANCH} (HTTP ${STATUS})"
|
||||
fi
|
||||
@@ -1,10 +1,213 @@
|
||||
# DISABLED — auto-release Step 11 recreates dev from main after every release.
|
||||
# Cascade-dev is redundant and causes version conflicts when both main and dev
|
||||
# have different version numbers in templateDetails.xml / manifest.xml.
|
||||
name: "Cascade Main → Dev (DISABLED)"
|
||||
on: workflow_dispatch
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: moko-platform.Maintenance
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/moko-platform
|
||||
# PATH: /templates/workflows/cascade-dev.yml.template
|
||||
# VERSION: 02.00.00
|
||||
# BRIEF: Forward-merge main → all open branches after every push to main
|
||||
#
|
||||
# +========================================================================+
|
||||
# | CASCADE MAIN → ALL BRANCHES |
|
||||
# +========================================================================+
|
||||
# | |
|
||||
# | Triggers on every push to main (PR merges, bot commits, etc.) |
|
||||
# | |
|
||||
# | 1. List all branches matching: dev, rc/*, beta/*, alpha/* |
|
||||
# | 2. For each: create PR (main → branch), auto-merge if clean |
|
||||
# | 3. On conflict: leave PR open for manual resolution |
|
||||
# | |
|
||||
# +========================================================================+
|
||||
|
||||
name: "Universal: Cascade Main → Dev"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
||||
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
noop:
|
||||
cascade:
|
||||
name: Cascade main → branches
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||
!contains(github.event.head_commit.message, '[skip cascade]')
|
||||
|
||||
steps:
|
||||
- run: echo "Cascade disabled — auto-release handles dev recreation"
|
||||
- name: Discover target branches
|
||||
id: branches
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
run: |
|
||||
API="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
|
||||
# Fetch all branches (paginated)
|
||||
PAGE=1
|
||||
ALL_BRANCHES=""
|
||||
while true; do
|
||||
BATCH=$(curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/branches?page=${PAGE}&limit=50" \
|
||||
| jq -r '.[].name // empty')
|
||||
[ -z "$BATCH" ] && break
|
||||
ALL_BRANCHES="$ALL_BRANCHES $BATCH"
|
||||
PAGE=$((PAGE + 1))
|
||||
done
|
||||
|
||||
# Filter to cascade targets: dev, dev/*, rc/*, beta/*, alpha/*
|
||||
TARGETS=""
|
||||
for BRANCH in $ALL_BRANCHES; do
|
||||
case "$BRANCH" in
|
||||
dev|dev/*|rc/*|beta/*|alpha/*)
|
||||
TARGETS="$TARGETS $BRANCH"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
TARGETS=$(echo "$TARGETS" | xargs) # trim whitespace
|
||||
|
||||
if [ -z "$TARGETS" ]; then
|
||||
echo "targets=" >> "$GITHUB_OUTPUT"
|
||||
echo "ℹ️ No cascade target branches found"
|
||||
else
|
||||
echo "targets=$TARGETS" >> "$GITHUB_OUTPUT"
|
||||
COUNT=$(echo "$TARGETS" | wc -w)
|
||||
echo "📋 Found ${COUNT} target branch(es): ${TARGETS}"
|
||||
fi
|
||||
|
||||
- name: Cascade to all target branches
|
||||
if: steps.branches.outputs.targets != ''
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
run: |
|
||||
API="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
SHORT_SHA="${GITHUB_SHA:0:7}"
|
||||
TARGETS="${{ steps.branches.outputs.targets }}"
|
||||
|
||||
SUCCESS=0
|
||||
CONFLICTS=0
|
||||
SKIPPED=0
|
||||
FAILED=0
|
||||
|
||||
for BRANCH in $TARGETS; do
|
||||
echo ""
|
||||
echo "═══ main → ${BRANCH} ═══"
|
||||
|
||||
# Check if branch is already up to date
|
||||
ENCODED_BRANCH=$(echo "$BRANCH" | sed 's|/|%2F|g')
|
||||
RESPONSE=$(curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/compare/${ENCODED_BRANCH}...main")
|
||||
|
||||
AHEAD=$(echo "$RESPONSE" | jq '.total_commits // 0')
|
||||
|
||||
if [ "$AHEAD" -eq 0 ]; then
|
||||
echo " ✅ Already up to date"
|
||||
SKIPPED=$((SKIPPED + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
echo " ℹ️ main is ${AHEAD} commit(s) ahead"
|
||||
|
||||
# Check for existing cascade PR
|
||||
EXISTING=$(curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/pulls?state=open&head=${GITEA_ORG}:main&base=${ENCODED_BRANCH}&limit=1")
|
||||
|
||||
EXISTING_COUNT=$(echo "$EXISTING" | jq 'length')
|
||||
PR_NUMBER=""
|
||||
|
||||
if [ "$EXISTING_COUNT" -gt 0 ]; then
|
||||
PR_NUMBER=$(echo "$EXISTING" | jq -r '.[0].number')
|
||||
echo " ℹ️ Reusing existing PR #${PR_NUMBER}"
|
||||
else
|
||||
# Create cascade PR
|
||||
PR_RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"chore: cascade main → ${BRANCH} (${SHORT_SHA}) [skip ci]\",
|
||||
\"body\": \"## Automatic cascade\\n\\nForward-merging \`main\` (${SHORT_SHA}) into \`${BRANCH}\`.\\n\\nIf conflicts exist, resolve manually and merge.\\n\\n> Auto-created by **Cascade Main → Dev**.\",
|
||||
\"head\": \"main\",
|
||||
\"base\": \"${BRANCH}\"
|
||||
}" \
|
||||
"${API}/pulls")
|
||||
|
||||
HTTP_CODE=$(echo "$PR_RESPONSE" | tail -1)
|
||||
BODY=$(echo "$PR_RESPONSE" | sed '$d')
|
||||
PR_NUMBER=$(echo "$BODY" | jq -r '.number // empty')
|
||||
|
||||
if [ "$HTTP_CODE" != "201" ] || [ -z "$PR_NUMBER" ]; then
|
||||
MSG=$(echo "$BODY" | jq -r '.message // .' 2>/dev/null | head -1)
|
||||
echo " ❌ Failed to create PR (HTTP ${HTTP_CODE}): ${MSG}"
|
||||
FAILED=$((FAILED + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
echo " ✅ Created PR #${PR_NUMBER}"
|
||||
fi
|
||||
|
||||
# Try auto-merge
|
||||
PR_DATA=$(curl -sS \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/pulls/${PR_NUMBER}")
|
||||
|
||||
MERGEABLE=$(echo "$PR_DATA" | jq -r '.mergeable // false')
|
||||
|
||||
if [ "$MERGEABLE" != "true" ]; then
|
||||
echo " ⚠️ Conflicts — PR #${PR_NUMBER} left open"
|
||||
CONFLICTS=$((CONFLICTS + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
MERGE_RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"Do\": \"merge\",
|
||||
\"merge_message_field\": \"chore: cascade main → ${BRANCH} [skip ci]\",
|
||||
\"delete_branch_after_merge\": false
|
||||
}" \
|
||||
"${API}/pulls/${PR_NUMBER}/merge")
|
||||
|
||||
MERGE_HTTP=$(echo "$MERGE_RESPONSE" | tail -1)
|
||||
|
||||
if [ "$MERGE_HTTP" = "200" ] || [ "$MERGE_HTTP" = "204" ]; then
|
||||
echo " ✅ Merged — ${BRANCH} is in sync"
|
||||
SUCCESS=$((SUCCESS + 1))
|
||||
else
|
||||
MERGE_BODY=$(echo "$MERGE_RESPONSE" | sed '$d')
|
||||
echo " ⚠️ Merge failed (HTTP ${MERGE_HTTP}) — PR #${PR_NUMBER} left open"
|
||||
CONFLICTS=$((CONFLICTS + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "════════════════════════════════════════"
|
||||
echo " ✅ Merged: ${SUCCESS}"
|
||||
echo " ⚠️ Conflicts: ${CONFLICTS}"
|
||||
echo " ⏭️ Up to date: ${SKIPPED}"
|
||||
echo " ❌ Failed: ${FAILED}"
|
||||
echo "════════════════════════════════════════"
|
||||
|
||||
if [ "$FAILED" -gt 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: MokoStandards.CI
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
||||
# PATH: /.gitea/workflows/ci-generic.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: CI pipeline — lint, validate, and test for generic projects (PHP + Node.js)
|
||||
|
||||
name: "Generic: Project CI"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
- dev/**
|
||||
- rc/**
|
||||
- version/**
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
- dev/**
|
||||
- rc/**
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
# ── Lint & Validate ───────────────────────────────────────────────────
|
||||
lint:
|
||||
name: Lint & Validate
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Detect toolchain
|
||||
id: detect
|
||||
run: |
|
||||
HAS_PHP=false
|
||||
HAS_NODE=false
|
||||
[ -f "composer.json" ] && HAS_PHP=true
|
||||
[ -f "package.json" ] && HAS_NODE=true
|
||||
echo "has_php=$HAS_PHP" >> "$GITHUB_OUTPUT"
|
||||
echo "has_node=$HAS_NODE" >> "$GITHUB_OUTPUT"
|
||||
echo "Toolchain: PHP=$HAS_PHP Node=$HAS_NODE"
|
||||
|
||||
- name: Setup PHP
|
||||
if: steps.detect.outputs.has_php == 'true'
|
||||
run: |
|
||||
if ! command -v php &> /dev/null; then
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq php-cli php-mbstring php-xml >/dev/null 2>&1
|
||||
fi
|
||||
php -v
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.detect.outputs.has_node == 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install PHP dependencies
|
||||
if: steps.detect.outputs.has_php == 'true'
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
composer install --no-interaction --prefer-dist --quiet 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
if: steps.detect.outputs.has_node == 'true'
|
||||
run: |
|
||||
if [ -f "package.json" ]; then
|
||||
npm ci --quiet 2>/dev/null || npm install --quiet 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: PHP syntax check
|
||||
if: steps.detect.outputs.has_php == 'true'
|
||||
run: |
|
||||
ERRORS=0
|
||||
while IFS= read -r -d '' file; do
|
||||
if ! php -l "$file" 2>&1 | grep -q "No syntax errors"; then
|
||||
echo "::error file=${file}::PHP syntax error"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
done < <(find . -name "*.php" -not -path "./.git/*" -not -path "./vendor/*" -not -path "./node_modules/*" -print0)
|
||||
|
||||
echo "## PHP Lint" >> $GITHUB_STEP_SUMMARY
|
||||
if [ "$ERRORS" -eq 0 ]; then
|
||||
echo "All PHP files passed syntax check." >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "${ERRORS} file(s) with syntax errors." >> $GITHUB_STEP_SUMMARY
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: TypeScript/JavaScript lint
|
||||
if: steps.detect.outputs.has_node == 'true'
|
||||
run: |
|
||||
if [ -f "node_modules/.bin/eslint" ]; then
|
||||
npx eslint src/ --quiet 2>&1 || { echo "::error::ESLint errors found"; exit 1; }
|
||||
echo "## ESLint" >> $GITHUB_STEP_SUMMARY
|
||||
echo "All files passed ESLint." >> $GITHUB_STEP_SUMMARY
|
||||
elif [ -f ".eslintrc.json" ] || [ -f ".eslintrc.js" ] || [ -f "eslint.config.js" ]; then
|
||||
echo "::warning::ESLint config found but eslint not installed"
|
||||
else
|
||||
echo "No ESLint configured — skipping"
|
||||
fi
|
||||
|
||||
- name: TypeScript compile check
|
||||
if: steps.detect.outputs.has_node == 'true'
|
||||
run: |
|
||||
if [ -f "tsconfig.json" ] && [ -f "node_modules/.bin/tsc" ]; then
|
||||
npx tsc --noEmit 2>&1 || { echo "::error::TypeScript compilation errors"; exit 1; }
|
||||
echo "## TypeScript" >> $GITHUB_STEP_SUMMARY
|
||||
echo "TypeScript compilation passed." >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
- name: PHPStan static analysis
|
||||
if: steps.detect.outputs.has_php == 'true'
|
||||
run: |
|
||||
if [ -f "phpstan.neon" ] && [ -f "vendor/bin/phpstan" ]; then
|
||||
vendor/bin/phpstan analyse --no-progress 2>&1 || { echo "::warning::PHPStan found issues"; }
|
||||
fi
|
||||
|
||||
# ── Tests ─────────────────────────────────────────────────────────────
|
||||
test:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Detect toolchain
|
||||
id: detect
|
||||
run: |
|
||||
HAS_PHP=false
|
||||
HAS_NODE=false
|
||||
[ -f "composer.json" ] && HAS_PHP=true
|
||||
[ -f "package.json" ] && HAS_NODE=true
|
||||
echo "has_php=$HAS_PHP" >> "$GITHUB_OUTPUT"
|
||||
echo "has_node=$HAS_NODE" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup PHP
|
||||
if: steps.detect.outputs.has_php == 'true'
|
||||
run: |
|
||||
if ! command -v php &> /dev/null; then
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq php-cli php-mbstring php-xml >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.detect.outputs.has_node == 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
[ -f "composer.json" ] && composer install --no-interaction --prefer-dist --quiet 2>/dev/null || true
|
||||
[ -f "package.json" ] && { npm ci --quiet 2>/dev/null || npm install --quiet 2>/dev/null || true; }
|
||||
|
||||
- name: Run PHP tests
|
||||
if: steps.detect.outputs.has_php == 'true'
|
||||
run: |
|
||||
if [ -f "vendor/bin/phpunit" ]; then
|
||||
vendor/bin/phpunit --testdox 2>&1
|
||||
echo "## PHPUnit" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Tests passed." >> $GITHUB_STEP_SUMMARY
|
||||
elif [ -f "phpunit.xml" ] || [ -f "phpunit.xml.dist" ]; then
|
||||
echo "::warning::PHPUnit config found but phpunit not installed"
|
||||
else
|
||||
echo "No PHPUnit configured — skipping"
|
||||
fi
|
||||
|
||||
- name: Run Node.js tests
|
||||
if: steps.detect.outputs.has_node == 'true'
|
||||
run: |
|
||||
if jq -e '.scripts.test' package.json > /dev/null 2>&1; then
|
||||
npm test 2>&1
|
||||
echo "## Node.js Tests" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Tests passed." >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "No test script in package.json — skipping"
|
||||
fi
|
||||
|
||||
- name: Build check
|
||||
run: |
|
||||
if [ -f "Makefile" ]; then
|
||||
make build 2>&1 || echo "::warning::Build failed or not configured"
|
||||
elif [ -f "package.json" ] && jq -e '.scripts.build' package.json > /dev/null 2>&1; then
|
||||
npm run build 2>&1 || echo "::warning::Build failed"
|
||||
fi
|
||||
@@ -45,22 +45,19 @@ jobs:
|
||||
fi
|
||||
php -v && composer --version
|
||||
|
||||
- name: Setup moko-platform tools
|
||||
- name: Clone MokoStandards
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN || github.token }}
|
||||
MOKO_CLONE_HOST: ${{ secrets.GA_TOKEN && 'git.mokoconsulting.tech/MokoConsulting' || 'github.com/mokoconsulting-tech' }}
|
||||
GA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN || secrets.MOKOGITEA_TOKEN || github.token }}
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN || secrets.MOKOGITEA_TOKEN || github.token }}
|
||||
MOKO_CLONE_HOST: ${{ secrets.MOKOGITEA_TOKEN && 'git.mokoconsulting.tech/MokoConsulting' || 'github.com/mokoconsulting-tech' }}
|
||||
run: |
|
||||
if [ -d "/tmp/moko-platform" ] || [ -d "/opt/moko-platform" ]; then
|
||||
echo "moko-platform already available on runner — skipping clone"
|
||||
else
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||
/tmp/moko-platform 2>/dev/null || echo "moko-platform clone skipped — continuing without it"
|
||||
fi
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoStandards-API.git" \
|
||||
/tmp/mokostandards-api
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || secrets.GA_TOKEN || github.token }}"}}'
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.MOKOGITEA_TOKEN || github.token }}"}}'
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
composer install \
|
||||
@@ -131,8 +128,8 @@ jobs:
|
||||
echo "Manifest is well-formed XML." >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
# Check required tags: name, version, author
|
||||
for TAG in name version author; do
|
||||
# Check required tags: name, version, author, namespace (Joomla 5+)
|
||||
for TAG in name version author namespace; do
|
||||
if ! grep -q "<${TAG}>" "$MANIFEST" 2>/dev/null; then
|
||||
echo "Missing required tag: \`<${TAG}>\`" >> $GITHUB_STEP_SUMMARY
|
||||
ERRORS=$((ERRORS + 1))
|
||||
@@ -140,19 +137,6 @@ jobs:
|
||||
echo "Found required tag: \`<${TAG}>\`" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
done
|
||||
|
||||
# Namespace is required for components/plugins but not packages
|
||||
EXT_TYPE=$(grep -oP '<extension[^>]*\btype="\K[^"]+' "$MANIFEST" | head -1)
|
||||
if [ "$EXT_TYPE" != "package" ]; then
|
||||
if ! grep -q "<namespace" "$MANIFEST" 2>/dev/null; then
|
||||
echo "Missing required tag: \`<namespace>\` (required for Joomla 5+ ${EXT_TYPE} extensions)" >> $GITHUB_STEP_SUMMARY
|
||||
ERRORS=$((ERRORS + 1))
|
||||
else
|
||||
echo "Found required tag: \`<namespace>\`" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
else
|
||||
echo "Package extension — \`<namespace>\` not required." >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${ERRORS}" -gt 0 ]; then
|
||||
@@ -370,7 +354,7 @@ jobs:
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || secrets.GA_TOKEN || github.token }}"}}'
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.MOKOGITEA_TOKEN || github.token }}"}}'
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
composer install \
|
||||
@@ -420,7 +404,7 @@ jobs:
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || secrets.GA_TOKEN || github.token }}"}}'
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.MOKOGITEA_TOKEN || github.token }}"}}'
|
||||
run: |
|
||||
if [ -f "composer.json" ]; then
|
||||
composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||
@@ -477,24 +461,3 @@ jobs:
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
exit $EXIT
|
||||
|
||||
pre-release:
|
||||
name: Build RC Pre-Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: [lint-and-validate, test]
|
||||
if: github.event_name == 'pull_request'
|
||||
|
||||
steps:
|
||||
- name: Trigger pre-release build
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH: ${{ github.head_ref }}
|
||||
run: |
|
||||
curl -s -X POST \
|
||||
"${GITEA_URL:-https://git.mokoconsulting.tech}/api/v1/repos/${REPO}/actions/workflows/pre-release.yml/dispatches" \
|
||||
-H "Authorization: token ${GA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"ref\":\"${BRANCH}\",\"inputs\":{\"stability\":\"release-candidate\"}}"
|
||||
echo "### Pre-Release" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Triggered RC build on branch \`${BRANCH}\`" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: MokoStandards.Maintenance
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
||||
# PATH: /.gitea/workflows/cleanup.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Scheduled cleanup — delete merged branches and old workflow runs
|
||||
|
||||
name: "Universal: Repository Cleanup"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 3 * * 0' # Weekly on Sunday at 03:00 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
name: Clean Merged Branches
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GA_TOKEN }}
|
||||
|
||||
- name: Delete merged branches
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||
run: |
|
||||
echo "=== Merged Branch Cleanup ==="
|
||||
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
|
||||
|
||||
# List branches via API
|
||||
BRANCHES=$(curl -sS -H "Authorization: token ${GA_TOKEN}" \
|
||||
"${API}/branches?limit=50" | jq -r '.[].name')
|
||||
|
||||
DELETED=0
|
||||
for BRANCH in $BRANCHES; do
|
||||
# Skip protected branches
|
||||
case "$BRANCH" in
|
||||
main|master|develop|release/*|hotfix/*) continue ;;
|
||||
esac
|
||||
|
||||
# Check if branch is merged into main
|
||||
if git merge-base --is-ancestor "origin/${BRANCH}" origin/main 2>/dev/null; then
|
||||
echo " Deleting merged branch: ${BRANCH}"
|
||||
curl -sS -X DELETE -H "Authorization: token ${GA_TOKEN}" \
|
||||
"${API}/branches/${BRANCH}" 2>/dev/null || true
|
||||
DELETED=$((DELETED + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Deleted ${DELETED} merged branch(es)"
|
||||
|
||||
- name: Clean old workflow runs
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||
run: |
|
||||
echo "=== Workflow Run Cleanup ==="
|
||||
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
|
||||
CUTOFF=$(date -d "30 days ago" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -v-30d +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
# Get old completed runs
|
||||
RUNS=$(curl -sS -H "Authorization: token ${GA_TOKEN}" \
|
||||
"${API}/actions/runs?status=completed&limit=50" | \
|
||||
jq -r ".workflow_runs[] | select(.created_at < \"${CUTOFF}\") | .id" 2>/dev/null)
|
||||
|
||||
DELETED=0
|
||||
for RUN_ID in $RUNS; do
|
||||
curl -sS -X DELETE -H "Authorization: token ${GA_TOKEN}" \
|
||||
"${API}/actions/runs/${RUN_ID}" 2>/dev/null || true
|
||||
DELETED=$((DELETED + 1))
|
||||
done
|
||||
|
||||
echo "Deleted ${DELETED} old workflow run(s)"
|
||||
@@ -1,126 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: MokoStandards.Deploy
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards-API
|
||||
# PATH: /templates/workflows/joomla/deploy-manual.yml.template
|
||||
# VERSION: 04.07.00
|
||||
# BRIEF: Manual SFTP deploy to dev server for Joomla repos
|
||||
|
||||
name: "Universal: Deploy to Dev (Manual)"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
clear_remote:
|
||||
description: 'Delete all remote files before uploading'
|
||||
required: false
|
||||
default: 'false'
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: SFTP Deploy to Dev
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
|
||||
- name: Setup PHP
|
||||
run: |
|
||||
php -v && composer --version
|
||||
|
||||
- name: Setup MokoStandards tools
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
||||
MOKO_CLONE_HOST: ${{ secrets.GA_TOKEN && 'git.mokoconsulting.tech/MokoConsulting' || 'github.com/mokoconsulting-tech' }}
|
||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GA_TOKEN || github.token }}"}}'
|
||||
run: |
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoStandards-API.git" \
|
||||
/tmp/mokostandards-api 2>/dev/null || true
|
||||
if [ -d "/tmp/mokostandards-api" ] && [ -f "/tmp/mokostandards-api/composer.json" ]; then
|
||||
cd /tmp/mokostandards-api && composer install --no-dev --no-interaction --quiet 2>/dev/null || true
|
||||
fi
|
||||
|
||||
- name: Check FTP configuration
|
||||
id: check
|
||||
env:
|
||||
HOST: ${{ vars.DEV_FTP_HOST }}
|
||||
PATH_VAR: ${{ vars.DEV_FTP_PATH }}
|
||||
PORT: ${{ vars.DEV_FTP_PORT }}
|
||||
run: |
|
||||
if [ -z "$HOST" ] || [ -z "$PATH_VAR" ]; then
|
||||
echo "DEV_FTP_HOST or DEV_FTP_PATH not configured -- cannot deploy"
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||
echo "host=$HOST" >> "$GITHUB_OUTPUT"
|
||||
|
||||
REMOTE="${PATH_VAR%/}"
|
||||
echo "remote=$REMOTE" >> "$GITHUB_OUTPUT"
|
||||
|
||||
[ -z "$PORT" ] && PORT="22"
|
||||
echo "port=$PORT" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Deploy via SFTP
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
env:
|
||||
SFTP_KEY: ${{ secrets.DEV_FTP_KEY }}
|
||||
SFTP_PASS: ${{ secrets.DEV_FTP_PASSWORD }}
|
||||
SFTP_USER: ${{ vars.DEV_FTP_USERNAME }}
|
||||
run: |
|
||||
SOURCE_DIR="src"
|
||||
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="htdocs"
|
||||
[ ! -d "$SOURCE_DIR" ] && { echo "No src/ or htdocs/ -- nothing to deploy"; exit 0; }
|
||||
|
||||
printf '{"host":"%s","port":%s,"username":"%s","remotePath":"%s"' \
|
||||
"${{ steps.check.outputs.host }}" "${{ steps.check.outputs.port }}" "$SFTP_USER" "${{ steps.check.outputs.remote }}" \
|
||||
> /tmp/sftp-config.json
|
||||
|
||||
if [ -n "$SFTP_KEY" ]; then
|
||||
echo "$SFTP_KEY" > /tmp/deploy_key
|
||||
chmod 600 /tmp/deploy_key
|
||||
printf ',"privateKeyPath":"/tmp/deploy_key"}' >> /tmp/sftp-config.json
|
||||
else
|
||||
printf ',"password":"%s"}' "$SFTP_PASS" >> /tmp/sftp-config.json
|
||||
fi
|
||||
|
||||
DEPLOY_ARGS=(--path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json)
|
||||
[ "${{ inputs.clear_remote }}" = "true" ] && DEPLOY_ARGS+=(--clear-remote)
|
||||
|
||||
PLATFORM=$(php /tmp/mokostandards-api/cli/platform_detect.php --path . 2>/dev/null || true)
|
||||
if [ "$PLATFORM" = "waas-component" ] && [ -f "/tmp/mokostandards-api/deploy/deploy-joomla.php" ]; then
|
||||
php /tmp/mokostandards-api/deploy/deploy-joomla.php "${DEPLOY_ARGS[@]}"
|
||||
else
|
||||
php /tmp/mokostandards-api/deploy/deploy-sftp.php "${DEPLOY_ARGS[@]}"
|
||||
fi
|
||||
|
||||
rm -f /tmp/deploy_key /tmp/sftp-config.json
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
run: |
|
||||
if [ "${{ steps.check.outputs.skip }}" = "true" ]; then
|
||||
echo "### Deploy Skipped -- FTP not configured" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "### Manual Dev Deploy Complete" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Host | \`${{ steps.check.outputs.host }}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Remote | \`${{ steps.check.outputs.remote }}\` |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Clear | ${{ inputs.clear_remote }} |" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
@@ -1,96 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: MokoStandards.Security
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/MokoStandards-API
|
||||
# PATH: /templates/workflows/gitleaks.yml.template
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Secret scanning — detect leaked credentials, API keys, and tokens
|
||||
#
|
||||
# +========================================================================+
|
||||
# | SECRET SCANNING |
|
||||
# +========================================================================+
|
||||
# | |
|
||||
# | Scans commits for leaked secrets using Gitleaks. |
|
||||
# | |
|
||||
# | - PR scan: only new commits in the PR |
|
||||
# | - Scheduled: full repo scan weekly |
|
||||
# | - Alerts via ntfy on findings |
|
||||
# | |
|
||||
# +========================================================================+
|
||||
|
||||
name: "Universal: Secret Scanning"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- 'dev/**'
|
||||
schedule:
|
||||
- cron: '0 5 * * 1' # Weekly Monday 05:00 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'gitea-security' }}
|
||||
|
||||
jobs:
|
||||
gitleaks:
|
||||
name: Gitleaks Secret Scan
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install Gitleaks
|
||||
run: |
|
||||
GITLEAKS_VERSION="8.21.2"
|
||||
curl -sSL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
|
||||
| tar -xz -C /usr/local/bin gitleaks
|
||||
gitleaks version
|
||||
|
||||
- name: Scan for secrets
|
||||
id: scan
|
||||
run: |
|
||||
echo "### Secret Scanning" >> $GITHUB_STEP_SUMMARY
|
||||
ARGS="--source . --verbose --report-format json --report-path /tmp/gitleaks-report.json"
|
||||
|
||||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||
# Scan only PR commits
|
||||
ARGS="$ARGS --log-opts=${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
|
||||
echo "Scanning PR commits only" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "Full repository scan" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
if gitleaks detect $ARGS 2>&1; then
|
||||
echo "result=clean" >> "$GITHUB_OUTPUT"
|
||||
echo "**No secrets detected.**" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "result=found" >> "$GITHUB_OUTPUT"
|
||||
FINDINGS=$(jq length /tmp/gitleaks-report.json 2>/dev/null || echo "unknown")
|
||||
echo "**${FINDINGS} potential secret(s) detected.**" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Review the findings and rotate any exposed credentials immediately." >> $GITHUB_STEP_SUMMARY
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Notify on findings
|
||||
if: failure() && steps.scan.outputs.result == 'found'
|
||||
run: |
|
||||
REPO="${{ github.event.repository.name }}"
|
||||
curl -sS \
|
||||
-H "Title: ${REPO} — secrets detected in code" \
|
||||
-H "Tags: rotating_light,key" \
|
||||
-H "Priority: urgent" \
|
||||
-d "Gitleaks found potential secrets. Review and rotate credentials immediately." \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}" || true
|
||||
@@ -4,8 +4,8 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: mokoplatform.Automation
|
||||
# VERSION: 01.01.02
|
||||
# INGROUP: moko-platform.Automation
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Auto-create feature branch when an issue is opened
|
||||
|
||||
name: "Universal: Issue Branch"
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: MokoStandards.Notifications
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
||||
# PATH: /.gitea/workflows/notify.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Push notifications via ntfy on release success or workflow failure
|
||||
|
||||
name: "Universal: Notifications"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows:
|
||||
- "Joomla Build & Release"
|
||||
- "Joomla Extension CI"
|
||||
- "Deploy"
|
||||
types:
|
||||
- completed
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'gitea-releases' }}
|
||||
|
||||
jobs:
|
||||
notify:
|
||||
name: Send Notification
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
github.event.workflow_run.conclusion == 'success' ||
|
||||
github.event.workflow_run.conclusion == 'failure'
|
||||
|
||||
steps:
|
||||
- name: Notify on success (releases only)
|
||||
if: >-
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
contains(github.event.workflow_run.name, 'Release')
|
||||
run: |
|
||||
REPO="${{ github.event.repository.name }}"
|
||||
WORKFLOW="${{ github.event.workflow_run.name }}"
|
||||
URL="${{ github.event.workflow_run.html_url }}"
|
||||
|
||||
curl -sS \
|
||||
-H "Title: ${REPO} released" \
|
||||
-H "Tags: white_check_mark,package" \
|
||||
-H "Priority: default" \
|
||||
-H "Click: ${URL}" \
|
||||
-d "${WORKFLOW} completed successfully." \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}"
|
||||
|
||||
- name: Notify on failure
|
||||
if: github.event.workflow_run.conclusion == 'failure'
|
||||
run: |
|
||||
REPO="${{ github.event.repository.name }}"
|
||||
WORKFLOW="${{ github.event.workflow_run.name }}"
|
||||
URL="${{ github.event.workflow_run.html_url }}"
|
||||
|
||||
curl -sS \
|
||||
-H "Title: ${REPO} workflow failed" \
|
||||
-H "Tags: x,warning" \
|
||||
-H "Priority: high" \
|
||||
-H "Click: ${URL}" \
|
||||
-d "${WORKFLOW} failed. Check the run for details." \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}"
|
||||
@@ -1,510 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: mokoplatform.CI
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/mokoplatform
|
||||
# PATH: /templates/workflows/universal/pr-check.yml.template
|
||||
# VERSION: 09.23.00
|
||||
# BRIEF: PR gate — branch policy + code validation before merge
|
||||
|
||||
name: "Universal: PR Check"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, edited]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
# ── Branch Policy ──────────────────────────────────────────────────────
|
||||
branch-policy:
|
||||
name: Branch Policy
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check branch merge target
|
||||
run: |
|
||||
HEAD="${{ github.head_ref }}"
|
||||
BASE="${{ github.base_ref }}"
|
||||
|
||||
echo "PR: ${HEAD} → ${BASE}"
|
||||
|
||||
ALLOWED=true
|
||||
REASON=""
|
||||
|
||||
case "$HEAD" in
|
||||
feature/*|feat/*)
|
||||
if [ "$BASE" != "dev" ]; then
|
||||
ALLOWED=false
|
||||
REASON="Feature branches must target 'dev', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
fix/*|bugfix/*)
|
||||
if [ "$BASE" != "dev" ]; then
|
||||
ALLOWED=false
|
||||
REASON="Fix branches must target 'dev', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
patch/*)
|
||||
if [ "$BASE" != "dev" ] && [ "$BASE" != "rc" ]; then
|
||||
ALLOWED=false
|
||||
REASON="Patch branches must target 'dev' or 'rc', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
hotfix/*)
|
||||
if [ "$BASE" != "dev" ] && [ "$BASE" != "main" ]; then
|
||||
ALLOWED=false
|
||||
REASON="Hotfix branches can only target 'dev' or 'main', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
rc)
|
||||
if [ "$BASE" != "main" ]; then
|
||||
ALLOWED=false
|
||||
REASON="RC branch can only merge into 'main', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
dev)
|
||||
if [ "$BASE" != "main" ]; then
|
||||
ALLOWED=false
|
||||
REASON="Dev branch can only merge into 'main', not '${BASE}'"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$ALLOWED" = false ]; then
|
||||
echo "::error::${REASON}"
|
||||
echo "## Branch Policy Violation" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "${REASON}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Allowed merge paths:" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`feature/*\` → \`dev\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`fix/*\` → \`dev\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`hotfix/*\` → \`dev\` or \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`dev\` → \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- \`rc/*\` → \`main\`" >> $GITHUB_STEP_SUMMARY
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Branch policy: OK (${HEAD} → ${BASE})"
|
||||
echo "## Branch Policy: Passed" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# ── Code Validation ────────────────────────────────────────────────────
|
||||
validate:
|
||||
name: Validate PR
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check for merge conflict markers
|
||||
run: |
|
||||
CONFLICTS=$(grep -rn '<<<<<<< \|>>>>>>> \|^=======$' --include='*.php' --include='*.xml' --include='*.css' --include='*.js' --include='*.json' --include='*.md' --include='*.yml' --include='*.yaml' --include='*.ini' --include='*.txt' . 2>/dev/null | grep -v '.git/' || true)
|
||||
if [ -n "$CONFLICTS" ]; then
|
||||
echo "::error::Merge conflict markers found in source files"
|
||||
echo "## Conflict Markers Found" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
echo "$CONFLICTS" >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
exit 1
|
||||
fi
|
||||
echo "No conflict markers found"
|
||||
|
||||
- name: Detect platform
|
||||
id: platform
|
||||
run: |
|
||||
# Read platform from XML manifest (<platform> tag) or plain text fallback
|
||||
PLATFORM=$(sed -n 's/.*<platform>\([^<]*\)<\/platform>.*/\1/p' .mokogitea/manifest.xml 2>/dev/null | head -1)
|
||||
[ -z "$PLATFORM" ] && PLATFORM=$(cat .mokogitea/manifest.xml 2>/dev/null | tr -d '[:space:]')
|
||||
[ -z "$PLATFORM" ] && PLATFORM="generic"
|
||||
echo "platform=$PLATFORM" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup PHP
|
||||
if: steps.platform.outputs.platform == 'joomla' || steps.platform.outputs.platform == 'dolibarr'
|
||||
run: |
|
||||
if ! command -v php &> /dev/null; then
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq php-cli php-mbstring php-xml >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
- name: PHP syntax check
|
||||
if: steps.platform.outputs.platform == 'joomla' || steps.platform.outputs.platform == 'dolibarr'
|
||||
run: |
|
||||
ERRORS=0
|
||||
while IFS= read -r -d '' file; do
|
||||
if ! php -l "$file" 2>&1 | grep -q "No syntax errors"; then
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
done < <(find . -name "*.php" -not -path "./.git/*" -not -path "./vendor/*" -print0)
|
||||
echo "PHP lint: ${ERRORS} error(s)"
|
||||
[ "$ERRORS" -eq 0 ] || { echo "::error::PHP syntax errors found"; exit 1; }
|
||||
|
||||
- name: Joomla JEXEC guard check
|
||||
if: steps.platform.outputs.platform == 'joomla'
|
||||
run: |
|
||||
ERRORS=0
|
||||
while IFS= read -r -d '' file; do
|
||||
# Skip vendor, node_modules, and index.html stub files
|
||||
case "$file" in ./vendor/*|./node_modules/*) continue ;; esac
|
||||
# Check first 10 lines for JEXEC or JPATH guard
|
||||
if ! head -20 "$file" | grep -qE "defined\s*\(\s*['\"](_JEXEC|JPATH_BASE|\\\\JPATH_PLATFORM)['\"]"; then
|
||||
echo "::error file=${file}::Missing JEXEC guard: ${file}"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
done < <(find . -name "*.php" \( -path "*/source/*" -o -path "*/src/*" \) -not -path "./.git/*" -not -path "./vendor/*" -print0)
|
||||
if [ "$ERRORS" -gt 0 ]; then
|
||||
echo "::error::${ERRORS} PHP file(s) missing defined('_JEXEC') or die guard"
|
||||
echo "## JEXEC Guard Check: Failed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "${ERRORS} file(s) are missing the Joomla execution guard." >> $GITHUB_STEP_SUMMARY
|
||||
exit 1
|
||||
fi
|
||||
echo "JEXEC guard: OK"
|
||||
|
||||
- name: Joomla directory listing protection
|
||||
if: steps.platform.outputs.platform == 'joomla'
|
||||
run: |
|
||||
MISSING=0
|
||||
SOURCE_DIR="source"
|
||||
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="src"
|
||||
[ ! -d "$SOURCE_DIR" ] && exit 0
|
||||
while IFS= read -r dir; do
|
||||
if [ ! -f "${dir}/index.html" ]; then
|
||||
echo "::warning::Missing index.html in ${dir} (directory listing protection)"
|
||||
MISSING=$((MISSING + 1))
|
||||
fi
|
||||
done < <(find "$SOURCE_DIR" -type d -not -path "./.git/*" -not -path "*/vendor/*" -not -path "*/node_modules/*")
|
||||
if [ "$MISSING" -gt 0 ]; then
|
||||
echo "## Directory Protection" >> $GITHUB_STEP_SUMMARY
|
||||
echo "${MISSING} director(ies) missing index.html" >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
echo "Directory protection: ${MISSING} missing (advisory)"
|
||||
|
||||
- name: Joomla script file and asset checks
|
||||
if: steps.platform.outputs.platform == 'joomla'
|
||||
run: |
|
||||
ERRORS=0
|
||||
MANIFEST=$(find . -maxdepth 3 -name "*.xml" ! -path "./.git/*" -exec grep -l '<extension' {} \; 2>/dev/null | head -1)
|
||||
[ -z "$MANIFEST" ] && exit 0
|
||||
MANIFEST_DIR=$(dirname "$MANIFEST")
|
||||
|
||||
# Check scriptfile exists if declared
|
||||
SCRIPTFILE=$(sed -n 's/.*<scriptfile>\([^<]*\)<\/scriptfile>.*/\1/p' "$MANIFEST" 2>/dev/null)
|
||||
if [ -n "$SCRIPTFILE" ]; then
|
||||
if [ ! -f "${MANIFEST_DIR}/${SCRIPTFILE}" ]; then
|
||||
echo "::error::Manifest declares <scriptfile>${SCRIPTFILE}</scriptfile> but file not found at ${MANIFEST_DIR}/${SCRIPTFILE}"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
else
|
||||
echo "Script file: ${MANIFEST_DIR}/${SCRIPTFILE} (OK)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Require joomla.asset.json and validate it
|
||||
ASSET_JSON=$(find "$MANIFEST_DIR" -name "joomla.asset.json" -not -path "./.git/*" 2>/dev/null | head -1)
|
||||
if [ -z "$ASSET_JSON" ]; then
|
||||
echo "::error::joomla.asset.json not found — Joomla asset system is required"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
else
|
||||
if command -v php &> /dev/null; then
|
||||
php -r "json_decode(file_get_contents('$ASSET_JSON')); if(json_last_error()!==JSON_ERROR_NONE){echo json_last_error_msg();exit(1);}" 2>&1 || {
|
||||
echo "::error::joomla.asset.json is not valid JSON"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
}
|
||||
fi
|
||||
echo "joomla.asset.json: valid"
|
||||
fi
|
||||
|
||||
# Validate all XML files in source/src are well-formed
|
||||
XML_ERRORS=0
|
||||
if command -v php &> /dev/null; then
|
||||
while IFS= read -r -d '' xmlfile; do
|
||||
if ! php -r "libxml_use_internal_errors(true); \$x = simplexml_load_file('$xmlfile'); if(!\$x){foreach(libxml_get_errors() as \$e) echo trim(\$e->message) . ' in $xmlfile'; exit(1);}" 2>&1; then
|
||||
XML_ERRORS=$((XML_ERRORS + 1))
|
||||
fi
|
||||
done < <(find "$MANIFEST_DIR" -name "*.xml" -not -path "./.git/*" -print0)
|
||||
fi
|
||||
if [ "$XML_ERRORS" -gt 0 ]; then
|
||||
echo "::error::${XML_ERRORS} XML file(s) are malformed"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
else
|
||||
echo "XML well-formedness: OK"
|
||||
fi
|
||||
|
||||
[ "$ERRORS" -gt 0 ] && exit 1
|
||||
echo "Joomla asset checks: OK"
|
||||
|
||||
- name: Validate platform manifest
|
||||
run: |
|
||||
PLATFORM="${{ steps.platform.outputs.platform }}"
|
||||
case "$PLATFORM" in
|
||||
joomla)
|
||||
MANIFEST=$(find . -maxdepth 3 -name "*.xml" ! -path "./.git/*" -exec grep -l '<extension' {} \; 2>/dev/null | head -1)
|
||||
if [ -z "$MANIFEST" ]; then
|
||||
echo "::warning::No Joomla manifest found (WaaS site)"
|
||||
exit 0
|
||||
fi
|
||||
echo "Manifest: ${MANIFEST}"
|
||||
if command -v php &> /dev/null; then
|
||||
php -r "libxml_use_internal_errors(true); \$x = simplexml_load_file('$MANIFEST'); if(!\$x){foreach(libxml_get_errors() as \$e) echo \$e->message; exit(1);}" || { echo "::error::Manifest XML is malformed"; exit 1; }
|
||||
fi
|
||||
for ELEMENT in name version description; do
|
||||
grep -q "<${ELEMENT}>" "$MANIFEST" || { echo "::error::Missing <${ELEMENT}> in manifest"; exit 1; }
|
||||
done
|
||||
# Block legacy raw/branch update server URLs on MokoGitea
|
||||
RAW_URLS=$(grep -n 'raw/branch' "$MANIFEST" | grep -i 'mokoconsulting\|mokogitea\|git\.mokoconsulting\.tech' || true)
|
||||
if [ -n "$RAW_URLS" ]; then
|
||||
echo "::error::Manifest contains legacy raw/branch update server URL on MokoGitea. Use the Gitea Pages URL instead (e.g. /{REPO}/updates.xml not /{REPO}/raw/branch/main/updates.xml)"
|
||||
echo "$RAW_URLS"
|
||||
exit 1
|
||||
fi
|
||||
echo "Joomla manifest valid"
|
||||
;;
|
||||
dolibarr)
|
||||
MOD_FILE=$(find . -maxdepth 4 -name "mod*.class.php" ! -path "./.git/*" -exec grep -l 'extends DolibarrModules' {} \; 2>/dev/null | head -1)
|
||||
if [ -z "$MOD_FILE" ]; then
|
||||
echo "::error::No mod*.class.php found"
|
||||
exit 1
|
||||
fi
|
||||
echo "Dolibarr module: ${MOD_FILE}"
|
||||
;;
|
||||
*)
|
||||
echo "Generic platform — no manifest validation"
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Check update stream format
|
||||
run: |
|
||||
PLATFORM="${{ steps.platform.outputs.platform }}"
|
||||
case "$PLATFORM" in
|
||||
joomla)
|
||||
if [ -f "updates.xml" ]; then
|
||||
if command -v php &> /dev/null; then
|
||||
php -r "libxml_use_internal_errors(true); \$x = simplexml_load_file('updates.xml'); if(!\$x){foreach(libxml_get_errors() as \$e) echo \$e->message; exit(1);}" || { echo "::error::updates.xml is malformed"; exit 1; }
|
||||
fi
|
||||
echo "updates.xml valid"
|
||||
fi
|
||||
;;
|
||||
dolibarr)
|
||||
[ -f "update.txt" ] && echo "update.txt present" || echo "::warning::No update.txt"
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Validate Joomla language files
|
||||
if: steps.platform.outputs.platform == 'joomla'
|
||||
run: |
|
||||
ERRORS=0
|
||||
WARNINGS=0
|
||||
|
||||
# Require both en-GB and en-US language directories
|
||||
LANG_ROOT=$(find . -path "*/language" -type d -not -path "./.git/*" 2>/dev/null | head -1)
|
||||
if [ -z "$LANG_ROOT" ]; then
|
||||
echo "No language/ directory found — skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -d "$LANG_ROOT/en-GB" ]; then
|
||||
echo "::error::Missing en-GB language directory (${LANG_ROOT}/en-GB)"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
if [ ! -d "$LANG_ROOT/en-US" ]; then
|
||||
echo "::error::Missing en-US language directory (${LANG_ROOT}/en-US)"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
|
||||
# Check that en-GB and en-US have matching .ini files
|
||||
if [ -d "$LANG_ROOT/en-GB" ] && [ -d "$LANG_ROOT/en-US" ]; then
|
||||
for GB_INI in "$LANG_ROOT/en-GB"/*.ini; do
|
||||
[ ! -f "$GB_INI" ] && continue
|
||||
US_INI="$LANG_ROOT/en-US/$(basename "$GB_INI")"
|
||||
if [ ! -f "$US_INI" ]; then
|
||||
echo "::error::$(basename "$GB_INI") exists in en-GB but missing from en-US"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
done
|
||||
for US_INI in "$LANG_ROOT/en-US"/*.ini; do
|
||||
[ ! -f "$US_INI" ] && continue
|
||||
GB_INI="$LANG_ROOT/en-GB/$(basename "$US_INI")"
|
||||
if [ ! -f "$GB_INI" ]; then
|
||||
echo "::error::$(basename "$US_INI") exists in en-US but missing from en-GB"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Find all .ini language files
|
||||
INI_FILES=$(find . -path "*/language/*/*.ini" -not -path "./.git/*" 2>/dev/null)
|
||||
if [ -z "$INI_FILES" ]; then
|
||||
echo "No .ini language files found"
|
||||
[ "$ERRORS" -gt 0 ] && exit 1
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Found $(echo "$INI_FILES" | wc -l) language file(s)"
|
||||
|
||||
for FILE in $INI_FILES; do
|
||||
FNAME=$(basename "$FILE")
|
||||
LINENUM=0
|
||||
SEEN_KEYS=""
|
||||
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
LINENUM=$((LINENUM + 1))
|
||||
|
||||
# Skip empty lines and comments
|
||||
[ -z "$line" ] && continue
|
||||
echo "$line" | grep -qE '^\s*;' && continue
|
||||
echo "$line" | grep -qE '^\s*$' && continue
|
||||
|
||||
# Must match KEY="VALUE" format
|
||||
if ! echo "$line" | grep -qE '^[A-Z_][A-Z0-9_]*=".*"$'; then
|
||||
echo "::error file=${FILE},line=${LINENUM}::Malformed line: ${line}"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Extract key and check for duplicates
|
||||
KEY=$(echo "$line" | sed 's/=.*//')
|
||||
if echo "$SEEN_KEYS" | grep -qx "$KEY"; then
|
||||
echo "::error file=${FILE},line=${LINENUM}::Duplicate key: ${KEY}"
|
||||
ERRORS=$((ERRORS + 1))
|
||||
fi
|
||||
SEEN_KEYS="${SEEN_KEYS}
|
||||
${KEY}"
|
||||
done < "$FILE"
|
||||
|
||||
echo " ${FILE}: checked ${LINENUM} lines"
|
||||
done
|
||||
|
||||
# Cross-check en-GB vs en-US key consistency
|
||||
GB_DIR=$(find . -path "*/language/en-GB" -type d -not -path "./.git/*" 2>/dev/null | head -1)
|
||||
US_DIR=$(find . -path "*/language/en-US" -type d -not -path "./.git/*" 2>/dev/null | head -1)
|
||||
|
||||
if [ -n "$GB_DIR" ] && [ -n "$US_DIR" ]; then
|
||||
for GB_FILE in "$GB_DIR"/*.ini; do
|
||||
[ ! -f "$GB_FILE" ] && continue
|
||||
FNAME=$(basename "$GB_FILE")
|
||||
US_FILE="$US_DIR/$FNAME"
|
||||
[ ! -f "$US_FILE" ] && continue
|
||||
|
||||
GB_KEYS=$(grep -oP '^[A-Z_][A-Z0-9_]*(?==)' "$GB_FILE" 2>/dev/null | sort)
|
||||
US_KEYS=$(grep -oP '^[A-Z_][A-Z0-9_]*(?==)' "$US_FILE" 2>/dev/null | sort)
|
||||
|
||||
# Keys in en-GB but not en-US
|
||||
MISSING_US=$(comm -23 <(echo "$GB_KEYS") <(echo "$US_KEYS"))
|
||||
if [ -n "$MISSING_US" ]; then
|
||||
echo "::warning::Keys in en-GB/$FNAME but missing from en-US/$FNAME:"
|
||||
echo "$MISSING_US" | while read -r k; do echo " - $k"; done
|
||||
WARNINGS=$((WARNINGS + 1))
|
||||
fi
|
||||
|
||||
# Keys in en-US but not en-GB
|
||||
MISSING_GB=$(comm -13 <(echo "$GB_KEYS") <(echo "$US_KEYS"))
|
||||
if [ -n "$MISSING_GB" ]; then
|
||||
echo "::warning::Keys in en-US/$FNAME but missing from en-GB/$FNAME:"
|
||||
echo "$MISSING_GB" | while read -r k; do echo " - $k"; done
|
||||
WARNINGS=$((WARNINGS + 1))
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
{
|
||||
echo "### Language File Validation"
|
||||
echo "| Metric | Count |"
|
||||
echo "|---|---|"
|
||||
echo "| Files checked | $(echo "$INI_FILES" | wc -l) |"
|
||||
echo "| Errors | ${ERRORS} |"
|
||||
echo "| Warnings | ${WARNINGS} |"
|
||||
} >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
if [ "$ERRORS" -gt 0 ]; then
|
||||
echo "::error::Language validation failed with ${ERRORS} error(s)"
|
||||
exit 1
|
||||
fi
|
||||
echo "Language files: OK (${WARNINGS} warning(s))"
|
||||
|
||||
- name: Check changelog has unreleased entry
|
||||
run: |
|
||||
if [ ! -f "CHANGELOG.md" ]; then
|
||||
echo "::warning::No CHANGELOG.md found"
|
||||
exit 0
|
||||
fi
|
||||
# Check for content under [Unreleased] section
|
||||
if ! grep -q "## \[Unreleased\]" CHANGELOG.md; then
|
||||
echo "::error::CHANGELOG.md missing [Unreleased] section"
|
||||
exit 1
|
||||
fi
|
||||
# Check there's at least one entry (Added/Changed/Fixed/Removed) under Unreleased
|
||||
UNRELEASED_CONTENT=$(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md | grep -cE '^\s*-\s' || true)
|
||||
if [ "$UNRELEASED_CONTENT" -eq 0 ]; then
|
||||
echo "::error::CHANGELOG.md [Unreleased] section has no entries. Add a changelog entry describing your changes."
|
||||
echo "## Changelog Check: Failed" >> $GITHUB_STEP_SUMMARY
|
||||
echo "The \`[Unreleased]\` section in CHANGELOG.md has no entries." >> $GITHUB_STEP_SUMMARY
|
||||
echo "Add a line like \`- Description of your change\` under a heading (\`### Added\`, \`### Changed\`, \`### Fixed\`, etc.)" >> $GITHUB_STEP_SUMMARY
|
||||
exit 1
|
||||
fi
|
||||
echo "Changelog: ${UNRELEASED_CONTENT} entry/entries in [Unreleased]"
|
||||
|
||||
- name: Verify package source
|
||||
run: |
|
||||
SOURCE_DIR="source"
|
||||
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="src"
|
||||
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="htdocs"
|
||||
if [ ! -d "$SOURCE_DIR" ]; then
|
||||
echo "::warning::No source/, src/, or htdocs/ directory"
|
||||
exit 0
|
||||
fi
|
||||
FILE_COUNT=$(find "$SOURCE_DIR" -type f | wc -l)
|
||||
echo "Source: ${FILE_COUNT} files"
|
||||
[ "$FILE_COUNT" -gt 0 ] || { echo "::error::Source directory is empty"; exit 1; }
|
||||
|
||||
# ── Pre-Release RC Build ─────────────────────────────────────────────────
|
||||
pre-release:
|
||||
name: Build RC Package
|
||||
runs-on: ubuntu-latest
|
||||
needs: [branch-policy, validate]
|
||||
|
||||
steps:
|
||||
- name: Trigger RC pre-release
|
||||
env:
|
||||
GA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH: ${{ github.head_ref }}
|
||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
run: |
|
||||
curl -s -X POST "${GITEA_URL}/api/v1/repos/${REPO}/actions/workflows/pre-release.yml/dispatches" -H "Authorization: token ${GITEA_TOKEN}" -H "Content-Type: application/json" -d "{\"ref\":\"${BRANCH}\",\"inputs\":{\"stability\":\"release-candidate\"}}"
|
||||
echo "### Pre-Release" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Triggered RC build on branch \`${BRANCH}\`" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# ── Issue Reporter ──────────────────────────────────────────────────────
|
||||
report-issues:
|
||||
name: Report Issues
|
||||
runs-on: ubuntu-latest
|
||||
needs: [branch-policy, validate]
|
||||
if: >-
|
||||
always() &&
|
||||
needs.validate.result == 'failure'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: automation/ci-issue-reporter.sh
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: "File issue for PR validation failure"
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
run: |
|
||||
chmod +x automation/ci-issue-reporter.sh
|
||||
./automation/ci-issue-reporter.sh \
|
||||
--gate "PR Validation" \
|
||||
--workflow "PR Check" \
|
||||
--severity error \
|
||||
--details "PR validation failed (syntax, manifest, changelog, or source checks). See the CI run for the specific check that failed."
|
||||
@@ -4,8 +4,8 @@
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: mokoplatform.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokoplatform
|
||||
# INGROUP: moko-platform.Release
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||
# PATH: /templates/workflows/universal/pre-release.yml.template
|
||||
# VERSION: 05.01.00
|
||||
# BRIEF: Manual pre-release -- builds dev/alpha/beta/rc packages from any branch
|
||||
@@ -17,10 +17,6 @@ on:
|
||||
types: [closed]
|
||||
branches:
|
||||
- dev
|
||||
pull_request_target:
|
||||
types: [synchronize, opened, reopened]
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
stability:
|
||||
@@ -47,8 +43,7 @@ jobs:
|
||||
runs-on: release
|
||||
if: >-
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev') ||
|
||||
(github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == 'main')
|
||||
(github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev')
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -56,28 +51,22 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}
|
||||
|
||||
- name: Setup mokoplatform tools
|
||||
- name: Setup moko-platform tools
|
||||
env:
|
||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||
run: |
|
||||
# Use pre-installed /opt/mokoplatform if available (updated by cron every 6h)
|
||||
if [ -f /opt/mokoplatform/cli/version_bump.php ] && [ -f /opt/mokoplatform/cli/manifest_element.php ] && [ -f /opt/mokoplatform/vendor/autoload.php ]; then
|
||||
echo Using pre-installed /opt/mokoplatform
|
||||
echo MOKO_CLI=/opt/mokoplatform/cli >> $GITHUB_ENV
|
||||
else
|
||||
echo Falling back to fresh clone
|
||||
if ! command -v composer > /dev/null 2>&1; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer > /dev/null 2>&1
|
||||
fi
|
||||
rm -rf /tmp/mokoplatform-api
|
||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/mokoplatform.git
|
||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/mokoplatform-api
|
||||
cd /tmp/mokoplatform-api && composer install --no-dev --no-interaction --quiet
|
||||
echo MOKO_CLI=/tmp/mokoplatform-api/cli >> $GITHUB_ENV
|
||||
if ! command -v composer &> /dev/null; then
|
||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||
fi
|
||||
# Always fetch latest CLI tools — never use stale cache from previous runs
|
||||
rm -rf /tmp/moko-platform-api
|
||||
git clone --depth 1 --branch main --quiet \
|
||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||
/tmp/moko-platform-api
|
||||
cd /tmp/moko-platform-api && composer install --no-dev --no-interaction --quiet
|
||||
echo "MOKO_CLI=/tmp/moko-platform-api/cli" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Detect platform
|
||||
id: platform
|
||||
@@ -87,12 +76,7 @@ jobs:
|
||||
- name: Resolve metadata and bump version
|
||||
id: meta
|
||||
run: |
|
||||
# Auto-detect stability: RC for PRs targeting main, else use input or default to development
|
||||
if [ "${{ github.event_name }}" = "pull_request_target" ] && [ "${{ github.event.pull_request.base.ref }}" = "main" ]; then
|
||||
STABILITY="release-candidate"
|
||||
else
|
||||
STABILITY="${{ inputs.stability || 'development' }}"
|
||||
fi
|
||||
STABILITY="${{ inputs.stability || 'development' }}"
|
||||
|
||||
case "$STABILITY" in
|
||||
development) SUFFIX="-dev"; TAG="development" ;;
|
||||
@@ -101,26 +85,20 @@ jobs:
|
||||
release-candidate) SUFFIX="-rc"; TAG="release-candidate" ;;
|
||||
esac
|
||||
|
||||
# Bump version via CLI: patch for dev/alpha/beta, minor for RC
|
||||
case "$STABILITY" in
|
||||
release-candidate) BUMP="minor" ;;
|
||||
*) BUMP="patch" ;;
|
||||
esac
|
||||
# Read current version (bump already handled by push workflow)
|
||||
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null)
|
||||
[ -z "$VERSION" ] && VERSION="00.00.01"
|
||||
|
||||
php ${MOKO_CLI}/version_bump.php --path . $([ "$BUMP" = "minor" ] && echo "--minor") 2>/dev/null || true
|
||||
|
||||
# Set stability suffix and verify consistency
|
||||
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null || echo "00.00.01")
|
||||
# Strip any existing suffix from version before applying stability
|
||||
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
||||
|
||||
php ${MOKO_CLI}/version_set_platform.php \
|
||||
--path . --version "$VERSION" --branch "${{ github.ref_name }}" --stability "$STABILITY" 2>/dev/null || true
|
||||
|
||||
# Verify version consistency across all files
|
||||
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
||||
|
||||
# Ensure licensing tags (updateservers, dlid) if enabled in manifest.xml
|
||||
php ${MOKO_CLI}/manifest_licensing.php --path . --fix 2>/dev/null || true
|
||||
|
||||
# Append suffix for output
|
||||
# Update VERSION variable with suffix
|
||||
if [ -n "$SUFFIX" ]; then
|
||||
VERSION="${VERSION}${SUFFIX}"
|
||||
fi
|
||||
@@ -166,41 +144,6 @@ jobs:
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||
--repo "${GITEA_REPO}" --branch dev --prerelease
|
||||
|
||||
- name: Update release notes from CHANGELOG.md
|
||||
run: |
|
||||
TAG="${{ steps.meta.outputs.tag }}"
|
||||
VERSION="${{ steps.meta.outputs.version }}"
|
||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||
|
||||
# Extract [Unreleased] section from changelog (everything between [Unreleased] and next ## heading)
|
||||
if [ -f "CHANGELOG.md" ]; then
|
||||
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
||||
[ -z "$NOTES" ] && NOTES="Release ${VERSION}"
|
||||
else
|
||||
NOTES="Release ${VERSION}"
|
||||
fi
|
||||
|
||||
# Update release body via API
|
||||
RELEASE_ID=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||
"${API_BASE}/releases/tags/${TAG}" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
||||
|
||||
if [ -n "$RELEASE_ID" ]; then
|
||||
python3 -c "
|
||||
import json, urllib.request
|
||||
body = open('/dev/stdin').read()
|
||||
payload = json.dumps({'body': body}).encode()
|
||||
req = urllib.request.Request(
|
||||
'${API_BASE}/releases/${RELEASE_ID}',
|
||||
data=payload, method='PATCH',
|
||||
headers={
|
||||
'Authorization': 'token ${{ secrets.MOKOGITEA_TOKEN }}',
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
urllib.request.urlopen(req)
|
||||
" <<< "$NOTES"
|
||||
echo "Release notes updated from CHANGELOG.md"
|
||||
fi
|
||||
|
||||
- name: Build package and upload
|
||||
id: package
|
||||
run: |
|
||||
@@ -212,8 +155,55 @@ jobs:
|
||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||
--repo "${GITEA_REPO}" --output /tmp || true
|
||||
|
||||
# updates.xml is generated dynamically by MokoGitea license server
|
||||
# No need to build, commit, or sync updates.xml from workflows
|
||||
- name: Update updates.xml
|
||||
if: steps.platform.outputs.platform == 'joomla'
|
||||
run: |
|
||||
VERSION="${{ steps.meta.outputs.version }}"
|
||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
||||
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||
|
||||
if [ ! -f "updates.xml" ]; then
|
||||
echo "No updates.xml -- skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SHA_FLAG=""
|
||||
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
||||
|
||||
php ${MOKO_CLI}/updates_xml_build.php \
|
||||
--path . --version "${VERSION}" --stability "${STABILITY}" \
|
||||
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
||||
${SHA_FLAG}
|
||||
|
||||
# Commit and push
|
||||
if ! git diff --quiet updates.xml 2>/dev/null; then
|
||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||
git config --local user.name "gitea-actions[bot]"
|
||||
git add updates.xml
|
||||
git commit -m "chore: update ${STABILITY} channel ${VERSION} [skip ci]"
|
||||
git push origin HEAD 2>&1 || echo "WARNING: push failed"
|
||||
fi
|
||||
|
||||
- name: "Sync updates.xml to all branches"
|
||||
if: steps.platform.outputs.platform == 'joomla'
|
||||
run: |
|
||||
CURRENT_BRANCH="${{ github.ref_name }}"
|
||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||
git config --local user.name "gitea-actions[bot]"
|
||||
|
||||
for BRANCH in main dev; do
|
||||
[ "$BRANCH" = "$CURRENT_BRANCH" ] && continue
|
||||
echo "Syncing updates.xml -> ${BRANCH}"
|
||||
git fetch origin "${BRANCH}" 2>/dev/null || continue
|
||||
git checkout "origin/${BRANCH}" -- updates.xml 2>/dev/null || continue
|
||||
git checkout "${CURRENT_BRANCH}" -- updates.xml
|
||||
if ! git diff --quiet updates.xml 2>/dev/null; then
|
||||
git add updates.xml
|
||||
git commit -m "chore: sync updates.xml from ${CURRENT_BRANCH} [skip ci]"
|
||||
git push origin HEAD:refs/heads/${BRANCH} 2>&1 || echo "WARNING: push to ${BRANCH} failed"
|
||||
fi
|
||||
git checkout "${CURRENT_BRANCH}" 2>/dev/null
|
||||
done
|
||||
|
||||
- name: "Delete lesser pre-release channels (cascade)"
|
||||
continue-on-error: true
|
||||
|
||||
@@ -1,713 +0,0 @@
|
||||
# ============================================================================
|
||||
# Copyright (C) 2025 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# This file is part of a Moko Consulting project.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: mokoplatform.Validation
|
||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/mokoplatform
|
||||
# PATH: /templates/workflows/joomla/repo_health.yml.template
|
||||
# VERSION: 09.23.00
|
||||
# BRIEF: Enforces repository guardrails by validating scripts governance, tooling availability, and core repository health artifacts.
|
||||
# ============================================================================
|
||||
|
||||
name: "Generic: Repo Health"
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
profile:
|
||||
description: 'Validation profile: all, scripts, or repo'
|
||||
required: true
|
||||
default: all
|
||||
type: choice
|
||||
options:
|
||||
- all
|
||||
- scripts
|
||||
- repo
|
||||
pull_request:
|
||||
push:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
# Scripts governance policy
|
||||
SCRIPTS_REQUIRED_DIRS:
|
||||
SCRIPTS_ALLOWED_DIRS: scripts,scripts/fix,scripts/lib,scripts/release,scripts/run,scripts/validate
|
||||
|
||||
# Repo health policy
|
||||
REPO_REQUIRED_ARTIFACTS: README.md,LICENSE,CHANGELOG.md,CONTRIBUTING.md,CODE_OF_CONDUCT.md,.mokogitea/workflows/
|
||||
REPO_OPTIONAL_FILES: SECURITY.md,GOVERNANCE.md,.editorconfig,.gitattributes,.gitignore,README.md,docs/
|
||||
REPO_DISALLOWED_DIRS:
|
||||
REPO_DISALLOWED_FILES: TODO.md,todo.md
|
||||
|
||||
# Extended checks toggles
|
||||
EXTENDED_CHECKS: "true"
|
||||
|
||||
# File / directory variables
|
||||
DOCS_INDEX: docs/docs-index.md
|
||||
SCRIPT_DIR: scripts
|
||||
WORKFLOWS_DIR: .mokogitea/workflows
|
||||
SHELLCHECK_PATTERN: '*.sh'
|
||||
SPDX_FILE_GLOBS: '*.sh,*.php,*.js,*.ts,*.css,*.xml,*.yml,*.yaml'
|
||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||
|
||||
jobs:
|
||||
access_check:
|
||||
name: Access control
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
outputs:
|
||||
allowed: ${{ steps.perm.outputs.allowed }}
|
||||
permission: ${{ steps.perm.outputs.permission }}
|
||||
|
||||
steps:
|
||||
- name: Check actor permission (admin only)
|
||||
id: perm
|
||||
env:
|
||||
TOKEN: ${{ secrets.MOKOGITEA_TOKEN || secrets.MOKOGITEA_TOKEN || github.token }}
|
||||
REPO: ${{ github.repository }}
|
||||
ACTOR: ${{ github.actor }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
ALLOWED=false
|
||||
PERMISSION=unknown
|
||||
METHOD=""
|
||||
|
||||
# Hardcoded authorized users — always allowed
|
||||
case "$ACTOR" in
|
||||
jmiller|gitea-actions[bot])
|
||||
ALLOWED=true
|
||||
PERMISSION=admin
|
||||
METHOD="hardcoded allowlist"
|
||||
;;
|
||||
*)
|
||||
# Detect platform and check permissions via API
|
||||
API_BASE="${GITHUB_API_URL:-${GITEA_API_URL:-https://api.github.com}}"
|
||||
RESP=$(curl -sf -H "Authorization: token ${TOKEN}" \
|
||||
"${API_BASE}/repos/${REPO}/collaborators/${ACTOR}/permission" 2>/dev/null || echo '{}')
|
||||
PERMISSION=$(echo "$RESP" | grep -oP '"permission"\s*:\s*"\K[^"]+' || echo "unknown")
|
||||
if [ "$PERMISSION" = "admin" ] || [ "$PERMISSION" = "maintain" ] || [ "$PERMISSION" = "owner" ]; then
|
||||
ALLOWED=true
|
||||
fi
|
||||
METHOD="collaborator API"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "permission=${PERMISSION}" >> "$GITHUB_OUTPUT"
|
||||
echo "allowed=${ALLOWED}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
{
|
||||
echo "## Access Authorization"
|
||||
echo ""
|
||||
echo "| Field | Value |"
|
||||
echo "|-------|-------|"
|
||||
echo "| **Actor** | \`${ACTOR}\` |"
|
||||
echo "| **Repository** | \`${REPO}\` |"
|
||||
echo "| **Permission** | \`${PERMISSION}\` |"
|
||||
echo "| **Method** | ${METHOD} |"
|
||||
echo "| **Authorized** | ${ALLOWED} |"
|
||||
echo ""
|
||||
if [ "$ALLOWED" = "true" ]; then
|
||||
echo "${ACTOR} authorized (${METHOD})"
|
||||
else
|
||||
echo "${ACTOR} is NOT authorized. Requires admin or maintain role."
|
||||
fi
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
|
||||
- name: Deny execution when not permitted
|
||||
if: ${{ steps.perm.outputs.allowed != 'true' }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
printf '%s\n' 'ERROR: Access denied. Admin permission required.' >> "${GITHUB_STEP_SUMMARY}"
|
||||
exit 1
|
||||
|
||||
scripts_governance:
|
||||
name: Scripts governance
|
||||
needs: access_check
|
||||
if: ${{ needs.access_check.outputs.allowed == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Scripts folder checks
|
||||
env:
|
||||
PROFILE_RAW: ${{ github.event.inputs.profile }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
profile="${PROFILE_RAW:-all}"
|
||||
case "${profile}" in
|
||||
all|scripts|repo) ;;
|
||||
*)
|
||||
printf '%s\n' "ERROR: Unknown profile: ${profile}" >> "${GITHUB_STEP_SUMMARY}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${profile}" = 'repo' ]; then
|
||||
{
|
||||
printf '%s\n' '### Scripts governance'
|
||||
printf '%s\n' "Profile: ${profile}"
|
||||
printf '%s\n' 'Status: SKIPPED'
|
||||
printf '%s\n' 'Reason: profile excludes scripts governance'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -d "${SCRIPT_DIR}" ]; then
|
||||
{
|
||||
printf '%s\n' '### Scripts governance'
|
||||
printf '%s\n' 'Status: OK (advisory)'
|
||||
printf '%s\n' 'scripts/ directory not present. No scripts governance enforced.'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "${SCRIPTS_REQUIRED_DIRS:-}" ]; then IFS=',' read -r -a required_dirs <<< "${SCRIPTS_REQUIRED_DIRS}"; else required_dirs=(); fi
|
||||
IFS=',' read -r -a allowed_dirs <<< "${SCRIPTS_ALLOWED_DIRS}"
|
||||
|
||||
missing_dirs=()
|
||||
unapproved_dirs=()
|
||||
|
||||
for d in "${required_dirs[@]}"; do
|
||||
req="${d%/}"
|
||||
[ ! -d "${req}" ] && missing_dirs+=("${req}/")
|
||||
done
|
||||
|
||||
while IFS= read -r d; do
|
||||
allowed=false
|
||||
for a in "${allowed_dirs[@]}"; do
|
||||
a_norm="${a%/}"
|
||||
[ "${d%/}" = "${a_norm}" ] && allowed=true
|
||||
done
|
||||
[ "${allowed}" = false ] && unapproved_dirs+=("${d%/}/")
|
||||
done < <(find "${SCRIPT_DIR}" -maxdepth 1 -mindepth 1 -type d 2>/dev/null | sed 's#^\./##')
|
||||
|
||||
{
|
||||
printf '%s\n' '### Scripts governance'
|
||||
printf '%s\n' "Profile: ${profile}"
|
||||
printf '%s\n' '| Area | Status | Notes |'
|
||||
printf '%s\n' '|---|---|---|'
|
||||
|
||||
if [ "${#missing_dirs[@]}" -gt 0 ]; then
|
||||
printf '%s\n' '| Required directories | Warning | Missing required subfolders |'
|
||||
else
|
||||
printf '%s\n' '| Required directories | OK | All required subfolders present |'
|
||||
fi
|
||||
|
||||
if [ "${#unapproved_dirs[@]}" -gt 0 ]; then
|
||||
printf '%s\n' '| Directory policy | Warning | Unapproved directories detected |'
|
||||
else
|
||||
printf '%s\n' '| Directory policy | OK | No unapproved directories |'
|
||||
fi
|
||||
|
||||
printf '%s\n' '| Enforcement mode | Advisory | scripts folder is optional |'
|
||||
printf '\n'
|
||||
|
||||
if [ "${#missing_dirs[@]}" -gt 0 ]; then
|
||||
printf '%s\n' 'Missing required script directories:'
|
||||
for m in "${missing_dirs[@]}"; do printf '%s\n' "- ${m}"; done
|
||||
printf '\n'
|
||||
else
|
||||
printf '%s\n' 'Missing required script directories: none.'
|
||||
printf '\n'
|
||||
fi
|
||||
|
||||
if [ "${#unapproved_dirs[@]}" -gt 0 ]; then
|
||||
printf '%s\n' 'Unapproved script directories detected:'
|
||||
for m in "${unapproved_dirs[@]}"; do printf '%s\n' "- ${m}"; done
|
||||
printf '\n'
|
||||
else
|
||||
printf '%s\n' 'Unapproved script directories detected: none.'
|
||||
printf '\n'
|
||||
fi
|
||||
|
||||
printf '%s\n' 'Scripts governance completed in advisory mode.'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
|
||||
repo_health:
|
||||
name: Repository health
|
||||
needs: access_check
|
||||
if: ${{ needs.access_check.outputs.allowed == 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Repository health checks
|
||||
env:
|
||||
PROFILE_RAW: ${{ github.event.inputs.profile }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
profile="${PROFILE_RAW:-all}"
|
||||
case "${profile}" in
|
||||
all|scripts|repo) ;;
|
||||
*)
|
||||
printf '%s\n' "ERROR: Unknown profile: ${profile}" >> "${GITHUB_STEP_SUMMARY}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${profile}" = 'scripts' ]; then
|
||||
{
|
||||
printf '%s\n' '### Repository health'
|
||||
printf '%s\n' "Profile: ${profile}"
|
||||
printf '%s\n' 'Status: SKIPPED'
|
||||
printf '%s\n' 'Reason: profile excludes repository health'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
IFS=',' read -r -a required_artifacts <<< "${REPO_REQUIRED_ARTIFACTS}"
|
||||
IFS=',' read -r -a optional_files <<< "${REPO_OPTIONAL_FILES}"
|
||||
if [ -n "${REPO_DISALLOWED_DIRS:-}" ]; then IFS=',' read -r -a disallowed_dirs <<< "${REPO_DISALLOWED_DIRS}"; else disallowed_dirs=(); fi
|
||||
IFS=',' read -r -a disallowed_files <<< "${REPO_DISALLOWED_FILES:-}"
|
||||
|
||||
missing_required=()
|
||||
missing_optional=()
|
||||
|
||||
# Source directory: source/, src/, or htdocs/ (any is valid for extension repos)
|
||||
SOURCE_DIR=""
|
||||
if [ -d "source" ]; then
|
||||
SOURCE_DIR="source"
|
||||
elif [ -d "src" ]; then
|
||||
SOURCE_DIR="src"
|
||||
elif [ -d "htdocs" ]; then
|
||||
SOURCE_DIR="htdocs"
|
||||
elif [ -d "deploy" ] || [ -d "cli" ] || [ -d "monitoring" ]; then
|
||||
# Platform/tooling repos don't need source/
|
||||
SOURCE_DIR=""
|
||||
else
|
||||
missing_required+=("source/ or src/ or htdocs/ (source directory required)")
|
||||
fi
|
||||
|
||||
for item in "${required_artifacts[@]}"; do
|
||||
if printf '%s' "${item}" | grep -q '/$'; then
|
||||
d="${item%/}"
|
||||
[ ! -d "${d}" ] && missing_required+=("${item}")
|
||||
else
|
||||
[ ! -f "${item}" ] && missing_required+=("${item}")
|
||||
fi
|
||||
done
|
||||
|
||||
for f in "${optional_files[@]}"; do
|
||||
if printf '%s' "${f}" | grep -q '/$'; then
|
||||
d="${f%/}"
|
||||
[ ! -d "${d}" ] && missing_optional+=("${f}")
|
||||
else
|
||||
[ ! -f "${f}" ] && missing_optional+=("${f}")
|
||||
fi
|
||||
done
|
||||
|
||||
for d in "${disallowed_dirs[@]}"; do
|
||||
d_norm="${d%/}"
|
||||
[ -d "${d_norm}" ] && missing_required+=("${d_norm}/ (disallowed)")
|
||||
done
|
||||
|
||||
for f in "${disallowed_files[@]}"; do
|
||||
[ -f "${f}" ] && missing_required+=("${f} (disallowed)")
|
||||
done
|
||||
|
||||
git fetch origin --prune
|
||||
|
||||
dev_paths=()
|
||||
dev_branches=()
|
||||
|
||||
while IFS= read -r b; do
|
||||
name="${b#origin/}"
|
||||
if [ "${name}" = 'dev' ]; then
|
||||
dev_branches+=("${name}")
|
||||
else
|
||||
dev_paths+=("${name}")
|
||||
fi
|
||||
done < <(git branch -r --list 'origin/dev*' | sed 's/^ *//')
|
||||
|
||||
if [ "${#dev_paths[@]}" -eq 0 ] && [ "${#dev_branches[@]}" -eq 0 ]; then
|
||||
missing_required+=("dev or dev/* branch")
|
||||
fi
|
||||
|
||||
content_warnings=()
|
||||
|
||||
if [ -f 'CHANGELOG.md' ] && ! grep -Eq '^# Changelog' CHANGELOG.md; then
|
||||
content_warnings+=("CHANGELOG.md missing '# Changelog' header")
|
||||
fi
|
||||
|
||||
if [ -f 'CHANGELOG.md' ] && grep -Eq '^[# ]*Unreleased' CHANGELOG.md; then
|
||||
content_warnings+=("CHANGELOG.md contains Unreleased section (review release readiness)")
|
||||
fi
|
||||
|
||||
if [ -f 'LICENSE' ] && ! grep -qiE 'GNU GENERAL PUBLIC LICENSE|GPL' LICENSE; then
|
||||
content_warnings+=("LICENSE does not look like a GPL text")
|
||||
fi
|
||||
|
||||
if [ -f 'README.md' ] && ! grep -qiE 'moko|Moko' README.md; then
|
||||
content_warnings+=("README.md missing expected brand keyword")
|
||||
fi
|
||||
|
||||
export PROFILE_RAW="${profile}"
|
||||
export MISSING_REQUIRED="$(printf '%s\n' "${missing_required[@]:-}")"
|
||||
export MISSING_OPTIONAL="$(printf '%s\n' "${missing_optional[@]:-}")"
|
||||
export CONTENT_WARNINGS="$(printf '%s\n' "${content_warnings[@]:-}")"
|
||||
|
||||
report_json=$(printf '{"profile":"%s","missing_required":%d,"missing_optional":%d,"content_warnings":%d}' "$profile" "${#missing_required[@]}" "${#missing_optional[@]}" "${#content_warnings[@]}")
|
||||
|
||||
{
|
||||
printf '%s\n' '### Repository health'
|
||||
printf '%s\n' "Profile: ${profile}"
|
||||
printf '%s\n' '| Metric | Value |'
|
||||
printf '%s\n' '|---|---|'
|
||||
printf '%s\n' "| Missing required | ${#missing_required[@]} |"
|
||||
printf '%s\n' "| Missing optional | ${#missing_optional[@]} |"
|
||||
printf '%s\n' "| Content warnings | ${#content_warnings[@]} |"
|
||||
printf '\n'
|
||||
|
||||
printf '%s\n' '### Guardrails report (JSON)'
|
||||
printf '%s\n' '```json'
|
||||
printf '%s\n' "${report_json}"
|
||||
printf '%s\n' '```'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
|
||||
if [ "${#missing_required[@]}" -gt 0 ]; then
|
||||
{
|
||||
printf '%s\n' '### Missing required repo artifacts'
|
||||
for m in "${missing_required[@]}"; do printf '%s\n' "- ${m}"; done
|
||||
printf '%s\n' 'ERROR: Guardrails failed. Missing required repository artifacts.'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${#missing_optional[@]}" -gt 0 ]; then
|
||||
{
|
||||
printf '%s\n' '### Missing optional repo artifacts'
|
||||
for m in "${missing_optional[@]}"; do printf '%s\n' "- ${m}"; done
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
|
||||
if [ "${#content_warnings[@]}" -gt 0 ]; then
|
||||
{
|
||||
printf '%s\n' '### Repo content warnings'
|
||||
for m in "${content_warnings[@]}"; do printf '%s\n' "- ${m}"; done
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
|
||||
# -- Joomla-specific checks --
|
||||
joomla_findings=()
|
||||
|
||||
MANIFEST="$(find . -maxdepth 2 -name '*.xml' -exec grep -l '<extension' {} \; 2>/dev/null | head -1 || true)"
|
||||
if [ -z "${MANIFEST}" ]; then
|
||||
joomla_findings+=("Joomla XML manifest not found (no *.xml with <extension> tag)")
|
||||
else
|
||||
if ! grep -qP '<version>' "${MANIFEST}"; then
|
||||
joomla_findings+=("XML manifest: <version> tag missing")
|
||||
fi
|
||||
if ! grep -qP 'type="(component|module|plugin|library|package|template|language)"' "${MANIFEST}"; then
|
||||
joomla_findings+=("XML manifest: type attribute missing or invalid")
|
||||
fi
|
||||
if ! grep -qP '<name>' "${MANIFEST}"; then
|
||||
joomla_findings+=("XML manifest: <name> tag missing")
|
||||
fi
|
||||
if ! grep -qP '<author>' "${MANIFEST}"; then
|
||||
joomla_findings+=("XML manifest: <author> tag missing")
|
||||
fi
|
||||
if ! grep -qP '<namespace' "${MANIFEST}"; then
|
||||
joomla_findings+=("XML manifest: <namespace> missing (required for Joomla 5+)")
|
||||
fi
|
||||
fi
|
||||
|
||||
INI_COUNT="$(find . -name '*.ini' -type f 2>/dev/null | wc -l)"
|
||||
if [ "${INI_COUNT}" -eq 0 ]; then
|
||||
joomla_findings+=("No .ini language files found")
|
||||
fi
|
||||
|
||||
if [ ! -f 'updates.xml' ]; then
|
||||
joomla_findings+=("updates.xml missing in root (required for Joomla update server)")
|
||||
fi
|
||||
|
||||
if [ -n "${SOURCE_DIR}" ]; then
|
||||
INDEX_DIRS=("${SOURCE_DIR}" "${SOURCE_DIR}/admin" "${SOURCE_DIR}/site")
|
||||
for dir in "${INDEX_DIRS[@]}"; do
|
||||
if [ -d "${dir}" ] && [ ! -f "${dir}/index.html" ]; then
|
||||
joomla_findings+=("${dir}/index.html missing (directory listing protection)")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "${#joomla_findings[@]}" -gt 0 ]; then
|
||||
{
|
||||
printf '%s\n' '### Joomla extension checks'
|
||||
printf '%s\n' '| Check | Status |'
|
||||
printf '%s\n' '|---|---|'
|
||||
for f in "${joomla_findings[@]}"; do
|
||||
printf '%s\n' "| ${f} | Warning |"
|
||||
done
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
else
|
||||
{
|
||||
printf '%s\n' '### Joomla extension checks'
|
||||
printf '%s\n' 'All Joomla-specific checks passed.'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
|
||||
extended_enabled="${EXTENDED_CHECKS:-true}"
|
||||
extended_findings=()
|
||||
|
||||
if [ "${extended_enabled}" = 'true' ]; then
|
||||
if [ -f '.github/CODEOWNERS' ] || [ -f 'CODEOWNERS' ] || [ -f 'docs/CODEOWNERS' ]; then
|
||||
:
|
||||
else
|
||||
extended_findings+=("CODEOWNERS not found (.github/CODEOWNERS preferred)")
|
||||
fi
|
||||
|
||||
if ls "${WORKFLOWS_DIR}"/*.yml >/dev/null 2>&1 || ls "${WORKFLOWS_DIR}"/*.yaml >/dev/null 2>&1; then
|
||||
bad_refs="$(grep -RIn --include='*.yml' --include='*.yaml' -E '^[[:space:]]*uses:[[:space:]]*[^#]+@(main|master)\b' "${WORKFLOWS_DIR}" 2>/dev/null || true)"
|
||||
if [ -n "${bad_refs}" ]; then
|
||||
extended_findings+=("Workflows reference actions @main/@master (pin versions): see log excerpt")
|
||||
{
|
||||
printf '%s\n' '### Workflow pinning advisory'
|
||||
printf '%s\n' 'Found uses: entries pinned to main/master:'
|
||||
printf '%s\n' '```'
|
||||
printf '%s\n' "${bad_refs}"
|
||||
printf '%s\n' '```'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -f "${DOCS_INDEX}" ]; then
|
||||
missing_links=""
|
||||
while IFS= read -r docline; do
|
||||
for link in $(echo "$docline" | grep -oE '\]\([^)]+\)' | sed 's/\](//' | sed 's/)$//' || true); do
|
||||
case "$link" in http://*|https://*|"#"*|mailto:*) continue ;; esac
|
||||
linkpath="${link%%#*}"
|
||||
linkpath="${linkpath%%\?*}"
|
||||
[ -z "$linkpath" ] && continue
|
||||
if [ "${linkpath:0:1}" = "/" ]; then
|
||||
testpath="${linkpath#/}"
|
||||
else
|
||||
testpath="$(dirname "${DOCS_INDEX}")/${linkpath}"
|
||||
fi
|
||||
[ ! -e "$testpath" ] && missing_links="${missing_links}${testpath} "
|
||||
done
|
||||
done < "${DOCS_INDEX}"
|
||||
if [ -n "${missing_links}" ]; then
|
||||
extended_findings+=("docs/docs-index.md contains broken relative links")
|
||||
{
|
||||
printf '%s\n' '### Docs index link integrity'
|
||||
printf '%s\n' 'Broken relative links:'
|
||||
for bl in ${missing_links}; do
|
||||
printf '%s\n' "- ${bl}"
|
||||
done
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "${SCRIPT_DIR}" ]; then
|
||||
if ! command -v shellcheck >/dev/null 2>&1; then
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y shellcheck >/dev/null
|
||||
fi
|
||||
|
||||
sc_out=''
|
||||
while IFS= read -r shf; do
|
||||
[ -z "${shf}" ] && continue
|
||||
out_one="$(shellcheck -S warning -x "${shf}" 2>/dev/null || true)"
|
||||
if [ -n "${out_one}" ]; then
|
||||
sc_out="${sc_out}${out_one}\n"
|
||||
fi
|
||||
done < <(find "${SCRIPT_DIR}" -type f -name "${SHELLCHECK_PATTERN}" 2>/dev/null | sort)
|
||||
|
||||
if [ -n "${sc_out}" ]; then
|
||||
extended_findings+=("ShellCheck warnings detected (advisory)")
|
||||
sc_head="$(printf '%s' "${sc_out}" | head -n 200)"
|
||||
{
|
||||
printf '%s\n' '### ShellCheck (advisory)'
|
||||
printf '%s\n' '```'
|
||||
printf '%s\n' "${sc_head}"
|
||||
printf '%s\n' '```'
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
fi
|
||||
|
||||
spdx_missing=()
|
||||
IFS=',' read -r -a spdx_globs <<< "${SPDX_FILE_GLOBS}"
|
||||
spdx_args=()
|
||||
for g in "${spdx_globs[@]}"; do spdx_args+=("${g}"); done
|
||||
|
||||
while IFS= read -r f; do
|
||||
[ -z "${f}" ] && continue
|
||||
if ! head -n 40 "${f}" | grep -q 'SPDX-License-Identifier:'; then
|
||||
spdx_missing+=("${f}")
|
||||
fi
|
||||
done < <(git ls-files "${spdx_args[@]}" 2>/dev/null || true)
|
||||
|
||||
if [ "${#spdx_missing[@]}" -gt 0 ]; then
|
||||
extended_findings+=("SPDX header missing in some tracked files (advisory)")
|
||||
{
|
||||
printf '%s\n' '### SPDX header advisory'
|
||||
printf '%s\n' 'Files missing SPDX-License-Identifier (first 40 lines scan):'
|
||||
for f in "${spdx_missing[@]}"; do printf '%s\n' "- ${f}"; done
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
|
||||
stale_cutoff_days=180
|
||||
stale_branches="$(git for-each-ref --format='%(refname:short) %(committerdate:unix)' refs/remotes/origin 2>/dev/null | awk -v now="$(date +%s)" -v days="${stale_cutoff_days}" '{if (now-$2 > days*86400) print $1}' | head -50)"
|
||||
if [ -n "${stale_branches}" ]; then
|
||||
extended_findings+=("Stale remote branches detected (advisory)")
|
||||
{
|
||||
printf '%s\n' '### Git hygiene advisory'
|
||||
printf '%s\n' "Branches with last commit older than ${stale_cutoff_days} days (sample up to 50):"
|
||||
while IFS= read -r b; do [ -n "${b}" ] && printf '%s\n' "- ${b}"; done <<< "${stale_branches}"
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
fi
|
||||
|
||||
{
|
||||
printf '%s\n' '### Guardrails coverage matrix'
|
||||
printf '%s\n' '| Domain | Status | Notes |'
|
||||
printf '%s\n' '|---|---|---|'
|
||||
printf '%s\n' '| Access control | OK | Admin-only execution gate |'
|
||||
printf '%s\n' '| Release policy | N/A | Releases handled by MokoGitea |'
|
||||
printf '%s\n' '| Scripts governance | OK | Directory policy and advisory reporting |'
|
||||
printf '%s\n' '| Repo required artifacts | OK | Required, optional, disallowed enforcement |'
|
||||
printf '%s\n' '| Repo content heuristics | OK | Brand, license, changelog structure |'
|
||||
if [ "${extended_enabled}" = 'true' ]; then
|
||||
if [ "${#extended_findings[@]}" -gt 0 ]; then
|
||||
printf '%s\n' '| Extended checks | Warning | See extended findings below |'
|
||||
else
|
||||
printf '%s\n' '| Extended checks | OK | No findings |'
|
||||
fi
|
||||
else
|
||||
printf '%s\n' '| Extended checks | SKIPPED | EXTENDED_CHECKS disabled |'
|
||||
fi
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
|
||||
if [ "${extended_enabled}" = 'true' ] && [ "${#extended_findings[@]}" -gt 0 ]; then
|
||||
{
|
||||
printf '%s\n' '### Extended findings (advisory)'
|
||||
for f in "${extended_findings[@]}"; do printf '%s\n' "- ${f}"; done
|
||||
printf '\n'
|
||||
} >> "${GITHUB_STEP_SUMMARY}"
|
||||
fi
|
||||
|
||||
printf '%s\n' 'Repository health guardrails passed.' >> "${GITHUB_STEP_SUMMARY}"
|
||||
|
||||
|
||||
site-health:
|
||||
name: Site Health
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.3'
|
||||
|
||||
- name: Uptime check
|
||||
if: env.URLS != ''
|
||||
run: |
|
||||
echo "$URLS" > /tmp/urls.txt
|
||||
php monitoring/uptime-probe.php --urls /tmp/urls.txt --timeout 15 || echo "::warning::Some sites are down"
|
||||
rm -f /tmp/urls.txt
|
||||
env:
|
||||
URLS: ${{ vars.MONITORED_URLS }}
|
||||
|
||||
- name: SSL certificate check
|
||||
if: env.DOMAINS != ''
|
||||
run: |
|
||||
echo "$DOMAINS" > /tmp/domains.txt
|
||||
php monitoring/ssl-check.php --domains /tmp/domains.txt --warn-days 30 || echo "::warning::SSL certificates expiring soon"
|
||||
rm -f /tmp/domains.txt
|
||||
env:
|
||||
DOMAINS: ${{ vars.MONITORED_DOMAINS }}
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
run: |
|
||||
echo "### Site Health" >> $GITHUB_STEP_SUMMARY
|
||||
echo "Uptime and SSL checks completed." >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════
|
||||
# Issue Reporter — file issues for failed gates
|
||||
# ═══════════════════════════════════════════════════════════════════════
|
||||
report-issues:
|
||||
name: "Report Issues"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [access_check, scripts_governance, repo_health]
|
||||
if: >-
|
||||
always() &&
|
||||
(needs.scripts_governance.result == 'failure' ||
|
||||
needs.repo_health.result == 'failure')
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: automation/ci-issue-reporter.sh
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: "File issues for failed gates"
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||
run: |
|
||||
chmod +x automation/ci-issue-reporter.sh
|
||||
REPORTER="./automation/ci-issue-reporter.sh"
|
||||
WF="Repo Health"
|
||||
|
||||
report_gate() {
|
||||
local gate="$1" result="$2" details="$3"
|
||||
if [ "$result" = "failure" ]; then
|
||||
"$REPORTER" --gate "$gate" --details "$details" --workflow "$WF" --severity error
|
||||
fi
|
||||
}
|
||||
|
||||
report_gate "Scripts Governance" \
|
||||
"${{ needs.scripts_governance.result }}" \
|
||||
"Scripts directory policy violations detected. Review required and allowed directories."
|
||||
|
||||
report_gate "Repository Health" \
|
||||
"${{ needs.repo_health.result }}" \
|
||||
"Repository health checks failed — missing required artifacts, disallowed files, or content warnings. Check the CI run summary."
|
||||
@@ -1,82 +0,0 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Gitea.Workflow
|
||||
# INGROUP: MokoStandards.Security
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
||||
# PATH: /.gitea/workflows/security-audit.yml
|
||||
# VERSION: 01.00.00
|
||||
# BRIEF: Dependency vulnerability scanning for composer and npm packages
|
||||
|
||||
name: "Universal: Security Audit"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 6 * * 1' # Weekly on Monday at 06:00 UTC
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'composer.json'
|
||||
- 'composer.lock'
|
||||
- 'package.json'
|
||||
- 'package-lock.json'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
NTFY_URL: ${{ vars.NTFY_URL || 'https://ntfy.mokoconsulting.tech' }}
|
||||
NTFY_TOPIC: ${{ vars.NTFY_TOPIC || 'gitea-security' }}
|
||||
|
||||
jobs:
|
||||
audit:
|
||||
name: Dependency Audit
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Composer audit
|
||||
if: hashFiles('composer.lock') != ''
|
||||
run: |
|
||||
echo "=== Composer Security Audit ==="
|
||||
if ! command -v composer &> /dev/null; then
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq php-cli composer >/dev/null 2>&1
|
||||
fi
|
||||
composer audit --format=plain 2>&1 | tee /tmp/composer-audit.txt
|
||||
RESULT=$?
|
||||
if [ $RESULT -ne 0 ]; then
|
||||
echo "::warning::Composer vulnerabilities found"
|
||||
echo "composer_vulnerable=true" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "No known vulnerabilities in composer dependencies"
|
||||
fi
|
||||
|
||||
- name: NPM audit
|
||||
if: hashFiles('package-lock.json') != ''
|
||||
run: |
|
||||
echo "=== NPM Security Audit ==="
|
||||
npm audit --production 2>&1 | tee /tmp/npm-audit.txt || true
|
||||
if npm audit --production 2>&1 | grep -q "found 0 vulnerabilities"; then
|
||||
echo "No known vulnerabilities in npm dependencies"
|
||||
else
|
||||
echo "::warning::NPM vulnerabilities found"
|
||||
echo "npm_vulnerable=true" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Notify on vulnerabilities
|
||||
if: env.composer_vulnerable == 'true' || env.npm_vulnerable == 'true'
|
||||
run: |
|
||||
REPO="${{ github.event.repository.name }}"
|
||||
curl -sS \
|
||||
-H "Title: ${REPO} has vulnerable dependencies" \
|
||||
-H "Tags: lock,warning" \
|
||||
-H "Priority: high" \
|
||||
-d "Security audit found vulnerabilities. Review dependency updates." \
|
||||
"${NTFY_URL}/${NTFY_TOPIC}" || true
|
||||
+14
-53
@@ -1,28 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
<!-- VERSION: 01.00.00 -->
|
||||
|
||||
|
||||
<!-- VERSION: 01.01.02 -->
|
||||
|
||||
All notable changes to MokoSuiteCross will be documented in this file.
|
||||
All notable changes to MokoJoomCross will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
- **C-1 OauthController**: Added CSRF nonce validation to OAuth callback — session-based nonce is generated during `authorize()`, embedded in the state parameter, and verified in `callback()` to prevent CSRF attacks
|
||||
- **C-2 DispatchController**: Added POST method enforcement — rejects non-POST requests with 405 status
|
||||
- **C-5 ServiceModel**: Credential form fields (`cred_*`) are now collected into the `credentials` JSON column on save, and expanded back into individual fields on load — previously these fields were silently discarded
|
||||
- **H-1 Event pattern**: Fixed Joomla 5 SubscriberInterface incompatibility where `onMokoSuiteCrossGetServices` by-reference pattern silently lost all service plugins — dispatchers now read plugin instances from Event ArrayAccess indices after dispatch
|
||||
- **H-4 ServiceTable**: Added `check()` method with alias generation, required field validation (title, service_type), timestamp management, and JSON defaults for credentials/params
|
||||
- **H-9 WebhookService**: Fixed credential key mismatch — `publish()` and `validateCredentials()` now use keys matching the service.xml form fields (`url`, `method`, `auth_type`, `bearer_token`, `basic_username`, `basic_password`, `content_type`) and properly apply Bearer/Basic auth headers
|
||||
- **M-4 ServiceIconHelper**: Escaped `$extraClass` parameter in `renderIcon()` with `htmlspecialchars()` to prevent XSS
|
||||
- **M-5 Content plugin**: Fixed double-escaped HTML in cross-post history panel — uses `setFieldAttribute()` to inject history HTML into the note field description after XML load, avoiding XML attribute encoding
|
||||
|
||||
- **Content plugin**: Fixed `onContentBeforeDisplay` signature for Joomla 5/6 — now accepts `BeforeDisplayEvent` object instead of individual parameters
|
||||
|
||||
### Added
|
||||
- **CrossPostDispatcher**: New static helper (`com_mokojoomcross/Helper/CrossPostDispatcher`) centralising dispatch logic for reuse by all source plugins
|
||||
- **Content plugin**: Added `onContentAfterSave` and `onContentChangeState` handlers with Joomla 5/6 event compatibility, dispatching via `CrossPostDispatcher`
|
||||
- **plg_system_mokojoomcross_events**: New source plugin for MokoJoomCalendar — cross-posts calendar events when published
|
||||
- **plg_system_mokojoomcross_gallery**: New source plugin for MokoJoomGallery — cross-posts galleries and images when published
|
||||
|
||||
### Fixed
|
||||
- **QueueProcessor**: Replaced read-then-write DB lock with MySQL advisory locks (`GET_LOCK`/`RELEASE_LOCK`) to eliminate race condition
|
||||
- **Twitter/X**: Replaced Bearer token auth with OAuth 1.0a (HMAC-SHA1) — Bearer tokens are app-only and cannot create tweets
|
||||
- **service.xml**: Fixed missing closing `</field>` tag on webhook method field
|
||||
@@ -38,24 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- **Nostr**: Stub with clear "not yet implemented" message (requires WebSocket)
|
||||
- **RSS Feed**: Local service — no external API, always succeeds
|
||||
|
||||
|
||||
### Added
|
||||
- **ServiceIconHelper**: Centralised icon mapping for all 34 service types — replaces per-template icon arrays with `ServiceIconHelper::getIcon()` / `::renderIcon()`
|
||||
- **Service Stats drill-down**: New `servicestats` view with per-service analytics — post counts, success rate, daily trend chart, recent posts table, and top articles list
|
||||
- **Dashboard service links**: Service breakdown table rows now link to the per-service stats view with service type icons
|
||||
- **Posts list icons**: Service type column in the posts list now shows the service icon
|
||||
- **Category routing rules**: New `#__mokosuitecross_category_rules` table to whitelist services per Joomla category — if rules exist for a category, only those services receive posts; no rules = all services (backward compatible)
|
||||
- **CrossPostDispatcher**: Category rule filtering integrated before per-article service filter in the dispatch loop
|
||||
- **Template editor**: Live character counter below template body textarea with platform-aware limits (green/yellow/red badges)
|
||||
- **Template editor**: Added `{tags}`, `{hashtags}`, and `{field:xxx}` rows to the placeholder reference table
|
||||
- **Content plugin**: Cross-post history panel in article editor showing last 10 posts with status badges, service names, timestamps, and error messages
|
||||
- **Config**: New "Category Rules" fieldset with explanatory note about the feature
|
||||
|
||||
- **CrossPostDispatcher**: New static helper (`com_mokosuitecross/Helper/CrossPostDispatcher`) centralising dispatch logic for reuse by all source plugins
|
||||
- **Content plugin**: Added `onContentAfterSave` and `onContentChangeState` handlers with Joomla 5/6 event compatibility, dispatching via `CrossPostDispatcher`
|
||||
- **plg_system_mokosuitecross_events**: New source plugin for MokoSuiteCalendar — cross-posts calendar events when published
|
||||
- **plg_system_mokosuitecross_gallery**: New source plugin for MokoSuiteGallery — cross-posts galleries and images when published
|
||||
|
||||
- **Credential fields**: Added fields for 19 previously missing services (Pinterest, Tumblr, TikTok, Nostr, ActivityPub, Brevo, ConvertKit, Constant Contact, Hashnode, Blogger, Google Business, RSS Feed config)
|
||||
- **Twitter**: Access Token and Access Token Secret fields for OAuth 1.0a
|
||||
- **LinkedIn**: Refresh token field for automatic token renewal
|
||||
@@ -83,8 +61,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- **Posts service filter**: SQL-driven service dropdown filter in posts list, plus search filter by article title or message content
|
||||
- **CSV export**: "Export CSV" toolbar button on posts list to download filtered post data as CSV
|
||||
- **WordPress canonical URL**: WordPress cross-posts now include an "Originally published at" source link appended to content with the Joomla article URL
|
||||
- **REST API dispatch endpoint**: `POST /api/v1/mokosuitecross/dispatch` — trigger cross-posts for an article via API with optional service filtering, duplicate guard, and template rendering
|
||||
|
||||
- **REST API dispatch endpoint**: `POST /api/v1/mokojoomcross/dispatch` — trigger cross-posts for an article via API with optional service filtering, duplicate guard, and template rendering
|
||||
|
||||
### Added (original)
|
||||
|
||||
@@ -93,8 +70,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- System plugin hooks `onContentAfterSave` and `onContentChangeState`
|
||||
- Duplicate guard prevents re-posting to services that already received an article
|
||||
- Message template rendering with 8 placeholders: `{title}`, `{url}`, `{introtext}`, `{fulltext}`, `{image}`, `{category}`, `{author}`, `{date}`
|
||||
- Custom `mokosuitecross` plugin group for extensible service architecture
|
||||
- `MokoSuiteCrossServiceInterface` contract for all service plugins
|
||||
- Custom `mokojoomcross` plugin group for extensible service architecture
|
||||
- `MokoJoomCrossServiceInterface` contract for all service plugins
|
||||
|
||||
#### Admin Component (5 views)
|
||||
- **Dashboard** — summary cards, posts-by-service analytics with success rates, top cross-posted articles, recent activity feed, PP Pro migration banner, page-load processing warning
|
||||
@@ -104,7 +81,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- **Activity Logs** — list with level badges (info/warning/error), service column, context data, level and search filters
|
||||
|
||||
#### Queue Processing (3 methods)
|
||||
- Joomla Scheduled Task plugin (`plg_task_mokosuitecross`) — preferred, processes 20 posts per run
|
||||
- Joomla Scheduled Task plugin (`plg_task_mokojoomcross`) — preferred, processes 20 posts per run
|
||||
- Page-load fallback via system plugin `onAfterRender` — configurable throttle interval, backend/frontend/both
|
||||
- Shared `QueueProcessor` helper with DB lock to prevent concurrent execution
|
||||
- Failed post retry with configurable max retries and exponential delay
|
||||
@@ -198,23 +175,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
- 9 wiki documentation pages
|
||||
- Windows Terminal profile in Joomla dropdown
|
||||
|
||||
|
||||
## [01.01.00] - 2026-06-19
|
||||
|
||||
### Added
|
||||
- Initial package structure with component, system plugin, content plugin, and webservices plugin
|
||||
- Admin component with dashboard, post queue, services management, and activity logs
|
||||
- System plugin triggering cross-post on article publish via `onContentAfterSave`
|
||||
- Content plugin adding cross-post controls to article editor
|
||||
- WebServices API plugin with REST endpoints for posts and services
|
||||
- Custom `mokosuitecross` plugin group for extensible service architecture
|
||||
- Service plugins: Facebook, X/Twitter, LinkedIn, Mastodon, Bluesky, Mailchimp, Telegram, Discord, Slack
|
||||
- Database tables: services, posts, templates, logs
|
||||
- Perfect Publisher Pro migration tool in installer script
|
||||
- Message template system with per-platform placeholders
|
||||
- Post queue with scheduled posting, retry logic, and delivery tracking
|
||||
|
||||
## [01.00] - 2026-05-28
|
||||
## [01.00.00] - 2026-05-28
|
||||
|
||||
### Added
|
||||
- Initial release
|
||||
|
||||
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code when working with this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
**MokoSuiteCross** -- Cross-posting Joomla content to social media, email marketing, and chat platforms
|
||||
**MokoJoomCross** -- Cross-posting Joomla content to social media, email marketing, and chat platforms
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
@@ -12,7 +12,7 @@ This file provides guidance to Claude Code when working with this repository.
|
||||
| **Language** | PHP |
|
||||
| **Default branch** | main |
|
||||
| **License** | GPL-3.0-or-later |
|
||||
| **Wiki** | [MokoSuiteCross Wiki](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteCross/wiki) |
|
||||
| **Wiki** | [MokoJoomCross Wiki](https://git.mokoconsulting.tech/MokoConsulting/MokoJoomCross/wiki) |
|
||||
| **Standards** | [MokoStandards](https://git.mokoconsulting.tech/MokoConsulting/moko-platform/wiki/Home) |
|
||||
|
||||
## Common Commands
|
||||
@@ -32,60 +32,60 @@ composer install # Install PHP dependencies
|
||||
|
||||
## Architecture
|
||||
|
||||
This is a Joomla **package** extension (`pkg_mokosuitecross`) containing sub-extensions:
|
||||
This is a Joomla **package** extension (`pkg_mokojoomcross`) containing sub-extensions:
|
||||
|
||||
### com_mokosuitecross (Component)
|
||||
### com_mokojoomcross (Component)
|
||||
- Admin backend for managing services, post queue, templates, and logs
|
||||
- Joomla 5/6 MVC: Dashboard, Services, Posts, Logs (list/edit each)
|
||||
- Namespace: `Joomla\Component\MokoSuiteCross\Administrator`
|
||||
- Database tables: `#__mokosuitecross_services`, `#__mokosuitecross_posts`, `#__mokosuitecross_templates`, `#__mokosuitecross_logs`
|
||||
- Namespace: `Joomla\Component\MokoJoomCross\Administrator`
|
||||
- Database tables: `#__mokojoomcross_services`, `#__mokojoomcross_posts`, `#__mokojoomcross_templates`, `#__mokojoomcross_logs`
|
||||
|
||||
### plg_system_mokosuitecross (System Plugin)
|
||||
### plg_system_mokojoomcross (System Plugin)
|
||||
- Hooks `onContentAfterSave` to trigger cross-posting when articles are published
|
||||
- Dispatches to registered service plugins via the `mokosuitecross` plugin group
|
||||
- Namespace: `Joomla\Plugin\System\MokoSuiteCross`
|
||||
- Dispatches to registered service plugins via the `mokojoomcross` plugin group
|
||||
- Namespace: `Joomla\Plugin\System\MokoJoomCross`
|
||||
|
||||
### plg_content_mokosuitecross (Content Plugin)
|
||||
### plg_content_mokojoomcross (Content Plugin)
|
||||
- Hooks `onContentBeforeDisplay` to add cross-post status badges to articles
|
||||
- Namespace: `Joomla\Plugin\Content\MokoSuiteCross`
|
||||
- Namespace: `Joomla\Plugin\Content\MokoJoomCross`
|
||||
|
||||
### plg_webservices_mokosuitecross (WebServices Plugin)
|
||||
### plg_webservices_mokojoomcross (WebServices Plugin)
|
||||
- REST API endpoints for posts and services
|
||||
- Namespace: `Joomla\Plugin\WebServices\MokoSuiteCross`
|
||||
- Namespace: `Joomla\Plugin\WebServices\MokoJoomCross`
|
||||
|
||||
### Service Plugins (mokosuitecross group)
|
||||
Each platform is a separate plugin in the custom `mokosuitecross` plugin group:
|
||||
- `plg_mokosuitecross_facebook` — Facebook/Meta Graph API
|
||||
- `plg_mokosuitecross_twitter` — X/Twitter API v2
|
||||
- `plg_mokosuitecross_linkedin` — LinkedIn Share API
|
||||
- `plg_mokosuitecross_mastodon` — Mastodon API
|
||||
- `plg_mokosuitecross_bluesky` — Bluesky AT Protocol
|
||||
- `plg_mokosuitecross_mailchimp` — Mailchimp Campaigns API
|
||||
- `plg_mokosuitecross_telegram` — Telegram Bot API (default @MokoWaaSBot + custom bot)
|
||||
- `plg_mokosuitecross_discord` — Discord Webhooks
|
||||
- `plg_mokosuitecross_slack` — Slack Incoming Webhooks
|
||||
### Service Plugins (mokojoomcross group)
|
||||
Each platform is a separate plugin in the custom `mokojoomcross` plugin group:
|
||||
- `plg_mokojoomcross_facebook` — Facebook/Meta Graph API
|
||||
- `plg_mokojoomcross_twitter` — X/Twitter API v2
|
||||
- `plg_mokojoomcross_linkedin` — LinkedIn Share API
|
||||
- `plg_mokojoomcross_mastodon` — Mastodon API
|
||||
- `plg_mokojoomcross_bluesky` — Bluesky AT Protocol
|
||||
- `plg_mokojoomcross_mailchimp` — Mailchimp Campaigns API
|
||||
- `plg_mokojoomcross_telegram` — Telegram Bot API (default @MokoWaaSBot + custom bot)
|
||||
- `plg_mokojoomcross_discord` — Discord Webhooks
|
||||
- `plg_mokojoomcross_slack` — Slack Incoming Webhooks
|
||||
|
||||
### Database Schema
|
||||
|
||||
Four tables:
|
||||
|
||||
`#__mokosuitecross_services`:
|
||||
`#__mokojoomcross_services`:
|
||||
- `id`, `title`, `alias`, `service_type` (facebook, twitter, etc.)
|
||||
- `credentials` (JSON encrypted), `params` (JSON)
|
||||
- `published`, `ordering`, `created`, `modified`, `created_by`
|
||||
|
||||
`#__mokosuitecross_posts`:
|
||||
`#__mokojoomcross_posts`:
|
||||
- `id`, `article_id` (FK to #__content), `service_id` (FK)
|
||||
- `status` (queued/posting/posted/failed/scheduled)
|
||||
- `message`, `platform_post_id`, `platform_response` (JSON)
|
||||
- `scheduled_at`, `posted_at`, `retry_count`
|
||||
- `created`, `modified`
|
||||
|
||||
`#__mokosuitecross_templates`:
|
||||
`#__mokojoomcross_templates`:
|
||||
- `id`, `service_type`, `title`, `template_body`
|
||||
- `published`, `ordering`, `created`, `modified`
|
||||
|
||||
`#__mokosuitecross_logs`:
|
||||
`#__mokojoomcross_logs`:
|
||||
- `id`, `post_id` (FK), `service_id` (FK)
|
||||
- `level` (info/warning/error), `message`, `context` (JSON)
|
||||
- `created`
|
||||
@@ -109,4 +109,4 @@ Four tables:
|
||||
- `bind() → check() → store()` for Table operations (not `save()`)
|
||||
- Language file placement: site (no `folder`) vs admin (`folder="administrator"`)
|
||||
- SPDX license headers on all PHP files
|
||||
- Service plugins MUST implement `MokoSuiteCrossServiceInterface`
|
||||
- Service plugins MUST implement `MokoJoomCrossServiceInterface`
|
||||
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
# Contributing to Moko Consulting Projects
|
||||
|
||||
Thank you for your interest in contributing. All Moko Consulting repositories follow this universal workflow and version policy.
|
||||
|
||||
## Branching Workflow
|
||||
|
||||
```
|
||||
feature/* ──PR──> dev ──draft PR──> (renamed to rc) ──merge──> main
|
||||
```
|
||||
|
||||
### Step by step
|
||||
|
||||
1. **Create a feature branch** from `dev`:
|
||||
```bash
|
||||
git checkout dev && git pull
|
||||
git checkout -b feature/my-change
|
||||
```
|
||||
|
||||
2. **Work and commit** on your feature branch. Push to origin.
|
||||
|
||||
3. **Open a PR**: `feature/my-change` → `dev`. After review and checks, merge it.
|
||||
|
||||
4. **When ready for release**, open a **draft PR**: `dev` → `main`.
|
||||
- This automatically renames the source branch to `rc` (release candidate)
|
||||
- An RC pre-release is built and uploaded
|
||||
|
||||
5. **Alpha and beta branches** are created by manually renaming the branch before the RC stage:
|
||||
- Rename `dev` to `alpha` for early testing → alpha pre-release is built
|
||||
- Rename `alpha` to `beta` for feature-complete testing → beta pre-release is built
|
||||
- When the draft PR is created, the branch is renamed to `rc`
|
||||
|
||||
6. **Once PR checks pass** on the `rc` branch, mark the PR as ready and merge to `main`.
|
||||
|
||||
7. **Merging to main** triggers the stable release pipeline:
|
||||
- Minor version bump (e.g., `02.09.xx` → `02.10.00`)
|
||||
- Stability suffix stripped (clean version)
|
||||
- Gitea release created with ZIP/tar.gz packages
|
||||
- `updates.xml` updated (Joomla extensions)
|
||||
- `dev` branch recreated from `main`
|
||||
|
||||
### Branch summary
|
||||
|
||||
| Branch | Purpose | Created by |
|
||||
|--------|---------|-----------|
|
||||
| `feature/*` | New features and fixes | Developer |
|
||||
| `dev` | Integration branch | Auto-recreated after release |
|
||||
| `alpha` | Alpha pre-release testing | Manual rename from `dev` |
|
||||
| `beta` | Beta pre-release testing | Manual rename from `alpha` |
|
||||
| `rc` | Release candidate | Auto-renamed on draft PR to main |
|
||||
| `main` | Stable releases | Protected, merge only |
|
||||
| `version/XX.YY.ZZ` | Archived release snapshots | Auto-created by CI |
|
||||
|
||||
### Protected branches
|
||||
|
||||
| Branch | Direct push | Merge via |
|
||||
|--------|------------|-----------|
|
||||
| `main` | Blocked (CI bot whitelisted) | PR merge only |
|
||||
| `dev` | Blocked (CI bot whitelisted) | PR merge from feature/* |
|
||||
| `rc` | Blocked (CI bot whitelisted) | Auto-created on draft PR |
|
||||
| `alpha` | Blocked (CI bot whitelisted) | Manual rename |
|
||||
| `beta` | Blocked (CI bot whitelisted) | Manual rename |
|
||||
| `feature/*` | Open | N/A (source branch) |
|
||||
|
||||
## Version Policy
|
||||
|
||||
### Format
|
||||
|
||||
All versions use `XX.YY.ZZ` — three two-digit segments, zero-padded:
|
||||
|
||||
- **XX** — Major version (breaking changes)
|
||||
- **YY** — Minor version (new features, bumped on release to main)
|
||||
- **ZZ** — Patch version (auto-incremented on every push to dev/feature branches)
|
||||
|
||||
Rollover: patch `99` → `00` increments minor; minor `99` → `00` increments major.
|
||||
|
||||
### Stability suffixes
|
||||
|
||||
Each branch appends a suffix to indicate stability:
|
||||
|
||||
| Branch | Suffix | Example |
|
||||
|--------|--------|---------|
|
||||
| `main` | (none) | `02.09.00` |
|
||||
| `dev` | `-dev` | `02.09.01-dev` |
|
||||
| `feature/*` | `-dev` | `02.09.01-dev` |
|
||||
| `alpha` | `-alpha` | `02.09.01-alpha` |
|
||||
| `beta` | `-beta` | `02.09.01-beta` |
|
||||
| `rc` | `-rc` | `02.09.01-rc` |
|
||||
|
||||
### Auto version bump
|
||||
|
||||
On every push to `dev`, `feature/*`, or `patch/*`:
|
||||
|
||||
1. Patch version incremented
|
||||
2. Stability suffix `-dev` applied
|
||||
3. All version-bearing files updated (manifests, CHANGELOG, PHP headers, etc.)
|
||||
4. Commit created with `[skip ci]` to avoid loops
|
||||
|
||||
### Release version flow
|
||||
|
||||
Version bumps happen at specific release events:
|
||||
|
||||
| Event | Bump | Example |
|
||||
|-------|------|---------|
|
||||
| Feature merged to dev | Patch bump after dev release | `02.09.01-dev` → release → `02.09.02-dev` |
|
||||
| Dev promoted to RC | Minor bump | `02.09.02-dev` → `02.10.00-rc` |
|
||||
| RC merged to main | Minor bump | `02.10.00-rc` → `02.11.00` (stable) |
|
||||
| Dev recreated from main | Patch bump | `02.11.00` → `02.11.01-dev` |
|
||||
|
||||
### Release stream copies
|
||||
|
||||
When a higher-stability release is published, copies are created for all lesser streams with the same base version:
|
||||
|
||||
- **RC `02.10.00-rc`** also creates: `02.10.00-dev`, `02.10.00-alpha`, `02.10.00-beta`
|
||||
- **Stable `02.11.00`** also creates: `02.11.00-dev`, `02.11.00-alpha`, `02.11.00-beta`, `02.11.00-rc`
|
||||
|
||||
This ensures Joomla sites on ANY stability channel see the update (Joomla only shows versions higher than what's installed).
|
||||
|
||||
### Version files
|
||||
|
||||
The version tools update all files containing version stamps:
|
||||
|
||||
- `.mokogitea/manifest.xml` (canonical source)
|
||||
- Joomla XML manifests (`<version>` tag)
|
||||
- `README.md`, `CHANGELOG.md` (`VERSION:` pattern)
|
||||
- `package.json`, `pyproject.toml`
|
||||
- Any text file with a `VERSION: XX.YY.ZZ` label
|
||||
|
||||
Files synced from other repos (with a `# REPO:` header) are not touched.
|
||||
|
||||
## Code Standards
|
||||
|
||||
- **PHP**: PSR-12, tabs for indentation
|
||||
- **Copyright**: all files must include the Moko Consulting copyright header
|
||||
- **License**: SPDX identifier `GPL-3.0-or-later` (or as specified per repo)
|
||||
- **Attribution**: use `Authored-by: Moko Consulting` in commits, not individual names
|
||||
|
||||
## Commit Messages
|
||||
|
||||
Use conventional commit format:
|
||||
|
||||
```
|
||||
type(scope): short description
|
||||
|
||||
Optional body with context.
|
||||
|
||||
Authored-by: Moko Consulting
|
||||
```
|
||||
|
||||
Types: `feat`, `fix`, `chore`, `docs`, `style`, `refactor`, `test`, `ci`
|
||||
|
||||
Special flags in commit messages:
|
||||
- `[skip ci]` — skip all CI workflows
|
||||
- `[skip bump]` — skip auto version bump only
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
Use the repository's issue tracker with the appropriate template.
|
||||
|
||||
---
|
||||
|
||||
*Moko Consulting <hello@mokoconsulting.tech>*
|
||||
@@ -2,14 +2,14 @@
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# MokoSuiteCross — Cross-posting Joomla content to social media, email marketing, and chat platforms
|
||||
# MokoJoomCross — Cross-posting Joomla content to social media, email marketing, and chat platforms
|
||||
|
||||
# ==============================================================================
|
||||
# CONFIGURATION - Customize these for your extension
|
||||
# ==============================================================================
|
||||
|
||||
# Extension Configuration
|
||||
EXTENSION_NAME := mokosuitecross
|
||||
EXTENSION_NAME := mokojoomcross
|
||||
EXTENSION_TYPE := package
|
||||
# Options: module, plugin, component, package, template
|
||||
EXTENSION_VERSION := 1.0.0
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# MokoSuiteCross
|
||||
# MokoJoomCross
|
||||
|
||||
<!-- VERSION: 01.01.02 -->
|
||||
<!-- VERSION: 01.00.22 -->
|
||||
|
||||
Cross-posting Joomla content to social media, email marketing, and chat platforms for Joomla 5/6.
|
||||
|
||||
## Overview
|
||||
|
||||
MokoSuiteCross automatically publishes your Joomla articles to multiple platforms when you hit publish. Connect your social media accounts, email marketing tools, and chat channels — then cross-post with one click. Each platform is a separate plugin, so you only install what you need and third-party developers can add new services.
|
||||
MokoJoomCross automatically publishes your Joomla articles to multiple platforms when you hit publish. Connect your social media accounts, email marketing tools, and chat channels — then cross-post with one click. Each platform is a separate plugin, so you only install what you need and third-party developers can add new services.
|
||||
|
||||
## Features
|
||||
|
||||
@@ -22,29 +22,29 @@ MokoSuiteCross automatically publishes your Joomla articles to multiple platform
|
||||
|
||||
| Platform | Plugin | Status |
|
||||
|----------|--------|--------|
|
||||
| Facebook / Meta | `plg_mokosuitecross_facebook` | Planned |
|
||||
| X / Twitter | `plg_mokosuitecross_twitter` | Planned |
|
||||
| LinkedIn | `plg_mokosuitecross_linkedin` | Planned |
|
||||
| Mastodon | `plg_mokosuitecross_mastodon` | Planned |
|
||||
| Bluesky | `plg_mokosuitecross_bluesky` | Planned |
|
||||
| Mailchimp | `plg_mokosuitecross_mailchimp` | Planned |
|
||||
| Telegram | `plg_mokosuitecross_telegram` | Planned |
|
||||
| Discord | `plg_mokosuitecross_discord` | Planned |
|
||||
| Slack | `plg_mokosuitecross_slack` | Planned |
|
||||
| Facebook / Meta | `plg_mokojoomcross_facebook` | Planned |
|
||||
| X / Twitter | `plg_mokojoomcross_twitter` | Planned |
|
||||
| LinkedIn | `plg_mokojoomcross_linkedin` | Planned |
|
||||
| Mastodon | `plg_mokojoomcross_mastodon` | Planned |
|
||||
| Bluesky | `plg_mokojoomcross_bluesky` | Planned |
|
||||
| Mailchimp | `plg_mokojoomcross_mailchimp` | Planned |
|
||||
| Telegram | `plg_mokojoomcross_telegram` | Planned |
|
||||
| Discord | `plg_mokojoomcross_discord` | Planned |
|
||||
| Slack | `plg_mokojoomcross_slack` | Planned |
|
||||
|
||||
## Installation
|
||||
|
||||
1. Download the latest `pkg_mokosuitecross-*.zip` from [Releases](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteCross/releases)
|
||||
1. Download the latest `pkg_mokojoomcross-*.zip` from [Releases](https://git.mokoconsulting.tech/MokoConsulting/MokoJoomCross/releases)
|
||||
2. In Joomla Administrator → Extensions → Install → Upload Package File
|
||||
3. System and content plugins are enabled automatically on install
|
||||
4. Navigate to Components → MokoSuiteCross to connect your first service
|
||||
4. Navigate to Components → MokoJoomCross to connect your first service
|
||||
|
||||
## Migrating from Perfect Publisher Pro
|
||||
|
||||
MokoSuiteCross includes a built-in migration tool:
|
||||
MokoJoomCross includes a built-in migration tool:
|
||||
|
||||
1. Install MokoSuiteCross (Perfect Publisher Pro can remain installed)
|
||||
2. Navigate to Components → MokoSuiteCross → Dashboard
|
||||
1. Install MokoJoomCross (Perfect Publisher Pro can remain installed)
|
||||
2. Navigate to Components → MokoJoomCross → Dashboard
|
||||
3. Click "Migrate from Perfect Publisher Pro"
|
||||
4. Review detected services and confirm import
|
||||
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ============================================================================
|
||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# FILE INFORMATION
|
||||
# DEFGROUP: Automation.CI
|
||||
# INGROUP: moko-platform.Automation
|
||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||
# PATH: /automation/ci-issue-reporter.sh
|
||||
# VERSION: 09.23.00
|
||||
# BRIEF: Creates or updates a Gitea issue when a CI gate fails.
|
||||
# Deduplicates by searching open issues with the "ci-auto" label
|
||||
# whose title matches the gate. If a matching issue exists, a comment
|
||||
# is appended instead of opening a duplicate.
|
||||
# ============================================================================
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# ── Defaults ────────────────────────────────────────────────────────────────
|
||||
GITEA_URL="${GITEA_URL:-https://git.mokoconsulting.tech}"
|
||||
GITEA_TOKEN="${GITEA_TOKEN:-}"
|
||||
REPO="${GITHUB_REPOSITORY:-}"
|
||||
RUN_URL="${GITHUB_SERVER_URL:-${GITEA_URL}}/${REPO}/actions/runs/${GITHUB_RUN_ID:-0}"
|
||||
LABEL_NAME="ci-auto"
|
||||
LABEL_COLOR="#e11d48"
|
||||
|
||||
GATE=""
|
||||
DETAILS=""
|
||||
SEVERITY="error"
|
||||
WORKFLOW=""
|
||||
|
||||
# ── Parse arguments ─────────────────────────────────────────────────────────
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: ci-issue-reporter.sh --gate NAME --details TEXT [OPTIONS]
|
||||
|
||||
Required:
|
||||
--gate CI gate name (e.g. "Code Quality", "Self-Health")
|
||||
--details Human-readable failure description
|
||||
|
||||
Optional:
|
||||
--severity "error" (default) or "warning"
|
||||
--workflow Workflow name for the issue title
|
||||
--repo owner/repo (default: \$GITHUB_REPOSITORY)
|
||||
--run-url URL to the CI run (auto-detected from env)
|
||||
--token Gitea API token (default: \$GITEA_TOKEN)
|
||||
--url Gitea base URL (default: \$GITEA_URL)
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--gate) GATE="$2"; shift 2 ;;
|
||||
--details) DETAILS="$2"; shift 2 ;;
|
||||
--severity) SEVERITY="$2"; shift 2 ;;
|
||||
--workflow) WORKFLOW="$2"; shift 2 ;;
|
||||
--repo) REPO="$2"; shift 2 ;;
|
||||
--run-url) RUN_URL="$2"; shift 2 ;;
|
||||
--token) GITEA_TOKEN="$2"; shift 2 ;;
|
||||
--url) GITEA_URL="$2"; shift 2 ;;
|
||||
-h|--help) usage ;;
|
||||
*) echo "Unknown option: $1"; usage ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -z "$GATE" ]] && { echo "ERROR: --gate is required"; usage; }
|
||||
[[ -z "$DETAILS" ]] && { echo "ERROR: --details is required"; usage; }
|
||||
[[ -z "$GITEA_TOKEN" ]] && { echo "ERROR: GITEA_TOKEN not set"; exit 1; }
|
||||
[[ -z "$REPO" ]] && { echo "ERROR: GITHUB_REPOSITORY not set"; exit 1; }
|
||||
|
||||
API="${GITEA_URL}/api/v1/repos/${REPO}"
|
||||
|
||||
# ── Build title ─────────────────────────────────────────────────────────────
|
||||
if [[ -n "$WORKFLOW" ]]; then
|
||||
TITLE="[CI] ${WORKFLOW}: ${GATE} failed"
|
||||
else
|
||||
TITLE="[CI] ${GATE} failed"
|
||||
fi
|
||||
|
||||
# ── Ensure label exists ─────────────────────────────────────────────────────
|
||||
ensure_label() {
|
||||
local exists
|
||||
exists=$(curl -sf -o /dev/null -w '%{http_code}' \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/labels" 2>/dev/null || echo "000")
|
||||
|
||||
if [[ "$exists" == "200" ]]; then
|
||||
# Check if label already exists
|
||||
local found
|
||||
found=$(curl -sf \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/labels" 2>/dev/null \
|
||||
| grep -o "\"name\":\"${LABEL_NAME}\"" || true)
|
||||
|
||||
if [[ -z "$found" ]]; then
|
||||
curl -sf -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${API}/labels" \
|
||||
-d "{\"name\":\"${LABEL_NAME}\",\"color\":\"${LABEL_COLOR}\",\"description\":\"Auto-created by CI issue reporter\"}" \
|
||||
> /dev/null 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# ── Search for existing open issue ──────────────────────────────────────────
|
||||
find_existing_issue() {
|
||||
# URL-encode the gate name for the query
|
||||
local query
|
||||
query=$(printf '%s' "[CI] ${GATE}" | sed 's/ /%20/g; s/\[/%5B/g; s/\]/%5D/g')
|
||||
|
||||
local response
|
||||
response=$(curl -sf \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/issues?type=issues&state=open&labels=${LABEL_NAME}&q=${query}&limit=5" \
|
||||
2>/dev/null || echo "[]")
|
||||
|
||||
# Extract the first matching issue number
|
||||
echo "$response" \
|
||||
| grep -oP '"number":\s*\K[0-9]+' \
|
||||
| head -1
|
||||
}
|
||||
|
||||
# ── Build issue body ────────────────────────────────────────────────────────
|
||||
build_body() {
|
||||
local severity_badge
|
||||
if [[ "$SEVERITY" == "error" ]]; then
|
||||
severity_badge="**Severity:** Error"
|
||||
else
|
||||
severity_badge="**Severity:** Warning"
|
||||
fi
|
||||
|
||||
cat <<BODY
|
||||
## CI Gate Failure: ${GATE}
|
||||
|
||||
${severity_badge}
|
||||
**Workflow:** ${WORKFLOW:-unknown}
|
||||
**Branch:** ${GITHUB_REF_NAME:-unknown}
|
||||
**Commit:** \`${GITHUB_SHA:0:8}\`
|
||||
**Run:** [View CI run](${RUN_URL})
|
||||
|
||||
### Details
|
||||
|
||||
${DETAILS}
|
||||
|
||||
### Resolution
|
||||
|
||||
Fix the issue described above and push a new commit. This issue will be closed automatically when the gate passes, or can be closed manually.
|
||||
|
||||
---
|
||||
*Auto-created by [ci-issue-reporter](${GITEA_URL}/${REPO}/src/branch/main/automation/ci-issue-reporter.sh)*
|
||||
BODY
|
||||
}
|
||||
|
||||
# ── Build comment body (for existing issues) ────────────────────────────────
|
||||
build_comment() {
|
||||
cat <<COMMENT
|
||||
### CI failure recurrence
|
||||
|
||||
**Branch:** ${GITHUB_REF_NAME:-unknown}
|
||||
**Commit:** \`${GITHUB_SHA:0:8}\`
|
||||
**Run:** [View CI run](${RUN_URL})
|
||||
|
||||
${DETAILS}
|
||||
COMMENT
|
||||
}
|
||||
|
||||
# ── Main ────────────────────────────────────────────────────────────────────
|
||||
ensure_label
|
||||
|
||||
EXISTING=$(find_existing_issue)
|
||||
|
||||
if [[ -n "$EXISTING" ]]; then
|
||||
# Append comment to existing issue
|
||||
COMMENT_BODY=$(build_comment)
|
||||
COMMENT_JSON=$(printf '%s' "$COMMENT_BODY" | python3 -c "
|
||||
import sys, json
|
||||
print(json.dumps({'body': sys.stdin.read()}))" 2>/dev/null)
|
||||
|
||||
HTTP=$(curl -sf -o /dev/null -w '%{http_code}' -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${API}/issues/${EXISTING}/comments" \
|
||||
-d "${COMMENT_JSON}" 2>/dev/null || echo "000")
|
||||
|
||||
if [[ "$HTTP" == "201" ]]; then
|
||||
echo "Commented on existing issue #${EXISTING}"
|
||||
else
|
||||
echo "WARNING: Failed to comment on issue #${EXISTING} (HTTP ${HTTP})"
|
||||
fi
|
||||
else
|
||||
# Create new issue
|
||||
ISSUE_BODY=$(build_body)
|
||||
ISSUE_JSON=$(python3 -c "
|
||||
import sys, json
|
||||
body = sys.stdin.read()
|
||||
print(json.dumps({
|
||||
'title': sys.argv[1],
|
||||
'body': body,
|
||||
'labels': []
|
||||
}))" "$TITLE" <<< "$ISSUE_BODY" 2>/dev/null)
|
||||
|
||||
# Create the issue
|
||||
RESPONSE=$(curl -sf -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${API}/issues" \
|
||||
-d "${ISSUE_JSON}" 2>/dev/null || echo "{}")
|
||||
|
||||
ISSUE_NUM=$(echo "$RESPONSE" | grep -oP '"number":\s*\K[0-9]+' | head -1)
|
||||
|
||||
if [[ -n "$ISSUE_NUM" ]]; then
|
||||
# Apply label (separate call — more reliable across Gitea versions)
|
||||
LABEL_ID=$(curl -sf \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/labels" 2>/dev/null \
|
||||
| grep -oP "\"id\":\s*\K[0-9]+(?=[^}]*\"name\":\s*\"${LABEL_NAME}\")" \
|
||||
| head -1 || true)
|
||||
|
||||
if [[ -n "$LABEL_ID" ]]; then
|
||||
curl -sf -X POST \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${API}/issues/${ISSUE_NUM}/labels" \
|
||||
-d "{\"labels\":[${LABEL_ID}]}" \
|
||||
> /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
echo "Created issue #${ISSUE_NUM}: ${TITLE}"
|
||||
else
|
||||
echo "WARNING: Failed to create issue"
|
||||
echo "Response: ${RESPONSE}"
|
||||
fi
|
||||
fi
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "mokoconsulting/mokosuitecross",
|
||||
"name": "mokoconsulting/mokojoomcross",
|
||||
"description": "Cross-posting Joomla content to social media, email marketing, and chat platforms",
|
||||
"type": "joomla-package",
|
||||
"version": "01.00.00",
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
; MokoSuiteCross - Package System Language File
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
PKG_MOKOSUITECROSS="MokoSuiteCross"
|
||||
PKG_MOKOSUITECROSS_DESCRIPTION="Cross-posting Joomla content to social media, email marketing, and chat platforms. Automatically publish articles to Facebook, X/Twitter, LinkedIn, Mastodon, Bluesky, Mailchimp, Telegram, Discord, and Slack."
|
||||
PKG_MOKOSUITECROSS_PHP_VERSION_ERROR="MokoSuiteCross requires PHP %s or later."
|
||||
PKG_MOKOSUITECROSS_MIGRATION_DETECTED="Perfect Publisher Pro detected! Navigate to Components → MokoSuiteCross → Dashboard to migrate your settings."
|
||||
@@ -1,146 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<fieldset name="component" label="COM_MOKOSUITECROSS_CONFIG_COMPONENT">
|
||||
<field
|
||||
name="auto_post_on_publish"
|
||||
type="radio"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_AUTO_POST"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_AUTO_POST_DESC"
|
||||
default="1"
|
||||
class="btn-group">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="post_on_first_publish_only"
|
||||
type="radio"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_FIRST_PUBLISH_ONLY"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_FIRST_PUBLISH_ONLY_DESC"
|
||||
default="0"
|
||||
class="btn-group"
|
||||
showon="auto_post_on_publish:1">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="retry_max"
|
||||
type="number"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_RETRY_MAX"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_RETRY_MAX_DESC"
|
||||
default="3"
|
||||
min="0"
|
||||
max="10"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="retry_delay"
|
||||
type="number"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_RETRY_DELAY"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_RETRY_DELAY_DESC"
|
||||
default="300"
|
||||
min="60"
|
||||
max="3600"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="log_retention_days"
|
||||
type="number"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_LOG_RETENTION"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_LOG_RETENTION_DESC"
|
||||
default="90"
|
||||
min="7"
|
||||
max="365"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="default_template"
|
||||
type="textarea"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_DEFAULT_TEMPLATE"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_DEFAULT_TEMPLATE_DESC"
|
||||
default="{title}\n\n{introtext}\n\n{url}"
|
||||
rows="4"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="evergreen" label="COM_MOKOSUITECROSS_CONFIG_EVERGREEN">
|
||||
<field
|
||||
name="evergreen_enabled"
|
||||
type="radio"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_EVERGREEN_ENABLED"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_EVERGREEN_ENABLED_DESC"
|
||||
default="1"
|
||||
class="btn-group">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="evergreen_default_interval"
|
||||
type="number"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL_DESC"
|
||||
default="30"
|
||||
min="1"
|
||||
max="365"
|
||||
showon="evergreen_enabled:1"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="evergreen_max_per_run"
|
||||
type="number"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_EVERGREEN_MAX_PER_RUN"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_EVERGREEN_MAX_PER_RUN_DESC"
|
||||
default="3"
|
||||
min="1"
|
||||
max="20"
|
||||
showon="evergreen_enabled:1"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="queue" label="COM_MOKOSUITECROSS_CONFIG_QUEUE">
|
||||
<field
|
||||
name="queue_processing"
|
||||
type="list"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_QUEUE_PROCESSING"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_QUEUE_PROCESSING_DESC"
|
||||
default="scheduler">
|
||||
<option value="scheduler">COM_MOKOSUITECROSS_CONFIG_QUEUE_SCHEDULER</option>
|
||||
<option value="pageload">COM_MOKOSUITECROSS_CONFIG_QUEUE_PAGELOAD</option>
|
||||
<option value="both">COM_MOKOSUITECROSS_CONFIG_QUEUE_BOTH</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="pageload_client"
|
||||
type="list"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_PAGELOAD_CLIENT"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_PAGELOAD_CLIENT_DESC"
|
||||
default="both"
|
||||
showon="queue_processing:pageload,both">
|
||||
<option value="both">COM_MOKOSUITECROSS_CONFIG_PAGELOAD_BOTH</option>
|
||||
<option value="admin">COM_MOKOSUITECROSS_CONFIG_PAGELOAD_ADMIN</option>
|
||||
<option value="site">COM_MOKOSUITECROSS_CONFIG_PAGELOAD_SITE</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="pageload_interval"
|
||||
type="number"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_PAGELOAD_INTERVAL"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_PAGELOAD_INTERVAL_DESC"
|
||||
default="300"
|
||||
min="60"
|
||||
max="3600"
|
||||
showon="queue_processing:pageload,both"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset name="category_rules" label="COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES">
|
||||
<field
|
||||
name="category_rules_note"
|
||||
type="note"
|
||||
label="COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES_NOTE"
|
||||
description="COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES_NOTE_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
</config>
|
||||
@@ -1,513 +0,0 @@
|
||||
; MokoSuiteCross — Admin Backend Language File
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
COM_MOKOSUITECROSS="MokoSuiteCross"
|
||||
COM_MOKOSUITECROSS_DESCRIPTION="Cross-posting Joomla content to social media, email marketing, and chat platforms"
|
||||
|
||||
; Submenu
|
||||
COM_MOKOSUITECROSS_SUBMENU_DASHBOARD="Dashboard"
|
||||
COM_MOKOSUITECROSS_SUBMENU_POSTS="Post Queue"
|
||||
COM_MOKOSUITECROSS_SUBMENU_SERVICES="Services"
|
||||
COM_MOKOSUITECROSS_SUBMENU_LOGS="Activity Logs"
|
||||
|
||||
; Dashboard
|
||||
COM_MOKOSUITECROSS_DASHBOARD_ACTIVE_SERVICES="Active Services"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_QUEUED="Queued"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_POSTED="Posted"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_FAILED="Failed"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_QUICK_LINKS="Quick Links"
|
||||
|
||||
; Migration
|
||||
COM_MOKOSUITECROSS_MIGRATION_TITLE="Migrate from Perfect Publisher Pro"
|
||||
COM_MOKOSUITECROSS_MIGRATION_DESCRIPTION="We detected Perfect Publisher Pro settings. Import your service configurations to MokoSuiteCross."
|
||||
COM_MOKOSUITECROSS_MIGRATION_BUTTON="Start Migration"
|
||||
COM_MOKOSUITECROSS_MIGRATION_SUCCESS="Migration complete: %d service(s) imported, %d skipped."
|
||||
COM_MOKOSUITECROSS_MIGRATION_ERROR="Migration encountered errors: %s"
|
||||
|
||||
; Services
|
||||
COM_MOKOSUITECROSS_FIELD_SERVICE_TYPE="Service Type"
|
||||
COM_MOKOSUITECROSS_SELECT_SERVICE_TYPE="- Select Service Type -"
|
||||
COM_MOKOSUITECROSS_FIELDSET_CREDENTIALS="API Credentials"
|
||||
COM_MOKOSUITECROSS_FIELD_CREDENTIALS="Credentials (JSON)"
|
||||
COM_MOKOSUITECROSS_FIELD_CREDENTIALS_DESC="JSON object with API keys and tokens for this service. Keys vary by platform."
|
||||
|
||||
; Posts
|
||||
COM_MOKOSUITECROSS_FILTER_SEARCH="Search"
|
||||
COM_MOKOSUITECROSS_FILTER_STATUS="Status"
|
||||
COM_MOKOSUITECROSS_SELECT_STATUS="- Select Status -"
|
||||
COM_MOKOSUITECROSS_FILTER_SERVICE_TYPE="Service Type"
|
||||
COM_MOKOSUITECROSS_CREATED_ASC="Created ascending"
|
||||
COM_MOKOSUITECROSS_CREATED_DESC="Created descending"
|
||||
COM_MOKOSUITECROSS_STATUS_ASC="Status ascending"
|
||||
COM_MOKOSUITECROSS_STATUS_DESC="Status descending"
|
||||
|
||||
; Actions
|
||||
COM_MOKOSUITECROSS_ACTION_CROSSPOST="Cross-post"
|
||||
COM_MOKOSUITECROSS_ACTION_MIGRATE="Migrate"
|
||||
|
||||
; Configuration
|
||||
COM_MOKOSUITECROSS_CONFIG_COMPONENT="MokoSuiteCross Settings"
|
||||
COM_MOKOSUITECROSS_CONFIG_AUTO_POST="Auto-post on Publish"
|
||||
COM_MOKOSUITECROSS_CONFIG_AUTO_POST_DESC="Automatically cross-post articles when they are published"
|
||||
COM_MOKOSUITECROSS_CONFIG_RETRY_MAX="Max Retries"
|
||||
COM_MOKOSUITECROSS_CONFIG_RETRY_MAX_DESC="Maximum number of retry attempts for failed posts"
|
||||
COM_MOKOSUITECROSS_CONFIG_RETRY_DELAY="Retry Delay (seconds)"
|
||||
COM_MOKOSUITECROSS_CONFIG_RETRY_DELAY_DESC="Seconds to wait before retrying a failed post"
|
||||
COM_MOKOSUITECROSS_CONFIG_LOG_RETENTION="Log Retention (days)"
|
||||
COM_MOKOSUITECROSS_CONFIG_LOG_RETENTION_DESC="Number of days to keep activity logs"
|
||||
COM_MOKOSUITECROSS_CONFIG_DEFAULT_TEMPLATE="Default Message Template"
|
||||
COM_MOKOSUITECROSS_CONFIG_DEFAULT_TEMPLATE_DESC="Default template for cross-posts. Placeholders: {title}, {url}, {introtext}, {image}, {category}, {author}"
|
||||
|
||||
; Table headings
|
||||
COM_MOKOSUITECROSS_HEADING_STATUS="Status"
|
||||
COM_MOKOSUITECROSS_HEADING_ARTICLE="Article"
|
||||
COM_MOKOSUITECROSS_HEADING_SERVICE="Service"
|
||||
COM_MOKOSUITECROSS_HEADING_MESSAGE="Message"
|
||||
COM_MOKOSUITECROSS_HEADING_POSTED_AT="Posted"
|
||||
COM_MOKOSUITECROSS_HEADING_CREATED="Created"
|
||||
COM_MOKOSUITECROSS_HEADING_LEVEL="Level"
|
||||
COM_MOKOSUITECROSS_HEADING_MODE="Mode"
|
||||
|
||||
; Dashboard
|
||||
COM_MOKOSUITECROSS_DASHBOARD_RECENT_ACTIVITY="Recent Activity"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_NO_RECENT="No recent activity."
|
||||
COM_MOKOSUITECROSS_DASHBOARD_TOTAL_POSTS="Total Posts"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_PAGELOAD_WARNING_TITLE="Page-load queue processing is active"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_PAGELOAD_WARNING="You are using page-load processing for the cross-post queue. This is a fallback method and may be unreliable on low-traffic sites. For production use, switch to Joomla Scheduled Tasks: create a task of type <strong>MokoSuiteCross - Process Queue</strong> in System → Scheduled Tasks, then set queue processing to <strong>Scheduler only</strong> in component options."
|
||||
|
||||
; Evergreen Configuration
|
||||
COM_MOKOSUITECROSS_CONFIG_EVERGREEN="Evergreen Re-sharing"
|
||||
COM_MOKOSUITECROSS_CONFIG_EVERGREEN_ENABLED="Enable Evergreen"
|
||||
COM_MOKOSUITECROSS_CONFIG_EVERGREEN_ENABLED_DESC="Allow articles marked as evergreen to be automatically re-shared on a recurring schedule."
|
||||
COM_MOKOSUITECROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL="Default Interval (days)"
|
||||
COM_MOKOSUITECROSS_CONFIG_EVERGREEN_DEFAULT_INTERVAL_DESC="Default number of days between re-shares when no per-article interval is set."
|
||||
COM_MOKOSUITECROSS_CONFIG_EVERGREEN_MAX_PER_RUN="Max Re-shares Per Run"
|
||||
COM_MOKOSUITECROSS_CONFIG_EVERGREEN_MAX_PER_RUN_DESC="Maximum number of evergreen articles to re-share in a single queue processing run. Prevents flooding platforms."
|
||||
|
||||
; Queue Processing Configuration
|
||||
COM_MOKOSUITECROSS_CONFIG_QUEUE="Queue Processing"
|
||||
COM_MOKOSUITECROSS_CONFIG_QUEUE_PROCESSING="Processing Method"
|
||||
COM_MOKOSUITECROSS_CONFIG_QUEUE_PROCESSING_DESC="How queued posts, retries, and scheduled posts are processed. Scheduler (recommended) uses Joomla's built-in Task Scheduler. Page-load piggybacks on page requests."
|
||||
COM_MOKOSUITECROSS_CONFIG_QUEUE_SCHEDULER="Scheduler only (recommended)"
|
||||
COM_MOKOSUITECROSS_CONFIG_QUEUE_PAGELOAD="Page-load only (fallback)"
|
||||
COM_MOKOSUITECROSS_CONFIG_QUEUE_BOTH="Both (scheduler + page-load)"
|
||||
COM_MOKOSUITECROSS_CONFIG_PAGELOAD_CLIENT="Page-load Client"
|
||||
COM_MOKOSUITECROSS_CONFIG_PAGELOAD_CLIENT_DESC="Which Joomla application triggers page-load processing."
|
||||
COM_MOKOSUITECROSS_CONFIG_PAGELOAD_BOTH="Backend and Frontend"
|
||||
COM_MOKOSUITECROSS_CONFIG_PAGELOAD_ADMIN="Backend only"
|
||||
COM_MOKOSUITECROSS_CONFIG_PAGELOAD_SITE="Frontend only"
|
||||
COM_MOKOSUITECROSS_CONFIG_PAGELOAD_INTERVAL="Page-load Interval (seconds)"
|
||||
COM_MOKOSUITECROSS_CONFIG_PAGELOAD_INTERVAL_DESC="Minimum seconds between page-load queue runs. Lower = more responsive but more DB queries per page load."
|
||||
|
||||
; Submenu (extended)
|
||||
COM_MOKOSUITECROSS_SUBMENU_TEMPLATES="Templates"
|
||||
|
||||
; Template Management
|
||||
COM_MOKOSUITECROSS_TEMPLATE_BODY="Template Body"
|
||||
COM_MOKOSUITECROSS_TEMPLATE_BODY_DESC="Message template with placeholders. Use the reference panel on the right for available placeholders."
|
||||
COM_MOKOSUITECROSS_TEMPLATE_SERVICE_TYPE_DESC="Which platform this template is for. 'Default' is the fallback when no platform-specific template exists."
|
||||
COM_MOKOSUITECROSS_TEMPLATE_TYPE_DEFAULT="Default (fallback)"
|
||||
COM_MOKOSUITECROSS_TEMPLATE_PREVIEW="Preview"
|
||||
COM_MOKOSUITECROSS_TEMPLATE_PLACEHOLDERS="Available Placeholders"
|
||||
|
||||
; Placeholders
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_TITLE="Article title"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_URL="Article URL"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_INTROTEXT="Intro text (280 chars, no HTML)"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_FULLTEXT="Full text (500 chars, no HTML)"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_IMAGE="Intro image URL"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_CATEGORY="Category name"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_AUTHOR="Author name"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_DATE="Publish date (YYYY-MM-DD)"
|
||||
|
||||
; Logs
|
||||
COM_MOKOSUITECROSS_FILTER_LEVEL="Level"
|
||||
COM_MOKOSUITECROSS_SELECT_LEVEL="- Select Level -"
|
||||
COM_MOKOSUITECROSS_LEVEL_ASC="Level ascending"
|
||||
COM_MOKOSUITECROSS_LEVEL_DESC="Level descending"
|
||||
|
||||
; Analytics Dashboard
|
||||
COM_MOKOSUITECROSS_DASHBOARD_SERVICE_BREAKDOWN="Posts by Service"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_TOP_ARTICLES="Most Cross-Posted Articles"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_SUCCESS_RATE="Success Rate"
|
||||
|
||||
; OAuth
|
||||
COM_MOKOSUITECROSS_OAUTH_NO_SERVICE="No service specified for OAuth authorization."
|
||||
COM_MOKOSUITECROSS_OAUTH_SERVICE_NOT_FOUND="Service not found."
|
||||
COM_MOKOSUITECROSS_OAUTH_NO_CLIENT_ID="No OAuth Client ID configured for %s. Set it in Extensions → Plugins → MokoSuiteCross - %s."
|
||||
COM_MOKOSUITECROSS_OAUTH_NOT_SUPPORTED="OAuth is not supported for %s."
|
||||
COM_MOKOSUITECROSS_OAUTH_PLATFORM_ERROR="Platform returned error: %s"
|
||||
COM_MOKOSUITECROSS_OAUTH_INVALID_CALLBACK="Invalid OAuth callback — missing code or state."
|
||||
COM_MOKOSUITECROSS_OAUTH_INVALID_STATE="Invalid OAuth state parameter."
|
||||
COM_MOKOSUITECROSS_OAUTH_TOKEN_ERROR="Token exchange failed: %s"
|
||||
COM_MOKOSUITECROSS_OAUTH_SUCCESS="%s connected successfully! Access token stored."
|
||||
|
||||
; Post edit
|
||||
COM_MOKOSUITECROSS_NEW_POST="New Post"
|
||||
COM_MOKOSUITECROSS_EDIT_POST="Edit Post"
|
||||
COM_MOKOSUITECROSS_POST_ARTICLE="Article"
|
||||
COM_MOKOSUITECROSS_POST_ARTICLE_DESC="The Joomla article to cross-post."
|
||||
COM_MOKOSUITECROSS_SELECT_ARTICLE="- Select Article -"
|
||||
COM_MOKOSUITECROSS_POST_SERVICE="Service"
|
||||
COM_MOKOSUITECROSS_POST_SERVICE_DESC="The service to post to."
|
||||
COM_MOKOSUITECROSS_SELECT_SERVICE="- Select Service -"
|
||||
COM_MOKOSUITECROSS_POST_MESSAGE="Message"
|
||||
COM_MOKOSUITECROSS_POST_MESSAGE_DESC="The message to send to the platform. Use template placeholders or write a custom message."
|
||||
COM_MOKOSUITECROSS_POST_STATUS="Status"
|
||||
COM_MOKOSUITECROSS_STATUS_QUEUED="Queued"
|
||||
COM_MOKOSUITECROSS_STATUS_SCHEDULED="Scheduled"
|
||||
COM_MOKOSUITECROSS_STATUS_POSTED="Posted"
|
||||
COM_MOKOSUITECROSS_STATUS_FAILED="Failed"
|
||||
COM_MOKOSUITECROSS_POST_SCHEDULED_AT="Scheduled Date/Time"
|
||||
COM_MOKOSUITECROSS_POST_SCHEDULED_AT_DESC="When to send this post. Leave empty to process immediately. Set a future date to schedule."
|
||||
COM_MOKOSUITECROSS_POST_RESULTS="Post Results"
|
||||
COM_MOKOSUITECROSS_POST_PLATFORM_ID="Platform Post ID"
|
||||
COM_MOKOSUITECROSS_POST_ERROR="Error Message"
|
||||
COM_MOKOSUITECROSS_POST_RETRY_COUNT="Retry Count"
|
||||
COM_MOKOSUITECROSS_POST_POSTED_AT="Posted At"
|
||||
COM_MOKOSUITECROSS_POST_CREATE_HELP="Create a manual cross-post. Select an article and service, write your message, and optionally set a scheduled date. Leave the schedule empty to queue for immediate processing."
|
||||
COM_MOKOSUITECROSS_POST_REQUEUE="Re-queue for Posting"
|
||||
COM_MOKOSUITECROSS_POST_REQUEUE_HELP="Reset this post to queued status so it will be processed again on the next queue run."
|
||||
|
||||
; Service edit
|
||||
COM_MOKOSUITECROSS_NEW_SERVICE="New Service"
|
||||
COM_MOKOSUITECROSS_EDIT_SERVICE="Edit Service"
|
||||
COM_MOKOSUITECROSS_SERVICE_DETAILS="Service Details"
|
||||
COM_MOKOSUITECROSS_CREDENTIALS_HELP="Fill in the connection details for the selected platform. Fields change based on the service type you choose above."
|
||||
|
||||
; Credential mode
|
||||
COM_MOKOSUITECROSS_FIELD_CRED_MODE="Connection Mode"
|
||||
COM_MOKOSUITECROSS_FIELD_CRED_MODE_DESC="Default uses the pre-configured MokoWaaS account. Custom lets you use your own API credentials."
|
||||
COM_MOKOSUITECROSS_CRED_MODE_DEFAULT="Default (MokoWaaS)"
|
||||
COM_MOKOSUITECROSS_CRED_MODE_CUSTOM="Custom (your own credentials)"
|
||||
|
||||
; Telegram
|
||||
COM_MOKOSUITECROSS_CRED_TELEGRAM_CHAT_ID="Chat ID"
|
||||
COM_MOKOSUITECROSS_CRED_TELEGRAM_CHAT_ID_DESC="Telegram channel, group, or user chat ID. Channel IDs start with -100. Get yours from @userinfobot."
|
||||
COM_MOKOSUITECROSS_CRED_TELEGRAM_BOT_TOKEN="Bot Token"
|
||||
COM_MOKOSUITECROSS_CRED_TELEGRAM_BOT_TOKEN_DESC="Your custom Telegram bot token from @BotFather. Only needed in Custom mode."
|
||||
|
||||
; Discord
|
||||
COM_MOKOSUITECROSS_CRED_DISCORD_WEBHOOK="Webhook URL"
|
||||
COM_MOKOSUITECROSS_CRED_DISCORD_WEBHOOK_DESC="Discord channel webhook URL. Create one in Channel Settings → Integrations → Webhooks."
|
||||
|
||||
; Slack
|
||||
COM_MOKOSUITECROSS_CRED_SLACK_WEBHOOK="Webhook URL"
|
||||
COM_MOKOSUITECROSS_CRED_SLACK_WEBHOOK_DESC="Slack Incoming Webhook URL. Create one at api.slack.com/apps."
|
||||
|
||||
; Teams
|
||||
COM_MOKOSUITECROSS_CRED_TEAMS_WEBHOOK="Webhook URL"
|
||||
COM_MOKOSUITECROSS_CRED_TEAMS_WEBHOOK_DESC="Microsoft Teams Incoming Webhook URL. Create in channel Connectors."
|
||||
|
||||
; Google Chat
|
||||
COM_MOKOSUITECROSS_CRED_GOOGLECHAT_WEBHOOK="Webhook URL"
|
||||
COM_MOKOSUITECROSS_CRED_GOOGLECHAT_WEBHOOK_DESC="Google Chat space webhook URL."
|
||||
|
||||
; Facebook
|
||||
COM_MOKOSUITECROSS_CRED_FACEBOOK_PAGE_ID="Facebook Page ID"
|
||||
COM_MOKOSUITECROSS_CRED_FACEBOOK_PAGE_ID_DESC="Your Facebook Page numeric ID. Find it in Page Settings → About."
|
||||
COM_MOKOSUITECROSS_CRED_FACEBOOK_TOKEN="Page Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_FACEBOOK_TOKEN_DESC="Long-lived Page Access Token. Use the Authorize button below or generate via Meta Business Suite."
|
||||
|
||||
; Threads
|
||||
COM_MOKOSUITECROSS_CRED_THREADS_USER_ID="Threads User ID"
|
||||
COM_MOKOSUITECROSS_CRED_THREADS_TOKEN="Access Token"
|
||||
|
||||
; Twitter (OAuth 1.0a)
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_API_KEY="API Key (Consumer Key)"
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_API_KEY_DESC="Consumer Key from the Twitter Developer Portal → Keys and Tokens."
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_API_SECRET="API Secret (Consumer Secret)"
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_API_SECRET_DESC="Consumer Secret from the Twitter Developer Portal → Keys and Tokens."
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_ACCESS_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_ACCESS_TOKEN_DESC="User access token from the Developer Portal → Keys and Tokens → Authentication Tokens."
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_ACCESS_TOKEN_SECRET="Access Token Secret"
|
||||
COM_MOKOSUITECROSS_CRED_TWITTER_ACCESS_TOKEN_SECRET_DESC="User access token secret from the Developer Portal → Keys and Tokens → Authentication Tokens."
|
||||
|
||||
; LinkedIn
|
||||
COM_MOKOSUITECROSS_CRED_LINKEDIN_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_LINKEDIN_ORG_ID="Organization ID"
|
||||
COM_MOKOSUITECROSS_CRED_LINKEDIN_ORG_ID_DESC="LinkedIn Company Page ID. Leave empty to post as yourself."
|
||||
|
||||
; Mastodon
|
||||
COM_MOKOSUITECROSS_CRED_MASTODON_INSTANCE="Instance URL"
|
||||
COM_MOKOSUITECROSS_CRED_MASTODON_INSTANCE_DESC="Your Mastodon server (e.g. https://mastodon.social)"
|
||||
COM_MOKOSUITECROSS_CRED_MASTODON_TOKEN="Access Token"
|
||||
|
||||
; Bluesky
|
||||
COM_MOKOSUITECROSS_CRED_BLUESKY_HANDLE="Handle"
|
||||
COM_MOKOSUITECROSS_CRED_BLUESKY_HANDLE_DESC="Your Bluesky handle (e.g. user.bsky.social)"
|
||||
COM_MOKOSUITECROSS_CRED_BLUESKY_APP_PWD="App Password"
|
||||
COM_MOKOSUITECROSS_CRED_BLUESKY_APP_PWD_DESC="Generate in Bluesky Settings → Advanced → App Passwords."
|
||||
|
||||
; WhatsApp
|
||||
COM_MOKOSUITECROSS_CRED_WHATSAPP_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_WHATSAPP_PHONE_ID="Phone Number ID"
|
||||
COM_MOKOSUITECROSS_CRED_WHATSAPP_RECIPIENT="Recipient Number"
|
||||
COM_MOKOSUITECROSS_CRED_WHATSAPP_RECIPIENT_DESC="Phone number to send to, with country code (e.g. +1234567890)"
|
||||
|
||||
; Mailchimp
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_KEY="API Key"
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_KEY_DESC="Mailchimp API key (ends with -us1, -us2, etc.)"
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_LIST="Audience/List ID"
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_LIST_DESC="The audience to send campaigns to. Find in Audience → Settings → Audience ID."
|
||||
|
||||
; SendGrid
|
||||
COM_MOKOSUITECROSS_CRED_SENDGRID_KEY="API Key"
|
||||
COM_MOKOSUITECROSS_CRED_SENDGRID_LIST="Contact List ID"
|
||||
|
||||
; Webhook
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_URL="Webhook URL"
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_URL_DESC="The URL to send article data to. Works with Zapier, IFTTT, n8n, Make, or any custom endpoint."
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_METHOD="HTTP Method"
|
||||
|
||||
; Matrix
|
||||
COM_MOKOSUITECROSS_CRED_MATRIX_HOMESERVER="Homeserver URL"
|
||||
COM_MOKOSUITECROSS_CRED_MATRIX_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_MATRIX_ROOM="Room ID"
|
||||
COM_MOKOSUITECROSS_CRED_MATRIX_ROOM_DESC="Matrix room ID (e.g. !abc123:matrix.org)"
|
||||
|
||||
; Ntfy
|
||||
COM_MOKOSUITECROSS_CRED_NTFY_SERVER="Server URL"
|
||||
COM_MOKOSUITECROSS_CRED_NTFY_TOPIC="Topic Name"
|
||||
COM_MOKOSUITECROSS_CRED_NTFY_TOPIC_DESC="The notification topic (e.g. my-site-updates). Subscribers use this to receive push notifications."
|
||||
COM_MOKOSUITECROSS_CRED_NTFY_TOKEN="Auth Token"
|
||||
COM_MOKOSUITECROSS_CRED_NTFY_TOKEN_DESC="Optional authentication token if your ntfy server requires it."
|
||||
|
||||
; WordPress
|
||||
COM_MOKOSUITECROSS_CRED_WP_SITE="WordPress Site URL"
|
||||
COM_MOKOSUITECROSS_CRED_WP_USER="Username"
|
||||
COM_MOKOSUITECROSS_CRED_WP_APP_PWD="Application Password"
|
||||
COM_MOKOSUITECROSS_CRED_WP_APP_PWD_DESC="Generate in WordPress → Users → Profile → Application Passwords."
|
||||
|
||||
; Medium
|
||||
COM_MOKOSUITECROSS_CRED_MEDIUM_TOKEN="Integration Token"
|
||||
|
||||
; Dev.to
|
||||
COM_MOKOSUITECROSS_CRED_DEVTO_KEY="API Key"
|
||||
|
||||
; Ghost
|
||||
COM_MOKOSUITECROSS_CRED_GHOST_SITE="Ghost Site URL"
|
||||
COM_MOKOSUITECROSS_CRED_GHOST_KEY="Admin API Key"
|
||||
|
||||
; Reddit
|
||||
COM_MOKOSUITECROSS_CRED_REDDIT_CLIENT_ID="App Client ID"
|
||||
COM_MOKOSUITECROSS_CRED_REDDIT_SECRET="App Secret"
|
||||
COM_MOKOSUITECROSS_CRED_REDDIT_USER="Reddit Username"
|
||||
COM_MOKOSUITECROSS_CRED_REDDIT_SUBREDDIT="Subreddit"
|
||||
COM_MOKOSUITECROSS_CRED_REDDIT_SUBREDDIT_DESC="Subreddit to post to (without r/ prefix)"
|
||||
|
||||
; Authorize / OAuth
|
||||
COM_MOKOSUITECROSS_AUTHORIZE_BUTTON="Connect to %s"
|
||||
COM_MOKOSUITECROSS_AUTHORIZE_HELP="Click to open the authorization page. You'll be redirected back after granting access. Your token will be saved automatically."
|
||||
COM_MOKOSUITECROSS_OAUTH_HELP_TITLE="Authorization Required"
|
||||
COM_MOKOSUITECROSS_OAUTH_HELP_BODY="This service requires OAuth authorization. Save the service first, then click the Connect button below to authorize access."
|
||||
|
||||
; LinkedIn (additional)
|
||||
COM_MOKOSUITECROSS_CRED_LINKEDIN_REFRESH_TOKEN="Refresh Token"
|
||||
COM_MOKOSUITECROSS_CRED_LINKEDIN_REFRESH_TOKEN_DESC="OAuth refresh token for automatic access token renewal."
|
||||
|
||||
; Bluesky (additional)
|
||||
COM_MOKOSUITECROSS_CRED_BLUESKY_PDS_URL="PDS URL"
|
||||
COM_MOKOSUITECROSS_CRED_BLUESKY_PDS_URL_DESC="Personal Data Server URL. Default is https://bsky.social. Only change for self-hosted PDS."
|
||||
|
||||
; Discord (additional)
|
||||
COM_MOKOSUITECROSS_CRED_DISCORD_USERNAME="Display Name Override"
|
||||
COM_MOKOSUITECROSS_CRED_DISCORD_USERNAME_DESC="Override the webhook's default display name. Leave empty to use the webhook name."
|
||||
COM_MOKOSUITECROSS_CRED_DISCORD_AVATAR="Avatar URL Override"
|
||||
COM_MOKOSUITECROSS_CRED_DISCORD_AVATAR_DESC="Override the webhook's default avatar with a custom image URL."
|
||||
|
||||
; Mailchimp (additional)
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_FROM_NAME="From Name"
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_FROM_NAME_DESC="Sender name for campaigns. Leave empty to use the audience default."
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_FROM_EMAIL="From Email"
|
||||
COM_MOKOSUITECROSS_CRED_MAILCHIMP_FROM_EMAIL_DESC="Sender email for campaigns. Must be a verified sending domain."
|
||||
|
||||
; SendGrid (additional)
|
||||
COM_MOKOSUITECROSS_CRED_SENDGRID_FROM_EMAIL="From Email"
|
||||
COM_MOKOSUITECROSS_CRED_SENDGRID_FROM_EMAIL_DESC="Verified sender email address for Single Sends."
|
||||
COM_MOKOSUITECROSS_CRED_SENDGRID_FROM_NAME="From Name"
|
||||
COM_MOKOSUITECROSS_CRED_SENDGRID_FROM_NAME_DESC="Display name for the sender."
|
||||
|
||||
; Reddit (additional)
|
||||
COM_MOKOSUITECROSS_CRED_REDDIT_PASSWORD="Account Password"
|
||||
COM_MOKOSUITECROSS_CRED_REDDIT_PASSWORD_DESC="Required for Reddit script-type OAuth. The password for the Reddit account."
|
||||
|
||||
; WordPress (additional)
|
||||
COM_MOKOSUITECROSS_CRED_WP_DEFAULT_STATUS="Default Post Status"
|
||||
COM_MOKOSUITECROSS_CRED_WP_DEFAULT_STATUS_DESC="Whether cross-posted articles appear as drafts or are published immediately."
|
||||
|
||||
; Dev.to (additional)
|
||||
COM_MOKOSUITECROSS_CRED_DEVTO_ORG_ID="Organization ID"
|
||||
COM_MOKOSUITECROSS_CRED_DEVTO_ORG_ID_DESC="Optional. Publish under a Dev.to organization instead of your personal account."
|
||||
|
||||
; Ghost (additional)
|
||||
COM_MOKOSUITECROSS_CRED_GHOST_DEFAULT_STATUS="Default Post Status"
|
||||
COM_MOKOSUITECROSS_CRED_GHOST_DEFAULT_STATUS_DESC="Whether cross-posted articles are saved as drafts or published immediately."
|
||||
|
||||
; Status options (shared)
|
||||
COM_MOKOSUITECROSS_STATUS_DRAFT="Draft"
|
||||
COM_MOKOSUITECROSS_STATUS_PUBLISH="Publish"
|
||||
COM_MOKOSUITECROSS_STATUS_PUBLISHED="Published"
|
||||
|
||||
; Pinterest
|
||||
COM_MOKOSUITECROSS_CRED_PINTEREST_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_PINTEREST_TOKEN_DESC="Pinterest API v5 access token from the Developer Portal."
|
||||
COM_MOKOSUITECROSS_CRED_PINTEREST_BOARD="Board ID"
|
||||
COM_MOKOSUITECROSS_CRED_PINTEREST_BOARD_DESC="The board to pin to. Find the ID in the board URL or via the API."
|
||||
|
||||
; Tumblr
|
||||
COM_MOKOSUITECROSS_CRED_TUMBLR_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_TUMBLR_TOKEN_DESC="Tumblr OAuth access token."
|
||||
COM_MOKOSUITECROSS_CRED_TUMBLR_BLOG="Blog Name"
|
||||
COM_MOKOSUITECROSS_CRED_TUMBLR_BLOG_DESC="Your Tumblr blog name (e.g. myblog — without .tumblr.com)."
|
||||
|
||||
; TikTok
|
||||
COM_MOKOSUITECROSS_CRED_TIKTOK_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_TIKTOK_REFRESH_TOKEN="Refresh Token"
|
||||
COM_MOKOSUITECROSS_CRED_TIKTOK_OPEN_ID="Open ID"
|
||||
COM_MOKOSUITECROSS_CRED_TIKTOK_OPEN_ID_DESC="Your TikTok Open ID from the developer app authorization."
|
||||
|
||||
; Nostr
|
||||
COM_MOKOSUITECROSS_CRED_NOSTR_PRIVKEY="Private Key"
|
||||
COM_MOKOSUITECROSS_CRED_NOSTR_PRIVKEY_DESC="Nostr private key in hex or nsec format. Used to sign events."
|
||||
COM_MOKOSUITECROSS_CRED_NOSTR_RELAYS="Relay URLs"
|
||||
COM_MOKOSUITECROSS_CRED_NOSTR_RELAYS_DESC="Comma-separated list of relay WebSocket URLs (e.g. wss://relay.damus.io, wss://nos.lol)."
|
||||
|
||||
; ActivityPub
|
||||
COM_MOKOSUITECROSS_CRED_ACTIVITYPUB_INSTANCE="Instance URL"
|
||||
COM_MOKOSUITECROSS_CRED_ACTIVITYPUB_INSTANCE_DESC="Fediverse instance URL (Pleroma, Akkoma, Misskey, Pixelfed, etc.)."
|
||||
COM_MOKOSUITECROSS_CRED_ACTIVITYPUB_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_ACTIVITYPUB_TOKEN_DESC="API access token from the instance's developer settings."
|
||||
|
||||
; Brevo (Sendinblue)
|
||||
COM_MOKOSUITECROSS_CRED_BREVO_KEY="API Key"
|
||||
COM_MOKOSUITECROSS_CRED_BREVO_LIST="Contact List ID"
|
||||
COM_MOKOSUITECROSS_CRED_BREVO_LIST_DESC="Brevo contact list ID to send campaigns to."
|
||||
COM_MOKOSUITECROSS_CRED_BREVO_SENDER_EMAIL="Sender Email"
|
||||
COM_MOKOSUITECROSS_CRED_BREVO_SENDER_EMAIL_DESC="Must be a verified sender in your Brevo account."
|
||||
COM_MOKOSUITECROSS_CRED_BREVO_SENDER_NAME="Sender Name"
|
||||
|
||||
; ConvertKit
|
||||
COM_MOKOSUITECROSS_CRED_CONVERTKIT_KEY="API Key"
|
||||
COM_MOKOSUITECROSS_CRED_CONVERTKIT_SECRET="API Secret"
|
||||
|
||||
; Constant Contact
|
||||
COM_MOKOSUITECROSS_CRED_CONSTANTCONTACT_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_CONSTANTCONTACT_REFRESH_TOKEN="Refresh Token"
|
||||
COM_MOKOSUITECROSS_CRED_CONSTANTCONTACT_LISTS="Contact List IDs"
|
||||
COM_MOKOSUITECROSS_CRED_CONSTANTCONTACT_LISTS_DESC="Comma-separated list IDs to include in the campaign."
|
||||
|
||||
; Hashnode
|
||||
COM_MOKOSUITECROSS_CRED_HASHNODE_TOKEN="Personal Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_HASHNODE_PUB_ID="Publication ID"
|
||||
COM_MOKOSUITECROSS_CRED_HASHNODE_PUB_ID_DESC="Your Hashnode publication ID. Find in Dashboard → General settings."
|
||||
|
||||
; Google Blogger
|
||||
COM_MOKOSUITECROSS_CRED_BLOGGER_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_BLOGGER_REFRESH_TOKEN="Refresh Token"
|
||||
COM_MOKOSUITECROSS_CRED_BLOGGER_BLOG_ID="Blog ID"
|
||||
COM_MOKOSUITECROSS_CRED_BLOGGER_BLOG_ID_DESC="Numeric Blog ID from Blogger settings or the Blogger API."
|
||||
|
||||
; Google Business Profile
|
||||
COM_MOKOSUITECROSS_CRED_GBUSINESS_TOKEN="Access Token"
|
||||
COM_MOKOSUITECROSS_CRED_GBUSINESS_REFRESH_TOKEN="Refresh Token"
|
||||
COM_MOKOSUITECROSS_CRED_GBUSINESS_LOCATION="Location ID"
|
||||
COM_MOKOSUITECROSS_CRED_GBUSINESS_LOCATION_DESC="Google Business location ID (e.g. locations/1234567890)."
|
||||
COM_MOKOSUITECROSS_CRED_GBUSINESS_ACCOUNT="Account ID"
|
||||
COM_MOKOSUITECROSS_CRED_GBUSINESS_ACCOUNT_DESC="Google Business account ID (e.g. accounts/1234567890)."
|
||||
|
||||
; RSS Feed
|
||||
COM_MOKOSUITECROSS_CRED_RSSFEED_TITLE="Feed Title"
|
||||
COM_MOKOSUITECROSS_CRED_RSSFEED_TITLE_DESC="Title for the generated RSS feed. Defaults to the site name."
|
||||
COM_MOKOSUITECROSS_CRED_RSSFEED_MAX_ITEMS="Max Feed Items"
|
||||
COM_MOKOSUITECROSS_CRED_RSSFEED_MAX_ITEMS_DESC="Maximum number of items to include in the feed."
|
||||
|
||||
; Webhook (additional)
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_AUTH_TYPE="Authentication"
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_AUTH_TYPE_DESC="Authentication method for the webhook endpoint."
|
||||
COM_MOKOSUITECROSS_WEBHOOK_AUTH_NONE="None"
|
||||
COM_MOKOSUITECROSS_WEBHOOK_AUTH_BEARER="Bearer Token"
|
||||
COM_MOKOSUITECROSS_WEBHOOK_AUTH_BASIC="Basic Auth"
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_BEARER_TOKEN="Bearer Token"
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_BEARER_TOKEN_DESC="Authentication token sent as Authorization: Bearer {token}."
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_BASIC_USER="Username"
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_BASIC_PWD="Password"
|
||||
COM_MOKOSUITECROSS_CRED_WEBHOOK_CONTENT_TYPE="Content Type"
|
||||
|
||||
; Service help link
|
||||
COM_MOKOSUITECROSS_SERVICE_HELP_LINK="%s Setup Guide"
|
||||
|
||||
; Setup help panel
|
||||
COM_MOKOSUITECROSS_SETUP_HELP_TITLE="How to set up"
|
||||
COM_MOKOSUITECROSS_SETUP_HELP_INTRO="Setting up a new service is easy:"
|
||||
COM_MOKOSUITECROSS_SETUP_STEP1="Choose a service type from the dropdown"
|
||||
COM_MOKOSUITECROSS_SETUP_STEP2="Fill in the connection details that appear"
|
||||
COM_MOKOSUITECROSS_SETUP_STEP3="For OAuth services, save first, then click Connect"
|
||||
COM_MOKOSUITECROSS_SETUP_STEP4="Set status to Published and save"
|
||||
|
||||
; Test Connection
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_TITLE="Test Connection"
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_DESC="Verify that your credentials are valid and the service is reachable."
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_BUTTON="Test Connection"
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_TESTING="Testing..."
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_SUCCESS="Connection successful"
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_FAILED="Connection failed"
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_ERROR="Could not reach the server. Please try again."
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_NO_SERVICE="No service specified for test."
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_NOT_FOUND="Service record not found."
|
||||
COM_MOKOSUITECROSS_TEST_CONNECTION_NO_PLUGIN="No service plugin available for type '%s'."
|
||||
|
||||
; Bulk Queue Actions
|
||||
COM_MOKOSUITECROSS_TOOLBAR_RETRY_FAILED="Retry Failed"
|
||||
COM_MOKOSUITECROSS_TOOLBAR_PURGE_POSTED="Purge Posted"
|
||||
COM_MOKOSUITECROSS_POSTS_N_RETRIED="%d failed post(s) re-queued for retry."
|
||||
COM_MOKOSUITECROSS_POSTS_N_RETRIED_1="1 failed post re-queued for retry."
|
||||
COM_MOKOSUITECROSS_POSTS_N_PURGED="%d posted record(s) purged."
|
||||
COM_MOKOSUITECROSS_POSTS_N_PURGED_1="1 posted record purged."
|
||||
COM_MOKOSUITECROSS_POSTS_N_SCHEDULED="%d post(s) scheduled."
|
||||
COM_MOKOSUITECROSS_POSTS_NO_ITEM_SELECTED="No posts selected."
|
||||
COM_MOKOSUITECROSS_SCHEDULE_NO_DATE="Please select a date and time for scheduling."
|
||||
COM_MOKOSUITECROSS_TOOLBAR_SCHEDULE="Schedule"
|
||||
COM_MOKOSUITECROSS_TOOLBAR_RETRY_SELECTED="Retry Selected"
|
||||
|
||||
; Queue Depth Warning
|
||||
COM_MOKOSUITECROSS_DASHBOARD_QUEUE_DEPTH_WARNING_TITLE="Large queue backlog"
|
||||
COM_MOKOSUITECROSS_DASHBOARD_QUEUE_DEPTH_WARNING="There are %d posts waiting in the queue. Please verify that the Joomla Task Scheduler is running and the MokoSuiteCross scheduled task is enabled in System → Scheduled Tasks."
|
||||
|
||||
; First-Publish-Only
|
||||
COM_MOKOSUITECROSS_CONFIG_FIRST_PUBLISH_ONLY="First Publish Only"
|
||||
COM_MOKOSUITECROSS_CONFIG_FIRST_PUBLISH_ONLY_DESC="When enabled, articles are only cross-posted on their first save as published. Subsequent edits to already-published articles will not trigger new cross-posts."
|
||||
|
||||
; Trend Chart
|
||||
COM_MOKOSUITECROSS_DASHBOARD_TREND_CHART="Daily Post Trend"
|
||||
|
||||
; Date Range Period Filter
|
||||
COM_MOKOSUITECROSS_PERIOD_7_DAYS="Last 7 days"
|
||||
COM_MOKOSUITECROSS_PERIOD_30_DAYS="Last 30 days"
|
||||
COM_MOKOSUITECROSS_PERIOD_90_DAYS="Last 90 days"
|
||||
COM_MOKOSUITECROSS_PERIOD_ALL_TIME="All time"
|
||||
|
||||
; Hashtag Placeholders
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_TAGS="Article tags (comma-separated)"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_HASHTAGS="Article tags as hashtags (#Tag1 #Tag2)"
|
||||
COM_MOKOSUITECROSS_PLACEHOLDER_CUSTOM_FIELD="Custom field value (replace xxx with field name)"
|
||||
|
||||
; CSV Export
|
||||
COM_MOKOSUITECROSS_EXPORT_CSV="Export CSV"
|
||||
|
||||
; Service Stats (drill-down)
|
||||
COM_MOKOSUITECROSS_SERVICESTATS_RECENT_POSTS="Recent Posts"
|
||||
COM_MOKOSUITECROSS_SERVICESTATS_NO_POSTS="No posts for this service yet."
|
||||
COM_MOKOSUITECROSS_SERVICESTATS_TOP_ARTICLES="Top Articles for This Service"
|
||||
|
||||
; API Dispatch
|
||||
COM_MOKOSUITECROSS_DISPATCH_MISSING_ARTICLE="Missing or invalid article_id in request body."
|
||||
COM_MOKOSUITECROSS_DISPATCH_INVALID_SERVICES="service_ids must be a non-empty array of service IDs."
|
||||
COM_MOKOSUITECROSS_DISPATCH_ARTICLE_NOT_FOUND="Article not found."
|
||||
COM_MOKOSUITECROSS_DISPATCH_NO_SERVICES="No enabled services found matching the request."
|
||||
|
||||
; Category Rules
|
||||
COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES="Category Rules"
|
||||
COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES_NOTE="Category Routing"
|
||||
COM_MOKOSUITECROSS_CONFIG_CATEGORY_RULES_NOTE_DESC="Category routing rules let you map Joomla categories to specific cross-post services. When rules exist for a category, only those services receive posts. When no rules exist, all services are used (default behaviour). Rules are managed in the database table #__mokosuitecross_category_rules. A full admin UI will be added in a future release."
|
||||
@@ -1,11 +0,0 @@
|
||||
; MokoSuiteCross — System Language File
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
COM_MOKOSUITECROSS="MokoSuiteCross"
|
||||
COM_MOKOSUITECROSS_DESCRIPTION="Cross-posting Joomla content to social media, email marketing, and chat platforms"
|
||||
COM_MOKOSUITECROSS_SUBMENU_DASHBOARD="Dashboard"
|
||||
COM_MOKOSUITECROSS_SUBMENU_POSTS="Post Queue"
|
||||
COM_MOKOSUITECROSS_SUBMENU_SERVICES="Services"
|
||||
COM_MOKOSUITECROSS_SUBMENU_TEMPLATES="Templates"
|
||||
COM_MOKOSUITECROSS_SUBMENU_LOGS="Activity Logs"
|
||||
@@ -1,5 +0,0 @@
|
||||
-- MokoSuiteCross — Uninstall
|
||||
DROP TABLE IF EXISTS `#__mokosuitecross_logs`;
|
||||
DROP TABLE IF EXISTS `#__mokosuitecross_posts`;
|
||||
DROP TABLE IF EXISTS `#__mokosuitecross_templates`;
|
||||
DROP TABLE IF EXISTS `#__mokosuitecross_services`;
|
||||
@@ -1,14 +0,0 @@
|
||||
-- MokoSuiteCross 01.01.00 — Category routing rules
|
||||
-- Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
-- SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-- Note: also in install.mysql.sql for fresh installs; IF NOT EXISTS prevents conflicts
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `#__mokosuitecross_category_rules` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`category_id` int(10) unsigned NOT NULL,
|
||||
`service_id` int(10) unsigned NOT NULL,
|
||||
`published` tinyint(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `idx_category_service` (`category_id`, `service_id`),
|
||||
KEY `idx_category` (`category_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
/**
|
||||
* Encrypts and decrypts service credentials using libsodium.
|
||||
*
|
||||
* Uses Joomla's $secret from configuration.php as the key source.
|
||||
* Falls back to plaintext JSON if sodium is unavailable or decryption
|
||||
* fails (backward compat with existing unencrypted credentials).
|
||||
*/
|
||||
class CredentialHelper
|
||||
{
|
||||
private const PREFIX = 'enc:sodium:';
|
||||
|
||||
/**
|
||||
* Encrypt a credentials array to a storable string.
|
||||
*
|
||||
* @param array $credentials Credentials to encrypt
|
||||
*
|
||||
* @return string Encrypted string prefixed with "enc:sodium:", or plain JSON as fallback
|
||||
*/
|
||||
public static function encrypt(array $credentials): string
|
||||
{
|
||||
$json = json_encode($credentials);
|
||||
|
||||
if (!function_exists('sodium_crypto_secretbox')) {
|
||||
return $json;
|
||||
}
|
||||
|
||||
try {
|
||||
$key = self::deriveKey();
|
||||
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
$cipher = sodium_crypto_secretbox($json, $nonce, $key);
|
||||
|
||||
return self::PREFIX . base64_encode($nonce . $cipher);
|
||||
} catch (\Throwable $e) {
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt a credentials string back to an array.
|
||||
*
|
||||
* Handles both encrypted (prefixed) and legacy plaintext JSON.
|
||||
*
|
||||
* @param string $stored Stored credential string
|
||||
*
|
||||
* @return array Decoded credentials
|
||||
*/
|
||||
public static function decrypt(string $stored): array
|
||||
{
|
||||
if (empty($stored)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Legacy plaintext JSON — no prefix
|
||||
if (!str_starts_with($stored, self::PREFIX)) {
|
||||
return json_decode($stored, true) ?: [];
|
||||
}
|
||||
|
||||
if (!function_exists('sodium_crypto_secretbox_open')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
$key = self::deriveKey();
|
||||
$payload = base64_decode(substr($stored, strlen(self::PREFIX)));
|
||||
|
||||
if ($payload === false || strlen($payload) < SODIUM_CRYPTO_SECRETBOX_NONCEBYTES) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$nonce = substr($payload, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
$cipher = substr($payload, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
$plain = sodium_crypto_secretbox_open($cipher, $nonce, $key);
|
||||
|
||||
if ($plain === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return json_decode($plain, true) ?: [];
|
||||
} catch (\Throwable $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive a 32-byte encryption key from Joomla's secret.
|
||||
*/
|
||||
private static function deriveKey(): string
|
||||
{
|
||||
$secret = Factory::getApplication()->get('secret', '');
|
||||
|
||||
return sodium_crypto_generichash($secret, '', SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
|
||||
}
|
||||
}
|
||||
@@ -1,388 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
/**
|
||||
* Migration helper for importing settings from Perfect Publisher Pro (com_autotweet).
|
||||
*
|
||||
* PP Pro stores channels in #__autotweet_channels with a channeltype_id FK
|
||||
* to #__autotweet_channeltypes. Each channel has a JSON params column
|
||||
* containing OAuth tokens, API keys, webhook URLs, etc.
|
||||
*
|
||||
* This helper reads those channels and creates MokoSuiteCross service records.
|
||||
*/
|
||||
class MigrationHelper
|
||||
{
|
||||
/**
|
||||
* Channel type name → MokoSuiteCross service type mapping.
|
||||
* PP Pro channeltype names vary; we match common patterns.
|
||||
*/
|
||||
private const CHANNEL_MAP = [
|
||||
'facebook' => 'facebook',
|
||||
'fb' => 'facebook',
|
||||
'twitter' => 'twitter',
|
||||
'tw' => 'twitter',
|
||||
'linkedin' => 'linkedin',
|
||||
'li' => 'linkedin',
|
||||
'telegram' => 'telegram',
|
||||
'tg' => 'telegram',
|
||||
'discord' => 'discord',
|
||||
'slack' => 'slack',
|
||||
'mastodon' => 'mastodon',
|
||||
];
|
||||
|
||||
/**
|
||||
* Run the full migration from Perfect Publisher Pro.
|
||||
*
|
||||
* Strategy:
|
||||
* 1. Try reading #__autotweet_channels (PP Pro's channel table)
|
||||
* 2. Fall back to reading component params if table doesn't exist
|
||||
* 3. Create disabled MokoSuiteCross service records
|
||||
*
|
||||
* @return array ['migrated' => int, 'skipped' => int, 'errors' => string[]]
|
||||
*/
|
||||
public static function migrate(): array
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$result = ['migrated' => 0, 'skipped' => 0, 'errors' => []];
|
||||
|
||||
// Check if PP Pro is installed
|
||||
if (!self::isPPProInstalled($db)) {
|
||||
$result['errors'][] = 'Perfect Publisher Pro (com_autotweet) is not installed.';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Try channel-based migration first (PP Pro stores configs in #__autotweet_channels)
|
||||
if (self::hasChannelTable($db)) {
|
||||
$result = self::migrateFromChannels($db, $result);
|
||||
} else {
|
||||
// Fall back to component params extraction
|
||||
$result = self::migrateFromParams($db, $result);
|
||||
}
|
||||
|
||||
// Clear migration flag from MokoSuiteCross params
|
||||
self::clearMigrationFlag($db);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if PP Pro is installed.
|
||||
*/
|
||||
private static function isPPProInstalled($db): bool
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where('(' . $db->quoteName('element') . ' = ' . $db->quote('com_autotweet')
|
||||
. ' OR ' . $db->quoteName('element') . ' LIKE ' . $db->quote('%perfectpublisher%') . ')')
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'));
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return (int) $db->loadResult() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the autotweet_channels table exists.
|
||||
*/
|
||||
private static function hasChannelTable($db): bool
|
||||
{
|
||||
$prefix = $db->getPrefix();
|
||||
|
||||
try {
|
||||
$db->setQuery('SHOW TABLES LIKE ' . $db->quote($prefix . 'autotweet_channels'));
|
||||
|
||||
return !empty($db->loadResult());
|
||||
} catch (\Throwable $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate from #__autotweet_channels table (primary method).
|
||||
*/
|
||||
private static function migrateFromChannels($db, array $result): array
|
||||
{
|
||||
// Load channels with their type names
|
||||
$query = $db->getQuery(true)
|
||||
->select('c.id, c.name, c.published, c.params')
|
||||
->select($db->quoteName('ct.name', 'type_name'))
|
||||
->from($db->quoteName('#__autotweet_channels', 'c'))
|
||||
->join('LEFT', $db->quoteName('#__autotweet_channeltypes', 'ct')
|
||||
. ' ON ' . $db->quoteName('ct.id') . ' = ' . $db->quoteName('c.channeltype_id'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$channels = $db->loadObjectList();
|
||||
|
||||
if (empty($channels)) {
|
||||
$result['errors'][] = 'No channels found in Perfect Publisher Pro.';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($channels as $channel) {
|
||||
$typeName = strtolower(trim($channel->type_name ?? ''));
|
||||
|
||||
// Match to MokoSuiteCross service type
|
||||
$mjcType = null;
|
||||
|
||||
foreach (self::CHANNEL_MAP as $pattern => $serviceType) {
|
||||
if (str_contains($typeName, $pattern)) {
|
||||
$mjcType = $serviceType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$mjcType) {
|
||||
$result['skipped']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for duplicate (same type + migrated alias)
|
||||
$alias = $mjcType . '-pp-' . $channel->id;
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__mokosuitecross_services'))
|
||||
->where($db->quoteName('alias') . ' = ' . $db->quote($alias));
|
||||
$db->setQuery($query);
|
||||
|
||||
if ((int) $db->loadResult() > 0) {
|
||||
$result['skipped']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Parse channel params to extract credentials
|
||||
$channelParams = json_decode($channel->params ?: '{}', true) ?: [];
|
||||
$credentials = self::mapChannelCredentials($mjcType, $channelParams);
|
||||
|
||||
if (empty($credentials)) {
|
||||
$result['skipped']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create MokoSuiteCross service record
|
||||
$service = (object) [
|
||||
'title' => $channel->name ?: ucfirst($mjcType) . ' (PP Pro #' . $channel->id . ')',
|
||||
'alias' => $alias,
|
||||
'service_type' => $mjcType,
|
||||
'credentials' => json_encode($credentials),
|
||||
'params' => '{}',
|
||||
'published' => 0, // Disabled — user must verify before enabling
|
||||
'ordering' => 0,
|
||||
'created' => Factory::getDate()->toSql(),
|
||||
'modified' => Factory::getDate()->toSql(),
|
||||
'created_by' => Factory::getApplication()->getIdentity()->id ?? 0,
|
||||
];
|
||||
|
||||
try {
|
||||
$db->insertObject('#__mokosuitecross_services', $service);
|
||||
$result['migrated']++;
|
||||
} catch (\Throwable $e) {
|
||||
$result['errors'][] = sprintf('Failed to create %s service: %s', $mjcType, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map PP Pro channel params to MokoSuiteCross credential format.
|
||||
*
|
||||
* PP Pro stores various keys in channel params depending on the type.
|
||||
* We normalize them to MokoSuiteCross's expected credential structure.
|
||||
*/
|
||||
private static function mapChannelCredentials(string $serviceType, array $channelParams): array
|
||||
{
|
||||
$creds = ['mode' => 'custom'];
|
||||
|
||||
// Common OAuth fields PP Pro uses
|
||||
$oauthFields = ['access_token', 'access_secret', 'client_id', 'client_secret',
|
||||
'api_key', 'api_secret', 'app_id', 'app_secret', 'token'];
|
||||
|
||||
switch ($serviceType) {
|
||||
case 'facebook':
|
||||
$creds['page_access_token'] = $channelParams['access_token'] ?? $channelParams['token'] ?? '';
|
||||
$creds['page_id'] = $channelParams['page_id'] ?? $channelParams['pageid'] ?? '';
|
||||
break;
|
||||
|
||||
case 'twitter':
|
||||
$creds['bearer_token'] = $channelParams['bearer_token'] ?? '';
|
||||
$creds['api_key'] = $channelParams['api_key'] ?? $channelParams['consumer_key'] ?? '';
|
||||
$creds['api_secret'] = $channelParams['api_secret'] ?? $channelParams['consumer_secret'] ?? '';
|
||||
$creds['access_token'] = $channelParams['access_token'] ?? '';
|
||||
$creds['access_token_secret'] = $channelParams['access_secret'] ?? $channelParams['access_token_secret'] ?? '';
|
||||
break;
|
||||
|
||||
case 'linkedin':
|
||||
$creds['access_token'] = $channelParams['access_token'] ?? $channelParams['token'] ?? '';
|
||||
$creds['organization_id'] = $channelParams['company_id'] ?? $channelParams['organization_id'] ?? '';
|
||||
$creds['person_id'] = $channelParams['person_id'] ?? $channelParams['member_id'] ?? '';
|
||||
break;
|
||||
|
||||
case 'telegram':
|
||||
$creds['bot_token'] = $channelParams['bot_token'] ?? $channelParams['token'] ?? $channelParams['api_key'] ?? '';
|
||||
$creds['chat_id'] = $channelParams['chat_id'] ?? $channelParams['channel_id'] ?? '';
|
||||
break;
|
||||
|
||||
case 'discord':
|
||||
$creds['webhook_url'] = $channelParams['webhook_url'] ?? $channelParams['webhook'] ?? '';
|
||||
break;
|
||||
|
||||
case 'slack':
|
||||
$creds['webhook_url'] = $channelParams['webhook_url'] ?? $channelParams['webhook'] ?? '';
|
||||
break;
|
||||
|
||||
case 'mastodon':
|
||||
$creds['instance_url'] = $channelParams['instance_url'] ?? $channelParams['server'] ?? '';
|
||||
$creds['access_token'] = $channelParams['access_token'] ?? $channelParams['token'] ?? '';
|
||||
break;
|
||||
|
||||
default:
|
||||
// Generic: copy all non-empty params
|
||||
foreach ($channelParams as $key => $value) {
|
||||
if (!empty($value) && is_string($value)) {
|
||||
$creds[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove empty credential values and the mode key for check
|
||||
$check = array_filter($creds, fn($v, $k) => $k !== 'mode' && !empty($v), ARRAY_FILTER_USE_BOTH);
|
||||
|
||||
return empty($check) ? [] : $creds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback: migrate from component params when channel table doesn't exist.
|
||||
*/
|
||||
private static function migrateFromParams($db, array $result): array
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('params'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where('(' . $db->quoteName('element') . ' = ' . $db->quote('com_autotweet')
|
||||
. ' OR ' . $db->quoteName('element') . ' LIKE ' . $db->quote('%perfectpublisher%') . ')')
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rawParams = $db->loadResult();
|
||||
|
||||
if (!$rawParams) {
|
||||
$result['errors'][] = 'No PP Pro configuration found.';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$params = json_decode($rawParams, true);
|
||||
|
||||
if (!is_array($params)) {
|
||||
$result['errors'][] = 'Could not parse PP Pro configuration.';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Extract services from component params using prefix patterns
|
||||
$servicePatterns = [
|
||||
'facebook' => ['facebook_', 'fb_'],
|
||||
'twitter' => ['twitter_', 'tw_'],
|
||||
'linkedin' => ['linkedin_', 'li_'],
|
||||
'telegram' => ['telegram_', 'tg_'],
|
||||
];
|
||||
|
||||
foreach ($servicePatterns as $mjcType => $prefixes) {
|
||||
$credentials = ['mode' => 'custom'];
|
||||
$found = false;
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
foreach ($prefixes as $prefix) {
|
||||
if (str_starts_with($key, $prefix) && !empty($value)) {
|
||||
$cleanKey = substr($key, strlen($prefix));
|
||||
$credentials[$cleanKey] = $value;
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$result['skipped']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Duplicate check
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__mokosuitecross_services'))
|
||||
->where($db->quoteName('service_type') . ' = ' . $db->quote($mjcType))
|
||||
->where($db->quoteName('alias') . ' LIKE ' . $db->quote('%-migrated%'));
|
||||
$db->setQuery($query);
|
||||
|
||||
if ((int) $db->loadResult() > 0) {
|
||||
$result['skipped']++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$service = (object) [
|
||||
'title' => ucfirst($mjcType) . ' (migrated from PP Pro)',
|
||||
'alias' => $mjcType . '-migrated',
|
||||
'service_type' => $mjcType,
|
||||
'credentials' => json_encode($credentials),
|
||||
'params' => '{}',
|
||||
'published' => 0,
|
||||
'ordering' => 0,
|
||||
'created' => Factory::getDate()->toSql(),
|
||||
'modified' => Factory::getDate()->toSql(),
|
||||
'created_by' => Factory::getApplication()->getIdentity()->id ?? 0,
|
||||
];
|
||||
|
||||
try {
|
||||
$db->insertObject('#__mokosuitecross_services', $service);
|
||||
$result['migrated']++;
|
||||
} catch (\Throwable $e) {
|
||||
$result['errors'][] = sprintf('Failed to create %s: %s', $mjcType, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the migration flag from MokoSuiteCross component params.
|
||||
*/
|
||||
private static function clearMigrationFlag($db): void
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('params'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote('com_mokosuitecross'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$params = json_decode($db->loadResult() ?: '{}', true) ?: [];
|
||||
|
||||
unset($params['migration_available'], $params['migration_source_params']);
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__extensions'))
|
||||
->set($db->quoteName('params') . ' = ' . $db->quote(json_encode($params)))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote('com_mokosuitecross'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
/**
|
||||
* Component helper — renders the admin submenu.
|
||||
*
|
||||
* Uses Joomla 5+ toolbar submenu API when available, falling back to the
|
||||
* deprecated Sidebar API for Joomla 4 compatibility.
|
||||
*/
|
||||
class MokoSuiteCrossHelper
|
||||
{
|
||||
/**
|
||||
* Configure the submenu links.
|
||||
*
|
||||
* Called from each view's display() to highlight the active item.
|
||||
*
|
||||
* @param string $activeView The current view name
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function addSubmenu(string $activeView): void
|
||||
{
|
||||
$views = [
|
||||
'dashboard' => 'COM_MOKOSUITECROSS_SUBMENU_DASHBOARD',
|
||||
'posts' => 'COM_MOKOSUITECROSS_SUBMENU_POSTS',
|
||||
'services' => 'COM_MOKOSUITECROSS_SUBMENU_SERVICES',
|
||||
'templates' => 'COM_MOKOSUITECROSS_SUBMENU_TEMPLATES',
|
||||
'logs' => 'COM_MOKOSUITECROSS_SUBMENU_LOGS',
|
||||
];
|
||||
|
||||
// Joomla 5+ toolbar submenu
|
||||
if (class_exists('Joomla\CMS\Toolbar\Toolbar')) {
|
||||
try {
|
||||
$toolbar = Factory::getApplication()->getDocument()->getToolbar('submenu');
|
||||
|
||||
if ($toolbar && method_exists($toolbar, 'linkButton')) {
|
||||
foreach ($views as $view => $langKey) {
|
||||
$toolbar->linkButton($view, Text::_($langKey))
|
||||
->url('index.php?option=com_mokosuitecross&view=' . $view)
|
||||
->active($activeView === $view);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Fall through to legacy sidebar
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy fallback for Joomla 4
|
||||
foreach ($views as $view => $langKey) {
|
||||
\Joomla\CMS\HTML\Sidebar::addEntry(
|
||||
Text::_($langKey),
|
||||
'index.php?option=com_mokosuitecross&view=' . $view,
|
||||
$activeView === $view
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Helper;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Static helper that maps service types to Joomla Bootstrap icons.
|
||||
*/
|
||||
class ServiceIconHelper
|
||||
{
|
||||
/**
|
||||
* Map of service type identifiers to icon CSS classes.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private const ICONS = [
|
||||
// Social
|
||||
'facebook' => 'icon-facebook',
|
||||
'twitter' => 'icon-twitter',
|
||||
'linkedin' => 'icon-linkedin',
|
||||
'mastodon' => 'icon-globe',
|
||||
'bluesky' => 'icon-cloud',
|
||||
'threads' => 'icon-comments',
|
||||
'pinterest' => 'icon-thumbtack',
|
||||
'reddit' => 'icon-comments-alt',
|
||||
'tumblr' => 'icon-pencil-alt',
|
||||
'tiktok' => 'icon-play-circle',
|
||||
'nostr' => 'icon-key',
|
||||
'activitypub' => 'icon-network-wired',
|
||||
// Chat
|
||||
'telegram' => 'icon-paper-plane',
|
||||
'discord' => 'icon-headset',
|
||||
'slack' => 'icon-hashtag',
|
||||
'teams' => 'icon-users',
|
||||
'googlechat' => 'icon-comment',
|
||||
'whatsapp' => 'icon-mobile',
|
||||
'matrix' => 'icon-th',
|
||||
'ntfy' => 'icon-bell',
|
||||
// Email
|
||||
'mailchimp' => 'icon-envelope',
|
||||
'sendgrid' => 'icon-envelope-open',
|
||||
'brevo' => 'icon-at',
|
||||
'convertkit' => 'icon-mail-bulk',
|
||||
'constantcontact' => 'icon-address-book',
|
||||
// Publishing
|
||||
'medium' => 'icon-book',
|
||||
'wordpress' => 'icon-blog',
|
||||
'devto' => 'icon-code',
|
||||
'ghost' => 'icon-ghost',
|
||||
'hashnode' => 'icon-newspaper',
|
||||
'blogger' => 'icon-rss',
|
||||
// Business
|
||||
'googlebusiness' => 'icon-store',
|
||||
// Universal
|
||||
'webhook' => 'icon-plug',
|
||||
'rssfeed' => 'icon-rss-square',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the icon CSS class for a service type.
|
||||
*
|
||||
* @param string $serviceType The service type identifier
|
||||
*
|
||||
* @return string Icon CSS class
|
||||
*/
|
||||
public static function getIcon(string $serviceType): string
|
||||
{
|
||||
return self::ICONS[$serviceType] ?? 'icon-share-alt';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an icon span element for a service type.
|
||||
*
|
||||
* @param string $serviceType The service type identifier
|
||||
* @param string $extraClass Additional CSS classes to append
|
||||
*
|
||||
* @return string HTML span element
|
||||
*/
|
||||
public static function renderIcon(string $serviceType, string $extraClass = ''): string
|
||||
{
|
||||
$icon = self::getIcon($serviceType);
|
||||
$class = trim($icon . ' ' . htmlspecialchars($extraClass, ENT_QUOTES, 'UTF-8'));
|
||||
|
||||
return '<span class="' . $class . '" aria-hidden="true"></span>';
|
||||
}
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
|
||||
class DashboardModel extends BaseDatabaseModel
|
||||
{
|
||||
/**
|
||||
* Get summary statistics for the dashboard.
|
||||
*
|
||||
* @return object Stats object with counts
|
||||
*/
|
||||
public function getStats(): object
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$stats = new \stdClass();
|
||||
|
||||
// Active services count
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__mokosuitecross_services'))
|
||||
->where($db->quoteName('published') . ' = 1');
|
||||
$db->setQuery($query);
|
||||
$stats->active_services = (int) $db->loadResult();
|
||||
|
||||
// Posts by status
|
||||
foreach (['queued', 'posted', 'failed'] as $status) {
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__mokosuitecross_posts'))
|
||||
->where($db->quoteName('status') . ' = ' . $db->quote($status));
|
||||
$db->setQuery($query);
|
||||
$stats->{$status . '_count'} = (int) $db->loadResult();
|
||||
}
|
||||
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Perfect Publisher Pro migration is available.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMigrationAvailable(): bool
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('params'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote('com_mokosuitecross'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$params = json_decode($db->loadResult() ?: '{}', true);
|
||||
|
||||
return !empty($params['migration_available']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recent activity log entries.
|
||||
*
|
||||
* @param int $limit Number of entries to return
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRecentActivity(int $limit = 10): array
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('l.*, s.title AS service_title, s.service_type')
|
||||
->from($db->quoteName('#__mokosuitecross_logs', 'l'))
|
||||
->join('LEFT', $db->quoteName('#__mokosuitecross_services', 's')
|
||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('l.service_id'))
|
||||
->order($db->quoteName('l.created') . ' DESC');
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
return $db->loadObjectList() ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get posts-per-service breakdown for the analytics chart.
|
||||
*
|
||||
* @param string|null $since Only count posts created on or after this datetime
|
||||
*
|
||||
* @return array [['service_type' => '...', 'posted' => N, 'failed' => N, 'queued' => N], ...]
|
||||
*/
|
||||
public function getServiceBreakdown(?string $since = null): array
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
$db->quoteName('s.id', 'service_id'),
|
||||
$db->quoteName('s.service_type'),
|
||||
$db->quoteName('s.title', 'service_title'),
|
||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS posted',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('failed') . ' THEN 1 ELSE 0 END) AS failed',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('queued') . ' THEN 1 ELSE 0 END) AS queued',
|
||||
'COUNT(*) AS total',
|
||||
])
|
||||
->from($db->quoteName('#__mokosuitecross_posts', 'p'))
|
||||
->join('INNER', $db->quoteName('#__mokosuitecross_services', 's')
|
||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('p.service_id'))
|
||||
->group($db->quoteName(['s.id', 's.service_type', 's.title']))
|
||||
->order('total DESC');
|
||||
|
||||
if ($since !== null) {
|
||||
$query->where($db->quoteName('p.created') . ' >= ' . $db->quote($since));
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadAssocList() ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get posts-per-day for the last N days (for trend chart).
|
||||
*
|
||||
* @param int $days Number of days to look back
|
||||
*
|
||||
* @return array [['day' => '2026-05-28', 'posted' => N, 'failed' => N], ...]
|
||||
*/
|
||||
public function getDailyTrend(int $days = 14): array
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$cutoff = Factory::getDate('now - ' . $days . ' days')->format('Y-m-d');
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
'DATE(' . $db->quoteName('created') . ') AS day',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS posted',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('failed') . ' THEN 1 ELSE 0 END) AS failed',
|
||||
'COUNT(*) AS total',
|
||||
])
|
||||
->from($db->quoteName('#__mokosuitecross_posts'))
|
||||
->where('DATE(' . $db->quoteName('created') . ') >= ' . $db->quote($cutoff))
|
||||
->group('DATE(' . $db->quoteName('created') . ')')
|
||||
->order('day ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadAssocList() ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get most cross-posted articles.
|
||||
*
|
||||
* @param int $limit Number of articles
|
||||
* @param string|null $since Only count posts created on or after this datetime
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTopArticles(int $limit = 5, ?string $since = null): array
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
$db->quoteName('c.id'),
|
||||
$db->quoteName('c.title'),
|
||||
'COUNT(*) AS post_count',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS success_count',
|
||||
])
|
||||
->from($db->quoteName('#__mokosuitecross_posts', 'p'))
|
||||
->join('INNER', $db->quoteName('#__content', 'c')
|
||||
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('p.article_id'))
|
||||
->group($db->quoteName(['c.id', 'c.title']))
|
||||
->order('post_count DESC');
|
||||
|
||||
if ($since !== null) {
|
||||
$query->where($db->quoteName('p.created') . ' >= ' . $db->quote($since));
|
||||
}
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
return $db->loadAssocList() ?: [];
|
||||
}
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filter\OutputFilter;
|
||||
use Joomla\CMS\MVC\Model\AdminModel;
|
||||
|
||||
class ServiceModel extends AdminModel
|
||||
{
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form
|
||||
* @param boolean $loadData True if the form is to load its own data
|
||||
*
|
||||
* @return \Joomla\CMS\Form\Form|boolean
|
||||
*/
|
||||
public function getForm($data = [], $loadData = true)
|
||||
{
|
||||
$form = $this->loadForm(
|
||||
'com_mokosuitecross.service',
|
||||
'service',
|
||||
['control' => 'jform', 'load_data' => $loadData]
|
||||
);
|
||||
|
||||
if (empty($form)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* Expands the JSON credentials column back into individual cred_* form fields
|
||||
* so they are populated when editing an existing service.
|
||||
*
|
||||
* @return mixed The data for the form
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
$data = $this->getItem();
|
||||
|
||||
if ($data && !empty($data->credentials)) {
|
||||
$credentials = \Joomla\Component\MokoSuiteCross\Administrator\Helper\CredentialHelper::decrypt($data->credentials);
|
||||
$serviceType = $data->service_type ?? '';
|
||||
|
||||
foreach ($credentials as $key => $value) {
|
||||
// Map credential keys back to form field names.
|
||||
// The mode field has no service type prefix.
|
||||
if ($key === 'mode') {
|
||||
$data->cred_mode = $value;
|
||||
} else {
|
||||
$data->{'cred_' . $serviceType . '_' . $key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override save to collect cred_* form fields into the credentials JSON column.
|
||||
*
|
||||
* The service form has individual fields (cred_twitter_api_key, cred_facebook_page_id, etc.)
|
||||
* but the database stores them as a single JSON blob in the `credentials` column.
|
||||
*
|
||||
* @param array $data The form data
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$serviceType = $data['service_type'] ?? '';
|
||||
$credentials = [];
|
||||
$credPrefix = 'cred_';
|
||||
|
||||
// Collect all cred_* fields into the credentials array
|
||||
foreach ($data as $key => $value) {
|
||||
if (strpos($key, $credPrefix) !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$credKey = substr($key, strlen($credPrefix));
|
||||
|
||||
// The mode field is shared across service types (no service_type prefix)
|
||||
if ($credKey === 'mode') {
|
||||
$credentials['mode'] = $value;
|
||||
} elseif ($serviceType && strpos($credKey, $serviceType . '_') === 0) {
|
||||
// Strip the service_type prefix: cred_twitter_api_key -> api_key
|
||||
$strippedKey = substr($credKey, strlen($serviceType) + 1);
|
||||
$credentials[$strippedKey] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Store credentials encrypted
|
||||
$data['credentials'] = !empty($credentials)
|
||||
? \Joomla\Component\MokoSuiteCross\Administrator\Helper\CredentialHelper::encrypt($credentials)
|
||||
: '{}';
|
||||
|
||||
// Remove individual cred_* fields so they don't cause column-not-found errors
|
||||
foreach (array_keys($data) as $key) {
|
||||
if (strpos($key, $credPrefix) === 0) {
|
||||
unset($data[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::save($data);
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
|
||||
/**
|
||||
* Per-service analytics drill-down model.
|
||||
*/
|
||||
class ServiceStatsModel extends BaseDatabaseModel
|
||||
{
|
||||
/**
|
||||
* Get the service ID from the request.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getServiceId(): int
|
||||
{
|
||||
return Factory::getApplication()->input->getInt('id', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a single service record by ID.
|
||||
*
|
||||
* @param int $id Service ID
|
||||
*
|
||||
* @return object|null
|
||||
*/
|
||||
public function getService(int $id = 0): ?object
|
||||
{
|
||||
if ($id === 0) {
|
||||
$id = $this->getServiceId();
|
||||
}
|
||||
|
||||
if ($id === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$db = $this->getDatabase();
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from($db->quoteName('#__mokosuitecross_services'))
|
||||
->where($db->quoteName('id') . ' = ' . (int) $id);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadObject() ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get post status counts for a specific service.
|
||||
*
|
||||
* @param int $serviceId Service ID
|
||||
*
|
||||
* @return object Object with total, posted, failed, queued properties
|
||||
*/
|
||||
public function getPostStats(int $serviceId): object
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$stats = new \stdClass();
|
||||
|
||||
foreach (['queued', 'posted', 'failed'] as $status) {
|
||||
$query = $db->getQuery(true)
|
||||
->select('COUNT(*)')
|
||||
->from($db->quoteName('#__mokosuitecross_posts'))
|
||||
->where($db->quoteName('service_id') . ' = ' . (int) $serviceId)
|
||||
->where($db->quoteName('status') . ' = ' . $db->quote($status));
|
||||
$db->setQuery($query);
|
||||
$stats->{$status} = (int) $db->loadResult();
|
||||
}
|
||||
|
||||
$stats->total = $stats->queued + $stats->posted + $stats->failed;
|
||||
|
||||
return $stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get daily post trend for a specific service.
|
||||
*
|
||||
* @param int $serviceId Service ID
|
||||
* @param int $days Number of days to look back
|
||||
*
|
||||
* @return array [['day' => '2026-05-28', 'posted' => N, 'failed' => N], ...]
|
||||
*/
|
||||
public function getDailyTrend(int $serviceId, int $days = 30): array
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$cutoff = Factory::getDate('now - ' . $days . ' days')->format('Y-m-d');
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
'DATE(' . $db->quoteName('created') . ') AS day',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS posted',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('status') . ' = ' . $db->quote('failed') . ' THEN 1 ELSE 0 END) AS failed',
|
||||
'COUNT(*) AS total',
|
||||
])
|
||||
->from($db->quoteName('#__mokosuitecross_posts'))
|
||||
->where($db->quoteName('service_id') . ' = ' . (int) $serviceId)
|
||||
->where('DATE(' . $db->quoteName('created') . ') >= ' . $db->quote($cutoff))
|
||||
->group('DATE(' . $db->quoteName('created') . ')')
|
||||
->order('day ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
return $db->loadAssocList() ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recent posts for a specific service with article titles.
|
||||
*
|
||||
* @param int $serviceId Service ID
|
||||
* @param int $limit Number of posts to return
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRecentPosts(int $serviceId, int $limit = 20): array
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
$db->quoteName('p.id'),
|
||||
$db->quoteName('p.status'),
|
||||
$db->quoteName('p.posted_at'),
|
||||
$db->quoteName('p.created'),
|
||||
$db->quoteName('p.error_message'),
|
||||
$db->quoteName('p.retry_count'),
|
||||
$db->quoteName('c.title', 'article_title'),
|
||||
])
|
||||
->from($db->quoteName('#__mokosuitecross_posts', 'p'))
|
||||
->join('LEFT', $db->quoteName('#__content', 'c')
|
||||
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('p.article_id'))
|
||||
->where($db->quoteName('p.service_id') . ' = ' . (int) $serviceId)
|
||||
->order($db->quoteName('p.created') . ' DESC');
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
return $db->loadAssocList() ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the most cross-posted articles for a specific service.
|
||||
*
|
||||
* @param int $serviceId Service ID
|
||||
* @param int $limit Number of articles to return
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTopArticles(int $serviceId, int $limit = 10): array
|
||||
{
|
||||
$db = $this->getDatabase();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select([
|
||||
$db->quoteName('c.id'),
|
||||
$db->quoteName('c.title'),
|
||||
'COUNT(*) AS post_count',
|
||||
'SUM(CASE WHEN ' . $db->quoteName('p.status') . ' = ' . $db->quote('posted') . ' THEN 1 ELSE 0 END) AS success_count',
|
||||
])
|
||||
->from($db->quoteName('#__mokosuitecross_posts', 'p'))
|
||||
->join('INNER', $db->quoteName('#__content', 'c')
|
||||
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('p.article_id'))
|
||||
->where($db->quoteName('p.service_id') . ' = ' . (int) $serviceId)
|
||||
->group($db->quoteName(['c.id', 'c.title']))
|
||||
->order('post_count DESC');
|
||||
|
||||
$db->setQuery($query, 0, $limit);
|
||||
|
||||
return $db->loadAssocList() ?: [];
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\Table;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filter\OutputFilter;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Table\Table;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
class ServiceTable extends Table
|
||||
{
|
||||
public function __construct(DatabaseDriver $db)
|
||||
{
|
||||
parent::__construct('#__mokosuitecross_services', 'id', $db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the record before storing.
|
||||
*
|
||||
* Generates alias from title if empty, validates required fields,
|
||||
* sets created/modified timestamps.
|
||||
*
|
||||
* @return boolean True if the record is valid
|
||||
*/
|
||||
public function check(): bool
|
||||
{
|
||||
// Title is required
|
||||
if (empty($this->title)) {
|
||||
$this->setError(Text::_('COM_MOKOSUITECROSS_ERROR_TITLE_REQUIRED'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Service type is required
|
||||
if (empty($this->service_type)) {
|
||||
$this->setError(Text::_('COM_MOKOSUITECROSS_ERROR_SERVICE_TYPE_REQUIRED'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Generate alias from title if empty
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = $this->title;
|
||||
}
|
||||
|
||||
$this->alias = OutputFilter::stringURLSafe($this->alias);
|
||||
|
||||
// Make sure alias is unique
|
||||
if (empty($this->alias)) {
|
||||
$this->alias = Factory::getDate()->format('Y-m-d-H-i-s');
|
||||
}
|
||||
|
||||
// Set timestamps
|
||||
$now = Factory::getDate()->toSql();
|
||||
|
||||
if (empty($this->created)) {
|
||||
$this->created = $now;
|
||||
}
|
||||
|
||||
$this->modified = $now;
|
||||
|
||||
// Set created_by if not set
|
||||
if (empty($this->created_by)) {
|
||||
$this->created_by = Factory::getApplication()->getIdentity()->id ?? 0;
|
||||
}
|
||||
|
||||
// Ensure credentials is valid JSON
|
||||
if (empty($this->credentials)) {
|
||||
$this->credentials = '{}';
|
||||
}
|
||||
|
||||
// Ensure params is valid JSON
|
||||
if (empty($this->params)) {
|
||||
$this->params = '{}';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\View\Dashboard;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
protected $stats;
|
||||
protected $migrationAvailable;
|
||||
protected $recentActivity;
|
||||
protected $serviceBreakdown;
|
||||
protected $dailyTrend;
|
||||
protected $topArticles;
|
||||
public $sidebar;
|
||||
public $period;
|
||||
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
$model = $this->getModel();
|
||||
|
||||
// Read period parameter for date range filtering
|
||||
$this->period = Factory::getApplication()->input->getInt('period', 30);
|
||||
$validPeriods = [7, 30, 90, 0];
|
||||
|
||||
if (!in_array($this->period, $validPeriods, true)) {
|
||||
$this->period = 30;
|
||||
}
|
||||
|
||||
// Calculate the since date based on period (0 = all time)
|
||||
$since = null;
|
||||
|
||||
if ($this->period > 0) {
|
||||
$since = Factory::getDate('now - ' . $this->period . ' days')->toSql();
|
||||
}
|
||||
|
||||
$this->stats = $this->get('Stats');
|
||||
$this->migrationAvailable = $this->get('MigrationAvailable');
|
||||
$this->recentActivity = $model->getRecentActivity(10);
|
||||
$this->serviceBreakdown = $model->getServiceBreakdown($since);
|
||||
$this->dailyTrend = $model->getDailyTrend($this->period ?: 365);
|
||||
$this->topArticles = $model->getTopArticles(5, $since);
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
MokoSuiteCrossHelper::addSubmenu('dashboard');
|
||||
$this->sidebar = \Joomla\CMS\HTML\Sidebar::render();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
ToolbarHelper::title('MokoSuiteCross — Dashboard', 'share-alt');
|
||||
ToolbarHelper::preferences('com_mokosuitecross');
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\View\Posts;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
protected $items;
|
||||
protected $pagination;
|
||||
protected $state;
|
||||
public $filterForm;
|
||||
public $activeFilters;
|
||||
public $sidebar;
|
||||
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->filterForm = $this->get('FilterForm');
|
||||
$this->activeFilters = $this->get('ActiveFilters');
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
ToolbarHelper::title('MokoSuiteCross — Post Queue', 'share-alt');
|
||||
ToolbarHelper::addNew('post.add');
|
||||
|
||||
$toolbar = Toolbar::getInstance('toolbar');
|
||||
$toolbar->standardButton('retry', 'COM_MOKOSUITECROSS_TOOLBAR_RETRY_FAILED', 'posts.retryFailed')
|
||||
->icon('icon-refresh')
|
||||
->listCheck(false);
|
||||
$toolbar->standardButton('purge', 'COM_MOKOSUITECROSS_TOOLBAR_PURGE_POSTED', 'posts.purgePosted')
|
||||
->icon('icon-trash')
|
||||
->listCheck(false);
|
||||
|
||||
$toolbar->standardButton('retry-selected', 'COM_MOKOSUITECROSS_TOOLBAR_RETRY_SELECTED', 'posts.retrySelected')
|
||||
->icon('icon-redo')
|
||||
->listCheck(true);
|
||||
$toolbar->standardButton('schedule', 'COM_MOKOSUITECROSS_TOOLBAR_SCHEDULE', 'posts.schedule')
|
||||
->icon('icon-calendar')
|
||||
->listCheck(true);
|
||||
|
||||
ToolbarHelper::deleteList('', 'posts.delete', 'JTOOLBAR_DELETE');
|
||||
|
||||
// Export CSV button
|
||||
$toolbar->appendButton(
|
||||
'Link',
|
||||
'download',
|
||||
'COM_MOKOSUITECROSS_EXPORT_CSV',
|
||||
Route::_('index.php?option=com_mokosuitecross&task=posts.exportCsv&format=raw', false)
|
||||
);
|
||||
|
||||
// Dashboard link in toolbar
|
||||
$toolbar->appendButton(
|
||||
'Link',
|
||||
'home',
|
||||
'COM_MOKOSUITECROSS_SUBMENU_DASHBOARD',
|
||||
Route::_('index.php?option=com_mokosuitecross&view=dashboard', false)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Component\MokoSuiteCross\Administrator\View\ServiceStats;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Helper\MokoSuiteCrossHelper;
|
||||
|
||||
/**
|
||||
* Per-service analytics drill-down view.
|
||||
*/
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
public $service;
|
||||
public $postStats;
|
||||
public $dailyTrend;
|
||||
public $recentPosts;
|
||||
public $topArticles;
|
||||
public $period;
|
||||
|
||||
public function display($tpl = null): void
|
||||
{
|
||||
/** @var \Joomla\Component\MokoSuiteCross\Administrator\Model\ServiceStatsModel $model */
|
||||
$model = $this->getModel();
|
||||
|
||||
$serviceId = $model->getServiceId();
|
||||
|
||||
$this->service = $model->getService($serviceId);
|
||||
|
||||
if (!$this->service) {
|
||||
throw new \RuntimeException('Service not found.', 404);
|
||||
}
|
||||
|
||||
$this->period = Factory::getApplication()->input->getInt('period', 30);
|
||||
$validPeriods = [7, 30, 90, 0];
|
||||
|
||||
if (!\in_array($this->period, $validPeriods, true)) {
|
||||
$this->period = 30;
|
||||
}
|
||||
|
||||
$days = $this->period ?: 365;
|
||||
|
||||
$this->postStats = $model->getPostStats($serviceId);
|
||||
$this->dailyTrend = $model->getDailyTrend($serviceId, $days);
|
||||
$this->recentPosts = $model->getRecentPosts($serviceId, 20);
|
||||
$this->topArticles = $model->getTopArticles($serviceId, 10);
|
||||
|
||||
$this->addToolbar();
|
||||
|
||||
MokoSuiteCrossHelper::addSubmenu('servicestats');
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
protected function addToolbar(): void
|
||||
{
|
||||
ToolbarHelper::title(
|
||||
'MokoSuiteCross — ' . $this->escape($this->service->title),
|
||||
'share-alt'
|
||||
);
|
||||
|
||||
$toolbar = Toolbar::getInstance('toolbar');
|
||||
$toolbar->appendButton(
|
||||
'Link',
|
||||
'home',
|
||||
'COM_MOKOSUITECROSS_SUBMENU_DASHBOARD',
|
||||
Route::_('index.php?option=com_mokosuitecross&view=dashboard', false)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,289 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Helper\ServiceIconHelper;
|
||||
|
||||
/** @var \Joomla\Component\MokoSuiteCross\Administrator\View\Dashboard\HtmlView $this */
|
||||
$stats = $this->stats;
|
||||
$componentParams = ComponentHelper::getParams('com_mokosuitecross');
|
||||
$queueProcessing = $componentParams->get('queue_processing', 'scheduler');
|
||||
?>
|
||||
<?php if ($queueProcessing === 'pageload' || $queueProcessing === 'both') : ?>
|
||||
<div class="alert alert-warning d-flex align-items-start mb-3">
|
||||
<span class="icon-exclamation-triangle me-2 mt-1" aria-hidden="true"></span>
|
||||
<div>
|
||||
<strong><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_PAGELOAD_WARNING_TITLE'); ?></strong><br>
|
||||
<?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_PAGELOAD_WARNING'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($stats->queued_count > 50) : ?>
|
||||
<div class="alert alert-warning d-flex align-items-start mb-3">
|
||||
<span class="icon-exclamation-triangle me-2 mt-1" aria-hidden="true"></span>
|
||||
<div>
|
||||
<strong><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_QUEUE_DEPTH_WARNING_TITLE'); ?></strong><br>
|
||||
<?php echo Text::sprintf('COM_MOKOSUITECROSS_DASHBOARD_QUEUE_DEPTH_WARNING', $stats->queued_count); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-9">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_ACTIVE_SERVICES'); ?></h5>
|
||||
<p class="display-4"><?php echo $stats->active_services; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_QUEUED'); ?></h5>
|
||||
<p class="display-4 text-warning"><?php echo $stats->queued_count; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_POSTED'); ?></h5>
|
||||
<p class="display-4 text-success"><?php echo $stats->posted_count; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_FAILED'); ?></h5>
|
||||
<p class="display-4 text-danger"><?php echo $stats->failed_count; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Trend Chart -->
|
||||
<?php if (!empty($this->dailyTrend)) : ?>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_TREND_CHART'); ?></h5>
|
||||
<form method="get" class="d-inline">
|
||||
<input type="hidden" name="option" value="com_mokosuitecross" />
|
||||
<input type="hidden" name="view" value="dashboard" />
|
||||
<select name="period" class="form-select form-select-sm" style="width: auto; display: inline-block;" onchange="this.form.submit();">
|
||||
<option value="7" <?php echo $this->period == 7 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_7_DAYS'); ?></option>
|
||||
<option value="30" <?php echo $this->period == 30 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_30_DAYS'); ?></option>
|
||||
<option value="90" <?php echo $this->period == 90 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_90_DAYS'); ?></option>
|
||||
<option value="0" <?php echo $this->period == 0 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_ALL_TIME'); ?></option>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<canvas id="trendChart" height="80"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js" integrity="sha384-UPIssOjNMqMfON6mDKHvO4sOY4hhxN1ymYcfl2MrDz69idMU/L3MNFlyJGlIRjQH" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var trendData = <?php echo json_encode($this->dailyTrend); ?>;
|
||||
var labels = trendData.map(function(d) { return d.day; });
|
||||
var posted = trendData.map(function(d) { return parseInt(d.posted, 10); });
|
||||
var failed = trendData.map(function(d) { return parseInt(d.failed, 10); });
|
||||
|
||||
new Chart(document.getElementById('trendChart'), {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: '<?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_POSTED', true); ?>',
|
||||
data: posted,
|
||||
borderColor: '#198754',
|
||||
backgroundColor: 'rgba(25, 135, 84, 0.1)',
|
||||
fill: true,
|
||||
tension: 0.3
|
||||
},
|
||||
{
|
||||
label: '<?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_FAILED', true); ?>',
|
||||
data: failed,
|
||||
borderColor: '#dc3545',
|
||||
backgroundColor: 'rgba(220, 53, 69, 0.1)',
|
||||
fill: true,
|
||||
tension: 0.3
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
scales: {
|
||||
y: { beginAtZero: true, ticks: { stepSize: 1 } }
|
||||
},
|
||||
plugins: {
|
||||
legend: { position: 'bottom' }
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->migrationAvailable) : ?>
|
||||
<div class="alert alert-info">
|
||||
<h4 class="alert-heading"><?php echo Text::_('COM_MOKOSUITECROSS_MIGRATION_TITLE'); ?></h4>
|
||||
<p><?php echo Text::_('COM_MOKOSUITECROSS_MIGRATION_DESCRIPTION'); ?></p>
|
||||
<a href="<?php echo Route::_('index.php?option=com_mokosuitecross&task=dashboard.migrate&' . \Joomla\CMS\Session\Session::getFormToken() . '=1'); ?>"
|
||||
class="btn btn-primary">
|
||||
<?php echo Text::_('COM_MOKOSUITECROSS_MIGRATION_BUTTON'); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Analytics: Service Breakdown -->
|
||||
<?php if (!empty($this->serviceBreakdown)) : ?>
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_SERVICE_BREAKDOWN'); ?></h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-sm table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo Text::_('COM_MOKOSUITECROSS_HEADING_SERVICE'); ?></th>
|
||||
<th class="text-center text-success"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_POSTED'); ?></th>
|
||||
<th class="text-center text-danger"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_FAILED'); ?></th>
|
||||
<th class="text-center text-warning"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_QUEUED'); ?></th>
|
||||
<th class="text-center"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_TOTAL_POSTS'); ?></th>
|
||||
<th class="text-center"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_SUCCESS_RATE'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->serviceBreakdown as $row) :
|
||||
$rate = $row['total'] > 0 ? round(($row['posted'] / $row['total']) * 100) : 0;
|
||||
$rateClass = $rate >= 80 ? 'text-success' : ($rate >= 50 ? 'text-warning' : 'text-danger');
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo ServiceIconHelper::renderIcon($row['service_type']); ?>
|
||||
<a href="<?php echo Route::_('index.php?option=com_mokosuitecross&view=servicestats&id=' . $row['service_id']); ?>">
|
||||
<?php echo htmlspecialchars($row['service_title'] . ' (' . ucfirst($row['service_type']) . ')'); ?>
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-center"><span class="badge bg-success"><?php echo (int) $row['posted']; ?></span></td>
|
||||
<td class="text-center"><span class="badge bg-danger"><?php echo (int) $row['failed']; ?></span></td>
|
||||
<td class="text-center"><span class="badge bg-warning text-dark"><?php echo (int) $row['queued']; ?></span></td>
|
||||
<td class="text-center"><?php echo (int) $row['total']; ?></td>
|
||||
<td class="text-center <?php echo $rateClass; ?> fw-bold"><?php echo $rate; ?>%</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Analytics: Top Articles -->
|
||||
<?php if (!empty($this->topArticles)) : ?>
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_TOP_ARTICLES'); ?></h5>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach ($this->topArticles as $row) : ?>
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span><?php echo htmlspecialchars($row['title']); ?></span>
|
||||
<span>
|
||||
<span class="badge bg-success"><?php echo (int) $row['success_count']; ?></span>
|
||||
/
|
||||
<span class="badge bg-secondary"><?php echo (int) $row['post_count']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Recent Activity -->
|
||||
<div class="card mt-3">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_RECENT_ACTIVITY'); ?></h5>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<?php if (empty($this->recentActivity)) : ?>
|
||||
<p class="p-3 mb-0 text-muted"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_NO_RECENT'); ?></p>
|
||||
<?php else : ?>
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach ($this->recentActivity as $entry) :
|
||||
$levelClass = match ($entry->level) {
|
||||
'error' => 'text-danger',
|
||||
'warning' => 'text-warning',
|
||||
default => 'text-muted',
|
||||
};
|
||||
$levelIcon = match ($entry->level) {
|
||||
'error' => 'icon-times-circle',
|
||||
'warning' => 'icon-exclamation-triangle',
|
||||
default => 'icon-info-circle',
|
||||
};
|
||||
?>
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<span class="<?php echo $levelClass; ?>">
|
||||
<span class="<?php echo $levelIcon; ?>" aria-hidden="true"></span>
|
||||
<?php echo htmlspecialchars(mb_substr($entry->message, 0, 120)); ?>
|
||||
</span>
|
||||
<small class="text-muted"><?php echo \Joomla\CMS\HTML\HTMLHelper::_('date', $entry->created, 'Y-m-d H:i'); ?></small>
|
||||
</div>
|
||||
<?php if ($entry->service_title) : ?>
|
||||
<small class="text-muted"><?php echo htmlspecialchars($entry->service_title); ?></small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_QUICK_LINKS'); ?></h5>
|
||||
<div class="list-group list-group-flush">
|
||||
<a href="<?php echo Route::_('index.php?option=com_mokosuitecross&view=services'); ?>"
|
||||
class="list-group-item list-group-item-action">
|
||||
<?php echo Text::_('COM_MOKOSUITECROSS_SUBMENU_SERVICES'); ?>
|
||||
</a>
|
||||
<a href="<?php echo Route::_('index.php?option=com_mokosuitecross&view=posts'); ?>"
|
||||
class="list-group-item list-group-item-action">
|
||||
<?php echo Text::_('COM_MOKOSUITECROSS_SUBMENU_POSTS'); ?>
|
||||
</a>
|
||||
<a href="<?php echo Route::_('index.php?option=com_mokosuitecross&view=templates'); ?>"
|
||||
class="list-group-item list-group-item-action">
|
||||
<?php echo Text::_('COM_MOKOSUITECROSS_SUBMENU_TEMPLATES'); ?>
|
||||
</a>
|
||||
<a href="<?php echo Route::_('index.php?option=com_mokosuitecross&view=logs'); ?>"
|
||||
class="list-group-item list-group-item-action">
|
||||
<?php echo Text::_('COM_MOKOSUITECROSS_SUBMENU_LOGS'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,219 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Helper\ServiceIconHelper;
|
||||
|
||||
/** @var \Joomla\Component\MokoSuiteCross\Administrator\View\ServiceStats\HtmlView $this */
|
||||
|
||||
$service = $this->service;
|
||||
$stats = $this->postStats;
|
||||
$rate = $stats->total > 0 ? round(($stats->posted / $stats->total) * 100) : 0;
|
||||
$rateClass = $rate >= 80 ? 'text-success' : ($rate >= 50 ? 'text-warning' : 'text-danger');
|
||||
|
||||
$statusBadges = [
|
||||
'queued' => 'bg-warning text-dark',
|
||||
'posting' => 'bg-info',
|
||||
'posted' => 'bg-success',
|
||||
'failed' => 'bg-danger',
|
||||
'scheduled' => 'bg-secondary',
|
||||
];
|
||||
?>
|
||||
|
||||
<!-- Service Header -->
|
||||
<div class="d-flex align-items-center mb-4">
|
||||
<?php echo ServiceIconHelper::renderIcon($service->service_type, 'fs-3 me-2'); ?>
|
||||
<h2 class="mb-0"><?php echo $this->escape($service->title); ?></h2>
|
||||
<span class="badge bg-secondary ms-2"><?php echo $this->escape(ucfirst($service->service_type)); ?></span>
|
||||
</div>
|
||||
|
||||
<!-- Stats Cards -->
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_TOTAL_POSTS'); ?></h5>
|
||||
<p class="display-4"><?php echo $stats->total; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_POSTED'); ?></h5>
|
||||
<p class="display-4 text-success"><?php echo $stats->posted; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_FAILED'); ?></h5>
|
||||
<p class="display-4 text-danger"><?php echo $stats->failed; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="card text-center mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_SUCCESS_RATE'); ?></h5>
|
||||
<p class="display-4 <?php echo $rateClass; ?>"><?php echo $rate; ?>%</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Daily Trend Chart -->
|
||||
<?php if (!empty($this->dailyTrend)) : ?>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header d-flex justify-content-between align-items-center">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_TREND_CHART'); ?></h5>
|
||||
<form method="get" class="d-inline">
|
||||
<input type="hidden" name="option" value="com_mokosuitecross" />
|
||||
<input type="hidden" name="view" value="servicestats" />
|
||||
<input type="hidden" name="id" value="<?php echo (int) $service->id; ?>" />
|
||||
<select name="period" class="form-select form-select-sm" style="width: auto; display: inline-block;" onchange="this.form.submit();">
|
||||
<option value="7" <?php echo $this->period == 7 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_7_DAYS'); ?></option>
|
||||
<option value="30" <?php echo $this->period == 30 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_30_DAYS'); ?></option>
|
||||
<option value="90" <?php echo $this->period == 90 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_90_DAYS'); ?></option>
|
||||
<option value="0" <?php echo $this->period == 0 ? 'selected' : ''; ?>><?php echo Text::_('COM_MOKOSUITECROSS_PERIOD_ALL_TIME'); ?></option>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<canvas id="serviceStatsChart" height="80"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.7/dist/chart.umd.min.js" integrity="sha384-UPIssOjNMqMfON6mDKHvO4sOY4hhxN1ymYcfl2MrDz69idMU/L3MNFlyJGlIRjQH" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var trendData = <?php echo json_encode($this->dailyTrend); ?>;
|
||||
var labels = trendData.map(function(d) { return d.day; });
|
||||
var posted = trendData.map(function(d) { return parseInt(d.posted, 10); });
|
||||
var failed = trendData.map(function(d) { return parseInt(d.failed, 10); });
|
||||
|
||||
new Chart(document.getElementById('serviceStatsChart'), {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: '<?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_POSTED', true); ?>',
|
||||
data: posted,
|
||||
borderColor: '#198754',
|
||||
backgroundColor: 'rgba(25, 135, 84, 0.1)',
|
||||
fill: true,
|
||||
tension: 0.3
|
||||
},
|
||||
{
|
||||
label: '<?php echo Text::_('COM_MOKOSUITECROSS_DASHBOARD_FAILED', true); ?>',
|
||||
data: failed,
|
||||
borderColor: '#dc3545',
|
||||
backgroundColor: 'rgba(220, 53, 69, 0.1)',
|
||||
fill: true,
|
||||
tension: 0.3
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
scales: {
|
||||
y: { beginAtZero: true, ticks: { stepSize: 1 } }
|
||||
},
|
||||
plugins: {
|
||||
legend: { position: 'bottom' }
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Recent Posts -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_SERVICESTATS_RECENT_POSTS'); ?></h5>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<?php if (empty($this->recentPosts)) : ?>
|
||||
<p class="p-3 mb-0 text-muted"><?php echo Text::_('COM_MOKOSUITECROSS_SERVICESTATS_NO_POSTS'); ?></p>
|
||||
<?php else : ?>
|
||||
<table class="table table-sm table-striped mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php echo Text::_('COM_MOKOSUITECROSS_HEADING_STATUS'); ?></th>
|
||||
<th><?php echo Text::_('COM_MOKOSUITECROSS_HEADING_ARTICLE'); ?></th>
|
||||
<th><?php echo Text::_('COM_MOKOSUITECROSS_HEADING_POSTED_AT'); ?></th>
|
||||
<th><?php echo Text::_('COM_MOKOSUITECROSS_POST_ERROR'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->recentPosts as $post) :
|
||||
$badgeClass = $statusBadges[$post['status']] ?? 'bg-secondary';
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="badge <?php echo $badgeClass; ?>">
|
||||
<?php echo $this->escape(ucfirst($post['status'])); ?>
|
||||
</span>
|
||||
<?php if ((int) $post['retry_count'] > 0) : ?>
|
||||
<br><small class="text-muted">Retries: <?php echo (int) $post['retry_count']; ?></small>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?php echo Route::_('index.php?option=com_mokosuitecross&task=post.edit&id=' . (int) $post['id']); ?>">
|
||||
<?php echo $this->escape($post['article_title'] ?? 'Article #' . $post['id']); ?>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $post['posted_at'] ? HTMLHelper::_('date', $post['posted_at'], 'Y-m-d H:i') : '—'; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (!empty($post['error_message'])) : ?>
|
||||
<small class="text-danger"><?php echo $this->escape(mb_substr($post['error_message'], 0, 100)); ?></small>
|
||||
<?php else : ?>
|
||||
—
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Top Articles -->
|
||||
<?php if (!empty($this->topArticles)) : ?>
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_SERVICESTATS_TOP_ARTICLES'); ?></h5>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="list-group list-group-flush">
|
||||
<?php foreach ($this->topArticles as $row) : ?>
|
||||
<div class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<span><?php echo htmlspecialchars($row['title']); ?></span>
|
||||
<span>
|
||||
<span class="badge bg-success"><?php echo (int) $row['success_count']; ?></span>
|
||||
/
|
||||
<span class="badge bg-secondary"><?php echo (int) $row['post_count']; ?></span>
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage com_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
/** @var \Joomla\Component\MokoSuiteCross\Administrator\View\Template\HtmlView $this */
|
||||
|
||||
HTMLHelper::_('behavior.formvalidator');
|
||||
HTMLHelper::_('behavior.keepalive');
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_mokosuitecross&layout=edit&id=' . (int) ($this->item->id ?? 0)); ?>"
|
||||
method="post" name="adminForm" id="adminForm" class="form-validate">
|
||||
|
||||
<div class="main-card">
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<?php echo $this->form->renderFieldset('details'); ?>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title mb-0"><?php echo Text::_('COM_MOKOSUITECROSS_TEMPLATE_PLACEHOLDERS'); ?></h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-sm table-striped">
|
||||
<tbody>
|
||||
<tr><td><code>{title}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_TITLE'); ?></td></tr>
|
||||
<tr><td><code>{url}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_URL'); ?></td></tr>
|
||||
<tr><td><code>{introtext}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_INTROTEXT'); ?></td></tr>
|
||||
<tr><td><code>{fulltext}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_FULLTEXT'); ?></td></tr>
|
||||
<tr><td><code>{image}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_IMAGE'); ?></td></tr>
|
||||
<tr><td><code>{category}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_CATEGORY'); ?></td></tr>
|
||||
<tr><td><code>{author}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_AUTHOR'); ?></td></tr>
|
||||
<tr><td><code>{date}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_DATE'); ?></td></tr>
|
||||
<tr><td><code>{tags}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_TAGS'); ?></td></tr>
|
||||
<tr><td><code>{hashtags}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_HASHTAGS'); ?></td></tr>
|
||||
<tr><td><code>{field:xxx}</code></td><td><?php echo Text::_('COM_MOKOSUITECROSS_PLACEHOLDER_CUSTOM_FIELD'); ?></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="task" value="">
|
||||
<?php echo HTMLHelper::_('form.token'); ?>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const platformLimits = {
|
||||
twitter: 280, bluesky: 300, mastodon: 500, threads: 500,
|
||||
telegram: 4096, discord: 2000, whatsapp: 4096,
|
||||
linkedin: 3000, googlebusiness: 1500, matrix: 65536,
|
||||
ntfy: 4096, facebook: 0, medium: 0, wordpress: 0,
|
||||
ghost: 0, hashnode: 0, blogger: 0, devto: 0,
|
||||
default: 0
|
||||
};
|
||||
|
||||
const textarea = document.getElementById('jform_template_body');
|
||||
const serviceSelect = document.getElementById('jform_service_type');
|
||||
|
||||
if (!textarea) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create counter element
|
||||
const counter = document.createElement('div');
|
||||
counter.id = 'mokosuitecross-char-counter';
|
||||
counter.className = 'small mt-1';
|
||||
textarea.parentNode.appendChild(counter);
|
||||
|
||||
function updateCounter() {
|
||||
const len = textarea.value.length;
|
||||
const serviceType = serviceSelect ? serviceSelect.value : 'default';
|
||||
const limit = platformLimits[serviceType] || 0;
|
||||
|
||||
if (limit > 0) {
|
||||
const ratio = len / limit;
|
||||
let badgeClass = 'bg-success';
|
||||
if (ratio > 1) {
|
||||
badgeClass = 'bg-danger';
|
||||
} else if (ratio > 0.9) {
|
||||
badgeClass = 'bg-warning text-dark';
|
||||
}
|
||||
counter.innerHTML = '<span class="badge ' + badgeClass + '">Characters: ' + len + ' / ' + limit + '</span>';
|
||||
} else {
|
||||
counter.innerHTML = '<span class="badge bg-secondary">Characters: ' + len + ' (no limit)</span>';
|
||||
}
|
||||
}
|
||||
|
||||
textarea.addEventListener('input', updateCounter);
|
||||
|
||||
if (serviceSelect) {
|
||||
serviceSelect.addEventListener('change', updateCounter);
|
||||
}
|
||||
|
||||
// Initial count
|
||||
updateCounter();
|
||||
});
|
||||
</script>
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
PLG_CONTENT_MOKOSUITECROSS="Content - MokoSuiteCross"
|
||||
PLG_CONTENT_MOKOSUITECROSS_DESCRIPTION="Adds cross-post status badges and per-article service selection to the article editor."
|
||||
|
||||
PLG_CONTENT_MOKOSUITECROSS_FIELDSET_CROSSPOST="Cross-Posting"
|
||||
PLG_CONTENT_MOKOSUITECROSS_SKIP="Skip Cross-Posting"
|
||||
PLG_CONTENT_MOKOSUITECROSS_SKIP_DESC="Skip all cross-posting for this article."
|
||||
PLG_CONTENT_MOKOSUITECROSS_SERVICES="Post to Services"
|
||||
PLG_CONTENT_MOKOSUITECROSS_SERVICES_DESC="Select which services to cross-post to. Leave all unchecked to post to all enabled services."
|
||||
PLG_CONTENT_MOKOSUITECROSS_EVERGREEN="Evergreen Content"
|
||||
PLG_CONTENT_MOKOSUITECROSS_EVERGREEN_DESC="Automatically re-share this article on a recurring schedule. Great for high-value content that stays relevant."
|
||||
PLG_CONTENT_MOKOSUITECROSS_EVERGREEN_INTERVAL="Re-share Interval (days)"
|
||||
PLG_CONTENT_MOKOSUITECROSS_EVERGREEN_INTERVAL_DESC="How many days to wait between automatic re-shares. Default: 30 days."
|
||||
PLG_CONTENT_MOKOSUITECROSS_HISTORY="Cross-Post History"
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_CONTENT_MOKOSUITECROSS="Content - MokoSuiteCross"
|
||||
PLG_CONTENT_MOKOSUITECROSS_DESCRIPTION="Adds cross-post status badges to articles in the admin backend."
|
||||
@@ -1,361 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage plg_content_mokosuitecross
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\Content\MokoSuiteCross\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Event\Model\PrepareFormEvent;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Helper\CrossPostDispatcher;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
/**
|
||||
* Content plugin that:
|
||||
* 1. Adds cross-post status badges to article views in admin
|
||||
* 2. Injects service selection checkboxes into the article editor (#19)
|
||||
*/
|
||||
class MokoSuiteCrossContent extends CMSPlugin implements SubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
'onContentBeforeDisplay' => 'onContentBeforeDisplay',
|
||||
'onContentPrepareForm' => 'onContentPrepareForm',
|
||||
'onContentAfterSave' => 'onContentAfterSave',
|
||||
'onContentChangeState' => 'onContentChangeState',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject cross-post service selection fields into article edit form.
|
||||
*
|
||||
* Adds a "Cross-Posting" fieldset to the article attribs tab with:
|
||||
* - Checkbox list of all enabled services
|
||||
* - Skip cross-posting toggle
|
||||
*/
|
||||
/**
|
||||
* Joomla 5/6 compatible — accepts both PrepareFormEvent and legacy Form signature.
|
||||
*/
|
||||
public function onContentPrepareForm($event): void
|
||||
{
|
||||
// Joomla 5+ passes PrepareFormEvent; extract the Form from it
|
||||
if ($event instanceof PrepareFormEvent) {
|
||||
$form = $event->getForm();
|
||||
} elseif ($event instanceof Form) {
|
||||
$form = $event;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($form->getName() !== 'com_content.article') {
|
||||
return;
|
||||
}
|
||||
|
||||
$app = $this->getApplication();
|
||||
|
||||
if (!$app->isClient('administrator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Load enabled services for the checkbox list
|
||||
$query = $db->getQuery(true)
|
||||
->select('id, title, service_type')
|
||||
->from($db->quoteName('#__mokosuitecross_services'))
|
||||
->where($db->quoteName('published') . ' = 1')
|
||||
->order($db->quoteName('ordering') . ' ASC');
|
||||
|
||||
$db->setQuery($query);
|
||||
$services = $db->loadObjectList();
|
||||
|
||||
if (empty($services)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Build dynamic XML form for the attribs fieldset
|
||||
$options = '';
|
||||
|
||||
foreach ($services as $svc) {
|
||||
$label = htmlspecialchars($svc->title . ' (' . ucfirst($svc->service_type) . ')', ENT_XML1);
|
||||
$options .= '<option value="' . (int) $svc->id . '">' . $label . '</option>';
|
||||
}
|
||||
|
||||
$xml = <<<XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form>
|
||||
<fields name="attribs">
|
||||
<fieldset name="mokosuitecross" label="PLG_CONTENT_MOKOSUITECROSS_FIELDSET_CROSSPOST">
|
||||
<field
|
||||
name="mokosuitecross_skip"
|
||||
type="radio"
|
||||
label="PLG_CONTENT_MOKOSUITECROSS_SKIP"
|
||||
description="PLG_CONTENT_MOKOSUITECROSS_SKIP_DESC"
|
||||
default="0"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field
|
||||
name="mokosuitecross_services"
|
||||
type="checkboxes"
|
||||
label="PLG_CONTENT_MOKOSUITECROSS_SERVICES"
|
||||
description="PLG_CONTENT_MOKOSUITECROSS_SERVICES_DESC"
|
||||
showon="mokosuitecross_skip:0">
|
||||
{$options}
|
||||
</field>
|
||||
<field
|
||||
name="mokosuitecross_evergreen"
|
||||
type="radio"
|
||||
label="PLG_CONTENT_MOKOSUITECROSS_EVERGREEN"
|
||||
description="PLG_CONTENT_MOKOSUITECROSS_EVERGREEN_DESC"
|
||||
default="0"
|
||||
class="btn-group btn-group-yesno"
|
||||
showon="mokosuitecross_skip:0">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field
|
||||
name="mokosuitecross_evergreen_interval"
|
||||
type="number"
|
||||
label="PLG_CONTENT_MOKOSUITECROSS_EVERGREEN_INTERVAL"
|
||||
description="PLG_CONTENT_MOKOSUITECROSS_EVERGREEN_INTERVAL_DESC"
|
||||
default="30"
|
||||
min="1"
|
||||
max="365"
|
||||
showon="mokosuitecross_skip:0[AND]mokosuitecross_evergreen:1"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</form>
|
||||
XML;
|
||||
|
||||
$form->load($xml);
|
||||
|
||||
// Cross-post history panel for existing articles
|
||||
$articleId = Factory::getApplication()->input->getInt('id', 0);
|
||||
|
||||
if ($articleId > 0) {
|
||||
$query = $db->getQuery(true)
|
||||
->select('p.status, p.posted_at, p.error_message, s.title AS service_title, s.service_type')
|
||||
->from($db->quoteName('#__mokosuitecross_posts', 'p'))
|
||||
->join('LEFT', $db->quoteName('#__mokosuitecross_services', 's') . ' ON s.id = p.service_id')
|
||||
->where($db->quoteName('p.article_id') . ' = ' . $articleId)
|
||||
->order('p.created DESC');
|
||||
$db->setQuery($query, 0, 10);
|
||||
$history = $db->loadObjectList();
|
||||
|
||||
if (!empty($history)) {
|
||||
$historyHtml = '<div class="mokosuitecross-history">';
|
||||
|
||||
foreach ($history as $post) {
|
||||
$badgeClass = match ($post->status) {
|
||||
'posted' => 'bg-success',
|
||||
'failed' => 'bg-danger',
|
||||
'queued' => 'bg-warning',
|
||||
default => 'bg-secondary',
|
||||
};
|
||||
$historyHtml .= '<div class="mb-1">'
|
||||
. '<span class="badge ' . $badgeClass . ' me-1">' . ucfirst($post->status) . '</span>'
|
||||
. '<small>' . htmlspecialchars($post->service_title ?? '') . '</small>';
|
||||
|
||||
if ($post->posted_at) {
|
||||
$historyHtml .= ' <small class="text-muted">' . HTMLHelper::_('date', $post->posted_at, 'Y-m-d H:i') . '</small>';
|
||||
}
|
||||
|
||||
if ($post->status === 'failed' && $post->error_message) {
|
||||
$historyHtml .= '<br><small class="text-danger">' . htmlspecialchars(mb_substr($post->error_message, 0, 60)) . '</small>';
|
||||
}
|
||||
|
||||
$historyHtml .= '</div>';
|
||||
}
|
||||
|
||||
$historyHtml .= '</div>';
|
||||
|
||||
// Add the note field first with an empty description, then set the
|
||||
// description via setFieldAttribute() to avoid double-escaping.
|
||||
// Putting raw HTML into an XML attribute via htmlspecialchars() causes
|
||||
// Joomla's note field renderer to display escaped tags since it outputs
|
||||
// the description as raw HTML.
|
||||
$historyXml = '<?xml version="1.0"?>
|
||||
<form><fields name="attribs"><fieldset name="mokosuitecross">
|
||||
<field name="mokosuitecross_history" type="note"
|
||||
label="PLG_CONTENT_MOKOSUITECROSS_HISTORY"
|
||||
description="" />
|
||||
</fieldset></fields></form>';
|
||||
$form->load($historyXml);
|
||||
$form->setFieldAttribute('mokosuitecross_history', 'description', $historyHtml, 'attribs');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add cross-post status badges before article content in admin.
|
||||
*
|
||||
* Joomla 5/6 compatible — accepts both BeforeDisplayEvent and legacy parameters.
|
||||
*/
|
||||
public function onContentBeforeDisplay($event): string
|
||||
{
|
||||
// Joomla 5/6 compatibility
|
||||
if ($event instanceof \Joomla\CMS\Event\Content\BeforeDisplayEvent) {
|
||||
$context = $event->getContext();
|
||||
$article = $event->getItem();
|
||||
} elseif (is_string($event)) {
|
||||
$context = $event;
|
||||
$article = func_get_arg(1);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($context !== 'com_content.article') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$app = $this->getApplication();
|
||||
|
||||
if (!$app->isClient('administrator')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select('p.status, s.service_type')
|
||||
->from($db->quoteName('#__mokosuitecross_posts', 'p'))
|
||||
->join('LEFT', $db->quoteName('#__mokosuitecross_services', 's')
|
||||
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('p.service_id'))
|
||||
->where($db->quoteName('p.article_id') . ' = ' . (int) $article->id)
|
||||
->order($db->quoteName('p.created') . ' DESC');
|
||||
|
||||
$db->setQuery($query, 0, 10);
|
||||
$posts = $db->loadObjectList();
|
||||
|
||||
if (empty($posts)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$badges = '';
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$class = match ($post->status) {
|
||||
'posted' => 'badge bg-success',
|
||||
'failed' => 'badge bg-danger',
|
||||
'queued' => 'badge bg-warning',
|
||||
default => 'badge bg-secondary',
|
||||
};
|
||||
$badges .= '<span class="' . $class . ' me-1">' . htmlspecialchars($post->service_type) . '</span>';
|
||||
}
|
||||
|
||||
return '<div class="mokosuitecross-status mb-2">' . $badges . '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch cross-post when an article is saved and published.
|
||||
*
|
||||
* Joomla 5/6 compatible — accepts both AfterSaveEvent and legacy parameters.
|
||||
*/
|
||||
public function onContentAfterSave($event): void
|
||||
{
|
||||
// Joomla 5/6 compatibility
|
||||
if ($event instanceof \Joomla\CMS\Event\Content\AfterSaveEvent) {
|
||||
$context = $event->getContext();
|
||||
$article = $event->getItem();
|
||||
$isNew = $event->getIsNew();
|
||||
} else {
|
||||
$context = $event;
|
||||
$article = func_get_arg(1);
|
||||
$isNew = func_get_arg(2);
|
||||
}
|
||||
|
||||
if ($context !== 'com_content.article') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((int) ($article->state ?? 0) !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$params = ComponentHelper::getParams('com_mokosuitecross');
|
||||
|
||||
if (!$params->get('auto_post_on_publish', 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($params->get('post_on_first_publish_only', 0) && !$isNew) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id;
|
||||
|
||||
if (!empty($article->catid)) {
|
||||
$url .= '&catid=' . $article->catid;
|
||||
}
|
||||
|
||||
CrossPostDispatcher::dispatch($article, $url, 'com_content.article');
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch cross-post when article state changes to published.
|
||||
*
|
||||
* Joomla 5/6 compatible — accepts both ContentChangeStateEvent and legacy parameters.
|
||||
*/
|
||||
public function onContentChangeState($event): void
|
||||
{
|
||||
if ($event instanceof \Joomla\CMS\Event\Content\ContentChangeStateEvent) {
|
||||
$context = $event->getContext();
|
||||
$pks = $event->getPks();
|
||||
$value = $event->getValue();
|
||||
} else {
|
||||
$context = $event;
|
||||
$pks = func_get_arg(1);
|
||||
$value = func_get_arg(2);
|
||||
}
|
||||
|
||||
if ($context !== 'com_content.article' || $value !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$params = ComponentHelper::getParams('com_mokosuitecross');
|
||||
|
||||
if (!$params->get('auto_post_on_publish', 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db = Factory::getDbo();
|
||||
|
||||
foreach ($pks as $pk) {
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from('#__content')
|
||||
->where('id = ' . (int) $pk);
|
||||
$db->setQuery($query);
|
||||
$article = $db->loadObject();
|
||||
|
||||
if (!$article) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$url = Uri::root() . 'index.php?option=com_content&view=article&id=' . $article->id;
|
||||
|
||||
if (!empty($article->catid)) {
|
||||
$url .= '&catid=' . $article->catid;
|
||||
}
|
||||
|
||||
CrossPostDispatcher::dispatch($article, $url, 'com_content.article');
|
||||
}
|
||||
}
|
||||
}
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_ACTIVITYPUB="MokoSuiteCross - ActivityPub (Fediverse)"
|
||||
PLG_MOKOSUITECROSS_ACTIVITYPUB_DESCRIPTION="Cross-post Joomla articles to ActivityPub (Fediverse)."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_ACTIVITYPUB="MokoSuiteCross - ActivityPub (Fediverse)"
|
||||
PLG_MOKOSUITECROSS_ACTIVITYPUB_DESCRIPTION="Cross-post Joomla articles to ActivityPub (Fediverse)."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_BLOGGER="MokoSuiteCross - Google Blogger"
|
||||
PLG_MOKOSUITECROSS_BLOGGER_DESCRIPTION="Cross-post Joomla articles to Google Blogger."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_BLOGGER="MokoSuiteCross - Google Blogger"
|
||||
PLG_MOKOSUITECROSS_BLOGGER_DESCRIPTION="Cross-post Joomla articles to Google Blogger."
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_BLUESKY="MokoSuiteCross - Bluesky"
|
||||
PLG_MOKOSUITECROSS_BLUESKY_DESCRIPTION="Cross-post Joomla articles to Bluesky."
|
||||
PLG_MOKOSUITECROSS_BLUESKY_FIELDSET_DEFAULTS="Bluesky Defaults"
|
||||
PLG_MOKOSUITECROSS_BLUESKY_DEFAULT_PDS_URL="Default PDS URL"
|
||||
PLG_MOKOSUITECROSS_BLUESKY_DEFAULT_PDS_URL_DESC="Default Bluesky PDS URL (e.g. https://bsky.social)."
|
||||
PLG_MOKOSUITECROSS_BLUESKY_AUTO_LINK_CARD="Auto Link Card"
|
||||
PLG_MOKOSUITECROSS_BLUESKY_AUTO_LINK_CARD_DESC="Automatically detect URLs and create link cards in posts."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_BLUESKY="MokoSuiteCross - Bluesky"
|
||||
PLG_MOKOSUITECROSS_BLUESKY_DESCRIPTION="Cross-post Joomla articles to Bluesky."
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_BREVO="MokoSuiteCross - Brevo (Sendinblue)"
|
||||
PLG_MOKOSUITECROSS_BREVO_DESCRIPTION="Cross-post Joomla articles to Brevo (Sendinblue)."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_BREVO="MokoSuiteCross - Brevo (Sendinblue)"
|
||||
PLG_MOKOSUITECROSS_BREVO_DESCRIPTION="Cross-post Joomla articles to Brevo (Sendinblue)."
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage plg_mokosuitecross_brevo
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\MokoSuiteCross\Brevo\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
/**
|
||||
* Brevo (Sendinblue) service plugin for MokoSuiteCross.
|
||||
*
|
||||
* API: https://api.brevo.com/v3/emailCampaigns
|
||||
*/
|
||||
class BrevoService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
||||
{
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
||||
}
|
||||
|
||||
public function onMokoSuiteCrossGetServices(&$services): void
|
||||
{
|
||||
$services[] = $this;
|
||||
}
|
||||
|
||||
public function getServiceType(): string { return 'brevo'; }
|
||||
public function getServiceName(): string { return 'Brevo (Sendinblue)'; }
|
||||
public function getMaxLength(): int { return 0; }
|
||||
public function supportsMedia(): bool { return true; }
|
||||
|
||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
||||
{
|
||||
$apiKey = $credentials['api_key'] ?? '';
|
||||
$listId = (int) ($credentials['list_id'] ?? 0);
|
||||
$senderName = $credentials['sender_name'] ?? 'Newsletter';
|
||||
$senderEmail = $credentials['sender_email'] ?? '';
|
||||
|
||||
if (empty($apiKey) || empty($listId) || empty($senderEmail)) {
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing API key, list ID, or sender email']];
|
||||
}
|
||||
|
||||
$subject = $params['subject'] ?? mb_substr(strip_tags($message), 0, 150);
|
||||
|
||||
$postData = json_encode([
|
||||
'name' => $subject,
|
||||
'subject' => $subject,
|
||||
'sender' => ['name' => $senderName, 'email' => $senderEmail],
|
||||
'htmlContent' => $message,
|
||||
'recipients' => ['listIds' => [$listId]],
|
||||
]);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => 'https://api.brevo.com/v3/emailCampaigns',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $postData,
|
||||
CURLOPT_HTTPHEADER => ['api-key: ' . $apiKey, 'Content-Type: application/json'],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => 'https://api.brevo.com/v3/emailCampaigns',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $postData,
|
||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token, 'Content-Type: application/json'],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
|
||||
$curlError = curl_error($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
||||
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if ($httpCode >= 200 && $httpCode < 300) {
|
||||
return ['success' => true, 'platform_post_id' => $data['id'] ?? $data['uri'] ?? '', 'response' => $data];
|
||||
}
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
||||
}
|
||||
|
||||
public function validateCredentials(array $credentials): array
|
||||
{
|
||||
$key = $credentials['api_key'] ?? '';
|
||||
|
||||
if (empty($key)) {
|
||||
return ['valid' => false, 'message' => 'Missing API key', 'account_name' => ''];
|
||||
}
|
||||
|
||||
$ch = curl_init('https://api.brevo.com/v3/account');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_HTTPHEADER => ['api-key: ' . $key],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
if ($response === false) {
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
return ['valid' => false, 'message' => 'Connection error: ' . $curlError, 'account_name' => ''];
|
||||
}
|
||||
curl_close($ch);
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if (!empty($data['companyName'])) {
|
||||
return ['valid' => true, 'message' => 'Connected', 'account_name' => $data['companyName']];
|
||||
}
|
||||
|
||||
return ['valid' => false, 'message' => $data['message'] ?? 'Invalid API key', 'account_name' => ''];
|
||||
}
|
||||
|
||||
public function getSupportedMediaTypes(): array
|
||||
{
|
||||
return ['image'];
|
||||
}
|
||||
}
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_CONSTANTCONTACT="MokoSuiteCross - Constant Contact"
|
||||
PLG_MOKOSUITECROSS_CONSTANTCONTACT_DESCRIPTION="Cross-post Joomla articles to Constant Contact."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_CONSTANTCONTACT="MokoSuiteCross - Constant Contact"
|
||||
PLG_MOKOSUITECROSS_CONSTANTCONTACT_DESCRIPTION="Cross-post Joomla articles to Constant Contact."
|
||||
-142
@@ -1,142 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage plg_mokosuitecross_constantcontact
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\MokoSuiteCross\Constantcontact\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
/**
|
||||
* Constant Contact service plugin for MokoSuiteCross.
|
||||
*
|
||||
* API: https://api.cc.email/v3/emails
|
||||
*/
|
||||
class ConstantcontactService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
||||
{
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
||||
}
|
||||
|
||||
public function onMokoSuiteCrossGetServices(&$services): void
|
||||
{
|
||||
$services[] = $this;
|
||||
}
|
||||
|
||||
public function getServiceType(): string { return 'constantcontact'; }
|
||||
public function getServiceName(): string { return 'Constant Contact'; }
|
||||
public function getMaxLength(): int { return 0; }
|
||||
public function supportsMedia(): bool { return true; }
|
||||
|
||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
||||
{
|
||||
$token = $credentials['access_token'] ?? '';
|
||||
$listId = $credentials['list_id'] ?? '';
|
||||
$fromName = $credentials['from_name'] ?? 'Newsletter';
|
||||
$fromEmail = $credentials['from_email'] ?? '';
|
||||
|
||||
if (empty($token) || empty($fromEmail)) {
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing access token or sender email']];
|
||||
}
|
||||
|
||||
$subject = $params['subject'] ?? mb_substr(strip_tags($message), 0, 150);
|
||||
|
||||
$postData = json_encode([
|
||||
'name' => $subject,
|
||||
'email_campaign_activities' => [[
|
||||
'format_type' => 5,
|
||||
'from_name' => $fromName,
|
||||
'from_email' => $fromEmail,
|
||||
'subject' => $subject,
|
||||
'html_content' => $message,
|
||||
]],
|
||||
]);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => 'https://api.cc.email/v3/emails',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $postData,
|
||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token, 'Content-Type: application/json'],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => 'https://api.cc.email/v3/emails',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $postData,
|
||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token, 'Content-Type: application/json'],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
|
||||
$curlError = curl_error($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
||||
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if ($httpCode >= 200 && $httpCode < 300) {
|
||||
return ['success' => true, 'platform_post_id' => $data['id'] ?? $data['uri'] ?? '', 'response' => $data];
|
||||
}
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
||||
}
|
||||
|
||||
public function validateCredentials(array $credentials): array
|
||||
{
|
||||
$token = $credentials['access_token'] ?? '';
|
||||
|
||||
if (empty($token)) {
|
||||
return ['valid' => false, 'message' => 'Missing access token', 'account_name' => ''];
|
||||
}
|
||||
|
||||
$ch = curl_init('https://api.cc.email/v3/account/summary');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
if ($response === false) {
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
return ['valid' => false, 'message' => 'Connection error: ' . $curlError, 'account_name' => ''];
|
||||
}
|
||||
curl_close($ch);
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if (!empty($data['organization_name'])) {
|
||||
return ['valid' => true, 'message' => 'Connected', 'account_name' => $data['organization_name']];
|
||||
}
|
||||
|
||||
return ['valid' => false, 'message' => 'Invalid token', 'account_name' => ''];
|
||||
}
|
||||
|
||||
public function getSupportedMediaTypes(): array
|
||||
{
|
||||
return ['image'];
|
||||
}
|
||||
}
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_CONVERTKIT="MokoSuiteCross - ConvertKit"
|
||||
PLG_MOKOSUITECROSS_CONVERTKIT_DESCRIPTION="Cross-post Joomla articles to ConvertKit."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_CONVERTKIT="MokoSuiteCross - ConvertKit"
|
||||
PLG_MOKOSUITECROSS_CONVERTKIT_DESCRIPTION="Cross-post Joomla articles to ConvertKit."
|
||||
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage plg_mokosuitecross_convertkit
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\MokoSuiteCross\Convertkit\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
/**
|
||||
* ConvertKit service plugin for MokoSuiteCross.
|
||||
*
|
||||
* API: https://api.convertkit.com/v3/broadcasts
|
||||
*/
|
||||
class ConvertkitService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
||||
{
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
||||
}
|
||||
|
||||
public function onMokoSuiteCrossGetServices(&$services): void
|
||||
{
|
||||
$services[] = $this;
|
||||
}
|
||||
|
||||
public function getServiceType(): string { return 'convertkit'; }
|
||||
public function getServiceName(): string { return 'ConvertKit'; }
|
||||
public function getMaxLength(): int { return 0; }
|
||||
public function supportsMedia(): bool { return true; }
|
||||
|
||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
||||
{
|
||||
$apiSecret = $credentials['api_secret'] ?? '';
|
||||
|
||||
if (empty($apiSecret)) {
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing API secret']];
|
||||
}
|
||||
|
||||
$subject = $params['subject'] ?? mb_substr(strip_tags($message), 0, 150);
|
||||
|
||||
$postData = json_encode([
|
||||
'api_secret' => $apiSecret,
|
||||
'content' => $message,
|
||||
'subject' => $subject,
|
||||
'description' => mb_substr(strip_tags($message), 0, 200),
|
||||
]);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => 'https://api.convertkit.com/v3/broadcasts',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $postData,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => 'https://api.convertkit.com/v3/broadcasts',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $postData,
|
||||
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token, 'Content-Type: application/json'],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
|
||||
$curlError = curl_error($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
||||
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if ($httpCode >= 200 && $httpCode < 300) {
|
||||
return ['success' => true, 'platform_post_id' => $data['id'] ?? $data['uri'] ?? '', 'response' => $data];
|
||||
}
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
||||
}
|
||||
|
||||
public function validateCredentials(array $credentials): array
|
||||
{
|
||||
$apiSecret = $credentials['api_secret'] ?? '';
|
||||
|
||||
if (empty($apiSecret)) {
|
||||
return ['valid' => false, 'message' => 'Missing API secret', 'account_name' => ''];
|
||||
}
|
||||
|
||||
$ch = curl_init('https://api.convertkit.com/v3/account?api_secret=' . urlencode($apiSecret));
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
if ($response === false) {
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
return ['valid' => false, 'message' => 'Connection error: ' . $curlError, 'account_name' => ''];
|
||||
}
|
||||
curl_close($ch);
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if (!empty($data['name'])) {
|
||||
return ['valid' => true, 'message' => 'Connected', 'account_name' => $data['name']];
|
||||
}
|
||||
|
||||
return ['valid' => false, 'message' => 'Invalid API secret', 'account_name' => ''];
|
||||
}
|
||||
|
||||
public function getSupportedMediaTypes(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_DEVTO="MokoSuiteCross - Dev.to"
|
||||
PLG_MOKOSUITECROSS_DEVTO_DESCRIPTION="Cross-post Joomla articles to Dev.to."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_DEVTO="MokoSuiteCross - Dev.to"
|
||||
PLG_MOKOSUITECROSS_DEVTO_DESCRIPTION="Cross-post Joomla articles to Dev.to."
|
||||
@@ -1,134 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package MokoSuiteCross
|
||||
* @subpackage plg_mokosuitecross_devto
|
||||
* @author Moko Consulting <hello@mokoconsulting.tech>
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\MokoSuiteCross\Devto\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Component\MokoSuiteCross\Administrator\Service\MokoSuiteCrossServiceInterface;
|
||||
use Joomla\Event\SubscriberInterface;
|
||||
|
||||
/**
|
||||
* Dev.to service plugin for MokoSuiteCross.
|
||||
*
|
||||
* API: https://dev.to/api/articles
|
||||
*/
|
||||
class DevtoService extends CMSPlugin implements SubscriberInterface, MokoSuiteCrossServiceInterface
|
||||
{
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return ['onMokoSuiteCrossGetServices' => 'onMokoSuiteCrossGetServices'];
|
||||
}
|
||||
|
||||
public function onMokoSuiteCrossGetServices(&$services): void
|
||||
{
|
||||
$services[] = $this;
|
||||
}
|
||||
|
||||
public function getServiceType(): string { return 'devto'; }
|
||||
public function getServiceName(): string { return 'Dev.to'; }
|
||||
public function getMaxLength(): int { return 0; }
|
||||
public function supportsMedia(): bool { return true; }
|
||||
|
||||
public function publish(string $message, array $media, array $credentials, array $params): array
|
||||
{
|
||||
$token = $credentials['api_key'] ?? '';
|
||||
|
||||
if (empty($token)) {
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Missing API key']];
|
||||
}
|
||||
|
||||
$title = mb_substr(strip_tags($message), 0, 150);
|
||||
$body = $message;
|
||||
|
||||
// Prepend image in markdown if available
|
||||
if (!empty($media[0])) {
|
||||
$body = '\n\n" . $body;
|
||||
}
|
||||
|
||||
$postData = json_encode([
|
||||
'article' => [
|
||||
'title' => $title,
|
||||
'body_markdown' => $body,
|
||||
'published' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => 'https://dev.to/api/articles',
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $postData,
|
||||
CURLOPT_HTTPHEADER => ['api-key: ' . $token, 'Content-Type: application/json'],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if ($response === false) {
|
||||
|
||||
$curlError = curl_error($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => ['error' => 'Connection error: ' . $curlError]];
|
||||
|
||||
}
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if ($httpCode >= 200 && $httpCode < 300) {
|
||||
return ['success' => true, 'platform_post_id' => $data['id'] ?? $data['uri'] ?? '', 'response' => $data];
|
||||
}
|
||||
|
||||
return ['success' => false, 'platform_post_id' => '', 'response' => $data];
|
||||
}
|
||||
|
||||
public function validateCredentials(array $credentials): array
|
||||
{
|
||||
$key = $credentials['api_key'] ?? '';
|
||||
|
||||
if (empty($key)) {
|
||||
return ['valid' => false, 'message' => 'Missing API key', 'account_name' => ''];
|
||||
}
|
||||
|
||||
$ch = curl_init('https://dev.to/api/users/me');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_HTTPHEADER => ['api-key: ' . $key],
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 10,
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
if ($response === false) {
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
return ['valid' => false, 'message' => 'Connection error: ' . $curlError, 'account_name' => ''];
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
$data = json_decode($response, true) ?: [];
|
||||
|
||||
if (!empty($data['username'])) {
|
||||
return ['valid' => true, 'message' => 'Connected', 'account_name' => $data['username']];
|
||||
}
|
||||
|
||||
return ['valid' => false, 'message' => $data['error'] ?? 'Invalid API key', 'account_name' => ''];
|
||||
}
|
||||
|
||||
public function getSupportedMediaTypes(): array
|
||||
{
|
||||
return ['image'];
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_DISCORD="MokoSuiteCross - Discord"
|
||||
PLG_MOKOSUITECROSS_DISCORD_DESCRIPTION="Cross-post Joomla articles to Discord."
|
||||
PLG_MOKOSUITECROSS_DISCORD_FIELDSET_DEFAULTS="Default Settings"
|
||||
PLG_MOKOSUITECROSS_DISCORD_DEFAULT_WEBHOOK_URL="Default Webhook URL"
|
||||
PLG_MOKOSUITECROSS_DISCORD_DEFAULT_WEBHOOK_URL_DESC="The default MokoWaaS Discord webhook URL used when a service is set to 'default' mode."
|
||||
PLG_MOKOSUITECROSS_DISCORD_EMBED_COLOR="Embed Color"
|
||||
PLG_MOKOSUITECROSS_DISCORD_EMBED_COLOR_DESC="Default color for Discord embed messages. Defaults to Discord blurple (#5865F2)."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_DISCORD="MokoSuiteCross - Discord"
|
||||
PLG_MOKOSUITECROSS_DISCORD_DESCRIPTION="Cross-post Joomla articles to Discord."
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_FACEBOOK="MokoSuiteCross - Facebook / Meta"
|
||||
PLG_MOKOSUITECROSS_FACEBOOK_DESCRIPTION="Cross-post Joomla articles to Facebook / Meta."
|
||||
PLG_MOKOSUITECROSS_FACEBOOK_FIELDSET_DEFAULTS="Default Settings"
|
||||
PLG_MOKOSUITECROSS_FACEBOOK_DEFAULT_PAGE_ACCESS_TOKEN="Default Page Access Token"
|
||||
PLG_MOKOSUITECROSS_FACEBOOK_DEFAULT_PAGE_ACCESS_TOKEN_DESC="The default MokoWaaS Facebook Page Access Token used when a service is set to 'default' mode."
|
||||
PLG_MOKOSUITECROSS_FACEBOOK_DEFAULT_PAGE_ID="Default Page ID"
|
||||
PLG_MOKOSUITECROSS_FACEBOOK_DEFAULT_PAGE_ID_DESC="The default Facebook Page ID used when a service is set to 'default' mode."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_FACEBOOK="MokoSuiteCross - Facebook / Meta"
|
||||
PLG_MOKOSUITECROSS_FACEBOOK_DESCRIPTION="Cross-post Joomla articles to Facebook / Meta."
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_GHOST="MokoSuiteCross - Ghost"
|
||||
PLG_MOKOSUITECROSS_GHOST_DESCRIPTION="Cross-post Joomla articles to Ghost."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_GHOST="MokoSuiteCross - Ghost"
|
||||
PLG_MOKOSUITECROSS_GHOST_DESCRIPTION="Cross-post Joomla articles to Ghost."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_GOOGLEBUSINESS="MokoSuiteCross - Google Business Profile"
|
||||
PLG_MOKOSUITECROSS_GOOGLEBUSINESS_DESCRIPTION="Cross-post Joomla articles to Google Business Profile."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_GOOGLEBUSINESS="MokoSuiteCross - Google Business Profile"
|
||||
PLG_MOKOSUITECROSS_GOOGLEBUSINESS_DESCRIPTION="Cross-post Joomla articles to Google Business Profile."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_GOOGLECHAT="MokoSuiteCross - Google Chat"
|
||||
PLG_MOKOSUITECROSS_GOOGLECHAT_DESCRIPTION="Cross-post Joomla articles to Google Chat."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_GOOGLECHAT="MokoSuiteCross - Google Chat"
|
||||
PLG_MOKOSUITECROSS_GOOGLECHAT_DESCRIPTION="Cross-post Joomla articles to Google Chat."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_HASHNODE="MokoSuiteCross - Hashnode"
|
||||
PLG_MOKOSUITECROSS_HASHNODE_DESCRIPTION="Cross-post Joomla articles to Hashnode."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_HASHNODE="MokoSuiteCross - Hashnode"
|
||||
PLG_MOKOSUITECROSS_HASHNODE_DESCRIPTION="Cross-post Joomla articles to Hashnode."
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_LINKEDIN="MokoSuiteCross - LinkedIn"
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_DESCRIPTION="Cross-post Joomla articles to LinkedIn."
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_FIELDSET_DEFAULTS="LinkedIn Defaults"
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_CLIENT_ID="Client ID"
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_CLIENT_ID_DESC="LinkedIn App Client ID."
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_CLIENT_SECRET="Client Secret"
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_CLIENT_SECRET_DESC="LinkedIn App Client Secret."
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_REDIRECT_URI="Redirect URI"
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_REDIRECT_URI_DESC="OAuth callback URL for LinkedIn authentication."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_LINKEDIN="MokoSuiteCross - LinkedIn"
|
||||
PLG_MOKOSUITECROSS_LINKEDIN_DESCRIPTION="Cross-post Joomla articles to LinkedIn."
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP="MokoSuiteCross - Mailchimp"
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_DESCRIPTION="Cross-post Joomla articles to Mailchimp."
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_FIELDSET_DEFAULTS="Mailchimp Defaults"
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_DEFAULT_FROM_NAME="Default From Name"
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_DEFAULT_FROM_NAME_DESC="Default sender name for Mailchimp campaigns."
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_DEFAULT_FROM_EMAIL="Default From Email"
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_DEFAULT_FROM_EMAIL_DESC="Default sender email address for Mailchimp campaigns."
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_AUTO_SEND="Auto Send"
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_AUTO_SEND_DESC="Automatically send the campaign on creation instead of saving as draft."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP="MokoSuiteCross - Mailchimp"
|
||||
PLG_MOKOSUITECROSS_MAILCHIMP_DESCRIPTION="Cross-post Joomla articles to Mailchimp."
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MASTODON="MokoSuiteCross - Mastodon"
|
||||
PLG_MOKOSUITECROSS_MASTODON_DESCRIPTION="Cross-post Joomla articles to Mastodon."
|
||||
PLG_MOKOSUITECROSS_MASTODON_FIELDSET_DEFAULTS="Mastodon Defaults"
|
||||
PLG_MOKOSUITECROSS_MASTODON_DEFAULT_INSTANCE_URL="Default Instance URL"
|
||||
PLG_MOKOSUITECROSS_MASTODON_DEFAULT_INSTANCE_URL_DESC="Default Mastodon instance URL (e.g. https://mastodon.social)."
|
||||
PLG_MOKOSUITECROSS_MASTODON_DEFAULT_VISIBILITY="Default Visibility"
|
||||
PLG_MOKOSUITECROSS_MASTODON_DEFAULT_VISIBILITY_DESC="Default post visibility for Mastodon toots."
|
||||
PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_PUBLIC="Public"
|
||||
PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_UNLISTED="Unlisted"
|
||||
PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_PRIVATE="Private"
|
||||
PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_DIRECT="Direct"
|
||||
PLG_MOKOSUITECROSS_MASTODON_APPEND_HASHTAGS="Append Hashtags"
|
||||
PLG_MOKOSUITECROSS_MASTODON_APPEND_HASHTAGS_DESC="Default hashtags to append to posts (e.g. #Joomla #MokoWaaS)."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MASTODON="MokoSuiteCross - Mastodon"
|
||||
PLG_MOKOSUITECROSS_MASTODON_DESCRIPTION="Cross-post Joomla articles to Mastodon."
|
||||
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||
<name>MokoSuiteCross - Mastodon</name>
|
||||
<version>01.01.02-dev</version>
|
||||
<creationDate>2026-05-28</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
<authorUrl>https://mokoconsulting.tech</authorUrl>
|
||||
<copyright>Copyright (C) 2026 Moko Consulting. All rights reserved.</copyright>
|
||||
<license>GPL-3.0-or-later</license>
|
||||
<description>PLG_MOKOSUITECROSS_MASTODON_DESCRIPTION</description>
|
||||
|
||||
<namespace path="src">Joomla\Plugin\MokoSuiteCross${CLASS_NAME}</namespace>
|
||||
|
||||
<files>
|
||||
<filename plugin="mastodon">mastodon.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>services</folder>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_mokosuitecross_mastodon.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_mokosuitecross_mastodon.sys.ini</language>
|
||||
</languages>
|
||||
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic" label="PLG_MOKOSUITECROSS_MASTODON_FIELDSET_DEFAULTS">
|
||||
<field
|
||||
name="default_instance_url"
|
||||
type="url"
|
||||
label="PLG_MOKOSUITECROSS_MASTODON_DEFAULT_INSTANCE_URL"
|
||||
description="PLG_MOKOSUITECROSS_MASTODON_DEFAULT_INSTANCE_URL_DESC"
|
||||
/>
|
||||
<field
|
||||
name="default_visibility"
|
||||
type="list"
|
||||
label="PLG_MOKOSUITECROSS_MASTODON_DEFAULT_VISIBILITY"
|
||||
description="PLG_MOKOSUITECROSS_MASTODON_DEFAULT_VISIBILITY_DESC"
|
||||
default="public"
|
||||
>
|
||||
<option value="public">PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_PUBLIC</option>
|
||||
<option value="unlisted">PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_UNLISTED</option>
|
||||
<option value="private">PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_PRIVATE</option>
|
||||
<option value="direct">PLG_MOKOSUITECROSS_MASTODON_VISIBILITY_DIRECT</option>
|
||||
</field>
|
||||
<field
|
||||
name="append_hashtags"
|
||||
type="text"
|
||||
label="PLG_MOKOSUITECROSS_MASTODON_APPEND_HASHTAGS"
|
||||
description="PLG_MOKOSUITECROSS_MASTODON_APPEND_HASHTAGS_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MATRIX="MokoSuiteCross - Matrix / Element"
|
||||
PLG_MOKOSUITECROSS_MATRIX_DESCRIPTION="Cross-post Joomla articles to Matrix / Element."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MATRIX="MokoSuiteCross - Matrix / Element"
|
||||
PLG_MOKOSUITECROSS_MATRIX_DESCRIPTION="Cross-post Joomla articles to Matrix / Element."
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MEDIUM="MokoSuiteCross - Medium"
|
||||
PLG_MOKOSUITECROSS_MEDIUM_DESCRIPTION="Cross-post Joomla articles to Medium."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_MEDIUM="MokoSuiteCross - Medium"
|
||||
PLG_MOKOSUITECROSS_MEDIUM_DESCRIPTION="Cross-post Joomla articles to Medium."
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
; MokoSuiteCross - MokoSuiteCalendar Events Service
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR="MokoSuiteCross - MokoSuiteCalendar Events"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_DESCRIPTION="Cross-posts MokoSuiteCalendar events to connected platforms. Enriches messages with event date, time, location, and calendar details."
|
||||
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_FIELDSET_DEFAULTS="Event Cross-Post Settings"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_INCLUDE_LOCATION="Include Location"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_INCLUDE_LOCATION_DESC="Append the event location to the cross-post message."
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_INCLUDE_DATE="Include Date/Time"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_INCLUDE_DATE_DESC="Append the event date and time to the cross-post message."
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_DATE_FORMAT="Date Format"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_DATE_FORMAT_DESC="PHP date format string for event dates. Default: l, F j, Y at g:ia"
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
; MokoSuiteCross - MokoSuiteCalendar Events Service
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR="Plugin - MokoSuiteCross MokoSuiteCalendar Events"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMCALENDAR_DESCRIPTION="Cross-posts MokoSuiteCalendar events to connected platforms."
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
; MokoSuiteCross - MokoSuiteGallery Service
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY="MokoSuiteCross - MokoSuiteGallery"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_DESCRIPTION="Cross-posts MokoSuiteGallery content to connected platforms. Supports gallery announcements with preview images and individual image posts."
|
||||
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_FIELDSET_DEFAULTS="Gallery Cross-Post Settings"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_POST_MODE="Post Mode"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_POST_MODE_DESC="Gallery mode posts when a gallery is published (with preview images). Image mode posts each individual image."
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MODE_GALLERY="Gallery (with preview images)"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MODE_IMAGE="Individual Images"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MAX_IMAGES="Max Preview Images"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MAX_IMAGES_DESC="Maximum number of preview images to attach when cross-posting a gallery."
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_INCLUDE_DESCRIPTION="Include Description"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_INCLUDE_DESCRIPTION_DESC="Append the gallery or image description to the cross-post message."
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
; MokoSuiteCross - MokoSuiteGallery Service
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY="Plugin - MokoSuiteCross MokoSuiteGallery"
|
||||
PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_DESCRIPTION="Cross-posts MokoSuiteGallery galleries and images to connected platforms."
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="mokosuitecross" method="upgrade">
|
||||
<name>MokoSuiteCross - MokoSuiteGallery</name>
|
||||
<version>01.01.02-dev</version>
|
||||
<creationDate>2026-05-28</creationDate>
|
||||
<author>Moko Consulting</author>
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
<authorUrl>https://mokoconsulting.tech</authorUrl>
|
||||
<copyright>Copyright (C) 2026 Moko Consulting. All rights reserved.</copyright>
|
||||
<license>GPL-3.0-or-later</license>
|
||||
<description>PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_DESCRIPTION</description>
|
||||
|
||||
<namespace path="src">Joomla\Plugin\MokoSuiteCross\MokoSuiteGallery</namespace>
|
||||
|
||||
<files>
|
||||
<filename plugin="mokosuitegallery">mokosuitegallery.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>services</folder>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_mokosuitecross_mokosuitegallery.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_mokosuitecross_mokosuitegallery.sys.ini</language>
|
||||
</languages>
|
||||
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic" label="PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_FIELDSET_DEFAULTS">
|
||||
<field
|
||||
name="post_mode"
|
||||
type="list"
|
||||
label="PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_POST_MODE"
|
||||
description="PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_POST_MODE_DESC"
|
||||
default="gallery"
|
||||
>
|
||||
<option value="gallery">PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MODE_GALLERY</option>
|
||||
<option value="image">PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MODE_IMAGE</option>
|
||||
</field>
|
||||
<field
|
||||
name="max_images"
|
||||
type="number"
|
||||
label="PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MAX_IMAGES"
|
||||
description="PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_MAX_IMAGES_DESC"
|
||||
default="4"
|
||||
min="1"
|
||||
max="20"
|
||||
/>
|
||||
<field
|
||||
name="include_description"
|
||||
type="radio"
|
||||
label="PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_INCLUDE_DESCRIPTION"
|
||||
description="PLG_MOKOSUITECROSS_MOKOJOOMGALLERY_INCLUDE_DESCRIPTION_DESC"
|
||||
default="1"
|
||||
class="btn-group"
|
||||
>
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_NOSTR="MokoSuiteCross - Nostr"
|
||||
PLG_MOKOSUITECROSS_NOSTR_DESCRIPTION="Cross-post Joomla articles to Nostr."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_NOSTR="MokoSuiteCross - Nostr"
|
||||
PLG_MOKOSUITECROSS_NOSTR_DESCRIPTION="Cross-post Joomla articles to Nostr."
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_NTFY="MokoSuiteCross - Ntfy Push Notifications"
|
||||
PLG_MOKOSUITECROSS_NTFY_DESCRIPTION="Cross-post Joomla articles to Ntfy Push Notifications."
|
||||
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_NTFY="MokoSuiteCross - Ntfy Push Notifications"
|
||||
PLG_MOKOSUITECROSS_NTFY_DESCRIPTION="Cross-post Joomla articles to Ntfy Push Notifications."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_PINTEREST="MokoSuiteCross - Pinterest"
|
||||
PLG_MOKOSUITECROSS_PINTEREST_DESCRIPTION="Cross-post Joomla articles to Pinterest."
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
PLG_MOKOSUITECROSS_PINTEREST="MokoSuiteCross - Pinterest"
|
||||
PLG_MOKOSUITECROSS_PINTEREST_DESCRIPTION="Cross-post Joomla articles to Pinterest."
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user