강현태

카카오 로그인 추가

...@@ -20,21 +20,31 @@ ...@@ -20,21 +20,31 @@
20 <file leaf-file-name="app.js" pinned="false" current-in-tab="false"> 20 <file leaf-file-name="app.js" pinned="false" current-in-tab="false">
21 <entry file="file://$PROJECT_DIR$/app.js"> 21 <entry file="file://$PROJECT_DIR$/app.js">
22 <provider selected="true" editor-type-id="text-editor"> 22 <provider selected="true" editor-type-id="text-editor">
23 - <state relative-caret-position="236"> 23 + <state relative-caret-position="420">
24 - <caret line="86" column="31" lean-forward="false" selection-start-line="86" selection-start-column="31" selection-end-line="86" selection-end-column="31" /> 24 + <caret line="28" column="29" lean-forward="false" selection-start-line="28" selection-start-column="29" selection-end-line="28" selection-end-column="29" />
25 <folding> 25 <folding>
26 - <element signature="e#921#993#0" expanded="false" /> 26 + <element signature="e#955#1027#0" expanded="false" />
27 - <element signature="e#1052#1298#0" expanded="false" /> 27 + <element signature="e#1086#1332#0" expanded="false" />
28 </folding> 28 </folding>
29 </state> 29 </state>
30 </provider> 30 </provider>
31 </entry> 31 </entry>
32 </file> 32 </file>
33 + <file leaf-file-name="helloWorld.html" pinned="false" current-in-tab="false">
34 + <entry file="file://$PROJECT_DIR$/views/helloWorld.html">
35 + <provider selected="true" editor-type-id="text-editor">
36 + <state relative-caret-position="60">
37 + <caret line="4" column="16" lean-forward="false" selection-start-line="4" selection-start-column="11" selection-end-line="4" selection-end-column="16" />
38 + <folding />
39 + </state>
40 + </provider>
41 + </entry>
42 + </file>
33 <file leaf-file-name="index.ejs" pinned="false" current-in-tab="true"> 43 <file leaf-file-name="index.ejs" pinned="false" current-in-tab="true">
34 <entry file="file://$PROJECT_DIR$/views/index.ejs"> 44 <entry file="file://$PROJECT_DIR$/views/index.ejs">
35 <provider selected="true" editor-type-id="text-editor"> 45 <provider selected="true" editor-type-id="text-editor">
36 - <state relative-caret-position="327"> 46 + <state relative-caret-position="269">
37 - <caret line="38" column="11" lean-forward="false" selection-start-line="38" selection-start-column="11" selection-end-line="38" selection-end-column="11" /> 47 + <caret line="56" column="14" lean-forward="false" selection-start-line="56" selection-start-column="14" selection-end-line="56" selection-end-column="92" />
38 <folding /> 48 <folding />
39 </state> 49 </state>
40 </provider> 50 </provider>
...@@ -43,8 +53,8 @@ ...@@ -43,8 +53,8 @@
43 <file leaf-file-name="index.js" pinned="false" current-in-tab="false"> 53 <file leaf-file-name="index.js" pinned="false" current-in-tab="false">
44 <entry file="file://$PROJECT_DIR$/routes/index.js"> 54 <entry file="file://$PROJECT_DIR$/routes/index.js">
45 <provider selected="true" editor-type-id="text-editor"> 55 <provider selected="true" editor-type-id="text-editor">
46 - <state relative-caret-position="150"> 56 + <state relative-caret-position="0">
47 - <caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" /> 57 + <caret line="0" column="33" lean-forward="false" selection-start-line="0" selection-start-column="33" selection-end-line="0" selection-end-column="33" />
48 <folding /> 58 <folding />
49 </state> 59 </state>
50 </provider> 60 </provider>
...@@ -56,6 +66,7 @@ ...@@ -56,6 +66,7 @@
56 <option name="RECENT_TEMPLATES"> 66 <option name="RECENT_TEMPLATES">
57 <list> 67 <list>
58 <option value="JavaScript File" /> 68 <option value="JavaScript File" />
69 + <option value="HTML File" />
59 </list> 70 </list>
60 </option> 71 </option>
61 </component> 72 </component>
...@@ -74,6 +85,7 @@ ...@@ -74,6 +85,7 @@
74 <option value="$PROJECT_DIR$/package.json" /> 85 <option value="$PROJECT_DIR$/package.json" />
75 <option value="$PROJECT_DIR$/controllers/webtoon_crawler.js" /> 86 <option value="$PROJECT_DIR$/controllers/webtoon_crawler.js" />
76 <option value="$PROJECT_DIR$/routes/index.js" /> 87 <option value="$PROJECT_DIR$/routes/index.js" />
88 + <option value="$PROJECT_DIR$/views/helloWorld.html" />
77 <option value="$PROJECT_DIR$/app.js" /> 89 <option value="$PROJECT_DIR$/app.js" />
78 <option value="$PROJECT_DIR$/views/index.ejs" /> 90 <option value="$PROJECT_DIR$/views/index.ejs" />
79 </list> 91 </list>
...@@ -153,6 +165,7 @@ ...@@ -153,6 +165,7 @@
153 <property name="javascript.nodejs.core.library.configured.version" value="6.11.4" /> 165 <property name="javascript.nodejs.core.library.configured.version" value="6.11.4" />
154 <property name="ChangesBrowser.SHOW_FLATTEN" value="false" /> 166 <property name="ChangesBrowser.SHOW_FLATTEN" value="false" />
155 <property name="jdk.selected.JAVA_MODULE" value="1.8" /> 167 <property name="jdk.selected.JAVA_MODULE" value="1.8" />
168 + <property name="DefaultHtmlFileTemplate" value="HTML File" />
156 </component> 169 </component>
157 <component name="RunDashboard"> 170 <component name="RunDashboard">
158 <option name="ruleStates"> 171 <option name="ruleStates">
...@@ -260,7 +273,7 @@ ...@@ -260,7 +273,7 @@
260 <option name="presentableId" value="Default" /> 273 <option name="presentableId" value="Default" />
261 <updated>1512173581551</updated> 274 <updated>1512173581551</updated>
262 <workItem from="1512173589576" duration="1873000" /> 275 <workItem from="1512173589576" duration="1873000" />
263 - <workItem from="1512179289398" duration="29710000" /> 276 + <workItem from="1512179289398" duration="35658000" />
264 </task> 277 </task>
265 <task id="LOCAL-00001" summary="초기 commit by intellij"> 278 <task id="LOCAL-00001" summary="초기 commit by intellij">
266 <created>1512174269218</created> 279 <created>1512174269218</created>
...@@ -280,7 +293,7 @@ ...@@ -280,7 +293,7 @@
280 <servers /> 293 <servers />
281 </component> 294 </component>
282 <component name="TimeTrackingManager"> 295 <component name="TimeTrackingManager">
283 - <option name="totallyTimeSpent" value="31583000" /> 296 + <option name="totallyTimeSpent" value="37531000" />
284 </component> 297 </component>
285 <component name="ToolWindowManager"> 298 <component name="ToolWindowManager">
286 <frame x="0" y="0" width="1440" height="900" extended-state="0" /> 299 <frame x="0" y="0" width="1440" height="900" extended-state="0" />
...@@ -295,7 +308,7 @@ ...@@ -295,7 +308,7 @@
295 <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" /> 308 <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" />
296 <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" /> 309 <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" />
297 <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" /> 310 <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" />
298 - <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" /> 311 + <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" />
299 <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" /> 312 <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" />
300 <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" /> 313 <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" />
301 <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" /> 314 <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 @@ ...@@ -354,14 +367,6 @@
354 </component> 367 </component>
355 <component name="XDebuggerManager"> 368 <component name="XDebuggerManager">
356 <breakpoint-manager> 369 <breakpoint-manager>
357 - <breakpoints>
358 - <line-breakpoint enabled="true" type="javascript">
359 - <url>file://$PROJECT_DIR$/routes/index.js</url>
360 - <line>6</line>
361 - <properties />
362 - <option name="timeStamp" value="39" />
363 - </line-breakpoint>
364 - </breakpoints>
365 <option name="time" value="40" /> 370 <option name="time" value="40" />
366 </breakpoint-manager> 371 </breakpoint-manager>
367 <watches-manager /> 372 <watches-manager />
...@@ -447,29 +452,37 @@ ...@@ -447,29 +452,37 @@
447 </state> 452 </state>
448 </provider> 453 </provider>
449 </entry> 454 </entry>
450 - <entry file="file://$PROJECT_DIR$/routes/index.js"> 455 + <entry file="file://$PROJECT_DIR$/app.js">
451 <provider selected="true" editor-type-id="text-editor"> 456 <provider selected="true" editor-type-id="text-editor">
452 - <state relative-caret-position="150"> 457 + <state relative-caret-position="420">
453 - <caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" /> 458 + <caret line="28" column="29" lean-forward="false" selection-start-line="28" selection-start-column="29" selection-end-line="28" selection-end-column="29" />
459 + <folding>
460 + <element signature="e#955#1027#0" expanded="false" />
461 + <element signature="e#1086#1332#0" expanded="false" />
462 + </folding>
463 + </state>
464 + </provider>
465 + </entry>
466 + <entry file="file://$PROJECT_DIR$/views/helloWorld.html">
467 + <provider selected="true" editor-type-id="text-editor">
468 + <state relative-caret-position="60">
469 + <caret line="4" column="16" lean-forward="false" selection-start-line="4" selection-start-column="11" selection-end-line="4" selection-end-column="16" />
454 <folding /> 470 <folding />
455 </state> 471 </state>
456 </provider> 472 </provider>
457 </entry> 473 </entry>
458 - <entry file="file://$PROJECT_DIR$/app.js"> 474 + <entry file="file://$PROJECT_DIR$/routes/index.js">
459 <provider selected="true" editor-type-id="text-editor"> 475 <provider selected="true" editor-type-id="text-editor">
460 - <state relative-caret-position="236"> 476 + <state relative-caret-position="0">
461 - <caret line="86" column="31" lean-forward="false" selection-start-line="86" selection-start-column="31" selection-end-line="86" selection-end-column="31" /> 477 + <caret line="0" column="33" lean-forward="false" selection-start-line="0" selection-start-column="33" selection-end-line="0" selection-end-column="33" />
462 - <folding> 478 + <folding />
463 - <element signature="e#921#993#0" expanded="false" />
464 - <element signature="e#1052#1298#0" expanded="false" />
465 - </folding>
466 </state> 479 </state>
467 </provider> 480 </provider>
468 </entry> 481 </entry>
469 <entry file="file://$PROJECT_DIR$/views/index.ejs"> 482 <entry file="file://$PROJECT_DIR$/views/index.ejs">
470 <provider selected="true" editor-type-id="text-editor"> 483 <provider selected="true" editor-type-id="text-editor">
471 - <state relative-caret-position="327"> 484 + <state relative-caret-position="269">
472 - <caret line="38" column="11" lean-forward="false" selection-start-line="38" selection-start-column="11" selection-end-line="38" selection-end-column="11" /> 485 + <caret line="56" column="14" lean-forward="false" selection-start-line="56" selection-start-column="14" selection-end-line="56" selection-end-column="92" />
473 <folding /> 486 <folding />
474 </state> 487 </state>
475 </provider> 488 </provider>
......
...@@ -5,8 +5,8 @@ var logger = require('morgan'); ...@@ -5,8 +5,8 @@ var logger = require('morgan');
5 var cookieParser = require('cookie-parser'); 5 var cookieParser = require('cookie-parser');
6 var bodyParser = require('body-parser'); 6 var bodyParser = require('body-parser');
7 7
8 -var request = require('request');
9 var cheerio = require('cheerio'); 8 var cheerio = require('cheerio');
9 +var request = require('request');
10 var index = require('./routes/index'); 10 var index = require('./routes/index');
11 var users = require('./routes/users'); 11 var users = require('./routes/users');
12 12
...@@ -26,6 +26,7 @@ app.use(express.static(path.join(__dirname, 'public'))); ...@@ -26,6 +26,7 @@ app.use(express.static(path.join(__dirname, 'public')));
26 26
27 app.use('/', index); 27 app.use('/', index);
28 app.use('/users', users); 28 app.use('/users', users);
29 +app.use(express.static('views'));
29 30
30 // catch 404 and forward to error handler 31 // catch 404 and forward to error handler
31 app.use(function(req, res, next) { 32 app.use(function(req, res, next) {
...@@ -68,33 +69,7 @@ function getUpdatedToons(){ ...@@ -68,33 +69,7 @@ function getUpdatedToons(){
68 }); 69 });
69 } 70 }
70 71
71 -allWebtoons = getAllToons(); 72 +
72 -function getAllToons() {
73 - var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn";
74 - allWebtoonJSONList = new Array();
75 - request(allWeeklyToonsUrl,function (err, res, html) {
76 - if(!err){
77 - var $ = cheerio.load(html);
78 - $(".thumb").each(function (i) {
79 - var week = $(this).parent().parent().prev().attr('class');
80 - var webtoon_link = "http://comic.naver.com" + $(this).children().first().attr('href');
81 - var thumb_link = $(this).children().first().children().first().attr('src');
82 - var name = $(this).next().text();
83 -
84 - var webtoon= {
85 - name : name,
86 - thum_link : thumb_link,
87 - webtoon_link : webtoon_link,
88 - week : week
89 - };
90 - webtoon_string = JSON.stringify(webtoon);
91 - //JSON으로 만든당.
92 - allWebtoonJSONList.push(webtoon_string);
93 - })
94 - }
95 - });
96 - return(allWebtoonJSONList);
97 -}
98 73
99 74
100 module.exports = app; 75 module.exports = app;
...\ No newline at end of file ...\ No newline at end of file
......
1 var express = require('express'); 1 var express = require('express');
2 +var cheerio = require('cheerio');
3 +var request = require('request');
2 var router = express.Router(); 4 var router = express.Router();
3 5
6 +allWebtoons = getAllToons();
7 +function getAllToons() {
8 + var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn";
9 + allWebtoonJSONList = new Array();
10 + request(allWeeklyToonsUrl,function (err, res, html) {
11 + if(!err){
12 + var $ = cheerio.load(html);
13 + $(".thumb").each(function (i) {
14 + var week = $(this).parent().parent().prev().attr('class');
15 + var webtoon_link = "http://comic.naver.com" + $(this).children().first().attr('href');
16 + var thumb_link = $(this).children().first().children().first().attr('src');
17 + var name = $(this).next().text();
18 +
19 + var webtoon= {
20 + name : name,
21 + thum_link : thumb_link,
22 + webtoon_link : webtoon_link,
23 + week : week
24 + };
25 + webtoon_string = JSON.stringify(webtoon);
26 + //JSON으로 만든당.
27 + allWebtoonJSONList.push(webtoon_string);
28 + })
29 + }
30 + });
31 + return(allWebtoonJSONList);
32 +}
33 +
4 /* GET home page. */ 34 /* GET home page. */
5 router.get('/', function(req, res, next) { 35 router.get('/', function(req, res, next) {
6 36
......
...@@ -3,9 +3,14 @@ ...@@ -3,9 +3,14 @@
3 <head> 3 <head>
4 <title><%= title %></title> 4 <title><%= title %></title>
5 <link rel='stylesheet' href='/stylesheets/style.css' /> 5 <link rel='stylesheet' href='/stylesheets/style.css' />
6 + <script src="http://developers.kakao.com/sdk/js/kakao.min.js"></script>
6 </head> 7 </head>
7 <h1><%= title %></h1> 8 <h1><%= title %></h1>
8 - <p><%= title %></p> 9 + <p>웹툰 리스트</p>
10 + <a id="kakao-login-btn"></a>
11 + <a id="kakao-logout-btn" href="javascript:logout();">로그아웃</a>
12 + <a id="save_config">저장</a>
13 +
9 14
10 <table> 15 <table>
11 <% 16 <%
...@@ -39,5 +44,42 @@ ...@@ -39,5 +44,42 @@
39 </table> 44 </table>
40 </br> 45 </br>
41 46
47 + <script type='text/javascript'>
48 + //<![CDATA[
49 + // 사용할 앱의 JavaScript 키를 설정해 주세요.
50 + Kakao.init('602377cd7aa60a82eeebda466560f3e5');
51 + // 카카오 로그인 버튼을 생성합니다.
52 + Kakao.Auth.getStatus(function(statusObj){
53 + if(statusObj.status=='connected'){
54 + document.getElementById('kakao-login-btn').setAttribute('style','display: none;');
55 + }else{
56 + document.getElementById('kakao-logout-btn').setAttribute('style','display: none;');
57 + document.getElementById('save_config').setAttribute('style','display: none;');
58 + }
59 + });
60 +
61 + Kakao.Auth.createLoginButton({
62 + container: '#kakao-login-btn',
63 + size:'small',
64 + success: function(authObj) {
65 + alert(JSON.stringify(authObj));
66 + location.reload();
67 + },
68 + fail: function(err) {
69 + alert(JSON.stringify(err));
70 + }
71 + });
72 +
73 + function logout(){
74 + Kakao.Auth.logout(function () {
75 + location.reload();
76 + });
77 +
78 + }
79 + //]]>
80 +
81 + </script>
82 +
42 </body> 83 </body>
84 +
43 </html> 85 </html>
......