mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 04:52: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 (
|
import (
|
||||||
"fmt"
|
"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"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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/git"
|
||||||
|
"github.com/thomiceli/opengist/internal/index"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -24,6 +24,19 @@ const (
|
||||||
PrivateVisibility
|
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 {
|
func (v Visibility) Next() Visibility {
|
||||||
switch v {
|
switch v {
|
||||||
case PublicVisibility:
|
case PublicVisibility:
|
||||||
|
|
Loading…
Reference in a new issue