prime8dev

prime8dev
git clone https://git.prime8.dev/prime8dev.git
Log | Files | Refs | README | LICENSE

projects.go (1977B)


      1 package config
      2 
      3 import (
      4 	"os"
      5 	"strings"
      6 )
      7 
      8 const defaultGitCloneBase = "https://prime8.dev"
      9 
     10 type Project struct {
     11 	ID       string
     12 	Name     string
     13 	Subtitle string
     14 	Tech     []string
     15 	URL      string
     16 	Repo     string
     17 	Markdown string
     18 	HTML     string
     19 }
     20 
     21 // GitCloneBase is the base URL repos are cloned from over HTTP (env
     22 // GIT_CLONE_BASE): <base>/<repo>.git.
     23 func GitCloneBase() string {
     24 	base := strings.TrimSpace(os.Getenv("GIT_CLONE_BASE"))
     25 	if base == "" {
     26 		base = defaultGitCloneBase
     27 	}
     28 	return strings.TrimSuffix(base, "/")
     29 }
     30 
     31 // GitCloneURL is the public clone URL for a repo: <base>/<repo>.git.
     32 func GitCloneURL(repo string) string {
     33 	return GitCloneBase() + "/" + repo + ".git"
     34 }
     35 
     36 // GitSSHCloneURL is the public SSH clone URL for a repo, served read-only by
     37 // the site's SSH server: git@<domain>:<repo>.git.
     38 func GitSSHCloneURL(repo string) string {
     39 	return "git@" + strings.TrimPrefix(SiteDomain, "www.") + ":" + repo + ".git"
     40 }
     41 
     42 // ProjectRawURL is where the site serves a file from a project's HEAD.
     43 func ProjectRawURL(id, path string) string {
     44 	return SiteURL + "/projects/" + id + "/raw/" + strings.TrimLeft(path, "/")
     45 }
     46 
     47 func GetProjects() []Project {
     48 	return []Project{
     49 		{
     50 			ID:       "janitor",
     51 			Name:     "janitor",
     52 			Subtitle: "audio classification with ast",
     53 			Tech:     []string{"rust", "cuda"},
     54 			URL:      GitCloneURL("janitor"),
     55 			Repo:     "janitor",
     56 		},
     57 		{
     58 			ID:       "summarizer",
     59 			Name:     "summarizer",
     60 			Subtitle: "audio transcription microservices",
     61 			Tech:     []string{"python", "docker", "kafka"},
     62 			URL:      GitCloneURL("summarizer"),
     63 			Repo:     "summarizer",
     64 		},
     65 		{
     66 			ID:       "finger",
     67 			Name:     "finger",
     68 			Subtitle: "mobile auth app",
     69 			Tech:     []string{"typescript", "react native", "supabase"},
     70 			URL:      GitCloneURL("finger"),
     71 			Repo:     "finger",
     72 		},
     73 	}
     74 }
     75 
     76 func GetProjectByID(id string) *Project {
     77 	for _, p := range GetProjects() {
     78 		if p.ID == id {
     79 			return &p
     80 		}
     81 	}
     82 	return nil
     83 }