From 3c7b668cde6b17262e95af4ce991761e19804823 Mon Sep 17 00:00:00 2001 From: Landwelle Server Date: Fri, 4 Dec 2026 15:28:52 +0100 Subject: [PATCH] feat(editorial): two-column editor and scheduled publication --- CHANGELOG.md | 7 + README.md | 2 +- cmd/portal/admin.go | 56 +++++++- cmd/portal/editorial.go | 96 ++++++++++++-- cmd/portal/editorial_schedule_test.go | 88 +++++++++++++ cmd/portal/main.go | 3 +- cmd/portal/main_test.go | 2 +- cmd/portal/news.go | 8 +- cmd/portal/web/admin/editorial.html | 30 +++-- cmd/portal/web/assets/admin-editorial-v39.js | 122 ++++++++++++++++++ cmd/portal/web/assets/admin-editorial-v43.css | 22 ++++ docs/EDITORIAL_MEDIA.md | 7 +- scripts/test-postgres-integration.sh | 1 + 13 files changed, 404 insertions(+), 40 deletions(-) create mode 100644 cmd/portal/editorial_schedule_test.go create mode 100644 cmd/portal/web/assets/admin-editorial-v39.js create mode 100644 cmd/portal/web/assets/admin-editorial-v43.css diff --git a/CHANGELOG.md b/CHANGELOG.md index abefe0f..c776ce3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## v1.5.84 – Redaktion: zweispaltiger Editor und Veröffentlichungsplanung (04.12.2026) + +- Beitragsinhalt und Bildauswahl links; Datum, Facebook, KI-Transparenz und Speichern rechts; auf kleinen Bildschirmen untereinander. +- Veröffentlichungsdatum standardmäßig heute; zukünftige freigegebene Beiträge erscheinen ab Mitternacht in Europe/Berlin. Entwürfe bleiben unveröffentlicht. +- Öffentliche Übersichten, API und Direktlinks berücksichtigen den Termin. Geplante Facebook-Beiträge werden bei laufendem Portal automatisch fällig und atomar reserviert; Versandfehler bleiben zur manuellen Prüfung sichtbar. +- Bestehendes PostgreSQL-Feld published_at wird weiterverwendet; keine Migration erforderlich. + ## v1.5.83 – Plattformmodernisierung (03.12.2026) - Go 1.27.4 in Modul, Gitea CI und optionalem Container-Build. diff --git a/README.md b/README.md index abbb240..e0e6300 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Landwelle wächst Schritt für Schritt. Hinter dem Programm und dem Portal stehe Hier liegt der **Quellcode des Landwelle-Webportals**, nicht die Musikbibliothek oder der eigentliche Sendestream. Die Anwendung wird für den Produktivbetrieb auf einem Linux-x64-Server entwickelt und über [Gitea](https://git.stadt-nexverse.de/nexverse/landwelle) versioniert. -**Aktueller Anwendungsstand:** Landwelle **v1.5.83**. Das Repository ist für Gitea und eine klare Verzeichnisstruktur eingerichtet. Repository-Pflege allein installiert keine neue Portalversion. +**Aktueller Anwendungsstand:** Landwelle **v1.5.84**. Das Repository ist für Gitea und eine klare Verzeichnisstruktur eingerichtet. Repository-Pflege allein installiert keine neue Portalversion. ### Technische Grundlage diff --git a/cmd/portal/admin.go b/cmd/portal/admin.go index 0d1b3aa..9927739 100644 --- a/cmd/portal/admin.go +++ b/cmd/portal/admin.go @@ -1678,17 +1678,23 @@ func (a *adminHandler) setEditorialFacebookStatus(id int64, status string) { } } -func (a *adminHandler) publishEditorialFacebook(ctx context.Context, entry EditorialEntry) error { +func (a *adminHandler) publishEditorialFacebook(ctx context.Context, entry EditorialEntry, automatic bool) error { if entry.ID <= 0 { return errors.New("der redaktionelle Inhalt besitzt keine gültige ID") } - if entry.Status != "published" { + if !entry.IsPublished() { return errors.New("der Inhalt muss zuerst veröffentlicht werden") } if !entry.PostToFacebook { return errors.New("Facebook ist für diesen Inhalt nicht ausgewählt") } - a.setEditorialFacebookStatus(entry.ID, "sending") + claimed, err := a.editorial.ClaimFacebook(ctx, entry.ID, automatic) + if err != nil { + return err + } + if !claimed { + return errors.New("Facebook-Versand nicht fällig oder bereits in Bearbeitung") + } fbCtx, cancel := context.WithTimeout(ctx, 25*time.Second) postID, err := newFacebookPublisher().Publish(fbCtx, a.settings.Get().Social, entry) cancel() @@ -1780,7 +1786,7 @@ func (a *adminHandler) adminEditorial(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/admin/editorial?tab=contents&facebook=missing", http.StatusSeeOther) return } - if err := a.publishEditorialFacebook(ctx, entry); err != nil { + if err := a.publishEditorialFacebook(ctx, entry, false); err != nil { http.Redirect(w, r, "/admin/editorial?tab=contents&facebook=failed", http.StatusSeeOther) return } @@ -1811,6 +1817,15 @@ func (a *adminHandler) adminEditorial(w http.ResponseWriter, r *http.Request) { MediaAssetID: parseInt64(r.FormValue("media_asset_id")), PostToFacebook: r.FormValue("post_to_facebook") == "on", } + publication, dateErr := parseEditorialPublicationDate(r.FormValue("publication_date"), previous, time.Now()) + if dateErr != nil { + data.Edit = entry + data.HasEdit = id > 0 + data.Error = dateErr.Error() + a.renderEditorial(w, data) + return + } + entry.PublishedAt = publication saved, err := a.editorial.SaveAndGet(ctx, entry) if err != nil { data.Edit = entry @@ -1821,10 +1836,10 @@ func (a *adminHandler) adminEditorial(w http.ResponseWriter, r *http.Request) { return } - shouldPublishFacebook := saved.Status == "published" && saved.PostToFacebook && + shouldPublishFacebook := saved.IsPublished() && saved.PostToFacebook && (id == 0 || !previous.PostToFacebook || !strings.HasPrefix(strings.TrimSpace(previous.FacebookStatus), "published")) if shouldPublishFacebook { - if err := a.publishEditorialFacebook(ctx, saved); err != nil { + if err := a.publishEditorialFacebook(ctx, saved, true); err != nil { http.Redirect(w, r, "/admin/editorial?tab=contents&saved=1&facebook=failed", http.StatusSeeOther) return } @@ -3208,3 +3223,32 @@ func (a *adminHandler) adminAutoTasks(w http.ResponseWriter, r *http.Request) { } render() } + +func (a *adminHandler) runEditorialSchedule(ctx context.Context) { + ticker := time.NewTicker(30 * time.Second) + defer ticker.Stop() + for { + if ctx.Err() != nil { + return + } + check, cancel := context.WithTimeout(ctx, 10*time.Second) + items, err := a.editorial.DueScheduledFacebook(check) + cancel() + if err != nil { + a.logger.Printf("editorial schedule: %v", err) + } + for _, entry := range items { + if ctx.Err() != nil { + return + } + if err := a.publishEditorialFacebook(ctx, entry, true); err != nil { + a.logger.Printf("editorial scheduled Facebook %d: %v", entry.ID, err) + } + } + select { + case <-ctx.Done(): + return + case <-ticker.C: + } + } +} diff --git a/cmd/portal/editorial.go b/cmd/portal/editorial.go index 33028d1..31ae39d 100644 --- a/cmd/portal/editorial.go +++ b/cmd/portal/editorial.go @@ -108,7 +108,60 @@ func (e EditorialEntry) UpdatedLabel() string { return e.UpdatedAt.Local().Format("02.01.2006 · 15:04") } +func editorialLocation() *time.Location { + loc, err := time.LoadLocation("Europe/Berlin") + if err != nil { + return time.Local + } + return loc +} +func (e EditorialEntry) PublicationDate() string { + t := e.PublishedAt + if t.IsZero() { + t = time.Now() + } + return t.In(editorialLocation()).Format("2006-01-02") +} +func (e EditorialEntry) PublicationLabel() string { + return e.PublishedAt.In(editorialLocation()).Format("02.01.2006") +} +func (e EditorialEntry) IsScheduled() bool { + return e.Status == "published" && e.PublishedAt.After(time.Now()) +} +func (e EditorialEntry) IsPublished() bool { + return e.Status == "published" && !e.PublishedAt.After(time.Now()) +} +func (e EditorialEntry) DisplayStatus() string { + if e.IsScheduled() { + return "scheduled" + } + return e.Status +} +func parseEditorialPublicationDate(raw string, previous EditorialEntry, now time.Time) (time.Time, error) { + loc := editorialLocation() + if strings.TrimSpace(raw) == "" { + if !previous.PublishedAt.IsZero() { + return previous.PublishedAt, nil + } + return now, nil + } + t, err := time.ParseInLocation("2006-01-02", raw, loc) + if err != nil { + return time.Time{}, errors.New("Ungültiges Veröffentlichungsdatum") + } + if !previous.PublishedAt.IsZero() && previous.PublicationDate() == raw { + return previous.PublishedAt, nil + } + if raw == now.In(loc).Format("2006-01-02") { + return now, nil + } + return t, nil +} + func (e EditorialEntry) StatusLabel() string { + if e.IsScheduled() { + return "Geplant" + } switch strings.TrimSpace(e.Status) { case "draft": return "Entwurf" @@ -151,7 +204,7 @@ func (e EditorialEntry) FacebookStatusLabel() string { case "sending": return "Wird an Facebook übertragen" default: - if e.Status != "published" { + if !e.IsPublished() { return "Wird nach Veröffentlichung gesendet" } return "Facebook-Versand steht aus" @@ -286,21 +339,20 @@ func (s *editorialStore) Save(ctx context.Context, e EditorialEntry) error { if !allowedStatus[e.Status] { return errors.New("ungültiger Status") } + publicationSQL := "now()" + if !e.PublishedAt.IsZero() { + publicationSQL = sqlText(e.PublishedAt.UTC().Format(time.RFC3339Nano)) + "::timestamptz" + } mediaSQL := "NULL" if e.MediaAssetID > 0 { mediaSQL = strconv.FormatInt(e.MediaAssetID, 10) } if e.ID == 0 { - q := `INSERT INTO landwelle.editorial_entries(content_type,title,slug,teaser,body,location,status,ai_generated,ai_usage,ai_human_reviewed,ai_editorial_responsible,ai_disclosure,media_asset_id,post_to_facebook,published_at) VALUES (` + sqlText(e.ContentType) + `,` + sqlText(e.Title) + `,` + sqlText(e.Slug) + `,` + sqlText(e.Teaser) + `,` + sqlText(e.Body) + `,` + sqlText(e.Location) + `,` + sqlText(e.Status) + `,` + sqlBool(e.AIGenerated) + `,` + sqlText(e.AIUsage) + `,` + sqlBool(e.AIHumanReviewed) + `,` + sqlText(e.AIEditorialResponsible) + `,` + sqlText(e.AIDisclosure) + `,` + mediaSQL + `,` + sqlBool(e.PostToFacebook) + `,` + func() string { - if e.Status == "published" { - return "now()" - } - return "NULL" - }() + `);` + q := `INSERT INTO landwelle.editorial_entries(content_type,title,slug,teaser,body,location,status,ai_generated,ai_usage,ai_human_reviewed,ai_editorial_responsible,ai_disclosure,media_asset_id,post_to_facebook,published_at,facebook_status) VALUES (` + sqlText(e.ContentType) + `,` + sqlText(e.Title) + `,` + sqlText(e.Slug) + `,` + sqlText(e.Teaser) + `,` + sqlText(e.Body) + `,` + sqlText(e.Location) + `,` + sqlText(e.Status) + `,` + sqlBool(e.AIGenerated) + `,` + sqlText(e.AIUsage) + `,` + sqlBool(e.AIHumanReviewed) + `,` + sqlText(e.AIEditorialResponsible) + `,` + sqlText(e.AIDisclosure) + `,` + mediaSQL + `,` + sqlBool(e.PostToFacebook) + `,` + publicationSQL + `,CASE WHEN ` + sqlBool(e.PostToFacebook && e.Status == "published") + ` AND ` + publicationSQL + ` > now() THEN 'scheduled' ELSE 'pending' END);` _, err := s.db.exec(ctx, q) return err } - q := `UPDATE landwelle.editorial_entries SET content_type=` + sqlText(e.ContentType) + `,title=` + sqlText(e.Title) + `,slug=` + sqlText(e.Slug) + `,teaser=` + sqlText(e.Teaser) + `,body=` + sqlText(e.Body) + `,location=` + sqlText(e.Location) + `,status=` + sqlText(e.Status) + `,ai_generated=` + sqlBool(e.AIGenerated) + `,ai_usage=` + sqlText(e.AIUsage) + `,ai_human_reviewed=` + sqlBool(e.AIHumanReviewed) + `,ai_editorial_responsible=` + sqlText(e.AIEditorialResponsible) + `,ai_disclosure=` + sqlText(e.AIDisclosure) + `,media_asset_id=` + mediaSQL + `,post_to_facebook=` + sqlBool(e.PostToFacebook) + `,facebook_status=CASE WHEN NOT ` + sqlBool(e.PostToFacebook) + ` OR ` + sqlText(e.Status) + `<>'published' THEN 'pending' ELSE facebook_status END,published_at=CASE WHEN ` + sqlText(e.Status) + `='published' THEN COALESCE(published_at,now()) ELSE published_at END,updated_at=now() WHERE id=` + strconv.FormatInt(e.ID, 10) + `;` + q := `UPDATE landwelle.editorial_entries SET content_type=` + sqlText(e.ContentType) + `,title=` + sqlText(e.Title) + `,slug=` + sqlText(e.Slug) + `,teaser=` + sqlText(e.Teaser) + `,body=` + sqlText(e.Body) + `,location=` + sqlText(e.Location) + `,status=` + sqlText(e.Status) + `,ai_generated=` + sqlBool(e.AIGenerated) + `,ai_usage=` + sqlText(e.AIUsage) + `,ai_human_reviewed=` + sqlBool(e.AIHumanReviewed) + `,ai_editorial_responsible=` + sqlText(e.AIEditorialResponsible) + `,ai_disclosure=` + sqlText(e.AIDisclosure) + `,media_asset_id=` + mediaSQL + `,post_to_facebook=` + sqlBool(e.PostToFacebook) + `,facebook_status=CASE WHEN NOT ` + sqlBool(e.PostToFacebook) + ` OR ` + sqlText(e.Status) + `<>'published' THEN 'pending' WHEN facebook_status LIKE 'published%' OR facebook_status='sending' THEN facebook_status WHEN ` + publicationSQL + ` > now() THEN 'scheduled' WHEN facebook_status='scheduled' THEN 'pending' ELSE facebook_status END,published_at=` + publicationSQL + `,updated_at=now() WHERE id=` + strconv.FormatInt(e.ID, 10) + `;` _, err = s.db.exec(ctx, q) return err } @@ -399,7 +451,7 @@ func homepageStoriesQuery(limit int) string { if limit > 0 { limitClause = " LIMIT " + strconv.Itoa(limit) } - return `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `) ORDER BY COALESCE(e.published_at,e.updated_at) DESC),'[]'::json)::text FROM (SELECT e.* FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types type_filter ON type_filter.slug=e.content_type WHERE e.status='published' AND type_filter.active=true AND type_filter.homepage_section=true ORDER BY COALESCE(e.published_at,e.updated_at) DESC` + limitClause + `) e LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id LEFT JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type;` + return `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `) ORDER BY COALESCE(e.published_at,e.updated_at) DESC),'[]'::json)::text FROM (SELECT e.* FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types type_filter ON type_filter.slug=e.content_type WHERE e.status='published' AND COALESCE(e.published_at,e.updated_at)<=now() AND type_filter.active=true AND type_filter.homepage_section=true ORDER BY COALESCE(e.published_at,e.updated_at) DESC` + limitClause + `) e LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id LEFT JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type;` } func (s *editorialStore) HomepageStories(ctx context.Context, limit int) ([]EditorialEntry, error) { @@ -447,7 +499,7 @@ func (s *editorialStore) HomepageContentTypes(ctx context.Context) ([]EditorialC } func homepageStoriesByCategoryQuery(category string) string { - return `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `) ORDER BY COALESCE(e.published_at,e.updated_at) DESC),'[]'::json)::text FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id WHERE e.status='published' AND ct.active=true AND ct.homepage_section=true AND e.content_type=` + sqlText(strings.TrimSpace(category)) + `;` + return `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `) ORDER BY COALESCE(e.published_at,e.updated_at) DESC),'[]'::json)::text FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id WHERE e.status='published' AND COALESCE(e.published_at,e.updated_at)<=now() AND ct.active=true AND ct.homepage_section=true AND e.content_type=` + sqlText(strings.TrimSpace(category)) + `;` } // HomepageStoriesByCategory liefert alle veröffentlichten Vor-Ort-Beiträge @@ -468,7 +520,7 @@ func (s *editorialStore) HomepageStoryBySlug(ctx context.Context, slug string) ( return EditorialEntry{}, false, errors.New("PostgreSQL ist nicht konfiguriert") } var items []EditorialEntry - query := `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `)),'[]'::json)::text FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id WHERE e.slug=` + sqlText(strings.TrimSpace(slug)) + ` AND e.status='published' AND ct.active=true AND ct.homepage_section=true LIMIT 1;` + query := `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `)),'[]'::json)::text FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id WHERE e.slug=` + sqlText(strings.TrimSpace(slug)) + ` AND e.status='published' AND COALESCE(e.published_at,e.updated_at)<=now() AND ct.active=true AND ct.homepage_section=true LIMIT 1;` if err := s.db.queryJSON(ctx, query, &items); err != nil { return EditorialEntry{}, false, err } @@ -483,7 +535,7 @@ func (s *editorialStore) HomepageStoryByCategoryAndSlug(ctx context.Context, cat return EditorialEntry{}, false, errors.New("PostgreSQL ist nicht konfiguriert") } var items []EditorialEntry - query := `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `)),'[]'::json)::text FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id WHERE e.content_type=` + sqlText(strings.TrimSpace(category)) + ` AND e.slug=` + sqlText(strings.TrimSpace(slug)) + ` AND e.status='published' AND ct.active=true AND ct.homepage_section=true LIMIT 1;` + query := `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `)),'[]'::json)::text FROM landwelle.editorial_entries e JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id WHERE e.content_type=` + sqlText(strings.TrimSpace(category)) + ` AND e.slug=` + sqlText(strings.TrimSpace(slug)) + ` AND e.status='published' AND COALESCE(e.published_at,e.updated_at)<=now() AND ct.active=true AND ct.homepage_section=true LIMIT 1;` if err := s.db.queryJSON(ctx, query, &items); err != nil { return EditorialEntry{}, false, err } @@ -515,3 +567,23 @@ func (s *editorialStore) GetBySlug(ctx context.Context, slug string) (EditorialE } return items[0], true, nil } + +// The database retains scheduled Facebook work across portal restarts. +func (s *editorialStore) DueScheduledFacebook(ctx context.Context) ([]EditorialEntry, error) { + if !s.Enabled() { + return nil, nil + } + var items []EditorialEntry + q := `SELECT COALESCE(json_agg(json_build_object(` + editorialJSON + `)),'[]'::json)::text FROM landwelle.editorial_entries e LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id LEFT JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type WHERE e.status='published' AND e.published_at<=now() AND e.post_to_facebook AND e.facebook_status='scheduled';` + return items, s.db.queryJSON(ctx, q, &items) +} +func (s *editorialStore) ClaimFacebook(ctx context.Context, id int64, automatic bool) (bool, error) { + var rows []struct{ ID int64 } + guard := "facebook_status<>'sending'" + if automatic { + guard = "(facebook_status IN ('pending','scheduled') OR facebook_status LIKE 'failed:%')" + } + q := `WITH claimed AS (UPDATE landwelle.editorial_entries SET facebook_status='sending' WHERE id=` + strconv.FormatInt(id, 10) + ` AND status='published' AND COALESCE(published_at,updated_at)<=now() AND post_to_facebook AND ` + guard + ` RETURNING id) SELECT COALESCE(json_agg(claimed),'[]'::json)::text FROM claimed;` + err := s.db.queryJSON(ctx, q, &rows) + return len(rows) > 0, err +} diff --git a/cmd/portal/editorial_schedule_test.go b/cmd/portal/editorial_schedule_test.go new file mode 100644 index 0000000..0fc7295 --- /dev/null +++ b/cmd/portal/editorial_schedule_test.go @@ -0,0 +1,88 @@ +package main + +import ( + "context" + "os" + "testing" + "time" +) + +func TestEditorialPublicationDate(t *testing.T) { + loc := editorialLocation() + now := time.Date(2026, 12, 4, 15, 24, 0, 0, loc) + today, err := parseEditorialPublicationDate("2026-12-04", EditorialEntry{}, now) + if err != nil || !today.Equal(now) { + t.Fatalf("today: %v %v", today, err) + } + future, err := parseEditorialPublicationDate("2027-07-01", EditorialEntry{}, now) + if err != nil || !future.Equal(time.Date(2027, 6, 30, 22, 0, 0, 0, time.UTC)) { + t.Fatalf("future: %v %v", future, err) + } + if _, err := parseEditorialPublicationDate("2026-02-31", EditorialEntry{}, now); err == nil { + t.Fatal("invalid date accepted") + } + e := EditorialEntry{Status: "published", PublishedAt: time.Now().Add(24 * time.Hour)} + if !e.IsScheduled() || e.IsPublished() || e.DisplayStatus() != "scheduled" { + t.Fatal("future publication must be hidden") + } + e.PublishedAt = time.Now().Add(-time.Hour) + if !e.IsPublished() || e.IsScheduled() { + t.Fatal("due publication must be visible") + } + e.Status = "draft" + if e.IsPublished() { + t.Fatal("draft must remain hidden") + } +} + +func TestEditorialSchedulePostgres(t *testing.T) { + url := os.Getenv("LANDWELLE_TEST_DATABASE_URL") + if url == "" { + t.Skip("requires disposable PostgreSQL") + } + t.Setenv("DATABASE_URL", url) + db, err := newPostgresStore() + if err != nil { + t.Fatal(err) + } + defer db.Close() + s := newEditorialStore(db) + ctx := context.Background() + cat := EditorialContentType{Slug: "schedule-test", Name: "Schedule test", Active: true, HomepageSection: true} + if err := s.SaveContentType(ctx, cat); err != nil { + t.Fatal(err) + } + e := EditorialEntry{ContentType: cat.Slug, Title: "Schedule integration test", Status: "published", PostToFacebook: true, PublishedAt: time.Now().Add(48 * time.Hour)} + saved, err := s.SaveAndGet(ctx, e) + if err != nil { + t.Fatal(err) + } + defer s.Delete(ctx, saved.ID) + if !saved.IsScheduled() || saved.FacebookStatus != "scheduled" { + t.Fatalf("unexpected saved status: %+v", saved) + } + if _, ok, err := s.HomepageStoryByCategoryAndSlug(ctx, cat.Slug, saved.Slug); err != nil || ok { + t.Fatalf("future direct link exposed: %v %v", ok, err) + } + if items, err := s.HomepageStoriesByCategory(ctx, cat.Slug); err != nil || len(items) != 0 { + t.Fatalf("future list exposed: %v %v", items, err) + } + if ok, err := s.ClaimFacebook(ctx, saved.ID, false); err != nil || ok { + t.Fatalf("future Facebook claim: %v %v", ok, err) + } + if _, err := db.exec(ctx, "UPDATE landwelle.editorial_entries SET published_at=now()-interval '1 second' WHERE slug='schedule-integration-test';"); err != nil { + t.Fatal(err) + } + if _, ok, err := s.HomepageStoryByCategoryAndSlug(ctx, cat.Slug, saved.Slug); err != nil || !ok { + t.Fatalf("due direct link missing: %v %v", ok, err) + } + if items, err := s.DueScheduledFacebook(ctx); err != nil || len(items) != 1 || items[0].ID != saved.ID { + t.Fatalf("due list: %v %v", items, err) + } + if ok, err := s.ClaimFacebook(ctx, saved.ID, true); err != nil || !ok { + t.Fatalf("claim: %v %v", ok, err) + } + if ok, err := s.ClaimFacebook(ctx, saved.ID, true); err != nil || ok { + t.Fatalf("duplicate claim: %v %v", ok, err) + } +} diff --git a/cmd/portal/main.go b/cmd/portal/main.go index 282afc2..6d6fae9 100644 --- a/cmd/portal/main.go +++ b/cmd/portal/main.go @@ -40,7 +40,7 @@ const ( apiVersion = "v1" apiContractVersion = "1.0.0" applicationName = "Landwelle Radio" - applicationVersion = "1.5.83" + applicationVersion = "1.5.84" ) var publicTemplateFiles = []string{ @@ -308,6 +308,7 @@ func main() { admin.apiMetrics = &monitoring.Metrics{} admin.giteaStatus = &giteastatus.Service{} go admin.giteaStatus.Run(workerCtx) + go admin.runEditorialSchedule(workerCtx) if database.pool != nil { admin.productionQueue = &jobqueue.Queue{Pool: database.pool} check, cancel := context.WithTimeout(context.Background(), 5*time.Second) diff --git a/cmd/portal/main_test.go b/cmd/portal/main_test.go index 872fda7..70fd35e 100644 --- a/cmd/portal/main_test.go +++ b/cmd/portal/main_test.go @@ -147,7 +147,7 @@ func TestWeatherHelpers(t *testing.T) { } func TestApplicationVersion(t *testing.T) { - if applicationVersion != "1.5.83" { + if applicationVersion != "1.5.84" { t.Fatalf("unexpected application version %q", applicationVersion) } } diff --git a/cmd/portal/news.go b/cmd/portal/news.go index dc31ae1..e231db9 100644 --- a/cmd/portal/news.go +++ b/cmd/portal/news.go @@ -94,7 +94,7 @@ SELECT json_build_object(` + editorialJSON + `) AS item, COALESCE(e.published_at FROM landwelle.editorial_entries e LEFT JOIN landwelle.media_assets m ON m.id=e.media_asset_id LEFT JOIN landwelle.editorial_content_types ct ON ct.slug=e.content_type -WHERE e.content_type='news' AND e.status='published' +WHERE e.content_type='news' AND e.status='published' AND COALESCE(e.published_at,e.updated_at)<=now() ORDER BY COALESCE(e.published_at,e.updated_at) DESC LIMIT ` + strconv.Itoa(limit) + `) x;` return items, s.db.queryJSON(ctx, q, &items) @@ -269,7 +269,7 @@ func loadPublicNewsBuckets(ctx context.Context, editorial *editorialStore, rss * if image == "" { image = "/assets/news-region-v14.jpg" } - localItems = append(localItems, PublicNewsItem{ID: entry.ID, Title: entry.Title, Teaser: entry.Teaser, Body: entry.Body, ImageURL: image, ImageAlt: entry.MediaAlt, Location: entry.Location, Source: "Landwelle Redaktion", ArticleURL: "/aktuelles/" + entry.Slug, PublishedAt: entry.UpdatedAt, Editorial: true}) + localItems = append(localItems, PublicNewsItem{ID: entry.ID, Title: entry.Title, Teaser: entry.Teaser, Body: entry.Body, ImageURL: image, ImageAlt: entry.MediaAlt, Location: entry.Location, Source: "Landwelle Redaktion", ArticleURL: "/aktuelles/" + entry.Slug, PublishedAt: entry.PublishedAt, Editorial: true}) ownCount++ } if rss != nil { @@ -472,7 +472,7 @@ func newsArticleHandler(t *template.Template, logger *log.Logger, data PageData, return } entry, found, err := editorial.GetBySlug(r.Context(), slug) - if err != nil || !found || entry.Status != "published" || entry.ContentType != "news" { + if err != nil || !found || !entry.IsPublished() || entry.ContentType != "news" { http.NotFound(w, r) return } @@ -480,7 +480,7 @@ func newsArticleHandler(t *template.Template, logger *log.Logger, data PageData, if image == "" { image = "/assets/news-region-v14.jpg" } - payload := NewsArticlePageData{PageData: data, Article: PublicNewsItem{ID: entry.ID, Title: entry.Title, Teaser: entry.Teaser, Body: entry.Body, ImageURL: image, ImageAlt: entry.MediaAlt, Location: entry.Location, Source: "Landwelle Redaktion", ArticleURL: r.URL.Path, PublishedAt: entry.UpdatedAt, Editorial: true}} + payload := NewsArticlePageData{PageData: data, Article: PublicNewsItem{ID: entry.ID, Title: entry.Title, Teaser: entry.Teaser, Body: entry.Body, ImageURL: image, ImageAlt: entry.MediaAlt, Location: entry.Location, Source: "Landwelle Redaktion", ArticleURL: r.URL.Path, PublishedAt: entry.PublishedAt, Editorial: true}} w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Cache-Control", "no-store") if r.Method == http.MethodHead { diff --git a/cmd/portal/web/admin/editorial.html b/cmd/portal/web/admin/editorial.html index 3c55273..cc751b5 100644 --- a/cmd/portal/web/admin/editorial.html +++ b/cmd/portal/web/admin/editorial.html @@ -8,9 +8,9 @@ Redaktion – Landwelle - + - +
@@ -36,25 +36,25 @@
- +
InhaltKategorie & StatusVerteilungAktionen
{{range .Items}} -
+
{{if .MediaURL}}{{.MediaAlt}}{{else}}LW{{end}}
{{.Title}}

{{if .Teaser}}{{.Teaser}}{{else}}Noch kein Teaser hinterlegt.{{end}}

{{if .Location}}⌖ {{.Location}} · {{end}}Aktualisiert {{.UpdatedLabel}}
-
{{.ContentTypeLabel}}{{.StatusLabel}}{{if .HomepageSection}}Landwelle vor Ort{{end}}{{if .HasAITransparency}}✦ {{.AIShortLabel}}{{.AIReviewLabel}}{{end}}{{if .HasMediaAITransparency}}Bild: KI-Inhalt{{end}}
+
{{.ContentTypeLabel}}{{.StatusLabel}}{{if .IsScheduled}}Veröffentlichung: {{.PublicationLabel}}{{end}}{{if .HomepageSection}}Landwelle vor Ort{{end}}{{if .HasAITransparency}}✦ {{.AIShortLabel}}{{.AIReviewLabel}}{{end}}{{if .HasMediaAITransparency}}Bild: KI-Inhalt{{end}}
- {{if .PublicPath}}Ansehen{{end}} + {{if and .PublicPath .IsPublished}}Ansehen{{end}} Bearbeiten - {{if and .PostToFacebook (eq .Status "published")}}
{{end}} + {{if and .PostToFacebook .IsPublished}}
{{end}}
@@ -69,7 +69,7 @@
{{if .HasEdit}}Beitrag bearbeiten{{else}}Neuer Inhalt{{end}}

{{if .HasEdit}}{{.Edit.Title}}{{else}}Inhalt anlegen{{end}}

Erst speichern, dann erscheint der Inhalt in der übersichtlichen Inhaltsliste.

{{if .HasEdit}}Bearbeitung schließen{{end}}
-
+
@@ -78,12 +78,9 @@
Beitragsbild aus der Mediengalerie
{{range .Media}}{{end}}
Zur Mediengalerie / neues Bild hochladen
-
Veröffentlichung
-
KI-Transparenz nach Art. 50 EU-KI-Verordnung

Lege fest, welchen Anteil künstliche Intelligenz am veröffentlichten Inhalt hatte. Die öffentliche Kennzeichnung wird daraus automatisch erzeugt.

Öffentliche KI-Transparenzseite öffnen ↗
-
Zur Inhaltsliste
- -
- +
Veröffentlichung
+
KI-Transparenz nach Art. 50 EU-KI-Verordnung

Lege fest, welchen Anteil künstliche Intelligenz am veröffentlichten Inhalt hatte. Die öffentliche Kennzeichnung wird daraus automatisch erzeugt.

Öffentliche KI-Transparenzseite öffnen ↗
+
Zur Inhaltsliste
+
+ + + + {{end}} diff --git a/cmd/portal/web/assets/admin-editorial-v39.js b/cmd/portal/web/assets/admin-editorial-v39.js new file mode 100644 index 0000000..bef3006 --- /dev/null +++ b/cmd/portal/web/assets/admin-editorial-v39.js @@ -0,0 +1,122 @@ +(() => { + const makeSlug = value => value.toLowerCase().trim() + .replace(/ä/g, 'ae').replace(/ö/g, 'oe').replace(/ü/g, 'ue').replace(/ß/g, 'ss') + .normalize('NFD').replace(/[\u0300-\u036f]/g, '') + .replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, ''); + + const form = document.querySelector('[data-editorial-form]'); + if (form) { + const title = form.querySelector('[data-editorial-title]'); + const slug = form.querySelector('[data-editorial-slug]'); + const teaser = form.querySelector('[data-editorial-teaser]'); + const category = form.querySelector('[data-editorial-category]'); + const status = form.querySelector('[data-editorial-status]'); + const facebookToggle = form.querySelector('[data-facebook-toggle]'); + const aiUsage = form.querySelector('[name="ai_usage"]'); + const aiDisclosure = form.querySelector('[name="ai_disclosure"]'); + const preview = document.querySelector('[data-facebook-preview]'); + + const updatePreview = () => { + const generatedSlug = makeSlug(title?.value || ''); + if (slug) slug.value = generatedSlug; + if (!preview) return; + + preview.hidden = !facebookToggle?.checked; + if (preview.hidden) return; + + const titleValue = (title?.value || '').trim() || 'Titel des Beitrags'; + const teaserValue = (teaser?.value || '').trim() || 'Der kurze Einstieg deines Beitrags erscheint hier.'; + const selectedCategory = category?.selectedOptions?.[0]; + const isHomepageCategory = selectedCategory?.dataset.homepage === '1'; + const isPublished = status?.value === 'published'; + const base = (preview.dataset.publicBase || 'https://landwelle.de').replace(/\/+$/, ''); + const categorySlug = category?.value || 'kategorie'; + const publicPath = `/landwelle-vor-ort/${categorySlug}/${generatedSlug || 'dein-beitrag'}`; + + const message = preview.querySelector('[data-facebook-message]'); + const previewTitle = preview.querySelector('[data-facebook-title]'); + const previewTeaser = preview.querySelector('[data-facebook-teaser]'); + const previewLink = preview.querySelector('[data-facebook-link]'); + const note = preview.querySelector('[data-facebook-note]'); + const aiValue = aiUsage?.value || 'none'; + const aiDefaults = { + assisted: 'Dieser Inhalt wurde mit Unterstützung künstlicher Intelligenz erstellt.', + generated: 'Dieser Inhalt wurde mithilfe künstlicher Intelligenz erstellt.', + manipulated: 'Dieser Inhalt wurde mithilfe künstlicher Intelligenz wesentlich bearbeitet.' + }; + const aiText = (aiDisclosure?.value || '').trim() || aiDefaults[aiValue] || ''; + if (message) message.textContent = `${titleValue}\n\n${teaserValue}${aiText ? `\n\nKI-Transparenz: ${aiText}` : ''}`; + if (previewTitle) previewTitle.textContent = titleValue; + if (previewTeaser) previewTeaser.textContent = teaserValue; + if (previewLink) previewLink.textContent = isHomepageCategory ? `${base}${publicPath}` : 'Noch keine öffentliche Beitragsseite'; + + if (note) { + note.classList.toggle('is-warning', !isHomepageCategory); + if (!isHomepageCategory) { + note.textContent = 'Diese Kategorie ist nicht für „Landwelle vor Ort“ freigeschaltet. Facebook kann den Beitrag deshalb nicht mit einer öffentlichen Landwelle-Seite verknüpfen.'; + } else if (!isPublished) { + note.textContent = 'Der Beitrag wird erst an Facebook gesendet, wenn du den Status auf „Veröffentlicht“ stellst.'; + } else { + note.textContent = 'Der Beitrag wird zum gewählten Veröffentlichungsdatum an die eingerichtete Facebook-Seite gesendet.'; + } + } + + const selectedMedia = form.querySelector('input[name="media_asset_id"]:checked'); + const mediaURL = selectedMedia?.dataset.mediaUrl || ''; + const image = preview.querySelector('[data-facebook-image]'); + const emptyImage = preview.querySelector('[data-facebook-image-empty]'); + if (image) { + image.hidden = !mediaURL; + if (mediaURL) image.src = mediaURL; + } + if (emptyImage) emptyImage.hidden = Boolean(mediaURL); + }; + + [title, teaser, category, status, facebookToggle, aiUsage, aiDisclosure].forEach(element => { + element?.addEventListener('input', updatePreview); + element?.addEventListener('change', updatePreview); + }); + form.querySelectorAll('input[name="media_asset_id"]').forEach(input => input.addEventListener('change', updatePreview)); + updatePreview(); + } + + const categoryModal = document.querySelector('[data-category-modal]'); + const openCategory = document.querySelector('[data-open-category-modal]'); + const closeCategoryButtons = document.querySelectorAll('[data-close-category-modal]'); + openCategory?.addEventListener('click', () => { + if (typeof categoryModal?.showModal === 'function') categoryModal.showModal(); + else categoryModal?.setAttribute('open', ''); + }); + closeCategoryButtons.forEach(button => button.addEventListener('click', () => categoryModal?.close())); + categoryModal?.addEventListener('click', event => { + if (event.target === categoryModal) categoryModal.close(); + }); + + const list = document.querySelector('[data-editorial-content-list]'); + if (list) { + const categoryFilter = document.querySelector('[data-editorial-filter-category]'); + const statusFilter = document.querySelector('[data-editorial-filter-status]'); + const searchFilter = document.querySelector('[data-editorial-filter-search]'); + const empty = document.querySelector('[data-editorial-filter-empty]'); + const rows = [...list.querySelectorAll('[data-editorial-row]')]; + const applyFilters = () => { + const categoryValue = categoryFilter?.value || ''; + const statusValue = statusFilter?.value || ''; + const searchValue = (searchFilter?.value || '').trim().toLocaleLowerCase('de'); + let visible = 0; + rows.forEach(row => { + const matchesCategory = !categoryValue || row.dataset.category === categoryValue; + const matchesStatus = !statusValue || row.dataset.status === statusValue; + const haystack = (row.dataset.search || '').toLocaleLowerCase('de'); + const matchesSearch = !searchValue || haystack.includes(searchValue); + row.hidden = !(matchesCategory && matchesStatus && matchesSearch); + if (!row.hidden) visible += 1; + }); + if (empty) empty.hidden = visible !== 0 || rows.length === 0; + }; + [categoryFilter, statusFilter, searchFilter].forEach(element => { + element?.addEventListener('input', applyFilters); + element?.addEventListener('change', applyFilters); + }); + } +})(); diff --git a/cmd/portal/web/assets/admin-editorial-v43.css b/cmd/portal/web/assets/admin-editorial-v43.css new file mode 100644 index 0000000..bab90c3 --- /dev/null +++ b/cmd/portal/web/assets/admin-editorial-v43.css @@ -0,0 +1,22 @@ +.editorial-admin-page{display:grid;gap:18px}.editorial-admin-page [hidden]{display:none!important}.editorial-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.editorial-tabs a{display:grid;grid-template-columns:42px minmax(0,1fr);column-gap:11px;align-items:center;padding:15px 17px;border:1px solid #dce5da;border-radius:15px;background:#fff;color:#263128;text-decoration:none;box-shadow:0 5px 18px rgba(28,42,26,.05)}.editorial-tabs a>span{grid-row:1/3;display:grid;place-items:center;width:42px;height:42px;border-radius:13px;background:#eff4ec;color:#5d8f20;font-size:21px;font-weight:900}.editorial-tabs strong{font-size:15px}.editorial-tabs small{color:#758078;font-size:11px}.editorial-tabs a.is-active{border-color:#8fbd55;background:linear-gradient(135deg,#fbfef8,#eef7e6);box-shadow:0 10px 24px rgba(93,143,32,.12)}.editorial-tabs a.is-active>span{background:#6faa24;color:#fff}.editorial-panel-heading{display:flex;justify-content:space-between;gap:20px;align-items:flex-start;margin-bottom:20px}.editorial-panel-heading h2{margin:4px 0 5px;font-size:25px}.editorial-panel-heading p{max-width:760px;margin:0;color:#68736b}.editorial-contents-panel,.editorial-category-panel{padding:22px}.editorial-list-toolbar{display:grid;grid-template-columns:220px 200px minmax(240px,1fr);gap:12px;padding:14px;border:1px solid #e0e7de;border-radius:14px;background:#f7faf5}.editorial-list-toolbar label{display:grid;gap:5px}.editorial-list-toolbar label>span{color:#647066;font-size:11px;font-weight:850;text-transform:uppercase;letter-spacing:.05em}.editorial-list-toolbar select,.editorial-list-toolbar input{width:100%;box-sizing:border-box;padding:10px 11px;border:1px solid #cad6cb;border-radius:9px;background:#fff;color:#263027}.editorial-content-table{margin-top:16px;border:1px solid #e1e7df;border-radius:14px;overflow:hidden}.editorial-content-head,.editorial-content-table>article{display:grid;grid-template-columns:minmax(300px,1.65fr) minmax(160px,.72fr) minmax(210px,.9fr) minmax(150px,.6fr);gap:16px;align-items:center}.editorial-content-head{padding:11px 15px;background:#eef3eb;color:#657066;font-size:10px;font-weight:900;text-transform:uppercase;letter-spacing:.07em}.editorial-content-table>article{padding:14px 15px;border-top:1px solid #e8ede7;background:#fff}.editorial-content-table>article:hover{background:#fbfdf9}.editorial-content-main{display:grid;grid-template-columns:72px minmax(0,1fr);gap:13px;align-items:center;min-width:0}.admin-editorial-thumb,.admin-editorial-placeholder{width:72px;height:64px;border-radius:10px}.admin-editorial-thumb{object-fit:cover}.admin-editorial-placeholder{display:grid;place-items:center;background:linear-gradient(145deg,#223023,#101810);color:#9bda4e;font-weight:950}.editorial-content-main strong{display:block;color:#1e271f;font-size:15px;line-height:1.25}.editorial-content-main p{display:-webkit-box;overflow:hidden;-webkit-line-clamp:2;-webkit-box-orient:vertical;margin:4px 0;color:#68736b;font-size:11px;line-height:1.4}.editorial-content-main small{color:#879088;font-size:10px}.editorial-content-classification{display:flex;align-items:flex-start;flex-direction:column;gap:7px}.editorial-category-chip,.editorial-status-chip{display:inline-flex;padding:6px 9px;border-radius:999px;font-size:10px;font-weight:900}.editorial-category-chip{background:#edf4e8;color:#537b22}.editorial-status-chip{background:#eff1ef;color:#657066}.editorial-status-chip.is-published{background:#e4f5d6;color:#4f7f17}.editorial-status-chip.is-review{background:#fff1cd;color:#866311}.editorial-status-chip.is-archived{background:#e8e9e8;color:#676b68}.editorial-content-classification small{color:#7b857c;font-size:10px}.editorial-distribution-status{display:grid;gap:8px}.facebook-state{display:flex;gap:8px;align-items:flex-start;min-width:0}.facebook-state>b{display:grid;place-items:center;flex:0 0 25px;width:25px;height:25px;border-radius:50%;background:#e9edf4;color:#4267a9;font-family:Arial,sans-serif;font-size:16px}.facebook-state>span{display:grid;min-width:0}.facebook-state strong{font-size:10px;color:#536058}.facebook-state small{overflow:hidden;text-overflow:ellipsis;color:#8b4d4d;font-size:9px;line-height:1.35}.facebook-state.is-published>b{background:#4267b2;color:#fff}.facebook-state.is-published strong{color:#37653a}.facebook-state.is-failed>b{background:#f9dddd;color:#a13d3d}.facebook-state.is-failed strong{color:#9a3535}.facebook-state.is-off{opacity:.65}.push-state{font-size:10px;font-weight:800;color:#547c23}.push-state.is-muted{color:#929a93}.editorial-row-actions{display:flex;flex-direction:column;align-items:stretch;gap:6px}.editorial-row-actions a,.editorial-row-actions button{display:block;width:100%;box-sizing:border-box;padding:7px 9px;border:1px solid #d9e1d8;border-radius:8px;background:#fff;color:#566159;text-align:center;text-decoration:none;font:inherit;font-size:10px;font-weight:850;cursor:pointer}.editorial-row-actions a.is-primary{border-color:#7eaf42;background:#eef7e6;color:#4e761d}.editorial-row-actions button.is-danger{color:#a14646}.editorial-filter-empty{display:grid;place-items:center;gap:4px;padding:35px;color:#68736b}.editorial-filter-empty strong{color:#2b362d}.editorial-create-layout{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(310px,.7fr);gap:18px;align-items:start}.editorial-editor-card{padding:22px}.editorial-editor-card .admin-card-heading p{margin:4px 0 0;color:#6d776f}.editorial-editor-card .admin-form-actions{display:flex;justify-content:flex-end;align-items:center;gap:14px}.editorial-editor-card .admin-form-actions>a{color:#667168}.facebook-preview-card{position:sticky;top:88px;padding:0;overflow:hidden}.facebook-preview-heading{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:17px 18px;border-bottom:1px solid #e5e9e4;background:#f8faf7}.facebook-preview-heading>div{display:flex;gap:10px;align-items:center}.facebook-preview-heading>div>div{display:grid}.facebook-preview-heading small{color:#788078;font-size:10px}.facebook-mark{display:grid;place-items:center;width:34px;height:34px;border-radius:50%;background:#4267b2;color:#fff;font-family:Arial,sans-serif;font-size:22px;font-weight:900}.facebook-connection{padding:6px 8px;border-radius:999px;font-size:9px;font-weight:900;text-transform:uppercase}.facebook-connection.is-ready{background:#e3f3d7;color:#4f7b1c}.facebook-connection.is-missing{background:#fde5d7;color:#a05b2d}.facebook-setup-warning{display:grid;gap:4px;margin:14px 14px 0;padding:12px;border:1px solid #f1cfae;border-radius:11px;background:#fff8ec;color:#79522e}.facebook-setup-warning strong{font-size:11px}.facebook-setup-warning span,.facebook-setup-warning a{font-size:10px}.facebook-setup-warning a{color:#80531f;font-weight:850}.facebook-post-preview{margin:14px;border:1px solid #dfe3e8;border-radius:12px;background:#fff;overflow:hidden;box-shadow:0 5px 17px rgba(26,39,60,.08)}.facebook-post-preview>header{display:grid;grid-template-columns:38px minmax(0,1fr) auto;gap:9px;align-items:center;padding:12px}.facebook-post-preview>header>div{display:grid}.facebook-post-preview>header small{color:#7a8189;font-size:9px}.facebook-page-avatar{display:grid;place-items:center;width:38px;height:38px;border-radius:50%;background:#162017;color:#9edb50;font-weight:950}.facebook-post-preview>p{margin:0;padding:2px 12px 13px;color:#222;font-size:12px;line-height:1.45;white-space:pre-line}.facebook-link-card{border-top:1px solid #e2e5e8;background:#f1f3f5}.facebook-preview-image{display:grid;place-items:center;height:150px;overflow:hidden;background:linear-gradient(145deg,#1a251b,#4b6631);color:#bce67c;font-size:17px;font-weight:900}.facebook-preview-image img{width:100%;height:100%;object-fit:cover}.facebook-link-card>div:last-child{padding:10px 12px}.facebook-link-card small{color:#727b84;font-size:9px}.facebook-link-card strong{display:block;margin:2px 0;color:#20252b;font-size:13px}.facebook-link-card p{display:-webkit-box;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:2;margin:0;color:#69717a;font-size:10px;line-height:1.35}.facebook-link-card span{display:block;overflow:hidden;margin-top:5px;color:#777f87;font-size:8px;text-overflow:ellipsis;white-space:nowrap}.facebook-preview-note{margin:0 14px 14px;padding:10px 11px;border-radius:9px;background:#edf5e8;color:#4f6f31;font-size:10px;line-height:1.45}.facebook-preview-note.is-warning{background:#fff2dc;color:#80591f}.facebook-current-status{display:grid;gap:3px;margin:0 14px 14px;padding:11px;border-radius:10px;background:#f1f4f0}.facebook-current-status strong{font-size:10px}.facebook-current-status small{overflow-wrap:anywhere;color:#7b4b4b;font-size:9px}.facebook-current-status.is-published{background:#e8f5df;color:#47751d}.facebook-current-status.is-failed{background:#fde8e8;color:#973b3b}.editorial-category-list{display:grid;gap:10px}.editorial-category-list article{display:grid;grid-template-columns:44px minmax(250px,1fr) auto auto;gap:14px;align-items:center;padding:14px;border:1px solid #e1e7df;border-radius:13px;background:#fff}.editorial-category-list article.is-inactive{opacity:.65;background:#f4f5f3}.editorial-category-icon{display:grid;place-items:center;width:44px;height:44px;border-radius:13px;background:#edf5e7;color:#5d8c24;font-size:18px;font-weight:950;text-transform:uppercase}.editorial-category-list strong,.editorial-category-list code{display:inline-block;margin-right:8px}.editorial-category-list code{padding:3px 6px;border-radius:6px;background:#edf1ec;color:#617063}.editorial-category-list p{margin:4px 0 0;color:#6b756d;font-size:11px}.editorial-type-badges{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.editorial-type-badges span,.editorial-type-badges small{padding:5px 8px;border-radius:999px;background:#e9f4db;color:#527b18;font-size:9px;font-weight:850}.editorial-type-badges small{background:#eef1ed;color:#626d64}.editorial-category-dialog{width:min(680px,calc(100% - 28px));padding:0;border:0;border-radius:18px;background:#fff;box-shadow:0 28px 90px rgba(15,24,16,.35)}.editorial-category-dialog::backdrop{background:rgba(10,15,11,.62);backdrop-filter:blur(3px)}.editorial-category-form>header{display:flex;justify-content:space-between;gap:18px;padding:22px 24px;border-bottom:1px solid #e4e9e3;background:#f7faf5}.editorial-category-form>header h2{margin:4px 0}.editorial-category-form>header p{max-width:520px;margin:0;color:#6a756c}.editorial-category-form>header>button{width:38px;height:38px;border:0;border-radius:10px;background:#e9eee7;color:#465148;font-size:24px;cursor:pointer}.editorial-category-form>.admin-form-grid{padding:22px 24px}.editorial-category-form textarea{resize:vertical}.editorial-switch{display:flex!important;grid-template-columns:auto 1fr;gap:10px;align-items:flex-start;padding:12px;border:1px solid #e0e6df;border-radius:10px}.editorial-switch input{width:auto!important;margin-top:3px}.editorial-switch>span{display:grid;gap:3px}.editorial-switch small{color:#768078;font-weight:500}.editorial-category-form>footer{display:flex;justify-content:flex-end;gap:10px;padding:16px 24px;border-top:1px solid #e4e9e3;background:#fafcf9} +@media(max-width:1180px){.editorial-content-head,.editorial-content-table>article{grid-template-columns:minmax(270px,1.5fr) minmax(145px,.7fr) minmax(180px,.85fr) 130px}.editorial-create-layout{grid-template-columns:1fr}.facebook-preview-card{position:static;max-width:620px}.editorial-category-list article{grid-template-columns:44px minmax(220px,1fr) auto}.editorial-category-list article>form{grid-column:2/-1;justify-self:end}} +@media(max-width:900px){.editorial-tabs{grid-template-columns:1fr}.editorial-list-toolbar{grid-template-columns:1fr 1fr}.editorial-search{grid-column:1/-1}.editorial-content-head{display:none}.editorial-content-table{display:grid;gap:12px;border:0;overflow:visible}.editorial-content-table>article{grid-template-columns:1fr 1fr;padding:15px;border:1px solid #e1e7df;border-radius:13px}.editorial-content-main{grid-column:1/-1}.editorial-row-actions{grid-column:1/-1;display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.editorial-category-list article{grid-template-columns:44px minmax(0,1fr)}.editorial-category-list .editorial-type-badges,.editorial-category-list article>form{grid-column:2}} +@media(max-width:620px){.editorial-panel-heading{align-items:stretch;flex-direction:column}.editorial-panel-heading .admin-primary-button{width:100%;box-sizing:border-box;text-align:center}.editorial-list-toolbar{grid-template-columns:1fr}.editorial-search{grid-column:auto}.editorial-content-table>article{grid-template-columns:1fr}.editorial-content-classification,.editorial-distribution-status,.editorial-row-actions{grid-column:auto}.editorial-row-actions{grid-template-columns:1fr 1fr}.editorial-content-main{grid-template-columns:58px minmax(0,1fr)}.admin-editorial-thumb,.admin-editorial-placeholder{width:58px;height:58px}.editorial-category-list article{grid-template-columns:1fr}.editorial-category-list .editorial-category-icon,.editorial-category-list .editorial-type-badges,.editorial-category-list article>form{grid-column:auto}.editorial-category-list article>form,.editorial-category-list article>form button{width:100%}.editorial-category-form>.admin-form-grid{grid-template-columns:1fr}.editorial-category-form .is-wide{grid-column:auto}.facebook-preview-card{min-width:0}.editorial-category-dialog{width:calc(100% - 18px)}} +/* v1.5.24 – KI-Transparenz */ +.editorial-ai-chip{display:inline-flex;align-items:center;gap:5px;width:max-content;padding:5px 8px;border-radius:999px;background:#ede7ff;color:#5f3a8f;font-size:9px;font-weight:900;text-transform:uppercase}.editorial-ai-chip.is-media{background:#e2eef8;color:#315f83}.editorial-ai-panel{display:grid;gap:14px;padding:18px;border:1px solid #cbd8c5;border-radius:15px;background:linear-gradient(145deg,#f8fbf5,#f0f5ec)}.editorial-ai-panel legend{padding:0 8px;color:#29482b;font-weight:900}.editorial-ai-panel>p{margin:0;color:#667365;line-height:1.55}.editorial-ai-panel>a{width:max-content;color:#527d20;font-weight:800;text-decoration:none}.editorial-ai-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.editorial-ai-grid label{display:grid;gap:7px}.editorial-ai-grid .is-wide{grid-column:1/-1}.editorial-ai-grid label>span{font-weight:780}.editorial-ai-grid small{color:#758174;font-weight:500;line-height:1.45}.editorial-ai-grid input,.editorial-ai-grid select,.editorial-ai-grid textarea{width:100%;box-sizing:border-box;padding:12px;border:1px solid #cbd7c7;border-radius:10px;background:#fff;font:inherit}.editorial-ai-review{display:flex!important;grid-template-columns:auto 1fr!important;align-items:flex-start;padding:13px;border:1px solid #d5e0d0;border-radius:11px;background:#fff}.editorial-ai-review input{width:auto!important;margin-top:3px}.editorial-ai-review>span{display:grid;gap:3px}.editorial-ai-review strong{font-size:.92rem}@media(max-width:700px){.editorial-ai-grid{grid-template-columns:1fr}.editorial-ai-grid .is-wide{grid-column:auto}} + +/* Editorial editor: content left, publication and AI disclosure right. */ +.editorial-create-layout{grid-template-columns:minmax(0,1fr)} +.editorial-form-columns{display:grid;grid-template-columns:minmax(0,1.65fr) minmax(290px,1fr);gap:22px;align-items:start} +.editorial-form-sidebar{display:grid;gap:16px;min-width:0} +.editorial-form-sidebar .editorial-ai-grid{grid-template-columns:minmax(0,1fr)} +.editorial-form-sidebar .editorial-ai-panel{min-width:0} +.editorial-form-sidebar .editorial-ai-panel>a{width:auto;overflow-wrap:anywhere} +.editorial-form-sidebar .admin-distribution{display:grid;gap:12px} +.editorial-form-sidebar .admin-distribution>label:not(.admin-check){display:grid;gap:6px} +.editorial-form-sidebar input[type=date]{width:100%;box-sizing:border-box;padding:12px;border:1px solid #cbd7c7;border-radius:10px;font:inherit} +.editorial-form-sidebar .admin-form-actions{flex-wrap:wrap} +.editorial-status-chip.is-scheduled{background:#e8eefb;color:#345a92} +@media(max-width:1000px){.editorial-form-columns{grid-template-columns:minmax(0,1fr)}} + +.editorial-form-sidebar .facebook-preview-card{position:static;max-width:none;min-width:0} diff --git a/docs/EDITORIAL_MEDIA.md b/docs/EDITORIAL_MEDIA.md index 84c8ca8..0ae027a 100644 --- a/docs/EDITORIAL_MEDIA.md +++ b/docs/EDITORIAL_MEDIA.md @@ -16,7 +16,7 @@ Beiträge besitzen Slug, Titel, Teaser, Inhalt, Veröffentlichungsstatus und opt ## Verteilung -Bei veröffentlichten Inhalten mit aktivierter Facebook-Ausgabe sendet der Server den Beitrag unmittelbar über den Facebook-Publisher. Die Zieladresse ist bei öffentlichen Regionalbeiträgen `/landwelle-vor-ort//`. Vor dem Speichern zeigt der Adminbereich eine Live-Vorschau aus Titel, Teaser, Bild und Zieladresse. Erfolgreiche Übertragungen, ausstehende Zustände und Fehler werden am Inhalt angezeigt; ein manueller Wiederholungsversand ist möglich. Zugangsdaten und Plattformtokens bleiben ausschließlich serverseitig. Push-Ausgaben bleiben als eigener Verteilungsweg gespeichert. +Bei veröffentlichten Inhalten mit aktivierter Facebook-Ausgabe sendet der Server den Beitrag zum Veröffentlichungsdatum über den Facebook-Publisher. Die Zieladresse ist bei öffentlichen Regionalbeiträgen `/landwelle-vor-ort//`. Vor dem Speichern zeigt der Adminbereich eine Live-Vorschau aus Titel, Teaser, Bild und Zieladresse. Erfolgreiche Übertragungen, ausstehende Zustände und Fehler werden am Inhalt angezeigt; ein manueller Wiederholungsversand ist möglich. Zugangsdaten und Plattformtokens bleiben ausschließlich serverseitig. Push-Ausgaben bleiben als eigener Verteilungsweg gespeichert. ## Mediathek @@ -37,3 +37,8 @@ Redaktionseinträge speichern `ai_usage`, `ai_human_reviewed`, `ai_editorial_res Jedes Bild in `/admin/media` kann nach dem Upload erneut bearbeitet werden. Neben Alternativtext und Rechteangaben werden KI-Klassifizierung, Transparenzhinweis, Wasserzeichenstatus und ein optionaler kurzer Wasserzeichentext gespeichert. Ohne individuellen Text verwendet das Portal „Mit KI erstellt“ beziehungsweise „Mit KI bearbeitet“. Ein Wasserzeichen kann nur bei einer KI-Klassifizierung wirksam sein. Die Originaldatei bleibt unverändert. Aktive Wasserzeichen werden derzeit in redaktionellen Beiträgen, Startseitenkarten, Teamprofilen, Programmkarten und Mediathek-Covern übernommen, sofern die Bildadresse auf ein Objekt der zentralen Mediengalerie verweist. + + +### Veröffentlichungsplanung + +Der Editor zeigt Datum, KI-Transparenz und Speichern in der rechten Spalte. Das Datum ist beim Anlegen auf den heutigen Tag voreingestellt. Nur mit Status „Veröffentlicht“ werden Inhalte sichtbar: heute sofort, bei einem zukünftigen Datum ab 00:00 Uhr deutscher Zeit. In der Inhaltsliste erscheint bis dahin „Geplant“. Entwürfe, Prüfung und Archivierung veröffentlichen nichts. Facebook (optional) wird für geplante Beiträge automatisch im 30-Sekunden-Takt geprüft; bei Fehlern kann der Versand manuell wiederholt werden. Bereits extern veröffentlichte Facebook-Beiträge werden durch eine spätere Terminänderung nicht zurückgerufen. diff --git a/scripts/test-postgres-integration.sh b/scripts/test-postgres-integration.sh index 206af8d..655d785 100755 --- a/scripts/test-postgres-integration.sh +++ b/scripts/test-postgres-integration.sh @@ -32,6 +32,7 @@ touch "$TMP/test.env" # Apply all historical and current migrations without moving repository files. go run ./cmd/migrate --env-file "$TMP/test.env" --dir migrations --keep-files --lock-file "$TMP/migration.lock" go test -count=1 -p 1 ./internal/database ./internal/jobqueue +go test -count=1 ./cmd/portal -run TestEditorialSchedulePostgres # Optional authenticated HTTP smoke test against the same disposable database. if [[ "${LANDWELLE_HTTP_SMOKE:-0}" == 1 ]]; then "$PGBIN/psql" -X -v ON_ERROR_STOP=1 -c 'UPDATE landwelle.feed_sources SET enabled=false' >/dev/null