윤혜원

다른 사용자의 내툰리스트를 볼 수 있는 니툰 기능 구현 완료!

This diff is collapsed. Click to expand it.
...@@ -10,6 +10,7 @@ var request = require('request'); ...@@ -10,6 +10,7 @@ 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 var mytoons = require('./routes/mytoons'); 12 var mytoons = require('./routes/mytoons');
13 +var yourtoons=require('./routes/yourtoons');
13 var passport = require('passport'); 14 var passport = require('passport');
14 var setting = require('./routes/setting'); 15 var setting = require('./routes/setting');
15 var session = require('express-session'); 16 var session = require('express-session');
...@@ -59,7 +60,7 @@ app.use('/', index); ...@@ -59,7 +60,7 @@ app.use('/', index);
59 app.use('/users', users); 60 app.use('/users', users);
60 app.use('/mytoons', mytoons); 61 app.use('/mytoons', mytoons);
61 app.use('/setting', setting); 62 app.use('/setting', setting);
62 -app.use('/toonviewer', toonviewer); 63 +app.use('/yourtoons', yourtoons);
63 //app.use(express.static('views')); 64 //app.use(express.static('views'));
64 65
65 // catch 404 and forward to error handler 66 // catch 404 and forward to error handler
......
...@@ -4,9 +4,6 @@ var request = require('request'); ...@@ -4,9 +4,6 @@ var request = require('request');
4 var async = require('async'); 4 var async = require('async');
5 var router = express.Router(); 5 var router = express.Router();
6 6
7 -function getUpdatedToons(cb){
8 -}
9 -
10 function getMyToons(id,cb){ 7 function getMyToons(id,cb){
11 //id 값을 가진 user가 저장한 웹툰들 가져오기 8 //id 값을 가진 user가 저장한 웹툰들 가져오기
12 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;"; 9 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;";
......
1 +var express = require('express');
2 +var cheerio = require('cheerio');
3 +var request = require('request');
4 +var async = require('async');
5 +var router = express.Router();
6 +
7 +function getYourToons(id,cb){
8 + //현재 로그인한 유저가 아닌 다른 유저들의 내툰리스트 가져오기
9 + var sqlquery = "SELECT u.id, 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;";
10 + var yourlist = new Array();
11 + connection.query(sqlquery,id,function(err,rows,result){
12 + if(!err){
13 + yourlist=rows;
14 + cb(yourlist);
15 + console.log(yourlist);
16 + }else{
17 + console.log("니툰 리스트 가져오는데 실패했습니다!");
18 + //throw err;
19 + }
20 + });
21 +}
22 +
23 +/* GET home page. */
24 +router.get('/', function(req, res, next) {
25 + if(!req.isAuthenticated()){
26 + res.redirect('/');
27 + }else{
28 + async.series(
29 + [
30 + function(callback){
31 + getYourToons(req.user.user_id, function (yourtoon_list) {
32 + callback(null,yourtoon_list);
33 + });
34 + }
35 + ],
36 + function(err, results){
37 + res.render('yourtoons', {
38 + yourtoons: results[0]
39 + });
40 + }
41 + );
42 + }
43 +});
44 +
45 +module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
60 <ul class="nav navbar-nav navbar-right"> 60 <ul class="nav navbar-nav navbar-right">
61 <li><a href="#mylist" class="page-scroll">MyList</a></li> 61 <li><a href="#mylist" class="page-scroll">MyList</a></li>
62 <li><a href="/setting/"><!--<img src = "/images/basket.png" height="50" witdh="50">-->웹툰 담기</a> 62 <li><a href="/setting/"><!--<img src = "/images/basket.png" height="50" witdh="50">-->웹툰 담기</a>
63 + <li><a href="/yourtoons/">OtherList</a>
63 <li><a href="/auth/logout/kakao" class="page-scroll">Logout</a></li> 64 <li><a href="/auth/logout/kakao" class="page-scroll">Logout</a></li>
64 </ul> 65 </ul>
65 </div> 66 </div>
......
...@@ -132,8 +132,6 @@ ...@@ -132,8 +132,6 @@
132 </table> 132 </table>
133 </form> 133 </form>
134 </div> 134 </div>
135 -
136 -
137 <a onclick="navertoons.style.display=(navertoons.style.display=='none')?'block':'none';" href="javascript:void(0)"> 135 <a onclick="navertoons.style.display=(navertoons.style.display=='none')?'block':'none';" href="javascript:void(0)">
138 <img src ='/images/navericon.png' width="83" height="90"/> 136 <img src ='/images/navericon.png' width="83" height="90"/>
139 </a> 137 </a>
...@@ -179,7 +177,6 @@ ...@@ -179,7 +177,6 @@
179 } 177 }
180 %> 178 %>
181 </tr> 179 </tr>
182 -
183 </table> 180 </table>
184 </form> 181 </form>
185 </div> 182 </div>
......
1 +<!DOCTYPE html>
2 +<html>
3 +<head>
4 + <title>니툰</title>
5 + <link rel='stylesheet' href='/stylesheets/style2.css' />
6 + <<!-- Bootstrap -->
7 + <link rel="stylesheet" type="text/css" href="/stylesheets/bootstrap.css">
8 + <link rel="stylesheet" type="text/css" href="/stylesheets/font-awesome.css">
9 +
10 + <!-- Stylesheet
11 + ================================================== -->
12 + <link rel="stylesheet" type="text/css" href="/stylesheets/style.css">
13 + <link rel="stylesheet" type="text/css" href="/stylesheets/nivo-lightbox/nivo-lightbox.css">
14 + <link rel="stylesheet" type="text/css" href="/stylesheets/nivo-lightbox/default.css">
15 + <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,600,700" rel="stylesheet">
16 + <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
17 + <link href="https://fonts.googleapis.com/css?family=Dancing+Script:400,700" rel="stylesheet">
18 + <link href="https://fonts.googleapis.com/css?family=Gugi&amp;subset=korean" rel="stylesheet">
19 +
20 + <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
21 + <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
22 + <!--[if lt IE 9]>
23 + <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
24 + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
25 + <![endif]-->
26 + <style>
27 + .toon_name,.toon_thumbnail{
28 + width:10%;
29 + }
30 +
31 + td{
32 + vertical-align: middle;
33 + border-bottom: 1px solid #bcbcbc;
34 + border-left: 1px solid #bcbcbc;
35 + border-right: 1px solid #bcbcbc;
36 + margin:0;
37 + Text-align:center;
38 + }
39 + table{
40 + border-collapse:collapse;
41 + border: 2px solid #474747;
42 + }
43 + th{
44 + border-bottom:2px solid #474747;
45 + }
46 + </style>
47 +
48 +</head>
49 +<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
50 +<!-- Navigation
51 + ==========================================-->
52 +<nav id="menu" class="navbar navbar-default navbar-fixed-top">
53 + <div class="container">
54 + <!-- Brand and toggle get grouped for better mobile display -->
55 + <div class="navbar-header">
56 + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
57 + <a class="navbar-brand page-scroll" href="#page-top" style="font-family:Gugi">니툰</a> </div>
58 + <!-- Collect the nav links, forms, and other content for toggling -->
59 + <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
60 + <ul class="nav navbar-nav navbar-right">
61 + <li><a href="#mylist" class="page-scroll">OtherList</a></li>
62 + <li><a href="/mytoons" class="page-scroll">MyList</a></li>
63 + <li><a href="/auth/logout/kakao" class="page-scroll">Logout</a></li>
64 + </ul>
65 + </div>
66 + <!-- /.navbar-collapse -->
67 + </div>
68 +</nav>
69 +
70 +<table>
71 + <tr>
72 + <th>썸네일</th>
73 + <th>웹툰명</th>
74 + <th>요일</th>
75 + <th>사이트</th>
76 + <th>바로가기</th>
77 + </tr>
78 + <!--로그인한 회원이 내툰에 웹툰이 없을시-->
79 + <%if (yourtoons.length==0){
80 + %>
81 + <th>니툰리스트에 웹툰이 없습니다! </th>
82 + <%}%>
83 + <% for(i=0;i<yourtoons.length; i++){
84 + %><tr>
85 + <td class="toon_name"><%= yourtoons[i].id %></td>
86 + <td class="toon_thumbnail"><image src="<%= yourtoons[i].thum_link%>"/></td>
87 + <td class="toon_name"><%= yourtoons[i].name %></td>
88 + <td class="week"><%= yourtoons[i].week.toLowerCase() %></td>
89 + <td class="site"><%= yourtoons[i].site %></td>
90 + <td class="webtoon_link"><a href="<%=yourtoons[i].webtoon_link%>">바로가기</a></td>
91 +
92 + </td>
93 +
94 + </tr>
95 + <% } %>
96 +
97 +</table>
98 +
99 +</br>
100 +
101 +
102 +</body>
103 +
104 +</html>