db backed source creation
This commit is contained in:
parent
b9e288a22d
commit
847aeae772
5 changed files with 312 additions and 99 deletions
|
|
@ -40,39 +40,6 @@ PANGEA_CONTENT_TYPES = (
|
|||
"topstories",
|
||||
)
|
||||
|
||||
DEFAULT_SOURCES: tuple[dict[str, str], ...] = (
|
||||
{
|
||||
"name": "Guardian feed mirror",
|
||||
"slug": "guardian-feed",
|
||||
"source_type": "Feed",
|
||||
"upstream": "https://guardianproject.info/feed.xml",
|
||||
"schedule": "Every 30 minutes",
|
||||
"last_run": "Succeeded 53m ago",
|
||||
"state": "Enabled",
|
||||
"state_tone": "scheduled",
|
||||
},
|
||||
{
|
||||
"name": "Pangea mobile articles",
|
||||
"slug": "pangea-mobile",
|
||||
"source_type": "Pangea",
|
||||
"upstream": "guardianproject.info / News",
|
||||
"schedule": "Every 4 hours",
|
||||
"last_run": "Running now",
|
||||
"state": "Enabled",
|
||||
"state_tone": "running",
|
||||
},
|
||||
{
|
||||
"name": "Podcast enclosure mirror",
|
||||
"slug": "podcast-audio",
|
||||
"source_type": "Feed",
|
||||
"upstream": "https://guardianproject.info/podcast/podcast.xml",
|
||||
"schedule": "Paused",
|
||||
"last_run": "Failed 2h ago",
|
||||
"state": "Disabled",
|
||||
"state_tone": "idle",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def _source_row(source: Mapping[str, object]) -> tuple[Node, ...]:
|
||||
return (
|
||||
|
|
@ -106,7 +73,7 @@ def _source_row(source: Mapping[str, object]) -> tuple[Node, ...]:
|
|||
def sources_table(
|
||||
*, sources: tuple[Mapping[str, object], ...] | None = None
|
||||
) -> Renderable:
|
||||
rows = tuple(_source_row(source) for source in (sources or DEFAULT_SOURCES))
|
||||
rows = tuple(_source_row(source) for source in (sources or ()))
|
||||
return table_section(
|
||||
eyebrow="Inventory",
|
||||
title="Sources",
|
||||
|
|
@ -175,13 +142,11 @@ def create_source_form(*, action_path: str = "/actions/sources/create") -> Rende
|
|||
input_field(
|
||||
label="Source name",
|
||||
field_id="source-name",
|
||||
value="Pangea mobile articles",
|
||||
signal_name="sourceName",
|
||||
),
|
||||
input_field(
|
||||
label="Slug",
|
||||
field_id="source-slug",
|
||||
value="pangea-mobile",
|
||||
help_text="Immutable after creation.",
|
||||
signal_name="sourceSlug",
|
||||
),
|
||||
|
|
@ -244,13 +209,11 @@ def create_source_form(*, action_path: str = "/actions/sources/create") -> Rende
|
|||
input_field(
|
||||
label="Pangea domain",
|
||||
field_id="pangea-domain",
|
||||
value="guardianproject.info",
|
||||
signal_name="pangeaDomain",
|
||||
),
|
||||
input_field(
|
||||
label="Category name",
|
||||
field_id="pangea-category",
|
||||
value="News",
|
||||
signal_name="pangeaCategory",
|
||||
),
|
||||
select_field(
|
||||
|
|
@ -299,19 +262,25 @@ def create_source_form(*, action_path: str = "/actions/sources/create") -> Rende
|
|||
signal_name="excludeMedia",
|
||||
checked=False,
|
||||
),
|
||||
toggle_field(
|
||||
label="Include content",
|
||||
description="Store article body content in mirrored output when the upstream provides it.",
|
||||
signal_name="includeContent",
|
||||
checked=True,
|
||||
),
|
||||
],
|
||||
],
|
||||
h.div(class_="grid gap-4 lg:grid-cols-2")[
|
||||
textarea_field(
|
||||
label="Notes",
|
||||
field_id="source-notes",
|
||||
value="Primary Pangea mobile article mirror for the operator landing page.",
|
||||
value="",
|
||||
signal_name="sourceNotes",
|
||||
),
|
||||
textarea_field(
|
||||
label="Spider arguments",
|
||||
field_id="spider-arguments",
|
||||
value="language=en,download_media=true",
|
||||
value="language=en\ndownload_media=true",
|
||||
signal_name="spiderArguments",
|
||||
),
|
||||
],
|
||||
|
|
@ -331,13 +300,13 @@ def create_source_form(*, action_path: str = "/actions/sources/create") -> Rende
|
|||
input_field(
|
||||
label="Minute",
|
||||
field_id="cron-minute",
|
||||
value="15",
|
||||
value="*/30",
|
||||
signal_name="cronMinute",
|
||||
),
|
||||
input_field(
|
||||
label="Hour",
|
||||
field_id="cron-hour",
|
||||
value="*/4",
|
||||
value="*",
|
||||
signal_name="cronHour",
|
||||
),
|
||||
input_field(
|
||||
|
|
@ -349,7 +318,7 @@ def create_source_form(*, action_path: str = "/actions/sources/create") -> Rende
|
|||
input_field(
|
||||
label="Day of week",
|
||||
field_id="cron-day-of-week",
|
||||
value="1-6",
|
||||
value="*",
|
||||
signal_name="cronDayOfWeek",
|
||||
),
|
||||
input_field(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue