<%- include('partials/header.ejs') %>
<link href="/styles/users/post.css" rel="stylesheet"></link>
<script src="/scripts/ckeditor/ckeditor.js"></script>
<script src="/scripts/users/post.js"></script>
<style>
.Main .content form .wrapper{
margin-top:5px;
display: grid;
grid-template-columns: auto 30% 15%;
}
</style>
<section class='Main region'>
<div class='sidebar'>
<%- include('partials/menu.ejs') %>
</div>
<div class='content'>
<form action='/users/page' method='post'>
<input type='text' name='title' placeholder='ចំណងជើង' required />
<textarea name="content" id="editor" ></textarea>
<div class='wrapper'>
<input type='text' name='thumb' requred placeholder="តំណរភ្ជាប់រូបតំណាង" />
<input type='datetime-local' value='<%= datetime %>' name='datetime' required />
<input type='submit' value='ចុះផ្សាយ' />
</div>
<input name='entries' value='' type='hidden' />
</form>
<div class='form'>
<select name='type'>
<option>YouTube</option>
<option>YouTubePlaylist</option>
<option>Facebook</option>
<option>OK</option>
<option>Dailymotion</option>
<option>Vimeo</option>
</select>
<input name='id' type='text' placeholder="អត្តសញ្ញាណវីដេអូ" required />
<select name='ending'>
<option>ចប់ហើយ</option>
<option>មិនទាន់ចប់</option>
</select>
<input onclick='genJson()' type="button" value="បញ្ចូលវីដេអូ" />
</div>
<table class='viddata'></table>
<script src="/scripts/ckeditor/config.js"></script>
</div>
</section>
<%- include('partials/listing.ejs') %>
<%- include('partials/footer.ejs') %>
var express = require('express')
var router = express.Router()
var settings = require('../../settings')
router.get('/', async function(req, res, next) {
settings.dLogo = 'ទំព័រស្តាទិក'
if(req.session.user){
const today = new Date()
const date = today.toLocaleDateString('fr-CA')
const time = today.toLocaleTimeString('it-IT')
settings.datetime = date + 'T' + time
const count = await require('../../controllers/pages/count')()
settings.message = `ចំនួនទំព័រស្តាទិកសរុបៈ ${count}`
const read = await require('../../controllers/pages/read')
settings.items = await read(settings.dItemLimit)
settings.route = 'page'
res.render('users/page', settings)
}else{
res.redirect('/users')
}
})
router.post('/', async function(req, res, next) {
if(req.session.user.role === "Admin"){
await require('../../controllers/pages/create')(req)
res.redirect('/users/page')
}else{
res.redirect('/users')
}
})
module.exports = router
const schema = require('./schema')
async function createPage(req){
const pageSchema = await schema()
const id = (new Date()).getTime().toString(36) + Math.random().toString(36).slice(2)
const title = req.body.title
const content = req.body.content
const thumb = req.body.thumb
const video = req.body.entries
const date = new Date(req.body.datetime)
const author = req.session.user.username
const page = new pageSchema({id: id, title: title, content: content, thumb: thumb,
video: video, date: date, author: author})
return await page.save()
}
module.exports = createPage
GitHub: https://github.com/Sokhavuth/tv
Vercel: https://tv-neon.vercel.app
Responsive: http://www.responsinator.com