Removed fitty.js, using manual font-size setting instead. Fixed valid/expired posts check.

This commit is contained in:
2017-09-16 13:06:44 +07:00
parent d06921fcc8
commit 6cb980051c
6 changed files with 83 additions and 66 deletions

View File

@@ -24,49 +24,60 @@ class Posts
$date = new \DateTime();
$now = $date->format("Y-m-d");
$valid = $this->model->showAll([
['valid_at', '<=', $now],
['status', '!=', 0]
$data = [];
$valid_data = $this->model->showAll([
['valid_at', '<=', $now]
]);
if ($valid) {
foreach ($valid as $fields) {
if (is_array($fields)) {
$id = $fields['id'];
} else {
$id = $valid['id'];
}
$this->model->update(['status' => 1], $id);
if ($valid_data != false) {
if (array_key_exists(0, $valid_data)) {
$data = $valid_data;
} else {
$data[] = $valid_data;
}
foreach ($data as $fields) {
$id = $fields['id'];
}
$this->model->update(['status' => 1], $id);
$data = [];
}
$not_valid = $this->model->showAll([
['valid_at', '>', $now],
['status', '!=', 0]
$notvalid_data = $this->model->showAll([
['valid_at', '>', $now]
]);
if ($not_valid) {
foreach ($not_valid as $fields) {
if (is_array($fields)) {
$id = $fields['id'];
} else {
$id = $not_valid['id'];
}
$this->model->update(['status' => 2], $id);
if ($notvalid_data != false) {
if (array_key_exists(0, $notvalid_data)) {
$data = $notvalid_data;
} else {
$data[] = $notvalid_data;
}
foreach ($data as $fields) {
$id = $fields['id'];
}
$this->model->update(['status' => 2], $id);
$data = [];
}
$expired = $this->model->showAll([
['expired_at', '<', $now],
['status', '!=', 0]
$expired_data = $this->model->showAll([
['expired_at', '<', $now]
]);
if ($expired) {
foreach ($expired as $fields) {
if (is_array($fields)) {
$id = $fields['id'];
} else {
$id = $expired['id'];
}
$this->model->update(['status' => 0], $id);
if ($expired_data != false) {
if (array_key_exists(0, $expired_data)) {
$data = $expired_data;
} else {
$data[] = $expired_data;
}
foreach ($data as $fields) {
$id = $fields['id'];
}
$this->model->update(['status' => 0], $id);
$data = [];
}
}
@@ -318,13 +329,10 @@ class Posts
foreach ($args as $key => $val) {
if (strpos($val, "##date##") !== false) {
$date = new \DateTime();
$now = $date->format("Y-m-d");
$args[$key] = $now;
}
}
var_dump($args);
if ($this->model->update($args, $id)) {
Session::flash('info', 'Data berhasil diperbarui');
Redirect::to('/');

View File

@@ -10,8 +10,8 @@ class Post extends \Core\Model
[
'id int(3) NOT NULL AUTO_INCREMENT',
'category int(3) NOT NULL',
'created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
'valid_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP',
'created_at timestamp NOT NULL DEFAULT "00-00-00 00:00:00"',
'valid_at timestamp NOT NULL DEFAULT "00-00-00 00:00:00"',
'expired_at timestamp NOT NULL',
'creator int(3) NOT NULL',
'edited_at timestamp',
@@ -92,6 +92,7 @@ class Post extends \Core\Model
}
}
$query = $db->prepare($sql);
if (count($conditions)) {

View File

@@ -5,7 +5,7 @@
{% block body %}
<main class="documentation">
<section>
<h1>Pengumuman {{ post.id }}</h1>
<h1>Ubah Pengumuman</h1>
<form method="post">
<div class="flex five grow">

View File

@@ -13,7 +13,7 @@
{% endif %}
<a href="/logout" class="navy button" data-tooltip="Keluar"><i class="fa fa-sign-out" aria-hidden="true"></i>&nbsp;Keluar</a>
{% else %}
<a href="/login" class="navy hidden-hover" data-tooltip="Masuk">
<a href="/login" class="navy hidden-hover button" data-tooltip="Masuk">
<i class="fa fa-sign-in" aria-hidden="true"></i>&nbsp;Masuk
</a>
{% endif %}
@@ -26,14 +26,14 @@
{% if privilege == "" %}
{% if not posts %}
<div style="background:#fff;text-align:left;width:100vw;padding:10vh 0 0;">
<h1 class="fitty">Tidak ada pengumuman</h1>
<div style="background:#fff;text-align:left;max-width:100vw;padding:10vh 0 0;">
<h1 class="fitty pengumuman">Tidak ada pengumuman</h1>
</div>
{% else %}
<div id="slidr-div">
{% for post in posts %}
<div data-slidr="{{ post.id }}" style="color:{{ post.foreground }};background-color:{{ post.background }};width:100%;height:100vh;padding:15vh 0;">
<div class="fitty" style="padding:0 5rem">
<div data-slidr="{{ post.id }}" style="color:{{ post.foreground }};background-color:{{ post.background }};width:100vw;height:100vh;">
<div style="padding:15vh 0">
{{ post.content|rendermd }}
</div>
</div>
@@ -45,10 +45,10 @@
<div style="background:#fff;text-align:left;width:100vw;padding:10vh 0 0;">
<div class="filter flex six-600 four grow">
<div class="sixth-600 none"></div>
<a href="/" class="navy noFitty">Semua</a>
<a href="/?status=1" class="navy noFitty">Aktif</a>
<a href="/?status=2" class="navy noFitty">Belum Aktif</a>
<a href="/?status=0" class="navy noFitty">Nonaktif</a>
<a href="/" class="navy" style="font-size:smaller;">Semua</a>
<a href="/?status=1" class="navy" style="font-size:smaller;">Aktif</a>
<a href="/?status=2" class="navy" style="font-size:smaller;">Belum Aktif</a>
<a href="/?status=0" class="navy" style="font-size:smaller;">Nonaktif</a>
<div class="sixth-600 none"></div>
</div>
<div class="flex four-900 full card-wrapper" style="padding: 0 .6em;">
@@ -91,6 +91,7 @@
<div class="half-900">
<input type="hidden" name="id" value="{{ post.id }}">
<input type="hidden" name="valid_at" value="##date##">
<input type="hidden" name="status" value="1">
<!-- Method -->
<input type="hidden" name="_method" value="put">
<!-- Token -->
@@ -112,16 +113,6 @@
</main>
<script>
fitty('.fitty', {
minSize: 120,
maxSize: 700
});
fitty('.noFitty', {
minSize: 15,
maxSize: 15
});
slidr.create('slidr-div', {
controls: false,
timing: {'linear': '0.5s ease-in'},

View File

@@ -64,12 +64,28 @@
.fitty {
display: inline-block;
white-space: nowrap;
white-space: normal;
line-height: 1em;
padding-bottom: .1em;
text-align: center;
}
#slidr-div p {
margin: 0;
text-align: center;
line-height: 1;
}
@media screen and (orientation: landscape) {
#slidr-div p {
font-size: 8vw;
}
}
@media screen and (orientation: portrait) {
#slidr-div p {
font-size: 10vh;
}
}
.title {
font-family: 'Lobster', cursive;
font-size: x-large;
@@ -139,6 +155,14 @@
.fitty > p {
margin: 0;
}
nav {
max-width: 100vw;
}
.pengumuman {
width: 100%;
}
</style>
</head>
<body>
@@ -149,7 +173,6 @@
{% block nav %}{% endblock %}
</nav>
<script src="/js/rome.js"></script>
<script src="/js/fitty.min.js"></script>
<script src="/js/slidr.min.js"></script>
<script src="/js/simplemde.min.js"></script>
{% block body %}
@@ -170,6 +193,5 @@
}, 50);
}
</script>
</body>
</html>