Skip to content

Commit

Permalink
Merge pull request #20 from StepicOrg/release/1.21
Browse files Browse the repository at this point in the history
Release/1.21
  • Loading branch information
Ostrenkiy authored Nov 18, 2016
2 parents f55b3ab + 9ed0ac0 commit db7096e
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 68 deletions.
4 changes: 3 additions & 1 deletion Stepic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@
08C0A4331BF1276C0010F049 /* Messages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Messages.swift; sourceTree = "<group>"; };
08C0A4351BF12CDF0010F049 /* CustomMessagesDesign.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = CustomMessagesDesign.json; sourceTree = "<group>"; };
08C5E4FC1C315272004AA626 /* AudioManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioManager.swift; sourceTree = "<group>"; };
08C70F261DDA10D200B72CAB /* Model_exams_v10.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model_exams_v10.xcdatamodel; sourceTree = "<group>"; };
08C9F7CF1C29AE8B00E544D0 /* WebControllerManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebControllerManager.swift; sourceTree = "<group>"; };
08CA59D41BBA1628008DC44D /* Stepic-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Stepic-Bridging-Header.h"; sourceTree = "<group>"; };
08CA59D81BBC008A008DC44D /* CoursePreviewViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CoursePreviewViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
Expand Down Expand Up @@ -2973,6 +2974,7 @@
08D1EF6E1BB5618700BE84E6 /* Model.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
08C70F261DDA10D200B72CAB /* Model_exams_v10.xcdatamodel */,
082EDED51D88871F006B51DC /* Model_v9.xcdatamodel */,
084A2E5B1D80A83800C6702B /* Model_v8.xcdatamodel */,
084070821D64883400308FC1 /* Model_v7.xcdatamodel */,
Expand All @@ -2983,7 +2985,7 @@
0802AC531C7222B200C4F3E6 /* Model_v2.xcdatamodel */,
08D1EF6F1BB5618700BE84E6 /* Model.xcdatamodel */,
);
currentVersion = 082EDED51D88871F006B51DC /* Model_v9.xcdatamodel */;
currentVersion = 08C70F261DDA10D200B72CAB /* Model_exams_v10.xcdatamodel */;
path = Model.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
showNonLocalizedStrings = "YES"
language = "ru"
region = "RU">
<BuildableProductRunnable
Expand Down
10 changes: 8 additions & 2 deletions Stepic/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// AppDelegate.swift
// Stepic
//
Expand Down Expand Up @@ -78,7 +78,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var currentNavigation : UINavigationController? {
if let tabController = window?.rootViewController as? UITabBarController {
return tabController.viewControllers?[tabController.selectedIndex] as? UINavigationController
let cnt = tabController.viewControllers?.count ?? 0
let index = tabController.selectedIndex
if index < cnt {
return tabController.viewControllers?[tabController.selectedIndex] as? UINavigationController
} else {
return tabController.viewControllers?[0] as? UINavigationController
}
}
return nil
}
Expand Down
11 changes: 10 additions & 1 deletion Stepic/CoursePreviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ class CoursePreviewViewController: UIViewController {

}

var displayingInfoType : DisplayingInfoType = .overview
var displayingInfoType : DisplayingInfoType = .overview {
didSet {
if displayingInfoType == .syllabus {
tableView.reloadData()
}
}
}

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -83,6 +89,7 @@ class CoursePreviewViewController: UIViewController {
for section in c.sections {
sectionTitles += [section.title]
}
print(sectionTitles)
tableView.reloadData()
resetHeightConstraints()
if let introVideo = c.introVideo {
Expand Down Expand Up @@ -124,6 +131,7 @@ class CoursePreviewViewController: UIViewController {
for section in c.sections {
self?.sectionTitles += [section.title]
}
// print(self?.sectionTitles)
self?.isErrorWhileLoadingSections = false
self?.isLoadingSections = false
UIThread.performUI{ self?.tableView.reloadData() }
Expand Down Expand Up @@ -389,6 +397,7 @@ extension CoursePreviewViewController : UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0:
print(max(textData[0].count, textData[1].count, sectionTitles.count, 1))
return max(textData[0].count, textData[1].count, sectionTitles.count, 1)
default:
return 0
Expand Down
32 changes: 28 additions & 4 deletions Stepic/HTMLBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ class HTMLBuilder: NSObject {
return res
}

fileprivate var stepicBaseURLString: String = "<base href=\"\(StepicApplicationsInfo.stepicURL)\">"
fileprivate var stepicBaseURLString: String = ""//"<base href=\"\(StepicApplicationsInfo.stepicURL)\">"

func buildHTMLStringWith(head: String, body: String, addStepicFont : Bool = true, width: Int) -> String {
var res = "<html>\n"

res += "<head>\n\(stepicStyleString + stepicBaseURLString + head)\n</head>\n"
// print(body)
res += "<body style=\"width:\(width))px;\">\n\(body)\n</body>\n"
res += "<body style=\"width:\(width))px;\">\n\(addStepikURLWhereNeeded(body: body))\n</body>\n"

res += "</html>"
return res
Expand All @@ -65,7 +65,7 @@ class HTMLBuilder: NSObject {
res += "<head>\n\(stepicCommentStyleString + head)\n</head>\n"

let bodyOpenTag = "<body>"
res += "\(bodyOpenTag)\n\(body)\n</body>\n"
res += "\(bodyOpenTag)\n\(addStepikURLWhereNeeded(body: body))\n</body>\n"

res += "</html>"
return res
Expand All @@ -81,9 +81,33 @@ class HTMLBuilder: NSObject {
}
// print(body)
let bodyOpenTag = "<body text=\"\(textColorHex)\">"
res += "\(bodyOpenTag)\n\(body)\n</body>\n"
res += "\(bodyOpenTag)\n\(addStepikURLWhereNeeded(body: body))\n</body>\n"

res += "</html>"
return res
}

func addStepikURLWhereNeeded(body: String) -> String {
var links = HTMLParsingUtil.getAllLinksWithText(body).map({return $0.link})
links += HTMLParsingUtil.getImageSrcLinks(body)
var linkMap = [String:String]()

for link in links {
// print("found link:")
if link.characters.first == Character("/") {
linkMap[link] = "\(StepicApplicationsInfo.stepicURL)/\(link)"
}
}

var newBody = body
for (key, val) in linkMap {
newBody = newBody.replacingOccurrences(of: key, with: val)
}

print("BODYYYY/n/n")
print(body)
print(newBody)

return newBody
}
}
4 changes: 2 additions & 2 deletions Stepic/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.20</string>
<string>1.21</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>6</string>
<string>2</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
2 changes: 1 addition & 1 deletion Stepic/Model.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Model_v9.xcdatamodel</string>
<string>Model_exams_v10.xcdatamodel</string>
</dict>
</plist>
Loading

0 comments on commit db7096e

Please sign in to comment.