강현태

카카오 로그인 추가

......@@ -20,21 +20,31 @@
<file leaf-file-name="app.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/app.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="236">
<caret line="86" column="31" lean-forward="false" selection-start-line="86" selection-start-column="31" selection-end-line="86" selection-end-column="31" />
<state relative-caret-position="420">
<caret line="28" column="29" lean-forward="false" selection-start-line="28" selection-start-column="29" selection-end-line="28" selection-end-column="29" />
<folding>
<element signature="e#921#993#0" expanded="false" />
<element signature="e#1052#1298#0" expanded="false" />
<element signature="e#955#1027#0" expanded="false" />
<element signature="e#1086#1332#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="helloWorld.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/views/helloWorld.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="16" lean-forward="false" selection-start-line="4" selection-start-column="11" selection-end-line="4" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="index.ejs" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/views/index.ejs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="327">
<caret line="38" column="11" lean-forward="false" selection-start-line="38" selection-start-column="11" selection-end-line="38" selection-end-column="11" />
<state relative-caret-position="269">
<caret line="56" column="14" lean-forward="false" selection-start-line="56" selection-start-column="14" selection-end-line="56" selection-end-column="92" />
<folding />
</state>
</provider>
......@@ -43,8 +53,8 @@
<file leaf-file-name="index.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/routes/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
<state relative-caret-position="0">
<caret line="0" column="33" lean-forward="false" selection-start-line="0" selection-start-column="33" selection-end-line="0" selection-end-column="33" />
<folding />
</state>
</provider>
......@@ -56,6 +66,7 @@
<option name="RECENT_TEMPLATES">
<list>
<option value="JavaScript File" />
<option value="HTML File" />
</list>
</option>
</component>
......@@ -74,6 +85,7 @@
<option value="$PROJECT_DIR$/package.json" />
<option value="$PROJECT_DIR$/controllers/webtoon_crawler.js" />
<option value="$PROJECT_DIR$/routes/index.js" />
<option value="$PROJECT_DIR$/views/helloWorld.html" />
<option value="$PROJECT_DIR$/app.js" />
<option value="$PROJECT_DIR$/views/index.ejs" />
</list>
......@@ -153,6 +165,7 @@
<property name="javascript.nodejs.core.library.configured.version" value="6.11.4" />
<property name="ChangesBrowser.SHOW_FLATTEN" value="false" />
<property name="jdk.selected.JAVA_MODULE" value="1.8" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
......@@ -260,7 +273,7 @@
<option name="presentableId" value="Default" />
<updated>1512173581551</updated>
<workItem from="1512173589576" duration="1873000" />
<workItem from="1512179289398" duration="29710000" />
<workItem from="1512179289398" duration="35658000" />
</task>
<task id="LOCAL-00001" summary="초기 commit by intellij">
<created>1512174269218</created>
......@@ -280,7 +293,7 @@
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="31583000" />
<option name="totallyTimeSpent" value="37531000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1440" height="900" extended-state="0" />
......@@ -295,7 +308,7 @@
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.329602" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.16523606" sideWeight="0.51119405" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.329602" sideWeight="0.49713877" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.329602" sideWeight="0.49713877" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.329602" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
......@@ -354,14 +367,6 @@
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="javascript">
<url>file://$PROJECT_DIR$/routes/index.js</url>
<line>6</line>
<properties />
<option name="timeStamp" value="39" />
</line-breakpoint>
</breakpoints>
<option name="time" value="40" />
</breakpoint-manager>
<watches-manager />
......@@ -447,29 +452,37 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/routes/index.js">
<entry file="file://$PROJECT_DIR$/app.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150">
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
<state relative-caret-position="420">
<caret line="28" column="29" lean-forward="false" selection-start-line="28" selection-start-column="29" selection-end-line="28" selection-end-column="29" />
<folding>
<element signature="e#955#1027#0" expanded="false" />
<element signature="e#1086#1332#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/helloWorld.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="16" lean-forward="false" selection-start-line="4" selection-start-column="11" selection-end-line="4" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/app.js">
<entry file="file://$PROJECT_DIR$/routes/index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="236">
<caret line="86" column="31" lean-forward="false" selection-start-line="86" selection-start-column="31" selection-end-line="86" selection-end-column="31" />
<folding>
<element signature="e#921#993#0" expanded="false" />
<element signature="e#1052#1298#0" expanded="false" />
</folding>
<state relative-caret-position="0">
<caret line="0" column="33" lean-forward="false" selection-start-line="0" selection-start-column="33" selection-end-line="0" selection-end-column="33" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/views/index.ejs">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="327">
<caret line="38" column="11" lean-forward="false" selection-start-line="38" selection-start-column="11" selection-end-line="38" selection-end-column="11" />
<state relative-caret-position="269">
<caret line="56" column="14" lean-forward="false" selection-start-line="56" selection-start-column="14" selection-end-line="56" selection-end-column="92" />
<folding />
</state>
</provider>
......
......@@ -5,8 +5,8 @@ var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var request = require('request');
var cheerio = require('cheerio');
var request = require('request');
var index = require('./routes/index');
var users = require('./routes/users');
......@@ -26,6 +26,7 @@ app.use(express.static(path.join(__dirname, 'public')));
app.use('/', index);
app.use('/users', users);
app.use(express.static('views'));
// catch 404 and forward to error handler
app.use(function(req, res, next) {
......@@ -68,33 +69,7 @@ function getUpdatedToons(){
});
}
allWebtoons = getAllToons();
function getAllToons() {
var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn";
allWebtoonJSONList = new Array();
request(allWeeklyToonsUrl,function (err, res, html) {
if(!err){
var $ = cheerio.load(html);
$(".thumb").each(function (i) {
var week = $(this).parent().parent().prev().attr('class');
var webtoon_link = "http://comic.naver.com" + $(this).children().first().attr('href');
var thumb_link = $(this).children().first().children().first().attr('src');
var name = $(this).next().text();
var webtoon= {
name : name,
thum_link : thumb_link,
webtoon_link : webtoon_link,
week : week
};
webtoon_string = JSON.stringify(webtoon);
//JSON으로 만든당.
allWebtoonJSONList.push(webtoon_string);
})
}
});
return(allWebtoonJSONList);
}
module.exports = app;
\ No newline at end of file
......
var express = require('express');
var cheerio = require('cheerio');
var request = require('request');
var router = express.Router();
allWebtoons = getAllToons();
function getAllToons() {
var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn";
allWebtoonJSONList = new Array();
request(allWeeklyToonsUrl,function (err, res, html) {
if(!err){
var $ = cheerio.load(html);
$(".thumb").each(function (i) {
var week = $(this).parent().parent().prev().attr('class');
var webtoon_link = "http://comic.naver.com" + $(this).children().first().attr('href');
var thumb_link = $(this).children().first().children().first().attr('src');
var name = $(this).next().text();
var webtoon= {
name : name,
thum_link : thumb_link,
webtoon_link : webtoon_link,
week : week
};
webtoon_string = JSON.stringify(webtoon);
//JSON으로 만든당.
allWebtoonJSONList.push(webtoon_string);
})
}
});
return(allWebtoonJSONList);
}
/* GET home page. */
router.get('/', function(req, res, next) {
......
......@@ -3,9 +3,14 @@
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<script src="http://developers.kakao.com/sdk/js/kakao.min.js"></script>
</head>
<h1><%= title %></h1>
<p><%= title %></p>
<p>웹툰 리스트</p>
<a id="kakao-login-btn"></a>
<a id="kakao-logout-btn" href="javascript:logout();">로그아웃</a>
<a id="save_config">저장</a>
<table>
<%
......@@ -39,5 +44,42 @@
</table>
</br>
<script type='text/javascript'>
//<![CDATA[
// 사용할 앱의 JavaScript 키를 설정해 주세요.
Kakao.init('602377cd7aa60a82eeebda466560f3e5');
// 카카오 로그인 버튼을 생성합니다.
Kakao.Auth.getStatus(function(statusObj){
if(statusObj.status=='connected'){
document.getElementById('kakao-login-btn').setAttribute('style','display: none;');
}else{
document.getElementById('kakao-logout-btn').setAttribute('style','display: none;');
document.getElementById('save_config').setAttribute('style','display: none;');
}
});
Kakao.Auth.createLoginButton({
container: '#kakao-login-btn',
size:'small',
success: function(authObj) {
alert(JSON.stringify(authObj));
location.reload();
},
fail: function(err) {
alert(JSON.stringify(err));
}
});
function logout(){
Kakao.Auth.logout(function () {
location.reload();
});
}
//]]>
</script>
</body>
</html>
......