refactor: declare the content descriptors in MenuItemTypes
The three descriptors are now literal pact.ContentDescriptor values next to the types they describe; no behaviour change.
This commit is contained in:
@@ -39,18 +39,6 @@ func (m menuTypes) contentDB(ctx context.Context) (*gorm.DB, error) {
|
||||
return m.db(ctx)
|
||||
}
|
||||
|
||||
// postContent is the D-93 descriptor of journal-post: posts are edited by
|
||||
// the posts controller and carry the Post morph name.
|
||||
func (m menuTypes) postContent() *pact.ContentDescriptor {
|
||||
return &pact.ContentDescriptor{
|
||||
Controller: postsControllerID,
|
||||
Model: models.Post{}.MorphName(),
|
||||
Records: m.listPosts,
|
||||
Describe: m.describePost,
|
||||
Match: m.matchPost,
|
||||
}
|
||||
}
|
||||
|
||||
// describePost describes one post, drafts included: Published tells
|
||||
// whether visitors see it.
|
||||
func (m menuTypes) describePost(ctx context.Context, in pact.ContentDescribe) (*pact.ContentRecord, error) {
|
||||
@@ -314,17 +302,6 @@ func (m menuTypes) matchPost(ctx context.Context, in pact.ContentMatch) (*pact.C
|
||||
return matchContent(ctx, db, in, find, urls)
|
||||
}
|
||||
|
||||
// categoryContent is the D-93 descriptor of journal-category.
|
||||
func (m menuTypes) categoryContent() *pact.ContentDescriptor {
|
||||
return &pact.ContentDescriptor{
|
||||
Controller: categoriesControllerID,
|
||||
Model: models.Category{}.MorphName(),
|
||||
Records: m.listCategories,
|
||||
Describe: m.describeCategory,
|
||||
Match: m.matchCategory,
|
||||
}
|
||||
}
|
||||
|
||||
func (m menuTypes) describeCategory(ctx context.Context, in pact.ContentDescribe) (*pact.ContentRecord, error) {
|
||||
id, ok := menuReferenceID(in.ID)
|
||||
if !ok {
|
||||
@@ -439,17 +416,6 @@ func (m menuTypes) matchCategory(ctx context.Context, in pact.ContentMatch) (*pa
|
||||
return matchContent(ctx, db, in, find, urls)
|
||||
}
|
||||
|
||||
// tagContent is the D-93 descriptor of journal-tag.
|
||||
func (m menuTypes) tagContent() *pact.ContentDescriptor {
|
||||
return &pact.ContentDescriptor{
|
||||
Controller: tagsControllerID,
|
||||
Model: models.Tag{}.MorphName(),
|
||||
Records: m.listTags,
|
||||
Describe: m.describeTag,
|
||||
Match: m.matchTag,
|
||||
}
|
||||
}
|
||||
|
||||
// tagReferences lists every tag by name, ties by id.
|
||||
func (m menuTypes) tagReferences(ctx context.Context) ([]pact.MenuItemReference, error) {
|
||||
db, err := m.db(ctx)
|
||||
|
||||
Reference in New Issue
Block a user