mirror of https://github.com/Requarks/wiki.git
NGPixel
8 years ago
16 changed files with 207 additions and 52 deletions
Split View
Diff Options
-
2README.md
-
2assets/css/app.css
-
2assets/js/app.js
-
29client/js/modals/create.js
-
49client/js/modals/move.js
-
5client/js/pages/source.js
-
31client/js/pages/view.js
-
4client/scss/layout/_content.scss
-
29controllers/pages.js
-
17models/entries.js
-
24models/git.js
-
13views/common/header.pug
-
18views/modals/move.pug
-
7views/pages/edit.pug
-
22views/pages/source.pug
-
5views/pages/view.pug
2
assets/css/app.css
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
assets/js/app.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,29 @@ |
|||
|
|||
//-> Create New Document
|
|||
|
|||
let suggestedCreatePath = currentBasePath + '/new-page'; |
|||
|
|||
$('.btn-create-prompt').on('click', (ev) => { |
|||
$('#txt-create-prompt').val(suggestedCreatePath); |
|||
$('#modal-create-prompt').toggleClass('is-active'); |
|||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length + 1, suggestedCreatePath.length); |
|||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden'); |
|||
}); |
|||
|
|||
$('#txt-create-prompt').on('keypress', (ev) => { |
|||
if(ev.which === 13) { |
|||
$('.btn-create-go').trigger('click'); |
|||
} |
|||
}); |
|||
|
|||
$('.btn-create-go').on('click', (ev) => { |
|||
|
|||
let newDocPath = makeSafePath($('#txt-create-prompt').val()); |
|||
if(_.isEmpty(newDocPath)) { |
|||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden'); |
|||
} else { |
|||
$('#txt-create-prompt').parent().addClass('is-loading'); |
|||
window.location.assign('/create/' + newDocPath); |
|||
} |
|||
|
|||
}); |
@ -0,0 +1,49 @@ |
|||
|
|||
//-> Move Existing Document
|
|||
|
|||
if(currentBasePath !== '') { |
|||
$('.btn-move-prompt').removeClass('is-hidden'); |
|||
} |
|||
|
|||
let moveInitialDocument = _.lastIndexOf(currentBasePath, '/') + 1; |
|||
|
|||
$('.btn-move-prompt').on('click', (ev) => { |
|||
$('#txt-move-prompt').val(currentBasePath); |
|||
$('#modal-move-prompt').toggleClass('is-active'); |
|||
setInputSelection($('#txt-move-prompt').get(0), moveInitialDocument, currentBasePath.length); |
|||
$('#txt-move-prompt').removeClass('is-danger').next().addClass('is-hidden'); |
|||
}); |
|||
|
|||
$('#txt-move-prompt').on('keypress', (ev) => { |
|||
if(ev.which === 13) { |
|||
$('.btn-move-go').trigger('click'); |
|||
} |
|||
}); |
|||
|
|||
$('.btn-move-go').on('click', (ev) => { |
|||
|
|||
let newDocPath = makeSafePath($('#txt-move-prompt').val()); |
|||
if(_.isEmpty(newDocPath) || newDocPath === currentBasePath || newDocPath === 'home') { |
|||
$('#txt-move-prompt').addClass('is-danger').next().removeClass('is-hidden'); |
|||
} else { |
|||
$('#txt-move-prompt').parent().addClass('is-loading'); |
|||
|
|||
$.ajax(window.location.href, { |
|||
data: { |
|||
move: newDocPath |
|||
}, |
|||
dataType: 'json', |
|||
method: 'PUT' |
|||
}).then((rData, rStatus, rXHR) => { |
|||
if(rData.ok) { |
|||
window.location.assign('/' + newDocPath); |
|||
} else { |
|||
alerts.pushError('Something went wrong', rData.error); |
|||
} |
|||
}, (rXHR, rStatus, err) => { |
|||
alerts.pushError('Something went wrong', 'Save operation failed.'); |
|||
}); |
|||
|
|||
} |
|||
|
|||
}); |
@ -1,34 +1,9 @@ |
|||
|
|||
if($('#page-type-view').length) { |
|||
|
|||
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') + '/' : ''; |
|||
let suggestedCreatePath = currentBasePath + 'new-page'; |
|||
let currentBasePath = ($('#page-type-view').data('entrypath') !== 'home') ? $('#page-type-view').data('entrypath') : ''; |
|||
|
|||
//-> Create New Document
|
|||
|
|||
$('.btn-create-prompt').on('click', (ev) => { |
|||
$('#txt-create-prompt').val(suggestedCreatePath); |
|||
$('#modal-create-prompt').toggleClass('is-active'); |
|||
setInputSelection($('#txt-create-prompt').get(0), currentBasePath.length, suggestedCreatePath.length); |
|||
$('#txt-create-prompt').removeClass('is-danger').next().addClass('is-hidden'); |
|||
}); |
|||
|
|||
$('#txt-create-prompt').on('keypress', (ev) => { |
|||
if(ev.which === 13) { |
|||
$('.btn-create-go').trigger('click'); |
|||
} |
|||
}); |
|||
|
|||
$('.btn-create-go').on('click', (ev) => { |
|||
|
|||
let newDocPath = makeSafePath($('#txt-create-prompt').val()); |
|||
if(_.isEmpty(newDocPath)) { |
|||
$('#txt-create-prompt').addClass('is-danger').next().removeClass('is-hidden'); |
|||
} else { |
|||
$('#txt-create-prompt').parent().addClass('is-loading'); |
|||
window.location.assign('/create/' + newDocPath); |
|||
} |
|||
|
|||
}); |
|||
//=include ../modals/create.js
|
|||
//=include ../modals/move.js
|
|||
|
|||
} |
@ -0,0 +1,18 @@ |
|||
|
|||
.modal#modal-move-prompt |
|||
.modal-background |
|||
.modal-container |
|||
.modal-content |
|||
.card.is-fullwidth |
|||
header.card-header.is-info |
|||
p.card-header-title Move document |
|||
.card-content |
|||
.content |
|||
label.label Enter the new document path: |
|||
p.control |
|||
input.input(type='text', placeholder='page-name')#txt-move-prompt |
|||
span.help.is-danger.is-hidden This document path is invalid or not allowed! |
|||
span Note that moving or renaming documents can lead to broken links. Make sure to edit any page that links to this document afterwards! |
|||
footer.card-footer |
|||
a.card-footer-item.btn-move-prompt Discard |
|||
a.card-footer-item.btn-move-go Move |
@ -1,9 +1,29 @@ |
|||
extends ../layout.pug |
|||
|
|||
block rootNavCenter |
|||
h2.nav-item= pageData.meta.title |
|||
|
|||
block rootNavRight |
|||
i.nav-item#notifload |
|||
a.nav-item.btn-move-prompt.is-hidden |
|||
| Move |
|||
a.nav-item(href='/' + pageData.meta.path) |
|||
| Normal View |
|||
span.nav-item |
|||
a.button(href='/edit/' + pageData.meta.path) |
|||
span.icon |
|||
i.fa.fa-edit |
|||
span Edit |
|||
a.button.is-primary.btn-create-prompt |
|||
span.icon |
|||
i.fa.fa-plus |
|||
span Create |
|||
|
|||
block content |
|||
|
|||
#page-type-source(data-entrypath=pageData.meta.path) |
|||
.ace-container |
|||
#source-display= pageData.markdown |
|||
|
|||
include ../modals/create |
|||
include ../modals/create.pug |
|||
include ../modals/move.pug |
Write
Preview
Loading…
Cancel
Save