<!--views/dashboard/home.tpl-->
%include('./dashboard/partials/header.tpl')
<style>
#content{
min-height: 350px;
background: white;
padding: 0;
box-sizing: border-box;
}
#content .ck-editor__editable {
min-height: 350px !important;
}
#content #post-title{
width: 100%;
box-sizing: border-box;
padding: 5px 10px;
font: 16px/1.5 Koulen;
opacity: .4;
}
#content #bottombar{
background: #ebebeb;
padding: 5px;
border: 1px solid #bebbbb;
}
#content #bottombar .bottom-widget{
font: 14px/1.5 OdorMeanChey;
height: 30px;
}
#content #bottombar input:hover{
cursor: pointer;
}
#content #bottombar #category{
min-width: 80px;
}
#content #post-date, #content #post-time{
height: 24px !important;
font:bold 14px/1.5 'Lucida Sans' !important;
width: 100px;
}
#content #video{
min-width: 70px;
}
</style>
<div id='main' class='main region'>
%include('./dashboard/partials/sidebar.tpl')
<section id='content' class='content'>
<form action="/posting" method="post">
<input id="post-title" name="post-title" type="text" placeholder="ចំណងជើង" />
<textarea name="content" id="editor"></textarea>
<div id="bottombar">
<input class="bottom-widget" type="submit" value="ចុះផ្សាយ">
<select class="bottom-widget" id="category" name="category">
<option>News</option>
<option>Python</option>
<option>Node.js</option>
<option>PHP</option>
</select>
<input id="post-date" value="{{data['datetime'][0]}}" class="bottom-widget" type="text" name="post-date" />
<input id="post-time" value="{{data['datetime'][1]}}" class="bottom-widget" type="text" name="post-time" />
<input id="video" class="bottom-widget" type="button" value="VIDEO" />
</div>
</form>
<script src="/static/scripts/ckeditor/config.js"></script>
</section><!--content-->
</div><!--main-->
%include('./dashboard/partials/footer.tpl')
#controllers/login.py
import config
from pytz import timezone
from datetime import datetime
from bottle import route, template, request, response, redirect
def checkLogin(username, password):
if (username == 'Guest') and (password == 'password'):
return True
else:
return False
def getTimeZone():
khtz = timezone('Asia/Phnom_Penh')
date = datetime.now().astimezone(tz=khtz).strftime('%d-%m-%Y')
time = datetime.now().astimezone(tz=khtz).strftime('%H:%M')
return (date, time)
@route('/login', method="POST")
def user():
username = request.forms.get('fusername')
password = request.forms.get('fpassword')
if checkLogin(username, password):
response.set_cookie("logged-in", username, secret='some-secret-key')
redirect('/login')
@route('/login')
def login():
username = request.get_cookie("logged-in", secret='some-secret-key')
if username:
config.kargs['blogTitle'] = "ទំព័រគ្រប់គ្រង"
config.kargs['datetime'] = getTimeZone()
return template('dashboard/home', data=config.kargs)
else:
return template('login', data=config.kargs)
ClassicEditor
.create( document.querySelector( '#editor' ), {
toolbar: ['fontfamily', 'fontsize', 'fontcolor', 'bold', 'italic',
'bulletedList', 'indent', 'outdent', 'numberedList', 'link', 'blockQuote',
'code', 'codeblock', 'imageinsert', 'mediaembed', 'undo', 'redo' ],
fontFamily: {
options: [
'ឧត្តមានជ័យ, OdorMeanChey', 'អក្សរដៃ, HandWriting',
'គូលេន, Koulen', 'ក្រូចឆ្នារ, Limonf3',
'បាយ័ន, Bayon', 'ក្រសាំង, Rooster',
'មូល, Moul',
'Arial, Helvetica, sans-serif',
'Courier New, Courier, monospace',
'Georgia, serif',
'Lucida Sans Unicode, Lucida Grande, sans-serif',
'Tahoma, Geneva, sans-serif',
'Times New Roman, Times, serif',
'Trebuchet MS, Helvetica, sans-serif',
'Verdana, Geneva, sans-serif',
],
supportAllValues: true
},
fontSize: {
options: [
9,
11,
13,
'default',
17,
19,
21
],
supportAllValues: true
},
})
.catch( error => {
console.error( error );
});
GitHub: https://github.com/Sokhavuth/kwblog
Heroku: https://khmerweb-kwblog.herokuapp.com/














