Skip to content

Commit

Permalink
Added a SettingsViewController, so users can enter their Internet Arc…
Browse files Browse the repository at this point in the history
…hive S3 access and secret key.
  • Loading branch information
tladesignz committed Jul 5, 2018
1 parent 9b27f2e commit cf94e02
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 0 deletions.
10 changes: 10 additions & 0 deletions OpenArchive.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
A004E24A20EBCEA000A1D5F5 /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A004E24920EBCEA000A1D5F5 /* DetailsViewController.swift */; };
A004E24C20EBCF1700A1D5F5 /* Formatters.swift in Sources */ = {isa = PBXBuildFile; fileRef = A004E24B20EBCF1700A1D5F5 /* Formatters.swift */; };
A058628120E4EC3900EE2F14 /* ImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A058628020E4EC3900EE2F14 /* ImageCell.swift */; };
A0C0732820EE74CB00EA48F0 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0C0732720EE74CB00EA48F0 /* SettingsViewController.swift */; };
A0C0732A20EE779800EA48F0 /* InternetArchive.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0C0732920EE779800EA48F0 /* InternetArchive.swift */; };
A0D58DCE20E51517005A2F34 /* Asset.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0D58DCD20E51517005A2F34 /* Asset.swift */; };
A0D58DD020E5160A005A2F34 /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0D58DCF20E5160A005A2F34 /* Image.swift */; };
A0E739D820E4C85D00DB31E1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E739D720E4C85D00DB31E1 /* AppDelegate.swift */; };
Expand All @@ -29,6 +31,9 @@
A058628020E4EC3900EE2F14 /* ImageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCell.swift; sourceTree = "<group>"; };
A058628320E4FC5A00EE2F14 /* Podfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Podfile; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
A058628520E4FDBF00EE2F14 /* Podfile.lock */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Podfile.lock; sourceTree = "<group>"; };
A0C0732720EE74CB00EA48F0 /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
A0C0732920EE779800EA48F0 /* InternetArchive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternetArchive.swift; sourceTree = "<group>"; };
A0C0732B20EE7AB600EA48F0 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
A0D58DCD20E51517005A2F34 /* Asset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Asset.swift; sourceTree = "<group>"; };
A0D58DCF20E5160A005A2F34 /* Image.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Image.swift; sourceTree = "<group>"; };
A0E739D420E4C85D00DB31E1 /* OpenArchive.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenArchive.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -76,6 +81,7 @@
children = (
A058628320E4FC5A00EE2F14 /* Podfile */,
A058628520E4FDBF00EE2F14 /* Podfile.lock */,
A0C0732B20EE7AB600EA48F0 /* README.md */,
);
name = Build;
sourceTree = "<group>";
Expand All @@ -85,6 +91,7 @@
children = (
A0D58DCD20E51517005A2F34 /* Asset.swift */,
A0D58DCF20E5160A005A2F34 /* Image.swift */,
A0C0732920EE779800EA48F0 /* InternetArchive.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -116,6 +123,7 @@
A0E739D720E4C85D00DB31E1 /* AppDelegate.swift */,
A0E739D920E4C85D00DB31E1 /* MainViewController.swift */,
A058628020E4EC3900EE2F14 /* ImageCell.swift */,
A0C0732720EE74CB00EA48F0 /* SettingsViewController.swift */,
A004E24920EBCEA000A1D5F5 /* DetailsViewController.swift */,
A0E739DB20E4C85D00DB31E1 /* Main.storyboard */,
A0E739DE20E4C85E00DB31E1 /* Assets.xcassets */,
Expand Down Expand Up @@ -256,6 +264,8 @@
A058628120E4EC3900EE2F14 /* ImageCell.swift in Sources */,
A0D58DD020E5160A005A2F34 /* Image.swift in Sources */,
A004E24A20EBCEA000A1D5F5 /* DetailsViewController.swift in Sources */,
A0C0732820EE74CB00EA48F0 /* SettingsViewController.swift in Sources */,
A0C0732A20EE779800EA48F0 /* InternetArchive.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
107 changes: 107 additions & 0 deletions OpenArchive/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
</connections>
</tableView>
<navigationItem key="navigationItem" title="OpenArchive" id="qag-qj-eDJ">
<barButtonItem key="leftBarButtonItem" systemItem="compose" id="8kQ-9c-OMm">
<connections>
<segue destination="5Gf-8P-w4o" kind="show" id="yMy-dj-fQK"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" systemItem="add" id="MKK-1M-yTY">
<connections>
<action selector="add:" destination="dtV-Dk-Mg4" id="Rd4-uj-f0q"/>
Expand All @@ -74,6 +79,108 @@
</objects>
<point key="canvasLocation" x="592.79999999999995" y="116.49175412293854"/>
</scene>
<!--Settings-->
<scene sceneID="pfx-x7-Mmk">
<objects>
<tableViewController id="5Gf-8P-w4o" customClass="SettingsViewController" customModule="OpenArchive" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="iIh-Yv-we5">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<sections>
<tableViewSection headerTitle="Internet Archive" id="E1z-Kp-V0O">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="90" id="qRa-cX-Ibn">
<rect key="frame" x="0.0" y="28" width="375" height="90"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="qRa-cX-Ibn" id="eyk-wl-JfG">
<rect key="frame" x="0.0" y="0.0" width="375" height="89.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" text="Please go to http://archive.org/account/s3.php and copy the displayed access and secret keys into the provided fields!" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="q72-Gu-CUU">
<rect key="frame" x="16" y="11" width="343" height="68"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<dataDetectorType key="dataDetectorTypes" link="YES"/>
</textView>
</subviews>
<constraints>
<constraint firstItem="q72-Gu-CUU" firstAttribute="leading" secondItem="eyk-wl-JfG" secondAttribute="leadingMargin" id="08V-Yp-kla"/>
<constraint firstItem="q72-Gu-CUU" firstAttribute="bottom" secondItem="eyk-wl-JfG" secondAttribute="bottomMargin" id="F27-ii-XNc"/>
<constraint firstItem="q72-Gu-CUU" firstAttribute="trailing" secondItem="eyk-wl-JfG" secondAttribute="trailingMargin" id="v2A-4T-Tho"/>
<constraint firstItem="q72-Gu-CUU" firstAttribute="top" secondItem="eyk-wl-JfG" secondAttribute="topMargin" id="zWG-mT-V0b"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="52" id="Upd-EA-G0L">
<rect key="frame" x="0.0" y="118" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Upd-EA-G0L" id="whE-Jr-Ca4">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Access Key" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="geQ-s6-tpR">
<rect key="frame" x="16" y="11" width="343" height="30"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="changed:" destination="5Gf-8P-w4o" eventType="editingDidEnd" id="Fkg-rY-nXO"/>
</connections>
</textField>
</subviews>
<constraints>
<constraint firstItem="geQ-s6-tpR" firstAttribute="top" secondItem="whE-Jr-Ca4" secondAttribute="topMargin" id="Yj2-Xc-6I1"/>
<constraint firstItem="geQ-s6-tpR" firstAttribute="leading" secondItem="whE-Jr-Ca4" secondAttribute="leadingMargin" id="aiY-u0-u0w"/>
<constraint firstItem="geQ-s6-tpR" firstAttribute="trailing" secondItem="whE-Jr-Ca4" secondAttribute="trailingMargin" id="quZ-PH-bMN"/>
<constraint firstAttribute="bottomMargin" secondItem="geQ-s6-tpR" secondAttribute="bottom" id="yFG-Zs-bPv"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" rowHeight="52" id="irs-ei-Lfq">
<rect key="frame" x="0.0" y="170" width="375" height="52"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="irs-ei-Lfq" id="ZUk-C7-65h">
<rect key="frame" x="0.0" y="0.0" width="375" height="51.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Secret Key" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="kaI-PD-ZX3">
<rect key="frame" x="16" y="11" width="343" height="30"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
<connections>
<action selector="changed:" destination="5Gf-8P-w4o" eventType="editingDidEnd" id="l8N-W2-RzM"/>
</connections>
</textField>
</subviews>
<constraints>
<constraint firstItem="kaI-PD-ZX3" firstAttribute="leading" secondItem="ZUk-C7-65h" secondAttribute="leadingMargin" id="JIB-UW-37Q"/>
<constraint firstItem="kaI-PD-ZX3" firstAttribute="top" secondItem="ZUk-C7-65h" secondAttribute="topMargin" id="S1k-1R-rcW"/>
<constraint firstAttribute="bottomMargin" secondItem="kaI-PD-ZX3" secondAttribute="bottom" id="XQu-AX-NzD"/>
<constraint firstItem="kaI-PD-ZX3" firstAttribute="trailing" secondItem="ZUk-C7-65h" secondAttribute="trailingMargin" id="vBk-Ob-DYx"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="5Gf-8P-w4o" id="Xyv-rD-z8c"/>
<outlet property="delegate" destination="5Gf-8P-w4o" id="Es3-J5-eLp"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Settings" id="ZPJ-1v-7q6"/>
<connections>
<outlet property="accessKeyTf" destination="geQ-s6-tpR" id="Kfc-gk-j9U"/>
<outlet property="secretKeyTf" destination="kaI-PD-ZX3" id="cQa-5P-dHI"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="AwL-p3-kAP" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1612" y="-683.20839580209895"/>
</scene>
<!--Details-->
<scene sceneID="Fau-MA-0p5">
<objects>
Expand Down
33 changes: 33 additions & 0 deletions OpenArchive/Models/InternetArchive.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// InternetArchive.swift
// OpenArchive
//
// Created by Benjamin Erhart on 05.07.18.
// Copyright © 2018 Open Archive. All rights reserved.
//

import UIKit

class InternetArchive {

private static let ACCESS_KEY = "ACCESS_KEY"
private static let SECRET_KEY = "SECRET_KEY"

public static var accessKey: String? {
get {
return UserDefaults.standard.string(forKey: InternetArchive.ACCESS_KEY)
}
set {
UserDefaults.standard.set(newValue, forKey: InternetArchive.ACCESS_KEY)
}
}

public static var secretKey: String? {
get {
return UserDefaults.standard.string(forKey: InternetArchive.SECRET_KEY)
}
set {
UserDefaults.standard.set(newValue, forKey: InternetArchive.SECRET_KEY)
}
}
}
33 changes: 33 additions & 0 deletions OpenArchive/SettingsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// SettingsViewController.swift
// OpenArchive
//
// Created by Benjamin Erhart on 05.07.18.
// Copyright © 2018 Open Archive. All rights reserved.
//

import UIKit

class SettingsViewController: UITableViewController {

@IBOutlet var accessKeyTf: UITextField!
@IBOutlet var secretKeyTf: UITextField!

private let defaults = UserDefaults.standard

override func viewDidLoad() {
super.viewDidLoad()

accessKeyTf.text = InternetArchive.accessKey
secretKeyTf.text = InternetArchive.secretKey
}

@IBAction func changed(_ sender: UITextField) {
switch sender {
case accessKeyTf:
InternetArchive.accessKey = sender.text
default:
InternetArchive.secretKey = sender.text
}
}
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# OpenArchive

## Internet Archive S3 reference:
https://archive.org/help/abouts3.txt
https://github.com/vmbrasseur/IAS3API
http://internetarchive.readthedocs.io/en/latest/api.html

0 comments on commit cf94e02

Please sign in to comment.