diff --git a/.gitignore b/.gitignore index 20867276934e392b5449491d64335bd2c03458a2..dc5678396ee36caf8e2508a04ea7172f711d8b84 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ .tsnet/ -.policy/ diff --git a/flags.go b/flags.go index 96eac9b866d551c424debb7c1ac0514e114c67c5..ad39886431f753fcd48f4feaccb11fde317dc034 100644 --- a/flags.go +++ b/flags.go @@ -5,7 +5,6 @@ // Args are commandline arguments type Args struct { RepoUrl string - RepoOrigin string RepoLocation string Hostname string DataDir string @@ -17,14 +16,12 @@ // Flags is the [flag.FlagSet] for tailpolicy func Flags() (*Args, *flag.FlagSet) { args := &Args{ - DataDir: ".tsnet", - Hostname: "policy", - RepoLocation: ".policy", + DataDir: ".tsnet", + Hostname: "policy", } fs := flag.NewFlagSet("tailpolicy", flag.ExitOnError) fs.StringVar(&args.RepoUrl, "repo-url", args.RepoUrl, "Repo URL for the Tailscale policy") - fs.StringVar(&args.RepoOrigin, "repo-origin", args.RepoOrigin, "Repo URL for cloning/pushing") - fs.StringVar(&args.RepoLocation, "repo-location", args.RepoLocation, "Repo storage location") + fs.StringVar(&args.RepoLocation, "repo-location", args.RepoLocation, "Repo location to perform git operations against") fs.StringVar(&args.Hostname, "hostname", args.Hostname, "Tailnet hostname") fs.StringVar(&args.DataDir, "data-dir", args.DataDir, "tsnet data directory") fs.StringVar(&args.AuthKey, "auth-key", args.AuthKey, "tsnet auth key") diff --git a/index.go b/index.go index acf87e8b25914215a9879f29787616ca7264de65..f04d3049ba13d44c1d77457f66b2ea8392deef41 100644 --- a/index.go +++ b/index.go @@ -78,7 +78,7 @@ } if err := repo.Push(&git.PushOptions{}); err != nil { return err } - http.Redirect(w, r, "/", http.StatusSeeOther) + http.Redirect(w, r, "/", http.StatusTemporaryRedirect) return nil default: return errors.New("method not allowed") diff --git a/main.go b/main.go index 11666fb37ae0aa5c3089576496e7cab0ad508001..9592ed3ca44ddb057811b669703a6d32aa0b1bde 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - _ "embed" "encoding/json" "errors" "fmt" @@ -17,15 +16,6 @@ "go.jolheiser.com/tailpolicy/static" "go.jolheiser.com/tailroute" ) -var ( - //go:embed static/prism.js - prismJS []byte - //go:embed static/prism.css - prismCSS []byte - //go:embed static/ctp.css - ctpCSS []byte -) - func maine() error { args, fs := Flags() if err := fs.Parse(os.Args[1:]); err != nil { @@ -39,18 +29,6 @@ mux := http.NewServeMux() mux.HandleFunc("/", Index(args.RepoUrl, args.RepoLocation)) mux.HandleFunc("/preview", preview(args.RepoUrl)) mux.HandleFunc("/tailwind.css", static.TailwindHandler) - mux.HandleFunc("/prism.js", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/javascript") - w.Write(prismJS) - }) - mux.HandleFunc("/prism.css", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/css") - w.Write(prismCSS) - }) - mux.HandleFunc("/ctp.css", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "text/css") - w.Write(ctpCSS) - }) r := tailroute.Router{ Tailnet: mux, } @@ -60,7 +38,7 @@ if err := os.MkdirAll(filepath.Dir(args.RepoLocation), os.ModePerm); err != nil { return err } if _, err := git.PlainClone(args.RepoLocation, false, &git.CloneOptions{ - URL: args.RepoOrigin, + URL: args.RepoUrl, }); err != nil { return err } diff --git a/nix/module.nix b/nix/module.nix index c8413873315281056d427ff7151b78e5de2b81b8..6fc0342232a168228551040f8e45bbbc831fe7cf 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -27,14 +27,9 @@ repo-url = mkOption { type = types.str; description = "Repo URL for the Tailscale policy"; }; - repo-origin = mkOption { - type = types.str; - description = "Repo URL for cloning/pushing"; - }; repo-location = mkOption { type = types.str; - description = "Repo storage location"; - default = "/var/lib/tailpolicy/policy"; + description = "Repo location to perform git operations against"; }; hostname = mkOption { type = types.str; @@ -44,7 +39,7 @@ }; data-dir = mkOption { type = types.str; description = "tsnet data directory"; - default = "/var/lib/tailpolicy/tsnet"; + default = ".tsnet"; }; auth-key = mkOption { diff --git a/static/ctp.css b/static/ctp.css deleted file mode 100644 index ba2456d283f355e6b9e73d3e1db1ca3e77fc7bfc..0000000000000000000000000000000000000000 --- a/static/ctp.css +++ /dev/null @@ -1,135 +0,0 @@ -code[class*="language-"], -pre[class*="language-"] { - color: #cdd6f4; -} - -:not(pre)>code[class*="language-"], -pre[class*="language-"] { - background: #181825; -} - -/* https://prismjs.com/tokens.html */ - -.token.keyword { - color: #cba6f7; -} - -.token.builtin { - color: #f38ba8; -} - -.token.class-name { - color: #f9e2af; -} - -.token.function { - color: #89b4fa; -} - -.token.boolean, -.token.number { - color: #fab387; -} - -.token.string, -.token.char { - color: #a6e3a1; -} - -.token.symbol { - color: #f9e2af; -} - -.token.regex { - color: #f5c2e7; -} - -.token.url { - color: #a6e3a1; -} - -.token.operator { - color: #89dceb; -} - -.token.variable { - color: #cdd6f4; -} - -.token.constant { - color: #fab387; -} - -.token.property { - color: #89b4fa; -} - -.token.punctuation { - color: #9399b2; -} - -.token.important { - color: #cba6f7; -} - -.token.comment { - color: #9399b2; -} - -.token.tag { - color: #89b4fa; -} - -.token.attr-name { - color: #f9e2af; -} - -.token.attr-value { - color: #a6e3a1; -} - -.token.namespace { - color: #f9e2af; -} - -.token.prolog, -.token.doctype { - color: #cba6f7; -} - -.token.cdata { - color: #94e2d5; -} - -.token.entity { - color: #f38ba8; -} - -.token.atrule { - color: #cba6f7; -} - -.token.selector { - color: #89b4fa; -} - -/* Diff */ - -.token.deleted { - color: #f38ba8; -} - -.token.inserted { - color: #a6e3a1 -} - -/* Other */ - -.token.important, -.token.bold { - font-weight: bold; -} - -.token.italic { - font-style: italic; -} \ No newline at end of file diff --git a/static/index.tmpl b/static/index.tmpl index 5252efeada0b5ae9de13ce8ff8f588f68bae7bbd..63f20bbf87c08234887e8681b8430477412f1720 100644 --- a/static/index.tmpl +++ b/static/index.tmpl @@ -4,30 +4,24 @@
-