heluxsh / URLEmbeddedView

URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URLEmbeddedView

Platform Language Version License

Features

  • Simple interface for fetching Open Graph Data
  • Be able to display Open Graph Data
  • Automatically caching Open Graph Data
  • Automatically caching Open Graph Image
  • Tap handleable
  • Clearable image cache
  • Clearable data cache
  • Configurable expire date for cache

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

let embeddedView = URLEmbeddedView()
embeddedView.loadURL(urlString)

Layouts

  • Default

  • No Image

  • No response

Customization

embeddedView.textProvider[.Title].font = .boldSystemFontOfSize(18)
embeddedView.textProvider[.Title].fontColor = .lightGrayColor()
embeddedView.textProvider[.Title].numberOfLines = 2
//You can use ".Title", ".Description", ".Domain" and ".NoDataTitle"

Data and Image Cache

You can get Open Graph Data with OGDataProvider.

OGDataProvider.sharedInstance.fetchOGData(urlString: String, completion: ((OGData, NSError?) -> Void)? = nil) -> NSURLSessionDataTask?
OGDataProvider.sharedInstance.deleteOGData(urlString: String, completion: ((NSError?) -> Void)? = nil)
OGDataProvider.sharedInstance.deleteOGData(ogData: OGData, completion: ((NSError?) -> Void)? = nil)

You can configure time interval for next updating of OGData. Default is 10 days.

OGDataProvider.sharedInstance.updateInterval = 10.days

You can get UIImage with OGImageProvider.

OGImageProvider.sharedInstance.loadImage(urlString: String, completion: ((UIImage?, NSError?) -> Void)? = nil) -> NSURLSessionDataTask?
OGImageProvider.sharedInstance.clearMemoryCache()
OGImageProvider.sharedInstance.clearAllCache()

OGData Properties

@NSManaged public var createDate: NSDate
@NSManaged public var imageUrl: String
@NSManaged public var pageDescription: String
@NSManaged public var pageTitle: String
@NSManaged public var pageType: String
@NSManaged public var siteName: String
@NSManaged public var sourceUrl: String
@NSManaged public var updateDate: NSDate
@NSManaged public var url: String

Installation

URLEmbeddedView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "URLEmbeddedView"

Use in Objective-C

#import <URLEmbeddedView/URLEmbeddedView-Swift.h>

- (void)viewDidLoad {
    [super viewDidLoad];
    URLEmbeddedView *embeddedView = [[URLEmbeddedView alloc] init];
    [self.view addSubView:embeddedView];
    [embeddedView loadURL:@"https://github.com/" completion:nil];
}

- (void)setUpdateInterval {
  [OGDataProvider sharedInstance].updateInterval = [NSNumber days:10];
}

Here is Objective-C sample.

Special Thanks

Requirements

Other

Android version is here. (Created by @kaelaela)

Author

Taiki Suzuki, s1180183@gmail.com

License

URLEmbeddedView is available under the MIT license. See the LICENSE file for more info.

About

URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.

License:MIT License


Languages

Language:Swift 95.4%Language:Shell 2.9%Language:Objective-C 1.1%Language:Ruby 0.6%