94 lines
3.3 KiB
Ziran
94 lines
3.3 KiB
Ziran
#import, file "../src/app/mini_mode_policy.zi";
|
|
#import, file "../src/core/types.zi";
|
|
|
|
SameText :: (bytes: []u8, length: s64, expected: string) -> bool {
|
|
if length != expected.count {
|
|
return false
|
|
}
|
|
index: s64 = 0
|
|
while index < length {
|
|
if bytes[index] != expected[index] {
|
|
return false
|
|
}
|
|
index += 1
|
|
}
|
|
return bytes[length] == cast(u8)0
|
|
}
|
|
|
|
FullAppUrlIs :: (href: string, expected: string) -> bool {
|
|
output: [256]u8
|
|
length := MiniModeFullAppUrl(href, output[:])
|
|
return SameText(output[:], length, expected)
|
|
}
|
|
|
|
#program_export
|
|
Answer :: () -> s32 {
|
|
arguments: [3]string
|
|
arguments[0] = "inbe"
|
|
arguments[1] = "--break-now"
|
|
arguments[2] = "--mini"
|
|
if !MiniModeArgument(arguments[:]) { return 1 }
|
|
if MiniModeArgument(arguments[0:2]) { return 2 }
|
|
// The program name is not an option.
|
|
arguments[0] = "--mini"
|
|
if MiniModeArgument(arguments[0:1]) { return 3 }
|
|
|
|
if !MiniModeQuery("?mini") { return 4 }
|
|
if !MiniModeQuery("?mini=1") { return 5 }
|
|
if !MiniModeQuery("?lang=de&mini") { return 6 }
|
|
if !MiniModeQuery("mini") { return 7 }
|
|
if MiniModeQuery("") { return 8 }
|
|
if MiniModeQuery("?") { return 9 }
|
|
if MiniModeQuery("?minimal") { return 10 }
|
|
if MiniModeQuery("?theme=mini") { return 11 }
|
|
if MiniModeQuery("?xmini") { return 12 }
|
|
|
|
if !FullAppUrlIs("https://inbe.waozi.xyz/app/?mini#/start",
|
|
"https://inbe.waozi.xyz/app/#/start") { return 13 }
|
|
if !FullAppUrlIs("https://a.b/?lang=de&mini=1&theme=2#/session",
|
|
"https://a.b/?lang=de&theme=2#/session") { return 14 }
|
|
if !FullAppUrlIs("https://a.b/?mini&lang=de", "https://a.b/?lang=de") {
|
|
return 15
|
|
}
|
|
if !FullAppUrlIs("https://a.b/", "https://a.b/") { return 16 }
|
|
// A '?' inside the hash belongs to the hash.
|
|
if !FullAppUrlIs("https://a.b/#/start?mini", "https://a.b/#/start?mini") {
|
|
return 17
|
|
}
|
|
if !FullAppUrlIs("https://a.b/?&mini&&x#h", "https://a.b/?x#h") {
|
|
return 18
|
|
}
|
|
small: [8]u8
|
|
if MiniModeFullAppUrl("https://a.b/?mini", small[:]) != -1 { return 19 }
|
|
|
|
if !MiniModeAllowsScreen(ScreenStart) { return 20 }
|
|
if !MiniModeAllowsScreen(ScreenSession) { return 21 }
|
|
if !MiniModeAllowsScreen(ScreenMeditation) { return 22 }
|
|
if !MiniModeAllowsScreen(ScreenSunSalutation) { return 23 }
|
|
if !MiniModeAllowsScreen(ScreenPatterns) { return 24 }
|
|
if !MiniModeAllowsScreen(ScreenResults) { return 25 }
|
|
if MiniModeAllowsScreen(ScreenHabits) { return 26 }
|
|
if MiniModeAllowsScreen(ScreenEList) { return 27 }
|
|
if MiniModeAllowsScreen(ScreenSettings) { return 28 }
|
|
if MiniModeAllowsScreen(ScreenProfile) { return 29 }
|
|
if MiniModeAllowsScreen(ScreenLanguage) { return 30 }
|
|
if MiniModeAllowsScreen(ScreenManual) { return 31 }
|
|
if MiniModeAllowsScreen(ScreenBreak) { return 32 }
|
|
if !MiniModeWaoziThemeQuery("?mini&theme=waozi") {
|
|
return 33
|
|
}
|
|
if !MiniModeWaoziThemeQuery("?theme=waozi&mini=1") {
|
|
return 34
|
|
}
|
|
if MiniModeWaoziThemeQuery("?theme=waozi") ||
|
|
MiniModeWaoziThemeQuery("?mini&theme=waozix") ||
|
|
MiniModeWaoziThemeQuery("?mini&x-theme=waozi") {
|
|
return 35
|
|
}
|
|
if !FullAppUrlIs("https://a.b/?mini&theme=waozi&lang=de#/start",
|
|
"https://a.b/?lang=de#/start") {
|
|
return 36
|
|
}
|
|
return 42
|
|
}
|