서민정

Update code

......@@ -10,7 +10,6 @@ yarn-error.log*
.vscode
dev.js
auth.js
./server/config/dev.js
./server/config/auth.js
.env
\ No newline at end of file
......
### 오픈소스sw개발 개인 프로젝트
## CHATBOT WITH CRAWLING
- 뉴스 크롤링 후 이미지 사이즈 80*80 인 것을 원본으로 변환할 수 있는 방법은..?
- 구글 [Cloud Authentication](https://cloud.google.com/docs/authentication/getting-started?hl=ko) 으로 사용해서 로컬에서 실행시키는데,
만약 배포를 해야한다면 이 부분은 어떻게 해야할지 ..?
- 회원으로 로그인 했을 때, 주어진 키워드로 챗봇이 "먼저 검색"해줄 수 있도록 설정하는 방법은?!
-readme 수정하기
-로그인 시 페이지렌더링 안됨 ..... 수정하기
......
......@@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"engines": {
"node": "10.x.x",
"npm": "6.x",
"node": "12.16.1",
"npm": "6.13.4",
"yarn" : ">=1.0.0 <2.0.0"
},
"dependencies": {
......
No preview for this file type
import React, {Suspense} from "react";
import { Route, Switch } from "react-router-dom";
import { Route, Switch, BrowserRouter} from "react-router-dom";
// import { Typography, Icon } from 'antd';
// import Chatbot from './Chatbot/Chatbot';
import chatpage from './views/chatpage';
......@@ -11,13 +11,15 @@ import registerpage from './views/registerpage';
function App() {
return (
<BrowserRouter>
<Suspense fallback = {(<div>Loading...</div>)}>
<Switch>
<Route exact path="/chat" component={chatpage}/>
<Route exact path="/" component={loginpage} />
<Route exact path="/register" component={registerpage} />
<Route path="/chat" component={chatpage}/>
<Route path="/" exact component={loginpage} />
<Route path="/register" component={registerpage} />
</Switch>
</Suspense>
</BrowserRouter>
)
}
......
......@@ -6,69 +6,36 @@ import Message from './Sections/Message';
import { List, Icon, Avatar } from 'antd';
import Card from "./Sections/Card";
import CheckString from './Check';
import { text } from 'body-parser';
function getUserInfo(){
let url = window.location.href;
let keyword = "";
let name = "";
let from = 0;
let to = 0;
let flag = false;
if(!url) return keyword;
for(var i = 0; i <= url.length; i++){
if(flag && url[i] === '&'){
to = i;
break;
}
if(url[i] === '='){
from = i+1;
flag = true;
}
}
keyword = url.substr(from,to-from);
keyword = decodeURI(keyword);
name = url.substr(to+6);
name = decodeURI(name);
var user = {
keyword,
name
};
return user;
}
const user = getUserInfo();
let username = "유저";
let userKeyword = "";
if(user.keyword){
userKeyword = user.keyword;
username = user.name;
let userName = "유저";
let autoSearch = 0;
if(sessionStorage.length){
userKeyword = sessionStorage.getItem("Now_userKeyword");
userName = sessionStorage.getItem("Now_userName");
autoSearch = 1;
sessionStorage.clear();
}
function Chatbot() {
console.log("이름",username);
console.log("이름",userName);
console.log("키워드",userKeyword);
var isUser = false;
if(userKeyword) isUser = true;
const dispatch = useDispatch();
const messagesFromRedux = useSelector(state => state.message.messages)
useEffect(() => {
eventQuery('001_Welcome')
.then(eventQuery('002_Intro'))
}, [])
const textQuery = async (text) => {
// First Need to take care of the message I sent
let conversation = {
who: username,
who: userName,
content: {
text: {
text: text
......@@ -180,6 +147,21 @@ function Chatbot() {
}
if(autoSearch === 1){
setTimeout(function(){
eventQuery('008_AutoSearch');
}, 500);
setTimeout(function(){
textQuery(`@${userKeyword}_최신`);
textQuery(`@${userKeyword}_정확도`);
textQuery(`@${userKeyword}_소식`);
}, 1000);
autoSearch = 0;
console.log("I am in autoSearch!!");
}
const keyPressHanlder = (e) => {
if (e.key === "Enter") {
......@@ -243,10 +225,10 @@ function Chatbot() {
return (
<div style={{
height: 650, width: 700,
height: 610, width: 700,
border: '3px solid black', borderRadius: '7px'
}}>
<div style={{ height: 594, width: '100%', overflow: 'auto'}}>
<div style={{ height: 554, width: '100%', overflow: 'auto'}}>
{renderMessage(messagesFromRedux)}
......
import React from "react";
import { Typography, Form, Input, Icon, Button} from 'antd';
import { withRouter } from "react-router-dom";
import { withRouter, Link } from "react-router-dom";
import Axios from 'axios';
const { Title } = Typography;
......@@ -17,12 +17,17 @@ const userInfo = async (info) => {
}
const response = await Axios.post('/api/login/userInfo', userVariables);
if(response.data != 'FAIL'){
if(response.data !== 'FAIL'){
// loginForm.action = `/chat?${response.data}`;
// loginForm.submit();
var keyword = response.data.keyword;
var name = response.data.name;
window.location.href=`/chat?keyword=${keyword}&name=${name}`;
sessionStorage.setItem("Now_userKeyword", keyword);
sessionStorage.setItem("Now_userName", name);
window.history.replaceState('login','','/chat');
window.history.go();
// window.location.href = "/chat";
} else{
alert("입력하신 정보와 일치하는 회원이 존재하지 않습니다 😥");
}
......@@ -66,25 +71,12 @@ function loginpage() {
Log in
</Button>
</div>
<a href="/register">가입하기</a> Or <a href = "/chat"> 비회원으로 사용하기 </a>
<Link to ="/register">가입하기</Link> Or <Link to = "/chat">비회원으로 사용하기</Link>
</Form.Item>
</form>
</div>
</div>
);
// return (
// htmlType="submit"
// <div>
// <div style={{ display: 'flex', justifyContent: 'center', marginTop: '1rem' }}>
// <Title level={2} >Login Page</Title>
// </div>
// </div>
// )
}
export default withRouter(loginpage);
\ No newline at end of file
......
......@@ -2,7 +2,6 @@ const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
const app = express();
const config = require("./server/config/keys");
app.set('trust proxy',true);
app.use(bodyParser.urlencoded({ extended: true }));
......@@ -19,14 +18,19 @@ app.use('/api/news',require('./server/routes/news'));
if (process.env.NODE_ENV === "production") {
// Set static folder
app.use(express.static("client/build"));
app.use(express.static(path.join(__dirname,'client/build')));
app.get('/api/greeting',(req,res)=>{
res.send("Hello World!");
});
// index.html for all page routes
app.get("/", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + 'client/build','index.html'));
});
}
const port = process.env.PORT || 5000;
app.listen(port, () => {
......@@ -34,4 +38,5 @@ app.listen(port, () => {
});
// res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
\ No newline at end of file
......
......@@ -13,10 +13,7 @@
"backend": "nodemon index.js",
"frontend": "npm run front --prefix client"
},
"author": "Jaewon Ahn",
"contributors": [
"Minjeong Seo"
],
"author": "",
"license": "ISC",
"dependencies": {
"actions-on-google": "^2.12.0",
......
if (process.env.NODE_ENV === "production"){
module.exports = require("./prod");
}else{
module.exports = require("./dev");
}
\ No newline at end of file
module.exports = {
googleProjectID: process.env.GOOGLE_PROJECT_ID,
dialogFlowSessionID: process.env.DIALOGFLOW_SESSION_ID,
dialogFlowSessionLanguageCode: process.env.DIALOGFLOW_LANGUAGE_CODE,
googleClientEmail:process.env.GOOGLE_CLIENT_EMAIL,
googlePrivateKey: JSON.parse(process.env.GOOGLE_PRIVATE_KEY),
mongoURI:process.env.MONGO_URI,
}
\ No newline at end of file
......@@ -3,11 +3,12 @@ const router = express.Router();
const structjson = require('./structjson.js');
const dialogflow = require('dialogflow');
const config = require('../config/keys');
require('dotenv').config();
const projectId = process.env.googleProjectID
const sessionId = process.env.dialogFlowSessionID
const languageCode = process.env.dialogFlowSessionLanguageCode
const projectId = config.googleProjectID
const sessionId = config.dialogFlowSessionID
const languageCode = config.dialogFlowSessionLanguageCode
// Create a new session
......