2
0
Files
gitcaddy-server/modules/structs/repo_pages.go
logikonline fe5b504b97
Some checks failed
Build and Release / Create Release (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m44s
Build and Release / Lint (push) Failing after 8m24s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been skipped
Build and Release / Build Binary (linux/arm64) (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 8m43s
feat(api): add v2 API endpoints for landing page configuration
Add comprehensive REST API for managing landing page configuration programmatically. Includes GET /repos/{owner}/{repo}/pages/config to retrieve full config, PUT to replace entire config, PATCH to update specific sections. Supports all config sections: brand, hero, stats, features, pricing, blog, gallery, comparison, etc. Adds UpdatePagesConfigOption and related structs for API payloads. Includes error codes for pages validation. Enables headless/automated landing page management.
2026-03-17 00:52:18 -04:00

277 lines
10 KiB
Go

// Copyright 2026 MarketAlly. All rights reserved.
// SPDX-License-Identifier: MIT
package structs
import "time"
// PagesConfig represents the pages configuration for a repository
type PagesConfig struct {
Enabled bool `json:"enabled"`
Template string `json:"template"`
Subdomain string `json:"subdomain,omitempty"`
URL string `json:"url,omitempty"`
}
// PagesDomain represents a custom domain for Gitea Pages
type PagesDomain struct {
ID int64 `json:"id"`
Domain string `json:"domain"`
Verified bool `json:"verified"`
VerificationToken string `json:"verification_token,omitempty"`
SSLStatus string `json:"ssl_status"`
SSLCertExpiry time.Time `json:"ssl_cert_expiry,omitzero"`
Created time.Time `json:"created_at"`
VerifiedAt time.Time `json:"verified_at,omitzero"`
}
// CreatePagesConfigOption options for creating/updating pages config
type CreatePagesConfigOption struct {
// Whether pages is enabled
Enabled bool `json:"enabled"`
// Template to use (simple, documentation, product, portfolio)
Template string `json:"template" binding:"In(simple,documentation,product,portfolio)"`
}
// AddPagesDomainOption options for adding a custom domain
type AddPagesDomainOption struct {
// The custom domain to add
// required: true
Domain string `json:"domain" binding:"Required"`
// Mark SSL as handled externally (e.g., by Cloudflare)
SSLExternal bool `json:"ssl_external"`
}
// PagesInfo represents the full pages information for a repository
type PagesInfo struct {
Config *PagesConfig `json:"config"`
Domains []*PagesDomain `json:"domains,omitempty"`
}
// ---------------------------------------------------------------------------
// v2 Landing Page Configuration API structs
// ---------------------------------------------------------------------------
// UpdatePagesConfigOption represents the full landing page config update.
// For PATCH, only non-nil fields are applied. For PUT, all fields replace existing config.
type UpdatePagesConfigOption struct {
Enabled *bool `json:"enabled"`
PublicLanding *bool `json:"public_landing"`
Template *string `json:"template"`
Brand *UpdatePagesBrandOption `json:"brand"`
Hero *UpdatePagesHeroOption `json:"hero"`
Stats *[]PagesStatOption `json:"stats"`
ValueProps *[]PagesValuePropOption `json:"value_props"`
Features *[]PagesFeatureOption `json:"features"`
SocialProof *UpdatePagesSocialOption `json:"social_proof"`
Pricing *UpdatePagesPricingOption `json:"pricing"`
CTASection *UpdatePagesCTAOption `json:"cta_section"`
Blog *UpdatePagesBlogOption `json:"blog"`
Gallery *UpdatePagesGalleryOption `json:"gallery"`
Comparison *UpdatePagesComparisonOption `json:"comparison"`
Navigation *UpdatePagesNavOption `json:"navigation"`
Footer *UpdatePagesFooterOption `json:"footer"`
Theme *UpdatePagesThemeOption `json:"theme"`
SEO *UpdatePagesSEOOption `json:"seo"`
Advanced *UpdatePagesAdvancedOption `json:"advanced"`
}
// UpdatePagesBrandOption represents brand section update
type UpdatePagesBrandOption struct {
Name *string `json:"name"`
LogoURL *string `json:"logo_url"`
Tagline *string `json:"tagline"`
FaviconURL *string `json:"favicon_url"`
}
// UpdatePagesHeroOption represents hero section update
type UpdatePagesHeroOption struct {
Headline *string `json:"headline"`
Subheadline *string `json:"subheadline"`
ImageURL *string `json:"image_url"`
VideoURL *string `json:"video_url"`
CodeExample *string `json:"code_example"`
PrimaryCTA *PagesCTAButtonOption `json:"primary_cta"`
SecondaryCTA *PagesCTAButtonOption `json:"secondary_cta"`
}
// PagesCTAButtonOption represents a CTA button
type PagesCTAButtonOption struct {
Label *string `json:"label"`
URL *string `json:"url"`
Variant *string `json:"variant"`
}
// PagesStatOption represents a stat item
type PagesStatOption struct {
Value string `json:"value"`
Label string `json:"label"`
}
// PagesValuePropOption represents a value proposition item
type PagesValuePropOption struct {
Title string `json:"title"`
Description string `json:"description"`
Icon string `json:"icon"`
}
// PagesFeatureOption represents a feature item
type PagesFeatureOption struct {
Title string `json:"title"`
Description string `json:"description"`
Icon string `json:"icon"`
ImageURL string `json:"image_url"`
}
// UpdatePagesSocialOption represents social proof section update
type UpdatePagesSocialOption struct {
Logos *[]string `json:"logos"`
Testimonials *[]PagesTestimonialOption `json:"testimonials"`
}
// PagesTestimonialOption represents a testimonial item
type PagesTestimonialOption struct {
Quote string `json:"quote"`
Author string `json:"author"`
Role string `json:"role"`
Avatar string `json:"avatar"`
}
// UpdatePagesPricingOption represents pricing section update
type UpdatePagesPricingOption struct {
Headline *string `json:"headline"`
Subheadline *string `json:"subheadline"`
Plans *[]PagesPricingPlanOption `json:"plans"`
}
// PagesPricingPlanOption represents a pricing plan item
type PagesPricingPlanOption struct {
Name string `json:"name"`
Price string `json:"price"`
Period string `json:"period"`
Features []string `json:"features"`
CTA string `json:"cta"`
Featured bool `json:"featured"`
}
// UpdatePagesCTAOption represents CTA section update
type UpdatePagesCTAOption struct {
Headline *string `json:"headline"`
Subheadline *string `json:"subheadline"`
Button *PagesCTAButtonOption `json:"button"`
}
// UpdatePagesBlogOption represents blog section update
type UpdatePagesBlogOption struct {
Enabled *bool `json:"enabled"`
Headline *string `json:"headline"`
Subheadline *string `json:"subheadline"`
MaxPosts *int `json:"max_posts"`
}
// UpdatePagesGalleryOption represents gallery section update
type UpdatePagesGalleryOption struct {
Enabled *bool `json:"enabled"`
Headline *string `json:"headline"`
Subheadline *string `json:"subheadline"`
MaxImages *int `json:"max_images"`
Columns *int `json:"columns"`
}
// UpdatePagesComparisonOption represents comparison section update
type UpdatePagesComparisonOption struct {
Enabled *bool `json:"enabled"`
Headline *string `json:"headline"`
Subheadline *string `json:"subheadline"`
Columns *[]PagesComparisonColumnOption `json:"columns"`
Groups *[]PagesComparisonGroupOption `json:"groups"`
}
// PagesComparisonColumnOption represents a comparison column
type PagesComparisonColumnOption struct {
Name string `json:"name"`
Highlight bool `json:"highlight"`
}
// PagesComparisonGroupOption represents a comparison group
type PagesComparisonGroupOption struct {
Name string `json:"name"`
Features []PagesComparisonFeatureOption `json:"features"`
}
// PagesComparisonFeatureOption represents a comparison feature row
type PagesComparisonFeatureOption struct {
Name string `json:"name"`
Values []string `json:"values"`
}
// UpdatePagesNavOption represents navigation section update
type UpdatePagesNavOption struct {
ShowDocs *bool `json:"show_docs"`
ShowAPI *bool `json:"show_api"`
ShowRepository *bool `json:"show_repository"`
ShowReleases *bool `json:"show_releases"`
ShowIssues *bool `json:"show_issues"`
}
// UpdatePagesFooterOption represents footer section update
type UpdatePagesFooterOption struct {
Copyright *string `json:"copyright"`
ShowPoweredBy *bool `json:"show_powered_by"`
Links *[]PagesFooterLinkOption `json:"links"`
Social *[]PagesSocialLinkOption `json:"social"`
CTASection *UpdatePagesCTAOption `json:"cta_section"`
}
// PagesFooterLinkOption represents a footer link
type PagesFooterLinkOption struct {
Label string `json:"label"`
URL string `json:"url"`
}
// PagesSocialLinkOption represents a social link
type PagesSocialLinkOption struct {
Platform string `json:"platform"`
URL string `json:"url"`
}
// UpdatePagesThemeOption represents theme section update
type UpdatePagesThemeOption struct {
PrimaryColor *string `json:"primary_color"`
AccentColor *string `json:"accent_color"`
Mode *string `json:"mode"`
}
// UpdatePagesSEOOption represents SEO section update
type UpdatePagesSEOOption struct {
Title *string `json:"title"`
Description *string `json:"description"`
Keywords *[]string `json:"keywords"`
OGImage *string `json:"og_image"`
UseMediaKitOG *bool `json:"use_media_kit_og"`
TwitterCard *string `json:"twitter_card"`
TwitterSite *string `json:"twitter_site"`
}
// UpdatePagesAdvancedOption represents advanced settings update
type UpdatePagesAdvancedOption struct {
CustomCSS *string `json:"custom_css"`
CustomHead *string `json:"custom_head"`
PublicReleases *bool `json:"public_releases"`
HideMobileReleases *bool `json:"hide_mobile_releases"`
GooglePlayID *string `json:"google_play_id"`
AppStoreID *string `json:"app_store_id"`
}
// UpdatePagesContentOption bundles content-page sections for PUT /config/content
type UpdatePagesContentOption struct {
Blog *UpdatePagesBlogOption `json:"blog"`
Gallery *UpdatePagesGalleryOption `json:"gallery"`
ComparisonEnabled *bool `json:"comparison_enabled"`
Stats *[]PagesStatOption `json:"stats"`
ValueProps *[]PagesValuePropOption `json:"value_props"`
Features *[]PagesFeatureOption `json:"features"`
Navigation *UpdatePagesNavOption `json:"navigation"`
Advanced *UpdatePagesAdvancedOption `json:"advanced"`
}