Disable sign-up by default, enable by new --signup flag.
このコミットが含まれているのは:
コミット
6191847ed5
13
README.md
13
README.md
|
@ -64,17 +64,22 @@ This is [a common privilege problem](http://stackoverflow.com/q/413807) and
|
|||
|
||||
sudo setcap 'cap_net_bind_service=+ep' $GOPATH/bin/htwtxt
|
||||
|
||||
### Changing HTML templates
|
||||
### Opening up sign-up
|
||||
|
||||
By default, HTML templates are read out of `$GOPATH/src/htwtxt/templates/`. An
|
||||
alternate directory can be given with the flag `--templates` (it should contain
|
||||
template files of the same names as the default ones, however).
|
||||
By default, sign up / account creation is not open to the public. The `--signup`
|
||||
flag must be set explicitely to change that.
|
||||
|
||||
### Setting site owner contact info
|
||||
|
||||
The server serves a `/info` page (from the `info.html` template) that may
|
||||
include the site owner's contact info, as given with the `--info` flag.
|
||||
|
||||
### Changing HTML templates
|
||||
|
||||
By default, HTML templates are read out of `$GOPATH/src/htwtxt/templates/`. An
|
||||
alternate directory can be given with the flag `--templates` (it should contain
|
||||
template files of the same names as the default ones, however).
|
||||
|
||||
## Copyright, license
|
||||
|
||||
htwtxt (c) 2016 Christian Heller a.k.a. plomlompom
|
||||
|
|
12
main.go
12
main.go
|
@ -25,6 +25,7 @@ var feedsPath string
|
|||
var templPath string
|
||||
var templ *template.Template
|
||||
var contactString string
|
||||
var signupOpen bool
|
||||
|
||||
func createFileIfNotExists(path string) {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
|
@ -149,10 +150,19 @@ func infoHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func signUpFormHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if !signupOpen {
|
||||
execTemplate(w, "nosignup.html", "")
|
||||
return
|
||||
}
|
||||
execTemplate(w, "signupform.html", "")
|
||||
}
|
||||
|
||||
func signUpHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if !signupOpen {
|
||||
execTemplate(w, "error.html",
|
||||
"Account creation currently not allowed.")
|
||||
return
|
||||
}
|
||||
newLine, err := accountLine(w, r, true)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -268,6 +278,8 @@ func main() {
|
|||
flag.StringVar(&contactString, "contact",
|
||||
"[operator passed no contact info to server]",
|
||||
"operator contact info to display on info page")
|
||||
flag.BoolVar(&signupOpen, "signup", false,
|
||||
"enable on-site account creation")
|
||||
flag.Parse()
|
||||
log.Println("Using as templates dir:", templPath)
|
||||
log.Println("Using as data dir:", dataDir)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{{ template "header" }}
|
||||
<section>
|
||||
<h2>Account creation closed</h2>
|
||||
<p>The site operator has not decided to open up account creation on this site for the public.</p>
|
||||
</section>
|
||||
{{ template "footer" }}
|
読み込み中…
新しいイシューから参照