From bf0df928c776e84d7dbcdf23e992669aca2752ab Mon Sep 17 00:00:00 2001 From: Toby Chui Date: Sat, 31 May 2025 14:32:41 +0800 Subject: [PATCH] Fixed typo and optimized structure --- docs/plugins/build.go | 6 ++++++ docs/plugins/cssOptimizer.go | 6 +++--- docs/plugins/docs/3. Basic Examples/1. Hello World.md | 6 +++--- docs/plugins/html/3. Basic Examples/1. Hello World.html | 6 +++--- docs/plugins/main.go | 6 ------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/plugins/build.go b/docs/plugins/build.go index 86afdaf..d69bf13 100644 --- a/docs/plugins/build.go +++ b/docs/plugins/build.go @@ -14,6 +14,12 @@ import ( "github.com/yosssi/gohtml" ) +type FileInfo struct { + Filename string `json:"filename"` + Title string `json:"title"` + Type string `json:"type"` +} + func build() { rootDir := "./docs" outputFile := "./index.json" diff --git a/docs/plugins/cssOptimizer.go b/docs/plugins/cssOptimizer.go index 5e9e15a..f73701e 100644 --- a/docs/plugins/cssOptimizer.go +++ b/docs/plugins/cssOptimizer.go @@ -19,7 +19,7 @@ func optimizeCss(htmlContent []byte) ([]byte, error) { doc.Find("img").Each(func(i int, s *goquery.Selection) { //For each of the image element, replace the parent from p to div - orginalParent, err := s.Parent().Html() + originalParent, err := s.Parent().Html() if err != nil { fmt.Println("Error getting parent HTML:", err) return @@ -33,10 +33,10 @@ func optimizeCss(htmlContent []byte) ([]byte, error) { encodedSrc := (&url.URL{Path: src}).String() //Patch the bug in the parser that converts " />" to "/>" - orginalParent = strings.ReplaceAll(orginalParent, "/>", " />") + originalParent = strings.ReplaceAll(originalParent, "/>", " />") fmt.Println("
") //Replace the img with ts-image - originalHTMLContent = strings.Replace(originalHTMLContent, orginalParent, "
"+orginalParent+"
", 1) + originalHTMLContent = strings.Replace(originalHTMLContent, originalParent, "
"+originalParent+"
", 1) }) // Add "ts-text" class to each p element diff --git a/docs/plugins/docs/3. Basic Examples/1. Hello World.md b/docs/plugins/docs/3. Basic Examples/1. Hello World.md index 31edae5..efe8db9 100644 --- a/docs/plugins/docs/3. Basic Examples/1. Hello World.md +++ b/docs/plugins/docs/3. Basic Examples/1. Hello World.md @@ -12,7 +12,7 @@ Let start with a really simple Hello World plugin. This only function of this pl First things first, give your plugin a name. In this example, we are using the name "helloworld". -**Plugin name cannot contain space or special characters**, so you must use a file name that satisfy the requirement. No worry, the plugin file name is not the same as the plugin display name in the introspect. +**Plugin name cannot contain space or special characters**, so you must use a file name that satisfies the requirement. Dont worry, the plugin file name is not the same as the plugin display name in the introspect. --- @@ -56,7 +56,7 @@ ls Locate the Zoraxy plugin library from the Zoraxy source code. You can find the `zoraxy_plugin` Go module under `src/mod/plugins/zoraxy_plugin` -Copy the `zoraxy_plugin` folder from the Zoraxy source code mod folder into the your plugin’s mod folder. Let assume you use the same mod folder name as Zoraxy as `mod`, then your copied library path should be `plugins/helloword/mod/zoraxy_plugin` +Copy the `zoraxy_plugin` folder from the Zoraxy source code mod folder into the your plugin’s mod folder. Let assume you use the same mod folder name as Zoraxy as `mod`, then your copied library path should be `plugins/helloworld/mod/zoraxy_plugin` ```bash mkdir ./mod @@ -170,7 +170,7 @@ func main(){ -**Notes: If some post processing is needed between Introspect and Configure, you can use two seperate function to handle the first start and the second starting of your plugin. The "seperated version" of `ServeAndRecvSpec` is defined as ` ServeIntroSpect(pluginSpect *IntroSpect) ` and `RecvConfigureSpec() (*ConfigureSpec, error)`. See `zoraxy_plugin.go` for more information.** +**Notes: If some post processing is needed between Introspect and Configure, you can use two seperate function to handle the first start and the second starting of your plugin. The "separated version" of `ServeAndRecvSpec` is defined as ` ServeIntroSpect(pluginSpect *IntroSpect) ` and `RecvConfigureSpec() (*ConfigureSpec, error)`. See `zoraxy_plugin.go` for more information.** --- diff --git a/docs/plugins/html/3. Basic Examples/1. Hello World.html b/docs/plugins/html/3. Basic Examples/1. Hello World.html index 8ef0d90..76ddfa4 100644 --- a/docs/plugins/html/3. Basic Examples/1. Hello World.html +++ b/docs/plugins/html/3. Basic Examples/1. Hello World.html @@ -182,7 +182,7 @@ Plugin name cannot contain space or special characters - , so you must use a file name that satisfy the requirement. No worry, the plugin file name is not the same as the plugin display name in the introspect. + , so you must use a file name that satisfies the requirement. Dont worry, the plugin file name is not the same as the plugin display name in the introspect.

@@ -260,7 +260,7 @@ ls , then your copied library path should be - plugins/helloword/mod/zoraxy_plugin + plugins/helloworld/mod/zoraxy_plugin

@@ -407,7 +407,7 @@ func main(){

- Notes: If some post processing is needed between Introspect and Configure, you can use two seperate function to handle the first start and the second starting of your plugin. The “seperated version” of + Notes: If some post processing is needed between Introspect and Configure, you can use two seperate function to handle the first start and the second starting of your plugin. The “separated version” of ServeAndRecvSpec diff --git a/docs/plugins/main.go b/docs/plugins/main.go index b5bc6b0..0059aa0 100644 --- a/docs/plugins/main.go +++ b/docs/plugins/main.go @@ -10,12 +10,6 @@ import ( "github.com/fsnotify/fsnotify" ) -type FileInfo struct { - Filename string `json:"filename"` - Title string `json:"title"` - Type string `json:"type"` -} - /* Change this before deploying */ var ( mode = flag.String("m", "web", "Mode to run the application: 'web' or 'build'")