Permalink
Browse files

Switching to using API to request pages

  • Loading branch information...
1 parent 1bb4a43 commit 6f80788889b2bea0b6db10cc7a94fdfd6a8d21a0 @pfhayes pfhayes committed Apr 19, 2012
Showing with 1,833 additions and 772 deletions.
  1. +3 −0 .gitmodules
  2. +2 −4 CREDITS
  3. +0 −11 Makefile
  4. +10 −10 README.md
  5. +84 −1 Wikipedia-iOS/Classes/AppDelegate.m
  6. +35 −62 Wikipedia-iOS/Plugins/ReadItLater/ReadItLaterFull.h
  7. +65 −36 Wikipedia-iOS/Plugins/ReadItLater/ReadItLaterFull.m
  8. +0 −1 WinPhone7/Wikipedia-WP/GapSourceDictionary.xml
  9. +4 −10 WinPhone7/Wikipedia-WP/Properties/WMAppManifest.xml
  10. +34 −7 WinPhone7/Wikipedia-WP/Wikipedia.csproj
  11. +0 −113 WinPhone7/Wikipedia-WP/www/index.html
  12. +12 −0 add-keys.bash
  13. +0 −39 api-keys.patch
  14. +1 −0 assets/www/AUTHORS
  15. +1 −0 assets/www/MobileFrontend
  16. +11 −25 assets/www/android/platform.js
  17. +103 −6 assets/www/app.css
  18. +34 −12 assets/www/index.html
  19. +60 −14 assets/www/ios/platform.js
  20. +105 −39 assets/www/js/app.js
  21. +3 −2 assets/www/js/app_history.js
  22. +48 −83 assets/www/js/chrome.js
  23. +594 −0 assets/www/js/iscroll-lite.js
  24. +6 −1 assets/www/js/l10n-setup.js
  25. +23 −65 assets/www/js/langlinks.js
  26. +3 −1 assets/www/js/main.js
  27. +37 −42 assets/www/js/menu.js
  28. +1 −1 assets/www/js/mobilefrontend.js
  29. +0 −46 assets/www/js/network.js
  30. +120 −0 assets/www/js/page.js
  31. +23 −0 assets/www/js/platform-stub.js
  32. +7 −1 assets/www/js/preferences.js
  33. +44 −22 assets/www/js/savedpages.js
  34. +71 −102 assets/www/js/search.js
  35. +6 −0 assets/www/js/settings.js
  36. +0 −4 assets/www/js/zepto.min.js
  37. +4 −0 assets/www/messages/messages-be-tarask.properties
  38. +8 −2 assets/www/messages/messages-ca.properties
  39. +1 −0 assets/www/messages/messages-en.properties
  40. +11 −2 assets/www/messages/messages-he.properties
  41. +76 −0 assets/www/messages/messages-is.properties
  42. +8 −2 assets/www/messages/messages-os.properties
  43. +83 −0 assets/www/messages/messages-sat.properties
  44. +39 −2 assets/www/messages/messages-vep.properties
  45. +1 −2 assets/www/messages/messages-zh-hans.properties
  46. +52 −2 assets/www/playbook/platform.js
View
@@ -0,0 +1,3 @@
+[submodule "assets/www/MobileFrontend"]
+ path = assets/www/MobileFrontend
+ url = https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MobileFrontend.git
View
@@ -7,7 +7,6 @@ following names for their contribution to the product.
Anis Kadri
Antoine Musso
Arthur Richards
-awjrichards
Brion Vibber
Chris McKee
Dale Lemieux
@@ -18,6 +17,7 @@ Gaurav
Gord Tanner
Herm Wong
Jan Christiansen
+Janardan Yri
Jeroen De Dauw
Joe Bowser
Jon Robson
@@ -28,9 +28,9 @@ Niklas Laxström
Patrick Hayes
Patrick Reilly
Sam Reed
-Shea Clare
Shealen Clare
Shravan Aras
+Siebrand Mazeland
Soumya Deb
Suyash Joshi
Thomas PT
@@ -39,8 +39,6 @@ Tomasz Finc
Tony Cheng
unknown
Yohei Shimomae
-yoheishimomae
-Yuvi Panda
YuviPanda
View
@@ -1,14 +1,3 @@
-REVISION=113645
-remotes:
- curl -o assets/www/js/toggle.js \
- "http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/MobileFrontend/javascripts/toggle.js?view=co&revision=$(REVISION)&content-type=text%2Fplain&pathrev=$(REVISION)"
- curl -o assets/www/common.css \
- "http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/MobileFrontend/stylesheets/common.css?view=co&revision=$(REVISION)&content-type=text%2Fplain&pathrev=$(REVISION)"
-
sitematrix:
curl -o assets/www/sitematrix.json \
"http://en.wikipedia.org/w/api.php?action=sitematrix&format=json"
-
-clean:
- rm assets/www/js/toggle.js
- rm assets/www/common.css
View
@@ -6,7 +6,7 @@ This project has been forked from the <a href="https://github.com/wikimedia/Wiki
1. Setup your development environment
2. Setup the project
-3. Pull down external dependencies via command line by running `make remotes`
+3. Run `git submodules update --init` to grab our submodule dependencies (MobileFrontend)
## Environment setup
@@ -19,6 +19,11 @@ This project has been forked from the <a href="https://github.com/wikimedia/Wiki
### Setting up the project
+#### in web browser
+You can run the app within your desktop browser under certain situations. Safari works out of the box. You can also use Google Chrome by passing it the `--disable-web-security` flag. Navigate to `index.html` to start the app.
+
+Note: Running in the web browser is currently not a supported environment. Things might break
+
#### without Eclipse
There is a highly useful tutorial @
@@ -46,16 +51,11 @@ Make sure to modify the sdk.dir variable in the local.properties file so that it
## FAQ
-Q. I'm seeing an error that says "DroidGap cannot be resolved to a type", how do I fix it?
+Q. I can't seem to find PhoneGap 1.4.1! Where can I download it?
-A. You will need to add the PhoneGap library to your project, by following these steps to get the file.
-
-1. Download <a href="https://github.com/phonegap/phonegap" target="_blank">PhoneGap</a>
-2. Unzip the PhoneGap files.
-3. Copy Android/phonegap-1.1.0.jar into the libs folder of your project.
-4. To add the phonegap-1.1.0.jar into your project, right click your Eclipse project and select Properties.
-5. Select Java Build Path, click on the Libraries tab and then click the Add JARs button.
-6. Browse to libs/phonegap-1.1.0.jar and choose to add it.
+A: Right [here][phonegap-1-4-1-download]
## Contributing
Please ensure you read STYLE_GUIDELINES before making any contribution to this project!
+
+[phonegap-1-4-1-download]: https://nodeload.github.com/phonegap/phonegap/zipball/1.4.1
@@ -52,11 +52,16 @@ @implementation AppDelegate
- (id) init
{
- /* Fix problem with ios 5.0.1+ and Webkit databases described at the following urls:
+
+ /* Fix problem with ios 5.0.1+ and Webkit databases described at the following urls:
* https://issues.apache.org/jira/browse/CB-347
* https://issues.apache.org/jira/browse/CB-330
* My strategy is to move any existing database from default paths
* to Documents/ and then changing app preferences accordingly
+ * This is done here so that we don't crash from a 2.x -> 3.x upgrade, which have different
+ * Webkit settings paths. See above link for details.
+ * This goes in init since we're initializing a webview here to get the useragent
+ * So we can set the useragent. Is repeated on didFinishLaunchingWithOptions too
*/
NSString* library = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)objectAtIndex:0];
@@ -133,6 +138,7 @@ - (id) init
NSLog(@"Fix applied for database locations?: %@", ok? @"YES":@"NO");
[appPreferences synchronize];
}
+
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *currentUserAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
@@ -157,6 +163,83 @@ - (id) init
*/
- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
+ /* Fix problem with ios 5.0.1+ and Webkit databases described at the following urls:
+ * https://issues.apache.org/jira/browse/CB-347
+ * https://issues.apache.org/jira/browse/CB-330
+ * My strategy is to move any existing database from default paths
+ * to Documents/ and then changing app preferences accordingly
+ * This is done here so that the database changes actually persist.
+ */
+
+ NSString* library = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)objectAtIndex:0];
+ NSString* documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+
+ NSString *localStorageSubdir = (IsAtLeastiOSVersion(@"5.1")) ? @"Caches" : @"WebKit/LocalStorage";
+ NSString *localStoragePath = [library stringByAppendingPathComponent:localStorageSubdir];
+ NSString *localStorageDb = [localStoragePath stringByAppendingPathComponent:@"file__0.localstorage"];
+
+ NSString *WebSQLSubdir = (IsAtLeastiOSVersion(@"5.1")) ? @"Caches" : @"WebKit/Databases";
+ NSString *WebSQLPath = [library stringByAppendingPathComponent:WebSQLSubdir];
+ NSString *WebSQLIndex = [WebSQLPath stringByAppendingPathComponent:@"Databases.db"];
+ NSString *WebSQLDb = [WebSQLPath stringByAppendingPathComponent:@"file__0"];
+
+ NSString *ourLocalStoragePath = [documents stringByAppendingPathComponent:@"LocalStorage"];;
+ NSString *ourLocalStorageDb = [ourLocalStoragePath stringByAppendingPathComponent:@"file__0.localstorage"];
+
+ NSString *ourWebSQLPath = [documents stringByAppendingPathComponent:@"Databases"];
+ NSString *ourWebSQLIndex = [ourWebSQLPath stringByAppendingPathComponent:@"Databases.db"];
+ NSString *ourWebSQLDb = [ourWebSQLPath stringByAppendingPathComponent:@"file__0"];
+
+ NSFileManager* fileManager = [NSFileManager defaultManager];
+
+ BOOL copy;
+ NSError *err = nil;
+ copy = [fileManager fileExistsAtPath:localStorageDb] && ![fileManager fileExistsAtPath:ourLocalStorageDb];
+ if (copy) {
+ [fileManager createDirectoryAtPath:ourLocalStoragePath withIntermediateDirectories:YES attributes:nil error:&err];
+ [fileManager copyItemAtPath:localStorageDb toPath:ourLocalStorageDb error:&err];
+ if (err == nil)
+ [fileManager removeItemAtPath:localStorageDb error:&err];
+ }
+
+ err = nil;
+ copy = [fileManager fileExistsAtPath:WebSQLPath] && ![fileManager fileExistsAtPath:ourWebSQLPath];
+ if (copy) {
+ [fileManager createDirectoryAtPath:ourWebSQLPath withIntermediateDirectories:YES attributes:nil error:&err];
+ [fileManager copyItemAtPath:WebSQLIndex toPath:ourWebSQLIndex error:&err];
+ [fileManager copyItemAtPath:WebSQLDb toPath:ourWebSQLDb error:&err];
+ if (err == nil)
+ [fileManager removeItemAtPath:WebSQLPath error:&err];
+ }
+
+ NSUserDefaults* appPreferences = [NSUserDefaults standardUserDefaults];
+ NSBundle* mainBundle = [NSBundle mainBundle];
+
+ NSString *bundlePath = [[mainBundle bundlePath] stringByDeletingLastPathComponent];
+ NSString *bundleIdentifier = [[mainBundle infoDictionary] objectForKey:@"CFBundleIdentifier"];
+ NSString* libraryPreferences = @"Library/Preferences";
+
+ NSString* appPlistPath = [[bundlePath stringByAppendingPathComponent:libraryPreferences] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.plist", bundleIdentifier]];
+ NSMutableDictionary* appPlistDict = [NSMutableDictionary dictionaryWithContentsOfFile:appPlistPath];
+
+ NSString *value;
+ NSString *key = @"WebKitLocalStorageDatabasePathPreferenceKey";
+ value = [appPlistDict objectForKey: key];
+ if (![value isEqual:ourLocalStoragePath]) {
+ [appPlistDict setValue:ourLocalStoragePath forKey:key];
+ }
+
+ key = @"WebDatabaseDirectory";
+ value = [appPlistDict objectForKey: key];
+ if (![value isEqual:ourWebSQLPath]) {
+ [appPlistDict setValue:ourWebSQLPath forKey:key];
+ }
+
+ BOOL ok = [appPlistDict writeToFile:appPlistPath atomically:YES];
+ NSLog(@"Fix applied for database locations?: %@", ok? @"YES":@"NO");
+ [appPreferences synchronize];
+
+
NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
if (url && [url isKindOfClass:[NSURL class]]) {
self.invokeString = [url absoluteString];
@@ -78,80 +78,53 @@
@property (nonatomic) BOOL releaseAfterSpinnerCancel;
- // METHODS FOR SAVING A LINK TO READ IT LATER
- // for documentation, screenshots, examples, see http://readitlaterlist.com/api_iphone/
- // Additional methods are available in the ReadItLaterLite class (see the note at the top of this file for more)
-
- // SIMPLEST: Let RIL do all of the work for you
- // REQUIRES: ReadItLaterViews.h
- // --------------------------------------------
- // Save a link to Read It Later, RIL will show displays over your UI notifying user of progress/result
-
- // Arguments:
- // url - NSURL - link to the page to save
- // title - NSString - (optional nil) - title of the page you are saving. For the best user experience please provide a unique way of identifying the link.
- // If you have the page loaded in a UIWebView, you can retrieve the title with:
- // NSString *title = [yourWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
- // username - NSString - (optional) - if not provided, this needs to be stored in NSUserDefaults in the key 'ReadItLaterUsername'
- // password - NSString - (optional) - if not provided, this needs to be stored in NSUserDefaults in the key 'ReadItLaterPassword'
-
- // Example of use: [ReadItLater save:[NSURL urlWithString:@"http://google.com"] title:@"Google"]
-
- +(void)save:(NSURL *)url title:(NSString *)title;
- +(void)save:(NSURL *)url title:(NSString *)title username:(NSString *)username password:(NSString *)password;
-
-
-
-
- /* ----------------------------------- */
-
- // METHODS FOR HANDLING LOGINS/SIGNUPS
- // for documentation, screenshots, examples, see http://readitlaterlist.com/api_iphone/
- // Additional methods are available in the ReadItLaterLite class (see the note at the top of this file for more)
-
-
- // SIMPLIEST: A screen will popup over your application (without leaving it) and allow the user to signup or login.
- // REQUIRES: ReadItLaterViews.h
- // ------------------------
- // Allow RIL signups and logins with one single line of code without leaving your app!
- // After the user successfully logs in (or signs up), their username and password will be stored in NSUserDefaults with the following keys:
- // NSUserDefault key: @"ReadItLaterUsername" - user's username
- // NSUserDefault key: @"ReadItLaterPassword" - user's password
-
- // Arguments: none
-
- +(void)showUserSetup;
-
-
-
- // you shouldn't need to call this function directly
- +(void)showUserSetupSaveWhenDone:(NSURL *)url title:(NSString *)title;
+// METHODS FOR SAVING A LINK TO READ IT LATER
+// for documentation, screenshots, examples, see http://readitlaterlist.com/api_iphone/
+// Additional methods are available in the ReadItLaterLite class (see the note at the top of this file for more)
-@end
+// SIMPLEST: Let RIL do all of the work for you
+// REQUIRES: ReadItLaterViews.h
+// --------------------------------------------
+// Save a link to Read It Later, RIL will show displays over your UI notifying user of progress/result
+// Arguments:
+// url - NSURL - link to the page to save
+// title - NSString - (optional nil) - title of the page you are saving. For the best user experience please provide a unique way of identifying the link.
+// If you have the page loaded in a UIWebView, you can retrieve the title with:
+// NSString *title = [yourWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
+// username - NSString - (optional) - if not provided, this needs to be stored in NSUserDefaults in the key 'ReadItLaterUsername'
+// password - NSString - (optional) - if not provided, this needs to be stored in NSUserDefaults in the key 'ReadItLaterPassword'
+// Example of use: [ReadItLater save:[NSURL urlWithString:@"http://google.com"] title:@"Google"]
++(void)save:(NSURL *)url title:(NSString *)title;
++(void)save:(NSURL *)url title:(NSString *)title username:(NSString *)username password:(NSString *)password;
-// -- These are base methods that build the interface and probably should not be implemented directly -- //
-@interface ReadItLaterFull (Private)
--(id)openSetup:(NSURL *)url title:(NSString *)title;
--(void)showMessage:(NSString *)message loading:(BOOL)loading;
--(BOOL)handleError:(NSString *)error;
--(void)hideMessageAndReleaseWhenDone:(BOOL)release;
--(void)showSpinnerCancelButton;
--(void)done;
-@end
+/* ----------------------------------- */
+// METHODS FOR HANDLING LOGINS/SIGNUPS
+// for documentation, screenshots, examples, see http://readitlaterlist.com/api_iphone/
+// Additional methods are available in the ReadItLaterLite class (see the note at the top of this file for more)
-@interface ReadItLaterFullView (Private)
+// SIMPLIEST: A screen will popup over your application (without leaving it) and allow the user to signup or login.
+// REQUIRES: ReadItLaterViews.h
+// ------------------------
+// Allow RIL signups and logins with one single line of code without leaving your app!
+// After the user successfully logs in (or signs up), their username and password will be stored in NSUserDefaults with the following keys:
+// NSUserDefault key: @"ReadItLaterUsername" - user's username
+// NSUserDefault key: @"ReadItLaterPassword" - user's password
--(void)changeToSignupFinishedScreen;
--(UITextField *)createFormField;
+// Arguments: none
+
++(void)showUserSetup;
-@end
+// you shouldn't need to call this function directly
++(void)showUserSetupSaveWhenDone:(NSURL *)url title:(NSString *)title;
+
+@end
Oops, something went wrong.

0 comments on commit 6f80788

Please sign in to comment.