윤혜원

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

This diff is collapsed. Click to expand it.
......@@ -10,6 +10,7 @@ var request = require('request');
var index = require('./routes/index');
var users = require('./routes/users');
var mytoons = require('./routes/mytoons');
var yourtoons=require('./routes/yourtoons');
var passport = require('passport');
var setting = require('./routes/setting');
var session = require('express-session');
......@@ -59,7 +60,7 @@ app.use('/', index);
app.use('/users', users);
app.use('/mytoons', mytoons);
app.use('/setting', setting);
app.use('/toonviewer', toonviewer);
app.use('/yourtoons', yourtoons);
//app.use(express.static('views'));
// catch 404 and forward to error handler
......
......@@ -4,9 +4,6 @@ var request = require('request');
var async = require('async');
var router = express.Router();
function getUpdatedToons(cb){
}
function getMyToons(id,cb){
//id 값을 가진 user가 저장한 웹툰들 가져오기
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;";
......
var express = require('express');
var cheerio = require('cheerio');
var request = require('request');
var async = require('async');
var router = express.Router();
function getYourToons(id,cb){
//현재 로그인한 유저가 아닌 다른 유저들의 내툰리스트 가져오기
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;";
var yourlist = new Array();
connection.query(sqlquery,id,function(err,rows,result){
if(!err){
yourlist=rows;
cb(yourlist);
console.log(yourlist);
}else{
console.log("니툰 리스트 가져오는데 실패했습니다!");
//throw err;
}
});
}
/* GET home page. */
router.get('/', function(req, res, next) {
if(!req.isAuthenticated()){
res.redirect('/');
}else{
async.series(
[
function(callback){
getYourToons(req.user.user_id, function (yourtoon_list) {
callback(null,yourtoon_list);
});
}
],
function(err, results){
res.render('yourtoons', {
yourtoons: results[0]
});
}
);
}
});
module.exports = router;
\ No newline at end of file
This diff is collapsed. Click to expand it.
......@@ -60,6 +60,7 @@
<ul class="nav navbar-nav navbar-right">
<li><a href="#mylist" class="page-scroll">MyList</a></li>
<li><a href="/setting/"><!--<img src = "/images/basket.png" height="50" witdh="50">-->웹툰 담기</a>
<li><a href="/yourtoons/">OtherList</a>
<li><a href="/auth/logout/kakao" class="page-scroll">Logout</a></li>
</ul>
</div>
......
......@@ -132,8 +132,6 @@
</table>
</form>
</div>
<a onclick="navertoons.style.display=(navertoons.style.display=='none')?'block':'none';" href="javascript:void(0)">
<img src ='/images/navericon.png' width="83" height="90"/>
</a>
......@@ -179,7 +177,6 @@
}
%>
</tr>
</table>
</form>
</div>
......
<!DOCTYPE html>
<html>
<head>
<title>니툰</title>
<link rel='stylesheet' href='/stylesheets/style2.css' />
<<!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="/stylesheets/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/stylesheets/font-awesome.css">
<!-- Stylesheet
================================================== -->
<link rel="stylesheet" type="text/css" href="/stylesheets/style.css">
<link rel="stylesheet" type="text/css" href="/stylesheets/nivo-lightbox/nivo-lightbox.css">
<link rel="stylesheet" type="text/css" href="/stylesheets/nivo-lightbox/default.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,500,600,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Dancing+Script:400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Gugi&amp;subset=korean" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
.toon_name,.toon_thumbnail{
width:10%;
}
td{
vertical-align: middle;
border-bottom: 1px solid #bcbcbc;
border-left: 1px solid #bcbcbc;
border-right: 1px solid #bcbcbc;
margin:0;
Text-align:center;
}
table{
border-collapse:collapse;
border: 2px solid #474747;
}
th{
border-bottom:2px solid #474747;
}
</style>
</head>
<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
<!-- Navigation
==========================================-->
<nav id="menu" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<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>
<a class="navbar-brand page-scroll" href="#page-top" style="font-family:Gugi">니툰</a> </div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a href="#mylist" class="page-scroll">OtherList</a></li>
<li><a href="/mytoons" class="page-scroll">MyList</a></li>
<li><a href="/auth/logout/kakao" class="page-scroll">Logout</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</nav>
<table>
<tr>
<th>썸네일</th>
<th>웹툰명</th>
<th>요일</th>
<th>사이트</th>
<th>바로가기</th>
</tr>
<!--로그인한 회원이 내툰에 웹툰이 없을시-->
<%if (yourtoons.length==0){
%>
<th>니툰리스트에 웹툰이 없습니다! </th>
<%}%>
<% for(i=0;i<yourtoons.length; i++){
%><tr>
<td class="toon_name"><%= yourtoons[i].id %></td>
<td class="toon_thumbnail"><image src="<%= yourtoons[i].thum_link%>"/></td>
<td class="toon_name"><%= yourtoons[i].name %></td>
<td class="week"><%= yourtoons[i].week.toLowerCase() %></td>
<td class="site"><%= yourtoons[i].site %></td>
<td class="webtoon_link"><a href="<%=yourtoons[i].webtoon_link%>">바로가기</a></td>
</td>
</tr>
<% } %>
</table>
</br>
</body>
</html>