almanack

package
v0.0.0-...-16adccd Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 50 Imported by: 0

Documentation

Overview

Package almanack has business logic.

Index

Constants

View Source
const (
	HomepageLoc     = "data/editorsPicks.json"
	SidebarLoc      = "data/sidebar.json"
	SiteParamsLoc   = "config/_default/params.json"
	StateCollegeLoc = "data/stateCollege.json"
	ElectionFeatLoc = "data/elections.json"
)

Variables

View Source
var (
	BuildVersion = versioninfo.Revision

	DeployURL = strings.TrimSpace(deployURL)
)

Functions

func AddFlags

func AddFlags(fl *flag.FlagSet) func() (svc Services, err error)

func ArcFeedItemToBody

func ArcFeedItemToBody(ctx context.Context, svc Services, arcStory *arc.FeedItem) (body string, warnings []string, err error)

func ArcFeedItemToFrontmatter

func ArcFeedItemToFrontmatter(ctx context.Context, svc Services, arcStory *arc.FeedItem) (fm map[string]any, err error)

func FetchImageURL

func FetchImageURL(ctx context.Context, c *http.Client, srcurl string) (body []byte, ctype string, err error)

func GetSignedFileUpload

func GetSignedFileUpload(ctx context.Context, is aws.BlobStore, filename, mimetype string) (signedURL, fileURL, disposition, cachecontrol string, err error)

func GetSignedImageUpload

func GetSignedImageUpload(ctx context.Context, is aws.BlobStore, ct string) (signedURL, filename string, err error)

func MessageForLoc

func MessageForLoc(loc string) string

func UploadJSON

func UploadJSON(ctx context.Context, is aws.BlobStore, filepath, cachecontrol string, data any) error

Types

type ScheduledSiteConfig

type ScheduledSiteConfig struct {
	ScheduleFor time.Time `json:"schedule_for"`
	Data        db.Map    `json:"data"`
}

type Services

type Services struct {
	MailchimpSignupURL   string
	NetlifyWebhookSecret string
	Client               *http.Client
	Queries              *db.Queries
	Tx                   *db.Txable
	github.ContentStore
	ImageStore       aws.BlobStore
	FileStore        aws.BlobStore
	SlackSocial      *slackhook.Client
	SlackTech        *slackhook.Client
	Indexer          index.Indexer
	NewletterService mailchimp.V3
	Gsvc             *google.Service
	mailchimp.EmailService
	Plausible plausible.API
	// contains filtered or unexported fields
}

func (Services) ConfigureGoogleCert

func (svc Services) ConfigureGoogleCert(ctx context.Context) (err error)

func (Services) CreateGDocsDoc

func (svc Services) CreateGDocsDoc(ctx context.Context, externalID string) (dbDoc *db.GDocsDoc, err error)

func (Services) CreatePageFromArcSource

func (svc Services) CreatePageFromArcSource(ctx context.Context, shared *db.SharedArticle, kind string) (warnings []string, err error)

func (Services) CreatePageFromGDocsDoc

func (svc Services) CreatePageFromGDocsDoc(ctx context.Context, shared *db.SharedArticle, kind string) (err error)

func (Services) ImportNewsletterPages

func (svc Services) ImportNewsletterPages(ctx context.Context, types []db.NewsletterType) (err error)

func (Services) InflateSharedArticle

func (svc Services) InflateSharedArticle(ctx context.Context, a *db.SharedArticle) (v any, err error)

func (Services) Notify

func (svc Services) Notify(ctx context.Context, page *db.Page, publishingNow bool) (err error)

func (Services) PopScheduledPages

func (svc Services) PopScheduledPages(ctx context.Context) (err, warning error)

func (Services) PopScheduledSiteChanges

func (svc Services) PopScheduledSiteChanges(ctx context.Context, loc string) error

func (Services) ProcessGDocs

func (svc Services) ProcessGDocs(ctx context.Context) error

func (Services) ProcessGDocsDoc

func (svc Services) ProcessGDocsDoc(ctx context.Context, dbDoc db.GDocsDoc) (err error)

func (Services) PublishPage

func (svc Services) PublishPage(ctx context.Context, txq *db.Queries, page *db.Page) (err, warning error)

func (Services) PublishSiteConfig

func (svc Services) PublishSiteConfig(ctx context.Context, siteConfig *db.SiteDatum) (err error)

func (Services) RefreshArcFromFeed

func (svc Services) RefreshArcFromFeed(ctx context.Context) (fatal bool, merr error)

func (Services) RefreshPageContents

func (svc Services) RefreshPageContents(ctx context.Context, id int64) (err error)

func (Services) RefreshPageFromArcStory

func (svc Services) RefreshPageFromArcStory(ctx context.Context, page *db.Page, story *db.Arc, refreshMetadata bool) (warnings []string, err error)

func (Services) RefreshPageFromContentStore

func (svc Services) RefreshPageFromContentStore(ctx context.Context, page *db.Page) (err error)

func (Services) RefreshPageFromMailchimp

func (svc Services) RefreshPageFromMailchimp(ctx context.Context, page *db.Page) (err error)

func (Services) ReplaceAndUploadImageURL

func (svc Services) ReplaceAndUploadImageURL(ctx context.Context, srcURL, description, credit string) (path string, err error)

func (Services) ReplaceImageURL

func (svc Services) ReplaceImageURL(ctx context.Context, srcURL, description, credit string) (s string, err error)

func (Services) SaveNewsletterPage

func (svc Services) SaveNewsletterPage(ctx context.Context, nl *db.Newsletter, body string, types []db.NewsletterType) (err error)

func (Services) UpdateMostPopular

func (svc Services) UpdateMostPopular(ctx context.Context) (err error)

func (Services) UpdateNewsletterArchive

func (svc Services) UpdateNewsletterArchive(ctx context.Context, campaigns *mailchimp.ListCampaignsResp, mcType, dbType string) (err error)

func (Services) UpdateNewsletterArchives

func (svc Services) UpdateNewsletterArchives(ctx context.Context, types []db.NewsletterType) (err error)

func (Services) UpdateSiteConfig

func (svc Services) UpdateSiteConfig(ctx context.Context, loc string, configs []ScheduledSiteConfig) ([]db.SiteDatum, error)

func (Services) UploadGDocsImage

func (svc Services) UploadGDocsImage(ctx context.Context, arg UploadGDocsImageParams) (err error)

func (Services) UploadPendingImages

func (svc Services) UploadPendingImages(ctx context.Context) error

func (Services) UpsertSharedArticleForGDoc

func (svc Services) UpsertSharedArticleForGDoc(ctx context.Context, dbDoc *db.GDocsDoc, refreshMetadata bool) (*db.SharedArticle, error)

type SharedArticle

type SharedArticle struct {
	*db.SharedArticle
	GDocs SharedArticleGDoc `json:"gdocs"`
}

type SharedArticleGDoc

type SharedArticleGDoc struct {
	*db.GDocsDoc
	Document string `json:"document,omitempty"`
}

type UploadGDocsImageParams

type UploadGDocsImageParams struct {
	ExternalID  string
	DocObjectID string
	ImageURL    string
	Embed       *db.EmbedImage // In-out param
}

Jump to

Keyboard shortcuts

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