Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2-capstone-design2
/
2017110267
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Flare-k
2020-11-05 14:41:36 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8fe2f9c72549c4f165025ed9cfae7536b9f62811
8fe2f9c7
1 parent
2218d5f7
[Add] Speed Test
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
13 deletions
Project/controllers/homeController.js
Project/package-lock.json
Project/package.json
Project/views/fileDetail.pug
Project/views/search.pug
Project/controllers/homeController.js
View file @
8fe2f9c
/* eslint-disable no-console */
import
routes
from
"../routes"
;
import
File
from
"../models/File"
;
import
performance
from
"perf_hooks"
;
export
const
home
=
async
(
req
,
res
)
=>
{
try
{
...
...
@@ -13,6 +14,7 @@ export const home = async (req, res) => {
};
export
const
search
=
async
(
req
,
res
)
=>
{
console
.
time
(
"SearchFunction"
);
const
{
query
:
{
term
:
searchingBy
},
}
=
req
;
// == const searchingBy = req.query.term;
...
...
@@ -21,6 +23,7 @@ export const search = async (req, res) => {
files
=
await
File
.
find
({
title
:
{
$regex
:
searchingBy
,
$options
:
"i"
},
// i를 옵션으로 추가하면 insensitive.. 대소문자 구분 안함.
});
console
.
timeEnd
(
"SearchFunction"
);
}
catch
(
error
)
{
console
.
log
(
error
);
}
...
...
@@ -35,6 +38,7 @@ export const getUpload = (req, res) =>
export
const
postUpload
=
async
(
req
,
res
)
=>
{
// const {} 를 통해 body를 받아와 요청하는 정보들을 확인한다.
// 이는 pug와 db.js를 확인해야하는 듯 하다.
console
.
time
(
"UploadFunction"
);
const
{
body
:
{
title
},
file
:
{
path
},
// path로 할때는 로컬의 경로. S3는 location
...
...
@@ -45,10 +49,9 @@ export const postUpload = async (req, res) => {
title
,
// 여기있는 fileUrl, title은 fileDB의 속성이다.
});
console
.
log
(
newFile
);
console
.
timeEnd
(
"UploadFunction"
);
res
.
redirect
(
routes
.
home
);
};
export
const
fileDetail
=
async
(
req
,
res
)
=>
{
...
...
@@ -57,10 +60,8 @@ export const fileDetail = async (req, res) => {
params
:
{
id
},
}
=
req
;
try
{
const
video
=
await
Video
.
findById
(
id
)
.
populate
(
"creator"
)
.
populate
(
"comments"
);
res
.
render
(
"videoDetail"
,
{
pageTitle
:
video
.
title
,
video
});
const
file
=
await
File
.
findById
(
id
);
res
.
render
(
"fileDetail"
,
{
pageTitle
:
file
.
title
,
file
});
}
catch
(
error
)
{
res
.
redirect
(
routes
.
home
);
}
...
...
Project/package-lock.json
View file @
8fe2f9c
...
...
@@ -6832,6 +6832,11 @@
"sha.js"
:
"^2.4.8"
}
},
"perf_hooks"
:
{
"version"
:
"0.0.1"
,
"resolved"
:
"https://registry.npmjs.org/perf_hooks/-/perf_hooks-0.0.1.tgz"
,
"integrity"
:
"sha512-qG/D9iA4KDme+KF4vCObJy6Bouu3BlQnmJ8jPydVPm32NJBD9ZK1ZNgXSYaZKHkVC1sKSqUiLgFvAZPUiIEnBw=="
},
"performance-now"
:
{
"version"
:
"2.1.0"
,
"resolved"
:
"https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz"
,
...
...
Project/package.json
View file @
8fe2f9c
...
...
@@ -47,6 +47,7 @@
"passport-github"
:
"^1.1.0"
,
"passport-local"
:
"^1.0.0"
,
"passport-local-mongoose"
:
"^6.0.1"
,
"perf_hooks"
:
"0.0.1"
,
"postcss-loader"
:
"^3.0.0"
,
"pug"
:
"^2.0.4"
,
"sass-loader"
:
"^8.0.2"
,
...
...
Project/views/fileDetail.pug
0 → 100644
View file @
8fe2f9c
extends layouts/main
block content
.file-detail__container
.file__info
h5.file__title=file.title
\ No newline at end of file
Project/views/search.pug
View file @
8fe2f9c
extends layouts/main
include mixins/
video
Block
include mixins/
file
Block
block content
.search__header
h3 Searching for: #{searchingBy}
.search__videos
if
video
s.length === 0
h5 No
Video
s Found
each item in
video
s
+
video
Block({
if
file
s.length === 0
h5 No
File
s Found
each item in
file
s
+
file
Block({
title : item.title,
views: item.views,
videoFile:item.videoFile,
id: item.id
})
\ No newline at end of file
...
...
Please
register
or
login
to post a comment