developer

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

README

Developer Module

A development tool for generating random test data in oCMS with full multi-language support.

Warning: This module is intended for development and testing purposes only. Do not use in production.

Features

  • Generate 5-20 random tags with translations
  • Generate 5-20 random categories (nested hierarchy) with translations
  • Generate 5-20 placeholder images (colored rectangles with variants)
  • Generate 5-20 published pages with tags, categories, and featured images
  • Generate 5-10 menu items in Main Menu (nested, linked to pages)
  • Track all generated items for bulk deletion
  • Clean up generated content with one click

Admin Interface

Access at Admin > Modules > Developer Tools or /admin/developer.

Routes
Method Path Description
GET /admin/developer Dashboard with statistics
POST /admin/developer/generate Generate test data
POST /admin/developer/delete Delete all generated data

Usage

  1. Navigate to the Developer module dashboard
  2. Click Generate Test Data to create random content
  3. Use Delete All Generated Data to clean up

Item Tracking

The module tracks all generated items in a dedicated table:

CREATE TABLE developer_generated_items (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    entity_type TEXT NOT NULL,  -- 'tag', 'category', 'media', 'page', 'menu_item', 'translation'
    entity_id INTEGER NOT NULL,
    created_at DATETIME NOT NULL
);

This ensures only module-generated content is deleted during cleanup.

Module Structure

modules/developer/
├── module.go         # Module definition, lifecycle, migrations
├── handlers.go       # HTTP handlers (dashboard, generate, delete)
├── generator.go      # Random data generation and tracking logic
├── generator_test.go # Unit tests
└── locales/          # Embedded i18n translations
    ├── en/messages.json
    └── ru/messages.json

Internationalization

Translations are embedded in the module and automatically loaded. Supported languages:

  • English (en)
  • Russian (ru)

To add a new language, create locales/{lang}/messages.json.

Full Documentation

See docs/developer-module.md for complete documentation including:

  • Image generation details
  • Translation generation workflow
  • Menu item structure
  • Troubleshooting guide
  • Security considerations

Documentation

Overview

Package developer provides a developer module for generating test data in oCMS. This module creates random tags, categories, media, and pages with translations, tracks all generated items, and allows bulk deletion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DashboardData

type DashboardData struct {
	Counts map[string]int
	Total  int
}

DashboardData contains data for the developer dashboard template

type GenerateResult

type GenerateResult struct {
	Counts   GeneratedCounts
	TagIDs   []int64
	CatIDs   []int64
	MediaIDs []int64
	PageIDs  []int64
}

GenerateResult contains the result of the generation operation

type GeneratedCounts

type GeneratedCounts struct {
	Tags       int
	Categories int
	Media      int
	Pages      int
}

GeneratedCounts holds the counts of generated items

type Module

type Module struct {
	module.BaseModule
	// contains filtered or unexported fields
}

Module implements the module.Module interface for the developer module.

func New

func New() *Module

New creates a new instance of the developer module.

func (*Module) AdminURL

func (m *Module) AdminURL() string

AdminURL returns the admin dashboard URL for the module.

func (*Module) AllowedEnvs

func (m *Module) AllowedEnvs() []string

AllowedEnvs restricts the developer module to non-production environments. On first run, the module will be auto-inserted as inactive if the environment is not in this list.

func (*Module) Init

func (m *Module) Init(ctx *module.Context) error

Init initializes the module with the given context. The developer module is blocked in production environments for security.

func (*Module) Migrations

func (m *Module) Migrations() []module.Migration

Migrations returns database migrations for the module.

func (*Module) RegisterAdminRoutes

func (m *Module) RegisterAdminRoutes(r chi.Router)

RegisterAdminRoutes registers admin routes for the module.

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(_ chi.Router)

RegisterRoutes registers public routes for the module.

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown performs cleanup when the module is shutting down.

func (*Module) SidebarLabel

func (m *Module) SidebarLabel() string

SidebarLabel returns the display label for the admin sidebar.

func (*Module) TemplateFuncs

func (m *Module) TemplateFuncs() template.FuncMap

TemplateFuncs returns template functions provided by the module.

func (*Module) TranslationsFS

func (m *Module) TranslationsFS() embed.FS

TranslationsFS returns the embedded filesystem containing module translations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL