mirror of https://github.com/Requarks/wiki.git
15 changed files with 168 additions and 43 deletions
Unified View
Diff Options
-
1README.md
-
2assets/css/app.css
-
4assets/js/app.js
-
6client/js/components/alerts.js
-
49client/js/components/editor-video.js
-
45client/js/components/editor.js
-
8controllers/pages.js
-
2gulpfile.js
-
5libs/local.js
-
44libs/markdown.js
-
2libs/uploads.js
-
12views/common/alerts.pug
-
28views/modals/editor-video.pug
-
2views/pages/create.pug
-
1views/pages/edit.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
4
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,49 @@ |
|||||
|
|
||||
|
const videoRules = { |
||||
|
'youtube': new RegExp(/(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/, 'i'), |
||||
|
'vimeo': new RegExp(/vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:$|\/|\?)/, 'i'), |
||||
|
'dailymotion': new RegExp(/(?:dailymotion\.com(?:\/embed)?(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[\-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/, 'i') |
||||
|
}; |
||||
|
|
||||
|
// Vue Video instance
|
||||
|
|
||||
|
let vueVideo = new Vue({ |
||||
|
el: '#modal-editor-video', |
||||
|
data: { |
||||
|
link: '' |
||||
|
}, |
||||
|
methods: { |
||||
|
open: (ev) => { |
||||
|
$('#modal-editor-video').addClass('is-active'); |
||||
|
$('#modal-editor-video input').focus(); |
||||
|
}, |
||||
|
cancel: (ev) => { |
||||
|
mdeModalOpenState = false; |
||||
|
$('#modal-editor-video').removeClass('is-active'); |
||||
|
vueVideo.link = ''; |
||||
|
}, |
||||
|
insertVideo: (ev) => { |
||||
|
|
||||
|
if(mde.codemirror.doc.somethingSelected()) { |
||||
|
mde.codemirror.execCommand('singleSelection'); |
||||
|
} |
||||
|
|
||||
|
// Guess video type
|
||||
|
|
||||
|
let videoType = _.findKey(videoRules, (vr) => { |
||||
|
return vr.test(vueVideo.link); |
||||
|
}); |
||||
|
if(_.isNil(videoType)) { |
||||
|
videoType = 'video'; |
||||
|
} |
||||
|
|
||||
|
// Insert video tag
|
||||
|
|
||||
|
let videoText = '[video](' + vueVideo.link + '){.' + videoType + '}\n'; |
||||
|
|
||||
|
mde.codemirror.doc.replaceSelection(videoText); |
||||
|
vueVideo.cancel(); |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
}); |
@ -1,16 +1,14 @@ |
|||||
#alerts |
#alerts |
||||
ul |
ul |
||||
template(v-for="aItem in children", track-by='_uid') |
template(v-for="aItem in children", track-by='_uid') |
||||
.notification(v-bind:class='aItem.class') |
|
||||
|
li(v-bind:class='aItem.class') |
||||
button.delete(v-on:click='acknowledge(aItem._uid)') |
button.delete(v-on:click='acknowledge(aItem._uid)') |
||||
h3 {{ aItem.title }} |
h3 {{ aItem.title }} |
||||
span {{ aItem.message }} |
span {{ aItem.message }} |
||||
|
|
||||
if appflash.length > 0 |
if appflash.length > 0 |
||||
script(type='text/javascript') |
|
||||
| var alertsData = |
|
||||
!= JSON.stringify(appflash) |
|
||||
| ; |
|
||||
|
script(type='text/javascript'). |
||||
|
var alertsData = !{JSON.stringify(appflash)}; |
||||
else |
else |
||||
script(type='text/javascript') |
|
||||
| var alertsData = []; |
|
||||
|
script(type='text/javascript'). |
||||
|
var alertsData = []; |
@ -0,0 +1,28 @@ |
|||||
|
|
||||
|
.modal#modal-editor-video |
||||
|
.modal-background |
||||
|
.modal-container |
||||
|
.modal-content |
||||
|
header.is-green Insert Video Player |
||||
|
section |
||||
|
label.label Enter the link to the video to be embedded: |
||||
|
p.control.is-fullwidth |
||||
|
input.input(type='text', placeholder='https://www.youtube.com/watch?v=xxxxxxxxxxx', v-model='link') |
||||
|
span.help.is-red.is-hidden This URL is invalid or not supported! |
||||
|
.note The following are supported: |
||||
|
ul |
||||
|
li |
||||
|
i.icon-youtube-play |
||||
|
span Youtube |
||||
|
li |
||||
|
i.icon-vimeo |
||||
|
span Vimeo |
||||
|
li |
||||
|
i.icon-film |
||||
|
span Dailymotion |
||||
|
li |
||||
|
i.icon-video |
||||
|
span Any standard MP4 file |
||||
|
footer |
||||
|
a.button.is-grey.is-outlined(v-on:click="cancel") Discard |
||||
|
a.button.is-green(v-on:click="insertVideo") Insert Video |
Write
Preview
Loading…
Cancel
Save