-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
274 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/0xJacky/Nginx-UI/api" | ||
"github.com/0xJacky/Nginx-UI/internal/config" | ||
"github.com/0xJacky/Nginx-UI/internal/nginx" | ||
"github.com/0xJacky/Nginx-UI/query" | ||
"github.com/gin-gonic/gin" | ||
"github.com/sashabaranov/go-openai" | ||
"net/http" | ||
"os" | ||
"github.com/0xJacky/Nginx-UI/api" | ||
"github.com/0xJacky/Nginx-UI/internal/config" | ||
"github.com/0xJacky/Nginx-UI/internal/nginx" | ||
"github.com/0xJacky/Nginx-UI/query" | ||
"github.com/gin-gonic/gin" | ||
"github.com/sashabaranov/go-openai" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
func GetConfig(c *gin.Context) { | ||
name := c.Param("name") | ||
path := nginx.GetConfPath("/", name) | ||
|
||
stat, err := os.Stat(path) | ||
|
||
if err != nil { | ||
api.ErrHandler(c, err) | ||
return | ||
} | ||
|
||
content, err := os.ReadFile(path) | ||
|
||
if err != nil { | ||
api.ErrHandler(c, err) | ||
return | ||
} | ||
|
||
g := query.ChatGPTLog | ||
chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate() | ||
|
||
if err != nil { | ||
api.ErrHandler(c, err) | ||
return | ||
} | ||
|
||
if chatgpt.Content == nil { | ||
chatgpt.Content = make([]openai.ChatCompletionMessage, 0) | ||
} | ||
|
||
c.JSON(http.StatusOK, config.Config{ | ||
Name: name, | ||
Content: string(content), | ||
ChatGPTMessages: chatgpt.Content, | ||
FilePath: path, | ||
ModifiedAt: stat.ModTime(), | ||
}) | ||
name := c.Param("name") | ||
|
||
path := nginx.GetConfPath("/", name) | ||
|
||
stat, err := os.Stat(path) | ||
|
||
if err != nil { | ||
api.ErrHandler(c, err) | ||
return | ||
} | ||
|
||
content, err := os.ReadFile(path) | ||
|
||
if err != nil { | ||
api.ErrHandler(c, err) | ||
return | ||
} | ||
|
||
g := query.ChatGPTLog | ||
chatgpt, err := g.Where(g.Name.Eq(path)).FirstOrCreate() | ||
|
||
if err != nil { | ||
api.ErrHandler(c, err) | ||
return | ||
} | ||
|
||
if chatgpt.Content == nil { | ||
chatgpt.Content = make([]openai.ChatCompletionMessage, 0) | ||
} | ||
|
||
c.JSON(http.StatusOK, config.Config{ | ||
Name: name, | ||
Content: string(content), | ||
ChatGPTMessages: chatgpt.Content, | ||
FilePath: path, | ||
ModifiedAt: stat.ModTime(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
es fr_FR ru_RU vi_VN zh_CN zh_TW | ||
en zh_CN zh_TW fr_FR es ru_RU vi_VN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"2.0.0-beta.11","build_id":111,"total_build":315} | ||
{"version":"2.0.0-beta.14","build_id":112,"total_build":316} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"2.0.0-beta.11","build_id":111,"total_build":315} | ||
{"version":"2.0.0-beta.14","build_id":112,"total_build":316} |
Oops, something went wrong.