Mhurd has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/99774


Change subject: Added section tocLevel to core data schema.
......................................................................

Added section tocLevel to core data schema.

Change-Id: I8e7df67e863208357f563196e62bb28aae37e239
---
M Wikipedia-iOS.xcodeproj/project.pbxproj
M 
Wikipedia-iOS/Data/Model/ArticleData.xcdatamodeld/ArticleData.xcdatamodel/contents
M Wikipedia-iOS/Data/Model/Section.h
M Wikipedia-iOS/Data/Model/Section.m
M Wikipedia-iOS/View Controllers/WebView/WebViewController.m
M Wikipedia-iOSTests/ArticleDataModel.m
6 files changed, 28 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/ios/wikipedia 
refs/changes/74/99774/1

diff --git a/Wikipedia-iOS.xcodeproj/project.pbxproj 
b/Wikipedia-iOS.xcodeproj/project.pbxproj
index f615b56..d16351e 100644
--- a/Wikipedia-iOS.xcodeproj/project.pbxproj
+++ b/Wikipedia-iOS.xcodeproj/project.pbxproj
@@ -25,8 +25,6 @@
                04142A68184EC5AC006EF779 /* History.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A66184EC5AC006EF779 /* History.m */; };
                04142A6F184EC5C9006EF779 /* Saved.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A6E184EC5C9006EF779 /* Saved.m */; };
                04142A70184EC5C9006EF779 /* Saved.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A6E184EC5C9006EF779 /* Saved.m */; };
-               04142A73184EC5D4006EF779 /* Section.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A72184EC5D4006EF779 /* Section.m */; };
-               04142A74184EC5D4006EF779 /* Section.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A72184EC5D4006EF779 /* Section.m */; };
                04142A77184EC5E1006EF779 /* Site.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A76184EC5E1006EF779 /* Site.m */; };
                04142A78184EC5E1006EF779 /* Site.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A76184EC5E1006EF779 /* Site.m */; };
                04142A7B184EC7B2006EF779 /* Image.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 04142A7A184EC7B2006EF779 /* Image.m */; };
@@ -67,6 +65,8 @@
                04478658185159700050563B /* history-random.png in Resources */ 
= {isa = PBXBuildFile; fileRef = 0447864D185159700050563B /* history-random.png 
*/; };
                04478659185159700050563B /* history-ran...@2x.png in Resources 
*/ = {isa = PBXBuildFile; fileRef = 0447864E185159700050563B /* 
history-ran...@2x.png */; };
                0447865A185159700050563B /* history-ran...@2x.png in Resources 
*/ = {isa = PBXBuildFile; fileRef = 0447864E185159700050563B /* 
history-ran...@2x.png */; };
+               0447866118528DCF0050563B /* Section.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 0447866018528DCF0050563B /* Section.m */; };
+               0447866218528DCF0050563B /* Section.m in Sources */ = {isa = 
PBXBuildFile; fileRef = 0447866018528DCF0050563B /* Section.m */; };
                0466F44F183A30CC00EA1FD7 /* logo-search-placeholder.png in 
Resources */ = {isa = PBXBuildFile; fileRef = 0466F44D183A30CC00EA1FD7 /* 
logo-search-placeholder.png */; };
                0466F450183A30CC00EA1FD7 /* logo-search-placehol...@2x.png in 
Resources */ = {isa = PBXBuildFile; fileRef = 0466F44E183A30CC00EA1FD7 /* 
logo-search-placehol...@2x.png */; };
                04A47629183EF835009C0D82 /* w.png in Resources */ = {isa = 
PBXBuildFile; fileRef = 04A47627183EF835009C0D82 /* w.png */; };
@@ -143,8 +143,6 @@
                04142A66184EC5AC006EF779 /* History.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name 
= History.m; path = "Wikipedia-iOS/Data/Model/History.m"; sourceTree = 
SOURCE_ROOT; };
                04142A6D184EC5C9006EF779 /* Saved.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
Saved.h; path = "Wikipedia-iOS/Data/Model/Saved.h"; sourceTree = SOURCE_ROOT; };
                04142A6E184EC5C9006EF779 /* Saved.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name 
= Saved.m; path = "Wikipedia-iOS/Data/Model/Saved.m"; sourceTree = SOURCE_ROOT; 
};
-               04142A71184EC5D4006EF779 /* Section.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
Section.h; path = "Wikipedia-iOS/Data/Model/Section.h"; sourceTree = 
SOURCE_ROOT; };
-               04142A72184EC5D4006EF779 /* Section.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name 
= Section.m; path = "Wikipedia-iOS/Data/Model/Section.m"; sourceTree = 
SOURCE_ROOT; };
                04142A75184EC5E1006EF779 /* Site.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = 
Site.h; path = "Wikipedia-iOS/Data/Model/Site.h"; sourceTree = SOURCE_ROOT; };
                04142A76184EC5E1006EF779 /* Site.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name 
= Site.m; path = "Wikipedia-iOS/Data/Model/Site.m"; sourceTree = SOURCE_ROOT; };
                04142A79184EC7B2006EF779 /* Image.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
Image.h; sourceTree = "<group>"; };
@@ -175,6 +173,8 @@
                0447864C185159700050563B /* history-l...@2x.png */ = {isa = 
PBXFileReference; lastKnownFileType = image.png; path = "history-l...@2x.png"; 
sourceTree = "<group>"; };
                0447864D185159700050563B /* history-random.png */ = {isa = 
PBXFileReference; lastKnownFileType = image.png; path = "history-random.png"; 
sourceTree = "<group>"; };
                0447864E185159700050563B /* history-ran...@2x.png */ = {isa = 
PBXFileReference; lastKnownFileType = image.png; path = 
"history-ran...@2x.png"; sourceTree = "<group>"; };
+               0447865F18528DCF0050563B /* Section.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
Section.h; sourceTree = "<group>"; };
+               0447866018528DCF0050563B /* Section.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= Section.m; sourceTree = "<group>"; };
                0466F44D183A30CC00EA1FD7 /* logo-search-placeholder.png */ = 
{isa = PBXFileReference; lastKnownFileType = image.png; path = 
"logo-search-placeholder.png"; sourceTree = "<group>"; };
                0466F44E183A30CC00EA1FD7 /* logo-search-placehol...@2x.png */ = 
{isa = PBXFileReference; lastKnownFileType = image.png; path = 
"logo-search-placehol...@2x.png"; sourceTree = "<group>"; };
                04A47627183EF835009C0D82 /* w.png */ = {isa = PBXFileReference; 
lastKnownFileType = image.png; path = w.png; sourceTree = "<group>"; };
@@ -367,12 +367,12 @@
                        isa = PBXGroup;
                        children = (
                                04FD6C78184EBFCD002CA02F /* 
ArticleData.xcdatamodeld */,
+                               0447865F18528DCF0050563B /* Section.h */,
+                               0447866018528DCF0050563B /* Section.m */,
                                04142A79184EC7B2006EF779 /* Image.h */,
                                04142A7A184EC7B2006EF779 /* Image.m */,
                                04142A75184EC5E1006EF779 /* Site.h */,
                                04142A76184EC5E1006EF779 /* Site.m */,
-                               04142A71184EC5D4006EF779 /* Section.h */,
-                               04142A72184EC5D4006EF779 /* Section.m */,
                                04142A6D184EC5C9006EF779 /* Saved.h */,
                                04142A6E184EC5C9006EF779 /* Saved.m */,
                                04142A65184EC5AC006EF779 /* History.h */,
@@ -626,7 +626,6 @@
                                04FD6C7A184EBFCD002CA02F /* 
ArticleData.xcdatamodeld in Sources */,
                                D4EE00B9182443FC0090790F /* MWPageTitle.m in 
Sources */,
                                04142A8F184F974E006EF779 /* NSDate-Utilities.m 
in Sources */,
-                               04142A73184EC5D4006EF779 /* Section.m in 
Sources */,
                                04142A77184EC5E1006EF779 /* Site.m in Sources 
*/,
                                04142A5F184EC593006EF779 /* Domain.m in Sources 
*/,
                                04C43AC2183442FC006C643B /* 
NSURLRequest+DictionaryRequest.m in Sources */,
@@ -645,6 +644,7 @@
                                04142A63184EC5A0006EF779 /* GalleryImage.m in 
Sources */,
                                04C43A9D183440B0006C643B /* MWCrumbyTest.m in 
Sources */,
                                04478635185145090050563B /* SearchBarLogoView.m 
in Sources */,
+                               0447866118528DCF0050563B /* Section.m in 
Sources */,
                                D4991445181D51DE00E6073C /* main.m in Sources 
*/,
                                04C43AC0183442FC006C643B /* NSString+Extras.m 
in Sources */,
                                0447862F185145090050563B /* HistoryResultCell.m 
in Sources */,
@@ -664,7 +664,6 @@
                                04478636185145090050563B /* SearchBarLogoView.m 
in Sources */,
                                0447863A185145090050563B /* SearchResultCell.m 
in Sources */,
                                04C43AC3183442FC006C643B /* 
NSURLRequest+DictionaryRequest.m in Sources */,
-                               04142A74184EC5D4006EF779 /* Section.m in 
Sources */,
                                04142A54184EC55E006EF779 /* Article.m in 
Sources */,
                                04C43A9E183440B0006C643B /* MWCrumbyTest.m in 
Sources */,
                                04142A78184EC5E1006EF779 /* Site.m in Sources 
*/,
@@ -673,6 +672,7 @@
                                04C43AA5183440C1006C643B /* 
MWNetworkActivityIndicatorManager.m in Sources */,
                                04142A68184EC5AC006EF779 /* History.m in 
Sources */,
                                04C43ABF183442FC006C643B /* 
NSRunLoop+TimeOutAndFlag.m in Sources */,
+                               0447866218528DCF0050563B /* Section.m in 
Sources */,
                                D4EE00BD1824459D0090790F /* PageTitleTests.m in 
Sources */,
                                04C43AB61834423C006C643B /* 
NetworkOpCrumbyTests.m in Sources */,
                                04478634185145090050563B /* 
HistoryViewController.m in Sources */,
diff --git 
a/Wikipedia-iOS/Data/Model/ArticleData.xcdatamodeld/ArticleData.xcdatamodel/contents
 
b/Wikipedia-iOS/Data/Model/ArticleData.xcdatamodeld/ArticleData.xcdatamodel/contents
index 4bc4a28..eee4916 100644
--- 
a/Wikipedia-iOS/Data/Model/ArticleData.xcdatamodeld/ArticleData.xcdatamodel/contents
+++ 
b/Wikipedia-iOS/Data/Model/ArticleData.xcdatamodeld/ArticleData.xcdatamodel/contents
@@ -56,8 +56,9 @@
     <entity name="Section" representedClassName="Section" syncable="YES">
         <attribute name="dateRetrieved" attributeType="Date" indexed="YES" 
syncable="YES"/>
         <attribute name="html" optional="YES" attributeType="String" 
syncable="YES"/>
-        <attribute name="index" optional="YES" attributeType="Integer 16" 
defaultValueString="0" syncable="YES"/>
+        <attribute name="index" optional="YES" attributeType="Integer 16" 
indexed="YES" syncable="YES"/>
         <attribute name="title" optional="YES" attributeType="String" 
syncable="YES"/>
+        <attribute name="tocLevel" optional="YES" attributeType="Integer 16" 
defaultValueString="0" indexed="YES" syncable="YES"/>
         <relationship name="article" maxCount="1" deletionRule="Nullify" 
destinationEntity="Article" inverseName="section" inverseEntity="Article" 
syncable="YES"/>
         <relationship name="thumbnailImage" optional="YES" maxCount="1" 
deletionRule="Nullify" destinationEntity="Image" inverseName="section" 
inverseEntity="Image" syncable="YES"/>
     </entity>
@@ -74,7 +75,7 @@
         <element name="History" positionX="-317" positionY="-105" width="128" 
height="103"/>
         <element name="Image" positionX="-371" positionY="234" width="128" 
height="208"/>
         <element name="Saved" positionX="108" positionY="99" width="128" 
height="73"/>
-        <element name="Section" positionX="-551" positionY="63" width="128" 
height="135"/>
+        <element name="Section" positionX="-551" positionY="63" width="128" 
height="148"/>
         <element name="Site" positionX="79" positionY="204" width="128" 
height="75"/>
     </elements>
 </model>
\ No newline at end of file
diff --git a/Wikipedia-iOS/Data/Model/Section.h 
b/Wikipedia-iOS/Data/Model/Section.h
index 0ecf01c..33077f7 100644
--- a/Wikipedia-iOS/Data/Model/Section.h
+++ b/Wikipedia-iOS/Data/Model/Section.h
@@ -2,7 +2,7 @@
 //  Section.h
 //  Wikipedia-iOS
 //
-//  Created by Monte Hurd on 12/3/13.
+//  Created by Monte Hurd on 12/6/13.
 //  Copyright (c) 2013 Wikimedia Foundation. All rights reserved.
 //
 
@@ -17,6 +17,7 @@
 @property (nonatomic, retain) NSString * html;
 @property (nonatomic, retain) NSNumber * index;
 @property (nonatomic, retain) NSString * title;
+@property (nonatomic, retain) NSNumber * tocLevel;
 @property (nonatomic, retain) Article *article;
 @property (nonatomic, retain) Image *thumbnailImage;
 
diff --git a/Wikipedia-iOS/Data/Model/Section.m 
b/Wikipedia-iOS/Data/Model/Section.m
index 4b2899e..0bb4199 100644
--- a/Wikipedia-iOS/Data/Model/Section.m
+++ b/Wikipedia-iOS/Data/Model/Section.m
@@ -2,7 +2,7 @@
 //  Section.m
 //  Wikipedia-iOS
 //
-//  Created by Monte Hurd on 12/3/13.
+//  Created by Monte Hurd on 12/6/13.
 //  Copyright (c) 2013 Wikimedia Foundation. All rights reserved.
 //
 
@@ -17,6 +17,7 @@
 @dynamic html;
 @dynamic index;
 @dynamic title;
+@dynamic tocLevel;
 @dynamic article;
 @dynamic thumbnailImage;
 
diff --git a/Wikipedia-iOS/View Controllers/WebView/WebViewController.m 
b/Wikipedia-iOS/View Controllers/WebView/WebViewController.m
index c0127fd..4949d28 100644
--- a/Wikipedia-iOS/View Controllers/WebView/WebViewController.m
+++ b/Wikipedia-iOS/View Controllers/WebView/WebViewController.m
@@ -828,24 +828,21 @@
         article.lastScrollLocation = @0.0f;
 
         // Get article sections text (faster joining array elements than 
appending a string)
-        NSDictionary *sections = 
weakOp.jsonRetrieved[@"mobileview"][@"sections"];
-        NSMutableArray *sectionText = [@[] mutableCopy];
-        for (NSDictionary *section in sections) {
-            if ([section valueForKey:@"text"]){
-                [sectionText addObject:section[@"text"]];
+        NSArray *sections = weakOp.jsonRetrieved[@"mobileview"][@"sections"];
+        __block NSDictionary *sectionZeroDict = @{};
+        [sections enumerateObjectsUsingBlock:^(NSDictionary *dict, NSUInteger 
idx, BOOL *stop){
+            if ([dict[@"id"] isEqual: @0]) {
+                sectionZeroDict = dict;
+                *stop = YES;
             }
-        }
-        
-        // Join article sections text
-        NSString *joint = @""; //@"<div 
style=\"background-color:#ffffff;height:55px;\"></div>";
-        NSString *htmlStr = [sectionText componentsJoinedByString:joint];
+        }];
 
         // Add sections for article
         Section *section0 = [NSEntityDescription 
insertNewObjectForEntityForName:@"Section" inManagedObjectContext:dataContext_];
         section0.index = @0;
         section0.title = @"";
         section0.dateRetrieved = [NSDate date];
-        section0.html = htmlStr;
+        section0.html = sectionZeroDict[@"text"];
         article.section = [NSSet setWithObjects:section0, nil];
         
         // Add history for article
@@ -875,7 +872,7 @@
             // Clear out the loading message at the top of page
             [bridge_ sendMessage:@"clear" withPayload:@{}];
             // Add the first section html
-            [bridge_ sendMessage:@"append" withPayload:@{@"html": htmlStr}];
+            [bridge_ sendMessage:@"append" withPayload:@{@"html": 
sectionZeroDict[@"text"]}];
             // Add a loading message beneath the first section so user can see 
more is on the way
             [bridge_ sendMessage: @"append"
                      withPayload: @{@"html": [NSString stringWithFormat:@"<div 
id='loadingMessage'>%@</div>", self.loadingSectionsRemainingMessage]}];
@@ -915,7 +912,7 @@
         NSDictionary *sections = 
weakRemainingSectionsOp.jsonRetrieved[@"mobileview"][@"sections"];
         NSMutableArray *sectionText = [@[] mutableCopy];
         for (NSDictionary *section in sections) {
-            if ([section valueForKey:@"text"]){
+            if (![section[@"id"] isEqual: @0]) {
                 [sectionText addObject:section[@"text"]];
 
                 // Add sections for article
@@ -923,6 +920,7 @@
                 thisSection.index = section[@"id"];
                 thisSection.title = section[@"line"];
                 thisSection.html = section[@"text"];
+                thisSection.tocLevel = section[@"toclevel"];
                 thisSection.dateRetrieved = [NSDate date];
                 [article addSectionObject:thisSection];
             }
diff --git a/Wikipedia-iOSTests/ArticleDataModel.m 
b/Wikipedia-iOSTests/ArticleDataModel.m
index dca8b29..8756b5f 100644
--- a/Wikipedia-iOSTests/ArticleDataModel.m
+++ b/Wikipedia-iOSTests/ArticleDataModel.m
@@ -81,12 +81,14 @@
     section0.index = @0;
     section0.title = @"Potato chip section 0 title";
     section0.html = @"<b>Potato Chips section 0 html!</b>";
+    section0.tocLevel = @1;
     section0.dateRetrieved = [NSDate date];
 
     Section *section1 = [NSEntityDescription 
insertNewObjectForEntityForName:@"Section" inManagedObjectContext:dataContext];
     section1.index = @1;
     section1.title = @"Potato chip section 1 title";
     section1.html = @"<b>Potato Chips section 1 html!</b>";
+    section1.tocLevel = @1;
     section1.dateRetrieved = [NSDate date];
 
     article.section = [NSSet setWithObjects:section0, section1, nil];

-- 
To view, visit https://gerrit.wikimedia.org/r/99774
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8e7df67e863208357f563196e62bb28aae37e239
Gerrit-PatchSet: 1
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Mhurd <mh...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to