Browse Source

bug-fixes

master
Silberengel 4 weeks ago
parent
commit
9a86b674ff
  1. 41
      internal/generator/html.go
  2. 12
      internal/server/handlers.go
  3. 79
      static/css/main.css
  4. 13
      templates/base.html
  5. 23
      templates/feed.html
  6. 6
      templates/landing.html

41
internal/generator/html.go

@ -190,6 +190,7 @@ func NewHTMLGenerator(templateDir string, linkBaseURL, siteName, siteURL, defaul @@ -190,6 +190,7 @@ func NewHTMLGenerator(templateDir string, linkBaseURL, siteName, siteURL, defaul
"blog.html",
"wiki.html",
"contact.html",
"feed.html",
"404.html",
"500.html",
}
@ -793,6 +794,46 @@ func (g *HTMLGenerator) GenerateErrorPage(statusCode int, feedItems []FeedItemIn @@ -793,6 +794,46 @@ func (g *HTMLGenerator) GenerateErrorPage(statusCode int, feedItems []FeedItemIn
return g.renderTemplate(fmt.Sprintf("%d.html", statusCode), data)
}
// GenerateFeedPage generates a full feed page
func (g *HTMLGenerator) GenerateFeedPage(feedItems []FeedItemInfo) (string, error) {
canonicalURL := g.siteURL + "/feed"
data := PageData{
Title: "TheForest Feed",
Description: "Recent notes from TheForest relay",
CanonicalURL: canonicalURL,
OGImage: g.siteURL + g.defaultImage,
OGType: "website",
SiteName: g.siteName,
SiteURL: g.siteURL,
CurrentYear: time.Now().Year(),
WikiPages: []WikiPageInfo{},
FeedItems: feedItems,
Content: template.HTML(""), // Content comes from template
}
// Use renderTemplate but with custom data for feed
renderTmpl := template.New("feed-render").Funcs(getTemplateFuncs())
files := []string{
filepath.Join(g.templateDir, "components.html"),
filepath.Join(g.templateDir, "base.html"),
filepath.Join(g.templateDir, "feed.html"),
}
_, err := renderTmpl.ParseFiles(files...)
if err != nil {
return "", fmt.Errorf("failed to parse feed templates: %w", err)
}
var buf bytes.Buffer
if err := renderTmpl.ExecuteTemplate(&buf, "base.html", data); err != nil {
return "", fmt.Errorf("failed to execute feed template: %w", err)
}
return buf.String(), nil
}
// renderTemplate renders a template with the base template
func (g *HTMLGenerator) renderTemplate(templateName string, data PageData) (string, error) {
// Parse base.html together with the specific template to ensure correct blocks are used

12
internal/server/handlers.go

@ -31,6 +31,7 @@ func (s *Server) setupRoutes(mux *http.ServeMux) { @@ -31,6 +31,7 @@ func (s *Server) setupRoutes(mux *http.ServeMux) {
mux.HandleFunc("/articles", s.handleArticles)
mux.HandleFunc("/ebooks", s.handleEBooks)
mux.HandleFunc("/contact", s.handleContact)
mux.HandleFunc("/feed", s.handleFeed)
// Health and metrics
mux.HandleFunc("/health", s.handleHealth)
@ -118,6 +119,17 @@ func (s *Server) handleEBooks(w http.ResponseWriter, r *http.Request) { @@ -118,6 +119,17 @@ func (s *Server) handleEBooks(w http.ResponseWriter, r *http.Request) {
s.servePage(w, r, page)
}
// handleFeed handles the Feed page
func (s *Server) handleFeed(w http.ResponseWriter, r *http.Request) {
page, exists := s.cache.Get("/feed")
if !exists {
http.Error(w, "Page not ready", http.StatusServiceUnavailable)
return
}
s.servePage(w, r, page)
}
// handleContact handles the contact form (GET and POST)
func (s *Server) handleContact(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodGet {

79
static/css/main.css

@ -128,6 +128,20 @@ header { @@ -128,6 +128,20 @@ header {
align-items: center;
}
.nav-separator {
color: var(--text-secondary);
padding: 0 0.5rem;
user-select: none;
}
.nav-section-label {
color: var(--text-secondary);
font-weight: 600;
font-size: 0.9em;
padding: 0 0.25rem;
user-select: none;
}
.nav-menu a {
color: var(--text-primary);
text-decoration: none;
@ -368,6 +382,7 @@ a:focus { @@ -368,6 +382,7 @@ a:focus {
.btn:hover {
background: var(--link-hover);
color: #1a1a1a;
}
.btn:active {
@ -383,6 +398,23 @@ a:focus { @@ -383,6 +398,23 @@ a:focus {
outline-offset: var(--focus-offset);
}
/* Ensure all text and icons inside buttons are black */
.btn,
.btn *,
.btn span,
.btn .icon-inline,
.btn svg {
color: #1a1a1a !important;
}
.btn:hover,
.btn:hover *,
.btn:hover span,
.btn:hover .icon-inline,
.btn:hover svg {
color: #1a1a1a !important;
}
/* Landing Page Styles */
.landing-page {
max-width: 1200px;
@ -1221,6 +1253,7 @@ textarea:focus-visible { @@ -1221,6 +1253,7 @@ textarea:focus-visible {
.btn-primary:hover {
background: var(--link-hover);
color: #1a1a1a;
}
.btn-secondary {
@ -1265,6 +1298,52 @@ textarea:focus-visible { @@ -1265,6 +1298,52 @@ textarea:focus-visible {
}
/* E-Books page styles */
.ebooks-page {
max-width: 1000px;
margin: 0 auto;
}
.feed-about-blurb {
background: var(--bg-secondary);
padding: 1.5rem;
border-radius: 8px;
border: 1px solid var(--border-color);
margin-bottom: 2rem;
}
.feed-about-blurb h2 {
color: var(--text-primary);
margin-bottom: 1rem;
font-size: 1.5rem;
}
.feed-about-blurb p {
margin-bottom: 1rem;
line-height: 1.6;
}
.feed-about-blurb ul {
margin-left: 1.5rem;
margin-top: 0.5rem;
margin-bottom: 1rem;
}
.feed-about-blurb li {
margin-bottom: 0.5rem;
}
.feed-about-blurb code {
background: var(--bg-primary);
padding: 0.2rem 0.4rem;
border-radius: 4px;
font-family: 'Courier New', monospace;
color: var(--accent-color);
}
.feed-page .feed-container {
margin-top: 2rem;
}
.ebooks-page {
max-width: 1200px;
margin: 0 auto;

13
templates/base.html

@ -48,11 +48,16 @@ @@ -48,11 +48,16 @@
<ul class="nav-menu">
<li><a href="/"><span class="icon-inline">{{icon "home"}}</span> Home</a></li>
<li><a href="/wiki"><span class="icon-inline">{{icon "book-open"}}</span> Project Wiki</a></li>
<li><a href="/blog"><span class="icon-inline">{{icon "file-text"}}</span> Project Blog</a></li>
<li><a href="/articles"><span class="icon-inline">{{icon "file-text"}}</span> TheForest Articles</a></li>
<li><a href="/ebooks"><span class="icon-inline">{{icon "book"}}</span> TheForest E-Books</a></li>
<li class="nav-separator">|</li>
<li class="nav-section-label">The Company:</li>
<li><a href="/wiki"><span class="icon-inline">{{icon "book-open"}}</span> Wiki</a></li>
<li><a href="/blog"><span class="icon-inline">{{icon "file-text"}}</span> Blog</a></li>
<li><a href="/contact"><span class="icon-inline">{{icon "mail"}}</span> Contact Us</a></li>
<li class="nav-separator">|</li>
<li class="nav-section-label">TheForest Relay:</li>
<li><a href="/feed"><span class="icon-inline">{{icon "rss"}}</span> Feed</a></li>
<li><a href="/articles"><span class="icon-inline">{{icon "file-text"}}</span> Articles</a></li>
<li><a href="/ebooks"><span class="icon-inline">{{icon "book"}}</span> E-Books</a></li>
</ul>
</div>
</nav>

23
templates/feed.html

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
{{define "content"}}
<article class="feed-page">
<header class="page-header">
<h1><span class="icon-inline">{{icon "rss"}}</span> TheForest Feed</h1>
<p class="page-summary">Recent notes from TheForest relay</p>
</header>
<div class="feed-about-blurb">
<h2>About TheForest Relay</h2>
<p>TheForest is a Nostr relay operated by GitCitadel. It provides a reliable, fast, and open relay service for the Nostr protocol.</p>
<ul>
<li><strong>Relay URL:</strong> <code>wss://theforest.nostr1.com</code></li>
<li><strong>Status:</strong> Online and operational</li>
<li><strong>Features:</strong> Supports all standard Nostr event kinds</li>
</ul>
<p>TheForest relay hosts a variety of content, including longform markdown articles (kind 30023), e-books and structured publications (kind 30040), and short-form notes (kind 1).</p>
</div>
<div class="feed-container">
{{template "feed" .}}
</div>
</article>
{{end}}

6
templates/landing.html

@ -98,6 +98,12 @@ @@ -98,6 +98,12 @@
</div>
</div>
<div class="feature-card">
<h3><span class="icon-inline">{{icon "rss"}}</span> Feed</h3>
<p>Browse recent notes and updates from TheForest relay.</p>
<a href="/feed" class="btn"><span class="icon-inline">{{icon "arrow-right"}}</span> View Feed</a>
</div>
<div class="feature-card">
<h3><span class="icon-inline">{{icon "book"}}</span> E-Books</h3>
<p>Discover and download e-books from the decentralized #Alexandria library.</p>

Loading…
Cancel
Save