data

package
v0.0.0-...-73ca27c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheJSON

func CacheJSON(con *Context, namespace string, value []byte) error

CacheJSON store the JSON for a specific namespace in a cache

func CacheRSS

func CacheRSS(con *Context, namespace string, value string) error

CacheRSS stores the RSS for a specific namespace in a cache

func ClearNamespace

func ClearNamespace(con *Context, namespace string) error

ClearNamespace deletes every entry in a namespace

func DeleteAllItems

func DeleteAllItems(con *Context) error

DeleteAllItems deletes all items from datastore

func NamespaceIsEmpty

func NamespaceIsEmpty(con *Context, namespace string) (bool, error)

NamespaceIsEmpty checks if there is already an item in a namespace

func ReadJSONCache

func ReadJSONCache(con *Context, namespace string) ([]byte, error)

ReadJSONCache checks if there is an entry for the JOSN of namespace and returns it

func ReadRSSCache

func ReadRSSCache(con *Context, namespace string) (string, error)

ReadRSSCache checks if there is an entry for the RSS feed of namespace and returns it

Types

type Callback

type Callback struct {
	URL       string `datastore:"URL,index"`
	Namespace string `datastore:"Namespace,index"`
	DSKey     string `datastore:"-"`
}

A Callback is something that should be executed after sharing an url

func GetCallbacksByNamespace

func GetCallbacksByNamespace(con *Context, namespace string) ([]Callback, error)

GetCallbacksByNamespace returns all callbacks for a specific namespace

func (*Callback) Store

func (c *Callback) Store(con *Context) error

Store stores an item in the datastore

type Context

type Context struct {
	C   context.Context
	Log klogger.GAELogger
}

Context is our internal context and is passed to every function

func MakeContext

func MakeContext(r *http.Request) *Context

MakeContext creates a default context

type ImageUpload

type ImageUpload struct {
	URL        string `datastore:"URL,index"`
	DeleteHash string `datastore:"DeleteHash"`
}

An ImageUpload is all the data we store from an uploaded image

func (*ImageUpload) Store

func (i *ImageUpload) Store(con *Context) error

Store stores an ImageUpload in the datastore

type Item

type Item struct {
	Caption       string    `json:"caption" datastore:"Caption,noindex"`
	URL           string    `json:"url" datastore:"URL,index"`
	Via           string    `json:"via" datastore:"Via,noindex"` // Required for DS backward compatibility
	ImageURL      string    `json:"imageURL" datastore:"ImageURL,noindex"`
	Description   string    `json:"description" datastore:"Description,noindex"`
	CreatedAt     time.Time `json:"createdat" datastore:"CreatedAt,index"`
	Namespace     string    `json:"-" datastore:"Namespace,index"`
	HTMLforSearch string    `json:"-" datastore:"-"` // Required for DS backward compatibility
	DSKey         string    `json:"-" datastore:"-"`
}

An Item is all the data we store from a website TODO check if URL must be indexed .Namespace?

func GetNewestItems

func GetNewestItems(con *Context, namespace string, limit int, cursor string) ([]Item, string, error)

GetNewestItems returns the latest number elements for a specific namespace

func GetNewestItemsByTime

func GetNewestItemsByTime(con *Context, namespace string, limit int, t time.Time, cursor string) ([]Item, string, error)

GetNewestItemsByTime returns up to limit numbers of items stored >= the give time

func ItemFromWebpageInfo

func ItemFromWebpageInfo(info webpage.Info) Item

ItemFromWebpageInfo converts the results returned from go-URLextract into our own Item struct

func (*Item) Store

func (i *Item) Store(con *Context) error

Store stores an item in the datastore

Jump to

Keyboard shortcuts

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