diff --git a/cmd/server/main.go b/cmd/server/main.go deleted file mode 100644 index 2c4a3a6..0000000 --- a/cmd/server/main.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "git.home.dutchellie.nl/DutchEllie/proper-website-2/internal/pages" - "git.home.dutchellie.nl/DutchEllie/proper-website-2/internal/templatelib" - "github.com/gin-gonic/gin" -) - -func main() { - port := os.Getenv("SRV_PORT") - if port == "" { - msg := `Website writen in Go! - -Please include all the proper environment variables: -- "SRV_PORT" - ` - fmt.Println(msg) - return - } - address := ":" + port - - lib, err := templatelib.NewTemplateLibrary("../../website/templates") - if err != nil { - fmt.Println(err) - return - } - - router, _ := setupRouter(lib) - - router.Run(address) -} - -func setupRouter(lib templatelib.TemplateLibrary) (*gin.Engine, error) { - router := gin.Default() - - pages.RegisterHandlers(router.Group("/"), pages.NewService(pages.NewRepository(&lib))) - return router, nil -} diff --git a/internal/pages/repository.go b/internal/pages/repository.go deleted file mode 100644 index bb7f7ad..0000000 --- a/internal/pages/repository.go +++ /dev/null @@ -1,24 +0,0 @@ -package pages - -import ( - "context" - "html/template" - - "git.home.dutchellie.nl/DutchEllie/proper-website-2/internal/templatelib" -) - -type Repository interface { - Page(ctx context.Context, name string) (*template.Template, error) -} - -func NewRepository(lib *templatelib.TemplateLibrary) Repository { - return repository{lib} -} - -type repository struct { - library *templatelib.TemplateLibrary -} - -func (r repository) Page(ctx context.Context, name string) (*template.Template, error) { - return r.library.Templates[name], nil -} diff --git a/internal/pages/routes.go b/internal/pages/routes.go deleted file mode 100644 index 72f3088..0000000 --- a/internal/pages/routes.go +++ /dev/null @@ -1,26 +0,0 @@ -package pages - -import ( - "net/http" - - "github.com/gin-gonic/gin" -) - -func RegisterHandlers(r *gin.RouterGroup, service Service) { - res := resource{service} - - r.GET("/index", res.getindex) -} - -type resource struct { - service Service -} - -func (r resource) getindex(c *gin.Context) { - page, err := r.service.Page(c.Request.Context(), "index") - if err != nil { - c.AbortWithStatus(http.StatusInternalServerError) - } - - page.template.Execute(c.Writer, nil) -} diff --git a/internal/pages/service.go b/internal/pages/service.go deleted file mode 100644 index 4deced3..0000000 --- a/internal/pages/service.go +++ /dev/null @@ -1,31 +0,0 @@ -package pages - -import ( - "context" - "html/template" -) - -type Service interface { - Page(ctx context.Context, name string) (Page, error) -} - -type Page struct { - template *template.Template -} - -type service struct { - repository Repository - //logger log.Logger -} - -func NewService(r Repository) Service { - return service{r} -} - -func (s service) Page(ctx context.Context, name string) (Page, error) { - page, err := s.repository.Page(ctx, name) - if err != nil { - return Page{}, err - } - return Page{page}, nil -} diff --git a/internal/templatelib/library.go b/internal/templatelib/library.go deleted file mode 100644 index a35e47d..0000000 --- a/internal/templatelib/library.go +++ /dev/null @@ -1,46 +0,0 @@ -package templatelib - -import ( - "html/template" - "path/filepath" -) - -type TemplateLibrary struct { - Templates map[string]*template.Template -} - -func NewTemplateLibrary(dir string) (TemplateLibrary, error) { - t := make(map[string]*template.Template) - - pages, err := filepath.Glob(filepath.Join(dir, "*.page.tmpl")) - if err != nil { - return TemplateLibrary{}, err - } - - for _, page := range pages { - name := filepath.Base(page) - ts, err := template.ParseFiles(page) - if err != nil { - return TemplateLibrary{}, err - } - - // Use the ParseGlob method to add any 'layout' templates to the - // template set (in our case, it's just the 'base' layout at the - // moment). - ts, err = ts.ParseGlob(filepath.Join(dir, "*.layout.tmpl")) - if err != nil { - return TemplateLibrary{}, err - } - - // Use the ParseGlob method to add any 'partial' templates to the - // template set (in our case, it's just the 'footer' partial at the - // moment). - ts, err = ts.ParseGlob(filepath.Join(dir, "*.partial.tmpl")) - if err != nil { - return TemplateLibrary{}, err - } - t[name] = ts - } - - return TemplateLibrary{Templates: t}, nil -} diff --git a/test-website/base.html b/test-website/base.html index a436432..b296f98 100644 --- a/test-website/base.html +++ b/test-website/base.html @@ -5,7 +5,7 @@ - + Index @@ -14,10 +14,13 @@
- + Dit is eigenlijk 1 van die dingen die steeds kan veranderen + Deze doet dat
diff --git a/test-website/static/style.css b/test-website/static/style.css index 04e3ad1..e7d1a38 100644 --- a/test-website/static/style.css +++ b/test-website/static/style.css @@ -17,4 +17,37 @@ body { background-color: rgb(54, 39, 48); font-size: 5em; font-family: anisha; + text-align: center; +} + +.main { + margin-top: 5px; +} + +.navbar { + border: 3px solid; + border-radius: 4px; + border-color: rgb(252, 230, 255); + background-color: rgb(54, 39, 48); + position: relative; + float:left; + width: 250px; + text-decoration: none; + list-style: none; +} + +.navbar a, a:link, a:visited{ + text-decoration: none; + color:rgb(252, 230, 255) +} + +.content { + border: 3px solid; + border-radius: 4px; + border-color: rgb(252, 230, 255); + background-color: rgb(54, 39, 48); + position: relative; + float:right; + width: 633px; + } \ No newline at end of file diff --git a/website/templates/base.layout.tmpl b/website/templates/base.layout.tmpl deleted file mode 100644 index 51754ac..0000000 --- a/website/templates/base.layout.tmpl +++ /dev/null @@ -1,16 +0,0 @@ -{{ define "base" }} - - - - - {{template "title" .}} - - -
-

-
- - - - -{{ end }} \ No newline at end of file diff --git a/website/templates/index.page.tmpl b/website/templates/index.page.tmpl deleted file mode 100644 index e69de29..0000000