admin: Add link to forge
This commit is contained in:
parent
80917ae436
commit
2c76b5c7a3
7 changed files with 129 additions and 3 deletions
|
@ -85,6 +85,11 @@ func declareExercicesRoutes(router *gin.RouterGroup) {
|
|||
router.GET("/remote/themes/:thid/exercices/:exid/flags", sync.ApiGetRemoteExerciceFlags)
|
||||
}
|
||||
|
||||
type Exercice struct {
|
||||
*fic.Exercice
|
||||
ForgeLink string `json:"forge_link,omitempty"`
|
||||
}
|
||||
|
||||
func ExerciceHandler(c *gin.Context) {
|
||||
eid, err := strconv.ParseInt(string(c.Params.ByName("eid")), 10, 32)
|
||||
if err != nil {
|
||||
|
@ -359,7 +364,16 @@ func listExerciceQuiz(c *gin.Context) {
|
|||
}
|
||||
|
||||
func showExercice(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("exercice").(*fic.Exercice))
|
||||
exercice := c.MustGet("exercice").(*fic.Exercice)
|
||||
|
||||
var forgelink string
|
||||
if fli, ok := sync.GlobalImporter.(sync.ForgeLinkedImporter); ok {
|
||||
if u, _ := fli.GetExerciceLink(exercice); u != nil {
|
||||
forgelink = u.String()
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, Exercice{exercice, forgelink})
|
||||
}
|
||||
|
||||
func getExerciceHistory(c *gin.Context) {
|
||||
|
|
|
@ -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