diff --git a/config.go b/config.go
new file mode 100644
index 0000000..37cadfa
--- /dev/null
+++ b/config.go
@@ -0,0 +1,26 @@
+package main
+
+import (
+ "gopkg.in/yaml.v3"
+ "log/slog"
+ "os"
+)
+
+func readConfig(configFilePath string) (resumeConfig *Resume, err error) {
+ if configFilePath == "" {
+ configFilePath = "./data/resume.yaml"
+ }
+ _, err = os.Stat(configFilePath)
+ if err != nil {
+ return
+ }
+ configBytes, err := os.ReadFile(configFilePath)
+ if err != nil {
+ return
+ }
+ err = yaml.Unmarshal(configBytes, &resumeConfig)
+ if err != nil {
+ slog.Error(err.Error())
+ }
+ return
+}
diff --git a/data/resume.yaml b/data/resume.yaml
new file mode 100644
index 0000000..588a73f
--- /dev/null
+++ b/data/resume.yaml
@@ -0,0 +1,12 @@
+# Meta tag configuration
+# All keys correspond to a meta tag name attribute, and value content attribute
+# e.g.
+meta:
+ # Set the content for the robots meta tag (noindex to disable search engine indexing)
+ robots: "index, follow"
+ language: "en-EN"
+ author: "Job Applicant"
+ theme-color: "#bd93f9"
+ title: "Go-Resume - dynamic resume"
+ description: "Software Developer"
+
diff --git a/go.mod b/go.mod
index bbf1ed8..734cb5b 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,5 @@
module github.com/0ranki/go-resume
go 1.21
+
+require gopkg.in/yaml.v3 v3.0.1
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..a62c313
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,4 @@
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/main.go b/main.go
index d122554..bb85a87 100644
--- a/main.go
+++ b/main.go
@@ -5,43 +5,50 @@ import (
"html/template"
"log/slog"
"net/http"
+ "slices"
)
-//go:embed "static/css/*.css"
+//go:embed "static/css/*.css" "templates/*.html"
var static embed.FS
-
-func home(w http.ResponseWriter, r *http.Request) {
- templateFiles := []string{
- "./templates/index.html",
- "./templates/jsonLd.html",
- "./templates/metatag.html",
- "./templates/githubCorner.html",
- }
- tmpl, err := template.ParseFiles(templateFiles...)
- if err != nil {
- slog.Error(err.Error())
- http.Error(w, "Server error", http.StatusInternalServerError)
- return
- }
- err = tmpl.Execute(w, nil)
- if err != nil {
- slog.Error(err.Error())
- http.Error(w, "Server error", http.StatusInternalServerError)
- }
-}
-
-//func css(w http.ResponseWriter, r *http.Request) {
-// staticFileServer := http.FileServer(http.FS(static))
-// mime.AddExtensionType(".css", "text/css")
-// staticFileServer.ServeHTTP(w, r)
-//}
+var templates map[string]*template.Template
func main() {
+ readConfig("")
staticFileServer := http.FileServer(http.FS(static))
mux := http.NewServeMux()
mux.HandleFunc("/", home)
+ mux.HandleFunc("/light", home)
+ mux.HandleFunc("/dark", home)
mux.Handle("/static/", staticFileServer)
+ slog.Info("Starting go-resume server, listening on port 3000")
err := http.ListenAndServe(":3000", mux)
slog.Error(err.Error())
}
+
+func home(w http.ResponseWriter, r *http.Request) {
+ acceptedPages := []string{"/", "/light", "/dark"}
+ if !slices.Contains(acceptedPages, r.URL.Path) {
+ http.NotFound(w, r)
+ }
+ templateFiles := []string{
+ "templates/index.html",
+ "templates/metatag.html",
+ "templates/githubCorner.html",
+ }
+ tmpl, err := template.ParseFS(static, templateFiles...)
+ if err != nil {
+ slog.Error(err.Error())
+ http.Error(w, "Server error", http.StatusInternalServerError)
+ }
+ data, err := readConfig("")
+ if err != nil {
+ slog.Error(err.Error())
+ http.Error(w, "Server error", http.StatusInternalServerError)
+ }
+ err = tmpl.Execute(w, *data)
+ if err != nil {
+ slog.Error(err.Error())
+ http.Error(w, "Server error", http.StatusInternalServerError)
+ }
+}
diff --git a/static/css/base.css b/static/css/base.css
index c37033c..17cb677 100644
--- a/static/css/base.css
+++ b/static/css/base.css
@@ -69,7 +69,3 @@ body {
@media screen and (min-width: 768px) {
.has-text-right-in-desktop {
text-align: right; } }
-
-.ads-square {
- min-width: 250px;
- min-height: 100px; }
diff --git a/static/css/base.scss b/static/css/base.scss
index b277fdc..7e32004 100644
--- a/static/css/base.scss
+++ b/static/css/base.scss
@@ -90,7 +90,3 @@ body {
}
}
-.ads-square {
- min-width: 250px;
- min-height: 100px;
-}
diff --git a/static/css/github-corner.css b/static/css/github-corner.css
new file mode 100644
index 0000000..9ae8594
--- /dev/null
+++ b/static/css/github-corner.css
@@ -0,0 +1,31 @@
+.github-corner:hover .octo-arm {
+ animation: octocat-wave 560ms ease-in-out;
+}
+
+@keyframes octocat-wave {
+
+ 0%,
+ 100% {
+ transform: rotate(0);
+ }
+
+ 20%,
+ 60% {
+ transform: rotate(-25deg);
+ }
+
+ 40%,
+ 80% {
+ transform: rotate(10deg);
+ }
+}
+
+@media (max-width: 500px) {
+ .github-corner:hover .octo-arm {
+ animation: none;
+ }
+
+ .github-corner .octo-arm {
+ animation: octocat-wave 560ms ease-in-out;
+ }
+}
\ No newline at end of file
diff --git a/static/css/light-style.css b/static/css/light-style.css
index 7befdd2..ef80c07 100644
--- a/static/css/light-style.css
+++ b/static/css/light-style.css
@@ -74,7 +74,3 @@ body {
@media screen and (min-width: 768px) {
.has-text-right-in-desktop {
text-align: right; } }
-
-.ads-square {
- min-width: 250px;
- min-height: 100px; }
diff --git a/structs.go b/structs.go
index 338226d..fe9e0bd 100644
--- a/structs.go
+++ b/structs.go
@@ -1,5 +1,9 @@
package main
+type Resume struct {
+ Meta Meta `yaml:"meta"`
+}
+
type job struct {
Company string `yaml:"company"`
Location string `yaml:"location"`
@@ -34,3 +38,12 @@ type social struct {
}
type socials []social
+
+type Meta struct {
+ Language string `yaml:"language"`
+ Author string `yaml:"author"`
+ Title string `yaml:"title"`
+ Description string `yaml:"description"`
+ Robots string `yaml:"robots"`
+ ThemeColor string `yaml:"theme-color"`
+}
diff --git a/templates/githubCorner.html b/templates/githubCorner.html
index 84ba916..ae47c2f 100644
--- a/templates/githubCorner.html
+++ b/templates/githubCorner.html
@@ -1,5 +1,5 @@
{{ define "githubCorner" }}
-
+