Latest 0.9.0
Homepage https://github.com/marty-suzuki/URLEmbeddedView
License MIT
Platforms ios 8.0, requires ARC
Dependencies MisterFusion, Kanna
Frameworks UIKit, CoreData, CoreGraphics
Authors

Platform
Language
Version
License
Carthage compatible

URLEmbeddedView URLEmbeddedView

Features

  • [x] Simple interface for fetching Open Graph Data
  • [x] Be able to display Open Graph Data
  • [x] Automatically caching Open Graph Data
  • [x] Automatically caching Open Graph Image
  • [x] Tap handleable
  • [x] Clearable image cache
  • [x] Clearable data cache
  • [x] Support Swift2.3
  • [x] Support Swift3
  • [ ] 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

URLEmbeddedView

  • No Image

URLEmbeddedView

  • No response

URLEmbeddedView

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.shared.fetchOGData(urlString: String, completion: ((OGData, Error?) -> Void)? = nil) -> NSURLSessionDataTask?
OGDataProvider.shared.deleteOGData(urlString: String, completion: ((Error?) -> Void)? = nil)
OGDataProvider.shared.deleteOGData(ogData: OGData, completion: ((Error?) -> Void)? = nil)

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

OGDataProvider.shared.updateInterval = 10.days

You can get UIImage with OGImageProvider.

OGImageProvider.shared.loadImage(urlString: String, completion: ((UIImage?, Error?) -> Void)? = nil) -> NSURLSessionDataTask?
OGImageProvider.shared.clearMemoryCache()
OGImageProvider.shared.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:

# Uncomment the next line to define a global platform for your project
# platform :ios, '8.0'

target 'Your Project Name' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for URLEmbeddedViewSample
  pod "URLEmbeddedView"
end

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

  • Xcode 8.0 or greater
  • iOS 8.0 or greater
  • MisterFusion – Swift DSL for AutoLayout
  • Kanna(鉋)
  • UIKit
  • CoreData
  • CoreGraphics

Other

Author

Taiki Suzuki, [email protected]

License

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

Latest podspec

{
    "name": "URLEmbeddedView",
    "version": "0.9.0",
    "summary": "URLEmbeddedView is a view that automatically cache the Open Graph Protocol.",
    "homepage": "https://github.com/marty-suzuki/URLEmbeddedView",
    "license": "MIT",
    "authors": {
        "Taiki Suzuki": "[email protected]"
    },
    "source": {
        "git": "https://github.com/marty-suzuki/URLEmbeddedView.git",
        "tag": "0.9.0"
    },
    "social_media_url": "https://twitter.com/marty_suzuki",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "URLEmbeddedView/*.{swift}",
    "resources": "Resources/*.{pdf,xcdatamodeld}",
    "frameworks": [
        "UIKit",
        "CoreData",
        "CoreGraphics"
    ],
    "dependencies": {
        "MisterFusion": [
            "~> 2.2.1"
        ],
        "Kanna": [
            "~> 2.1.1"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This