Skip to content

Commit

Permalink
Extension safety (#74)
Browse files Browse the repository at this point in the history
* Improve Markymark's way of URL opening by allowing customisation of the url opening behavior.
- Support running Extensions and using extensionContext to open url's
- Support i.e. opening urls in a internal Safari View Controller instead of the open url behavior
  • Loading branch information
jvanzummeren authored Nov 22, 2018
1 parent bf07575 commit 76a00f2
Show file tree
Hide file tree
Showing 19 changed files with 482 additions and 124 deletions.
7 changes: 6 additions & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ end
target 'markymark_Tests' do
inherit! :search_paths
pod 'markymark', :path => '../'
end
end

target 'TodayExtension' do
inherit! :search_paths
pod 'markymark', :path => '../'
end
10 changes: 5 additions & 5 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
PODS:
- markymark (7.1)
- markymark (8.0.0)

DEPENDENCIES:
- markymark (from `../`)

EXTERNAL SOURCES:
markymark:
:path: ../
:path: "../"

SPEC CHECKSUMS:
markymark: 2dbd0f000579b1992d0e6355d5cdd83b097d03f7
markymark: 47a730450bc0c583f877a26ba3d77c3f7f930059

PODFILE CHECKSUM: 702819c9a9352a2969fd49865aabe1f21e7c3404
PODFILE CHECKSUM: b777cb29f5ff9935c02362ec42fa8a45e73dcf8f

COCOAPODS: 1.4.0
COCOAPODS: 1.5.3
46 changes: 46 additions & 0 deletions Example/TodayExtension/Base.lproj/MainInterface.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Today View Controller-->
<scene sceneID="cwh-vc-ff4">
<objects>
<viewController id="M4Y-Lb-cyx" customClass="TodayViewController" customModule="TodayExtension" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN">
<rect key="frame" x="0.0" y="0.0" width="320" height="37"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rR0-pe-hmH" customClass="MarkDownTextView" customModule="markymark">
<rect key="frame" x="0.0" y="0.0" width="320" height="37"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
<constraints>
<constraint firstItem="ssy-KU-ocm" firstAttribute="bottom" secondItem="rR0-pe-hmH" secondAttribute="bottom" id="Sgy-ET-v8k"/>
<constraint firstItem="rR0-pe-hmH" firstAttribute="top" secondItem="ssy-KU-ocm" secondAttribute="top" id="Vos-mV-XS2"/>
<constraint firstItem="rR0-pe-hmH" firstAttribute="leading" secondItem="ssy-KU-ocm" secondAttribute="leading" id="cx4-WT-whY"/>
<constraint firstItem="ssy-KU-ocm" firstAttribute="trailing" secondItem="rR0-pe-hmH" secondAttribute="trailing" id="hLA-Yo-WJ4"/>
</constraints>
<viewLayoutGuide key="safeArea" id="ssy-KU-ocm"/>
</view>
<extendedEdge key="edgesForExtendedLayout"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="37"/>
<connections>
<outlet property="markDownTextView" destination="rR0-pe-hmH" id="EZ1-yL-blg"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="137.59999999999999" y="129.98500749625188"/>
</scene>
</scenes>
</document>
31 changes: 31 additions & 0 deletions Example/TodayExtension/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>TodayExtension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widget-extension</string>
</dict>
</dict>
</plist>
28 changes: 28 additions & 0 deletions Example/TodayExtension/TodayViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// TodayViewController.swift
// TodayExtension
//
// Created by Jim van Zummeren on 21/11/2018.
// Copyright © 2018 CocoaPods. All rights reserved.
//

import UIKit
import NotificationCenter
import markymark

class TodayViewController: UIViewController, NCWidgetProviding {

@IBOutlet var markDownTextView: MarkDownTextView?

override func viewDidLoad() {
super.viewDidLoad()
markDownTextView?.text = """
# Some header
A paragraph with a **link** to [Google](https://www.google.com)
"""

markDownTextView?.urlOpener = ExtensionContextURLOpener(extensionContext: self.extensionContext)
}
}

Loading

0 comments on commit 76a00f2

Please sign in to comment.