Skip to content
This repository was archived by the owner on Nov 26, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
064D38CE83FACC358B7C0EC8 /* 📦 Copy Pods Resources */ = {
Expand Down Expand Up @@ -416,7 +416,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
52EDD0255393518C859DA01C /* 📦 Embed Pods Frameworks */ = {
Expand Down Expand Up @@ -461,7 +461,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
8F716768EB59E9B6D88C48D7 /* [CP] Copy Pods Resources */ = {
Expand Down Expand Up @@ -752,39 +752,39 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 5C8EADB52E1D834750CD7D23 /* Pods-Example.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
1A42C29D1C0E3883000F2137 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = F4CBB0C2C0FDFA3E1648DB43 /* Pods-Example.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
};
name = Release;
};
CA10C1391C572A4B0049165D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 3CE90B4095B5C7E6237EEBDD /* Pods-FolioReaderTests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
Expand All @@ -793,7 +793,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Debug;
Expand All @@ -802,7 +802,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 8E1BE6465444C567F5D1B8E6 /* Pods-FolioReaderTests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
BUNDLE_LOADER = "$(TEST_HOST)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = 32F2T8EJ6G;
Expand All @@ -811,7 +811,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.FolioReaderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 2.3;
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Example.app/Example";
};
name = Release;
Expand All @@ -820,7 +820,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = D7C82C879F323C6E960F882B /* Pods-StoryboardExample.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -830,14 +830,15 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.StoryboardExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
D12066731D65FABE006E1D18 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 1D4790507F22E69298DC06E1 /* Pods-StoryboardExample.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ANALYZER_NONNULL = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -847,6 +848,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.folioreader.StoryboardExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions Example/Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
FolioReader.applicationWillResignActive()
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
FolioReader.applicationWillTerminate()
}

Expand Down
14 changes: 7 additions & 7 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class ViewController: UIViewController {
setCover(bookTwo, index: 1)
}

@IBAction func didOpen(sender: AnyObject) {
@IBAction func didOpen(_ sender: AnyObject) {
openEpub(sender.tag);
}

func openEpub(sampleNum: Int) {
func openEpub(_ sampleNum: Int) {
let config = FolioReaderConfig()
config.shouldHideNavigationOnTap = sampleNum == 1 ? true : false
config.scrollDirection = sampleNum == 1 ? .horizontal : .vertical
Expand All @@ -45,23 +45,23 @@ class ViewController: UIViewController {
// config.menuBackgroundColor = UIColor.lightGrayColor()

// Custom sharing quote background
let customImageQuote = QuoteImage(withImage: UIImage(named: "demo-bg")!, alpha: 0.6, backgroundColor: UIColor.blackColor())
let customImageQuote = QuoteImage(withImage: UIImage(named: "demo-bg")!, alpha: 0.6, backgroundColor: UIColor.black)
let customQuote = QuoteImage(withColor: UIColor(red:0.30, green:0.26, blue:0.20, alpha:1.0), alpha: 1.0, textColor: UIColor(red:0.86, green:0.73, blue:0.70, alpha:1.0))

config.quoteCustomBackgrounds = [customImageQuote, customQuote]

// Epub file
let epubName = epubSampleFiles[sampleNum-1];
let bookPath = NSBundle.mainBundle().pathForResource(epubName, ofType: "epub")
let bookPath = Bundle.main.path(forResource: epubName, ofType: "epub")
FolioReader.presentReader(parentViewController: self, withEpubPath: bookPath!, andConfig: config, shouldRemoveEpub: false)
}

func setCover(button: UIButton, index: Int) {
func setCover(_ button: UIButton, index: Int) {
let epubName = epubSampleFiles[index];
let bookPath = NSBundle.mainBundle().pathForResource(epubName, ofType: "epub")
let bookPath = Bundle.main.path(forResource: epubName, ofType: "epub")

if let image = FolioReader.getCoverImage(bookPath!) {
button.setBackgroundImage(image, forState: .Normal)
button.setBackgroundImage(image, for: .normal)
}
}
}
5 changes: 3 additions & 2 deletions Example/FolioReaderTests/FolioReaderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ class FolioReaderTests: QuickSpec {
var subject: FREpubParser!

beforeEach {
let path = NSBundle(forClass: self.dynamicType).pathForResource("The Silver Chair", ofType: "epub")!
let path = Bundle(for: type(of: self)).path(forResource: "The Silver Chair", ofType: "epub")!
subject = FREpubParser()
subject.readEpub(epubPath: path)
let book = subject.readEpub(epubPath: path)
print(book?.tableOfContents.first?.title)
}

it("correctly parses a properly formatted document") {
Expand Down
4 changes: 2 additions & 2 deletions Example/FolioReaderTests/SharingProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SharingProviderTests: QuickSpec {
}

it("returns text for a mail activity") {
let itemForActivityType = subject.activityViewController(activityViewController, itemForActivityType: UIActivityTypeMail) as? String
let itemForActivityType = subject.activityViewController(activityViewController, itemForActivityType: UIActivityType.mail) as? String
expect(itemForActivityType).to(equal(subject.text))
}
}
Expand All @@ -41,7 +41,7 @@ class SharingProviderTests: QuickSpec {
}

it("returns HTML for a mail activity") {
let itemForActivityType = subject.activityViewController(activityViewController, itemForActivityType: UIActivityTypeMail) as? String
let itemForActivityType = subject.activityViewController(activityViewController, itemForActivityType: UIActivityType.mail) as? String
expect(itemForActivityType).to(equal(subject.html))
}
}
Expand Down
19 changes: 2 additions & 17 deletions Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def shared_pods
end

def testing_pods
pod 'Quick', '0.9.2'
pod 'Nimble', '~> 4.1.0'
pod 'Quick', '0.10.0'
pod 'Nimble', '~> 5.0.0'
end

target 'Example' do
Expand All @@ -24,18 +24,3 @@ target 'FolioReaderTests' do
shared_pods
testing_pods
end


post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Force add version
config.build_settings['SWIFT_VERSION'] = '2.3'

# ensure testability is set https://github.com/CocoaPods/CocoaPods/issues/4505
if config.name == 'Debug'
config.build_settings['ENABLE_TESTABILITY'] = 'YES'
end
end
end
end
39 changes: 21 additions & 18 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
PODS:
- AEXML (3.0.0)
- AEXML (4.0.0)
- FolioReaderKit (0.9.4):
- AEXML (= 3.0)
- JSQWebViewController (~> 3.0)
- MenuItemKit (= 1.1.3)
- AEXML (= 4.0)
- FontBlaster (= 3.0.0)
- JSQWebViewController (~> 5.0)
- MenuItemKit (= 2.0)
- RealmSwift (~> 1.0)
- SSZipArchive (= 1.5)
- ZFDragableModalTransition (~> 0.6)
- JSQWebViewController (3.0.0)
- MenuItemKit (1.1.3)
- Nimble (4.1.0)
- Quick (0.9.2)
- FontBlaster (3.0.0)
- JSQWebViewController (5.0.0)
- MenuItemKit (2.0)
- Nimble (5.0.0)
- Quick (0.10.0)
- Realm (1.1.0):
- Realm/Headers (= 1.1.0)
- Realm/Headers (1.1.0)
Expand All @@ -21,25 +23,26 @@ PODS:

DEPENDENCIES:
- FolioReaderKit (from `../`)
- Nimble (~> 4.1.0)
- Quick (= 0.9.2)
- Nimble (~> 5.0.0)
- Quick (= 0.10.0)

EXTERNAL SOURCES:
FolioReaderKit:
:path: "../"

SPEC CHECKSUMS:
AEXML: 716fb0a8decba4a3517324a71fee3685b30233d2
FolioReaderKit: 993c4bfb89e93c80bba3965feef3a49f70c25f95
JSQWebViewController: eaa6bd68d9e1426ae25ade99c9bbde4c6cdd4120
MenuItemKit: 11c448d9172936ee79ebb78f36dffd396020a9e5
Nimble: 97a0a4cae5124c117115634b2d055d8c97d0af19
Quick: 18d057bc66451eedd5d1c8dc99ba2a5db6e60226
AEXML: 6fc6433aa35bdc15dd8eb8d54eb7aa4520a010eb
FolioReaderKit: 600a04088ebaf0613c6681692aa65f477fe85a5c
FontBlaster: 0f4a3e2f965968e2dfc3f7f5cec7214c3f3b2f07
JSQWebViewController: 0461aa42612b221571556df61d9c09f080cb2eef
MenuItemKit: 9af69953dc983803ee85230e205fadbac0f26213
Nimble: 56fc9f5020effa2206de22c3dd910f4fb011b92f
Quick: 5d290df1c69d5ee2f0729956dcf0fd9a30447eaa
Realm: ceecf1a4540c4ce9efe196fe73fa9855bce05bd8
RealmSwift: 838058b2db95b12cb86bd0cf209df642c33fb60a
SSZipArchive: 29daace2bccb90a47de2837744da397728ff9207
ZFDragableModalTransition: 0d294eaaba6edfcb9839595de765f9ca06a4b524

PODFILE CHECKSUM: 55962a6106e53da04861e4602fc98856987b97b3
PODFILE CHECKSUM: b6c4012c0fafa1e10299b2246c12b2ff15d1d26d

COCOAPODS: 1.0.1
COCOAPODS: 1.1.0.rc.2
7 changes: 4 additions & 3 deletions FolioReaderKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ Pod::Spec.new do |s|
s.libraries = "z"
s.frameworks = 'CoreData'
s.dependency 'SSZipArchive', '1.5'
s.dependency 'MenuItemKit', '1.1.3'
s.dependency 'MenuItemKit', '2.0'
s.dependency 'ZFDragableModalTransition', '~> 0.6'
s.dependency 'AEXML', '3.0'
s.dependency 'JSQWebViewController', '~> 3.0'
s.dependency 'AEXML', '4.0'
s.dependency 'FontBlaster', '3.0.0'
s.dependency 'JSQWebViewController', '~> 5.0'
s.dependency 'RealmSwift', '~> 1.0'
# s.dependency 'SMSegmentView'
end
26 changes: 15 additions & 11 deletions Source/EPUBCore/FRBook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import UIKit

public class FRBook: NSObject {
open class FRBook: NSObject {
var resources = FRResources()
var metadata = FRMetadata()
var spine = FRSpine()
Expand Down Expand Up @@ -38,19 +38,23 @@ public class FRBook: NSObject {
}

// @NOTE: should "#" be automatically prefixed with the ID?
func durationFor(ID: String) -> String? {
func durationFor(_ ID: String) -> String? {
return metadata.findMetaByProperty("media:duration", refinedBy: ID)
}


func activeClass() -> String! {
let className = metadata.findMetaByProperty("media:active-class");
return className ?? "epub-media-overlay-active";
func activeClass() -> String {
guard let className = metadata.findMetaByProperty("media:active-class") else {
return "epub-media-overlay-active"
}
return className
}

func playbackActiveClass() -> String! {
let className = metadata.findMetaByProperty("media:playback-active-class");
return className ?? "epub-media-overlay-playing";
func playbackActiveClass() -> String {
guard let className = metadata.findMetaByProperty("media:playback-active-class") else {
return "epub-media-overlay-playing"
}
return className
}


Expand All @@ -59,7 +63,7 @@ public class FRBook: NSObject {
/**
Get Smil File from a resource (if it has a media-overlay)
*/
func smilFileForResource(resource: FRResource!) -> FRSmilFile! {
func smilFileForResource(_ resource: FRResource!) -> FRSmilFile! {
if( resource == nil || resource.mediaOverlay == nil ){
return nil
}
Expand All @@ -71,11 +75,11 @@ public class FRBook: NSObject {
return smils.findByHref( smilResource!.href )
}

func smilFileForHref(href: String) -> FRSmilFile! {
func smilFileForHref(_ href: String) -> FRSmilFile! {
return smilFileForResource(resources.findByHref(href))
}

func smilFileForId(ID: String) -> FRSmilFile! {
func smilFileForId(_ ID: String) -> FRSmilFile! {
return smilFileForResource(resources.findById(ID))
}

Expand Down
Loading