Browse Source

some style

master
2577 3 years ago
parent
commit
e43ec0548d
  1. 39
      index.html
  2. 7
      main.go
  3. 59
      static/style.css

39
index.html

@ -3,21 +3,40 @@
<title>Fahrenheit 2577</title>
<link rel="icon" type="image/png" href="favicon.png">
<link rel="alternative" type="application/rss+xml" href="feed.xml">
<link rel="stylesheet" type="text/css" href="static/style.css">
</head>
<body>
<h1>The temperature at which silicon burns...</h1>
<img src="https://sindominio.net/2577/2577.png" alt="2577" />
<a href="https://sindominio.net/2577/feed.xml">RSS feed</a>
<div class="wrap">
<div class="floatleft">
<div id="left-container">
<div>
<h1>Fahrenheit 2577</h1>
<img src="https://sindominio.net/2577/2577.png" alt="2577" />
</div>
<div id="rss-box">
<h2><a href="https://sindominio.net/2577/feed.xml">subscribe</a></h2>
</div>
</div>
</div>
<div class="floatright">
{{range $item := .}}
<article>
<div>
<a href="{{ $item.URL }}">{{ $item.Title }}</a>
<span class="url"> {{ $item.URL }}</span>
</div>
<div>
<span class="date">{{ $item.Date.Format "2006 Jan 02" }}</span>
</div>
</article>
{{end}}
</div>
</div>
<h2>The latest news from our dystopian present</h2>
<article>
{{range $item := .}}
<h3><a href="{{ $item.URL }}">{{ $item.Title }}</a></h3>
<p>{{ $item.Date.Format "2006 Jan 02" }} - {{ $item.URL }}</p>
{{end}}
</article>
</body>
</html>

7
main.go

@ -23,12 +23,17 @@ func (s *serve) htmlHandler(w http.ResponseWriter, req *http.Request) {
log.Printf("Serve html")
items := s.feed.items()
index := template.Must(template.ParseFiles("index.html"))
if index == nil {
log.Printf("Error parsing template!")
return
}
index.Execute(w, items)
log.Printf("Rendered %v items", len(items))
}
func (s *serve) postHandler(w http.ResponseWriter, req *http.Request) {
if req.Method == "GET" {
log.Printf("GET...")
s.htmlHandler(w, req)
return
}
@ -63,8 +68,10 @@ func main() {
}
defer f.close()
staticServer := http.FileServer(http.Dir("./static"))
s := serve{f, *token}
mux := http.NewServeMux()
mux.Handle("/static/", http.StripPrefix("/static", staticServer))
mux.HandleFunc("/rss", s.rssHandler)
mux.HandleFunc("/", s.postHandler)
log.Fatal(http.ListenAndServe(":2577", mux))

59
static/style.css

@ -0,0 +1,59 @@
body {
font-family: sans-serif;
}
.wrap {
width: 100%;
}
.floatleft {
float:left;
width: 40%;
height: 100%;
position: fixed;
}
.floatleft a {
text-decoration: none;
}
.floatleft a:hover {
color: grey;
}
#left-container {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
}
.floatright {
float: right;
background-color: #ffffff;
width: 60%;
}
a {
color: black;
}
article > div > a {
font-size: 200%;
font-weight: bold;
text-decoration: none;
}
article > div > a:hover {
color: #f24c2f;
}
.url {
color: grey;
}
.date {
color: grey;
font-size: 80%;
}
Loading…
Cancel
Save