ChestnutCMS

repository·master·Indexed 41 days ago

https://github.com/liweiyi/chestnutcms

An enterprise-grade, decoupled content management system (CMS) featuring multi-site management, dynamic metadata models, and multi-platform staticization. Built with Spring Boot 4.0.7, it integrates SaToken for permissions, xxl-job for task scheduling, Flowable for workflows, and Elasticsearch for full-text search. Version 1.6.0 supports multi-language content and a Vue3 frontend.

Tokens
7.7K
Snippets
21
Records
26
Agent score
52%

What's inside ChestnutCMS

  1. Overview of ChestnutCMS

    master

    ChestnutCMS is an enterprise-grade, decoupled (front-end and back-end separated) Content Management System (CMS). It is refactored from [RuoYi-Vue] and integrates several key technologies for advanced content management:

    • Permission Management: Uses [SaToken] for user authentication and authorization.
    • Task Scheduling: Uses [xxl-job] for distributed task scheduling.
    • Core Capabilities:
      • Site group management (multi-site support).
      • Multi-platform staticization (publishing to PC, H5, HTML, JSON, etc.).
      • Metadata model extensions (dynamic content models).
      • Complex content organization.
      • Multi-language support.
      • Full-text search (ElasticSearch + IK).
      • Workflow engine (Flowable) for content auditing processes.
  2. Configure Elasticsearch access credentials

    master

    After the Elasticsearch container is running, you must initialize the security credentials (username and password) using the interactive setup tool inside the container.

    1. Access the running container's shell.
    2. Navigate to the Elasticsearch binary directory.
    3. Run the elasticsearch-setup-passwords script in interactive mode to set your passwords.
    # 1. Enter the container
    docker exec -it elasticsearch bash
    
    # 2. Initialize access passwords
    cd /usr/share/elasticsearch/bin/
    sh elasticsearch-setup-passwords interactive
  3. Build ChestnutCMS frontend for Stage or Production

    master

    Use the following npm scripts to build the frontend for different environments:

    • Stage environment: npm run build:stage
    • Production environment: npm run build:prod

    After building, the frontend can be served and accessed at http://localhost:80.

    # Build for stage environment
    npm run build:stage
    
    # Build for production environment
    npm run build:prod
  4. Run the ChestnutCMS Vue3 frontend

    master

    To run the ChestnutCMS frontend locally, navigate to the chestnut-ui-vue3 directory, install dependencies using the npmmirror registry, and start the development server.

    By default, the frontend is accessible at http://localhost:80 after building for production.

    # Enter the project directory
    cd chestnut-ui-vue3
    
    # Install dependencies
    npm i --registry=https://registry.npmmirror.com
    
    # Start the development service
    npm run dev
  5. Configure AI functions in UEditorPlus

    master

    UEditorPlus supports extensible AI functions via the aiFunctions array in window.UEDITOR_CONFIG. Each function defines how the AI interacts with the selected text or the entire HTML content.

    Function Properties:

    • name: Unique identifier for the function.
    • text: The label/icon displayed in the UI (supports HTML).
    • systemPrompt: The instructions sent to the AI driver.
    • prompt: The template for the user's input. Supports placeholders like {selectText} (for selected text) or {html} (for the entire document content).
    • enable: A predicate function (context) => boolean to determine if the function should be active.
    • param: (Optional) Configuration for UI behavior, such as showInsert, showReplace, or showReplaceAll.

    Available Built-in Functions:

    • translate: Translates selected text.
    • continueWrite: Continues writing from the selection.
    • summarize: Simplifies the selected text.
    • extend: Expands the selected text with more detail.
    • optimizeWhole: Optimizes the entire document's HTML/content (uses {html} prompt).
    // Example of adding a custom AI function
    window.UEDITOR_CONFIG.aiFunctions.push({
      name: "myCustomAI",
      text: "<i class="edui-iconfont"></i> Custom",
      systemPrompt: "You are a helpful assistant.",
      prompt: "{selectText}",
      enable: function(context) {
        return !!context.selectText;
      }
    });
  6. Server class data structure overview

    master

    The Server class acts as a container for several nested data objects. When copyTo() is called, the following fields are populated:

    • app: AppInfo - Application-specific information.
    • dataSources: DataSources - Data source configurations.
    • cpu: Cpu - CPU metrics including logical processor count, total ticks, system load, used, wait, and free ticks.
    • mem: Mem - Physical memory metrics (total, used, and free).
    • jvm: Jvm - Java Virtual Machine metrics (total, max, and free memory, plus version and home path).
    • sys: Sys - Operating system and host information (computer name, IP, OS name, architecture, and user directory).
    • sysFiles: List<SysFile> - A list of disk/file system information including mount point, type, name, total space, free space, used space, and usage percentage.
  7. Deploy Elasticsearch using Docker Compose

    master

    The chestnut-search module provides a docker-compose.yml configuration to deploy a single-node Elasticsearch instance.

    Key Configuration Details:

    • Image: Uses a placeholder {{DOCKER_IMAGE}} which must be replaced with a valid Elasticsearch image.
    • Ports: Exposes 9200 (HTTP interface) and 9300 (Transport interface).
    • Environment Variables:
      • discovery.type: single-node: Configures Elasticsearch to run without cluster discovery requirements.
      • ES_JAVA_OPTS: Sets JVM heap size. The default is -Xms1024m -Xmx1024m.
    • Volumes: Requires the following local directory structure to persist data and configurations:
      • ./elasticsearch/config/elasticsearch.yml: Configuration file.
      • ./elasticsearch/data: Data persistence.
      • ./elasticsearch/logs: Log files.
      • ./elasticsearch/ik-config: Configuration for the IK analyzer plugin.
    • Resource Limits: Sets memlock ulimits to -1 (unlimited) to allow Elasticsearch to lock memory.
    • Healthcheck: Uses curl against localhost:9200/_cluster/health to monitor service availability.
    version: '3'
    services:
      cc-elasticsearch:
        image: {{DOCKER_IMAGE}}
        restart: unless-stopped
        container_name: cc-elasticsearch
        ports:                                                
          - 9200:9200                                          
          - 9300:9300                                         
        environment:
          discovery.type: single-node
          ES_JAVA_OPTS: -Xms1024m -Xmx1024m
        volumes:
          - ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
          - ./elasticsearch/data:/usr/share/elasticsearch/data
          - ./elasticsearch/logs:/usr/share/elasticsearch/logs
          - ./elasticsearch/ik-config:/usr/share/elasticsearch/plugins/ik/config
        ulimits:
          memlock:
            soft: -1
            hard: -1
  8. Install Vue3 frontend dependencies using package.bat

    master

    The package.bat script is used to install the necessary node_modules for the Vue3 frontend environment. It automatically switches to the parent directory of the script and executes yarn using the https://registry.npmmirror.com registry to ensure reliable dependency resolution.

    Note: This script requires yarn to be installed on your system and assumes the script is located within a subdirectory of the frontend project root.

    package.bat
  9. Deploy ChestnutCMS using the docker-deploy.sh script

    master

    The bin/docker-deploy.sh script automates the deployment process for ChestnutCMS using Docker. It performs the following sequence of operations:

    1. Authentication: Logs into the specified Docker Hub URL using provided credentials.
    2. Image Pulling: Pulls the specific image version defined by IMAGE_REPOSITORY and IMAGE_TAG.
    3. Cleanup of <none> Images:
      • Identifies dangling/intermediate images associated with the repository.
      • Stops any containers currently running from those <none> images.
      • Removes the stopped containers.
      • Deletes the <none> images themselves.
    4. Deployment: Starts the application using docker compose up -d.

    Note: This script uses template placeholders (e.g., {{DOCKERUSER}}) which must be replaced with actual values before execution.

    # Ensure the following variables are populated in the script:
    DOCKERUSER={{DOCKERUSER}}
    DOCKERPWD={{DOCKERPWD}}
    DOCKER_HUB_URL={{DOCKER_HUB_URL}}
    IMAGE_REPOSITORY={{IMAGE_REPOSITORY}}
    IMAGE_TAG={{IMAGE_TAG}}
    
    # Execute the deployment script
    ./bin/docker-deploy.sh