Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
19a3b37
initial commit for htmlInject feature branch
danielweck Oct 7, 2014
bb03b88
submodule
danielweck Oct 7, 2014
e8df0bc
removed MathJax AuthorInit section, fixes https://github.com/readium/…
danielweck Oct 15, 2014
9a8bc4f
Merge branch 'develop' into feature/htmlInject
danielweck Oct 20, 2014
f367b6b
added missing support for annotations.css injection in HTML documents
danielweck Oct 20, 2014
c95230f
submodule
danielweck Oct 22, 2014
9a3301d
submodule
danielweck Oct 23, 2014
8f75826
Merge branch 'develop' into feature/htmlInject
danielweck Oct 28, 2014
2fc04a6
isubodules
danielweck Oct 28, 2014
88db649
re-instated inadvertantly removed UI-Orientation (no idea why that ch…
danielweck Oct 28, 2014
3874d0c
removed NSURLCache, added "Javascript Executor" service (benefit: mai…
danielweck Oct 29, 2014
d43ef18
compile errors (sorry)
danielweck Oct 29, 2014
907a1cc
testing NSURLCache-free design...WIP
danielweck Oct 29, 2014
e431c9d
submodule
danielweck Oct 29, 2014
437ff65
NSBundle payload is now provided as an NSData* by the app launcher (c…
danielweck Oct 29, 2014
066a6d6
minor follow-up: ensure pointer references are set to nil
danielweck Oct 29, 2014
fadd7ae
Use the updated RDPackageResourceServer interface.
Oct 29, 2014
24eb8ca
Merge branch 'develop' into feature/htmlInject
danielweck Oct 29, 2014
099bb85
removed unnecessary (obsolete) comment
danielweck Oct 29, 2014
3f304c3
submodule
danielweck Oct 29, 2014
750a61a
Merge branch 'develop' into feature/htmlInject
danielweck Oct 30, 2014
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
77 changes: 71 additions & 6 deletions Classes/EPubViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
#import "RDSpineItem.h"


@interface EPubViewController ()
@interface EPubViewController () <RDPackageResourceServerDelegate> {
@private NSData *m_specialPayload_AnnotationsCSS;
@private NSData *m_specialPayload_MathJaxJS;
}

- (void)passSettingsToJavaScript;
- (void)updateNavigationItems;
Expand All @@ -50,6 +53,36 @@ - (void)updateToolbar;

@implementation EPubViewController

- (void)initializeSpecialPayloads {

// May be left to NIL if desired (in which case MathJax and annotations.css functionality will be disabled).

m_specialPayload_AnnotationsCSS = nil;
m_specialPayload_MathJaxJS = nil;


NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MathJax" ofType:@"js" inDirectory:@"mathjax"];
if (filePath != nil) {
NSString *code = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
if (code != nil) {
NSData *data = [code dataUsingEncoding:NSUTF8StringEncoding];
if (data != nil) {
m_specialPayload_MathJaxJS = data;
}
}
}

filePath = [[NSBundle mainBundle] pathForResource:@"annotations" ofType:@"css"];
if (filePath != nil) {
NSString *code = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
if (code != nil) {
NSData *data = [code dataUsingEncoding:NSUTF8StringEncoding];
if (data != nil) {
m_specialPayload_AnnotationsCSS = data;
}
}
}
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
m_alertAddBookmark = nil;
Expand Down Expand Up @@ -133,7 +166,6 @@ - (void)cleanUp {
cfi:bookmark.cfi];
}


- (id)
initWithContainer:(RDContainer *)container
package:(RDPackage *)package
Expand Down Expand Up @@ -161,7 +193,19 @@ - (void)cleanUp {
m_navElement = navElement;
m_package = package;
m_spineItem = spineItem;
m_resourceServer = [[RDPackageResourceServer alloc] initWithPackage:package];

[self initializeSpecialPayloads];

m_resourceServer = [[RDPackageResourceServer alloc]
initWithDelegate:self
package:package
specialPayloadAnnotationsCSS:m_specialPayload_AnnotationsCSS
specialPayloadMathJaxJS:m_specialPayload_MathJaxJS];

if (m_resourceServer == nil) {
return nil;
}

[self updateNavigationItems];
}

Expand Down Expand Up @@ -190,12 +234,24 @@ - (void)cleanUp {
return nil;
}

if (self = [super initWithTitle:package.title navBarHidden:NO]) {
if (self = [super initWithTitle:package.title navBarHidden:NO]) {
m_container = container;
m_initialCFI = cfi;
m_package = package;
m_resourceServer = [[RDPackageResourceServer alloc] initWithPackage:package];
m_spineItem = spineItem;

[self initializeSpecialPayloads];

m_resourceServer = [[RDPackageResourceServer alloc]
initWithDelegate:self
package:package
specialPayloadAnnotationsCSS:m_specialPayload_AnnotationsCSS
specialPayloadMathJaxJS:m_specialPayload_MathJaxJS];

if (m_resourceServer == nil) {
return nil;
}

[self updateNavigationItems];
}

Expand Down Expand Up @@ -322,6 +378,16 @@ - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverControl
}


- (void)
rdpackageResourceServer:(RDPackageResourceServer *)packageResourceServer
executeJavaScript:(NSString *)javaScript
{
dispatch_async(dispatch_get_main_queue(), ^{
[m_webView stringByEvaluatingJavaScriptFromString:javaScript];
});
}


- (void)updateNavigationItems {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAction
Expand Down Expand Up @@ -494,7 +560,6 @@ - (void)viewWillDisappear:(BOOL)animated {
}
}


- (BOOL)
webView:(UIWebView *)webView
shouldStartLoadWithRequest:(NSURLRequest *)request
Expand Down
56 changes: 56 additions & 0 deletions Resources/annotations.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* The z-index is to ensure that the bookmark is accessible even if it's overlayed on a highlight/underline of some type */
.comment {
background-image : url("/images/comment_clickable_icon.png");
background-repeat : no-repeat;
opacity : 0.5;
z-index : 10;
}
.hover-comment {
background-image : url("/images/comment_clickable_icon.png");
background-repeat : no-repeat;
opacity : 1.0;
z-index : 10;
}

.bookmark {
position : fixed;
top : "0px";
right : "0px";
background-color: red;
}

.highlight {
position: absolute;
opacity: 0.2;
background-color: red;
}

.hover-highlight {
position: absolute;
opacity: 0.4;
background-color: red;
}

.underline-range {
position: absolute;
}

.underline-range > .underline {
position: relative;
height: 15%;
opacity: 0.2;
background-color: red;
}

.underline-range > .hover-underline {
position: relative;
height: 15%;
opacity: 0.4;
background-color: red;
}

.underline-range > .transparent-part {
position: relative;
height: 85%;
background-color: transparent;
}
107 changes: 107 additions & 0 deletions Resources/mathjax/MathJax.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion Resources/reader.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@

$(document).ready(function () {
"use strict";
ReadiumSDK.reader = new ReadiumSDK.Views.ReaderView({el:"#viewport"});

//var prefix = (self.location && self.location.origin && self.location.pathname) ? (self.location.origin + self.location.pathname + "/..") : "";

ReadiumSDK.reader = new ReadiumSDK.Views.ReaderView(
{
el:"#viewport",
annotationCSSUrl: '/readium_Annotations.css' //prefix + '/css/annotations.css'
});

ReadiumSDK.trigger(ReadiumSDK.Events.READER_INITIALIZED);
});

Expand Down
8 changes: 8 additions & 0 deletions SDKLauncher-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
34E12BA9180301A2004DCB68 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 34E12B9C180301A2004DCB68 /* [email protected] */; };
34E12BAA180301A2004DCB68 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 34E12B9D180301A2004DCB68 /* Icon-76.png */; };
34E12BAB180301A2004DCB68 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 34E12B9E180301A2004DCB68 /* [email protected] */; };
8307EC6919E3DE4A00B00468 /* mathjax in Resources */ = {isa = PBXBuildFile; fileRef = 8307EC6719E3DDEC00B00468 /* mathjax */; };
83EBB4A419F56C1C0083E8F1 /* annotations.css in Resources */ = {isa = PBXBuildFile; fileRef = 83EBB4A319F56C1C0083E8F1 /* annotations.css */; };
85DE51A117FDDCAC00F55130 /* page-blanche-20130322.epub in Resources */ = {isa = PBXBuildFile; fileRef = 85DE51A017FDDCAC00F55130 /* page-blanche-20130322.epub */; };
A250D5FFC597F4E5EB74D3AC /* epub30-test-0120-20131022.epub in Resources */ = {isa = PBXBuildFile; fileRef = A250D58D34D67FC218608A1F /* epub30-test-0120-20131022.epub */; };
A250D8E19073D0C5B921BA5F /* epub30-test-0220-20131022.epub in Resources */ = {isa = PBXBuildFile; fileRef = A250D54A5C423A86C6099037 /* epub30-test-0220-20131022.epub */; };
Expand Down Expand Up @@ -286,6 +288,8 @@
34E12B9C180301A2004DCB68 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
34E12B9D180301A2004DCB68 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-76.png"; sourceTree = "<group>"; };
34E12B9E180301A2004DCB68 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
8307EC6719E3DDEC00B00468 /* mathjax */ = {isa = PBXFileReference; lastKnownFileType = folder; path = mathjax; sourceTree = "<group>"; };
83EBB4A319F56C1C0083E8F1 /* annotations.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = annotations.css; sourceTree = "<group>"; };
85DE51A017FDDCAC00F55130 /* page-blanche-20130322.epub */ = {isa = PBXFileReference; lastKnownFileType = file; path = "page-blanche-20130322.epub"; sourceTree = "<group>"; };
A250D54A5C423A86C6099037 /* epub30-test-0220-20131022.epub */ = {isa = PBXFileReference; lastKnownFileType = file.epub; path = "epub30-test-0220-20131022.epub"; sourceTree = "<group>"; };
A250D58D34D67FC218608A1F /* epub30-test-0120-20131022.epub */ = {isa = PBXFileReference; lastKnownFileType = file.epub; path = "epub30-test-0120-20131022.epub"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -315,6 +319,8 @@
3403515F16CE9362009E3B88 /* Injection */ = {
isa = PBXGroup;
children = (
83EBB4A319F56C1C0083E8F1 /* annotations.css */,
8307EC6719E3DDEC00B00468 /* mathjax */,
341A1F701790BC6800E603C4 /* host_app_feedback.js */,
3403516116CE93F2009E3B88 /* reader.css */,
3403516216CE93F2009E3B88 /* reader.html */,
Expand Down Expand Up @@ -740,6 +746,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8307EC6919E3DE4A00B00468 /* mathjax in Resources */,
34B56B5E1723158E00A5A4B8 /* childrens-literature-20130206.epub in Resources */,
3462FBEB16BC40F9003C79E1 /* Default.png in Resources */,
34E12BA9180301A2004DCB68 /* [email protected] in Resources */,
Expand All @@ -761,6 +768,7 @@
34E12BAA180301A2004DCB68 /* Icon-76.png in Resources */,
34E12BA0180301A2004DCB68 /* [email protected] in Resources */,
3462FBC816BC3C8F003C79E1 /* Localizable.strings in Resources */,
83EBB4A419F56C1C0083E8F1 /* annotations.css in Resources */,
340535B916BC729200D4A802 /* moby-dick-20120118.epub in Resources */,
3403516516CE93F2009E3B88 /* reader.css in Resources */,
3403516616CE93F2009E3B88 /* reader.html in Resources */,
Expand Down