Toggle navigation
Toggle navigation
This project
Loading...
Sign in
MotherProject
/
Learning Images
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
최예리
2019-11-22 02:19:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8e1ecceab495901e379ebbe38f1da852dbead195
8e1eccea
1 parent
57934b0b
directory modify 기능 추가, directory remove 기능 개선
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
7 deletions
server.js
views/directoryDeleteCheck.pug
views/directoryModifyCheck.pug
views/error_directoryAdd.pug
views/home.pug
server.js
View file @
8e1ecce
...
...
@@ -73,10 +73,43 @@ app.get('/home/:directoryName/upload', (req, res) => {
});
// Modify Directory name
app
.
get
(
'/home/:directoryName/modify'
,
(
req
,
res
)
=>
{
// exist query.newName
var
directoryName
=
new
String
(
req
.
params
.
directoryName
);
var
newName
=
new
String
(
req
.
query
.
newName
);
if
(
req
.
query
.
newName
)
{
// modify Directory name and Files
var
path
=
dataFolder
+
'/'
+
directoryName
;
fs
.
readdirSync
(
path
).
forEach
(
function
(
file
,
index
){
var
curPath
=
path
+
"/"
+
file
;
var
fileNameArr
=
string
.
split
(
"_"
);
var
newPath
=
path
+
"/"
+
newName
+
"_"
+
fileNameArr
[
1
];
fs
.
rename
(
curPath
,
newPath
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
"File Rename error: "
+
err
);
}
});
});
fs
.
rename
(
path
,
dataFolder
+
'/'
+
newName
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
"Directory Rename error: "
+
err
);
}
else
{
console
.
log
(
"Directory Rename: "
+
directoryName
+
" -> "
+
newName
);
}
});
res
.
redirect
(
'/'
);
}
else
{
res
.
render
(
'directoryModifyCheck'
,
{
directoryName
:
JSON
.
stringify
(
directoryName
)});
}
});
// Delete Directory
app
.
get
(
'/home/:directoryName/delete'
,
(
req
,
res
)
=>
{
// exist query.real
var
directoryName
=
req
.
params
.
directoryName
;
var
directoryName
=
new
String
(
req
.
params
.
directoryName
)
;
if
(
req
.
query
.
real
)
{
// Remove Directory and Files
var
path
=
dataFolder
+
'/'
+
directoryName
;
...
...
@@ -88,7 +121,7 @@ app.get('/home/:directoryName/delete', (req, res) => {
res
.
redirect
(
'/'
);
}
else
{
res
.
render
(
'directoryDeleteCheck'
);
res
.
render
(
'directoryDeleteCheck'
,
{
directoryName
:
JSON
.
stringify
(
directoryName
)}
);
}
});
...
...
views/directoryDeleteCheck.pug
View file @
8e1ecce
script.
confirm("모든 이미지가 삭제됩니다. 정말 분류를 삭제하시겠습니까?") ? location.href = location + 'real=true' : history.back();
var directoryName= !{directoryName};
confirm('모든 이미지가 삭제됩니다.\n정말 ' + directoryName + ' 분류를 삭제하시겠습니까?')
? location.href = location + 'real=true' : history.back();
\ No newline at end of file
...
...
views/directoryModifyCheck.pug
0 → 100644
View file @
8e1ecce
script.
var directoryName= !{directoryName};
var result = prompt('새 분류명을 입력하세요. (기존: ' + directoryName + ')');
if (result) {
location.href = location + 'newName=' + result;
} else {
alert('분류명을 수정하지 않습니다.');
history.back();
}
\ No newline at end of file
views/error_directoryAdd.pug
View file @
8e1ecce
script.
alert("이미 존재하는 분류입니다.");
var msg = '이미 존재하는 분류입니다.'
alert(msg);
history.back();
\ No newline at end of file
...
...
views/home.pug
View file @
8e1ecce
...
...
@@ -3,22 +3,36 @@ html
head
meta(charset='utf-8')
title 분류 리스트
body
form(action="directory_check" method="post")
p 새로 만들 분류명:
input(name="directoryName", type="text")
input(type="submit", value="생성")
br
form(action="test" method="post" enctype="multipart/form-data")
p 테스트할 이미지:
input(name="ImageTest", type="file")
input(type="submit", value="테스트")
br
ul
- var folderList=fileList
each folder in folderList
li=folder
form(action="home/"+folder method="get")
input(type="submit", value="편집")
div(style="margin-right:30px; float:left;")
li
a(href=location+folder)=folder
div(style="margin-right:5px; float:left;")
form(action="home/"+folder+"/modify" method="get")
input(type="submit", value="수정")
div
form(action="home/"+folder+"/delete" method="get")
input(type="submit", value="삭제")
br
\ No newline at end of file
...
...
Please
register
or
login
to post a comment