Skip to content

Commit

Permalink
Fixed a bug with Konachan where images wouldn't load(API changed so t…
Browse files Browse the repository at this point in the history
…he image URLs didn't have a protocol attached)
  • Loading branch information
DrabWeb committed Dec 23, 2016
1 parent ec786bc commit 0d42f02
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 6 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ DerivedData
# Carthage/Checkouts

Carthage/Build

.DS_Store
Binary file removed Booru-chan/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Booru-chan/Booru-chan.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = DrabWeb;
TargetAttributes = {
5D71B4911CCC06EA0011C281 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Binary file removed Booru-chan/Booru-chan/.DS_Store
Binary file not shown.
15 changes: 15 additions & 0 deletions Booru-chan/Booru-chan/Assets.xcassets/BCBooru.swift
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,21 @@ class BCBooruUtilities {
post?.url = self.baseUrl + "/index.php?page=post&s=view&id=\(post!.id)";
}

/// The protocol of this Booru's URL
let urlProtocol : String = self.representedBooru!.url.substring(to: self.representedBooru!.url.range(of: "//")!.lowerBound);

// If the image URL doesn't have a protocol...
if(post?.imageUrl.hasPrefix("//") ?? false) {
// Fix the image URL to also have the protocol
post!.imageUrl = urlProtocol + post!.imageUrl;
}

// If the thumbnail URL doesn't have a protocol...
if(post?.thumbnailUrl.hasPrefix("//") ?? false) {
// Fix the thumbnail URL to also have the protocol
post!.thumbnailUrl = urlProtocol + post!.thumbnailUrl;
}

// Return the post
return post;
}
Expand Down
6 changes: 3 additions & 3 deletions Booru-chan/Booru-chan/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11542"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -685,7 +685,7 @@
<scene sceneID="R2V-B0-nI4">
<objects>
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Booru-chan" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
<window key="window" title="Booru-chan" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="Booru-chan" animationBehavior="default" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<rect key="contentRect" x="550" y="405" width="600" height="400"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
Expand Down

0 comments on commit 0d42f02

Please sign in to comment.