Coder Social home page Coder Social logo

alexviquez / urlembeddedview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marty-suzuki/urlembeddedview

0.0 2.0 0.0 7.43 MB

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

License: MIT License

Ruby 1.11% Swift 89.88% Objective-C 3.43% Shell 5.59%

urlembeddedview's Introduction

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
  • Support Swift2.3
  • 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

  • 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.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

Other

Author

Taiki Suzuki, [email protected]

License

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

urlembeddedview's People

Contributors

marty-suzuki avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.