a lot of ui cleaning up, extending csrf time, adding csrf logging errors to screen

This commit is contained in:
Dan Ballard 2015-12-25 09:07:03 -08:00
parent 9f5cd7e5d8
commit 015d6fa86d
5 changed files with 19 additions and 10 deletions

View File

@ -18,11 +18,14 @@ go get github.com/dballard/transmet
sudo apt-get install postgres postgresql-contrib sudo apt-get install postgres postgresql-contrib
Setup postgres to hadle a local connection for transmet in pg_hba.conf Setup postgres to handle a local connection for transmet in pg_hba.conf
either: either:
'''host transmet transmet 127.0.0.1/32 md5''' '''host transmet transmet 127.0.0.1/32 md5'''
or a more liberal: or a more liberal:
'''host all all 127.0.0.1/32 md5 ''' '''host all all 127.0.0.1/32 md5 '''
and do the same for
'''host all all ::1/128 md5'''
ipv6
create ssl certs and put them somewhere create ssl certs and put them somewhere
@ -36,7 +39,7 @@ ssl_key_file = 'WHERE_YOU_PUT/server.key'
Create postgress DB and user Create postgress DB and user
'''sh '''sh
sudo -u postgres sudo -u postgres --or-- sudo su - postgres
createuser -S -P -E transmet createuser -S -P -E transmet
createdb --owner transmet --encoding utf8 transmet createdb --owner transmet --encoding utf8 transmet
psql psql

View File

@ -23,7 +23,7 @@ body {
/* Not required for template or sticky footer method. */ /* Not required for template or sticky footer method. */
body > .container { body > .container {
padding: 60px 15px 0; padding: 0px 15px 0;
} }
.container .text-muted { .container .text-muted {
margin: 20px 0; margin: 20px 0;

View File

@ -104,14 +104,15 @@ func main() {
dbConnect() dbConnect()
initTemplates() initTemplates()
muxRouter := init_route_handlers() muxRouter := init_route_handlers()
//errHandler := csrf.ErrorHandler( CSRFErrorHandler{} ) errHandler := csrf.ErrorHandler( CSRFErrorHandler{} )
// Terrible. TODO: Get SSL for prod, and then wrap in if(dev) { { // Terrible. TODO: Get SSL for prod, and then wrap in if(dev) { {
csrfSecurityOption := csrf.Secure(false) csrfSecurityOption := csrf.Secure(false)
csrfMaxTimeOption := csrf.MaxAge(3600 * 24 * 3) // 3 Days - a little more wiggle room
fmt.Println("Listening on", config.Port, "...") fmt.Println("Listening on", config.Port, "...")
err := http.ListenAndServe(":"+config.Port, csrf.Protect([]byte(csrfSecret()) /*errHandler,*/, csrfSecurityOption)(muxRouter)) err := http.ListenAndServe(":"+config.Port, csrf.Protect([]byte(csrfSecret()), errHandler, csrfSecurityOption, csrfMaxTimeOption)(muxRouter))
if err != nil { if err != nil {
fmt.Println("Fatal Error: ", err) fmt.Println("Fatal Error: ", err)
} }

View File

@ -145,9 +145,16 @@ func addFormHandler(w http.ResponseWriter, r *http.Request, user *user.User, ses
title = getUrlTitle(url) title = getUrlTitle(url)
} }
var notes = ""
selection := r.URL.Query().Get("selection")
if selection != "" {
notes = "<quote>" + selection + "</quote>"
}
popup := r.URL.Query().Get("popup") popup := r.URL.Query().Get("popup")
ShowTemplate("post", w, r, map[string]interface{}{"mode": "add", "user": user, "flashes": flashes, "link": url, "categories": categories.CategoriesTree, "title": title, "popup": popup, "category_id": -1}) ShowTemplate("post", w, r, map[string]interface{}{"mode": "add", "user": user, "flashes": flashes, "link": url, "categories": categories.CategoriesTree, "title": title, "popup": popup, "category_id": -1, "notes": notes})
} }
func addPostHandler(w http.ResponseWriter, r *http.Request, user *user.User, session *sessions.Session) { func addPostHandler(w http.ResponseWriter, r *http.Request, user *user.User, session *sessions.Session) {

View File

@ -7,7 +7,7 @@
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6">
Drag this link to bookmark bar and click anywhere to add a link Drag this bookmarklet to bookmark bar and click anywhere to add a link
</div> </div>
<div class="col-xs-4"></div> <div class="col-xs-4"></div>
<div class="col-xs-12">&nbsp;</div> <div class="col-xs-12">&nbsp;</div>
@ -54,6 +54,4 @@
{{end}} {{end}}
<!-- JS for the launcher of the add bookmarklet --> <!-- JS for the launcher of the add bookmarklet -->
{{define "launch-add"}} {{define "launch-add"}}javascript:(function() { var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='{{.url}}/news/add',l=d.location,e=encodeURIComponent,u=f+'?popup=1&url='+e(l.href)+'&title='+e(d.title)+'&selection='+e(s);a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=480'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0) })();{{end}}
javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='{{.url}}/news/add',l=d.location,e=encodeURIComponent,u=f+'?popup=1&url='+e(l.href)+'&title='+e(d.title);a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=410'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)
{{end}}