✨ Read news basis
✨ Able to read wordpress site
btw the 10 yrs ago package still work properly, amazing...
means the wordpress api did not change a lot and the golang backward
compability is amazing!
This commit is contained in:
32
pkg/internal/models/new.go
Normal file
32
pkg/internal/models/new.go
Normal file
@ -0,0 +1,32 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type NewsArticle struct {
|
||||
cruda.BaseModel
|
||||
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Content string `json:"content"`
|
||||
URL string `json:"url"`
|
||||
Hash string `json:"hash" gorm:"uniqueIndex"`
|
||||
Source string `json:"source"`
|
||||
}
|
||||
|
||||
func (v *NewsArticle) GenHash() *NewsArticle {
|
||||
if len(v.URL) == 0 {
|
||||
v.Hash = uuid.NewString()
|
||||
return v
|
||||
}
|
||||
|
||||
hash := md5.Sum([]byte(v.URL))
|
||||
v.Hash = hex.EncodeToString(hash[:])
|
||||
return v
|
||||
}
|
8
pkg/internal/models/source.go
Normal file
8
pkg/internal/models/source.go
Normal file
@ -0,0 +1,8 @@
|
||||
package models
|
||||
|
||||
type NewsSource struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type"`
|
||||
Source string `json:"source"`
|
||||
}
|
Reference in New Issue
Block a user