Merge pull request #540 from writefreely/better-titles-stats
Show post excerpt in stats list when no post title
This commit is contained in:
commit
4b33c51ece
|
@ -1774,7 +1774,7 @@ func (db *datastore) GetTopPosts(u *User, alias string, hostName string) (*[]Pub
|
||||||
where = " AND alias = ?"
|
where = " AND alias = ?"
|
||||||
params = append(params, alias)
|
params = append(params, alias)
|
||||||
}
|
}
|
||||||
rows, err := db.Query("SELECT p.id, p.slug, p.view_count, p.title, c.alias, c.title, c.description, c.view_count FROM posts p LEFT JOIN collections c ON p.collection_id = c.id WHERE p.owner_id = ?"+where+" ORDER BY p.view_count DESC, created DESC LIMIT 25", params...)
|
rows, err := db.Query("SELECT p.id, p.slug, p.view_count, p.title, p.content, c.alias, c.title, c.description, c.view_count FROM posts p LEFT JOIN collections c ON p.collection_id = c.id WHERE p.owner_id = ?"+where+" ORDER BY p.view_count DESC, created DESC LIMIT 25", params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed selecting from posts: %v", err)
|
log.Error("Failed selecting from posts: %v", err)
|
||||||
return nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't retrieve user top posts."}
|
return nil, impart.HTTPError{http.StatusInternalServerError, "Couldn't retrieve user top posts."}
|
||||||
|
@ -1788,7 +1788,7 @@ func (db *datastore) GetTopPosts(u *User, alias string, hostName string) (*[]Pub
|
||||||
c := Collection{}
|
c := Collection{}
|
||||||
var alias, title, description sql.NullString
|
var alias, title, description sql.NullString
|
||||||
var views sql.NullInt64
|
var views sql.NullInt64
|
||||||
err = rows.Scan(&p.ID, &p.Slug, &p.ViewCount, &p.Title, &alias, &title, &description, &views)
|
err = rows.Scan(&p.ID, &p.Slug, &p.ViewCount, &p.Title, &p.Content, &alias, &title, &description, &views)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed scanning User.getPosts() row: %v", err)
|
log.Error("Failed scanning User.getPosts() row: %v", err)
|
||||||
gotErr = true
|
gotErr = true
|
||||||
|
|
|
@ -51,7 +51,7 @@ td.none {
|
||||||
<th class="num">Total Views</th>
|
<th class="num">Total Views</th>
|
||||||
</tr>
|
</tr>
|
||||||
{{range .TopPosts}}<tr>
|
{{range .TopPosts}}<tr>
|
||||||
<td style="word-break: break-all;"><a href="{{if .Collection}}{{.Collection.CanonicalURL}}{{.Slug.String}}{{else}}/{{.ID}}{{end}}">{{if ne .Title.String ""}}{{.Title.String}}{{else}}<em>{{.ID}}</em>{{end}}</a></td>
|
<td style="word-break: break-all;"><a href="{{if .Collection}}{{.Collection.CanonicalURL}}{{.Slug.String}}{{else}}/{{.ID}}{{end}}">{{if ne .DisplayTitle ""}}{{.DisplayTitle}}{{else}}<em>{{.ID}}</em>{{end}}</a></td>
|
||||||
{{ if not $.Collection }}<td>{{if .Collection}}<a href="{{.Collection.CanonicalURL}}">{{.Collection.Title}}</a>{{else}}<em>Draft</em>{{end}}</td>{{ end }}
|
{{ if not $.Collection }}<td>{{if .Collection}}<a href="{{.Collection.CanonicalURL}}">{{.Collection.Title}}</a>{{else}}<em>Draft</em>{{end}}</td>{{ end }}
|
||||||
<td class="num">{{.ViewCount}}</td>
|
<td class="num">{{.ViewCount}}</td>
|
||||||
</tr>{{end}}
|
</tr>{{end}}
|
||||||
|
|
Loading…
Reference in New Issue