Documentation ¶
Index ¶
- Constants
- func ApplyMigrations(db *gorm.DB) error
- func Close() error
- func CountAll(table interface{}) (int64, error)
- func CountAllGistsForkedByUser(fromUserId uint, currentUserId uint) (int64, error)
- func CountAllGistsFromUser(fromUserId uint, currentUserId uint) (int64, error)
- func CountAllGistsLikedByUser(fromUserId uint, currentUserId uint) (int64, error)
- func GetAllGistsVisibleByUser(userId uint) ([]uint, error)
- func GetSetting(key string) (string, error)
- func GetSettings() (map[string]string, error)
- func GetUsersFromEmails(emailsSet map[string]struct{}) (map[string]*User, error)
- func InvitationCodeExists(code string) (bool, error)
- func IsUniqueConstraintViolation(err error) bool
- func Ping() error
- func SSHKeyLastUsedNow(sshKeyContent string) error
- func Setup(dbPath string, sharedCache bool) error
- func UpdateSetting(key string, value string) error
- func UserExists(username string) (bool, error)
- type AdminSetting
- type FileDTO
- type Gist
- func GetAllGists(offset int) ([]*Gist, error)
- func GetAllGistsByIds(ids []uint) ([]*Gist, error)
- func GetAllGistsForCurrentUser(currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsForkedByUser(fromUserId uint, currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsFromSearch(currentUserId uint, query string, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsFromUser(fromUserId uint, currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsLikedByUser(fromUserId uint, currentUserId uint, offset int, sort string, order string) ([]*Gist, error)
- func GetAllGistsRows() ([]*Gist, error)
- func GetGist(user string, gistUuid string) (*Gist, error)
- func GetGistByID(gistId string) (*Gist, error)
- func (gist *Gist) AddAndCommitFile(file *FileDTO) error
- func (gist *Gist) AddAndCommitFiles(files *[]FileDTO) error
- func (gist *Gist) AddInIndex()
- func (gist *Gist) AppendUserLike(user *User) error
- func (gist *Gist) BeforeDelete(tx *gorm.DB) error
- func (gist *Gist) CanWrite(user *User) bool
- func (gist *Gist) Create() error
- func (gist *Gist) CreateForked() error
- func (gist *Gist) Delete() error
- func (gist *Gist) DeleteRepository() error
- func (gist *Gist) File(revision string, filename string, truncate bool) (*git.File, error)
- func (gist *Gist) FileNames(revision string) ([]string, error)
- func (gist *Gist) Files(revision string, truncate bool) ([]*git.File, error)
- func (gist *Gist) ForkClone(username string, uuid string) error
- func (gist *Gist) GetForkParent(user *User) (*Gist, error)
- func (gist *Gist) GetForks(currentUserId uint, offset int) ([]*Gist, error)
- func (gist *Gist) GetLanguagesFromFiles() ([]string, error)
- func (gist *Gist) GetUsersLikes(offset int) ([]*User, error)
- func (gist *Gist) Identifier() string
- func (gist *Gist) IncrementForkCount() error
- func (gist *Gist) InitRepository() error
- func (gist *Gist) Log(skip int) ([]*git.Commit, error)
- func (gist *Gist) NbCommits() (string, error)
- func (gist *Gist) RPC(service string) ([]byte, error)
- func (gist *Gist) RemoveFromIndex()
- func (gist *Gist) RemoveUserLike(user *User) error
- func (gist *Gist) SetLastActiveNow() error
- func (gist *Gist) ToIndexedGist() (*index.Gist, error)
- func (gist *Gist) Update() error
- func (gist *Gist) UpdateNoTimestamps() error
- func (gist *Gist) UpdatePreviewAndCount(withTimestampUpdate bool) error
- func (gist *Gist) UpdateServerInfo() error
- func (gist *Gist) VisibilityStr() string
- type GistDTO
- type Invitation
- type Like
- type MigrationVersion
- type SSHKey
- type SSHKeyDTO
- type User
- type UserDTO
- type Visibility
Constants ¶
View Source
const ( SettingDisableSignup = "disable-signup" SettingRequireLogin = "require-login" SettingDisableLoginForm = "disable-login-form" SettingDisableGravatar = "disable-gravatar" )
Variables ¶
This section is empty.
Functions ¶
func ApplyMigrations ¶
func CountAllGistsFromUser ¶
func GetAllGistsVisibleByUser ¶ added in v1.6.0
func GetSetting ¶
func GetSettings ¶
func GetUsersFromEmails ¶
func InvitationCodeExists ¶ added in v1.7.0
func SSHKeyLastUsedNow ¶
func UpdateSetting ¶
func UserExists ¶
Types ¶
type AdminSetting ¶
type Gist ¶
type Gist struct { ID uint `gorm:"primaryKey"` Uuid string Title string URL string Preview string PreviewFilename string Description string Private Visibility // 0: public, 1: unlisted, 2: private UserID uint User User NbFiles int NbLikes int NbForks int CreatedAt int64 UpdatedAt int64 Likes []User `gorm:"many2many:likes;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` Forked *Gist `gorm:"foreignKey:ForkedID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"` ForkedID uint }
func GetAllGists ¶
func GetAllGistsByIds ¶ added in v1.6.0
func GetAllGistsForkedByUser ¶
func GetAllGistsFromSearch ¶
func GetAllGistsFromUser ¶
func GetAllGistsLikedByUser ¶
func GetAllGistsRows ¶
func GetGistByID ¶
func (*Gist) AddAndCommitFile ¶ added in v1.6.0
func (*Gist) AddAndCommitFiles ¶
func (*Gist) AddInIndex ¶ added in v1.6.0
func (gist *Gist) AddInIndex()
func (*Gist) AppendUserLike ¶
func (*Gist) CreateForked ¶
func (*Gist) DeleteRepository ¶
func (*Gist) GetLanguagesFromFiles ¶ added in v1.6.0
func (*Gist) Identifier ¶ added in v1.6.0
func (*Gist) IncrementForkCount ¶
func (*Gist) InitRepository ¶
func (*Gist) RemoveFromIndex ¶ added in v1.6.0
func (gist *Gist) RemoveFromIndex()
func (*Gist) RemoveUserLike ¶
func (*Gist) SetLastActiveNow ¶
func (*Gist) UpdateNoTimestamps ¶ added in v1.6.0
func (*Gist) UpdatePreviewAndCount ¶
func (*Gist) UpdateServerInfo ¶
func (*Gist) VisibilityStr ¶ added in v1.6.0
type GistDTO ¶
type GistDTO struct { Title string `validate:"max=250" form:"title"` Description string `validate:"max=1000" form:"description"` URL string `validate:"max=32,alphanumdashorempty" form:"url"` Private Visibility `validate:"number,min=0,max=2" form:"private"` Files []FileDTO `validate:"min=1,dive"` Name []string `form:"name"` Content []string `form:"content"` }
func (*GistDTO) ToExistingGist ¶
type Invitation ¶ added in v1.7.0
type Invitation struct { ID uint `gorm:"primaryKey"` Code string ExpiresAt int64 NbUsed uint NbMax uint }
func GetAllInvitations ¶ added in v1.7.0
func GetAllInvitations() ([]*Invitation, error)
func GetInvitationByCode ¶ added in v1.7.0
func GetInvitationByCode(code string) (*Invitation, error)
func GetInvitationByID ¶ added in v1.7.0
func GetInvitationByID(id uint) (*Invitation, error)
func (*Invitation) Create ¶ added in v1.7.0
func (i *Invitation) Create() error
func (*Invitation) Delete ¶ added in v1.7.0
func (i *Invitation) Delete() error
func (*Invitation) IsExpired ¶ added in v1.7.0
func (i *Invitation) IsExpired() bool
func (*Invitation) IsMaxedOut ¶ added in v1.7.0
func (i *Invitation) IsMaxedOut() bool
func (*Invitation) IsUsable ¶ added in v1.7.0
func (i *Invitation) IsUsable() bool
func (*Invitation) Update ¶ added in v1.7.0
func (i *Invitation) Update() error
func (*Invitation) Use ¶ added in v1.7.0
func (i *Invitation) Use() error
type MigrationVersion ¶
type SSHKey ¶
type SSHKey struct { ID uint `gorm:"primaryKey"` Title string Content string SHA string CreatedAt int64 LastUsedAt int64 UserID uint User User `validate:"-" ` }
func GetSSHKeyByID ¶
func GetSSHKeysByUserID ¶
func SSHKeyDoesExists ¶
type SSHKeyDTO ¶
type User ¶
type User struct { ID uint `gorm:"primaryKey"` Username string `gorm:"uniqueIndex"` Password string IsAdmin bool CreatedAt int64 Email string MD5Hash string // for gravatar, if no Email is specified, the value is random AvatarURL string GithubID string GitlabID string GiteaID string OIDCID string `gorm:"column:oidc_id"` Gists []Gist `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;foreignKey:UserID"` SSHKeys []SSHKey `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;foreignKey:UserID"` Liked []Gist `gorm:"many2many:likes;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"` }
func GetAllUsers ¶
func GetUserById ¶
func GetUserByUsername ¶
func (*User) DeleteProviderID ¶
type UserDTO ¶
type Visibility ¶ added in v1.6.0
type Visibility int
const ( PublicVisibility Visibility = iota UnlistedVisibility PrivateVisibility )
func ParseVisibility ¶ added in v1.6.0
func ParseVisibility[T string | int](v T) (Visibility, error)
func (Visibility) Next ¶ added in v1.6.0
func (v Visibility) Next() Visibility
Click to show internal directories.
Click to hide internal directories.