Commit ce982093 authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

Merge remote-tracking branch 'origin/cherry' into lsy

parents f87d8251 b7e0b8ba
import { Pagination } from "react-bootstrap";
import React from 'react';
function Paginations(props) {
return (
<Pagination>
<Pagination.First onClick={() => props.handlePage(1)} />
{props.index === 1 ? <Pagination.Prev onClick={()=>props.handlePage(props.index)} /> : <Pagination.Prev onClick={()=>props.handlePage(props.index - 1)} />}
{props.index === props.endPage-1 ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
{props.index === props.endPage ? <Pagination.Item onClick={()=>props.handlePage(props.index - 4)}>{props.index - 4}</Pagination.Item> : ""}
{props.index === props.endPage ? <Pagination.Item onClick={()=>props.handlePage(props.index - 3)}>{props.index - 3}</Pagination.Item> : ""}
{props.index < 3 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index - 2)}>{props.index - 2}</Pagination.Item>}
{props.index === 1 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index - 1)}>{props.index - 1}</Pagination.Item>}
<Pagination.Item active>{props.index}</Pagination.Item>
{props.index === props.endPage ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 1)}>{props.index + 1}</Pagination.Item>}
{props.index > props.endPage-2 ? "" : <Pagination.Item onClick={()=>props.handlePage(props.index + 2)}>{props.index + 2}</Pagination.Item>}
{props.index === 1 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 3)}>{props.index + 3}</Pagination.Item> : ""}
{props.index === 1 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 4)}>{props.index + 4}</Pagination.Item> : ""}
{props.index === 2 ? <Pagination.Item onClick={()=>props.handlePage(props.index + 3)}>{props.index + 3}</Pagination.Item> : ""}
{props.index === props.endPage ? "" : <Pagination.Next onClick={()=>props.handlePage(props.index + 1)} />}
<Pagination.Last onClick={() =>props.handlePage(props.endPage)} />
</Pagination>
)
}
export default Paginations
import React from 'react';
import { Modal, Container, Row, Col, Button } from 'react-bootstrap';
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import { Modal, Container, Row, Col, Button, Badge, Card, Accordion, Carousel } from 'react-bootstrap';
function Place(props) {
const [reviews, setReviews] = useState([])
const getReview = () => {
axios.get(`/api/review/${props.search.name}`)
.then(res => {
setReviews(res.data)
})
.catch(err => {
console.log(err)
})
}
useEffect(() => {
getReview();
}, [])
return (
<<<<<<< HEAD
<>
<style type="text/css">
{`
......@@ -28,11 +46,56 @@ function Place(props) {
<Row className="mt-4">
<div>주도 전역을 지배하는 한라산은 남한에서 가장 높은 산으로 높이는 1,947.3m이다. 한라산이라는 이름은 산이 높아 산정에 서면 은하수를 잡아당길 있다는 뜻이며, 부악·원산·선산·두무악·영주산·부라산·혈망봉·여장군 등으로도 불려왔다.</div>
<a href="https://www.daum.net">다음의 블로그</a>
=======
<Modal {...props}
size="xl"
keyboard="true"
variant="backdrop.in"
// show={lgShow}
// onHide={() => setLgShow(false)}
aria-labelledby="example-modal-sizes-title-lg">
<Modal.Header closeButton>
<Modal.Title id="contained-modal-title-vcenter" style={{ fontSize: '40px' }}>
{props.index + 1}. {props.search.name}
</Modal.Title>
</Modal.Header>
<Modal.Body className="show-grid">
<Container style={{ fontSize: '40px' }}>
{reviews.map((review, index) => {
return (
<Row className="mt-4">
<a href={review.link}>{review.title}</a>
<div>{review.summary}</div>
</Row>
)
})}
</Container>
{/* <Accordion defaultActiveKey="0">
<Accordion.Toggle as={Button} variant="link" eventKey="0">
<a className="mb-2">다음의 블로그 보기</a>
</Accordion.Toggle>
<Accordion.Collapse eventKey="0">
<Card.Body><div>주도 전역을 지배하는 한라산은 남한에서 가장 높은 산으로 높이는 1,947.3m이다. 한라산이라는 이름은 산이 높아 산정에 서면 은하수를 잡아당길 수 있다는 뜻이며, 부악·원산·선산·두무악·영주산·부라산·혈망봉·여장군 등으로도 불려왔다.</div></Card.Body>
</Accordion.Collapse>
<Row>
<Accordion.Toggle as={Button} variant="link" eventKey="1">
<a className="mb-2">네이버의 블로그 보기</a>
</Accordion.Toggle>
<Accordion.Collapse eventKey="1">
<Card.Body><div>한라산은 1966년 한라산 천연보호구역으로, 1970년 국립공원으로 지정되었다. 그리고 2002년에는 유네스코 생물권보전지역으로 지정되었으며 2007년에는 유네스코 세계자연유산으로 등재되었다. 2008년에는 물장오리오름 산정화구호 습지가 람사르 습지로 등록되어 보호 관리되고 있다</div></Card.Body>
</Accordion.Collapse>
>>>>>>> origin/cherry
</Row>
<Row className="mt-4">
<div>한라산은 1966 한라산 천연보호구역으로, 1970 국립공원으로 지정되었다. 그리고 2002년에는 유네스코 생물권보전지역으로 지정되었으며 2007년에는 유네스코 세계자연유산으로 등재되었다. 2008년에는 물장오리오름 산정화구호 습지가 람사르 습지로 등록되어 보호 관리되고 있다</div>
<a href="https://www.naver.com/">네이버의 블로그</a>
<Row>
<Accordion.Toggle as={Button} variant="link" eventKey="2">
<a className="mb-2">구글의 블로그 보기</a>
</Accordion.Toggle>
<Accordion.Collapse eventKey="2">
<Card.Body><div>한라산은 제주도에 있는 해발 1,947.06m, 면적 약 1,820km²의 화산으로, 제주도의 면적 대부분을 차지하고 있다. 정상에 백록담이라는 화산호가 있는데, 백록담이라는 이름은 흰 사슴이 물을 먹는 곳이라는 뜻에서 왔다고 전해진다.</div></Card.Body>
</Accordion.Collapse>
</Row>
<<<<<<< HEAD
<Row className="mt-4">
<div>한라산은 제주도에 있는 해발 1,947.06m, 면적 약 1,820km²의 화산으로, 제주도의 면적 대부분을 차지하고 있다. 정상에 백록담이라는 화산호가 있는데, 백록담이라는 이름은 흰 사슴이 물을 먹는 곳이라는 뜻에서 왔다고 전해진다.</div>
<a href="https://www.google.com/">구글의 블로그</a></Row>
......@@ -43,7 +106,33 @@ function Place(props) {
</Modal.Footer>
</Modal>
</>
=======
</Accordion>
<Row style={{ color: 'white' }}>
<a href="https://www.daum.net/" className="mb-2">다음</a><a href="https://www.naver.com/" className="mb-2">네이버</a><a href="https://www.google.com/" className="mb-2">구글</a>
</Row>
// </Container>
<Carousel>
<Carousel.Item interval={1000}>
<h3>다음 블로그</h3>
<div>주도 전역을 지배하는 한라산은 남한에서 가장 높은 산으로 높이는 1,947.3m이다. 한라산이라는 이름은 산이 높아 산정에 서면 은하수를 잡아당길 수 있다는 뜻이며, 부악·원산·선산·두무악·영주산·부라산·혈망봉·여장군 등으로도 불려왔다.</div>
</Carousel.Item>
<Carousel.Item interval={1000}>
<h3>네이버 블로그</h3>
<div>한라산은 1966년 한라산 천연보호구역으로, 1970년 국립공원으로 지정되었다. 그리고 2002년에는 유네스코 생물권보전지역으로 지정되었으며 2007년에는 유네스코 세계자연유산으로 등재되었다. 2008년에는 물장오리오름 산정화구호 습지가 람사르 습지로 등록되어 보호 관리되고 있다</div>
</Carousel.Item>
<Carousel.Item interval={1000}>
<h3>구글 블로그</h3>
<div>한라산은 제주도에 있는 해발 1,947.06m, 면적 약 1,820km²의 화산으로, 제주도의 면적 대부분을 차지하고 있다. 정상에 백록담이라는 화산호가 있는데, 백록담이라는 이름은 흰 사슴이 물을 먹는 곳이라는 뜻에서 왔다고 전해진다.</div>
</Carousel.Item>
</Carousel> */}
</Modal.Body>
<Modal.Footer>
<Button block onClick={props.onHide}>Close</Button>
</Modal.Footer>
</Modal>
>>>>>>> origin/cherry
);
}
export default Place;
\ No newline at end of file
export default Place;
import React, { useEffect, useState } from 'react';
import { Link, Redirect } from 'react-router-dom';
<<<<<<< HEAD:client/src/App.js
import ohuh from './ohuh.PNG';
import { Col, FormControl, Container, Row, Form, Image, InputGroup, Button, Navbar, Nav } from 'react-bootstrap';
import { handleLogout, isAuthenticated } from './utils/auth'
=======
import ohuh from '../ohuh.PNG';
import { Container, Row, Form, Image, InputGroup, Button, Col, FormControl } from 'react-bootstrap';
>>>>>>> origin/cherry:client/src/Pages/App.js
function App() {
const [state, setState] = useState(false);
......@@ -30,6 +35,7 @@ function App() {
return (
<Container className="vh-100">
<Row className="d-flex justify-content-md-center">
<<<<<<< HEAD:client/src/App.js
{/* <Row as={Image} src={ohuh} col-sm-5 col-lg-6 offset-lg-0> */}
<Col md={6} className="mt-5">
<Image src={ohuh} fluid />
......@@ -49,6 +55,12 @@ function App() {
</Col>
{/* </Row> */}
<Col lg={{ span: 10, offset: 1 }} > {/*xs={{ span: 12, offset: 3 }} */}
=======
<Col md={6} className="mt-5">
<Image src={ohuh} fluid />
</Col>
<Col lg={{ span: 10, offset: 1 }} >
>>>>>>> origin/cherry:client/src/Pages/App.js
<InputGroup size="lg" lg={6} xs={4} fluid>
<FormControl
className="d-flex justify-content-lg-center"
......@@ -61,14 +73,18 @@ function App() {
<Button variant="outline-secondary" onClick={handleSubmit}>검색</Button>
</InputGroup.Append>
</InputGroup>
<<<<<<< HEAD:client/src/App.js
{/* <form onSubmit={handleSubmit}>
<input className="" name="search" type="text" placeholder="검색어를 입력하세요." onChange={handleChange}></input>
<Link to="/search"><button type="submit">검색</button></Link>
</form> */}
=======
>>>>>>> origin/cherry:client/src/Pages/App.js
</Col>
</Row>
</Container>
);
}
export default App;
export default App;
\ No newline at end of file
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import { Link, Redirect } from 'react-router-dom';
<<<<<<< HEAD:client/src/Search.js
import ohuh from './ohuh-sm.PNG';
import Place from './Components/Place';
import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button, Pagination, Nav, Navbar } from 'react-bootstrap';
import Paginations from './pagination.js';
=======
import ohuh from '../ohuh-sm.PNG';
import Place from '../Components/Place';
import { Container, Form, Row, Col, Card, Image, InputGroup, FormControl, Button, Pagination } from 'react-bootstrap';
import Paginations from '../Components/Paginations';
>>>>>>> origin/cherry:client/src/Pages/Search.js
function Search(props) {
const endPage = 10;
const [state, setState] = useState(false);
const [index, setIndex] = useState(1);
const [show, setShow] = useState(false);
const [showSet, setShowSet] = useState([false, false, false, false]);
const [search, setSearch] = useState(props.location.state.id);
const [mobile, setMobile] = useState();
useEffect(() => {
if (window.innerWidth < 960) {
setMobile(true)
} else {
setMobile(false)
}
}, []);
const places = [{
name: "한라산(hallasan)",
......@@ -439,11 +455,14 @@ function Search(props) {
return page
}
const pagePlace = paginate(places, index)
return (
<Container >
<Link to="/" className="d-flex justify-content-center"><Image src={ohuh} /></Link>
<<<<<<< HEAD:client/src/Search.js
{/* <Row className='d-flex justify-content-flex-start'>
<Navbar bg="#fff" variant="light">
<Nav className="mr-auto">
......@@ -461,6 +480,11 @@ function Search(props) {
{/* <Image src={ohuh} fluid width="130px" /> */}
</Col>
</Link>
=======
<Row className="mb-2" className="d-flex justify-content-center">
<Form style={{ width: "90vw" }} onSubmit={handleSubmit}>
<InputGroup size="lg">
>>>>>>> origin/cherry:client/src/Pages/Search.js
<FormControl
placeholder="검색어를 입력하세요."
value={search}
......@@ -484,19 +508,26 @@ function Search(props) {
<Card.Body >
<Card.Text style={{ overflow: 'auto', fontSize: '25px', width: '100%', height: "80px" }} >
{place.address} </Card.Text>
<Button variant="primary" onClick={() => setShow(true)}>{place.name} 자세히 살펴보기</Button>
<Place search={place} show={show} onHide={() => setShow(false)} />
<Button variant="primary" onClick={() => {
const showArr = [false, false, false, false]
showArr[index] = true
setShowSet(showArr)
}}>{place.name} 자세히 살펴보기</Button>
<Place search={place} index={index} show={showSet[index]} onHide={() => setShowSet([false, false, false, false])} />
</Card.Body>
</Card>
</Col>
)
})}
</Row>
{console.log(showSet)}
{/* show가 전부 true로 바뀌어서 전부 다 보이게 되는 것이다. */}
<Row className="mt-2 d-flex justify-content-center">
<Paginations index={index} endPage={endPage} handlePage={handlePage}></Paginations>
</Row>
</Container>
);
}
export default Search;
\ No newline at end of file
export default Search;
......@@ -2,8 +2,9 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import 'bootstrap/dist/css/bootstrap.min.css';
import App from './App';
import Search from './Search';
import App from './Pages/App';
import Search from './Pages/Search';
import axios from 'axios';
import reportWebVitals from './reportWebVitals';
import Signup from './Components/Signup'
import Login from './Components/Login'
......@@ -15,15 +16,19 @@ import {
} from "react-router-dom";
import axios from 'axios';
axios.defaults.validateStatus = function (status) {
return status < 500; // default
}
ReactDOM.render(
<React.StrictMode>
<Router>
<Switch>
<Route exact path="/" component={App} />
<Route path="/search" component={Search} />
<Redirect path="/search/:id" to="/search" />
<Route path='/signup' component={Signup}/>
<Route path='/login' component={Login} />
<Redirect path="/search/:search" to="/search" />
</Switch>
</Router>
</React.StrictMode>,
......
......@@ -2,8 +2,12 @@ const config = {
env: process.env.NODE_ENV || 'development',
port: process.env.PORT || 3001,
jwtSecret: process.env.JWT_SECRET || 'My_Secret_Key',
<<<<<<< HEAD
mongoDbUri: process.env.MONGODB_URI || 'mongodb://localhost/search-page',
cookieMaxAge: 60 * 60 * 24 * 7 * 1000
=======
mongoDbUri: process.env.MONGODB_URI || 'mongodb://localhost/search_page'
>>>>>>> origin/cherry
}
export default config
\ No newline at end of file
import Place from '../models/Place.js'
import cheerio from 'cheerio'
const signup = async (req, res) => {
const { name, email, password } = req.body
console.log(name, email, password)
try {
if (!isLength(name, { min: 3, max: 10 })) {
return res.status(422).send('Name must be 3-10 characters')
}
const newUser = await new User({
name,
email,
password
}).save()
console.log(newUser)
res.json(newUser)
} catch (error) {
console.log(error)
res.status(500).send('User signup error')
}
}
const search = async (req, res) => {
// 정보들 크롤링 해오고 아래에 넣어주기
const url = "https://section.blog.naver.com/Search/Post.nhn?keyword=" + keyword
request(url, function (err, res, html) { // URL로부터 가져온 페이지 소스가 html이란 변수에 담긴다.
if (!err) {
var $ = cheerio.load(html);
// 블로그 title 정보 가져오기
$(".entry-title > a").each(function () {
var post = { "name": "", "address": "", "img": "" };
var data = $(this);
post["title"] = data.text();
post["link"] = data.attr("href");
});
}
})
// try {
// const newPlace = await new Place({
// name: req.params.search,
// address,
// img,
// })
// }
}
export default { signup, search }
\ No newline at end of file
import Review from '../models/Review.js'
import cheerio from "cheerio";
import express from 'express';
import request from 'request-promise'
import jschardet from 'jschardet'
import iconv from 'iconv'
import fs from 'fs'
const Iconv = iconv.Iconv
const signup = async (req, res) => {
res.send("안녕하세요")
}
const search = async (req, res) => {
const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com" + '&page_no=1'
request(url)
.then(anyToUtf8)
.then((html) => {
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
let $ = cheerio.load(html, null, false);
let places = []
$('.kCrYT').each(function (i) {
const review = await Review.findOne({ link: $(this).find('a').attr('href') })
if (!user) {
const newReview = await new Review({
name,
email,
password: hash
}).save()
}
places[i] = {
title: $(this).find('h3').text(),
link: $(this).find('a').attr('href'),
summary: $(this).find('.s3v9rd').text(),
}
})
// console.log(places)
res.send(places)
})
function anyToUtf8(str) {
const { encoding } = jschardet.detect(str);
console.log("source encoding = " + encoding);
const iconv = new Iconv(encoding, "utf-8//translit//ignore");
return iconv.convert(str).toString();
}
// try {
// const newPlace = await new Place({
// name: req.params.search,
// address,
// img,
// })
// }
}
const
export default { signup, search }
\ No newline at end of file
import mongoose from 'mongoose'
const { String, ObjectId } = mongoose.Schema.Types
const { String } = mongoose.Schema.Types
const PlaceSchema = new mongoose.Schema({
name: {
......@@ -17,14 +17,14 @@ const PlaceSchema = new mongoose.Schema({
required: true,
default: "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd",
},
search: {
type: Array,
required: true,
},
time: {
type: Array,
required: true,
},
review: {
type: ObjectId,
ref: 'Review'
}
}, {
timestamps: true
})
......
......@@ -3,19 +3,21 @@ import mongoose from 'mongoose'
const { String } = mongoose.Schema.Types
const ReviewSchema = new mongoose.Schema({
link: {
title: {
type: String,
required: true,
},
address: {
link: {
type: String,
required: true,
unique: true,
},
imag: {
summary: {
type: String,
required: true,
default: "https://t1.daumcdn.net/thumb/R600x0/?fname=http%3A%2F%2Ft1.daumcdn.net%2Fqna%2Fimage%2F4b035cdf8372d67108f7e8d339660479dfb41bbd",
},
keyword: {
type: Array,
required: true,
},
time: {
type: Array,
......
This diff is collapsed.
import express from 'express'
import place from '../controllers/place.controller.js'
const router = express.Router()
router.route('/api/search/:search')
.post(place.signup)
.get(place.search)
export default router
\ No newline at end of file
import express from 'express'
import review from '../controllers/review.controller.js'
const router = express.Router()
router.route('/api/review/:search')
.post(review.signup)
.get(review.search)
export default router
\ No newline at end of file
<<<<<<< HEAD
import cheerio from "cheerio"
import express from 'express'
import request from 'request'
......@@ -36,6 +37,41 @@ app.get('/', (req, res) => {
// })
// .then(res => console.log(res)); // 저장된 결과를 출력
)
=======
import axios from "axios";
import cheerio from "cheerio";
import express from 'express';
import request from 'request-promise'
import jschardet from 'jschardet'
import iconv from 'iconv'
import fs from 'fs'
const Iconv = iconv.Iconv
const app = express()
app.get('/', (req, res) => {
const url = "https://100mountain.tistory.com/117"
request({
url: url,
encoding: null,
})
.then(anyToUtf8)
.then((html) => {
// fs.writeFileSync("test.txt", '\ufeff' + html, {encoding: 'utf8'});
let $ = cheerio.load(html, null, false);
let places = []
$('div.tt_article_useless_p_margin').each(function () {
console.log("title", $(this).find('p').text())
});
console.log("places", places)
})
function anyToUtf8(str) {
const { encoding } = jschardet.detect(str);
const iconv = new Iconv(encoding, "utf-8//translit//ignore");
return iconv.convert(str).toString();
}
>>>>>>> origin/cherry
})
app.listen(3001, () => {
......
import axios from "axios";
import cheerio from "cheerio";
import express from 'express';
import request from 'request-promise'
import jschardet from 'jschardet'
import iconv from 'iconv'
import fs from 'fs'
const Iconv = iconv.Iconv
const app = express()
app.get('/', (req, res) => {
const url = "https://www.google.com/search?q=%ED%95%9C%EB%9D%BC%EC%82%B0%20site%3Atistory.com&oq=tistory&aqs=chrome..69i57j0l4j69i60l3.1746j0j4&sourceid=chrome&ie=UTF-8&ved=2ahUKEwis_bSFz4buAhWVdXAKHU0tBaoQ2wF6BAgIEAE&ei=T1D1X-yZD5XrwQPN2pTQCg"
request(url)
.then(anyToUtf8)
.then((html) => {
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
let $ = cheerio.load(html, null, false);
let places = []
$('.kCrYT').each(function (i) {
places[i] = {
title: $(this).find('h3').text(),
link: $(this).find('a').attr('href'),
summary: $(this).text(),
}
})
console.log(places)
})
function anyToUtf8(str) {
const { encoding } = jschardet.detect(str);
console.log("source encoding = " + encoding);
const iconv = new Iconv(encoding, "utf-8//translit//ignore");
return iconv.convert(str).toString();
}
res.send("안녕")
})
app.listen(3001, () => {
console.log('Server is listening on port 3001')
})
\ No newline at end of file
import express from 'express'
<<<<<<< HEAD
import connectDb from "./utils/connectDb.js"
import userRouter from "./routes/user.routes.js"
import authRouter from "./routes/auth.routes.js"
=======
import connectDb from './utils/connectDb.js'
import placeRouter from './routes/place.routes.js'
import reviewRouter from './routes/review.routes.js'
>>>>>>> origin/cherry
connectDb()
......@@ -11,8 +17,18 @@ app.use('/images', express.static('uploads/'))
app.use(express.json())
<<<<<<< HEAD
app.use(userRouter)
app.use(authRouter)
=======
app.use(placeRouter)
app.use(reviewRouter)
app.get('/', (req, res) => {
console.log("/ req.body", req.body)
res.json({ message: "http://localhost3001/ 에 연결됨" })
})
>>>>>>> origin/cherry
app.listen(3001, () => {
console.log('Listening on port 3001')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment