We currently use UIWebView for rendering posts and PMs. UIWebView has finally been deprecated in the iOS 12 SDK, so it's time to move to WKWebView.
Some stuff got moved over back when iOS 8 came out, but WKWebView was missing a few key features that meant our heaviest web view usage was stuck. The last feature to fall was custom url scheme support (we use URLProtocol which works in UIWebView), which we use in a few different ways and wasn't worth giving up. Happily, custom URL scheme handlers arrived in WKWebView in iOS 11, so we can give the full experience to everyone on iOS 11 and above (and for now, below, if we use some private API).
There's a lot of common pieces for Awful when rendering content in web views, so let's extract those into a RenderView. All relevant JavaScript can go into RenderView.js instead of having a bunch of .js files strewn about. Speaking of, zepto.js isn't giving us enough to bother including it, so let's just use what the browser gives us. Let's also aim to move document manipulation code from JavaScript into Swift. Finally, we won't need WebViewJavascriptBridge anymore because its functionality is built in to WKWebView.
This is a big task, so let's approach it incrementally. RenderView can start as the rendering facility for the new feature of showing announcements, then we can move screens of increasing complexity over to RenderView as time goes on.
[x] Render announcements using RenderView (thin wrapper around WKWebView).
[x] Render profiles using WKWebView.
[x] Render profiles using RenderView.
[x] Render acknowledgements using WKWebView.
[x] Move announcement template over to MustacheRepository.swift.
[x] Get non-http custom URL protocols working with RenderView.
[x] Render private messages using RenderView.
[x] Render post previews using RenderView.
Need to make the URL protocol work that shows soon-to-be-uploaded images.
[x] Render post pages using RenderView.
[x] Get http custom URL protocols working again.
We have protocols that make some image hosts work (Minus, Waffleimages) by intercepting some http/https URLs. That's no good in WKWebView; let's find the URLs before rendering them and replace the scheme with something custom (e.g. awful-imagehost://minus/… or whatever).
[x] Delete all vestiges of UIWebView, URLProtocol.registerClass (but keep the pre-iOS 11 WKWebView stuff working), WebViewJavascriptBridge, bundled .js files that aren't RenderView.js, etc.
The following issues may have been fixed during this PR (but double-check before closing):
We currently use
UIWebView
for rendering posts and PMs.UIWebView
has finally been deprecated in the iOS 12 SDK, so it's time to move toWKWebView
.Some stuff got moved over back when iOS 8 came out, but
WKWebView
was missing a few key features that meant our heaviest web view usage was stuck. The last feature to fall was custom url scheme support (we useURLProtocol
which works inUIWebView
), which we use in a few different ways and wasn't worth giving up. Happily, custom URL scheme handlers arrived inWKWebView
in iOS 11, so we can give the full experience to everyone on iOS 11 and above (and for now, below, if we use some private API).There's a lot of common pieces for Awful when rendering content in web views, so let's extract those into a RenderView. All relevant JavaScript can go into RenderView.js instead of having a bunch of .js files strewn about. Speaking of, zepto.js isn't giving us enough to bother including it, so let's just use what the browser gives us. Let's also aim to move document manipulation code from JavaScript into Swift. Finally, we won't need
WebViewJavascriptBridge
anymore because its functionality is built in toWKWebView
.This is a big task, so let's approach it incrementally. RenderView can start as the rendering facility for the new feature of showing announcements, then we can move screens of increasing complexity over to RenderView as time goes on.
RenderView
(thin wrapper aroundWKWebView
).WKWebView
.RenderView
.WKWebView
.MustacheRepository.swift
.RenderView
.RenderView
.RenderView
.RenderView
.WKWebView
; let's find the URLs before rendering them and replace the scheme with something custom (e.g.awful-imagehost://minus/…
or whatever).UIWebView
,URLProtocol.registerClass
(but keep the pre-iOS 11 WKWebView stuff working),WebViewJavascriptBridge
, bundled .js files that aren'tRenderView.js
, etc.The following issues may have been fixed during this PR (but double-check before closing):