Compare commits
No commits in common. "098d82075d28307aae5cf6260180bda713dc1751" and "6ada6f3ef5b12da3c25de03f99522300167a5639" have entirely different histories.
098d82075d
...
6ada6f3ef5
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.32bit.cafe/yequari/rss-gen/feed"
|
"git.32bit.cafe/yequari/rss-gen/rss"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -16,13 +16,11 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if *siteUrl == "" || *siteTitle == "" || *siteDesc == "" {
|
if *siteUrl == "" || *siteTitle == "" || *siteDesc == "" {
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
feedInfo, err := feed.NewFeedInfo(*siteTitle, *siteUrl, *siteDesc, "", flag.Args()...)
|
feed, err := rss.GenerateRss(*siteUrl, *siteTitle, *siteDesc, flag.Args()...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Stderr.WriteString(err.Error())
|
os.Stderr.WriteString(err.Error())
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
fmt.Println(feedInfo.GenerateRSS())
|
fmt.Println(feed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,8 @@ func (app *application) home(w http.ResponseWriter, r *http.Request) {
|
||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data := newTemplateData(r)
|
|
||||||
data.Title = "Home"
|
|
||||||
|
|
||||||
app.renderPage(w, http.StatusOK, "home.tmpl.html", data)
|
app.renderPage(w, http.StatusOK, "home.tmpl.html", nil)
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
func (app *application) generateRss(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -10,8 +10,7 @@ func (app *application) routes() http.Handler {
|
||||||
r.Handle("/static/*", http.StripPrefix("/static", fileServer))
|
r.Handle("/static/*", http.StripPrefix("/static", fileServer))
|
||||||
|
|
||||||
r.Get("/", app.home)
|
r.Get("/", app.home)
|
||||||
r.Get("/feedgen", app.feedgenView)
|
r.Get("/generate", app.generateRss)
|
||||||
r.Get("/feedgen/generate", app.generateRss)
|
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import (
|
||||||
type templateData struct {
|
type templateData struct {
|
||||||
CurrentYear int
|
CurrentYear int
|
||||||
Feeds []string
|
Feeds []string
|
||||||
Title string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTemplateCache() (map[string]*template.Template, error) {
|
func newTemplateCache() (map[string]*template.Template, error) {
|
||||||
|
|
|
@ -4,23 +4,13 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link rel="stylesheet" href="/static/css/main.css">
|
<link rel="stylesheet" href="/static/css/main.css">
|
||||||
<title>{{ .Title }} - webweav.ing</title>
|
<title>RSS Generator</title>
|
||||||
<script src="/static/js/htmx.min.js"></script>
|
<script src="/static/js/htmx.min.js"></script>
|
||||||
<script src="/static/js/main.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="wrapper">
|
|
||||||
<header>
|
|
||||||
{{ template "header" .}}
|
|
||||||
</header>
|
|
||||||
<main>
|
<main>
|
||||||
{{template "main" .}}
|
{{template "main" .}}
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
|
||||||
<script src="https://tinylytics.app/embed/Tpf2xrC3n_dkzqf1Au1E.js" defer></script>
|
|
||||||
{{template "footer" .}}
|
|
||||||
</footer>
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{ range .Feeds }}
|
{{ range .Feeds }}
|
||||||
<h2>Output</h2>
|
<pre tabindex="0">
|
||||||
<button id="copy" onclick="copyToClipboard()">Copy to Clipboard</button>
|
<code class="">
|
||||||
<textarea readonly="true" cols="80" rows="120" id="feed-output">
|
|
||||||
{{ . }}
|
{{ . }}
|
||||||
</textarea>
|
</code>
|
||||||
|
</pre>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
{{define "main"}}
|
|
||||||
<h1>Feed Generator</h1>
|
|
||||||
<p>
|
|
||||||
Generate an RSS feed. The generator will search each of the listed pages for the first <code><article></code> element. Inside the <code><article></code> element, there must be a <code><time></code> element with a valid <code>datetime</code> attribute representing the publish time of the page. See <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time">MDN <code><time></code> element</a> for details. If a page does not include both of these requirements, it will be skipped.
|
|
||||||
</p>
|
|
||||||
<form id="generate-form">
|
|
||||||
<p>
|
|
||||||
<label>
|
|
||||||
Site Name:
|
|
||||||
<input name="site-name" />
|
|
||||||
</label>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<label>
|
|
||||||
Site URL:
|
|
||||||
<input name="site-url" />
|
|
||||||
</label>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<label>
|
|
||||||
Site Description:
|
|
||||||
<input name="site-description" />
|
|
||||||
</label>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<label>
|
|
||||||
Pages to Include:
|
|
||||||
<textarea name="page-urls" cols="40" rows="6">List of URLs, one per line</textarea>
|
|
||||||
</label>
|
|
||||||
</p>
|
|
||||||
<button id="generate-button" hx-get="/feedgen/generate" hx-include="#generate-form" hx-params="*" hx-target="#output">Generate</button>
|
|
||||||
</form>
|
|
||||||
<div id="output">
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
|
@ -1,2 +1,33 @@
|
||||||
{{define "main"}}
|
{{define "main"}}
|
||||||
|
<h1>yequari's RSS Feed Generator</h1>
|
||||||
|
<!--<form action="/generate" method="get" id="generate-form">-->
|
||||||
|
<form id="generate-form">
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
Site Name:
|
||||||
|
<input name="site-name" />
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
Site URL:
|
||||||
|
<input name="site-url" />
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
Site Description:
|
||||||
|
<input name="site-description" />
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
Pages to Include:
|
||||||
|
<textarea name="page-urls" cols="40" rows="6">List of URLs, one per line</textarea>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<button id="generate-button" hx-get="/generate" hx-include="#generate-form" hx-params="*" hx-target="#output">Generate</button>
|
||||||
|
</form>
|
||||||
|
<div id="output">
|
||||||
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{{define "footer"}}
|
|
||||||
<p>
|
|
||||||
Created by <a href="https://yequari.com">yequari</a>.
|
|
||||||
</p>
|
|
||||||
{{end}}
|
|
|
@ -1,8 +0,0 @@
|
||||||
{{ define "header" }}
|
|
||||||
<h1>Webweav.ing</h1>
|
|
||||||
<p>Tools for the smallweb</p>
|
|
||||||
<nav>
|
|
||||||
<a href="/">Home</a> -
|
|
||||||
<a href="/feedgen">Feed Generator</a>
|
|
||||||
</nav>
|
|
||||||
{{ end }}
|
|
|
@ -1,21 +1,3 @@
|
||||||
#output {
|
#output {
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
line-height: 1.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
input, textarea {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#wrapper {
|
|
||||||
width: 750px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
function copyToClipboard() {
|
|
||||||
const elem = document.getElementById("feed-output")
|
|
||||||
elem.select()
|
|
||||||
document.execCommand("copy")
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue