Added private visibility

* Changed gist type and added HTML button on creation

* Adapted label and edit button

* Changed rules for git HTTP and SSH

* Adapt Readme features
هذا الالتزام موجود في:
Thomas Miceli
2023-09-02 03:58:37 +02:00
ملتزم من قبل GitHub
الأصل 4f623881ac
التزام 25316d7bf2
11 ملفات معدلة مع 114 إضافات و33 حذوفات

عرض الملف

@@ -80,7 +80,7 @@ func gistInit(next echo.HandlerFunc) echo.HandlerFunc {
setData(ctx, "hasLiked", hasLiked)
}
if gist.Private {
if gist.Private > 0 {
setData(ctx, "NoIndex", true)
}
@@ -88,6 +88,22 @@ func gistInit(next echo.HandlerFunc) echo.HandlerFunc {
}
}
// gistSoftInit try to load a gist (same as gistInit) but does not return a 404 if the gist is not found
// useful for git clients using HTTP to obfuscate the existence of a private gist
func gistSoftInit(next echo.HandlerFunc) echo.HandlerFunc {
return func(ctx echo.Context) error {
userName := ctx.Param("user")
gistName := ctx.Param("gistname")
gistName = strings.TrimSuffix(gistName, ".git")
gist, _ := models.GetGist(userName, gistName)
setData(ctx, "gist", gist)
return next(ctx)
}
}
func allGists(ctx echo.Context) error {
var err error
var urlPage string
@@ -400,7 +416,7 @@ func processCreate(ctx echo.Context) error {
func toggleVisibility(ctx echo.Context) error {
var gist = getData(ctx, "gist").(*models.Gist)
gist.Private = !gist.Private
gist.Private = (gist.Private + 1) % 3
if err := gist.Update(); err != nil {
return errorRes(500, "Error updating this gist", err)
}