Skip to content

Commit

Permalink
서버쪽 파일 추가, webview에 로그인 테스트 페이지 띄우도록 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
leadbrain committed Jul 15, 2012
1 parent 8a20320 commit 5db34c4
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 18 deletions.
14 changes: 14 additions & 0 deletions Delis.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
756E56A715ADD11E0009D04C /* sample_food.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 756E56A615ADD11E0009D04C /* sample_food.jpg */; };
756E56AA15ADD2EE0009D04C /* sample_people.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 756E56A915ADD2EE0009D04C /* sample_people.jpg */; };
756E56AD15ADD7770009D04C /* CameraViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 756E56AC15ADD7770009D04C /* CameraViewController.m */; };
75B0307515AF024400BABE2D /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 75B0307415AF024400BABE2D /* ProfileViewController.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -66,6 +67,8 @@
756E56A915ADD2EE0009D04C /* sample_people.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = sample_people.jpg; sourceTree = "<group>"; };
756E56AB15ADD7770009D04C /* CameraViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CameraViewController.h; sourceTree = "<group>"; };
756E56AC15ADD7770009D04C /* CameraViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CameraViewController.m; sourceTree = "<group>"; };
75B0307315AF024400BABE2D /* ProfileViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileViewController.h; sourceTree = "<group>"; };
75B0307415AF024400BABE2D /* ProfileViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProfileViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -129,6 +132,8 @@
7515BE1015AC7BD800F448FC /* Delis */ = {
isa = PBXGroup;
children = (
75B0307315AF024400BABE2D /* ProfileViewController.h */,
75B0307415AF024400BABE2D /* ProfileViewController.m */,
756E56AB15ADD7770009D04C /* CameraViewController.h */,
756E56AC15ADD7770009D04C /* CameraViewController.m */,
7515BE4B15ADB96900F448FC /* FeedViewController.h */,
Expand Down Expand Up @@ -289,6 +294,7 @@
7515BE2415AC7BD800F448FC /* ViewController.m in Sources */,
7515BE4D15ADB96900F448FC /* FeedViewController.m in Sources */,
756E56AD15ADD7770009D04C /* CameraViewController.m in Sources */,
75B0307515AF024400BABE2D /* ProfileViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -399,6 +405,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Delis/Delis-Prefix.pch";
INFOPLIST_FILE = "Delis/Delis-Info.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/facebook-ios-sdk\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand All @@ -410,6 +420,10 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Delis/Delis-Prefix.pch";
INFOPLIST_FILE = "Delis/Delis-Info.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/facebook-ios-sdk\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
landmarkType = "7">
</FileBreakpoint>
<FileBreakpoint
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
isPathRelative = "1"
Expand All @@ -31,5 +31,31 @@
landmarkName = "-viewDidLoad"
landmarkType = "5">
</FileBreakpoint>
<FileBreakpoint
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Delis/ProfileViewController.m"
timestampString = "364049979.167019"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "18"
endingLineNumber = "18"
landmarkName = "-viewDidLoad"
landmarkType = "5">
</FileBreakpoint>
<FileBreakpoint
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Delis/ProfileViewController.m"
timestampString = "364049972.341689"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "16"
endingLineNumber = "16"
landmarkName = "-viewDidLoad"
landmarkType = "5">
</FileBreakpoint>
</FileBreakpoints>
</Bucket>
5 changes: 4 additions & 1 deletion Delis/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate> {

}

@property (strong, nonatomic) UIWindow *window;


@end
3 changes: 2 additions & 1 deletion Delis/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ @implementation AppDelegate

@synthesize window = _window;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

return YES;
}

Expand Down
9 changes: 9 additions & 0 deletions Delis/Delis-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fbYOUR_APP_ID</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
17 changes: 17 additions & 0 deletions Delis/ProfileViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// ProfileViewController.h
// Delis
//
// Created by 김 영선 on 12. 7. 12..
// Copyright (c) 2012년 LBS. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ProfileViewController : UIViewController {
IBOutlet UIWebView* webview;
}

@property (nonatomic, retain) UIWebView* webview;

@end
21 changes: 21 additions & 0 deletions Delis/ProfileViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// ProfileViewController.m
// Delis
//
// Created by 김 영선 on 12. 7. 12..
// Copyright (c) 2012년 LBS. All rights reserved.
//

#import "ProfileViewController.h"

@implementation ProfileViewController
@synthesize webview;

-(void)viewDidLoad {
[super viewDidLoad];
NSURL* url = [NSURL URLWithString:@"http://localhost:8000/login_test.html"];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[webview loadRequest:request];
}

@end
27 changes: 12 additions & 15 deletions Delis/en.lproj/MainStoryboard_iPhone.storyboard
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1938" systemVersion="11E53" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="4rI-EZ-ajm">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.1" toolsVersion="2182" systemVersion="11E53" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="4rI-EZ-ajm">
<dependencies>
<deployment defaultVersion="1296" identifier="iOS"/>
<development defaultVersion="4200" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="933"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="1181"/>
</dependencies>
<scenes>
<!--Profile View Controller - ProfileView-->
<scene sceneID="5">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="4" sceneMemberID="firstResponder"/>
<viewController id="2" customClass="ViewController" sceneMemberID="viewController">
<webView key="view" contentMode="scaleToFill" id="fbc-ni-rHE">
<viewController id="2" customClass="ProfileViewController" sceneMemberID="viewController">
<webView key="view" contentMode="scaleToFill" id="0jk-8q-G9k">
<rect key="frame" x="0.0" y="20" width="320" height="411"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</webView>
<tabBarItem key="tabBarItem" title="ProfileView" id="fWW-lQ-XhT"/>
<connections>
<outlet property="webview" destination="0jk-8q-G9k" id="ZS7-09-J6x"/>
</connections>
</viewController>
</objects>
<point key="canvasLocation" x="598" y="995"/>
</scene>
<!--Feed View Controller - FeedView-->
<scene sceneID="7t4-lI-ruy">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="rBn-e5-DpE" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand Down Expand Up @@ -93,6 +99,7 @@
</objects>
<point key="canvasLocation" x="598" y="-141"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="5Bq-N6-WVH">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="tFP-3v-hEi" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand All @@ -112,6 +119,7 @@
</objects>
<point key="canvasLocation" x="64" y="151"/>
</scene>
<!--Camera View Controller - Camera-->
<scene sceneID="tb0-Xl-QMZ">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="ekg-sM-A1g" userLabel="First Responder" sceneMemberID="firstResponder"/>
Expand All @@ -131,17 +139,6 @@
<image name="sample_food.jpg" width="531" height="650"/>
<image name="sample_people.jpg" width="734" height="733"/>
</resources>
<classes>
<class className="CameraViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/CameraViewController.h"/>
</class>
<class className="FeedViewController" superclassName="UITableViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/FeedViewController.h"/>
</class>
<class className="ViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/ViewController.h"/>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Expand Down
50 changes: 50 additions & 0 deletions Server/:w
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!doctype html>
<html>
<head>
<title>Hello World</title>
<meta name="viewport"
content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
<script src="login.js"></script>
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '494841757196846', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.statusChange', handleStatusChange);
};

(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document))
</script>

<div id="login">
<p><button onClick="loginUser();">Login</button></p>
</div>
<div id="logout">
<p><button onClick="FB.logout();">Logout</button></p>
</div>

<div id="fb-root"></div>
<style>
body.connected #login { display: none; }
body.connected #logout { display: block; }
body.not_connected #login { display: block; }
body.not_connected #logout { display: none; }
</style>
<div id="user-info"></div>
<a href="#" onclick="getUserFriends();">Get friends</a><br>
<div id="user-friends"></div>
<a href="#" onclick="sendRequest();">Send request</a><br>
</body>
</html>
32 changes: 32 additions & 0 deletions Server/fileserver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var sys = require("sys"),
http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs");

http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname;
var filename = path.join(process.cwd(), uri);
path.exists(filename, function(exists) {
if(!exists) {
response.writeHeader(404, {"Content-Type": "text/plain"});
response.write("404 not found");
response.end();
return;
}

fs.readFile(filename, "binary", function(err, file) {
if(err) {
response.writeHeader(500, {"Content-Type": "text/plain"});
response.write(err + "\n");
response.end();
return;
}
response.writeHeader(200);
response.write(file, "binary");
response.end();
});
});
}).listen(8000);

sys.puts("server runnint at http://localhost:8000");
44 changes: 44 additions & 0 deletions Server/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function handleStatusChange(response) {
document.body.className = response.authResponse ? 'connected' : 'not_connected';
if (response.authResponse) {
console.log(response);
updateUserInfo(response);
}
}

function loginUser() {
FB.login(function(response) { }, {scope:'email'});
}
function updateUserInfo(response) {
FB.api('/me', function(response) {
document.getElementById('user-info').innerHTML = '<img src="https://graph.facebook.com/' + response.id + '/picture">' + response.name;
});
}
function getUserFriends() {
FB.api('/me/friends&fields=name,picture', function(response) {
console.log('Got friends: ', response);

if (!response.error) {
var markup = '';

var friends = response.data;

for (var i=0; i < friends.length && i < 25; i++) {
var friend = friends[i];

markup += '<img src="' + friend.picture + '"> ' + friend.name + '<br>';
}

document.getElementById('user-friends').innerHTML = markup;
}
});
}
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'invites you to learn how to make your mobile web app social',
},
function(response) {
console.log('sendRequest response: ', response);
});
}
Loading

0 comments on commit 5db34c4

Please sign in to comment.