From 62eaefce75a11e8cfebf2edf19df6f8bab4e13d7 Mon Sep 17 00:00:00 2001 From: Leonardo Cardoso Date: Wed, 2 Jan 2019 11:48:08 +0100 Subject: [PATCH] Bump to version 3.0.0 --- CHANGELOG.md | 14 ++++---- .../Controllers/ViewController.swift | 35 +++++++++++++------ Example/SwiftLinkPreviewExample/Info.plist | 2 +- README.md | 8 ++--- Sources/Response.swift | 3 ++ SwiftLinkPreviewTests/Info-macOS.plist | 2 +- SwiftLinkPreviewTests/Info-tvOS.plist | 2 +- SwiftLinkPreviewTests/Info.plist | 2 +- 8 files changed, 42 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ce1776..70836ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ # Change Log #### 3.x Releases -- `3.0.0` +- `3.0.x` Releases - [3.0.0](#300) #### 2.x Releases -- `2.3.x` Releases - [2.3.0](#230) | [2.3.1](#231) | [2.3.2](#232) +- `2.3.x` Releases - [2.3.0](#230) | [2.3.1](#231) - `2.2.x` Releases - [2.2.0](#220) - `2.1.x` Releases - [2.1.0](#210) - `2.0.x` Releases - [2.0.0](#200) | [2.0.1](#201) | [2.0.2](#202) | [2.0.3](#203) | [2.0.4](#204) | [2.0.5](#205) | [2.0.6](#206) | [2.0.7](#207) @@ -18,20 +18,20 @@ --- -## 2.3.2(https://github.com/LeonardoCardoso/Swift-Link-Preview/releases/tag/2.3.2) -Released on 2018-10-09. +## [3.0.0](https://github.com/LeonardoCardoso/Swift-Link-Preview/releases/tag/3.0.0) +Released on 2019-01-02. -#### Changed +#### Added - Added isVideo() check - Added by [Onur Genes](https://github.com/onurgenes) -## 3.0.0 #### Changed - Response is now a swift `struct` instead of a `Dictionary` - Moving to Swift 4.2 + - Changed by [Giuseppe Travasoni](https://github.com/neobeppe) -## 2.3.1(https://github.com/LeonardoCardoso/Swift-Link-Preview/releases/tag/2.3.1) +## [2.3.1](https://github.com/LeonardoCardoso/Swift-Link-Preview/releases/tag/2.3.1) Released on 2018-09-23. #### Changed diff --git a/Example/SwiftLinkPreviewExample/Controllers/ViewController.swift b/Example/SwiftLinkPreviewExample/Controllers/ViewController.swift index 97045a3..80a0f17 100644 --- a/Example/SwiftLinkPreviewExample/Controllers/ViewController.swift +++ b/Example/SwiftLinkPreviewExample/Controllers/ViewController.swift @@ -61,7 +61,7 @@ class ViewController: UIViewController { "Well, it's a gif! https://goo.gl/jKCPgp" ] - private var result = SwiftLinkPreview.Response() + private var result = Response() private let placeholderImages = [ImageSource(image: UIImage(named: "Placeholder")!)] private let slp = SwiftLinkPreview(cache: InMemoryCache()) @@ -127,7 +127,7 @@ class ViewController: UIViewController { private func setData() { - if let value: [String] = self.result[.images] as? [String] { + if let value = self.result.images { if !value.isEmpty { @@ -146,17 +146,17 @@ class ViewController: UIViewController { } else { - self.setImage(image: self.result[.image] as? String) + self.setImage(image: self.result.image) } } else { - self.setImage(image: self.result[.image] as? String) + self.setImage(image: self.result.image) } - if let value: String = self.result[.title] as? String { + if let value: String = self.result.title { self.previewTitle?.text = value.isEmpty ? "No title" : value @@ -166,13 +166,13 @@ class ViewController: UIViewController { } - if let value: String = self.result[.canonicalUrl] as? String { + if let value: String = self.result.canonicalUrl { self.previewCanonicalUrl?.text = value } - if let value: String = self.result[.description] as? String { + if let value: String = self.result.description { self.previewDescription?.text = value.isEmpty ? "No description" : value @@ -182,7 +182,7 @@ class ViewController: UIViewController { } - if let value: String = self.result[.icon] as? String, let url = URL(string: value) { + if let value: String = self.result.icon, let url = URL(string: value) { self.favicon?.af_setImage(withURL: url) } @@ -256,6 +256,18 @@ class ViewController: UIViewController { } @IBAction func submitAction(_ sender: AnyObject) { + + func printResult(_ result: Response) { + print("url: ", result.url ?? "no url") + print("finalUrl: ", result.finalUrl ?? "no finalUrl") + print("canonicalUrl: ", result.canonicalUrl ?? "no canonicalUrl") + print("title: ", result.title ?? "no title") + print("images: ", result.images ?? "no images") + print("image: ", result.image ?? "no image") + print("video: ", result.video ?? "no video") + print("icon: ", result.icon ?? "no icon") + print("description: ", result.description ?? "no description") + } guard textField?.text?.isEmpty == false else { @@ -274,14 +286,15 @@ class ViewController: UIViewController { self.result = cached self.setData() - result.forEach { print("\($0):", $1) } + printResult(result) } else { self.slp.preview( textFieldText, onSuccess: { result in - result.forEach { print("\($0):", $1) } + printResult(result) + self.result = result self.setData() @@ -301,7 +314,7 @@ class ViewController: UIViewController { @IBAction func openWithAction(_ sender: UIButton) { - if let url = self.result[.finalUrl] as? URL { + if let url = self.result.finalUrl { UIApplication.shared.open(url, options: [:], completionHandler: nil) diff --git a/Example/SwiftLinkPreviewExample/Info.plist b/Example/SwiftLinkPreviewExample/Info.plist index 8e8d51a..37b04c5 100644 --- a/Example/SwiftLinkPreviewExample/Info.plist +++ b/Example/SwiftLinkPreviewExample/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 2.3.1 + 3.0.0 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/README.md b/README.md index 6af0cbe..917cb47 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > It makes a preview from an URL, grabbing all the information such as title, relevant texts and images. [![Platform](https://img.shields.io/badge/platform-iOS%20|%20macOS%20|%20watchOS%20|%20tvOS-orange.svg)](https://github.com/LeonardoCardoso/SwiftLinkPreview#requirements-and-details) -[![CocoaPods](https://img.shields.io/badge/pod-v2.3.1-red.svg)](https://github.com/LeonardoCardoso/SwiftLinkPreview#cocoapods) +[![CocoaPods](https://img.shields.io/badge/pod-v3.0.0-red.svg)](https://github.com/LeonardoCardoso/SwiftLinkPreview#cocoapods) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/LeonardoCardoso/SwiftLinkPreview#carthage) [![Swift Package Manager](https://img.shields.io/badge/SPM-compatible-orange.svg)](https://github.com/LeonardoCardoso/SwiftLinkPreview#swift-package-manager) [![Build Status](https://travis-ci.org/LeonardoCardoso/SwiftLinkPreview.svg?branch=master)](https://travis-ci.org/LeonardoCardoso/SwiftLinkPreview) @@ -59,7 +59,7 @@ To use **SwiftLinkPreview** as a pod package just add the following in your **Po target 'Your Target Name' do use_frameworks! // ... - pod 'SwiftLinkPreview', '~> 2.3.1' + pod 'SwiftLinkPreview', '~> 3.0.0' // ... end ``` @@ -70,7 +70,7 @@ To use **SwiftLinkPreview** as a Carthage module package just add the following ```ruby // ... - github "LeonardoCardoso/SwiftLinkPreview" ~> 2.3.1 + github "LeonardoCardoso/SwiftLinkPreview" ~> 3.0.0 // ... ``` @@ -85,7 +85,7 @@ let package = Package( name: "Your Target Name", dependencies: [ // ... - .Package(url: "https://github.com/LeonardoCardoso/SwiftLinkPreview.git", "2.3.1") + .Package(url: "https://github.com/LeonardoCardoso/SwiftLinkPreview.git", "3.0.0") // ... ] ) diff --git a/Sources/Response.swift b/Sources/Response.swift index ddc8906..658d420 100644 --- a/Sources/Response.swift +++ b/Sources/Response.swift @@ -19,4 +19,7 @@ public struct Response { public internal(set) var image: String? public internal(set) var icon: String? public internal(set) var video: String? + + public init() { } + } diff --git a/SwiftLinkPreviewTests/Info-macOS.plist b/SwiftLinkPreviewTests/Info-macOS.plist index 3dcd1f0..b75bb84 100644 --- a/SwiftLinkPreviewTests/Info-macOS.plist +++ b/SwiftLinkPreviewTests/Info-macOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 2.3.1 + 3.0.0 CFBundleSignature ???? CFBundleVersion diff --git a/SwiftLinkPreviewTests/Info-tvOS.plist b/SwiftLinkPreviewTests/Info-tvOS.plist index 3dcd1f0..b75bb84 100644 --- a/SwiftLinkPreviewTests/Info-tvOS.plist +++ b/SwiftLinkPreviewTests/Info-tvOS.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 2.3.1 + 3.0.0 CFBundleSignature ???? CFBundleVersion diff --git a/SwiftLinkPreviewTests/Info.plist b/SwiftLinkPreviewTests/Info.plist index 3dcd1f0..b75bb84 100644 --- a/SwiftLinkPreviewTests/Info.plist +++ b/SwiftLinkPreviewTests/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 2.3.1 + 3.0.0 CFBundleSignature ???? CFBundleVersion