You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
3.3 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
part 'parse.g.dart';
@JsonSerializable()
class MWParseCategoryInfo {
String sortkey;
String category;
MWParseCategoryInfo({
required this.category,
this.sortkey = "",
});
factory MWParseCategoryInfo.fromJson(Map<String, dynamic> json) =>
_$MWParseCategoryInfoFromJson(json);
Map<String, dynamic> toJson() => _$MWParseCategoryInfoToJson(this);
}
@JsonSerializable()
class MWParseLangLinkInfo {
String lang;
String url;
String langname;
String autonym;
String title;
MWParseLangLinkInfo({
required this.lang,
this.url = "",
this.langname = "",
this.autonym = "",
required this.title,
});
factory MWParseLangLinkInfo.fromJson(Map<String, dynamic> json) =>
_$MWParseLangLinkInfoFromJson(json);
Map<String, dynamic> toJson() => _$MWParseLangLinkInfoToJson(this);
}
@JsonSerializable()
class MWParsePageLinkInfo {
int ns;
String title;
bool exists;
MWParsePageLinkInfo({
required this.ns,
required this.title,
this.exists = false,
});
factory MWParsePageLinkInfo.fromJson(Map<String, dynamic> json) =>
_$MWParsePageLinkInfoFromJson(json);
Map<String, dynamic> toJson() => _$MWParsePageLinkInfoToJson(this);
}
@JsonSerializable()
class MWParseSectionInfo {
int toclevel;
int level;
String line;
String number;
String index;
String fromtitle;
int? byteoffset;
String anchor;
MWParseSectionInfo({
this.toclevel = -1,
this.level = -1,
this.line = "",
this.number = "",
this.index = "",
this.fromtitle = "",
this.byteoffset,
this.anchor = "",
});
factory MWParseSectionInfo.fromJson(Map<String, dynamic> json) =>
_$MWParseSectionInfoFromJson(json);
Map<String, dynamic> toJson() => _$MWParseSectionInfoToJson(this);
}
@JsonSerializable()
class MWParseInfo {
String title;
int pageid;
int revid;
String text;
List<MWParseLangLinkInfo> langlink;
List<MWParseCategoryInfo> categories;
List<MWParsePageLinkInfo> links;
List<MWParsePageLinkInfo> templates;
List<String> images;
List<String> externallinks;
List<MWParseSectionInfo> sections;
bool showtoc;
String displaytitle;
List<String> modules;
List<String> modulescripts;
List<String> modulestyles;
Map<String, dynamic> jsconfigvars;
Map<String, dynamic> iwlinks;
Map<String, dynamic> properties;
MWParseInfo({
required this.title,
required this.pageid,
this.revid = -1,
this.text = "",
this.langlink = const [],
this.categories = const [],
this.links = const [],
this.templates = const [],
this.images = const [],
this.externallinks = const [],
this.sections = const [],
this.showtoc = true,
this.displaytitle = "",
this.modules = const [],
this.modulescripts = const [],
this.modulestyles = const [],
this.jsconfigvars = const {},
this.iwlinks = const {},
this.properties = const {},
});
factory MWParseInfo.fromJson(Map<String, dynamic> json) =>
_$MWParseInfoFromJson(json);
Map<String, dynamic> toJson() => _$MWParseInfoToJson(this);
}
@JsonSerializable()
class MWParseResponse {
MWParseInfo parse;
MWParseResponse({required this.parse});
factory MWParseResponse.fromJson(Map<String, dynamic> json) =>
_$MWParseResponseFromJson(json);
Map<String, dynamic> toJson() => _$MWParseResponseToJson(this);
}