diff options
| author | 2026-03-31 01:07:56 +0700 | |
|---|---|---|
| committer | 2026-03-31 01:07:56 +0700 | |
| commit | 5fae0a060450cd725c398f4d2d769d4c702a8ec3 (patch) | |
| tree | be2784c8b1066c2d38a752dc5338c44b2a95c9ee | |
| parent | a8f566cbeb8358aca7fb4532d8b69c513ef197f3 (diff) | |
| download | web-5fae0a060450cd725c398f4d2d769d4c702a8ec3.tar.gz web-5fae0a060450cd725c398f4d2d769d4c702a8ec3.zip | |
feat: add google site verification token for prod
| -rw-r--r-- | .github/workflows/build-and-deploy-prod.yml | 2 | ||||
| -rw-r--r-- | config/config.go | 5 | ||||
| -rw-r--r-- | config/config.prod.yaml | 2 | ||||
| -rw-r--r-- | deploy/playbook.yml | 1 | ||||
| -rw-r--r-- | internal/router/handlers/root.go | 8 | ||||
| -rw-r--r-- | internal/router/router.go | 3 |
6 files changed, 18 insertions, 3 deletions
diff --git a/.github/workflows/build-and-deploy-prod.yml b/.github/workflows/build-and-deploy-prod.yml index 413f402..24b6e0e 100644 --- a/.github/workflows/build-and-deploy-prod.yml +++ b/.github/workflows/build-and-deploy-prod.yml @@ -75,4 +75,4 @@ jobs: ANSIBLE_HOST_KEY_CHECKING: False working-directory: ./deploy run: | - ansible-playbook -i inventory.yml -l prod playbook.yml --private-key ~/.ssh/id_ed25519 -u svc_github -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" -e saya_today_web_b2_key_id="${{ secrets.B2_KEY_ID }}" -e saya_today_web_b2_application_key="${{ secrets.B2_APPLICATION_KEY }}" -e saya_today_web_environment=prod -e saya_today_web_tag=${{ github.ref_name }} -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" + ansible-playbook -i inventory.yml -l prod playbook.yml --private-key ~/.ssh/id_ed25519 -u svc_github -e saya_today_web_auth_salt="${{ secrets.AUTH_SALT }}" -e saya_today_web_b2_key_id="${{ secrets.B2_KEY_ID }}" -e saya_today_web_b2_application_key="${{ secrets.B2_APPLICATION_KEY }}" -e saya_today_web_environment=prod -e saya_today_web_tag=${{ github.ref_name }} -e saya_today_web_mail_salt="${{ secrets.MAIL_SALT }}" -e saya_today_web_mail_host="${{ secrets.MAIL_HOST }}" -e saya_today_web_mail_address="${{ secrets.MAIL_ADDRESS }}" -e saya_today_web_mail_username="${{ secrets.MAIL_USERNAME }}" -e saya_today_web_mail_password="${{ secrets.MAIL_PASSWORD }}" -e saya_today_google_site_verification="${{ secrets.GOOGLE_SITE_VERIFICATION }}" diff --git a/config/config.go b/config/config.go index fd8c480..eb4a91d 100644 --- a/config/config.go +++ b/config/config.go @@ -17,6 +17,7 @@ type Config struct { Auth AuthConfig `json:"Auth" yaml:"auth" validate:"required"` Mail MailConfig `json:"Mail" yaml:"mail" validate:"required"` CanonicalEndpoint string `json:"CanonicalEndpoint" yaml:"canonicalEndpoint" validate:"required"` + Meta MetaConfig `json:"Meta" yaml:"meta"` } type BlogPagesConfig struct { @@ -77,6 +78,10 @@ type TriggerConfig struct { OnNewPost string `json:"OnNewPost" yaml:"onNewPost" validate:"cron,required"` } +type MetaConfig struct { + GoogleSiteVerification string `json:"GoogleSiteVerification" yaml:"googleSiteVerification"` +} + func LoadConfig(path string, config *Config) error { fileBytes, err := os.ReadFile(path) if err != nil { diff --git a/config/config.prod.yaml b/config/config.prod.yaml index 4de853c..b40ba57 100644 --- a/config/config.prod.yaml +++ b/config/config.prod.yaml @@ -45,3 +45,5 @@ mail: trigger: onNewPost: "0/5 * * * *" canonicalEndpoint: 'https://${FQDN}' +meta: + googleSiteVerification: '${GOOGLE_SITE_VERIFICATION}' diff --git a/deploy/playbook.yml b/deploy/playbook.yml index 2516f4e..b0202bd 100644 --- a/deploy/playbook.yml +++ b/deploy/playbook.yml @@ -24,6 +24,7 @@ MAIL_PASSWORD: "{{ saya_today_web_mail_password }}" MAIL_SALT: "{{ saya_today_web_mail_salt }}" FQDN: "{{ saya_today_web_listen_address }}" + GOOGLE_SITE_VERIFICATION: "{{ saya_today_google_site_verification | default('') }}" network_mode: caddy networks: - name: caddy diff --git a/internal/router/handlers/root.go b/internal/router/handlers/root.go index cd01fcd..a8890fa 100644 --- a/internal/router/handlers/root.go +++ b/internal/router/handlers/root.go @@ -41,12 +41,16 @@ func (r *RootHandler) SitemapInfo(_ *router.Supplements) []router.SitemapInfo { } func (r *RootHandler) AddMeta(c *fiber.Ctx, supplements *router.Supplements, lang string, templateMap fiber.Map) (meta []router.MetaField, err error) { - return []router.MetaField{ + meta = []router.MetaField{ {Property: "og:title", Content: "Saya Blog"}, {Property: "og:description", Content: "The blog of a 25 years old, travelling God knows where, proud to be not mainstream // Личный блог 25-летки, странствующего по ебеням, зато не мейнстрим"}, {Property: "og:url", Content: fmt.Sprint(templateMap["CanonicalEndpoint"]) + "/"}, {Property: "og:type", Content: "website"}, - }, nil + } + if supplements.Meta.GoogleSiteVerification != "" { + meta = append(meta, router.MetaField{Name: "google-site-verification", Content: supplements.Meta.GoogleSiteVerification}) + } + return meta, nil } func (r *RootHandler) RenderBody(c *fiber.Ctx, supplements *router.Supplements, _ string, templateMap fiber.Map) (statusCode int, err error) { diff --git a/internal/router/router.go b/internal/router/router.go index 0d0ce8c..3242759 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -100,6 +100,7 @@ type Supplements struct { BlogTrigger *blogtrigger.BlogTriggerScheduler TemplateManager *templatemanager.TemplateManager MarkdownRenderer goldmark.Markdown + Meta config.MetaConfig } type Router struct { @@ -215,6 +216,8 @@ func NewRouter(cfg *config.Config) (*Router, error) { return nil, fmt.Errorf("fail to initialize template manager: %w", err) } + supplements.Meta = cfg.Meta + enablePrintRoutes := false if cfg.LogLevel <= slog.LevelDebug { enablePrintRoutes = true |