한요섭

1205

......@@ -8,12 +8,90 @@ var fs = require('fs');
var client_id = 'Lqxd8LWDGMYTe9YWJPBb';
var client_secret = '9HrBpH8oy1';
app.get('/', function(req, res){
fs.readFile('fb_login.ejs', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/html '});
res.end(data);
});
});
app.use('/', express.static(__dirname + '/../public'));
app.get('/errata', function (req, res) {
var api_url = 'https://openapi.naver.com/v1/search/errata.json?query=' + encodeURI(req.query.query); // json 결과
var request = require('request');
console.log(req.query.query);
console.log(req.query);
var options = {
url: api_url,
headers: {'X-Naver-Client-Id':'3VmmpKXfOwySxf5ONdKM', 'X-Naver-Client-Secret': 'q0xaSGu8Vl'}
};
request.get(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
res.writeHead(200, {'Content-Type': 'text/json;charset=utf-8'});
console.log(body);
res.end(body);
} else {
res.status(response.statusCode).end();
console.log('error = ' + response.statusCode);
}
});
});
app.get('/', function(req, res){
fs.readFile('fb_login.ejs', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/html '});
res.end(data);
});
});
app.get('/css/style.css', function(req, res){
fs.readFile('css/style.css', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/css '});
res.end(data);
});
});
app.get('/css/bootstrap.min.css', function(req, res){
fs.readFile('/css/bootstrap.min.css', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/css '});
res.end(data);
});
});
app.get('/css/bootstrap.css', function(req, res){
fs.readFile('/css/bootstrap.css', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/css '});
res.end(data);
});
});
app.get('/css/bootstrap-theme.css', function(req, res){
fs.readFile('/css/bootstrap-theme.css', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/css '});
res.end(data);
});
});
app.get('/css/bootstrap-theme.min.css', function(req, res){
fs.readFile('/css/bootstrap-theme.min.css', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/css '});
res.end(data);
});
});
app.get('/css/bootstrap-theme.css.map', function(req, res){
fs.readFile('/css/bootstrap-theme.css.map', function(error, data){
res.writeHead(200, {'Content-Type' : 'text/css '});
res.end(data);
});
});
app.get('/js/bootstrap.js', function(req, res){
fs.readFile('/js/bootstrap.js', function(error, data){
res.writeHead(200, {'Content-Type' : 'Application/javascript'});
res.end(data);
});
});
app.get('/js/bootstrap.min.js', function(req, res){
fs.readFile('/js/bootstrap.min.js', function(error, data){
res.writeHead(200, {'Content-Type' : 'Application/javascript'});
res.end(data);
});
});
app.get('/js/npm.js', function(req, res){
fs.readFile('/js/npm.js', function(error, data){
res.writeHead(200, {'Content-Type' : 'Application/javascript'});
res.end(data);
});
});
app.get('/imgs/megabox',function (req,res) {
fs.readFile('mega.png', function (error, data) {
......@@ -32,13 +110,36 @@ app.get('/main',function (req,res) {
app.get('/serach',function (req,res) {
var query= req.query;
var genre = query['genre'];
var year = query['year'];
var country = query['country'];
var search = query['search'];
if(genre != ""){
var searchAll = query['searchAll'];
if(genre != null){
var code = get_genre_code(genre);
get_info_using_genre(code,search, res);
}
else if(year != null){
var year_num = get_year_num(year);
get_info_using_year(year_num,search, res);
}
else if(country != null){
var country_real = makeETC(country);
get_info_using_country(country_real,search, res);
}
else if(searchAll != null){
get_info_all(searchAll, res);
}
})
function makeETC(country_input){
var country_input;
if(country_input == "ET"){
country_input = "ETC"
}
return country_input;
}
function get_genre_code(genre_str) {
var genre_num;
switch (genre_str) {
......@@ -71,15 +172,54 @@ function get_genre_code(genre_str) {
break;
default:
}
return genre_num;
}
function get_year_num(year){
var return_year;
switch (year) {
case "1980년대":
return_year = 1980;
break;
case "1990년대":
return_year = 1990;
break;
case "2000년대":
return_year = 2000;
break;
case "2010년대":
return_year = 2010;
break;
}
return return_year;
}
//장르 검색
function get_info_using_genre(code,search, res) {
var en = encodeURI(search);
var api_url = 'https://openapi.naver.com/v1/search/movie.json?query='+en+'&genre=' + code; // json 결과
var api_url = 'https://openapi.naver.com/v1/search/movie.json?query='+en+'&display=100'+'&genre=' + code; // json 결과
var request = require('request');
var options = {
url: api_url,
//headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret}
headers: {'X-Naver-Client-Id':'Lqxd8LWDGMYTe9YWJPBb', 'X-Naver-Client-Secret': '9HrBpH8oy1'}
};
request.get(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var data = JSON.parse(body);
var total = data['total'];
var items = data['items'];
console.log(data);
res.render('movie_info',{item:items});
}
});
}
//연도 검색
function get_info_using_year(year_num,search, res) {
var en = encodeURI(search);
var yearto = year_num+10;
var api_url = 'https://openapi.naver.com/v1/search/movie.json?query='+en+ '&display=100' + '&yearfrom=' + year_num + '&yearto=' + yearto // json 결과
//var api_url = 'https://openapi.naver.com/v1/search/movie.json?query='+en+'&display=100'; // json 결과
var request = require('request');
var options = {
url: api_url,
......@@ -91,35 +231,85 @@ function get_info_using_genre(code,search, res) {
var data = JSON.parse(body);
var total = data['total'];
var items = data['items'];
// var temps = items;
// var j = 0;
// for(var i = 0 ; i < total; i++){
// if(items[i]['pubDate'] >= year && items[i]['pubDate'] <= year+10 ){
// temps[j] = items[i];
// }
// }
console.log(data);
res.render('movie_info',{item:items});
}
});
}
//국가 검색
function get_info_using_country(country,search, res) {
var en = encodeURI(search);
var api_url = 'https://openapi.naver.com/v1/search/movie.json?query='+en+'&display=100'+'&country=' + country; // json 결과
var request = require('request');
var options = {
url: api_url,
//headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret}
headers: {'X-Naver-Client-Id':'Lqxd8LWDGMYTe9YWJPBb', 'X-Naver-Client-Secret': '9HrBpH8oy1'}
};
request.get(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var data = JSON.parse(body);
var total = data['total'];
var items = data['items'];
app.get('/search/movie', function (req, res) {
var api_url = 'https://openapi.naver.com/v1/search/movie.json?query=%EC%A3%BC%EC%8B%9D&display=10&start=1&genre=1' + encodeURI(req.query.query); // json 결과
var request = require('request');
var options = {
url: api_url,
//headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret}
headers: {'X-Naver-Client-Id':'Lqxd8LWDGMYTe9YWJPBb', 'X-Naver-Client-Secret': '9HrBpH8oy1'}
};
request.get(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var data = JSON.parse(body);
var total = data['total'];
var items = data['items'];
res.writeHead(200, {'Content-Type': 'text/json;charset=utf-8'});
// res.end(JSON.stringify(items));
res.end(body);
} else {
res.status(response.statusCode).end();
console.log('error = ' + response.statusCode);
}
});
});
console.log(data);
res.render('movie_info',{item:items});
}
});
}
//전체 검색
// 미정 /미확인 이딴거 두개만 뜸
function get_info_all(searchAll, res) {
var en = encodeURI(searchAll);
var api_url = 'https://openapi.naver.com/v1/search/movie.json?query='+en+'&display=100'; // json 결과
var request = require('request');
var options = {
url: api_url,
//headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret}
headers: {'X-Naver-Client-Id':'Lqxd8LWDGMYTe9YWJPBb', 'X-Naver-Client-Secret': '9HrBpH8oy1'}
};
request.get(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
var data = JSON.parse(body);
var total = data['total'];
var items = data['items'];
console.log(data);
res.render('movie_info',{item:items});
}
});
}
// app.get('/search/movie', function (req, res) {
// var api_url = 'https://openapi.naver.com/v1/search/movie.json?query=%EC%A3%BC%EC%8B%9D&display=10&start=1&genre=1' + encodeURI(req.query.query); // json 결과
// var request = require('request');
// var options = {
// url: api_url,
// //headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret}
// headers: {'X-Naver-Client-Id':'Lqxd8LWDGMYTe9YWJPBb', 'X-Naver-Client-Secret': '9HrBpH8oy1'}
// };
// request.get(options, function (error, response, body) {
// if (!error && response.statusCode == 200) {
// var data = JSON.parse(body);
// var total = data['total'];
// var items = data['items'];
// res.writeHead(200, {'Content-Type': 'text/json;charset=utf-8'});
// // res.end(JSON.stringify(items));
// res.end(body);
// } else {
// res.status(response.statusCode).end();
// console.log('error = ' + response.statusCode);
// }
// });
// });
app.listen(3000, function () {
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
body {
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: center;
background: #E3CAA1;
}
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background: #666; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
@import url(https://fonts.googleapis.com/css?family=Roboto:300);
.login-page {
width: 360px;
padding: 8% 0 0;
margin: auto;
}
.form {
position: relative;
z-index: 1;
background: #FFFFFF;
max-width: 360px;
margin: 0 auto 100px;
padding: 45px;
text-align: center;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
.form input {
font-family: "Roboto", sans-serif;
outline: 0;
background: #f2f2f2;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 14px;
}
.form button {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
outline: 0;
background: #4CAF50;
width: 100%;
border: 0;
padding: 15px;
color: #FFFFFF;
font-size: 14px;
-webkit-transition: all 0.3 ease;
transition: all 0.3 ease;
cursor: pointer;
}
.form button:hover,.form button:active,.form button:focus {
background: #43A047;
}
.form .message {
margin: 15px 0 0;
color: #b3b3b3;
font-size: 12px;
}
.form .message a {
color: #4CAF50;
text-decoration: none;
}
.form .register-form {
display: none;
}
.container {
position: relative;
z-index: 1;
max-width: 300px;
margin: 0 auto;
}
.container:before, .container:after {
content: "";
display: block;
clear: both;
}
.container .info {
margin: 50px auto;
text-align: center;
}
.container .info h1 {
margin: 0 0 15px;
padding: 0;
font-size: 36px;
font-weight: 300;
color: #1a1a1a;
}
.container .info span {
color: #4d4d4d;
font-size: 12px;
}
.container .info span a {
color: #000000;
text-decoration: none;
}
.container .info span .fa {
color: #EF3B3A;
}
body {
background: #76b852; /* fallback for old browsers */
background: -webkit-linear-gradient(right, #76b852, #8DC26F);
background: -moz-linear-gradient(right, #76b852, #8DC26F);
background: -o-linear-gradient(right, #76b852, #8DC26F);
background: linear-gradient(to left, #76b852, #8DC26F);
font-family: "Roboto", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
No preview for this file type
This diff could not be displayed because it is too large.
No preview for this file type
No preview for this file type
No preview for this file type
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
$('.message a').click(function(){
$('form').animate({height: "toggle", opacity: "toggle"}, "slow");
});
\ No newline at end of file
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
require('../../js/transition.js')
require('../../js/alert.js')
require('../../js/button.js')
require('../../js/carousel.js')
require('../../js/collapse.js')
require('../../js/dropdown.js')
require('../../js/modal.js')
require('../../js/tooltip.js')
require('../../js/popover.js')
require('../../js/scrollspy.js')
require('../../js/tab.js')
require('../../js/affix.js')
\ No newline at end of file
......@@ -5,91 +5,135 @@
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- 부가적인 테마 -->
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<!-- 합쳐지고 최소화된 최신 자바스크립트 -->
<script src="js/bootstrap.min.js"></script>
<style>
body {
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: center;
background: #E3CAA1;
}
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background: #666; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
</style>
<script>
$(function () {
$('.click_genre').click(function () {
var str = $(this).text();
var search = $("#search_input").val();
$.ajax({
type:"GET",
url:"serach",
data:{'genre':str, 'search':search},
success:function(args){
$('#info').html(args);
//alert(args);
},
});
var str = $(this).text();
$.ajax({
type:"GET",
url:"errata",
data:{'query':$("#search_input").val()},
success:function(args2){
if( args2.errata==""){
var search = $("#search_input").val();
}
else{
var search =args2.errata;
}
$.ajax({
type:"GET",
url:"serach",
data:{'genre':str, 'search':search},
success:function(args){
$('#info').html(args);
//alert(args);
alert(str + " 장르를 선택하셨습니다");
},
});
},
});
})
})
$(function () {
$('.click_year').click(function () {
var str = $(this).text();
$.ajax({
type:"GET",
url:"errata",
data:{'query':$("#search_input").val()},
success:function(args2){
if( args2.errata==""){
var search = $("#search_input").val();
}
else{
var search =args2.errata;
}
$.ajax({
type:"GET",
url:"serach",
data:{'year':str, 'search':search},
success:function(args){
$('#info').html(args);
//alert(args);
alert(str + " 영화를 선택하셨습니다");
},
});
},
});
})
})
$(function () {
$('.click_country').click(function () {
var str = $(this).text();
str = str.slice(0,2);
$.ajax({
type:"GET",
url:"errata",
data:{'query':$("#search_input").val()},
success:function(args2){
if( args2.errata==""){
var search = $("#search_input").val();
}
else{
var search =args2.errata;
}
$.ajax({
type:"GET",
url:"serach",
data:{'country':str , 'search':search},
success:function(args){
$('#info').html(args);
//alert(args);
alert(str + " 국가의 영화를 검색하셨습니다.");
},
});
},
});
})
})
$(function () {
$('.click_all').click(function () {
$.ajax({
type:"GET",
url:"errata",
data:{'query':$("#search_input").val()},
success:function(args2){
if( args2.errata==""){
var searchAll = $("#search_input").val();
}
else{
var searchAll =args2.errata;
}
$.ajax({
type:"GET",
url:"serach",
data:{'searchAll':searchAll},
success:function(args){
$('#info').html(args);
alert(searchAll + " 이(가) 들어가는 모든 영화를 검색하셨습니다.");
},
});
},
});
})
})
</script>
<body>
......@@ -113,25 +157,29 @@ $(function () {
</li>
<li>
Rating
Year
<ul>
<li>3.0 Above</li>
<li>3.5 Above</li>
<li>4.0 Above</li>
<li>4.5 Above</li>
<li class = "click_year" >1980년대</li>
<li class = "click_year" >1990년대</li>
<li class = "click_year" >2000년대</li>
<li class = "click_year" >2010년대</li>
</ul>
</li>
<li>
Portfolio
Country
<ul>
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
<li class = "click_country" >KR(한국)</li>
<li class = "click_country" >JP(일본)</li>
<li class = "click_country" >US(미국)</li>
<li class = "click_country" >HK(홍콩)</li>
<li class = "click_country" >GB(영국)</li>
<li class = "click_country" >FR(프랑스)</li>
<li class = "click_country" >ETC(기타)</li>
</ul>
</li>
<li>Blog</li>
<li>All</li>
<li class = "click_all" >All</li>
</ul>
<div id = info></div>
......
<% for(var i=0; i < item.length; i++) { %>
<p><%= 'item[i]["title"]'%></p>
<% } %>
<table class="table table-condensed">
<thead>
<tr>
<th>제목</th>
<th>사진</th>
</tr>
</thead>
<tbody>
<% for(var i=0; i < item.length; i++) { %>
<p><%= item[i]["title"]%></p>
<tr>
<td> <p><%= item[i]["title"]%></p></td>
<td><img src="<%=item[i].image%>"></td>
</tr>
<% } %>
</tbody>
</table>
......