MCPcopy
hub / github.com/writefreely/writefreely / getRawCollectionPost

Function getRawCollectionPost

posts.go:1408–1445  ·  view source on GitHub ↗

TODO; return a Post!

(app *App, slug, collAlias string)

Source from the content-addressed store, hash-verified

1406
1407// TODO; return a Post!
1408func getRawCollectionPost(app *App, slug, collAlias string) *RawPost {
1409 var id, title, content, font string
1410 var isRTL sql.NullBool
1411 var lang sql.NullString
1412 var created, updated time.Time
1413 var ownerID null.Int
1414 var views int64
1415 var err error
1416
1417 if app.cfg.App.SingleUser {
1418 err = app.db.QueryRow("SELECT id, title, content, text_appearance, language, rtl, view_count, created, updated, owner_id FROM posts WHERE slug = ? AND collection_id = 1", slug).Scan(&id, &title, &content, &font, &lang, &isRTL, &views, &created, &updated, &ownerID)
1419 } else {
1420 err = app.db.QueryRow("SELECT id, title, content, text_appearance, language, rtl, view_count, created, updated, owner_id FROM posts WHERE slug = ? AND collection_id = (SELECT id FROM collections WHERE alias = ?)", slug, collAlias).Scan(&id, &title, &content, &font, &lang, &isRTL, &views, &created, &updated, &ownerID)
1421 }
1422 switch {
1423 case err == sql.ErrNoRows:
1424 return &RawPost{Content: "", Found: false, Gone: false}
1425 case err != nil:
1426 log.Error("Unable to fetch getRawCollectionPost: %s", err)
1427 return &RawPost{Content: "", Found: true, Gone: false}
1428 }
1429
1430 return &RawPost{
1431 Id: id,
1432 Slug: slug,
1433 Title: title,
1434 Content: content,
1435 Font: font,
1436 Created: created,
1437 Updated: updated,
1438 IsRTL: isRTL,
1439 Language: lang,
1440 OwnerID: ownerID.Int64,
1441 Found: true,
1442 Gone: content == "" && title == "",
1443 Views: views,
1444 }
1445}
1446
1447func isRaw(r *http.Request) bool {
1448 vars := mux.Vars(r)

Callers 2

handleViewPadFunction · 0.85
handleViewMetaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected