working so far

This commit is contained in:
relikd
2018-07-28 11:27:40 +02:00
parent db3ef5a22a
commit 1de26a7a88
8 changed files with 92 additions and 30 deletions

View File

@@ -12,12 +12,12 @@
544FBD4721064B2F008A260C /* getFeed.py in Resources */ = {isa = PBXBuildFile; fileRef = 544FBD4621064B2F008A260C /* getFeed.py */; };
544FBD4921064DF0008A260C /* feedparser521.py in Resources */ = {isa = PBXBuildFile; fileRef = 544FBD4821064DF0008A260C /* feedparser521.py */; };
54ACC28121061B3B0020715F /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28021061B3B0020715F /* AppDelegate.m */; };
54ACC28421061B3B0020715F /* baRSS.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28221061B3B0020715F /* baRSS.xcdatamodeld */; };
54ACC28621061B3C0020715F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 54ACC28521061B3C0020715F /* Assets.xcassets */; };
54ACC28921061B3C0020715F /* Main.xib in Resources */ = {isa = PBXBuildFile; fileRef = 54ACC28721061B3C0020715F /* Main.xib */; };
54ACC28C21061B3C0020715F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28B21061B3C0020715F /* main.m */; };
54ACC29521061E270020715F /* NewsController.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29421061E270020715F /* NewsController.m */; };
54ACC29821061FBA0020715F /* Preferences.m in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC29721061FBA0020715F /* Preferences.m */; };
54F39C2E210BE1F700AEE730 /* DBv1.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -29,7 +29,7 @@
54ACC27C21061B3B0020715F /* baRSS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = baRSS.app; sourceTree = BUILT_PRODUCTS_DIR; };
54ACC27F21061B3B0020715F /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
54ACC28021061B3B0020715F /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
54ACC28321061B3B0020715F /* baRRS.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = baRRS.xcdatamodel; sourceTree = "<group>"; };
54ACC28321061B3B0020715F /* DBv1.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = DBv1.xcdatamodel; sourceTree = "<group>"; };
54ACC28521061B3C0020715F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
54ACC28821061B3C0020715F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Main.xib; sourceTree = "<group>"; };
54ACC28A21061B3C0020715F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -104,7 +104,7 @@
54ACC28A21061B3C0020715F /* Info.plist */,
54ACC28B21061B3C0020715F /* main.m */,
54ACC28D21061B3C0020715F /* baRSS.entitlements */,
54ACC28221061B3B0020715F /* baRSS.xcdatamodeld */,
54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */,
);
path = baRSS;
sourceTree = "<group>";
@@ -142,6 +142,9 @@
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 0940;
SystemCapabilities = {
com.apple.ApplicationGroups.Mac = {
enabled = 0;
};
com.apple.Sandbox = {
enabled = 1;
};
@@ -186,8 +189,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
54F39C2E210BE1F700AEE730 /* DBv1.xcdatamodeld in Sources */,
54ACC29521061E270020715F /* NewsController.m in Sources */,
54ACC28421061B3B0020715F /* baRSS.xcdatamodeld in Sources */,
54ACC28C21061B3C0020715F /* main.m in Sources */,
54ACC28121061B3B0020715F /* AppDelegate.m in Sources */,
54ACC29821061FBA0020715F /* Preferences.m in Sources */,
@@ -413,13 +416,13 @@
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
54ACC28221061B3B0020715F /* baRSS.xcdatamodeld */ = {
54ACC28221061B3B0020715F /* DBv1.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
54ACC28321061B3B0020715F /* baRRS.xcdatamodel */,
54ACC28321061B3B0020715F /* DBv1.xcdatamodel */,
);
currentVersion = 54ACC28321061B3B0020715F /* baRRS.xcdatamodel */;
path = baRSS.xcdatamodeld;
currentVersion = 54ACC28321061B3B0020715F /* DBv1.xcdatamodel */;
path = DBv1.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};

View File

@@ -41,9 +41,6 @@
printf("will init\n");
[PyHandler prepare];
printf("done\n");
NSDictionary * obj = [PyHandler getFeed:@"https://feeds.feedburner.com/simpledesktops" withEtag:nil andModified:nil];
NSLog(@"obj = %@", obj);
[self quitClicked:nil];
}
@@ -60,7 +57,7 @@
// The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
@synchronized (self) {
if (_persistentContainer == nil) {
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"baRSS"];
_persistentContainer = [[NSPersistentContainer alloc] initWithName:@"DBv1"];
[_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
if (error != nil) {
// Replace this implementation with code to handle the error appropriately.

View File

@@ -21,7 +21,6 @@
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<customObject id="he0-Eb-PDA" customClass="NewsController">
<connections>
<outlet property="managedObjectContext" destination="ESi-qE-Dj9" id="Nnv-1A-WLk"/>
<outlet property="openUnreadItem" destination="Qqw-Xj-oA5" id="8df-is-Qop"/>
<outlet property="pauseItem" destination="D7r-Vb-9eO" id="o7e-jD-3Yj"/>
<outlet property="updateAllItem" destination="wgp-fa-8Wj" id="edP-bQ-bIM"/>
@@ -447,7 +446,6 @@
</subviews>
<point key="canvasLocation" x="350" y="903.5"/>
</customView>
<managedObjectContext id="ESi-qE-Dj9"/>
<userDefaultsController representsSharedInstance="YES" id="K8S-BW-Na6"/>
</objects>
<resources>

View File

@@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>baRRS.xcdatamodel</string>
<string>DBv1.xcdatamodel</string>
</dict>
</plist>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14135" systemVersion="17G65" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="v1">
<entity name="Feed" representedClassName="Feed" syncable="YES" codeGenerationType="class">
<attribute name="author" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="date" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="etag" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="icon" optional="YES" attributeType="Binary" customClassName="NSImage" syncable="YES"/>
<attribute name="link" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="modified" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="published" optional="YES" attributeType="Transformable" customClassName="NSArray" syncable="YES"/>
<attribute name="subtitle" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="items" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="FeedItem" inverseName="feed" inverseEntity="FeedItem" syncable="YES"/>
</entity>
<entity name="FeedItem" representedClassName="FeedItem" syncable="YES" codeGenerationType="class">
<attribute name="author" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="link" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="published" optional="YES" attributeType="Transformable" customClassName="NSArray" syncable="YES"/>
<attribute name="subtitle" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="summary" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="feed" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Feed" inverseName="items" inverseEntity="Feed" syncable="YES"/>
<relationship name="tags" optional="YES" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="FeedTag" inverseName="feedItem" inverseEntity="FeedTag" syncable="YES"/>
</entity>
<entity name="FeedTag" representedClassName="FeedTag" syncable="YES" codeGenerationType="class">
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="feedItem" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="FeedItem" inverseName="tags" inverseEntity="FeedItem" syncable="YES"/>
</entity>
<elements>
<element name="FeedItem" positionX="-36" positionY="-36" width="128" height="165"/>
<element name="FeedTag" positionX="0" positionY="54" width="128" height="75"/>
<element name="Feed" positionX="27" positionY="9" width="128" height="195"/>
</elements>
</model>

View File

@@ -21,33 +21,66 @@
// SOFTWARE.
#import "NewsController.h"
#import "PyHandler.h"
#import "AppDelegate.h"
#import "DBv1+CoreDataModel.h"
@interface NewsController ()
@property (weak) IBOutlet NSMenuItem *pauseItem;
@property (weak) IBOutlet NSMenuItem *updateAllItem;
@property (weak) IBOutlet NSMenuItem *openUnreadItem;
@property (weak) IBOutlet NSManagedObjectContext *managedObjectContext;
@property (retain) NSManagedObjectContext *managedContext;
@end
@implementation NewsController
- (void)viewDidLoad {
[super viewDidLoad];
// Do view setup here.
- (void)awakeFromNib {
[super awakeFromNib];
self.managedContext = [((AppDelegate*)[NSApp delegate]) persistentContainer].viewContext;
}
- (IBAction)pauseUpdates:(NSMenuItem *)sender {
NSLog(@"pause");
NSLog(@"%@", self.managedObjectContext);
NSLog(@"%@", self.managedContext);
}
- (IBAction)updateAllFeeds:(NSMenuItem *)sender {
NSLog(@"update all");
NSDictionary * obj = [PyHandler getFeed:@"https://feeds.feedburner.com/simpledesktops" withEtag:nil andModified:nil];
NSLog(@"obj = %@", obj);
// TODO: check status code
/*
Feed *a = [[Feed alloc] initWithEntity:Feed.entity insertIntoManagedObjectContext:self.managedContext];
a.title = obj[@"feed"][@"title"];
a.subtitle = obj[@"feed"][@"subtitle"];
a.author = obj[@"feed"][@"author"];
a.link = obj[@"feed"][@"link"];
a.published = obj[@"feed"][@"published"];
a.icon = obj[@"feed"][@"icon"];
a.etag = obj[@"header"][@"etag"];
a.date = obj[@"header"][@"date"];
a.modified = obj[@"header"][@"modified"];
for (NSDictionary *entry in obj[@"entries"]) {
FeedItem *b = [[FeedItem alloc] initWithEntity:FeedItem.entity insertIntoManagedObjectContext:self.managedContext];
b.title = entry[@"title"];
b.subtitle = entry[@"subtitle"];
b.author = entry[@"author"];
b.link = entry[@"link"];
b.published = entry[@"published"];
b.summary = entry[@"summary"];
for (NSString *tag in entry[@"tags"]) {
FeedTag *c = [[FeedTag alloc] initWithEntity:FeedTag.entity insertIntoManagedObjectContext:self.managedContext];
c.name = tag;
[b addTagsObject:c];
}
[a addItemsObject:b];
}*/
}
- (IBAction)openAllUnread:(NSMenuItem *)sender {
NSLog(@"all unread");
}
- (IBAction)addFeed:(NSButton *)sender {
NSLog(@"add feed");
NSLog(@"%@", self.managedObjectContext);
NSLog(@"%@", self.managedContext);
}
- (IBAction)removeFeed:(NSButton *)sender {
NSLog(@"del feed");

View File

@@ -31,11 +31,12 @@
@end
@implementation Preferences
- (void)windowDidLoad {
[super windowDidLoad];
NSLog(@"%@", @"hi");
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
- (void)awakeFromNib {
[super awakeFromNib];
if (self.window.contentView.subviews.count == 0) {
self.window.contentView = self.viewGeneral;
self.toolbar.selectedItemIdentifier = self.toolbar.items.firstObject.itemIdentifier;
}
}
- (IBAction)clickGeneral:(NSToolbarItem *)sender {

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<elements/>
</model>