Archived
App now processes 'type' strings, information string will now be trimmed
This commit is contained in:
+34
-21
@@ -31,6 +31,7 @@ class DataFetcher {
|
|||||||
let time = Expression<String>("time")
|
let time = Expression<String>("time")
|
||||||
let room = Expression<String>("room")
|
let room = Expression<String>("room")
|
||||||
let teacher = Expression<String>("teacher")
|
let teacher = Expression<String>("teacher")
|
||||||
|
let substType = Expression<String>("type")
|
||||||
let text = Expression<String>("text")
|
let text = Expression<String>("text")
|
||||||
|
|
||||||
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) {
|
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) {
|
||||||
@@ -76,6 +77,7 @@ class DataFetcher {
|
|||||||
t.column(time)
|
t.column(time)
|
||||||
t.column(room)
|
t.column(room)
|
||||||
t.column(teacher)
|
t.column(teacher)
|
||||||
|
t.column(substType)
|
||||||
})
|
})
|
||||||
|
|
||||||
try db.run(personal.create(ifNotExists: true) { t in
|
try db.run(personal.create(ifNotExists: true) { t in
|
||||||
@@ -87,6 +89,7 @@ class DataFetcher {
|
|||||||
t.column(time)
|
t.column(time)
|
||||||
t.column(room)
|
t.column(room)
|
||||||
t.column(teacher)
|
t.column(teacher)
|
||||||
|
t.column(substType)
|
||||||
})
|
})
|
||||||
|
|
||||||
try db.run(substitutions.delete())
|
try db.run(substitutions.delete())
|
||||||
@@ -103,26 +106,27 @@ class DataFetcher {
|
|||||||
let mTime = try cols.get(2).text()
|
let mTime = try cols.get(2).text()
|
||||||
let mRoom = try cols.get(4).text()
|
let mRoom = try cols.get(4).text()
|
||||||
let mTeacher = try cols.get(6).text()
|
let mTeacher = try cols.get(6).text()
|
||||||
|
let mType = try cols.get(7).text()
|
||||||
|
|
||||||
subst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
subst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
||||||
date: mDate, time: mTime, room: mRoom, teacher: mTeacher))
|
date: mDate, time: mTime, room: mRoom, teacher: mTeacher, type: mType))
|
||||||
let insert = substitutions.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
let insert = substitutions.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
||||||
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher)
|
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher, substType <- mType)
|
||||||
_ = try db.run(insert)
|
try db.run(insert)
|
||||||
if mDate.count > 2 && mDate[...mDate.index(mDate.startIndex, offsetBy: 2)] == "psa" {
|
if mDate.count > 2 && mDate[...mDate.index(mDate.startIndex, offsetBy: 2)] == "psa" {
|
||||||
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
||||||
date: mDate, time: mTime, room: mRoom, teacher: mTeacher))
|
date: mDate, time: mTime, room: mRoom, teacher: mTeacher, type: mType))
|
||||||
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
||||||
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher)
|
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher, substType <- mType)
|
||||||
_ = try db.run(insertPersonal)
|
try db.run(insertPersonal)
|
||||||
} else if courses == nil || courses == "", classes != nil && classes != "" {
|
} else if courses == nil || courses == "", classes != nil && classes != "" {
|
||||||
if !mGroup.isEmpty && mGroup != "" {
|
if !mGroup.isEmpty && mGroup != "" {
|
||||||
if classes!.contains(mGroup) || mGroup.contains(classes!) {
|
if classes!.contains(mGroup) || mGroup.contains(classes!) {
|
||||||
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
||||||
date: mDate, time: mTime, room: mRoom, teacher: mTeacher))
|
date: mDate, time: mTime, room: mRoom, teacher: mTeacher, type: mType))
|
||||||
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
||||||
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher)
|
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher, substType <- mType)
|
||||||
_ = try db.run(insertPersonal)
|
try db.run(insertPersonal)
|
||||||
isPersonalEmpty = false
|
isPersonalEmpty = false
|
||||||
personalPlanCount += 1
|
personalPlanCount += 1
|
||||||
}
|
}
|
||||||
@@ -132,10 +136,10 @@ class DataFetcher {
|
|||||||
if courses!.contains(mCourse) {
|
if courses!.contains(mCourse) {
|
||||||
if classes!.contains(mGroup) || mGroup.contains(classes!) {
|
if classes!.contains(mGroup) || mGroup.contains(classes!) {
|
||||||
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
||||||
date: mDate, time: mTime, room: mRoom, teacher: mTeacher))
|
date: mDate, time: mTime, room: mRoom, teacher: mTeacher, type: mType))
|
||||||
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
||||||
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher)
|
date <- mDate, time <- mTime, room <- mRoom, teacher <- mTeacher, substType <- mType)
|
||||||
_ = try db.run(insertPersonal)
|
try db.run(insertPersonal)
|
||||||
isPersonalEmpty = false
|
isPersonalEmpty = false
|
||||||
personalPlanCount += 1
|
personalPlanCount += 1
|
||||||
}
|
}
|
||||||
@@ -147,9 +151,9 @@ class DataFetcher {
|
|||||||
|
|
||||||
prefs.set(personalPlanCount, forKey: "personalPlanCount")
|
prefs.set(personalPlanCount, forKey: "personalPlanCount")
|
||||||
if isPersonalEmpty {
|
if isPersonalEmpty {
|
||||||
personalSubst.append(SubstModel(group: NSLocalizedString("personal_plan_empty", comment: ""), course: "", additional: "", date: "", time: "", room: "", teacher: ""))
|
personalSubst.append(SubstModel(group: NSLocalizedString("personal_plan_empty", comment: ""), course: "", additional: "", date: "", time: "", room: "", teacher: "", type: ""))
|
||||||
let insertPersonal = personal.insert(group <- NSLocalizedString("personal_plan_empty", comment: ""), course <- "", additional <- "", date <- "", time <- "", room <- "", teacher <- "")
|
let insertPersonal = personal.insert(group <- NSLocalizedString("personal_plan_empty", comment: ""), course <- "", additional <- "", date <- "", time <- "", room <- "", teacher <- "", substType <- "")
|
||||||
_ = try db.run(insertPersonal)
|
try db.run(insertPersonal)
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastUpdated = try doc.select("h1").get(0).text()
|
let lastUpdated = try doc.select("h1").get(0).text()
|
||||||
@@ -159,11 +163,11 @@ class DataFetcher {
|
|||||||
for item in pi {
|
for item in pi {
|
||||||
info += "\n\n\(try item.text())"
|
info += "\n\n\(try item.text())"
|
||||||
}
|
}
|
||||||
_ = prefs.set(info, forKey: "information")
|
prefs.set(info.trimmingCharacters(in: .whitespacesAndNewlines), forKey: "information")
|
||||||
|
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
infoList.append(info)
|
infoList.append(info.trimmingCharacters(in: .whitespacesAndNewlines))
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let foodDoc: Document = try SwiftSoup.parse(food)
|
let foodDoc: Document = try SwiftSoup.parse(food)
|
||||||
@@ -197,10 +201,11 @@ class DataFetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
menuList.append(s)
|
menuList.append(s)
|
||||||
_ = try db.run(foodmenu.insert(text <- s))
|
try db.run(foodmenu.insert(text <- s))
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch {}
|
} catch {
|
||||||
|
}
|
||||||
|
|
||||||
switch type {
|
switch type {
|
||||||
case "plan":
|
case "plan":
|
||||||
@@ -229,7 +234,7 @@ class DataFetcher {
|
|||||||
do {
|
do {
|
||||||
let db = try Connection("\(path)/db.sqlite3")
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
for subst in try db.prepare(substitutions) {
|
for subst in try db.prepare(substitutions) {
|
||||||
substs.append(SubstModel(group: subst[group], course: subst[course], additional: subst[additional], date: subst[date], time: subst[time], room: subst[room], teacher: subst[teacher]))
|
substs.append(SubstModel(group: subst[group], course: subst[course], additional: subst[additional], date: subst[date], time: subst[time], room: subst[room], teacher: subst[teacher], type: subst[substType]))
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
return substs
|
return substs
|
||||||
@@ -240,7 +245,7 @@ class DataFetcher {
|
|||||||
do {
|
do {
|
||||||
let db = try Connection("\(path)/db.sqlite3")
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
for subst in try db.prepare(personal) {
|
for subst in try db.prepare(personal) {
|
||||||
substs.append(SubstModel(group: subst[group], course: subst[course], additional: subst[additional], date: subst[date], time: subst[time], room: subst[room], teacher: subst[teacher]))
|
substs.append(SubstModel(group: subst[group], course: subst[course], additional: subst[additional], date: subst[date], time: subst[time], room: subst[room], teacher: subst[teacher], type: subst[substType]))
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
return substs
|
return substs
|
||||||
@@ -373,4 +378,12 @@ class DataFetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setCardFormatting(for layer: CALayer) {
|
||||||
|
layer.cornerRadius = 12.0
|
||||||
|
layer.shadowColor = UIColor.gray.cgColor
|
||||||
|
layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
|
||||||
|
layer.shadowRadius = 1.5
|
||||||
|
layer.shadowOpacity = 0.7
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,7 @@ class InfoViewController : UIViewController {
|
|||||||
self.extendedLayoutIncludesOpaqueBars = true
|
self.extendedLayoutIncludesOpaqueBars = true
|
||||||
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("information", comment: "")
|
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("information", comment: "")
|
||||||
let layer = contentView.layer
|
let layer = contentView.layer
|
||||||
layer.cornerRadius = 12.0
|
df.setCardFormatting(for: layer)
|
||||||
layer.shadowColor = UIColor.gray.cgColor
|
|
||||||
layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
|
|
||||||
layer.shadowRadius = 1.5
|
|
||||||
layer.shadowOpacity = 0.7
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func objDoAsync(_ sender: Any) {
|
@objc private func objDoAsync(_ sender: Any) {
|
||||||
|
|||||||
@@ -78,11 +78,7 @@ class MenuViewController : UICollectionViewController, UICollectionViewDelegateM
|
|||||||
cell.content.text = self.items[indexPath.item]
|
cell.content.text = self.items[indexPath.item]
|
||||||
cell.tintView.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
|
cell.tintView.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
|
||||||
let layer = cell.tintView.layer
|
let layer = cell.tintView.layer
|
||||||
layer.cornerRadius = 12.0
|
df.setCardFormatting(for: layer)
|
||||||
layer.shadowColor = UIColor.gray.cgColor
|
|
||||||
layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
|
|
||||||
layer.shadowRadius = 1.5
|
|
||||||
layer.shadowOpacity = 0.7
|
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
|
|||||||
let layout = MagazineLayout()
|
let layout = MagazineLayout()
|
||||||
var url = ""
|
var url = ""
|
||||||
var indexOfPSA: Int? = nil
|
var indexOfPSA: Int? = nil
|
||||||
|
let cancellations = ["eigenverantwortliches arbeiten", "entfall", "entfällt", "fällt aus", "freisetzung", "vtr. ohne lehrer"]
|
||||||
|
|
||||||
required init?(coder decoder: NSCoder) {
|
required init?(coder decoder: NSCoder) {
|
||||||
super.init(coder: decoder)
|
super.init(coder: decoder)
|
||||||
@@ -106,11 +107,7 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
|
|||||||
var image = df.getImage(from: course)
|
var image = df.getImage(from: course)
|
||||||
|
|
||||||
let layer = cell.tintView.layer
|
let layer = cell.tintView.layer
|
||||||
layer.cornerRadius = 12.0
|
df.setCardFormatting(for: layer)
|
||||||
layer.shadowColor = UIColor.gray.cgColor
|
|
||||||
layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
|
|
||||||
layer.shadowRadius = 1.5
|
|
||||||
layer.shadowOpacity = 0.7
|
|
||||||
cell.tintView.backgroundColor = self.df.getColour(for: course)
|
cell.tintView.backgroundColor = self.df.getColour(for: course)
|
||||||
|
|
||||||
let dateString = self.substs[indexPath.item].date
|
let dateString = self.substs[indexPath.item].date
|
||||||
@@ -144,14 +141,31 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
|
|||||||
}
|
}
|
||||||
|
|
||||||
let add = self.substs[indexPath.item].additional.lowercased()
|
let add = self.substs[indexPath.item].additional.lowercased()
|
||||||
|
let type = self.substs[indexPath.item].type.lowercased()
|
||||||
if add.contains("eigenverantwortliches arbeiten") || add.contains("entfall") || add.contains("fällt aus"){
|
if add.contains("eigenverantwortliches arbeiten") || add.contains("entfall") || add.contains("fällt aus"){
|
||||||
for i in 2...4 {
|
|
||||||
mutableStrings[i].addAttribute(NSAttributedString.Key.strikethroughStyle, value: 2, range: NSMakeRange(0, mutableStrings[i].length))
|
}
|
||||||
|
|
||||||
|
if !add.isEmpty {
|
||||||
|
if check(string: add, for: cancellations) {
|
||||||
|
for i in 2...4 {
|
||||||
|
mutableStrings[i].addAttribute(NSAttributedString.Key.strikethroughStyle, value: 2, range: NSMakeRange(0, mutableStrings[i].length))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if check(string: type, for: cancellations) {
|
||||||
|
for i in 2...4 {
|
||||||
|
mutableStrings[i].addAttribute(NSAttributedString.Key.strikethroughStyle, value: 2, range: NSMakeRange(0, mutableStrings[i].length))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cell.group.attributedText = mutableStrings[0]
|
cell.group.attributedText = mutableStrings[0]
|
||||||
cell.additional.text = self.substs[indexPath.item].additional
|
if !self.substs[indexPath.item].additional.isEmpty {
|
||||||
|
cell.additional.text = self.substs[indexPath.item].additional
|
||||||
|
} else {
|
||||||
|
cell.additional.text = self.substs[indexPath.item].type
|
||||||
|
}
|
||||||
cell.time.attributedText = mutableStrings[1]
|
cell.time.attributedText = mutableStrings[1]
|
||||||
cell.room.attributedText = mutableStrings[3]
|
cell.room.attributedText = mutableStrings[3]
|
||||||
|
|
||||||
@@ -189,6 +203,16 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
|
|||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func check(string s: String, for array: [String]) -> Bool {
|
||||||
|
var b = false
|
||||||
|
array.forEach { string in
|
||||||
|
if s.contains(string) {
|
||||||
|
b = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeModeForItemAt indexPath: IndexPath) -> MagazineLayoutItemSizeMode {
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeModeForItemAt indexPath: IndexPath) -> MagazineLayoutItemSizeMode {
|
||||||
var widthMode: MagazineLayoutItemWidthMode
|
var widthMode: MagazineLayoutItemWidthMode
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad { // iPad
|
if UIDevice.current.userInterfaceIdiom == .pad { // iPad
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ class SubstModel {
|
|||||||
var time: String
|
var time: String
|
||||||
var room: String
|
var room: String
|
||||||
var teacher: String
|
var teacher: String
|
||||||
|
var type: String
|
||||||
|
|
||||||
init(group: String, course: String, additional: String, date: String, time: String, room: String, teacher: String) {
|
init(group: String, course: String, additional: String, date: String, time: String, room: String, teacher: String, type: String) {
|
||||||
self.group = group
|
self.group = group
|
||||||
self.course = course
|
self.course = course
|
||||||
self.additional = additional
|
self.additional = additional
|
||||||
@@ -25,5 +26,6 @@ class SubstModel {
|
|||||||
self.time = time
|
self.time = time
|
||||||
self.room = room
|
self.room = room
|
||||||
self.teacher = teacher
|
self.teacher = teacher
|
||||||
|
self.type = type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user