### Quick Start Halo with Docker Source: https://github.com/halo-dev/halo/blob/main/README.md Use this command to quickly start a Halo experience environment if you have Docker installed. This command maps port 8090 and mounts a local directory for data persistence. ```bash docker run -d --name halo -p 8090:8090 -v ~/.halo2:/root/.halo2 halohub/halo:2.23 ``` -------------------------------- ### Get Plugins Source: https://context7.com/halo-dev/halo/llms.txt Retrieves a list of installed plugins. ```APIDOC ## GET /apis/plugin.halo.run/v1alpha1/plugins ### Description Retrieves a list of installed plugins. ### Method GET ### Endpoint /apis/plugin.halo.run/v1alpha1/plugins ### Response #### Success Response (200) - **items** (array) - A list of plugin objects. ``` -------------------------------- ### Install API Client in Plugin Source: https://github.com/halo-dev/halo/blob/main/ui/packages/api-client/README.md Install the @halo-dev/api-client and axios packages using pnpm. This is required for using the API client within a Halo plugin. ```shell pnpm install @halo-dev/api-client axios ``` -------------------------------- ### Halo REST API Example - Curl Source: https://context7.com/halo-dev/halo/llms.txt Demonstrates common REST API endpoint calls using curl. This is a placeholder for actual API examples. ```bash ``` -------------------------------- ### Full-Text Search API Endpoint Example Source: https://github.com/halo-dev/halo/blob/main/docs/full-text-search/README.md This example demonstrates how to query for articles using the full-text search API. It includes parameters for keyword, sorting, offset, and limit. Note that the API does not directly support pagination but allows setting a limit for results per query. ```bash http://localhost:8090/apis/api.halo.run/v1alpha1/posts?keyword=halo&sort=title.asc&sort=publishTimestamp,desc&offset=20&limit=10 ``` -------------------------------- ### Create PAT Response Example Source: https://github.com/halo-dev/halo/blob/main/docs/authentication/README.md This JSON object is an example of a successful response when creating a Personal Access Token (PAT). It includes the PAT's metadata, spec, and the generated access token. ```json { "spec": { "description": "This is my first PAT.", "expiresAt": "2023-09-16T02:42:35.136Z", "roles": [], "username": "admin", "revoked": false, "tokenId": "0b897d9c-56d7-5541-2662-110b70e3f9fd" }, "apiVersion": "security.halo.run/v1alpha1", "kind": "PersonalAccessToken", "metadata": { "generateName": "pat-admin-", "name": "pat-admin-lobkm", "annotations": { "security.halo.run/access-token": "pat_eyJraWQiOiJabUNtcWhJX2FuaFlWQW5aRlVTS0lOckxXRFhqaEp1Nk9ZRGRtcW13Rno4IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJhZG1pbiIsInJvbGVzIjpbXSwicGF0X25hbWUiOiJwYXQtYWRtaW4tbG9ia20iLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwOTAvIiwiZXhwIjoxNjk0ODMyMTU1LCJpYXQiOjE2OTQ3NDcyOTgsImp0aSI6IjBiODk3ZDljLTU2ZDctNTU0MS0yNjYyLTExMGI3MGUzZjlmZCJ9.UVFYzKmz3bUk7fV6xh_CpuNJA-BR8bci-DIJ7o0fk-hayHXFHr_-7HMrVn7iZcphryqmk0RLv7Zsu_AjY9Qn9iCYybBJBycU0tUJzhDexRtj1ViJtlsraoYxLNSYpJK1hcPngeJuiMa9FZrYGp0k_7GX1NddoXLUBI9orN9DbdKmmJXtvigaxPCp52Mu7fBtVsTmO5fk_y2CglqRl_tkLRpFSgUbERKOqKItctDFRg-WUALBYEpXbhZIXBMuTCsJwhniBMpc1Uu_a1Dqa3K5hDgfHTeUADY2BuhEdYJCODPCzmdfWMNqxYSKQT5JFYoDv-ed6cRqNjKeNvd1IPT3RDkVt_fbo8KPrzvkgIjIzni-Wlwe-pXXQbj_n8iax-jkeK526iu8q2CLptxYxLGD0j8htKZramrov4UkK_eIsotEZZfqig9sYVU5_b442WhOWatdB_pbKj7h-YK1Cb2ueg5kl73bcbBu63b8edJZClp6xr72az343SfBZdwrT_JJ5HR0hJmckAMR_U4qvGWrJ-dobXDgY9Oz-qObfiyglzn0Wrz4HRPlmqDFr2o6TMV7UVjQiV77tDzaNbaXVevXGPS5MaZr313dia7XLpIV3QopXma7rDR6Xnqg7ftDQb5vAvsjwN-JsVabAsdFeCo6ejE1slAD9ZQrD88kgfAIuX4" }, "version": 0, "creationTimestamp": "2023-09-15T03:08:18.875350Z" } } ``` -------------------------------- ### Backup Configuration Example Source: https://github.com/halo-dev/halo/blob/main/docs/backup-and-restore.md This YAML snippet shows a potential configuration for backup compression formats. It specifies options for both extensions data and the work directory. ```yaml compressions: extensions: json | others workdir: zip | others ``` -------------------------------- ### Example PAT Structure Source: https://github.com/halo-dev/halo/blob/main/docs/authentication/README.md PATs in Halo start with 'pat_' followed by a random string, which can be a JWT, UUID, or other encrypted random string. This example shows the 'pat_' prefix combined with a JWT. ```text pat_eyJraWQiOiJabUNtcWhJX2FuaFlWQW5aRlVTS0lOckxXRFhqaEp1Nk9ZRGRtcW13Rno4IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJhZG1pbiIsInJvbGVzIjpbInN1cGVyLXJvbGUiXSwicGF0X25hbWUiOiJwYXQtYWRtaW4tSVdvbFEiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjgwOTAvIiwiZXhwIjoxNjk0NjcyMDc5LCJpYXQiOjE2OTQ1ODU3MjAsImp0aSI6IjE3ZWFkNzlkLTRkMjctYjg4NS02YjAzLTM4Y2JlYzQxMmFlMyJ9.xiq36NZIM3_ynBx-l0scGdfX-89aJi6uV7HJz_kNnuT78CFmxD-XTpncK1E-hqPdQSrSwyG4gT1pVO17UmUCoyoAkZKKKVk_seFwxdbygIueo2UJA5kVw1Naf_6iLtNkAXxAiYUpd8ihIwvVedhmOMQ9UUfd4QKZDR1XnTW4EAteWBi7b0pWqSa4h5lv7TpmAECY_KDAGrBRGGhc9AxsrGYPNZo68n2QGJ5BjH29vfdQaZz4vwsgKxG1WJ9Y7c8cQI9JN8EyQD_n560NWAaoFnRi1qL3nexvhjq8EVyGVyM48aKA02UcyvI9cxZFk6ZgnzmUsMjyA6ZL7wuexkujVqmc3iO5plBDCjW7oMe1zPQq-gEJXJU6gdr_SHcGG1BjamoekCkOeNT3CPzA_-5j3AVlj7FTFQkbn_h-kV07mfNO45BVVKsMb08HrN6iEk7TOX7SxN0s2gFc3xYVcXBMveLtftOfXs04SvSFCfTDeJH_Jy-3lYb_GLOji7xSc6FgRbuAwmzHLlsgBT4NJhR_0dZ-jNsCDIQCIC3iDc0qbcNTJYYocT77YaQzIkleFIXyPiV0RsNPmSTEDGiDlctsZ-AmcGCDQ-UmW8SIFBrA93OHncvb47o0-uBwZLdF_we4S90hJlNiAPVhhrBMtCoTJotyrODMEzwbLIukvewFXp8 ``` -------------------------------- ### Backup CRD Example (Succeeded) Source: https://github.com/halo-dev/halo/blob/main/docs/backup-and-restore.md This YAML defines a successful Backup custom resource. It specifies the backup format and an auto-delete timestamp. The status indicates successful completion with start and end times, filename, and size. ```yaml apiVersion: migration.halo.run/v1alpha1 kind: Backup metadata: name: halo-full-backup-xyz creationTimestamp: 2023.07.04-10:25:30 spec: format: zip autoDeleteWhen: 2023.07.10-00:00:00Z status: phase: Succeeded startTimestamp: 2023.07.04-10:25:31 completionTimestamp: 2023.07.04-10:26:30 filename: halo-full-backup-2023-07-04-10-25-30.zip size: 1024 # data unit: bytes ``` -------------------------------- ### ReactiveExtensionClient - Post Management Source: https://context7.com/halo-dev/halo/llms.txt Demonstrates how to use ReactiveExtensionClient for managing 'Post' resources, including getting, creating, updating, deleting, listing with pagination, filtering, and watching for changes. ```APIDOC ## ReactiveExtensionClient - Post Management ### Description This section illustrates the usage of `ReactiveExtensionClient` for performing CRUD operations on `Post` resources. It covers fetching individual posts, creating new ones, updating existing posts, deleting posts, listing posts with pagination, and filtering posts based on criteria. ### Methods and Endpoints (Conceptual) - **Get Post**: Retrieves a single post by its name. - **Create Post**: Creates a new post. - **Update Post**: Updates an existing post. - **Delete Post**: Deletes a post. - **List Posts**: Retrieves a paginated list of posts. - **List Published Posts**: Retrieves a stream of published posts, ordered by creation time. - **Watch Posts**: Sets up a listener to observe real-time changes (add, update, delete) to posts. ### Code Examples (Java) ```java import run.halo.app.extension.ReactiveExtensionClient; import run.halo.app.extension.ListOptions; import run.halo.app.extension.PageRequest; import run.halo.app.extension.PageRequestImpl; import run.halo.app.core.extension.content.Post; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; import reactor.core.publisher.Flux; @Service public class PostManagementService { private final ReactiveExtensionClient client; public PostManagementService(ReactiveExtensionClient client) { this.client = client; } // 获取单篇文章 public Mono getPost(String name) { return client.get(Post.class, name); } // 创建文章 public Mono createPost(Post post) { return client.create(post); } // 更新文章 public Mono updatePost(Post post) { return client.update(post); } // 删除文章 public Mono deletePost(Post post) { return client.delete(post); } // 分页查询文章 public Mono> listPosts(int page, int size) { ListOptions options = new ListOptions(); PageRequest pageRequest = PageRequestImpl.of(page, size); return client.listBy(Post.class, options, pageRequest); } // 使用过滤器和排序器查询 public Flux listPublishedPosts() { return client.list(Post.class, post -> Post.isPublished(post.getMetadata()), (p1, p2) -> p2.getMetadata().getCreationTimestamp() .compareTo(p1.getMetadata().getCreationTimestamp())); } // 监听资源变化 public void watchPosts() { client.watch(new Watcher() { @Override public void onAdd(Extension extension) { System.out.println("Post added: " + extension.getMetadata().getName()); } @Override public void onUpdate(Extension oldExt, Extension newExt) { System.out.println("Post updated: " + newExt.getMetadata().getName()); } @Override public void onDelete(Extension extension) { System.out.println("Post deleted: " + extension.getMetadata().getName()); } }); } } ``` ``` -------------------------------- ### Table Extension Floating Menu Example Source: https://github.com/halo-dev/halo/blob/main/ui/packages/editor/docs/extension.md Example of implementing `getBubbleMenu` for the Table extension to add a column before the current one. It specifies the plugin key, display condition, render container, and the menu item with its icon and action. ```typescript addOptions() { return { ...this.parent?.(), getBubbleMenu({ editor }) { return { pluginKey: "tableBubbleMenu", shouldShow: ({ state }: { state: EditorState }): boolean => { return isActive(state, Table.name); }, getRenderContainer(node) { let container = node; if (container.nodeName === "#text") { container = node.parentElement as HTMLElement; } while ( container && container.classList && !container.classList.contains("tableWrapper") ) { container = container.parentElement as HTMLElement; } return container; }, tippyOptions: { offset: [26, 0], }, items: [ { priority: 10, props: { icon: markRaw(MdiTableColumnPlusBefore), title: i18n.global.t("editor.menus.table.add_column_before"), action: () => editor.chain().focus().addColumnBefore().run(), }, }, ] } } } } ``` -------------------------------- ### Plugin Installation Tab Extension Point Type Source: https://github.com/halo-dev/halo/blob/main/ui/docs/extension-points/plugin-installation-tabs.md Defines the type for the `plugin:installation:tabs:create` extension point, specifying that it can return either an array of `PluginInstallationTab` or a Promise resolving to it. ```typescript "plugin:installation:tabs:create"?: () => | PluginInstallationTab[] | Promise; ``` -------------------------------- ### Get Plugin List with cURL Source: https://context7.com/halo-dev/halo/llms.txt Retrieves a list of all available plugins. Requires authentication. ```bash curl -X GET "${BASE_URL}/apis/plugin.halo.run/v1alpha1/plugins" \ -u "${AUTH}" \ -H "Content-Type: application/json" ``` -------------------------------- ### FormKit List Data Example Source: https://github.com/halo-dev/halo/blob/main/ui/docs/custom-formkit-input/README.md Example of the data structure produced by the FormKit 'list' component, showing an array of simple string values. ```json { "users": [ "Jack", "John" ] } ``` -------------------------------- ### Custom Menu Group Example Source: https://github.com/halo-dev/halo/blob/main/ui/docs/routes-generation/README.md Example of defining a custom menu group for a route, allowing plugins to organize menus under their own categories. ```typescript { name: "帖子", group: "社区", icon: markRaw(IconCummunity), priority: 1, mobile: false, } ``` -------------------------------- ### Create PAT Request Example Source: https://github.com/halo-dev/halo/blob/main/docs/authentication/README.md This shell command demonstrates how to create a new Personal Access Token (PAT) using a POST request to the specified API endpoint. It includes authentication and a JSON payload with PAT details. ```shell curl -u admin:admin -X 'POST' \ 'http://localhost:8090/apis/api.console.security.halo.run/v1alpha1/users/-/personalaccesstokens' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "spec": { "name": "My PAT", "description": "This is my first PAT.", "expiresAt": "2023-09-15T02:42:35.136Z" "roles": [""] } }' ``` -------------------------------- ### Get Themes Source: https://context7.com/halo-dev/halo/llms.txt Retrieves a list of available themes. ```APIDOC ## GET /apis/theme.halo.run/v1alpha1/themes ### Description Retrieves a list of available themes. ### Method GET ### Endpoint /apis/theme.halo.run/v1alpha1/themes ### Response #### Success Response (200) - **items** (array) - A list of theme objects. ``` -------------------------------- ### Create Backup API Request Source: https://github.com/halo-dev/halo/blob/main/docs/backup-and-restore.md This is an example of an HTTP POST request to create a backup. It specifies the API endpoint and the content type. ```http POST /apis/migration.halo.run/v1alpha1/backups Content-Type: application/json ``` -------------------------------- ### Vue Editor Component Example Source: https://github.com/halo-dev/halo/blob/main/ui/docs/extension-points/editor.md A Vue component example demonstrating how to bind raw input and content using `v-model:raw` and `v-model:content`. It uses the `marked` library to convert raw markdown to HTML. ```vue