package model import ( "time" ) // TODO docstring type Article struct { Identifier int SourceUrl string PublishDate time.Time FetchDate time.Time Title string Content string Author string } // TODO docstring type ArticleViewModel struct { Title string Author string PublishDate string SourceUrl string Summary string } // TODO docstring func (a *Article) ViewModel() *ArticleViewModel { summary := a.Content if len(a.Content) > 300 { summary = summary[:300] } return &ArticleViewModel{ Title: a.Title, Author: a.Author, PublishDate: a.PublishDate.Local().Format("02.01.2006 15:04"), SourceUrl: a.SourceUrl, Summary: summary, } }