2026-10-16 14:53:37 +02:00
|
|
|
enum SourceLanguage {
|
|
|
|
|
de('Deutsch', '🇩🇪'),
|
|
|
|
|
en('English', '🇬🇧');
|
|
|
|
|
|
|
|
|
|
const SourceLanguage(this.label, this.flag);
|
|
|
|
|
|
|
|
|
|
final String label;
|
|
|
|
|
final String flag;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-16 15:44:52 +02:00
|
|
|
/// What a Source's articles are for; see GLOSSARY.md. Each kind has its own
|
|
|
|
|
/// section in the app and its own time window.
|
|
|
|
|
enum SourceKind {
|
|
|
|
|
news('News'),
|
|
|
|
|
learning('Learning'),
|
|
|
|
|
fun('Fun');
|
|
|
|
|
|
|
|
|
|
const SourceKind(this.label);
|
|
|
|
|
|
|
|
|
|
final String label;
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-16 16:03:25 +02:00
|
|
|
/// A Source of any [kind]; see GLOSSARY.md.
|
|
|
|
|
class Source {
|
|
|
|
|
const Source({
|
2026-10-16 14:53:37 +02:00
|
|
|
required this.id,
|
|
|
|
|
required this.name,
|
|
|
|
|
required this.feedUrl,
|
|
|
|
|
required this.homepage,
|
|
|
|
|
required this.language,
|
2026-10-16 15:44:52 +02:00
|
|
|
this.kind = SourceKind.news,
|
2026-10-16 14:53:37 +02:00
|
|
|
this.description = '',
|
|
|
|
|
this.enabledByDefault = false,
|
|
|
|
|
this.isCustom = false,
|
|
|
|
|
this.checkPaywallOnPage = false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final String id;
|
|
|
|
|
final String name;
|
|
|
|
|
final String feedUrl;
|
|
|
|
|
final String homepage;
|
|
|
|
|
final SourceLanguage language;
|
2026-10-16 15:44:52 +02:00
|
|
|
final SourceKind kind;
|
2026-10-16 14:53:37 +02:00
|
|
|
final String description;
|
|
|
|
|
final bool enabledByDefault;
|
|
|
|
|
final bool isCustom;
|
|
|
|
|
|
|
|
|
|
/// Paid articles are only marked inside the page (schema.org), not in the
|
|
|
|
|
/// feed, so each new article page is checked once.
|
|
|
|
|
final bool checkPaywallOnPage;
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
|
'id': id,
|
|
|
|
|
'name': name,
|
|
|
|
|
'feedUrl': feedUrl,
|
|
|
|
|
'homepage': homepage,
|
|
|
|
|
'language': language.name,
|
2026-10-16 15:44:52 +02:00
|
|
|
'kind': kind.name,
|
2026-10-16 14:53:37 +02:00
|
|
|
'description': description,
|
|
|
|
|
};
|
|
|
|
|
|
2026-10-16 16:03:25 +02:00
|
|
|
factory Source.custom(Map<String, dynamic> json) => Source(
|
2026-10-16 14:53:37 +02:00
|
|
|
id: json['id'] as String,
|
|
|
|
|
name: json['name'] as String,
|
|
|
|
|
feedUrl: json['feedUrl'] as String,
|
|
|
|
|
homepage: json['homepage'] as String? ?? '',
|
|
|
|
|
language: SourceLanguage.values.byName(json['language'] as String? ?? 'en'),
|
2026-10-16 15:44:52 +02:00
|
|
|
// Custom sources saved before kinds existed are News sources.
|
|
|
|
|
kind: SourceKind.values.asNameMap()[json['kind']] ?? SourceKind.news,
|
2026-10-16 14:53:37 +02:00
|
|
|
description: json['description'] as String? ?? '',
|
|
|
|
|
isCustom: true,
|
|
|
|
|
);
|
|
|
|
|
}
|