admin: Add link to forge
This commit is contained in:
parent
80917ae436
commit
2c76b5c7a3
7 changed files with 129 additions and 3 deletions
|
|
@ -51,6 +51,11 @@ func declareThemesRoutes(router *gin.RouterGroup) {
|
|||
router.GET("/remote/themes/:thid/exercices", sync.ApiListRemoteExercices)
|
||||
}
|
||||
|
||||
type Theme struct {
|
||||
*fic.Theme
|
||||
ForgeLink string `json:"forge_link,omitempty"`
|
||||
}
|
||||
|
||||
func ThemeHandler(c *gin.Context) {
|
||||
thid, err := strconv.ParseInt(string(c.Params.ByName("thid")), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -142,7 +147,16 @@ func exportThemes(c *gin.Context) {
|
|||
}
|
||||
|
||||
func showTheme(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("theme").(*fic.Theme))
|
||||
theme := c.MustGet("theme").(*fic.Theme)
|
||||
|
||||
var forgelink string
|
||||
if fli, ok := sync.GlobalImporter.(sync.ForgeLinkedImporter); ok {
|
||||
if u, _ := fli.GetThemeLink(theme); u != nil {
|
||||
forgelink = u.String()
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, Theme{theme, forgelink})
|
||||
}
|
||||
|
||||
func createTheme(c *gin.Context) {
|
||||
|
|
|
|||
Reference in a new issue