mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-22 20:42:40 +00:00
feat: add String method to visibility (#276)
This allows templates that directly use `Private`, for example, to show a string rather than an int. Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
parent
88f0f6e4c0
commit
6836dedda4
1 changed files with 18 additions and 5 deletions
|
@ -2,17 +2,17 @@ package db
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/alecthomas/chroma/v2"
|
||||
"github.com/alecthomas/chroma/v2/lexers"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/thomiceli/opengist/internal/index"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/chroma/v2"
|
||||
"github.com/alecthomas/chroma/v2/lexers"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/thomiceli/opengist/internal/git"
|
||||
"github.com/thomiceli/opengist/internal/index"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
@ -24,6 +24,19 @@ const (
|
|||
PrivateVisibility
|
||||
)
|
||||
|
||||
func (v Visibility) String() string {
|
||||
switch v {
|
||||
case PublicVisibility:
|
||||
return "public"
|
||||
case UnlistedVisibility:
|
||||
return "unlisted"
|
||||
case PrivateVisibility:
|
||||
return "private"
|
||||
default:
|
||||
return "???"
|
||||
}
|
||||
}
|
||||
|
||||
func (v Visibility) Next() Visibility {
|
||||
switch v {
|
||||
case PublicVisibility:
|
||||
|
|
Loading…
Reference in a new issue