Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving plists with HTML and Markdown support #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Classes/Core/HSKBItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


#import <Foundation/Foundation.h>

#import <MMMarkdown/MMMarkdown.h>

typedef NS_OPTIONS(NSUInteger, HSKBItemType) {
HSKBItemTypeArticle = 0,
Expand Down Expand Up @@ -56,6 +56,7 @@ typedef NS_OPTIONS(NSUInteger, HSKBItemType) {
*/
- (id)initAsArticle:(NSString*)title textContent:(NSString*)content kbID:(NSString*)kbID;
- (id)initAsArticle:(NSString*)title htmlContent:(NSString*)content baseUrl:(NSString*)baseUrl kbID:(NSString*)kbID;
- (id)initAsArticle:(NSString*)title markdownContent:(NSString*)content baseUrl:(NSString*)baseUrl kbID:(NSString*)kbID;

/**
Kb will be prepared with given title, content and id, its type will be set as Section.
Expand Down
12 changes: 12 additions & 0 deletions Classes/Core/HSKBItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ - (id)initAsArticle:(NSString*)title htmlContent:(NSString*)content baseUrl:(NSS
return self;
}

- (id)initAsArticle:(NSString*)title markdownContent:(NSString*)content baseUrl:(NSString*)baseUrl kbID:(NSString*)kbID
{
if(self = [super init]) {
self.title = title;
self.htmlContent = [MMMarkdown HTMLStringWithMarkdown:content extensions:MMMarkdownExtensionsGitHubFlavored error:NULL];
self.baseUrl = baseUrl;
self.itemType = HSKBItemTypeArticle;
self.kb_id = kbID;
}
return self;
}

- (id)initAsSection:(NSString*)title kbID:(NSString*)kbID{
if(self = [super init]) {
self.title = title;
Expand Down
9 changes: 8 additions & 1 deletion Classes/Core/HSKBSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ - (void)readKBArticleFromLocalPList:(void (^)(void))success failure:(void (^)(NS


for (NSDictionary *object in articleDict) {
HSKBItem* kb = [[HSKBItem alloc] initAsArticle:[object objectForKey:@"title"] textContent:[object objectForKey:@"content"] kbID:nil];
HSKBItem* kb = [HSKBItem alloc];
if ([object objectForKey:@"html"] != nil) {
kb = [[HSKBItem alloc] initAsArticle:[object objectForKey:@"title"] htmlContent:[object objectForKey:@"html"] baseUrl:@"" kbID:nil];
} else if ([object objectForKey:@"markdown"] != nil) {
kb = [[HSKBItem alloc] initAsArticle:[object objectForKey:@"title"] markdownContent:[object objectForKey:@"markdown"] baseUrl:@"" kbID:nil];
} else {
kb = [[HSKBItem alloc] initAsArticle:[object objectForKey:@"title"] textContent:[object objectForKey:@"content"] kbID:nil];
}
[articles addObject:kb];
}

Expand Down
1 change: 1 addition & 0 deletions HelpStack.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/happyfoxinc/helpstack.git", :tag => "1.1.1", :submodules => true }
s.resources = ['Resources/*.png','Resources/*.storyboard']
s.dependency 'AFNetworking', '~> 2.0'
s.dependency 'MMMarkdown', '~> 0.5'
s.frameworks = 'UIKit', 'CoreGraphics'
s.requires_arc = true

Expand Down