implemented the Ticker module with a native ProseMirror document renderer and integrated API support for structured content, navigation trees, and proxied files

This commit is contained in:
2026-07-09 00:51:08 +02:00
parent 1114291313
commit cedeb06569
57 changed files with 4758 additions and 43 deletions
@@ -0,0 +1,25 @@
import 'package:dio/dio.dart';
import '../../errors/marianumconnect_error.dart';
import '../../marianumconnect_api.dart';
import '../../marianumconnect_endpoint.dart';
import 'get_ticker_response.dart';
/// Fetches the current "Aktuelles" ticker post from
/// `GET /api/mobile/v1/ticker`. Bearer token is attached by the shared dio.
class GetTicker {
final Dio _dio;
GetTicker({Dio? dio}) : _dio = dio ?? MarianumConnectApi.dio();
Future<TickerResponse> run() async {
try {
final response = await _dio.get<Map<String, dynamic>>(
MarianumConnectEndpoint.resolve('ticker'),
);
return TickerResponse.fromJson(response.data!);
} on DioException catch (e) {
throw mapMarianumConnectError(e);
}
}
}
@@ -0,0 +1,44 @@
import 'package:json_annotation/json_annotation.dart';
part 'get_ticker_response.g.dart';
/// The "Aktuelles" ticker post from `GET /api/mobile/v1/ticker`.
///
/// [available] is false when the current post has no ProseMirror JSON yet (a
/// legacy post not re-saved since the dual-write rollout); the backend still
/// returns 200 with `content: null` so the home surface degrades to a
/// "open in browser" hint rather than an error. Unknown/missing flags default
/// to a safe empty state.
@JsonSerializable()
class TickerResponse {
@JsonKey(defaultValue: 1)
final int schemaVersion;
@JsonKey(defaultValue: false)
final bool available;
final String? hash;
final String? publishedAt;
/// Site-relative link to the web ticker (e.g. `/ticker`); the app prefixes
/// the active Marianum-Connect base URL.
@JsonKey(defaultValue: '/ticker')
final String webUrl;
/// Nested ProseMirror document (`{ type: doc, content: [...] }`) or null when
/// [available] is false. Parsed to a `PmNode` at render time.
final Map<String, dynamic>? content;
TickerResponse({
required this.schemaVersion,
required this.available,
this.hash,
this.publishedAt,
required this.webUrl,
this.content,
});
factory TickerResponse.fromJson(Map<String, dynamic> json) =>
_$TickerResponseFromJson(json);
Map<String, dynamic> toJson() => _$TickerResponseToJson(this);
}
@@ -0,0 +1,27 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'get_ticker_response.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
TickerResponse _$TickerResponseFromJson(Map<String, dynamic> json) =>
TickerResponse(
schemaVersion: (json['schemaVersion'] as num?)?.toInt() ?? 1,
available: json['available'] as bool? ?? false,
hash: json['hash'] as String?,
publishedAt: json['publishedAt'] as String?,
webUrl: json['webUrl'] as String? ?? '/ticker',
content: json['content'] as Map<String, dynamic>?,
);
Map<String, dynamic> _$TickerResponseToJson(TickerResponse instance) =>
<String, dynamic>{
'schemaVersion': instance.schemaVersion,
'available': instance.available,
'hash': instance.hash,
'publishedAt': instance.publishedAt,
'webUrl': instance.webUrl,
'content': instance.content,
};