mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Port RSHTMLTag and RSOMLFeedSpecifier to Swift.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// RSHTMLTag.h
|
||||
// RSParser
|
||||
//
|
||||
// Created by Brent Simmons on 11/26/17.
|
||||
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
@import Foundation;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString *RSHTMLTagNameLink; // @"link"
|
||||
extern NSString *RSHTMLTagNameMeta; // @"meta"
|
||||
|
||||
typedef NS_ENUM(NSInteger, RSHTMLTagType) {
|
||||
RSHTMLTagTypeLink,
|
||||
RSHTMLTagTypeMeta
|
||||
};
|
||||
|
||||
@interface RSHTMLTag : NSObject
|
||||
|
||||
- (instancetype)initWithType:(RSHTMLTagType)type attributes:(NSDictionary *)attributes;
|
||||
|
||||
+ (RSHTMLTag *)linkTagWithAttributes:(NSDictionary *)attributes;
|
||||
+ (RSHTMLTag *)metaTagWithAttributes:(NSDictionary *)attributes;
|
||||
|
||||
@property (nonatomic, readonly) RSHTMLTagType type;
|
||||
@property (nonatomic, readonly) NSDictionary *attributes;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,43 +0,0 @@
|
||||
//
|
||||
// RSHTMLTag.m
|
||||
// RSParser
|
||||
//
|
||||
// Created by Brent Simmons on 11/26/17.
|
||||
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RSHTMLTag.h"
|
||||
|
||||
NSString *RSHTMLTagNameLink = @"link";
|
||||
NSString *RSHTMLTagNameMeta = @"meta";
|
||||
|
||||
@implementation RSHTMLTag
|
||||
|
||||
- (instancetype)initWithType:(RSHTMLTagType)type attributes:(NSDictionary *)attributes {
|
||||
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_type = type;
|
||||
_attributes = attributes;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (RSHTMLTag *)linkTagWithAttributes:(NSDictionary *)attributes {
|
||||
|
||||
return [[self alloc] initWithType:RSHTMLTagTypeLink attributes:attributes];
|
||||
}
|
||||
|
||||
+ (RSHTMLTag *)metaTagWithAttributes:(NSDictionary *)attributes {
|
||||
|
||||
return [[self alloc] initWithType:RSHTMLTagTypeMeta attributes:attributes];
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"<%@: %p> type: %ld attributes: %@", NSStringFromClass([self class]), self, (long)self.type, self.attributes];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// RSOPMLFeedSpecifier.h
|
||||
// RSParser
|
||||
//
|
||||
// Created by Brent Simmons on 2/28/16.
|
||||
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
@import Foundation;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface RSOPMLFeedSpecifier : NSObject
|
||||
|
||||
- (instancetype)initWithTitle:(NSString * _Nullable)title feedDescription:(NSString * _Nullable)feedDescription homePageURL:(NSString * _Nullable)homePageURL feedURL:(NSString *)feedURL;
|
||||
|
||||
@property (nonatomic, nullable, readonly) NSString *title;
|
||||
@property (nonatomic, nullable, readonly) NSString *feedDescription;
|
||||
@property (nonatomic, nullable, readonly) NSString *homePageURL;
|
||||
@property (nonatomic, readonly) NSString *feedURL;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,51 +0,0 @@
|
||||
//
|
||||
// RSOPMLFeedSpecifier.m
|
||||
// RSParser
|
||||
//
|
||||
// Created by Brent Simmons on 2/28/16.
|
||||
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RSOPMLFeedSpecifier.h"
|
||||
#import "RSParserInternal.h"
|
||||
|
||||
|
||||
|
||||
@implementation RSOPMLFeedSpecifier
|
||||
|
||||
- (instancetype)initWithTitle:(NSString *)title feedDescription:(NSString *)feedDescription homePageURL:(NSString *)homePageURL feedURL:(NSString *)feedURL {
|
||||
|
||||
NSParameterAssert(!RSParserStringIsEmpty(feedURL));
|
||||
|
||||
self = [super init];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (RSParserStringIsEmpty(title)) {
|
||||
_title = nil;
|
||||
}
|
||||
else {
|
||||
_title = title;
|
||||
}
|
||||
|
||||
if (RSParserStringIsEmpty(feedDescription)) {
|
||||
_feedDescription = nil;
|
||||
}
|
||||
else {
|
||||
_feedDescription = feedDescription;
|
||||
}
|
||||
|
||||
if (RSParserStringIsEmpty(homePageURL)) {
|
||||
_homePageURL = nil;
|
||||
}
|
||||
else {
|
||||
_homePageURL = homePageURL;
|
||||
}
|
||||
|
||||
_feedURL = feedURL;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user