Fixed topic creation.
Fixed a text overflow bug. Fixed a newline formatting bug. Fixed an avatar rendering bug.
This commit is contained in:
parent
7a49ff5194
commit
2c6a20f259
10
src/main.go
10
src/main.go
|
@ -57,25 +57,25 @@ func init_database(err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing create_topic statement.")
|
log.Print("Preparing create_topic statement.")
|
||||||
create_topic_stmt, err = db.Prepare("INSERT INTO topics(title,createdAt,lastReplyAt,createdBy) VALUES(?,?,0,?)")
|
create_topic_stmt, err = db.Prepare("INSERT INTO topics(title,content,parsed_content,createdAt,createdBy) VALUES(?,?,?,NOW(),?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing create_reply statement.")
|
log.Print("Preparing create_reply statement.")
|
||||||
create_reply_stmt, err = db.Prepare("INSERT INTO replies(tid,content,createdAt,createdBy) VALUES(?,?,?,?)")
|
create_reply_stmt, err = db.Prepare("INSERT INTO replies(tid,content,parsed_content,createdAt,createdBy) VALUES(?,?,?,NOW(),?)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing edit_topic statement.")
|
log.Print("Preparing edit_topic statement.")
|
||||||
edit_topic_stmt, err = db.Prepare("UPDATE topics SET title = ?, content = ?, is_closed = ? WHERE tid = ?")
|
edit_topic_stmt, err = db.Prepare("UPDATE topics SET title = ?, content = ?, parsed_content = ?, is_closed = ? WHERE tid = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Preparing edit_reply statement.")
|
log.Print("Preparing edit_reply statement.")
|
||||||
edit_reply_stmt, err = db.Prepare("UPDATE replies SET content = ? WHERE rid = ?")
|
edit_reply_stmt, err = db.Prepare("UPDATE replies SET content = ?, parsed_content = ? WHERE rid = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ func main(){
|
||||||
//http.HandleFunc("/user/edit/", route_logout)
|
//http.HandleFunc("/user/edit/", route_logout)
|
||||||
http.HandleFunc("/user/edit/critical/", route_account_own_edit_critical) // Password & Email
|
http.HandleFunc("/user/edit/critical/", route_account_own_edit_critical) // Password & Email
|
||||||
http.HandleFunc("/user/edit/critical/submit/", route_account_own_edit_critical_submit)
|
http.HandleFunc("/user/edit/critical/submit/", route_account_own_edit_critical_submit)
|
||||||
http.HandleFunc("/user/edit/avatar/", route_account_own_edit_avatar) // Password & Email
|
http.HandleFunc("/user/edit/avatar/", route_account_own_edit_avatar)
|
||||||
http.HandleFunc("/user/edit/avatar/submit/", route_account_own_edit_avatar_submit)
|
http.HandleFunc("/user/edit/avatar/submit/", route_account_own_edit_avatar_submit)
|
||||||
//http.HandleFunc("/user/:id/edit/", route_logout)
|
//http.HandleFunc("/user/:id/edit/", route_logout)
|
||||||
//http.HandleFunc("/user/:id/ban/", route_logout)
|
//http.HandleFunc("/user/:id/ban/", route_logout)
|
||||||
|
|
|
@ -63,7 +63,7 @@ $(document).ready(function(){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var block_parent = $(this).closest('.editable_parent');
|
var block_parent = $(this).closest('.editable_parent');
|
||||||
var block = block_parent.find('.editable_block').eq(0);
|
var block = block_parent.find('.editable_block').eq(0);
|
||||||
block.html("<textarea style='width: 100%;' name='edit_item'>" + block.html() + "</textarea><br /><a href='" + $(this).closest('a').attr("href") + "'><button class='submit_edit' type='submit'>Update</button></a>");
|
block.html("<textarea style='width: 99%;' name='edit_item'>" + block.html() + "</textarea><br /><a href='" + $(this).closest('a').attr("href") + "'><button class='submit_edit' type='submit'>Update</button></a>");
|
||||||
|
|
||||||
$(".submit_edit").click(function(event)
|
$(".submit_edit").click(function(event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
body
|
body
|
||||||
{
|
{
|
||||||
font-family: arial;
|
font-family: arial;
|
||||||
|
@ -10,7 +16,7 @@ ul
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
padding-left: 0px;
|
padding-left: 0px;
|
||||||
padding-right: 0px;
|
padding-right: 0px;
|
||||||
height: 18px;
|
height: 28px;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,6 +80,7 @@ li:not(:last-child)
|
||||||
padding-top: 0px;
|
padding-top: 0px;
|
||||||
width: 65%;
|
width: 65%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
.colblock_left:empty
|
.colblock_left:empty
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package main
|
package main
|
||||||
|
import "html/template"
|
||||||
|
|
||||||
type Reply struct
|
type Reply struct
|
||||||
{
|
{
|
||||||
ID int
|
ID int
|
||||||
ParentID int
|
ParentID int
|
||||||
Content string
|
Content string
|
||||||
|
ContentHtml template.HTML
|
||||||
CreatedBy int
|
CreatedBy int
|
||||||
CreatedByName string
|
CreatedByName string
|
||||||
CreatedAt string
|
CreatedAt string
|
||||||
LastEdit int
|
LastEdit int
|
||||||
LastEditBy int
|
LastEditBy int
|
||||||
Avatar string
|
Avatar string
|
||||||
HasAvatar bool
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ import "strconv"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
import "regexp"
|
import "regexp"
|
||||||
import "strings"
|
import "strings"
|
||||||
import "time"
|
|
||||||
import "io"
|
import "io"
|
||||||
import "os"
|
import "os"
|
||||||
import "net/http"
|
import "net/http"
|
||||||
import "html"
|
import "html"
|
||||||
|
import "html/template"
|
||||||
import "database/sql"
|
import "database/sql"
|
||||||
import _ "github.com/go-sql-driver/mysql"
|
import _ "github.com/go-sql-driver/mysql"
|
||||||
import "golang.org/x/crypto/bcrypt"
|
import "golang.org/x/crypto/bcrypt"
|
||||||
|
@ -94,20 +94,18 @@ func route_topics(w http.ResponseWriter, r *http.Request){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
pi := Page{"Topic List","topics",user,topicList,0}
|
pi := Page{"Topic List","topics",user,topicList,0}
|
||||||
templates.ExecuteTemplate(w,"topics.html", pi)
|
err = templates.ExecuteTemplate(w,"topics.html", pi)
|
||||||
|
if err != nil {
|
||||||
|
InternalError(err, w, r, user)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func route_topic_id(w http.ResponseWriter, r *http.Request){
|
func route_topic_id(w http.ResponseWriter, r *http.Request){
|
||||||
user := SessionCheck(w,r)
|
user := SessionCheck(w,r)
|
||||||
var(
|
var(
|
||||||
tid int
|
err error
|
||||||
rid int
|
rid int
|
||||||
parentID int
|
|
||||||
title string
|
|
||||||
content string
|
content string
|
||||||
createdBy int
|
|
||||||
createdByName string
|
|
||||||
createdAt string
|
|
||||||
replyContent string
|
replyContent string
|
||||||
replyCreatedBy int
|
replyCreatedBy int
|
||||||
replyCreatedByName string
|
replyCreatedByName string
|
||||||
|
@ -115,17 +113,15 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
|
||||||
replyLastEdit int
|
replyLastEdit int
|
||||||
replyLastEditBy int
|
replyLastEditBy int
|
||||||
replyAvatar string
|
replyAvatar string
|
||||||
replyHasAvatar bool
|
|
||||||
is_closed bool
|
|
||||||
sticky bool
|
|
||||||
|
|
||||||
currentID int
|
currentID int
|
||||||
replyList map[int]interface{}
|
replyList map[int]interface{}
|
||||||
)
|
)
|
||||||
replyList = make(map[int]interface{})
|
replyList = make(map[int]interface{})
|
||||||
currentID = 0
|
currentID = 0
|
||||||
|
topic := TopicUser{0,"","",0,false,false,"",0,"","",""}
|
||||||
|
|
||||||
tid, err := strconv.Atoi(r.URL.Path[len("/topic/"):])
|
topic.ID, err = strconv.Atoi(r.URL.Path[len("/topic/"):])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LocalError("The provided TopicID is not a valid number.",w,r,user)
|
LocalError("The provided TopicID is not a valid number.",w,r,user)
|
||||||
return
|
return
|
||||||
|
@ -133,7 +129,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
|
||||||
|
|
||||||
// Get the topic..
|
// Get the topic..
|
||||||
//err = db.QueryRow("select title, content, createdBy, status, is_closed from topics where tid = ?", tid).Scan(&title, &content, &createdBy, &status, &is_closed)
|
//err = db.QueryRow("select title, content, createdBy, status, is_closed from topics where tid = ?", tid).Scan(&title, &content, &createdBy, &status, &is_closed)
|
||||||
err = db.QueryRow("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, users.name from topics left join users ON topics.createdBy = users.uid where tid = ?", tid).Scan(&title, &content, &createdBy, &createdAt, &is_closed, &sticky, &parentID, &createdByName)
|
err = db.QueryRow("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid where tid = ?", topic.ID).Scan(&topic.Title, &content, &topic.CreatedBy, &topic.CreatedAt, &topic.Is_Closed, &topic.Sticky, &topic.ParentID, &topic.CreatedByName, &topic.Avatar)
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
errmsg := "The requested topic doesn't exist."
|
errmsg := "The requested topic doesn't exist."
|
||||||
pi := Page{"Error","error",user,tList,errmsg}
|
pi := Page{"Error","error",user,tList,errmsg}
|
||||||
|
@ -148,25 +144,19 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var tdata map[string]string
|
topic.Content = template.HTML(content)
|
||||||
tdata = make(map[string]string)
|
if topic.Is_Closed {
|
||||||
tdata["tid"] = strconv.Itoa(tid)
|
topic.Status = "closed"
|
||||||
tdata["title"] = title
|
|
||||||
tdata["content"] = content
|
|
||||||
tdata["createdBy"] = string(createdBy)
|
|
||||||
tdata["createdAt"] = string(createdAt)
|
|
||||||
tdata["parentID"] = string(parentID)
|
|
||||||
if is_closed {
|
|
||||||
tdata["status"] = "closed"
|
|
||||||
} else {
|
} else {
|
||||||
tdata["status"] = "open"
|
topic.Status = "open"
|
||||||
|
}
|
||||||
|
if topic.Avatar != "" && topic.Avatar[0] == '.' {
|
||||||
|
topic.Avatar = "/uploads/avatar_" + strconv.Itoa(topic.CreatedBy) + topic.Avatar
|
||||||
}
|
}
|
||||||
//tdata["sticky"] = sticky
|
|
||||||
tdata["createdByName"] = createdByName
|
|
||||||
|
|
||||||
// Get the replies..
|
// Get the replies..
|
||||||
//rows, err := db.Query("select rid, content, createdBy, createdAt from replies where tid = ?", tid)
|
//rows, err := db.Query("select rid, content, createdBy, createdAt from replies where tid = ?", tid)
|
||||||
rows, err := db.Query("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name from replies left join users ON replies.createdBy = users.uid where tid = ?", tid)
|
rows, err := db.Query("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name from replies left join users ON replies.createdBy = users.uid where tid = ?", topic.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InternalError(err,w,r,user)
|
InternalError(err,w,r,user)
|
||||||
return
|
return
|
||||||
|
@ -180,16 +170,11 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if replyAvatar != "" {
|
if replyAvatar != "" && replyAvatar[0] == '.' {
|
||||||
replyHasAvatar = true
|
replyAvatar = "/uploads/avatar_" + strconv.Itoa(user.ID) + replyAvatar
|
||||||
if replyAvatar[0] == '.' {
|
|
||||||
replyAvatar = "/uploads/avatar_" + strconv.Itoa(user.ID) + replyAvatar
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
replyHasAvatar = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
replyList[currentID] = Reply{rid,tid,replyContent,replyCreatedBy,replyCreatedByName,replyCreatedAt,replyLastEdit,replyLastEditBy,replyAvatar,replyHasAvatar}
|
replyList[currentID] = Reply{rid,topic.ID,replyContent,template.HTML(strings.Replace(replyContent,"\n","<br>",-1)),replyCreatedBy,replyCreatedByName,replyCreatedAt,replyLastEdit,replyLastEditBy,replyAvatar}
|
||||||
currentID++
|
currentID++
|
||||||
}
|
}
|
||||||
err = rows.Err()
|
err = rows.Err()
|
||||||
|
@ -198,8 +183,11 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pi := Page{title,"topic",user,replyList,tdata}
|
pi := Page{topic.Title,"topic",user,replyList,topic}
|
||||||
templates.ExecuteTemplate(w,"topic.html", pi)
|
err = templates.ExecuteTemplate(w,"topic.html", pi)
|
||||||
|
if err != nil {
|
||||||
|
InternalError(err, w, r, user)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func route_topic_create(w http.ResponseWriter, r *http.Request){
|
func route_topic_create(w http.ResponseWriter, r *http.Request){
|
||||||
|
@ -223,7 +211,7 @@ func route_create_topic(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
success := 1
|
success := 1
|
||||||
|
|
||||||
res, err := create_topic_stmt.Exec(html.EscapeString(r.PostFormValue("topic-name")),html.EscapeString(r.PostFormValue("topic-content")),int32(time.Now().Unix()),user.ID)
|
res, err := create_topic_stmt.Exec(html.EscapeString(r.PostFormValue("topic-name")),html.EscapeString(r.PostFormValue("topic-content")),strings.Replace(html.EscapeString(r.PostFormValue("topic-content")),"\n","<br>",-1),user.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
success = 0
|
success = 0
|
||||||
|
@ -250,8 +238,6 @@ func route_create_topic(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
func route_create_reply(w http.ResponseWriter, r *http.Request) {
|
func route_create_reply(w http.ResponseWriter, r *http.Request) {
|
||||||
var tid int
|
var tid int
|
||||||
|
|
||||||
|
|
||||||
user := SessionCheck(w,r)
|
user := SessionCheck(w,r)
|
||||||
if !user.Loggedin {
|
if !user.Loggedin {
|
||||||
LoginRequired(w,r,user)
|
LoginRequired(w,r,user)
|
||||||
|
@ -279,9 +265,8 @@ func route_create_reply(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w,errpage,500)
|
http.Error(w,errpage,500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//log.Println("A reply is being created")
|
|
||||||
|
|
||||||
_, err = create_reply_stmt.Exec(tid,html.EscapeString(r.PostFormValue("reply-content")),int32(time.Now().Unix()),user.ID)
|
_, err = create_reply_stmt.Exec(tid,html.EscapeString(r.PostFormValue("reply-content")),strings.Replace(html.EscapeString(r.PostFormValue("reply-content")),"\n","<br>",-1),user.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
success = 0
|
success = 0
|
||||||
|
@ -332,8 +317,8 @@ func route_edit_topic(w http.ResponseWriter, r *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
is_closed = false
|
is_closed = false
|
||||||
}
|
}
|
||||||
topic_content := html.EscapeString(r.PostFormValue("topic_content"))
|
topic_content := html.EscapeString(r.PostFormValue("topic-content"))
|
||||||
_, err = edit_topic_stmt.Exec(topic_name, topic_content, is_closed, tid)
|
_, err = edit_topic_stmt.Exec(topic_name, topic_content, strings.Replace(topic_content,"\n","<br>",-1), is_closed, tid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InternalErrorJSQ(err,w,r,user,is_js)
|
InternalErrorJSQ(err,w,r,user,is_js)
|
||||||
return
|
return
|
||||||
|
@ -371,7 +356,7 @@ func route_reply_edit_submit(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
content := html.EscapeString(r.PostFormValue("edit_item"))
|
content := html.EscapeString(r.PostFormValue("edit_item"))
|
||||||
_, err = edit_reply_stmt.Exec(content, rid)
|
_, err = edit_reply_stmt.Exec(content, strings.Replace(content,"\n","<br>",-1), rid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InternalError(err,w,r,user)
|
InternalError(err,w,r,user)
|
||||||
return
|
return
|
||||||
|
@ -634,7 +619,6 @@ func route_account_own_edit_avatar_submit(w http.ResponseWriter, r *http.Request
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user.HasAvatar = true
|
|
||||||
user.Avatar = "/uploads/avatar_" + strconv.Itoa(user.ID) + "." + ext
|
user.Avatar = "/uploads/avatar_" + strconv.Itoa(user.ID) + "." + ext
|
||||||
|
|
||||||
pi := Page{"Edit Avatar","account-own-edit-avatar-success",user,tList,0}
|
pi := Page{"Edit Avatar","account-own-edit-avatar-success",user,tList,0}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{{template "header.html" . }}
|
{{template "header.html" . }}
|
||||||
<div class="colblock_left">
|
<div class="colblock_left">
|
||||||
<div class="rowitem"><a>My Account</a></div>
|
<div class="rowitem"><a>My Account</a></div>
|
||||||
<div class="rowitem passive"><a href="/user/edit/critical/">Edit Password</a></div>
|
|
||||||
<div class="rowitem passive"><a href="/user/edit/avatar/">Edit Avatar</a></div>
|
<div class="rowitem passive"><a href="/user/edit/avatar/">Edit Avatar</a></div>
|
||||||
|
<div class="rowitem passive"><a href="/user/edit/critical/">Edit Password</a></div>
|
||||||
<div class="rowitem passive"><a>Coming Soon</a></div>
|
<div class="rowitem passive"><a>Coming Soon</a></div>
|
||||||
<div class="rowitem passive"><a>Coming Soon</a></div>
|
<div class="rowitem passive"><a>Coming Soon</a></div>
|
||||||
<div class="rowitem passive"><a>Coming Soon</a></div>
|
<div class="rowitem passive"><a>Coming Soon</a></div>
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<div class="colblock_right">
|
<div class="colblock_right">
|
||||||
<div class="rowitem"><a>Edit Avatar</a></div>
|
<div class="rowitem"><a>Edit Avatar</a></div>
|
||||||
</div>
|
</div>
|
||||||
{{ if .CurrentUser.HasAvatar }}
|
{{ if .CurrentUser.Avatar }}
|
||||||
<div class="colblock_right">
|
<div class="colblock_right">
|
||||||
<div class="rowitem"><img src="{{.CurrentUser.Avatar}}" height="128px" max-width="128px" /></div>
|
<div class="rowitem"><img src="{{.CurrentUser.Avatar}}" height="128px" max-width="128px" /></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{{template "header.html" . }}
|
{{template "header.html" . }}
|
||||||
<div class="rowblock">
|
<div class="rowblock">
|
||||||
<form action='/topic/edit/submit/{{index .Something "tid"}}/' method="post">
|
<form action='/topic/edit/submit/{{.Something.ID}}' method="post">
|
||||||
<div class="rowitem">
|
<div class="rowitem">
|
||||||
<a class='topic_name hide_on_edit'>{{index .Something "title"}}</a>
|
<a class='topic_name hide_on_edit'>{{.Something.Title}}</a>
|
||||||
<span class='topic_status topic_status_e topic_status_{{index .Something "status"}} hide_on_edit'>{{index .Something "status"}}</span>
|
<span class='topic_status topic_status_e topic_status_{{.Something.Status}} hide_on_edit'>{{.Something.Status}}</span>
|
||||||
<a href='/topic/edit/{{index .Something "ID"}}/' class="topic_status hide_on_edit open_edit">Edit</a>
|
<a href='/topic/edit/{{.Something.ID}}' class="topic_status hide_on_edit open_edit">Edit</a>
|
||||||
<a href='/topic/delete/{{index .Something "ID"}}/' class="topic_status">Delete</a>
|
<a href='/topic/delete/{{.Something.ID}}' class="topic_status">Delete</a>
|
||||||
|
|
||||||
<input class='show_on_edit topic_name_input' name="topic_name" value='{{index .Something "title"}}' type="text" />
|
<input class='show_on_edit topic_name_input' name="topic_name" value='{{.Something.Title}}' type="text" />
|
||||||
<select name="topic_status" class='show_on_edit topic_status_input'>
|
<select name="topic_status" class='show_on_edit topic_status_input'>
|
||||||
<option>closed</option>
|
<option>closed</option>
|
||||||
<option>open</option>
|
<option>open</option>
|
||||||
|
@ -17,26 +17,26 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="rowblock">
|
<div class="rowblock">
|
||||||
<div class="rowitem passive editable_parent" style="border-bottom: none;{{ if .CurrentUser.HasAvatar }}background-image: url({{ .CurrentUser.Avatar }});background-position: left;background-repeat: no-repeat;background-size: 128px;padding-left: 136px;{{end}}">
|
<div class="rowitem passive editable_parent" style="border-bottom: none;{{ if .Something.Avatar }}background-image: url({{ .Something.Avatar }});background-position: left;background-repeat: no-repeat;background-size: 128px;padding-left: 136px;{{end}}">
|
||||||
<span class="hide_on_edit topic_content">{{index .Something "content"}}</span>
|
<span class="hide_on_edit topic_content">{{.Something.Content}}</span>
|
||||||
<textarea name="topic_content" class="show_on_edit topic_content_input">{{index .Something "content"}}</textarea>
|
<textarea name="topic_content" class="show_on_edit topic_content_input">{{.Something.Content}}</textarea>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<a class="topic_status" style="padding-left: 0px;margin-left: 0px;">{{index .Something "createdByName"}}<a/>
|
<a class="topic_status" style="padding-left: 0px;margin-left: 0px;">{{.Something.CreatedByName}}<a/>
|
||||||
</div>
|
</div>
|
||||||
</div><br />
|
</div><br />
|
||||||
<div class="rowblock" style="overflow: hidden;">
|
<div class="rowblock" style="overflow: hidden;">
|
||||||
{{range $index, $element := .ItemList}}
|
{{range $index, $element := .ItemList}}
|
||||||
<div class="rowitem passive deletable_block editable_parent" style="{{ if $element.HasAvatar }}background-image: url({{ $element.Avatar }});background-position: left;background-repeat: no-repeat;background-size: 128px;padding-left: 136px;{{end}}">
|
<div class="rowitem passive deletable_block editable_parent" style="{{ if $element.Avatar }}background-image: url({{ $element.Avatar }});background-position: left;background-repeat: no-repeat;background-size: 128px;padding-left: 136px;{{end}}">
|
||||||
<span class="editable_block">{{$element.Content}}</span>
|
<span class="editable_block">{{$element.ContentHtml}}</span>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<a class="topic_status" style="padding-left: 0px;margin-left: 0px;">{{$element.CreatedByName}}<a/>
|
<a class="topic_status" style="padding-left: 0px;margin-left: 0px;">{{$element.CreatedByName}}<a/>
|
||||||
<a href="/reply/edit/submit/{{$element.ID}}/"><button class="topic_status edit_item">Edit</button></a>
|
<a href="/reply/edit/submit/{{$element.ID}}"><button class="topic_status edit_item">Edit</button></a>
|
||||||
<a href="/reply/delete/submit/{{$element.ID}}/"><button class="topic_status delete_item">Delete</button></a>
|
<a href="/reply/delete/submit/{{$element.ID}}"><button class="topic_status delete_item">Delete</button></a>
|
||||||
</div>{{ end }}
|
</div>{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<div class="rowblock">
|
<div class="rowblock">
|
||||||
<form action="/reply/create/" method="post">
|
<form action="/reply/create/" method="post">
|
||||||
<input name="tid" value='{{index .Something "tid"}}' type="hidden" />
|
<input name="tid" value='{{.Something.ID}}' type="hidden" />
|
||||||
<div class="formrow">
|
<div class="formrow">
|
||||||
<div class="formitem"><textarea name="reply-content" placeholder="Insert reply here"></textarea></div>
|
<div class="formitem"><textarea name="reply-content" placeholder="Insert reply here"></textarea></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
19
src/user.go
19
src/user.go
|
@ -16,7 +16,6 @@ type User struct
|
||||||
Session string
|
Session string
|
||||||
Loggedin bool
|
Loggedin bool
|
||||||
Avatar string
|
Avatar string
|
||||||
HasAvatar bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetPassword(uid int, password string) (error) {
|
func SetPassword(uid int, password string) (error) {
|
||||||
|
@ -39,7 +38,7 @@ func SetPassword(uid int, password string) (error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SessionCheck(w http.ResponseWriter, r *http.Request) (User) {
|
func SessionCheck(w http.ResponseWriter, r *http.Request) (User) {
|
||||||
user := User{0,"",0,false,false,"",false,"",false}
|
user := User{0,"",0,false,false,"",false,""}
|
||||||
var err error
|
var err error
|
||||||
var cookie *http.Cookie
|
var cookie *http.Cookie
|
||||||
|
|
||||||
|
@ -59,8 +58,8 @@ func SessionCheck(w http.ResponseWriter, r *http.Request) (User) {
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
user.Session = cookie.Value
|
user.Session = cookie.Value
|
||||||
log.Print("ID: " + user.Name)
|
//log.Print("ID: " + user.Name)
|
||||||
log.Print("Session: " + user.Session)
|
//log.Print("Session: " + user.Session)
|
||||||
|
|
||||||
// Is this session valid..?
|
// Is this session valid..?
|
||||||
err = get_session_stmt.QueryRow(user.ID,user.Session).Scan(&user.ID, &user.Name, &user.Group, &user.Is_Super_Admin, &user.Session, &user.Avatar)
|
err = get_session_stmt.QueryRow(user.ID,user.Session).Scan(&user.ID, &user.Name, &user.Group, &user.Is_Super_Admin, &user.Session, &user.Avatar)
|
||||||
|
@ -72,14 +71,11 @@ func SessionCheck(w http.ResponseWriter, r *http.Request) (User) {
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
user.Is_Admin = user.Is_Super_Admin
|
user.Is_Admin = user.Is_Super_Admin
|
||||||
if user.Avatar != "" {
|
if user.Avatar != "" && user.Avatar[0] == '.' {
|
||||||
user.HasAvatar = true
|
user.Avatar = "/uploads/avatar_" + strconv.Itoa(user.ID) + user.Avatar
|
||||||
if user.Avatar[0] == '.' {
|
|
||||||
user.Avatar = "/uploads/avatar_" + strconv.Itoa(user.ID) + user.Avatar
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
user.Loggedin = true
|
user.Loggedin = true
|
||||||
log.Print("Logged in")
|
/*log.Print("Logged in")
|
||||||
log.Print("ID: " + strconv.Itoa(user.ID))
|
log.Print("ID: " + strconv.Itoa(user.ID))
|
||||||
log.Print("Group: " + strconv.Itoa(user.Group))
|
log.Print("Group: " + strconv.Itoa(user.Group))
|
||||||
log.Print("Name: " + user.Name)
|
log.Print("Name: " + user.Name)
|
||||||
|
@ -92,7 +88,6 @@ func SessionCheck(w http.ResponseWriter, r *http.Request) (User) {
|
||||||
log.Print("Is_Admin: true")
|
log.Print("Is_Admin: true")
|
||||||
} else {
|
} else {
|
||||||
log.Print("Is_Admin: false")
|
log.Print("Is_Admin: false")
|
||||||
}
|
}*/
|
||||||
log.Print("Session: " + user.Session)
|
|
||||||
return user
|
return user
|
||||||
}
|
}
|
Loading…
Reference in New Issue