Compare commits
No commits in common. "1996707ee4753c49048366fdfb844b7387c9ffaa" and "91cbf2d3906a88a0a7377b3e379daf5b1241e6aa" have entirely different histories.
1996707ee4
...
91cbf2d390
3 changed files with 40 additions and 47 deletions
|
@ -1,7 +1,3 @@
|
||||||
## 1.1.0-alpha.1
|
|
||||||
- Experimentální podpora pro SPŠEI Ostrava
|
|
||||||
- Hezčí kód
|
|
||||||
- Alergeny
|
|
||||||
## 1.0.1
|
## 1.0.1
|
||||||
- změnit získávání názvu jídla
|
- změnit získávání názvu jídla
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
import 'tridy.dart';
|
import 'tridy.dart';
|
||||||
|
@ -116,9 +118,13 @@ class Canteen {
|
||||||
}
|
}
|
||||||
|
|
||||||
var res =
|
var res =
|
||||||
await http.post(Uri.parse("$url/j_spring_security_check"), headers: {
|
await http.post(Uri.parse(url + "/j_spring_security_check"), headers: {
|
||||||
"Cookie":
|
"Cookie": "JSESSIONID=" +
|
||||||
"JSESSIONID=${cookies["JSESSIONID"]!}; XSRF-TOKEN=${cookies["XSRF-TOKEN"]!};",
|
cookies["JSESSIONID"]! +
|
||||||
|
"; " +
|
||||||
|
"XSRF-TOKEN=" +
|
||||||
|
cookies["XSRF-TOKEN"]! +
|
||||||
|
";",
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
}, body: {
|
}, body: {
|
||||||
"j_username": user,
|
"j_username": user,
|
||||||
|
@ -146,8 +152,14 @@ class Canteen {
|
||||||
/// Builder pro GET request
|
/// Builder pro GET request
|
||||||
Future<String> _getRequest(String path) async {
|
Future<String> _getRequest(String path) async {
|
||||||
var r = await http.get(Uri.parse(url + path), headers: {
|
var r = await http.get(Uri.parse(url + path), headers: {
|
||||||
"Cookie":
|
"Cookie": "JSESSIONID=" +
|
||||||
"JSESSIONID=${cookies["JSESSIONID"]!}; XSRF-TOKEN=${cookies["XSRF-TOKEN"]!}${cookies.containsKey("remember-me") ? "; ${cookies["remember-me"]!};" : ";"}",
|
cookies["JSESSIONID"]! +
|
||||||
|
"; " +
|
||||||
|
"XSRF-TOKEN=" +
|
||||||
|
cookies["XSRF-TOKEN"]! +
|
||||||
|
(cookies.containsKey("remember-me")
|
||||||
|
? "; " + cookies["remember-me"]! + ";"
|
||||||
|
: ";"),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (r.statusCode != 200 ||
|
if (r.statusCode != 200 ||
|
||||||
|
@ -259,7 +271,7 @@ class Canteen {
|
||||||
String res;
|
String res;
|
||||||
try {
|
try {
|
||||||
res = await _getRequest(
|
res = await _getRequest(
|
||||||
"/faces/secured/main.jsp?day=${den.year}-${(den.month < 10) ? "0${den.month}" : den.month}-${(den.day < 10) ? "0${den.day}" : den.day}&terminal=false&printer=false&keyboard=false");
|
"/faces/secured/main.jsp?day=${den.year}-${(den.month < 10) ? "0" + den.month.toString() : den.month}-${(den.day < 10) ? "0" + den.day.toString() : den.day}&terminal=false&printer=false&keyboard=false");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Future.error(e);
|
return Future.error(e);
|
||||||
}
|
}
|
||||||
|
@ -269,9 +281,8 @@ class Canteen {
|
||||||
.group(0)
|
.group(0)
|
||||||
.toString());
|
.toString());
|
||||||
var jidla = <Jidlo>[];
|
var jidla = <Jidlo>[];
|
||||||
var jidelnicek = RegExp(
|
var jidelnicek =
|
||||||
r'(?<=<div class="jidWrapLeft">).+?((fa-clock)|(fa-ban))',
|
RegExp(r'(?<=<div class="jidWrapLeft">).+?((fa-clock))', dotAll: true)
|
||||||
dotAll: true)
|
|
||||||
.allMatches(res)
|
.allMatches(res)
|
||||||
.toList();
|
.toList();
|
||||||
for (var obed in jidelnicek) {
|
for (var obed in jidelnicek) {
|
||||||
|
@ -286,7 +297,7 @@ class Canteen {
|
||||||
o.contains("nelze změnit"));
|
o.contains("nelze změnit"));
|
||||||
|
|
||||||
var cenaMatch =
|
var cenaMatch =
|
||||||
RegExp(r'((?<=Cena objednaného jídla">).+?(?=&))').firstMatch(o);
|
RegExp(r'(?<=Cena objednaného jídla">).+?(?=&)').firstMatch(o);
|
||||||
cenaMatch ??=
|
cenaMatch ??=
|
||||||
RegExp(r'(?<=Cena při objednání jídla: ).+?(?=&)').firstMatch(o);
|
RegExp(r'(?<=Cena při objednání jídla: ).+?(?=&)').firstMatch(o);
|
||||||
cenaMatch ??=
|
cenaMatch ??=
|
||||||
|
@ -300,12 +311,7 @@ class Canteen {
|
||||||
.group(1)
|
.group(1)
|
||||||
.toString()
|
.toString()
|
||||||
.replaceAll(' ,', ",")
|
.replaceAll(' ,', ",")
|
||||||
.replaceAll(" <br>", "")
|
.replaceAll(" <br>", "");
|
||||||
.replaceAll("\n", "");
|
|
||||||
var alergeny =
|
|
||||||
RegExp(r"""<span title=".+?" class="textGrey">([a-zA-Z]*)<\/span>""")
|
|
||||||
.allMatches(jidlaProDen)
|
|
||||||
.toList();
|
|
||||||
var vydejna = RegExp(
|
var vydejna = RegExp(
|
||||||
r'(?<=<span class="smallBoldTitle button-link-align">).+?(?=<)')
|
r'(?<=<span class="smallBoldTitle button-link-align">).+?(?=<)')
|
||||||
.firstMatch(o)!
|
.firstMatch(o)!
|
||||||
|
@ -323,15 +329,14 @@ class Canteen {
|
||||||
} else {
|
} else {
|
||||||
// jinak nastavíme URL pro burzu
|
// jinak nastavíme URL pro burzu
|
||||||
var match = RegExp(
|
var match = RegExp(
|
||||||
r"""db\/dbProcessOrder\.jsp.+?type=((plusburza)|(minusburza)).+?(?=')""")
|
r"(?<=ajaxOrder\(this, ')(.+?)(?=').+?((do burzy)|(z burzy))")
|
||||||
.firstMatch(o);
|
.firstMatch(o);
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
burzaUrl = match.group(1)!.replaceAll("amp;", "");
|
burzaUrl = match.group(1)!.replaceAll("amp;", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jidla.add(
|
jidla.add(Jidlo(
|
||||||
Jidlo(
|
|
||||||
nazev: jidlaProDen.replaceAll(
|
nazev: jidlaProDen.replaceAll(
|
||||||
r' (?=[^a-zA-ZěščřžýáíéĚŠČŘŽÝÁÍÉŤŇťň])', ''),
|
r' (?=[^a-zA-ZěščřžýáíéĚŠČŘŽÝÁÍÉŤŇťň])', ''),
|
||||||
objednano: objednano,
|
objednano: objednano,
|
||||||
|
@ -342,9 +347,7 @@ class Canteen {
|
||||||
den: obedDen,
|
den: obedDen,
|
||||||
burzaUrl: burzaUrl,
|
burzaUrl: burzaUrl,
|
||||||
naBurze:
|
naBurze:
|
||||||
(burzaUrl == null) ? false : !burzaUrl.contains("plusburza"),
|
(burzaUrl == null) ? false : !burzaUrl.contains("plusburza")));
|
||||||
alergeny: [...alergeny.map((e) => e.group(1).toString())]),
|
|
||||||
);
|
|
||||||
// KONEC formátování do třídy
|
// KONEC formátování do třídy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +372,7 @@ class Canteen {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await _getRequest("/faces/secured/${j.orderUrl!}"); // provést operaci
|
await _getRequest("/faces/secured/" + j.orderUrl!); // provést operaci
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Future.error(e);
|
return Future.error(e);
|
||||||
}
|
}
|
||||||
|
@ -402,7 +405,7 @@ class Canteen {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await _getRequest("/faces/secured/${j.burzaUrl!}"); // provést operaci
|
await _getRequest("/faces/secured/" + j.burzaUrl!); // provést operaci
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Future.error(e);
|
return Future.error(e);
|
||||||
}
|
}
|
||||||
|
@ -484,7 +487,7 @@ class Canteen {
|
||||||
Future<bool> objednatZBurzy(Burza b) async {
|
Future<bool> objednatZBurzy(Burza b) async {
|
||||||
if (!prihlasen) return Future.error("Uživatel není přihlášen");
|
if (!prihlasen) return Future.error("Uživatel není přihlášen");
|
||||||
try {
|
try {
|
||||||
await _getRequest("/faces/secured/${b.url!}");
|
await _getRequest("/faces/secured/" + b.url!);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Future.error(e.toString());
|
return Future.error(e.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,6 @@ class Jidlo {
|
||||||
/// Den, který je jídlo vydáváno
|
/// Den, který je jídlo vydáváno
|
||||||
DateTime den;
|
DateTime den;
|
||||||
|
|
||||||
/// Seznam alergenů
|
|
||||||
///
|
|
||||||
/// Pokud se žádný nepodařilo najít, vrací prázdný seznam
|
|
||||||
List<String> alergeny;
|
|
||||||
|
|
||||||
/// URL pro požadavek na objednání jídla
|
/// URL pro požadavek na objednání jídla
|
||||||
final String? orderUrl;
|
final String? orderUrl;
|
||||||
|
|
||||||
|
@ -36,7 +31,6 @@ class Jidlo {
|
||||||
required this.objednano,
|
required this.objednano,
|
||||||
required this.varianta,
|
required this.varianta,
|
||||||
required this.den,
|
required this.den,
|
||||||
this.alergeny = const [],
|
|
||||||
this.cena,
|
this.cena,
|
||||||
required this.lzeObjednat,
|
required this.lzeObjednat,
|
||||||
this.orderUrl,
|
this.orderUrl,
|
||||||
|
|
Reference in a new issue