diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 7acf2f1..acdeabb 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -13,8 +13,16 @@ func (app *application) home(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } + data := newTemplateData(r) + data.Title = "Home" - app.renderPage(w, http.StatusOK, "home.tmpl.html", nil) + app.renderPage(w, http.StatusOK, "home.tmpl.html", data) +} + +func (app *application) feedgenView(w http.ResponseWriter, r *http.Request) { + data := newTemplateData(r) + data.Title = "Feed Generator" + app.renderPage(w, http.StatusOK, "feedgenview.tmpl.html", data) } func (app *application) generateRss(w http.ResponseWriter, r *http.Request) { diff --git a/cmd/web/routes.go b/cmd/web/routes.go index d2bad00..c0d5fd9 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -10,7 +10,8 @@ func (app *application) routes() http.Handler { r.Handle("/static/*", http.StripPrefix("/static", fileServer)) r.Get("/", app.home) - r.Get("/generate", app.generateRss) + r.Get("/feedgen", app.feedgenView) + r.Get("/feedgen/generate", app.generateRss) return r } diff --git a/cmd/web/templates.go b/cmd/web/templates.go index 2e6429c..44ea304 100644 --- a/cmd/web/templates.go +++ b/cmd/web/templates.go @@ -10,6 +10,7 @@ import ( type templateData struct { CurrentYear int Feeds []string + Title string } func newTemplateCache() (map[string]*template.Template, error) { diff --git a/ui/html/base.tmpl.html b/ui/html/base.tmpl.html index d06fe18..7715349 100644 --- a/ui/html/base.tmpl.html +++ b/ui/html/base.tmpl.html @@ -4,13 +4,23 @@ - RSS Generator + {{ .Title }} - webweav.ing + -
- {{template "main" .}} -
+
+
+ {{ template "header" .}} +
+
+ {{template "main" .}} +
+ +
{{end}} diff --git a/ui/html/htmx/feed-output.tmpl.html b/ui/html/htmx/feed-output.tmpl.html index 7fa5506..46cd98d 100644 --- a/ui/html/htmx/feed-output.tmpl.html +++ b/ui/html/htmx/feed-output.tmpl.html @@ -1,7 +1,7 @@ {{ range .Feeds }} -
-    
+

Output

+ + {{ end }} diff --git a/ui/html/pages/feedgenview.tmpl.html b/ui/html/pages/feedgenview.tmpl.html new file mode 100644 index 0000000..c2b5ee7 --- /dev/null +++ b/ui/html/pages/feedgenview.tmpl.html @@ -0,0 +1,35 @@ +{{define "main"}} +

Feed Generator

+

+ Generate an RSS feed. The generator will search each of the listed pages for the first <article> element. Inside the <article> element, there must be a <time> element with a valid datetime attribute representing the publish time of the page. See MDN <time> element for details. If a page does not include both of these requirements, it will be skipped. +

+
+

+ +

+

+ +

+

+ +

+

+ +

+ +
+
+
+{{end}} diff --git a/ui/html/pages/home.tmpl.html b/ui/html/pages/home.tmpl.html index 0edc05c..553a89f 100644 --- a/ui/html/pages/home.tmpl.html +++ b/ui/html/pages/home.tmpl.html @@ -1,33 +1,2 @@ {{define "main"}} -

yequari's RSS Feed Generator

- -
-

- -

-

- -

-

- -

-

- -

- -
-
-
{{end}} diff --git a/ui/html/partials/footer.tmpl.html b/ui/html/partials/footer.tmpl.html new file mode 100644 index 0000000..d26ed43 --- /dev/null +++ b/ui/html/partials/footer.tmpl.html @@ -0,0 +1,5 @@ +{{define "footer"}} +

+Created by yequari. +

+{{end}} diff --git a/ui/html/partials/header.tmpl.html b/ui/html/partials/header.tmpl.html index e69de29..53ca843 100644 --- a/ui/html/partials/header.tmpl.html +++ b/ui/html/partials/header.tmpl.html @@ -0,0 +1,8 @@ +{{ define "header" }} +

Webweav.ing

+

Tools for the smallweb

+ +{{ end }} diff --git a/ui/static/css/main.css b/ui/static/css/main.css index 83a1059..773a4d5 100644 --- a/ui/static/css/main.css +++ b/ui/static/css/main.css @@ -1,3 +1,21 @@ #output { white-space: pre; } + +body { + font-size: 16px; +} + +p { + line-height: 1.8; +} + +input, textarea { + display: block; +} + +#wrapper { + width: 750px; + margin: 0 auto; +} + diff --git a/ui/static/js/main.js b/ui/static/js/main.js new file mode 100644 index 0000000..0f5556e --- /dev/null +++ b/ui/static/js/main.js @@ -0,0 +1,6 @@ +function copyToClipboard() { + const elem = document.getElementById("feed-output") + elem.select() + document.execCommand("copy") +} +