Adding TOS

This commit is contained in:
m15o 2021-12-24 12:27:11 +01:00
parent ae3804bf04
commit f6a50eee26
12 changed files with 40 additions and 95 deletions

3
go.mod
View file

@ -5,10 +5,9 @@ go 1.16
require (
github.com/fogleman/gg v1.3.0
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/gorilla/csrf v1.7.1 // indirect
github.com/gorilla/csrf v1.7.1
github.com/gorilla/mux v1.8.0
github.com/gorilla/sessions v1.2.1
github.com/kr/pretty v0.3.0 // indirect
github.com/lib/pq v1.10.4
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
golang.org/x/image v0.0.0-20211028202545-6944b10bf410

14
go.sum
View file

@ -1,31 +1,19 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/gorilla/csrf v1.7.1 h1:Ir3o2c1/Uzj6FBxMlAUB6SivgVMy1ONXwYgXn+/aHPE=
github.com/gorilla/csrf v1.7.1/go.mod h1:+a/4tCmqhG6/w4oafeAZ9pEa3/NZOWYVbD9fV0FwIQA=
github.com/gorilla/feeds v1.1.1 h1:HwKXxqzcRNg9to+BbvJog4+f3s/xzvtZXICcQGutYfY=
github.com/gorilla/feeds v1.1.1/go.mod h1:Nk0jZrvPFZX1OBe5NPiddPw7CfwF6Q9eqzaBbaightA=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI=
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
@ -37,5 +25,3 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=

View file

@ -75,7 +75,7 @@ func New(cfg *config.Config, sess *session.Session, data *storage.Storage) (http
router.HandleFunc("/current-status.js", h.showCurrentStatusJSView).Methods(http.MethodGet)
router.HandleFunc("/current-status", h.showCurrentStatusView).Methods(http.MethodGet)
router.HandleFunc("/manage", h.showManageView).Methods(http.MethodGet)
router.HandleFunc("/intro", h.showIntroView).Methods(http.MethodGet)
router.HandleFunc("/tos", h.showTOSView).Methods(http.MethodGet)
router.HandleFunc("/about/status-updater", h.showStatusUpdaterView).Methods(http.MethodGet)
router.HandleFunc("/users/{user}.atom", h.showAtomView).Methods(http.MethodGet)
router.HandleFunc("/users/{user}", h.showUserView).Methods(http.MethodGet)

View file

@ -161,10 +161,10 @@ var TplMap = map[string]string{
{{ .csrfField }}
{{ template "status_form" .status }}
</form>
<ul class="tools">
<li><a href="/about/status-updater">status updater</a> bookmarklet</li>
<li><a href="/current-status">status widget</a> for your homepage</li>
</ul>
<p>
<a href="/about/status-updater">status updater</a> bookmarklet<br>
<a href="/current-status">status widget</a> for your homepage
</p>
<p><a href="/feed.atom">Subscribe via Atom</a></p>
{{ else }}
<h2>Welcome!</h2>
@ -184,38 +184,6 @@ var TplMap = map[string]string{
</div>
{{ end }}
`,
"intro": `{{ define "content" }}
<section>
<h1>Introduction</h1>
<p>
Welcome! You've just found a little internet tool that lets you set your current status
and see the status of others.
</p>
<h2>Your status</h2>
<p>
Once you've registered, you will be able to set your current status. A status is anything you are currently doing,
on your mind, or that you think about. It can be your mood, the song you are listening to, the book you are reading, or the new
cool link you've just found. A status has a maximum length of 140 characters and can be updated as often as you'd like.
</p>
<h2>Status updater</h2>
<p>
Use the status updater bookmarklet to update your status from anywhere, and capture all your feelings on your
profile page.
</p>
<h2>Homepage widgets</h2>
<h3>Current Status Widget</h3>
<h3>Status Feed Widget</h3>
<!-- wip -->
<p>Use the current status widget to display your latest status directly on
homepage, or the status feed widget to display the last few ones.
</p>
<p>
Use the status updater bookmarklet to update your status from anywhere, and capture all your feelings on your
profile page, which aggregates all your statuses. You can fully customize it with CSS and HTML. Make it yours!
</p>
</section>
{{ end }}`,
"login": `{{ define "content" }}
<section>
<h1>Login</h1>
@ -232,7 +200,6 @@ var TplMap = map[string]string{
<label for="password">Password</label>
<input type="password" id="password" name="password" required/>
</div>
<br>
<input type="submit" value="Submit">
</form>
</section>
@ -295,6 +262,7 @@ var TplMap = map[string]string{
<label for="answer">How did you discover status.cafe?</label>
<textarea id="answer" name="answer" required></textarea>
</div>
<p>By clicking the following button you agree to our <a href="/tos" target="_blank">Terms of Service</a>.</p>
<input type="submit" value="Submit">
</form>
</section>
@ -372,6 +340,18 @@ var TplMap = map[string]string{
</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>
{{ end }}`,
"tos": `{{ define "content" }}
<section>
<h1>Terms of service</h1>
<p>In order to use Status Cafe, you must agree to the following rules. A user not respecting these rules will have their account removed and will be banned from the service. The general rule is to be nice, friendly and respectful to anyone and their status.</p>
<p><b>Racist, bigoted or otherwise hate speech</b> is not permitted. Status Cafe is an inclusive place that will not tolerate anyone promoting hateful ideas and language.</p>
<p><b>Illegal activities</b> such as promoting malware, phishing or publishing something that promotes content that infringes copyright, patent or trademark you do not own is not permitted.</p>
<p><b>Pornographic content</b> is not allowed.</p>
<p><b>Spamming</b>, including unsolicited advertising isn't allowed. While it's perfectly fine to talk about your projects and link them, using Status Cafe only as a way to drive traffic to an external site isn't allowed.</p>
<p><b>Harassing</b>, bullying, picking on a user isn't permitted.</p>
<p><b>Revealing information (doxing)</b> from a user isn't allowed.</p>
</section>
{{ end }}`,
"user": `{{ define "head" }}
<link rel="alternate" type="application/atom+xml" title="Atom feed" href="/users/{{ .user }}.atom" />

View file

@ -10,10 +10,10 @@
{{ .csrfField }}
{{ template "status_form" .status }}
</form>
<ul class="tools">
<li><a href="/about/status-updater">status updater</a> bookmarklet</li>
<li><a href="/current-status">status widget</a> for your homepage</li>
</ul>
<p>
<a href="/about/status-updater">status updater</a> bookmarklet<br>
<a href="/current-status">status widget</a> for your homepage
</p>
<p><a href="/feed.atom">Subscribe via Atom</a></p>
{{ else }}
<h2>Welcome!</h2>

View file

@ -1,32 +0,0 @@
{{ define "content" }}
<section>
<h1>Introduction</h1>
<p>
Welcome! You've just found a little internet tool that lets you set your current status
and see the status of others.
</p>
<h2>Your status</h2>
<p>
Once you've registered, you will be able to set your current status. A status is anything you are currently doing,
on your mind, or that you think about. It can be your mood, the song you are listening to, the book you are reading, or the new
cool link you've just found. A status has a maximum length of 140 characters and can be updated as often as you'd like.
</p>
<h2>Status updater</h2>
<p>
Use the status updater bookmarklet to update your status from anywhere, and capture all your feelings on your
profile page.
</p>
<h2>Homepage widgets</h2>
<h3>Current Status Widget</h3>
<h3>Status Feed Widget</h3>
<!-- wip -->
<p>Use the current status widget to display your latest status directly on
homepage, or the status feed widget to display the last few ones.
</p>
<p>
Use the status updater bookmarklet to update your status from anywhere, and capture all your feelings on your
profile page, which aggregates all your statuses. You can fully customize it with CSS and HTML. Make it yours!
</p>
</section>
{{ end }}

View file

@ -14,7 +14,6 @@
<label for="password">Password</label>
<input type="password" id="password" name="password" required/>
</div>
<br>
<input type="submit" value="Submit">
</form>
</section>

View file

@ -30,6 +30,7 @@
<label for="answer">How did you discover status.cafe?</label>
<textarea id="answer" name="answer" required></textarea>
</div>
<p>By clicking the following button you agree to our <a href="/tos" target="_blank">Terms of Service</a>.</p>
<input type="submit" value="Submit">
</form>
</section>

12
web/handler/html/tos.html Normal file
View file

@ -0,0 +1,12 @@
{{ define "content" }}
<section>
<h1>Terms of service</h1>
<p>In order to use Status Cafe, you must agree to the following rules. A user not respecting these rules will have their account removed and will be banned from the service. The general rule is to be nice, friendly and respectful to anyone and their status.</p>
<p><b>Racist, bigoted or otherwise hate speech</b> is not permitted. Status Cafe is an inclusive place that will not tolerate anyone promoting hateful ideas and language.</p>
<p><b>Illegal activities</b> such as promoting malware, phishing or publishing something that promotes content that infringes copyright, patent or trademark you do not own is not permitted.</p>
<p><b>Pornographic content</b> is not allowed.</p>
<p><b>Spamming</b>, including unsolicited advertising isn't allowed. While it's perfectly fine to talk about your projects and link them, using Status Cafe only as a way to drive traffic to an external site isn't allowed.</p>
<p><b>Harassing</b>, bullying, picking on a user isn't permitted.</p>
<p><b>Revealing information (doxing)</b> from a user isn't allowed.</p>
</section>
{{ end }}

View file

@ -2,9 +2,9 @@ package handler
import "net/http"
func (h *Handler) showIntroView(w http.ResponseWriter, r *http.Request) {
func (h *Handler) showTOSView(w http.ResponseWriter, r *http.Request) {
user, _ := h.getUser(r)
h.renderLayout(w, "intro", nil, user)
h.renderLayout(w, "tos", nil, user)
}
func (h *Handler) showStatusUpdaterView(w http.ResponseWriter, r *http.Request) {

View file

@ -16,7 +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

@ -19,6 +19,6 @@ func Serve(data *storage.Storage, cfg *config.Config) error {
log.Fatal(err)
}
fmt.Printf("Starting HTTP server on port 8000\n")
err = http.ListenAndServe(":8000", csrf.Protect([]byte("32-byte-long-auth-key"))(s))
err = http.ListenAndServe(":8000", csrf.Protect([]byte("32-byte-long-auth-key"), csrf.MaxAge(0))(s))
return err
}