Search was not scrolling fine
This commit is contained in:
parent
4762f09df3
commit
ea906a7681
3 changed files with 3 additions and 7 deletions
|
@ -41,7 +41,7 @@ func GetBook(coll *mgo.Collection, query bson.M, r ...int) (books []Book, num in
|
||||||
start = r[1]
|
start = r[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
q := coll.Find(query)
|
q := coll.Find(query).Sort("-_id")
|
||||||
num, err = q.Count()
|
num, err = q.Count()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -50,7 +50,7 @@ func searchHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request
|
||||||
page = 0
|
page = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res, num, _ := GetBook(coll, buildQuery(req), SEARCH_ITEMS_PAGE, page)
|
res, num, _ := GetBook(coll, buildQuery(req), SEARCH_ITEMS_PAGE, page*SEARCH_ITEMS_PAGE)
|
||||||
|
|
||||||
var data searchData
|
var data searchData
|
||||||
data.S = GetStatus(w, r)
|
data.S = GetStatus(w, r)
|
||||||
|
|
|
@ -103,11 +103,7 @@ func indexHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request)
|
||||||
|
|
||||||
data.S = GetStatus(w, r)
|
data.S = GetStatus(w, r)
|
||||||
data.S.Home = true
|
data.S.Home = true
|
||||||
data.Count, _ = coll.Count()
|
data.Books, data.Count, _ = GetBook(coll, bson.M{}, 6)
|
||||||
coll.Find(bson.M{}).Sort("-_id").Limit(6).All(&data.Books)
|
|
||||||
for i, b := range data.Books {
|
|
||||||
data.Books[i].Id = bson.ObjectId(b.Id).Hex()
|
|
||||||
}
|
|
||||||
loadTemplate(w, "index", data)
|
loadTemplate(w, "index", data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue