serve

package
v0.0.0-...-07a7878 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const JWTDuration = time.Hour + 30*time.Minute

Variables

View Source
var (
	JWTKey = []byte(viper.GetString("jwt_key"))
)

Functions

func ConvertFromMarkdown

func ConvertFromMarkdown(src string) (template.HTML, error)

func HMS

func HMS(d time.Duration) string

func Incr

func Incr(num int) int

func IsCorrect

func IsCorrect(answer *models.Answer, response *models.Response) bool

func IsZeroDuration

func IsZeroDuration(d time.Duration) bool

func Now

func Now() time.Time

func TimeInterval

func TimeInterval(timezone string, dateFormat string, timeFormat string) func(start, end time.Time) string

func ValidateJwtCookie

func ValidateJwtCookie(r *http.Request) (*jwt.Token, error)

Types

type Claims

type Claims struct {
	Username      string `json:"username"`
	Token         string `json:"token"`
	IsAdmin       bool   `json:"is_admin"`
	ParticipantID string `json:"participant_d"`

	jwt.StandardClaims
}

type GitSync

type GitSync struct {
	Dir    string
	Url    string
	Branch string
	Token  string
	// contains filtered or unexported fields
}

func NewGitSync

func NewGitSync(dir, url, branch, token string) (*GitSync, error)

func (*GitSync) Checkout

func (sync *GitSync) Checkout() error

func (*GitSync) Commit

func (sync *GitSync) Commit() error

func (*GitSync) Open

func (sync *GitSync) Open() error

func (*GitSync) Pull

func (sync *GitSync) Pull() error

func (*GitSync) Push

func (sync *GitSync) Push() error

type PageData

type PageData struct {
	template.Validable

	Title    string
	Username string
	IsAdmin  bool
}

func (PageData) Validate

func (d PageData) Validate() error

type Store

type Store struct {
	Sessions  *session.Store
	Responses *response.Store
}

func (*Store) CreateUpdateResponse

func (s *Store) CreateUpdateResponse(response *models.Response, dir string) (*models.Response, bool, error)

func (*Store) GetResponsePath

func (s *Store) GetResponsePath(response *models.Response) string

func (*Store) GetScores

func (s *Store) GetScores(sessionId string) ([][]interface{}, error)

func (*Store) GetSessionPath

func (s *Store) GetSessionPath(session *models.Session) string

func (*Store) ReadAllSessions

func (s *Store) ReadAllSessions() []*models.Session

func (*Store) ReadResponse

func (s *Store) ReadResponse(sessionId, participantId string) (*models.Response, error)

func (*Store) ReadSession

func (s *Store) ReadSession(uuid string) (*models.Session, error)

type StoreHandler

type StoreHandler struct {
	// contains filtered or unexported fields
}

func NewStoreHandler

func NewStoreHandler(store Storer, funcs template.FuncMap, templatePaths ...string) *StoreHandler

type Storer

type Storer interface {
	ReadSession(uuid string) (*models.Session, error)
	ReadAllSessions() []*models.Session
	CreateUpdateResponse(response *models.Response, dir string) (*models.Response, bool, error)
	ReadResponse(sessionId, participantId string) (*models.Response, error)
	GetSessionPath(session *models.Session) string
	GetResponsePath(response *models.Response) string
	GetScores(sessionId string) ([][]interface{}, error)
}

Directories

Path Synopsis