update .link_most_viewed properly on page transitions
reduce variable lengths remove redundant thaw
This commit is contained in:
parent
fbcbfd9e96
commit
43bace814d
|
@ -17,7 +17,7 @@ var ErrAlreadyReported = errors.New("This item has already been reported")
|
||||||
|
|
||||||
// The report system mostly wraps around the topic system for simplicty
|
// The report system mostly wraps around the topic system for simplicty
|
||||||
type ReportStore interface {
|
type ReportStore interface {
|
||||||
Create(title, content string, user *User, itemType string, itemID int) (int, error)
|
Create(title, content string, u *User, itemType string, itemID int) (int, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type DefaultReportStore struct {
|
type DefaultReportStore struct {
|
||||||
|
|
|
@ -240,7 +240,7 @@ func (s *DefaultTopicStore) Create(fid int, name, content string, uid int, ip st
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
tid = int(lastID)
|
tid = int(lastID)
|
||||||
TopicListThaw.Thaw()
|
//TopicListThaw.Thaw() // redundant
|
||||||
|
|
||||||
return tid, Forums.AddTopic(tid, uid, fid)
|
return tid, Forums.AddTopic(tid, uid, fid)
|
||||||
}
|
}
|
||||||
|
|
|
@ -665,6 +665,8 @@ function mainInit(){
|
||||||
history.pushState(obj,obj.Title,obj.Url);
|
history.pushState(obj,obj.Title,obj.Url);
|
||||||
rebuildPaginator(d.LastPage);
|
rebuildPaginator(d.LastPage);
|
||||||
rebindPaginator();
|
rebindPaginator();
|
||||||
|
$(".link_select .link_option .link_recent").attr("href",url+q);
|
||||||
|
$(".link_select .link_option .link_most_viewed").attr("href",url+q);
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
log("Unable to get script "+url+q+"&js=1",e);
|
log("Unable to get script "+url+q+"&js=1",e);
|
||||||
console.trace();
|
console.trace();
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
c "github.com/Azareal/Gosora/common"
|
c "github.com/Azareal/Gosora/common"
|
||||||
"github.com/Azareal/Gosora/common/phrases"
|
p "github.com/Azareal/Gosora/common/phrases"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A blank list to fill out that parameter in Page for routes which don't use it
|
// A blank list to fill out that parameter in Page for routes which don't use it
|
||||||
|
@ -43,12 +43,12 @@ func renderTemplate(tmplName string, w http.ResponseWriter, r *http.Request, h *
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildBasePage(w http.ResponseWriter, r *http.Request, user *c.User, titlePhrase, zone string) (*c.BasePanelPage, c.RouteError) {
|
func buildBasePage(w http.ResponseWriter, r *http.Request, u *c.User, titlePhrase, zone string) (*c.BasePanelPage, c.RouteError) {
|
||||||
header, stats, ferr := c.PanelUserCheck(w, r, user)
|
h, stats, ferr := c.PanelUserCheck(w, r, u)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return nil, ferr
|
return nil, ferr
|
||||||
}
|
}
|
||||||
header.Title = phrases.GetTitlePhrase("panel_" + titlePhrase)
|
h.Title = p.GetTitlePhrase("panel_" + titlePhrase)
|
||||||
|
|
||||||
return &c.BasePanelPage{header, stats, zone, c.ReportForumID}, nil
|
return &c.BasePanelPage{h, stats, zone, c.ReportForumID}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
qgen "github.com/Azareal/Gosora/query_gen"
|
qgen "github.com/Azareal/Gosora/query_gen"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PollVote(w http.ResponseWriter, r *http.Request, user *c.User, sPollID string) c.RouteError {
|
func PollVote(w http.ResponseWriter, r *http.Request, u *c.User, sPollID string) c.RouteError {
|
||||||
pollID, err := strconv.Atoi(sPollID)
|
pollID, err := strconv.Atoi(sPollID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.PreError("The provided PollID is not a valid number.", w, r)
|
return c.PreError("The provided PollID is not a valid number.", w, r)
|
||||||
|
@ -44,19 +44,19 @@ func PollVote(w http.ResponseWriter, r *http.Request, user *c.User, sPollID stri
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add hooks to make use of headerLite
|
// TODO: Add hooks to make use of headerLite
|
||||||
_, ferr := c.SimpleForumUserCheck(w, r, user, topic.ParentID)
|
_, ferr := c.SimpleForumUserCheck(w, r, u, topic.ParentID)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
if !user.Perms.ViewTopic {
|
if !u.Perms.ViewTopic {
|
||||||
return c.NoPermissions(w, r, user)
|
return c.NoPermissions(w, r, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
optionIndex, err := strconv.Atoi(r.PostFormValue("poll_option_input"))
|
optIndex, err := strconv.Atoi(r.PostFormValue("poll_option_input"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.LocalError("Malformed input", w, r, user)
|
return c.LocalError("Malformed input", w, r, u)
|
||||||
}
|
}
|
||||||
err = poll.CastVote(optionIndex, user.ID, user.GetIP())
|
err = poll.CastVote(optIndex, u.ID, u.GetIP())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ func PollVote(w http.ResponseWriter, r *http.Request, user *c.User, sPollID stri
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PollResults(w http.ResponseWriter, r *http.Request, user *c.User, sPollID string) c.RouteError {
|
func PollResults(w http.ResponseWriter, r *http.Request, u *c.User, sPollID string) c.RouteError {
|
||||||
//log.Print("in PollResults")
|
//log.Print("in PollResults")
|
||||||
pollID, err := strconv.Atoi(sPollID)
|
pollID, err := strconv.Atoi(sPollID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -85,24 +85,23 @@ func PollResults(w http.ResponseWriter, r *http.Request, user *c.User, sPollID s
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
optionList := ""
|
optList := ""
|
||||||
var votes int
|
var votes int
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err := rows.Scan(&votes)
|
err := rows.Scan(&votes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
optionList += strconv.Itoa(votes) + ","
|
optList += strconv.Itoa(votes) + ","
|
||||||
}
|
}
|
||||||
err = rows.Err()
|
if err = rows.Err(); err != nil {
|
||||||
if err != nil {
|
|
||||||
return c.InternalError(err, w, r)
|
return c.InternalError(err, w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement a version of this which doesn't rely so much on sequential order
|
// TODO: Implement a version of this which doesn't rely so much on sequential order
|
||||||
if len(optionList) > 0 {
|
if len(optList) > 0 {
|
||||||
optionList = optionList[:len(optionList)-1]
|
optList = optList[:len(optList)-1]
|
||||||
}
|
}
|
||||||
w.Write([]byte("[" + optionList + "]"))
|
w.Write([]byte("[" + optList + "]"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue