mirror of https://github.com/jlelse/GoBlog
Show unlisted and private posts for logged-in users in map (#18)
This commit is contained in:
parent
e8189acb40
commit
d186f2e956
|
@ -175,3 +175,10 @@ func (a *goBlog) serveLogout(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
http.Redirect(w, r, "/", http.StatusFound)
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *goBlog) getDefaultPostStatusse(r *http.Request) []postStatus {
|
||||||
|
if a.isLoggedIn(r) {
|
||||||
|
return []postStatus{statusPublished, statusUnlisted, statusPrivate}
|
||||||
|
}
|
||||||
|
return []postStatus{statusPublished}
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ func (a *goBlog) serveGeoMap(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
allPostsWithLocation, err := a.db.countPosts(&postsRequestConfig{
|
allPostsWithLocation, err := a.db.countPosts(&postsRequestConfig{
|
||||||
blog: blog,
|
blog: blog,
|
||||||
status: statusPublished,
|
statusse: a.getDefaultPostStatusse(r),
|
||||||
parameters: []string{a.cfg.Micropub.LocationParam, gpxParameter},
|
parameters: []string{a.cfg.Micropub.LocationParam, gpxParameter},
|
||||||
withOnlyParameters: []string{a.cfg.Micropub.LocationParam, gpxParameter},
|
withOnlyParameters: []string{a.cfg.Micropub.LocationParam, gpxParameter},
|
||||||
})
|
})
|
||||||
|
@ -57,7 +57,7 @@ func (a *goBlog) serveGeoMapTracks(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
allPostsWithTracks, err := a.getPosts(&postsRequestConfig{
|
allPostsWithTracks, err := a.getPosts(&postsRequestConfig{
|
||||||
blog: blog,
|
blog: blog,
|
||||||
status: statusPublished,
|
statusse: a.getDefaultPostStatusse(r),
|
||||||
parameters: []string{gpxParameter},
|
parameters: []string{gpxParameter},
|
||||||
withOnlyParameters: []string{gpxParameter},
|
withOnlyParameters: []string{gpxParameter},
|
||||||
excludeParameter: showRouteParam,
|
excludeParameter: showRouteParam,
|
||||||
|
@ -103,7 +103,7 @@ func (a *goBlog) serveGeoMapLocations(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
allPostsWithLocations, err := a.getPosts(&postsRequestConfig{
|
allPostsWithLocations, err := a.getPosts(&postsRequestConfig{
|
||||||
blog: blog,
|
blog: blog,
|
||||||
status: statusPublished,
|
statusse: a.getDefaultPostStatusse(r),
|
||||||
parameters: []string{a.cfg.Micropub.LocationParam},
|
parameters: []string{a.cfg.Micropub.LocationParam},
|
||||||
withOnlyParameters: []string{a.cfg.Micropub.LocationParam},
|
withOnlyParameters: []string{a.cfg.Micropub.LocationParam},
|
||||||
})
|
})
|
||||||
|
|
5
posts.go
5
posts.go
|
@ -282,10 +282,7 @@ func (a *goBlog) serveIndex(w http.ResponseWriter, r *http.Request) {
|
||||||
statusse = []postStatus{ic.status}
|
statusse = []postStatus{ic.status}
|
||||||
}
|
}
|
||||||
if len(statusse) == 0 {
|
if len(statusse) == 0 {
|
||||||
statusse = []postStatus{statusPublished}
|
statusse = a.getDefaultPostStatusse(r)
|
||||||
if a.isLoggedIn(r) {
|
|
||||||
statusse = append(statusse, statusPrivate, statusUnlisted)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p := paginator.New(&postPaginationAdapter{config: &postsRequestConfig{
|
p := paginator.New(&postPaginationAdapter{config: &postsRequestConfig{
|
||||||
blog: blog,
|
blog: blog,
|
||||||
|
|
Loading…
Reference in New Issue