triangulate

package module
v0.0.0-...-4656ccd Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2023 License: MIT Imports: 49 Imported by: 0

README

Triangulate.xyz

This was the source code for Triangulate.xyz which allows you to create computer generated art.

I created this project to learn ReactJS, this was my first project. I also wanted to make a backend in Golang and learn how to integrate Stripe for payments.

Begin by copying the .example.env file to .env and make any needed changes. To run the project simply type the following in the root folder:

yarn --cwd=assets build && go run cmd/triangulate/main.go

This project takes a lot of concepts and code from generative-art-in-go and triangle.

LICENSE

All code falls under the MIT license unless otherwise specified. Please see LICENSE

Security

Please see Security.md.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(next http.Handler) http.Handler

func GeneralHeadersMiddleware

func GeneralHeadersMiddleware(next http.Handler) http.Handler

func GenerateImage

func GenerateImage(img image.Image, width int, height int, stroke bool, StrokeThickness int, blurAmount int, shapeMin int, shapeMax int) image.Image

func RandStringRunes

func RandStringRunes(n int) string

func Run

func Run()

func SensitiveHeadersMiddleware

func SensitiveHeadersMiddleware(next http.Handler) http.Handler

func StripeSessionMiddleware

func StripeSessionMiddleware(next http.Handler) http.Handler

Types

type AuthSession

type AuthSession struct {
	gorm.Model
	UserID        uint
	AuthSessionID string
}

TODO implement purging of sessions after x time

type ContextKey

type ContextKey string
const ContextUserKey ContextKey = "user"

type GeneratePollResponse

type GeneratePollResponse struct {
	Queue         int    `json:"queue"`
	Link          string `json:"link"`
	Identifier    string `json:"identifier"`
	RandomImage   bool   `json:"randomImage"`
	Thumbnail     string `json:"thumbnail"`
	Description   string `json:"description"`
	UserName      string `json:"user_name"`
	UserLocation  string `json:"user_location"`
	UserLink      string `json:"user_link"`
	ThumbnailLink string `json:"image_link"`
}

type Image

type Image struct {
	FileName             string    `json:"file_name"`
	Identifier           string    `json:"identifier"`
	Timestamp            time.Time `json:"timestamp"`
	RequestIP            string    `json:"request_ip"`
	Width                int
	Height               int
	ImageType            string
	Shapes               bool
	Max                  int
	Min                  int
	ComplexityAmount     int
	ShapesStroke         bool
	StrokeThickness      int
	Triangulate          bool
	TriangulateBefore    bool
	MaxPoints            int
	PointsThreshold      int
	SobelThreshold       int
	TriangulateWireframe bool
	TriangulateNoise     bool
	TriangulateGrayscale bool        `json:"triangulate_grayscale"`
	Image                image.Image `gorm:"-"`
	RandomImage          bool        `json:"randomImage"`
	Thumbnail            string      `json:"thumbnail"`
	Description          string      `json:"description"`
	UserName             string      `json:"user_name"`
	UserLocation         string      `json:"user_location"`
	UserLink             string      `json:"user_link"`
	ThumbnailLink        string      `json:"image_link"`
	AuthenticatedUser    bool
	Text                 string
}

type PasswordReset

type PasswordReset struct {
	gorm.Model
	UserID    uint
	Code      string
	ExpiresAt time.Time
}

type Session

type Session struct {
	TempSessionID   string
	StripeSessionID string
	AuthSessionID   string
}

type Settings

type Settings struct {
	LoggedIn  bool   `json:"logged_in"`
	PriceId   string `json:"price_id"`
	StripeKey string `json:"stripe_key"`
}

type Stat

type Stat struct {
	gorm.Model
	Key   string
	Value int
}

type TempSession

type TempSession struct {
	gorm.Model
	SessionString   string `gorm:"unique"`
	StripeSessionID string
	Email           string
	Password        string
}

type UnsplashRandomImageResponse

type UnsplashRandomImageResponse struct {
	ID          string `json:"id"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
	Width       int    `json:"width"`
	Height      int    `json:"height"`
	Color       string `json:"color"`
	BlurHash    string `json:"blur_hash"`
	Downloads   int    `json:"downloads"`
	Likes       int    `json:"likes"`
	LikedByUser bool   `json:"liked_by_user"`
	Description string `json:"description"`
	Exif        struct {
		Make         string `json:"make"`
		Model        string `json:"model"`
		ExposureTime string `json:"exposure_time"`
		Aperture     string `json:"aperture"`
		FocalLength  string `json:"focal_length"`
		Iso          int    `json:"iso"`
	} `json:"exif"`
	Location struct {
		Name     string `json:"name"`
		City     string `json:"city"`
		Country  string `json:"country"`
		Position struct {
			Latitude  float64 `json:"latitude"`
			Longitude float64 `json:"longitude"`
		} `json:"position"`
	} `json:"location"`
	CurrentUserCollections []struct {
		ID              int         `json:"id"`
		Title           string      `json:"title"`
		PublishedAt     string      `json:"published_at"`
		LastCollectedAt string      `json:"last_collected_at"`
		UpdatedAt       string      `json:"updated_at"`
		CoverPhoto      interface{} `json:"cover_photo"`
		User            interface{} `json:"user"`
	} `json:"current_user_collections"`
	Urls struct {
		Raw     string `json:"raw"`
		Full    string `json:"full"`
		Regular string `json:"regular"`
		Small   string `json:"small"`
		Thumb   string `json:"thumb"`
	} `json:"urls"`
	Links struct {
		Self             string `json:"self"`
		HTML             string `json:"html"`
		Download         string `json:"download"`
		DownloadLocation string `json:"download_location"`
	} `json:"links"`
	User struct {
		ID                string `json:"id"`
		UpdatedAt         string `json:"updated_at"`
		Username          string `json:"username"`
		Name              string `json:"name"`
		PortfolioURL      string `json:"portfolio_url"`
		Bio               string `json:"bio"`
		Location          string `json:"location"`
		TotalLikes        int    `json:"total_likes"`
		TotalPhotos       int    `json:"total_photos"`
		TotalCollections  int    `json:"total_collections"`
		InstagramUsername string `json:"instagram_username"`
		TwitterUsername   string `json:"twitter_username"`
		Links             struct {
			Self      string `json:"self"`
			HTML      string `json:"html"`
			Photos    string `json:"photos"`
			Likes     string `json:"likes"`
			Portfolio string `json:"portfolio"`
		} `json:"links"`
	} `json:"user"`
}

type User

type User struct {
	gorm.Model
	EmailHash        string `gorm:"unique"`
	PasswordHash     string
	StripeCustomerID string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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