blog

package
v0.0.0-...-d6e685d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit int64 = 10

Variables

View Source
var FastFeed []FeedStrcture

Stores the feed in a variable allowing for faster access

View Source
var StoryCacheVar *[]StoryStruct

Stores the last 50 most viewed stories allowing for quicker access

Functions

func IsValidStruct

func IsValidStruct(result *StoryStruct) error

valid if the stories' structure is valid

func ReflexCache

func ReflexCache()

Updates stories and fed

func SetLastStories

func SetLastStories()

Update the top 50 most viewed stories

func SetTopFeed

func SetTopFeed()

Update the fed

func TokenBlackList

func TokenBlackList(token, idtoken string) bool

gets if the token is blacklisted from some database

Types

type FeedStrcture

type FeedStrcture struct {
	Title       string    `bson:"Title,omitempty" `
	Author      string    `bson:"Author,omitempty"  `
	ID          string    `bson:"_id,omitempty" `
	Date        time.Time `bson:"Date,omitempty"`
	Imagen      string    `bson:"Imagen,omitempty"`
	Description string    `bson:"Description,omitempty"`
	Visible     bool      `bson:"Visible,omitempty"`
}

Feed structure

type PostController

type PostController struct {
	Conf       Queryconf
	Collection string
}

func InitControllerPost

func InitControllerPost() *PostController

InitControllerPost

func (*PostController) DelatePost

func (v *PostController) DelatePost(c *gin.Context)

func (*PostController) Feed

func (v *PostController) Feed(c *gin.Context)

func (*PostController) FeedFast

func (v *PostController) FeedFast() ([]FeedStrcture, error)

func (*PostController) FindPost

func (v *PostController) FindPost(c *gin.Context)

func (*PostController) Initialize

func (v *PostController) Initialize(c *gin.Context)

func (*PostController) InsertPost

func (v *PostController) InsertPost(c *gin.Context)

func (*PostController) MyPosts

func (v *PostController) MyPosts(c *gin.Context)

func (*PostController) Post

func (v *PostController) Post(c *gin.Context)

func (*PostController) RecommendedPost

func (v *PostController) RecommendedPost(c *gin.Context)

func (*PostController) SetCollection

func (v *PostController) SetCollection(Collection string) *PostController

change collection in the database

func (*PostController) SetTop

func (v *PostController) SetTop() ([]StoryStruct, error)

func (*PostController) UpdatePost

func (v *PostController) UpdatePost(c *gin.Context)

func (*PostController) UploadImage

func (*PostController) UploadImage(c *gin.Context)

func (*PostController) Visibility

func (v *PostController) Visibility(c *gin.Context)

type Queryconf

type Queryconf struct {
	Collection string
}

func (*Queryconf) Addviews

func (v *Queryconf) Addviews(id primitive.ObjectID) error

Adds the number of visits from a specific post

func (*Queryconf) DelatePost

func (v *Queryconf) DelatePost(id primitive.ObjectID) error

Delete a specific post

func (*Queryconf) GetFeed

func (v *Queryconf) GetFeed(next int64, query bson.M, limit int64) ([]FeedStrcture, error)

Get the feed

func (*Queryconf) GetMetaPost

func (v *Queryconf) GetMetaPost(objectId primitive.ObjectID) (FeedStrcture, error)

Returns the basic data of a post

func (*Queryconf) GetTOP

func (v *Queryconf) GetTOP() ([]StoryStruct, error)

Get the last ten posts most viewed

func (*Queryconf) ModelGetArticle

func (v *Queryconf) ModelGetArticle(objectId primitive.ObjectID) (StoryStruct, error)

Gets a post from an id

func (*Queryconf) ModelInsertPost

func (v *Queryconf) ModelInsertPost(result *StoryStruct) (*mongo.InsertOneResult, error)

Insert a post from a structure

func (*Queryconf) ModelUpdate

func (v *Queryconf) ModelUpdate(dataInsert *StoryStruct, objectId primitive.ObjectID) (bool, error)

Update a post from a structure

type StoryStruct

type StoryStruct struct {
	Title         string    `bson:"Title,omitempty"`
	Content       string    `bson:"Content,omitempty"`
	Visible       bool      `bson:"Visible"`
	Tags          []string  `bson:"Tags,omitempty"`
	Date          time.Time `bson:"Date,omitempty" `
	Imagen        string    `bson:"Imagen,omitempty"`
	Status        string    `bson:"Status,omitempty"`
	Author        string    `bson:"Author,omitempty"`
	Description   string    `bson:"Description,omitempty"`
	Password      string    `bson:"Password"`
	UrlImageFound []string  `bson:"UrlImageFound"`
	Views         int64     `bson:"Views"`
	ID            string    `bson:"_id,omitempty" `
	Referal       string    `bson:"Referal,omitempty"`
	Folder        string    `bson:"Folder,omitempty"`
}

Complete structure of the stories

type Top50

type Top50 struct {
	Top []StoryStruct
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL