Akhidjon

merging

dd
\ No newline at end of file
니툰내툰 URL : http://52.79.239.80:3000
2013100924 이현종
2018102151 Abdullaev Akhidjon
1. 네이버, 구글 로그인을 추가하였습니다.
2. 레진 코믹스 웹툰을 추가하였습니다.
3. 코드의 생산성을 증가시켰습니다.
(코드의 중복과 필요없는 부분을 삭제함, 주석을 달음)
......@@ -47,7 +47,6 @@ var mytoons = require('./routes/mytoons');
var yourtoons =require('./routes/yourtoons');
var setting = require('./routes/setting');
// 최초 로그인 성공시 (Strategy 성공시) 단 한번만 호출
passport.serializeUser(function(user, done) {
console.log('serialized');
......
......@@ -9,27 +9,27 @@ var NaverStrategy = require('passport-naver').Strategy;
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var router = express.Router();
// 설명
// kakao login API
var kakaoKey = {
clientID : '5634a5f8ca5c9a5eb378d6b6e6e869a0',
callbackURL : '/auth/login/kakao/callback'
};
//
// naver login API
var naverKey = {
clientID : 'OHmCrpQuVFnIEB4GkmF_',
callbackURL : '/auth/login/naver/callback',
clientSecret : 'BBgcRdnj0M'
};
//
// google login API
var googleKey = {
clientID : '924802195853-ir977i2ohnddaaninlqlbeg6sov629hq.apps.googleusercontent.com',
callbackURL : '/auth/login/google/callback',
clientSecret : 'NaWeoJouUzYq4VfBesTkdUfA'
};
//
// kakao passport
passport.use(new KakaoStrategy(kakaoKey,
function(accessToken, refreshToken,params, profile, done) {
console.log(profile);
......@@ -41,7 +41,7 @@ passport.use(new KakaoStrategy(kakaoKey,
}
));
//
// naver passport
passport.use(new NaverStrategy(naverKey,
function (accessToken, refreshToken, profile, done) {
console.log(profile);
......@@ -53,7 +53,7 @@ passport.use(new NaverStrategy(naverKey,
}
));
//
// google passport
passport.use(new GoogleStrategy(googleKey,
function (accessToken, refreshToken, profile, done) {
console.log(profile);
......@@ -73,10 +73,9 @@ router.get('/auth/login/kakao/callback', passport.authenticate('kakao', {
})
);
// naver 로그인
// naver 로그인, 로그인 콜백
router.get('/auth/login/naver', passport.authenticate('naver'));
router.get('/auth/login/naver/callback',
passport.authenticate('naver', {
router.get('/auth/login/naver/callback', passport.authenticate('naver', {
successRedirect: '/mytoons',
failureRedirect: '/'
})
......@@ -90,7 +89,7 @@ router.get('/auth/login/google/callback', passport.authenticate('google', {
})
);
// 설명
// 로그인 처리
function loginByThirdparty(info, done) {
var stmt_duplicated = "select *from `user` where id = id";
//'select *from `user` where `id` = ?
......@@ -125,7 +124,7 @@ function loginByThirdparty(info, done) {
});
}
router.get('/login', function(req,res){
router.get('/login', function(req,res) {
res.render('login_page')
})
......@@ -175,20 +174,27 @@ function gettop(){
};
function getDaumToons(_day){
// X요일 다음 웹툰
var daumCount = 0;
//_day요일의 다음웹툰 불러오기
function getDaumToons(_day) {
var day = _day;
var day_name = day;
var daum = `http://webtoon.daum.net/data/pc/webtoon/list_serialized/${day}?timeStamp=1515819276574`;
var site = 'daum';
client.fetch(daum, {}, function (err, $, res, body) {
client.fetch(daum, {}, function (err, $, res, body){
var data = JSON.parse(body);
var list = data["data"];
if(err) {
console.log("다음웹툰 DB 에러 : " + err);
} else {
list.forEach(function (item, idx) {
<<<<<<< HEAD
var webtoon_link = 'http://webtoon.daum.net/webtoon/view/' + item.nickname.toString();
var webtoon = {
toon_index : item.id,
......@@ -202,14 +208,35 @@ function getDaumToons(_day){
};
allWebtoonList.push(webtoon);
=======
var webtoon_link = 'http://webtoon.daum.net/webtoon/view/' + item.nickname.toString();
var webtoon = {
toon_index : item.id,
name : item.title,
thum_link : item.pcThumbnailImage.url,
webtoon_link : webtoon_link,
week : day_name,
site : site,
latest : 0
};
daumCount++;
allWebtoonList.push(webtoon);
>>>>>>> 0b039040370950fe61e1c6ae5d5cf6650db9652f
});
}
});
}
//
function getNaverToons(){
// 네이버 전체 웹툰 불러오기
function getNaverToons() {
var allWeeklyToonsUrl = "http://comic.naver.com/webtoon/weekday.nhn";
// 네이버 웹툰 개수
var naverCount = 0;
var webtoonCount = 0;
request(allWeeklyToonsUrl,function (err, res, html) {
<<<<<<< HEAD
if(!err){
var $ = cheerio.load(html);
var p = Promise.resolve();
......@@ -247,11 +274,54 @@ function getNaverToons(){
}
});
})
=======
if(!err){
var $ = cheerio.load(html);
var p = Promise.resolve();
var eachs = $(".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 titleid = webtoon_link.split('?')[1].split('&')[0].split('=')[1];
var site = 'naver';
var webtoon= {
toon_index: titleid,
name : name,
thum_link : thumb_link,
webtoon_link : webtoon_link,
week : week,
site : site,
latest : 0
};
naverCount++;
allWebtoonList.push(webtoon);
});
p.then(function() {
i = 0;
allWebtoonList.forEach(function (webtoon) {
var sql= "INSERT INTO `toon` (toon_index, name, thum_link, webtoon_link, week, site, latest) VALUES(?) ON DUPLICATE KEY UPDATE latest=latest";
var values=[webtoon.toon_index, webtoon.name, webtoon.thum_link, webtoon.webtoon_link,webtoon.week, webtoon.site, webtoon.latest];
connection.query(sql,[values],function(err,result){
if(err) {
console.log("웹툰 DB 에러 : " + err);
} else {
webtoonCount++;
console.log(`웹툰 ${webtoonCount}개 DB처리 완료!`);
}
>>>>>>> 0b039040370950fe61e1c6ae5d5cf6650db9652f
});
})
});
}
console.log(`다음웹툰 ${daumCount}개, 네이버웹툰 ${naverCount}개`)
});
}
<<<<<<< HEAD
......@@ -261,6 +331,9 @@ function getTomicsToons(){
}
// 설명
=======
// 모든 웹툰을 담고있는 배열
>>>>>>> 0b039040370950fe61e1c6ae5d5cf6650db9652f
allWebtoons = new Array();
// 설명
......
......@@ -2,16 +2,16 @@ var express = require('express');
var async = require('async');
var router = express.Router();
function getMyToons(id,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 mylist = new Array();
connection.query(sqlquery,id,function(err,rows,result){
if(!err){
connection.query(sqlquery,id,function(err,rows,result) {
if(!err) {
mylist=rows;
cb(mylist);
console.log(mylist);
}else{
} else {
console.log("내 웹툰 리스트 가져오는데 실패했습니다!");
//throw err;
}
......@@ -20,17 +20,15 @@ function getMyToons(id,cb){
/* GET home page. */
router.get('/', function(req, res, next) {
if(!req.isAuthenticated()){
if(!req.isAuthenticated()) {
res.redirect('/');
}else{
async.series(
[
} else {
async.series([
function(callback){
getMyToons(req.user.user_id, function (mytoon_list) {
callback(null,mytoon_list);
});
}
],
}],
function(err, results){
res.render('mytoons', {
mytoons: results[0]
......
......@@ -3,19 +3,18 @@ var router = express.Router();
function addMyToons(id,index,cb){
connection.query("INSERT INTO user_toon_relation SET ?;", {user_id : id,toon_index : index},function (err) {
if(err) {
throw err;
console.log("내 웹툰 추가 중 에러!")
} else{
// alert("추가되었습니다.")
} else {
alert("추가되었습니다.")
cb();
}
});
}
//내툰 수정하기
router.post('/toggle_toon',function(req,res,next){
router.post('/toggle_toon',function(req,res,next) {
var index = req.body.toon_index;
var id = req.user.user_id;
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){
console.log("내 웹툰 등록 중 에러!");
} else {
var count = rows[0]["COUNT(*)"];
if(count>0) {//이미 등록되어 있는 것이라면,
if(count > 0) { //이미 등록되어 있는 것이라면,
connection.query("DELETE FROM user_toon_relation WHERE user_id='"+id+"' && toon_index='"+index+"';", [id, index],function (err, rows, result) {
if(err) {
console.log("내 웹툰 제거중 에러!");
throw err;
} else {
//alert("제거되었습니다.")
alert("제거되었습니다.")
res.redirect('/setting');
}
});
} else {
addMyToons(id,index,function(){
addMyToons(id,index,function() {
res.redirect('/setting');
});
}
......@@ -47,11 +46,11 @@ function getMyToons(id,cb){
//mysql5.7 syntax에 맞게 수정 => 로그인한 유저의
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 mylist = new Array();
connection.query(sqlquery,id,function(err,rows,result){
if(!err){
mylist=rows;
connection.query(sqlquery,id,function(err,rows,result) {
if(!err) {
mylist = rows;
cb(mylist);
}else{
} else {
router.get('/')
console.log("내 웹툰 리스트 가져오는데 실패했습니다!");
//throw err;
......
......@@ -7,8 +7,7 @@
<link rel="stylesheet" type="text/css" href="/stylesheets/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/stylesheets/font-awesome.css">
<!-- Stylesheet
================================================== -->
<!-- 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">
......@@ -17,15 +16,13 @@
<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">
<script src="http://developers.kakao.com/sdk/js/kakao.min.js">
function daum_click()
{
function daum_click(){
if(Daum_webtoons.display == "none")
Daum_webtoons.display == "block";
if(Daum_webtoons.display = "block")
Daum_webtoons.display == "none";
}
function naver_click()
{
function naver_click(){
if(Naver_webtoons.display == "none")
Naver_webtoons.display == "block";
if(Naver_webtoons.display = "block")
......@@ -40,8 +37,10 @@
<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>
<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">
......@@ -60,10 +59,10 @@
<div class="container">
<div class="row">
<div class="intro-text">
<h1 style="font-family:Gugi">니툰내툰</h1>
<p> NAVER / DAUM / WEBTOONS </p>
<a href="#about" class="btn btn-custom btn-lg page-scroll">All the Webtoons</a> </div>
<p> NAVER / DAUM </p>
<a href="#about" class="btn btn-custom btn-lg page-scroll">All the Webtoons</a>
</div>
</div>
</div>
</div>
......@@ -75,30 +74,134 @@
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-6 ">
<div class="about-img"><img src="images/toon.png" class="img-responsive" alt=""></div>
<div class="about-img"><img src="images/toon.png" class="img-responsive" alt="">
</div>
</div>
<div class="col-xs-12 col-md-6">
<div class="about-text">
<h2>Our Term-Project</h2>
<hr>
<!--수정해주세욤!-->
<p>마더 프로젝트 니툰내툰(YTMT)를 개선하는 프로젝트입니다. 네이버 웹툰 뿐만 아니라 다음 웹툰도 담을 수 있으며, 타인이 담은 웹툰도 확인할 수 있습니다.</p>
<h3>Programmers</h3>
<hr><p>마더프로젝트 니툰내툰을 개선하는 프로젝트입니다. 네이버웹툰, 다음웹툰, 레진웹툰을 담을 수 있으며 다른 사용자가 담은 웹툰도 확인할 수 있습니다.</p>
<h3>Developers</h3>
<p>2013100924 이현종, 2018102151 Abdullaev Akhidjon</p>
</div>
</div>
</div>
</div>
</div>
<!-- Portfolio Section -->
<div id="portfolio">
<div class="section-title text-center center">
<div class="overlay">
<h2>Gallery</h2>
<hr>
<p>니툰내툰에서 제공하는 웹툰 리스트입니다</p>
<hr><p>니툰내툰에서 제공하는 웹툰 리스트입니다</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="categories">
<ul class="cat">
<font size = 30>
다음 웹툰
</font>
<a onclick="Daum_webtoons.style.display=(Daum_webtoons.style.display=='none')?'block':'none';" href="javascript:void(0)">
<img src ='/images/daumicon.png' width="90" height="90" onclick="daum_click" />
</a>
<div id="Daum_webtoons" style="display:none">
<table>
<%
var current = "";
for(webtoon in list){
if(current!=list[webtoon].week && list[webtoon].site == 'daum'){
if(current!=""){
%>
</tr>
<% } %>
<tr>
<th><%= list[webtoon].week %></th>
<% } %>
<%
if(list[webtoon].site == 'daum')
{
%>
<td>
<a href="<%= list[webtoon].webtoon_link %>">
<img alt="img" width="83" height="90" src="<%= list[webtoon].thum_link %>"/>
</a>
<%= list[webtoon].name %>
</td>
<%
}
%>
<%
if(current!=list[webtoon].week) {
current = list[webtoon].week;
%>
<%
}
}
%>
</tr>
</table>
</div>
<font size = 30>
네이버 웹툰
</font>
<a onclick="Naver_webtoons.style.display=(Naver_webtoons.style.display=='none')?'block':'none';" href="javascript:void(0)">
<img src ='/images/navericon.png' width="90" height="90"/>
</a>
<div id="Naver_webtoons" style = "display:none">
<table>
<%
var current = "";
for(webtoon in list){
if(current!=list[webtoon].week && list[webtoon].site == 'naver'){
if(current!=""){
%>
</tr>
<% } %>
<tr>
<th><%= list[webtoon].week %></th>
<% } %>
<%
if(list[webtoon].site == 'naver')
{
%>
<td>
<a href="<%= list[webtoon].webtoon_link %>">
<img alt="img" width="83" height="90" src="<%= list[webtoon].thum_link %>"/>
</a>
<%= list[webtoon].name %>
</td>
<%
}
%>
<%
if(current!=list[webtoon].week) {
current = list[webtoon].week;
%>
<%
}
}
%>
</tr>
</table>
</div>
</div>
</div>
</div>
<<<<<<< HEAD
<div class="container">
<div class="row">
<div class="categories">
......@@ -207,6 +310,8 @@
</br>
</div>
=======
</div>
>>>>>>> 0b039040370950fe61e1c6ae5d5cf6650db9652f
</body>
</html>
......
<!DOCTYPE html>
<html>
<head>
<head>
<title>내툰</title>
<link rel='stylesheet' href='/stylesheets/style2.css' />
<<<<<<< HEAD
<!-- Bootstrap -->
=======
<<!-- Bootstrap -->
>>>>>>> 0b039040370950fe61e1c6ae5d5cf6650db9652f
<link rel="stylesheet" type="text/css" href="/stylesheets/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/stylesheets/font-awesome.css">
<!-- Stylesheet
================================================== -->
<!-- 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">
......@@ -16,63 +20,28 @@
<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">
<!--===============================================================================================-->
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/perfect-scrollbar/perfect-scrollbar.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="stylesheets/util.css">
<link rel="stylesheet" type="text/css" href="stylesheets/main.css">
<!--===============================================================================================-->
<!-- 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>
</head>
<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
<body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
<!-- Navigation
==========================================-->
<!-- Navigation==========================================-->
<div class="nabvar">
<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>
<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">
......@@ -86,14 +55,15 @@
</div>
</nav>
</div>
<div id="mylist">
<div id="mylist">
<div class="section-title text-center center">
<div class="overlay">
<h2>내툰</h2>
<hr>
<p>웹툰 담기를 통해 담은 웹툰들의 리스트입니다</p>
<hr><p>웹툰 담기를 통해 담은 웹툰들의 리스트입니다</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="categories">
......@@ -115,15 +85,13 @@
</thead>
</table>
</div>
<div class ="table100-body js-pscroll">
<table>
<%if (mytoons.length==0){
%>
<%if(mytoons.length==0){ %>
<th>내툰리스트에 웹툰이 없습니다! 수정하기 버튼을 눌러서 추가하세요!</th>
<%}%>
<% for(i=0;i
<mytoons.length; i++){
%>
<% for(i=0;i<mytoons.length; i++){%>
<tr>
<td class="cell100 column1"><image src="<%= mytoons[i].thum_link%>" /></td>
<td class="cell100 column2"><%= mytoons[i].name %></td>
......@@ -188,19 +156,17 @@
{ %>업데이트됨
<%} %>
</td>
</tr>
<% } %>
</table>
</div></br>
</div>
</br>
</div>
</div>
</div>
</div>
</body>
</div>
</div>
</div>
</div>
</body>
</html>
......