Showing
6 changed files
with
46 additions
and
127 deletions
... | @@ -47,7 +47,6 @@ var mytoons = require('./routes/mytoons'); | ... | @@ -47,7 +47,6 @@ var mytoons = require('./routes/mytoons'); |
47 | var yourtoons =require('./routes/yourtoons'); | 47 | var yourtoons =require('./routes/yourtoons'); |
48 | var setting = require('./routes/setting'); | 48 | var setting = require('./routes/setting'); |
49 | 49 | ||
50 | - | ||
51 | // 최초 로그인 성공시 (Strategy 성공시) 단 한번만 호출 | 50 | // 최초 로그인 성공시 (Strategy 성공시) 단 한번만 호출 |
52 | passport.serializeUser(function(user, done) { | 51 | passport.serializeUser(function(user, done) { |
53 | console.log('serialized'); | 52 | console.log('serialized'); | ... | ... |
public/images/lezhinicon.png
deleted
100644 → 0

2.94 KB
... | @@ -152,6 +152,8 @@ function getLatestToon(titleid, day ,cb) { | ... | @@ -152,6 +152,8 @@ function getLatestToon(titleid, day ,cb) { |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | +var daumCount = 0; | ||
156 | + | ||
155 | //_day요일의 다음웹툰 불러오기 | 157 | //_day요일의 다음웹툰 불러오기 |
156 | function getDaumToons(_day) { | 158 | function getDaumToons(_day) { |
157 | 159 | ||
... | @@ -165,6 +167,9 @@ function getDaumToons(_day) { | ... | @@ -165,6 +167,9 @@ function getDaumToons(_day) { |
165 | var data = JSON.parse(body); | 167 | var data = JSON.parse(body); |
166 | var list = data["data"]; | 168 | var list = data["data"]; |
167 | 169 | ||
170 | + if(err) { | ||
171 | + console.log("다음웹툰 DB 에러 : " + err); | ||
172 | + } else { | ||
168 | list.forEach(function (item, idx) { | 173 | list.forEach(function (item, idx) { |
169 | 174 | ||
170 | var webtoon_link = 'http://webtoon.daum.net/webtoon/view/' + item.nickname.toString(); | 175 | var webtoon_link = 'http://webtoon.daum.net/webtoon/view/' + item.nickname.toString(); |
... | @@ -177,9 +182,10 @@ function getDaumToons(_day) { | ... | @@ -177,9 +182,10 @@ function getDaumToons(_day) { |
177 | site : site, | 182 | site : site, |
178 | latest : 0 | 183 | latest : 0 |
179 | }; | 184 | }; |
180 | - | 185 | + daumCount++; |
181 | allWebtoonList.push(webtoon); | 186 | allWebtoonList.push(webtoon); |
182 | }); | 187 | }); |
188 | + } | ||
183 | }); | 189 | }); |
184 | } | 190 | } |
185 | 191 | ||
... | @@ -187,6 +193,9 @@ function getDaumToons(_day) { | ... | @@ -187,6 +193,9 @@ function getDaumToons(_day) { |
187 | function getNaverToons() { | 193 | function getNaverToons() { |
188 | 194 | ||
189 | var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn"; | 195 | var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn"; |
196 | + // 네이버 웹툰 개수 | ||
197 | + var naverCount = 0; | ||
198 | + var webtoonCount = 0; | ||
190 | 199 | ||
191 | request(allWeeklyToonsUrl,function (err, res, html) { | 200 | request(allWeeklyToonsUrl,function (err, res, html) { |
192 | if(!err){ | 201 | if(!err){ |
... | @@ -209,54 +218,7 @@ function getNaverToons() { | ... | @@ -209,54 +218,7 @@ function getNaverToons() { |
209 | site : site, | 218 | site : site, |
210 | latest : 0 | 219 | latest : 0 |
211 | }; | 220 | }; |
212 | - | 221 | + naverCount++; |
213 | - allWebtoonList.push(webtoon); | ||
214 | - }); | ||
215 | - | ||
216 | - p.then(function() { | ||
217 | - i = 0; | ||
218 | - allWebtoonList.forEach(function (webtoon) { | ||
219 | - var sql= "INSERT INTO `toon` (toon_index, name, thum_link, webtoon_link, week, site, latest) VALUES(?) ON DUPLICATE KEY UPDATE latest=latest"; | ||
220 | - var values=[webtoon.toon_index, webtoon.name, webtoon.thum_link, webtoon.webtoon_link,webtoon.week, webtoon.site, webtoon.latest]; | ||
221 | - | ||
222 | - connection.query(sql,[values],function(err,result){ | ||
223 | - if (err) { | ||
224 | - console.log("웹툰 DB 에러 : " + err); | ||
225 | - } else { | ||
226 | - console.log("웹툰 DB처리 완료!"); | ||
227 | - } | ||
228 | - }); | ||
229 | - }) | ||
230 | - }); | ||
231 | - } | ||
232 | - }); | ||
233 | -} | ||
234 | - | ||
235 | -// 구현중 | ||
236 | -function getTomicsToons(){ | ||
237 | - var allWeeklyToonsUrl = "https://www.lezhin.com/ko/scheduled"; | ||
238 | - | ||
239 | - request(allWeeklyToonsUrl,function (err, res, html) { | ||
240 | - if(!err){ | ||
241 | - var $ = cheerio.load(html); | ||
242 | - var p = Promise.resolve(); | ||
243 | - var eachs = $(".thumb").each(function (i) { | ||
244 | - var week = $(this).parent().parent().prev().attr('class'); | ||
245 | - var webtoon_link = "https://www.lezhin.com/ko" + $(this).children().first().attr('href'); | ||
246 | - var thumb_link = $(this).children().first().children().first().attr('src'); | ||
247 | - var name = $(this).next().text(); | ||
248 | - var titleid = webtoon_link.split('?')[1].split('&')[0].split('=')[1]; | ||
249 | - var site = 'naver'; | ||
250 | - var webtoon= { | ||
251 | - toon_index: titleid, | ||
252 | - name : name, | ||
253 | - thum_link : thumb_link, | ||
254 | - webtoon_link : webtoon_link, | ||
255 | - week : week, | ||
256 | - site : site, | ||
257 | - latest : 0 | ||
258 | - }; | ||
259 | - | ||
260 | allWebtoonList.push(webtoon); | 222 | allWebtoonList.push(webtoon); |
261 | }); | 223 | }); |
262 | 224 | ||
... | @@ -267,19 +229,21 @@ function getTomicsToons(){ | ... | @@ -267,19 +229,21 @@ function getTomicsToons(){ |
267 | var values=[webtoon.toon_index, webtoon.name, webtoon.thum_link, webtoon.webtoon_link,webtoon.week, webtoon.site, webtoon.latest]; | 229 | var values=[webtoon.toon_index, webtoon.name, webtoon.thum_link, webtoon.webtoon_link,webtoon.week, webtoon.site, webtoon.latest]; |
268 | 230 | ||
269 | connection.query(sql,[values],function(err,result){ | 231 | connection.query(sql,[values],function(err,result){ |
270 | - if (err) { | 232 | + if(err) { |
271 | console.log("웹툰 DB 에러 : " + err); | 233 | console.log("웹툰 DB 에러 : " + err); |
272 | } else { | 234 | } else { |
273 | - console.log("웹툰 DB처리 완료!"); | 235 | + webtoonCount++; |
236 | + console.log(`웹툰 ${webtoonCount}개 DB처리 완료!`); | ||
274 | } | 237 | } |
275 | }); | 238 | }); |
276 | }) | 239 | }) |
277 | }); | 240 | }); |
278 | } | 241 | } |
242 | + console.log(`다음웹툰 ${daumCount}개, 네이버웹툰 ${naverCount}개`) | ||
279 | }); | 243 | }); |
280 | } | 244 | } |
281 | 245 | ||
282 | -// 모든 웹튼을 담고있는 배열 | 246 | +// 모든 웹툰을 담고있는 배열 |
283 | allWebtoons = new Array(); | 247 | allWebtoons = new Array(); |
284 | 248 | ||
285 | // 설명 | 249 | // 설명 |
... | @@ -303,8 +267,6 @@ function getAllToons() { | ... | @@ -303,8 +267,6 @@ function getAllToons() { |
303 | getDaumToons('sun'); | 267 | getDaumToons('sun'); |
304 | //네이버 웹툰 | 268 | //네이버 웹툰 |
305 | getNaverToons(); | 269 | getNaverToons(); |
306 | - //투믹스 웹툰 | ||
307 | - getTomicsToons(); | ||
308 | 270 | ||
309 | allWebtoons = allWebtoonList; | 271 | allWebtoons = allWebtoonList; |
310 | }; | 272 | }; | ... | ... |
... | @@ -2,16 +2,16 @@ var express = require('express'); | ... | @@ -2,16 +2,16 @@ var express = require('express'); |
2 | var async = require('async'); | 2 | var async = require('async'); |
3 | var router = express.Router(); | 3 | var router = express.Router(); |
4 | 4 | ||
5 | -function getMyToons(id,cb){ | 5 | +function getMyToons(id,cb) { |
6 | //id 값을 가진 user가 저장한 웹툰들 가져오기 | 6 | //id 값을 가진 user가 저장한 웹툰들 가져오기 |
7 | var sqlquery = "SELECT t.toon_index, t.name, t.thum_link, t.webtoon_link, t.week, t.site FROM user u, user_toon_relation ur, toon t WHERE u.id = '"+id+"' && u.id=ur.user_id && t.toon_index=ur.toon_index;"; | 7 | var sqlquery = "SELECT t.toon_index, t.name, t.thum_link, t.webtoon_link, t.week, t.site FROM user u, user_toon_relation ur, toon t WHERE u.id = '"+id+"' && u.id=ur.user_id && t.toon_index=ur.toon_index;"; |
8 | var mylist = new Array(); | 8 | var mylist = new Array(); |
9 | - connection.query(sqlquery,id,function(err,rows,result){ | 9 | + connection.query(sqlquery,id,function(err,rows,result) { |
10 | - if(!err){ | 10 | + if(!err) { |
11 | mylist=rows; | 11 | mylist=rows; |
12 | cb(mylist); | 12 | cb(mylist); |
13 | console.log(mylist); | 13 | console.log(mylist); |
14 | - }else{ | 14 | + } else { |
15 | console.log("내 웹툰 리스트 가져오는데 실패했습니다!"); | 15 | console.log("내 웹툰 리스트 가져오는데 실패했습니다!"); |
16 | //throw err; | 16 | //throw err; |
17 | } | 17 | } |
... | @@ -20,17 +20,15 @@ function getMyToons(id,cb){ | ... | @@ -20,17 +20,15 @@ function getMyToons(id,cb){ |
20 | 20 | ||
21 | /* GET home page. */ | 21 | /* GET home page. */ |
22 | router.get('/', function(req, res, next) { | 22 | router.get('/', function(req, res, next) { |
23 | - if(!req.isAuthenticated()){ | 23 | + if(!req.isAuthenticated()) { |
24 | res.redirect('/'); | 24 | res.redirect('/'); |
25 | - }else{ | 25 | + } else { |
26 | - async.series( | 26 | + async.series([ |
27 | - [ | ||
28 | function(callback){ | 27 | function(callback){ |
29 | getMyToons(req.user.user_id, function (mytoon_list) { | 28 | getMyToons(req.user.user_id, function (mytoon_list) { |
30 | callback(null,mytoon_list); | 29 | callback(null,mytoon_list); |
31 | }); | 30 | }); |
32 | - } | 31 | + }], |
33 | - ], | ||
34 | function(err, results){ | 32 | function(err, results){ |
35 | res.render('mytoons', { | 33 | res.render('mytoons', { |
36 | mytoons: results[0] | 34 | mytoons: results[0] | ... | ... |
... | @@ -3,19 +3,18 @@ var router = express.Router(); | ... | @@ -3,19 +3,18 @@ var router = express.Router(); |
3 | 3 | ||
4 | function addMyToons(id,index,cb){ | 4 | function addMyToons(id,index,cb){ |
5 | connection.query("INSERT INTO user_toon_relation SET ?;", {user_id : id,toon_index : index},function (err) { | 5 | connection.query("INSERT INTO user_toon_relation SET ?;", {user_id : id,toon_index : index},function (err) { |
6 | - | ||
7 | if(err) { | 6 | if(err) { |
8 | throw err; | 7 | throw err; |
9 | console.log("내 웹툰 추가 중 에러!") | 8 | console.log("내 웹툰 추가 중 에러!") |
10 | - } else{ | 9 | + } else { |
11 | - // alert("추가되었습니다.") | 10 | + alert("추가되었습니다.") |
12 | cb(); | 11 | cb(); |
13 | } | 12 | } |
14 | }); | 13 | }); |
15 | } | 14 | } |
16 | 15 | ||
17 | //내툰 수정하기 | 16 | //내툰 수정하기 |
18 | -router.post('/toggle_toon',function(req,res,next){ | 17 | +router.post('/toggle_toon',function(req,res,next) { |
19 | var index = req.body.toon_index; | 18 | var index = req.body.toon_index; |
20 | var id = req.user.user_id; | 19 | var id = req.user.user_id; |
21 | connection.query("SELECT COUNT(*) FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"'", [id,index], function (err, rows,result) { | 20 | connection.query("SELECT COUNT(*) FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"'", [id,index], function (err, rows,result) { |
... | @@ -23,18 +22,18 @@ router.post('/toggle_toon',function(req,res,next){ | ... | @@ -23,18 +22,18 @@ router.post('/toggle_toon',function(req,res,next){ |
23 | console.log("내 웹툰 등록 중 에러!"); | 22 | console.log("내 웹툰 등록 중 에러!"); |
24 | } else { | 23 | } else { |
25 | var count = rows[0]["COUNT(*)"]; | 24 | var count = rows[0]["COUNT(*)"]; |
26 | - if(count>0) {//이미 등록되어 있는 것이라면, | 25 | + if(count > 0) { //이미 등록되어 있는 것이라면, |
27 | connection.query("DELETE FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"';", [id, index],function (err, rows, result) { | 26 | connection.query("DELETE FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"';", [id, index],function (err, rows, result) { |
28 | if(err) { | 27 | if(err) { |
29 | console.log("내 웹툰 제거중 에러!"); | 28 | console.log("내 웹툰 제거중 에러!"); |
30 | throw err; | 29 | throw err; |
31 | } else { | 30 | } else { |
32 | - //alert("제거되었습니다.") | 31 | + alert("제거되었습니다.") |
33 | res.redirect('/setting'); | 32 | res.redirect('/setting'); |
34 | } | 33 | } |
35 | }); | 34 | }); |
36 | } else { | 35 | } else { |
37 | - addMyToons(id,index,function(){ | 36 | + addMyToons(id,index,function() { |
38 | res.redirect('/setting'); | 37 | res.redirect('/setting'); |
39 | }); | 38 | }); |
40 | } | 39 | } |
... | @@ -47,11 +46,11 @@ function getMyToons(id,cb){ | ... | @@ -47,11 +46,11 @@ function getMyToons(id,cb){ |
47 | //mysql5.7 syntax에 맞게 수정 => 로그인한 유저의 | 46 | //mysql5.7 syntax에 맞게 수정 => 로그인한 유저의 |
48 | var sqlquery = "SELECT t.toon_index, t.name, t.thum_link, t.webtoon_link, t.week, t.site FROM user u, user_toon_relation ur, toon t WHERE u.id = '"+id+"' && u.id=ur.user_id && t.toon_index=ur.toon_index;"; | 47 | var sqlquery = "SELECT t.toon_index, t.name, t.thum_link, t.webtoon_link, t.week, t.site FROM user u, user_toon_relation ur, toon t WHERE u.id = '"+id+"' && u.id=ur.user_id && t.toon_index=ur.toon_index;"; |
49 | var mylist = new Array(); | 48 | var mylist = new Array(); |
50 | - connection.query(sqlquery,id,function(err,rows,result){ | 49 | + connection.query(sqlquery,id,function(err,rows,result) { |
51 | - if(!err){ | 50 | + if(!err) { |
52 | - mylist=rows; | 51 | + mylist = rows; |
53 | cb(mylist); | 52 | cb(mylist); |
54 | - }else{ | 53 | + } else { |
55 | router.get('/') | 54 | router.get('/') |
56 | console.log("내 웹툰 리스트 가져오는데 실패했습니다!"); | 55 | console.log("내 웹툰 리스트 가져오는데 실패했습니다!"); |
57 | //throw err; | 56 | //throw err; | ... | ... |
... | @@ -60,7 +60,7 @@ | ... | @@ -60,7 +60,7 @@ |
60 | <div class="row"> | 60 | <div class="row"> |
61 | <div class="intro-text"> | 61 | <div class="intro-text"> |
62 | <h1 style="font-family:Gugi">니툰내툰</h1> | 62 | <h1 style="font-family:Gugi">니툰내툰</h1> |
63 | - <p> NAVER / DAUM / Lezhin </p> | 63 | + <p> NAVER / DAUM </p> |
64 | <a href="#about" class="btn btn-custom btn-lg page-scroll">All the Webtoons</a> | 64 | <a href="#about" class="btn btn-custom btn-lg page-scroll">All the Webtoons</a> |
65 | </div> | 65 | </div> |
66 | </div> | 66 | </div> |
... | @@ -110,54 +110,13 @@ | ... | @@ -110,54 +110,13 @@ |
110 | <img src ='/images/daumicon.png' width="90" height="90" onclick="daum_click" /> | 110 | <img src ='/images/daumicon.png' width="90" height="90" onclick="daum_click" /> |
111 | </a> | 111 | </a> |
112 | 112 | ||
113 | - <div style="display:none" id="Daum_webtoons"> | 113 | + <div id="Daum_webtoons" style="display:none"> |
114 | - <table> | ||
115 | - <%var current = ""; | ||
116 | - for(webtoon in list){ | ||
117 | - if(current!=list[webtoon].week && list[webtoon].site == 'daum'){ | ||
118 | - if(current!=""){ | ||
119 | - %> | ||
120 | - </tr> | ||
121 | - <% } %> | ||
122 | - <tr> | ||
123 | - <th> | ||
124 | - <% = list[webtoon].week %> | ||
125 | - </th> | ||
126 | - <% } %> | ||
127 | - <% | ||
128 | - if(list[webtoon].site == 'daum'){ | ||
129 | - %> | ||
130 | - <td> | ||
131 | - <a href="<%= list[webtoon].webtoon_link %>"> | ||
132 | - <img alt="img" width="83" height="90" src="<%= list[webtoon].thum_link %>"/> | ||
133 | - </a> | ||
134 | - <% = list[webtoon].name %> | ||
135 | - </td> | ||
136 | - <% } %> | ||
137 | - | ||
138 | - <% if(current!=list[webtoon].week){ | ||
139 | - current = list[webtoon].week; | ||
140 | - } | ||
141 | - } | ||
142 | - %> | ||
143 | - </tr> | ||
144 | - </table> | ||
145 | - </div> | ||
146 | - | ||
147 | - <font size = 30> | ||
148 | - 네이버 웹툰 | ||
149 | - </font> | ||
150 | - <a onclick="Naver_webtoons.style.display=(Naver_webtoons.style.display=='none')?'block':'none';" href="javascript:void(0)"> | ||
151 | - <img src ='/images/navericon.png' width="90" height="90"/> | ||
152 | - </a> | ||
153 | - | ||
154 | - <div id="Naver_webtoons" style = "display:none"> | ||
155 | <table> | 114 | <table> |
156 | <% | 115 | <% |
157 | var current = ""; | 116 | var current = ""; |
158 | for(webtoon in list){ | 117 | for(webtoon in list){ |
159 | 118 | ||
160 | - if(current!=list[webtoon].week && list[webtoon].site == 'naver'){ | 119 | + if(current!=list[webtoon].week && list[webtoon].site == 'daum'){ |
161 | if(current!=""){ | 120 | if(current!=""){ |
162 | %> | 121 | %> |
163 | </tr> | 122 | </tr> |
... | @@ -166,7 +125,7 @@ | ... | @@ -166,7 +125,7 @@ |
166 | <th><%= list[webtoon].week %></th> | 125 | <th><%= list[webtoon].week %></th> |
167 | <% } %> | 126 | <% } %> |
168 | <% | 127 | <% |
169 | - if(list[webtoon].site == 'naver') | 128 | + if(list[webtoon].site == 'daum') |
170 | { | 129 | { |
171 | %> | 130 | %> |
172 | <td> | 131 | <td> |
... | @@ -193,17 +152,18 @@ | ... | @@ -193,17 +152,18 @@ |
193 | </div> | 152 | </div> |
194 | 153 | ||
195 | <font size = 30> | 154 | <font size = 30> |
196 | - 레진 웹툰 | 155 | + 네이버 웹툰 |
197 | </font> | 156 | </font> |
198 | - <a onclick="Lezhin_webtoons.style.display=(Lezhin_webtoons.style.display=='none')?'block':'none';" href="javascript:void(0)"> | 157 | + <a onclick="Naver_webtoons.style.display=(Naver_webtoons.style.display=='none')?'block':'none';" href="javascript:void(0)"> |
199 | - <img src ='/images/lezhinicon.png' width="90" height="90"/> | 158 | + <img src ='/images/navericon.png' width="90" height="90"/> |
200 | </a> | 159 | </a> |
201 | 160 | ||
202 | - <div id="Lezhin_webtoons" style = "display:none"> | 161 | + <div id="Naver_webtoons" style = "display:none"> |
203 | <table> | 162 | <table> |
204 | <% | 163 | <% |
205 | var current = ""; | 164 | var current = ""; |
206 | for(webtoon in list){ | 165 | for(webtoon in list){ |
166 | + | ||
207 | if(current!=list[webtoon].week && list[webtoon].site == 'naver'){ | 167 | if(current!=list[webtoon].week && list[webtoon].site == 'naver'){ |
208 | if(current!=""){ | 168 | if(current!=""){ |
209 | %> | 169 | %> |
... | @@ -229,14 +189,15 @@ | ... | @@ -229,14 +189,15 @@ |
229 | <% | 189 | <% |
230 | if(current!=list[webtoon].week) { | 190 | if(current!=list[webtoon].week) { |
231 | current = list[webtoon].week; | 191 | current = list[webtoon].week; |
192 | + %> | ||
193 | + | ||
194 | + <% | ||
232 | } | 195 | } |
233 | } | 196 | } |
234 | %> | 197 | %> |
235 | </tr> | 198 | </tr> |
236 | </table> | 199 | </table> |
237 | </div> | 200 | </div> |
238 | - </ul> | ||
239 | - | ||
240 | </div> | 201 | </div> |
241 | </div> | 202 | </div> |
242 | </div> | 203 | </div> | ... | ... |
-
Please register or login to post a comment