Finishing up

This commit is contained in:
m15o 2021-12-04 16:22:30 +01:00
parent 07538e4011
commit 64c8ee3042
16 changed files with 206 additions and 173 deletions

View file

@ -7,20 +7,35 @@ body {
color: midnightblue;
}
/*section {*/
/* padding: 1em;*/
/* background-color: lightblue;*/
/*}*/
.faces {
margin-bottom: 1em;
max-width: 500px;
}
.flash {
background-color: lightgreen;
padding: 0.5em 1em;
color: darkgreen;
animation: 500ms ease-out 3s 1 forwards fadeout;
}
@keyframes fadeout {
0% {
opacity: 1;
}
99% {
opacity: 0;
font-size: inherit;
height: inherit;
}
100% {
font-size: 0;
height: 0;
}
}
.cols {
display: grid;
row-gap: 1em;
}
a {
@ -52,13 +67,9 @@ dd {
margin-bottom: 1em;
}
/*nav {*/
/* margin-bottom: 1em;*/
/*}*/
/*h1, h2 {*/
/* !*margin-top: 0;*!*/
/*}*/
.edit-status {
width: 100%; box-sizing: border-box; height: 100px;
}
.tools {
list-style-position: inside;

View file

@ -22,7 +22,7 @@ var TplCommonMap = map[string]string{
<body>
<header>
<nav>
<a href="/">status.cafe</a> <a href="/intro">intro</a>
<a href="/">status.cafe</a>
{{ if .logged }}
<a href="/settings">settings</a> <a href="/users/{{ .logged }}">{{ .logged }}</a> (<a href="/logout">logout</a>)
{{ else }}
@ -46,7 +46,7 @@ var TplCommonMap = map[string]string{
<p class="status-content">{{ .Content }}</p>
{{ end }}`,
"status_form": `{{ define "status_form" }}
<div style="margin-bottom: 1em">
<div class="faces">
{{ range $i, $v := faces }}
<div class="radio">
<input
@ -64,7 +64,7 @@ var TplCommonMap = map[string]string{
{{ end }}
</div>
<div class="field">
<textarea name="content" maxlength="140" placeholder="What's new?" required style="width: 100%; box-sizing: border-box; height: 100px;" autofocus>{{ .Content }}</textarea>
<textarea class="edit-status" name="content" maxlength="140" placeholder="What's new?" required autofocus>{{ .Content }}</textarea>
</div>
<input type="submit" value="Submit">
{{ end }}`,

View file

@ -23,7 +23,7 @@ var TplMap = map[string]string{
<meta name="description" content="your friends' updates">
<style>
body {
background-color: lightblue;
background-color: azure;
font-family: Verdana;
}
</style>
@ -63,19 +63,29 @@ var TplMap = map[string]string{
<style>
#statuscafe {
padding: .5em;
background-color: lightblue;
border: 1px solid;
background-color: azure;
border: 1px solid midnightblue;
}
#statuscafe-username {
margin-bottom: .5em;
}
#statuscafe-content {
margin: 0 1em 0.5em 1em;
}
@media (min-width: 650px) {
.cols {
grid-template-columns: 1fr 1fr;
grid-gap: 2em;
}
}
</style>
<div class="cols">
<section>
<h1>Current Status Widget</h1>
<div>
<h1>Status widget</h1>
<form method="get" action="/current-status">
<table>
<tr>
@ -89,47 +99,46 @@ var TplMap = map[string]string{
</table>
</form>
<p>Past this code into your HTML file:</p>
<textarea style="width: 100%; height: 75px;"><script src="https://status.cafe/current-status.js?name={{ .name }}"></script></textarea>
<textarea style="width: 100%; max-width: 500px; height: 75px;"><script src="https://status.cafe/current-status.js?name={{ .name }}"></script></textarea>
<p>Past this code into your CSS file:</p>
<textarea style="width: 100%; height: 75px;">#statuscafe {
<textarea style="width: 100%; max-width: 500px; height: 175px;">#statuscafe {
padding: .5em;
background-color: lightblue;
border: 1px solid;
background-color: azure;
border: 1px solid midnightblue;
}
#statuscafe-username {
margin-bottom: .5em;
}
#statuscafe-content {
margin: 0 1em 0.5em 1em;
}
</textarea>
}</textarea>
<p>Make it your own! The CSS above is only an example. Tweak it so that it integrates well with your sites's colors.</p>
</section>
<section>
</div>
<div>
<h2>Preview</h2>
{{ if .name }}
<script src="https://status.cafe/current-status.js?name={{ .name }}"></script>
{{ else }}
<p>Add your name and click "generate HTML" to see a preview.</p>
{{ end }}
</section>
</div>
</div>
{{ end }}`,
{{ end }}
`,
"edit_status": `{{ define "content" }}
<section>
<h1>Edit status</h1>
{{ if .form.Error }}
<p>{{ .form.Error }}</p>
{{ end }}
{{ template "flash" .flash }}
<form action="/edit?id={{ .status.Id }}" method="post">
{{ template "status_form" .status }}
</form>
</section>
<h1>Edit status</h1>
{{ if .form.Error }}
<p>{{ .form.Error }}</p>
{{ end }}
{{ template "flash" .flash }}
<form action="/edit?id={{ .status.Id }}" method="post">
{{ template "status_form" .status }}
</form>
{{ end }}`,
"index": `{{ define "content" }}
<div class="cols">
<section>
{{ if .logged }}
<h2>Set your status</h2>
{{ if .form.Error }}
<p>{{ .form.Error }}</p>
@ -140,6 +149,11 @@ var TplMap = map[string]string{
<li><a href="/about/status-updater">status updater</a> bookmarklet</li>
<li><a href="/current-status">status widget</a> for your homepage</li>
</ul>
{{ else }}
<h2>Welcome!</h2>
<p>status.cafe is a place to share your current status.</p>
<p><a href="/register">Register now!</a></p>
{{ end }}
</section>
<section>
<h2>Status stream</h2>
@ -205,32 +219,30 @@ var TplMap = map[string]string{
</section>
{{ end }}`,
"manage": `{{ define "content" }}
<section>
<h2>Manage statuses</h2>
{{ template "flash" .flash }}
{{ range .statuses }}
<article class="status">
{{ template "status" . }}
{{ if eq $.logged .User }}
<nav><a href="/edit?id={{ .Id }}">Edit</a> <a href="/remove?id={{ .Id }}">Delete</a></nav>
{{ end }}
</article>
<h1>Manage statuses</h1>
{{ template "flash" .flash }}
{{ range .statuses }}
<article class="status">
{{ template "status" . }}
{{ if eq $.logged .User }}
<nav><a href="/edit?id={{ .Id }}">Edit</a> <a href="/remove?id={{ .Id }}">Delete</a></nav>
{{ end }}
{{ if or .showMore (ne 0 .page) }}
<p>
{{ if ne 0 .page }}
{{ if eq 0 .prev_page }}
<a href="manage">Newer statuses</a>
{{ else }}
<a href="manage?page={{ .prev_page }}">Newer statuses</a>
{{ end }}
{{ end }}
{{ if .showMore }}
<a href="manage?page={{ .next_page }}">Older statuses</a>
{{- end }}
</p>
</article>
{{ end }}
{{ if or .showMore (ne 0 .page) }}
<p>
{{ if ne 0 .page }}
{{ if eq 0 .prev_page }}
<a href="manage">Newer statuses</a>
{{ else }}
<a href="manage?page={{ .prev_page }}">Newer statuses</a>
{{ end }}
</section>
{{ end }}
{{ if .showMore }}
<a href="manage?page={{ .next_page }}">Older statuses</a>
{{- end }}
</p>
{{ end }}
{{ end }}`,
"register": `{{ define "content" }}
<section>
@ -257,35 +269,33 @@ var TplMap = map[string]string{
</section>
{{ end }}`,
"settings": `{{ define "content" }}
<section>
<h1>Settings</h1>
{{ if .flash }}
<p>{{ .flash }}</p>
{{ end }}
<p><a href="/manage">Manage statuses</a></p>
<form action="/settings-update" method="post">
<div class="field">
<label for="homepage">homepage</label>
<input type="text" name="homepage" id="homepage" value="{{ .User.Homepage }}" autocomplete="off"/>
</div>
<h1>Settings</h1>
{{ if .flash }}
<p>{{ .flash }}</p>
{{ end }}
<p><a href="/manage">Manage statuses</a></p>
<form action="/settings-update" method="post">
<div class="field">
<label for="homepage">Homepage</label>
<input type="text" name="homepage" id="homepage" value="{{ .User.Homepage }}" autocomplete="off"/>
</div>
<div class="field">
<label for="email">Email</label>
<input type="text" name="email" id="email" value="{{ .User.Email }}" autocomplete="off"/>
</div>
<div class="field">
<label for="email">Email</label>
<input type="text" name="email" id="email" value="{{ .User.Email }}" autocomplete="off"/>
</div>
<div class="field">
<label for="picture">picture URL</label>
<input type="text" name="picture" id="picture" value="{{ .User.Picture }}" autocomplete="off"/>
</div>
<div class="field">
<label for="picture">Picture URL</label>
<input type="text" name="picture" id="picture" value="{{ .User.Picture }}" autocomplete="off"/>
</div>
<div class="field">
<label for="about">about</label>
<textarea name="about" id="about" rows="20">{{ .User.About }}</textarea>
</div>
<input type="submit" value="Submit">
</form>
</section>
<div class="field">
<label for="about">About (accepts HTML, including a style tag)</label>
<textarea name="about" id="about" rows="20">{{ .User.About }}</textarea>
</div>
<input type="submit" value="Submit">
</form>
{{ end }}`,
"status-updater": `{{ define "content" }}
<section>
@ -304,7 +314,7 @@ var TplMap = map[string]string{
Drag the following link to your bookmarks toolbar:
</p>
<p>
<a href="javascript:void(open('https://status.cafe/add','status.cafe','resizable,scrollbars,width=360,height=200'))">status updater</a>
<a href="javascript:void(open('https://status.cafe/add','status.cafe','resizable,scrollbars,width=350,height=250'))">status updater</a>
</p>
<p>That's it! From now on, whenever you want to update your status, click the status updater button from your bookmarks and a pop-up window will launch to let you update it.</p>
</section>
@ -320,6 +330,7 @@ var TplMap = map[string]string{
{{ if .picture }}
<img src="{{ .picture }}" width="100" class="profile-picture"/>
{{ end }}
<p><a href="/users/{{ .user }}.atom">Subscribe via Atom</a></p>
<dl>
<dt>Homepage</dt>
<dd>

View file

@ -12,7 +12,7 @@
<body>
<header>
<nav>
<a href="/">status.cafe</a> <a href="/intro">intro</a>
<a href="/">status.cafe</a>
{{ if .logged }}
<a href="/settings">settings</a> <a href="/users/{{ .logged }}">{{ .logged }}</a> (<a href="/logout">logout</a>)
{{ else }}

View file

@ -1,5 +1,5 @@
{{ define "status_form" }}
<div style="margin-bottom: 1em">
<div class="faces">
{{ range $i, $v := faces }}
<div class="radio">
<input
@ -17,7 +17,7 @@
{{ end }}
</div>
<div class="field">
<textarea name="content" maxlength="140" placeholder="What's new?" required style="width: 100%; box-sizing: border-box; height: 100px;" autofocus>{{ .Content }}</textarea>
<textarea class="edit-status" name="content" maxlength="140" placeholder="What's new?" required autofocus>{{ .Content }}</textarea>
</div>
<input type="submit" value="Submit">
{{ end }}

View file

@ -8,7 +8,7 @@
<meta name="description" content="your friends' updates">
<style>
body {
background-color: lightblue;
background-color: azure;
font-family: Verdana;
}
</style>

View file

@ -2,19 +2,29 @@
<style>
#statuscafe {
padding: .5em;
background-color: lightblue;
border: 1px solid;
background-color: azure;
border: 1px solid midnightblue;
}
#statuscafe-username {
margin-bottom: .5em;
}
#statuscafe-content {
margin: 0 1em 0.5em 1em;
}
@media (min-width: 650px) {
.cols {
grid-template-columns: 1fr 1fr;
grid-gap: 2em;
}
}
</style>
<div class="cols">
<section>
<h1>Current Status Widget</h1>
<div>
<h1>Status widget</h1>
<form method="get" action="/current-status">
<table>
<tr>
@ -28,29 +38,28 @@
</table>
</form>
<p>Past this code into your HTML file:</p>
<textarea style="width: 100%; height: 75px;"><script src="https://status.cafe/current-status.js?name={{ .name }}"></script></textarea>
<textarea style="width: 100%; max-width: 500px; height: 75px;"><script src="https://status.cafe/current-status.js?name={{ .name }}"></script></textarea>
<p>Past this code into your CSS file:</p>
<textarea style="width: 100%; height: 75px;">#statuscafe {
<textarea style="width: 100%; max-width: 500px; height: 175px;">#statuscafe {
padding: .5em;
background-color: lightblue;
border: 1px solid;
background-color: azure;
border: 1px solid midnightblue;
}
#statuscafe-username {
margin-bottom: .5em;
}
#statuscafe-content {
margin: 0 1em 0.5em 1em;
}
</textarea>
}</textarea>
<p>Make it your own! The CSS above is only an example. Tweak it so that it integrates well with your sites's colors.</p>
</section>
<section>
</div>
<div>
<h2>Preview</h2>
{{ if .name }}
<script src="https://status.cafe/current-status.js?name={{ .name }}"></script>
{{ else }}
<p>Add your name and click "generate HTML" to see a preview.</p>
{{ end }}
</section>
</div>
</div>
{{ end }}
{{ end }}

View file

@ -1,12 +1,10 @@
{{ define "content" }}
<section>
<h1>Edit status</h1>
{{ if .form.Error }}
<p>{{ .form.Error }}</p>
{{ end }}
{{ template "flash" .flash }}
<form action="/edit?id={{ .status.Id }}" method="post">
{{ template "status_form" .status }}
</form>
</section>
<h1>Edit status</h1>
{{ if .form.Error }}
<p>{{ .form.Error }}</p>
{{ end }}
{{ template "flash" .flash }}
<form action="/edit?id={{ .status.Id }}" method="post">
{{ template "status_form" .status }}
</form>
{{ end }}

View file

@ -1,6 +1,7 @@
{{ define "content" }}
<div class="cols">
<section>
{{ if .logged }}
<h2>Set your status</h2>
{{ if .form.Error }}
<p>{{ .form.Error }}</p>
@ -11,6 +12,11 @@
<li><a href="/about/status-updater">status updater</a> bookmarklet</li>
<li><a href="/current-status">status widget</a> for your homepage</li>
</ul>
{{ else }}
<h2>Welcome!</h2>
<p>status.cafe is a place to share your current status.</p>
<p><a href="/register">Register now!</a></p>
{{ end }}
</section>
<section>
<h2>Status stream</h2>

View file

@ -1,28 +1,26 @@
{{ define "content" }}
<section>
<h2>Manage statuses</h2>
{{ template "flash" .flash }}
{{ range .statuses }}
<article class="status">
{{ template "status" . }}
{{ if eq $.logged .User }}
<nav><a href="/edit?id={{ .Id }}">Edit</a> <a href="/remove?id={{ .Id }}">Delete</a></nav>
{{ end }}
</article>
<h1>Manage statuses</h1>
{{ template "flash" .flash }}
{{ range .statuses }}
<article class="status">
{{ template "status" . }}
{{ if eq $.logged .User }}
<nav><a href="/edit?id={{ .Id }}">Edit</a> <a href="/remove?id={{ .Id }}">Delete</a></nav>
{{ end }}
{{ if or .showMore (ne 0 .page) }}
<p>
{{ if ne 0 .page }}
{{ if eq 0 .prev_page }}
<a href="manage">Newer statuses</a>
{{ else }}
<a href="manage?page={{ .prev_page }}">Newer statuses</a>
{{ end }}
{{ end }}
{{ if .showMore }}
<a href="manage?page={{ .next_page }}">Older statuses</a>
{{- end }}
</p>
</article>
{{ end }}
{{ if or .showMore (ne 0 .page) }}
<p>
{{ if ne 0 .page }}
{{ if eq 0 .prev_page }}
<a href="manage">Newer statuses</a>
{{ else }}
<a href="manage?page={{ .prev_page }}">Newer statuses</a>
{{ end }}
</section>
{{ end }}
{{ if .showMore }}
<a href="manage?page={{ .next_page }}">Older statuses</a>
{{- end }}
</p>
{{ end }}
{{ end }}

View file

@ -1,31 +1,29 @@
{{ define "content" }}
<section>
<h1>Settings</h1>
{{ if .flash }}
<p>{{ .flash }}</p>
{{ end }}
<p><a href="/manage">Manage statuses</a></p>
<form action="/settings-update" method="post">
<div class="field">
<label for="homepage">homepage</label>
<input type="text" name="homepage" id="homepage" value="{{ .User.Homepage }}" autocomplete="off"/>
</div>
<h1>Settings</h1>
{{ if .flash }}
<p>{{ .flash }}</p>
{{ end }}
<p><a href="/manage">Manage statuses</a></p>
<form action="/settings-update" method="post">
<div class="field">
<label for="homepage">Homepage</label>
<input type="text" name="homepage" id="homepage" value="{{ .User.Homepage }}" autocomplete="off"/>
</div>
<div class="field">
<label for="email">Email</label>
<input type="text" name="email" id="email" value="{{ .User.Email }}" autocomplete="off"/>
</div>
<div class="field">
<label for="email">Email</label>
<input type="text" name="email" id="email" value="{{ .User.Email }}" autocomplete="off"/>
</div>
<div class="field">
<label for="picture">picture URL</label>
<input type="text" name="picture" id="picture" value="{{ .User.Picture }}" autocomplete="off"/>
</div>
<div class="field">
<label for="picture">Picture URL</label>
<input type="text" name="picture" id="picture" value="{{ .User.Picture }}" autocomplete="off"/>
</div>
<div class="field">
<label for="about">about</label>
<textarea name="about" id="about" rows="20">{{ .User.About }}</textarea>
</div>
<input type="submit" value="Submit">
</form>
</section>
<div class="field">
<label for="about">About (accepts HTML, including a style tag)</label>
<textarea name="about" id="about" rows="20">{{ .User.About }}</textarea>
</div>
<input type="submit" value="Submit">
</form>
{{ end }}

View file

@ -15,7 +15,7 @@
Drag the following link to your bookmarks toolbar:
</p>
<p>
<a href="javascript:void(open('https://status.cafe/add','status.cafe','resizable,scrollbars,width=360,height=200'))">status updater</a>
<a href="javascript:void(open('https://status.cafe/add','status.cafe','resizable,scrollbars,width=350,height=250'))">status updater</a>
</p>
<p>That's it! From now on, whenever you want to update your status, click the status updater button from your bookmarks and a pop-up window will launch to let you update it.</p>
</section>

View file

@ -9,6 +9,7 @@
{{ if .picture }}
<img src="{{ .picture }}" width="100" class="profile-picture"/>
{{ end }}
<p><a href="/users/{{ .user }}.atom">Subscribe via Atom</a></p>
<dl>
<dt>Homepage</dt>
<dd>

View file

@ -16,8 +16,7 @@ func (h *Handler) initTpl() {
for name, content := range TplMap {
views[name] = template.Must(template.New("main").Funcs(template.FuncMap{
"faces": func() []string {
return []string{"☕", "🙂", "🙃", "😇", "😋", "😐", "😴", "😎", "🤓", "🧐", "😭", "😡", "💀", "🤖",
"🍺", "🍷"}
return []string{"🙂", "😎", "😛", "🥰", "👽", "😱", "🤔", "😯", "🤒", "😡", "🥺", "🥳", "🤖", "💀", "😴", "😭", "☕", "🍺"}
}}).Parse(commonTemplates + content))
}
}

View file

@ -92,6 +92,7 @@ func (h *Handler) showUserView(w http.ResponseWriter, r *http.Request) {
type statusjson struct {
Author string `json:"author"`
Content string `json:"content"`
Face string `json:"face"`
TimeAgo string `json:"timeAgo"`
}
@ -112,6 +113,7 @@ func (h *Handler) showUserStatusView(w http.ResponseWriter, r *http.Request) {
if len(statuses) > 0 {
res.Author = statuses[0].User
res.Content = statuses[0].Content
res.Face = statuses[0].Face
res.TimeAgo = statuses[0].TimeAgo()
}
json.NewEncoder(w).Encode(res)

View file

@ -15,7 +15,7 @@ fetch("https://status.cafe/users/` + name + `/status.json")
document.getElementById("statuscafe-content").innerHTML = "No status yet."
return
}
document.getElementById("statuscafe-username").innerHTML = '<a href="https://status.cafe/users/` + name + `">' + r.author + '</a>, ' + r.timeAgo
document.getElementById("statuscafe-username").innerHTML = '<a href="https://status.cafe/users/` + name + `">' + r.author + '</a> ' + r.face + ' ' + r.timeAgo
document.getElementById("statuscafe-content").innerHTML = r.content
})
`))