mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 12:06:22 +05:30
Improvements
Styling, performance tweak, and bugs fixes.
This commit is contained in:
parent
f646e5f4f2
commit
db786347c6
17 changed files with 197 additions and 107 deletions
|
|
@ -86,7 +86,7 @@ function remove_accent($str)
|
|||
}
|
||||
|
||||
// Edit blog posts
|
||||
function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $fi, $vid)
|
||||
function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $img, $vid)
|
||||
{
|
||||
$oldurl = explode('_', $oldfile);
|
||||
if ($date !== null) {
|
||||
|
|
@ -94,17 +94,27 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null,
|
|||
}
|
||||
|
||||
$post_title = $title;
|
||||
$post_fi = $fi;
|
||||
$post_img = $img;
|
||||
$post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid);
|
||||
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
|
||||
$post_tag = rtrim($post_tag, ',');
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
if ($description !== null) {
|
||||
$post_description = "\n<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
||||
$post_content = '<!--fi ' . $post_fi . ' fi-->' . "\n\n" . '<!--vid ' . $post_vid . ' vid-->' . "\n\n" . $post_content;
|
||||
if ($img !== null) {
|
||||
$post_img = "\n<!--img " . $post_img. " img-->";
|
||||
} else {
|
||||
$post_img = "";
|
||||
}
|
||||
if ($vid !== null) {
|
||||
$post_vid = "\n<!--vid " . $post_vid. " vid-->";
|
||||
} else {
|
||||
$post_vid = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_img . $post_vid ."\n\n" . $content;
|
||||
|
||||
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
||||
if (get_magic_quotes_gpc()) {
|
||||
|
|
@ -182,22 +192,32 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr
|
|||
}
|
||||
|
||||
// Add blog post
|
||||
function add_post($title, $tag, $url, $content, $user, $description = null, $fi, $vid)
|
||||
function add_post($title, $tag, $url, $content, $user, $description = null, $img, $vid)
|
||||
{
|
||||
|
||||
$post_date = date('Y-m-d-H-i-s');
|
||||
$post_title = $title;
|
||||
$post_fi = $fi;
|
||||
$post_img = $img;
|
||||
$post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid);
|
||||
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
|
||||
$post_tag = rtrim($post_tag, ',');
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
if ($description !== null) {
|
||||
$post_description = "\n<!--d " . $description . " d-->";
|
||||
} else {
|
||||
$post_description = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
||||
$post_content = '<!--fi ' . $post_fi . ' fi-->' . "\n\n" . '<!--vid ' . $post_vid . ' vid-->' . "\n\n" . $post_content;
|
||||
if ($img !== null) {
|
||||
$post_img = "\n<!--img " . $post_img. " img-->";
|
||||
} else {
|
||||
$post_img = "";
|
||||
}
|
||||
if ($vid !== null) {
|
||||
$post_vid = "\n<!--vid " . $post_vid. " vid-->";
|
||||
} else {
|
||||
$post_vid = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . $post_img . $post_vid ."\n\n" . $content;
|
||||
|
||||
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
||||
if (get_magic_quotes_gpc()) {
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@
|
|||
echo $p->description;
|
||||
} ?></textarea>
|
||||
<br><br>
|
||||
Featured Image (optional)<br><input type="text" class="text" name="fi" value="<?php if (isset($postFi)) {
|
||||
echo $postFi;
|
||||
Featured Image (optional)<br><input type="text" class="text" name="img" value="<?php if (isset($postImg)) {
|
||||
echo $postImg;
|
||||
} ?>"/><br><br>
|
||||
Embed Youtube Video (optional)<br><input type="text" class="text" name="vid" value="<?php if (isset($postVid)) {
|
||||
echo $postVid;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ if (isset($p->file)) {
|
|||
|
||||
$content = file_get_contents($url);
|
||||
$oldtitle = get_content_tag('t', $content, 'Untitled');
|
||||
$oldfi = get_content_tag('fi', $content);
|
||||
$oldimg = get_content_tag('img', $content);
|
||||
$oldvid = get_content_tag('vid', $content);
|
||||
$oldcontent = remove_html_comments($content);
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ $delete = site_url() . date('Y/m', $postdate) . '/' . $oldmd . '/delete?destinat
|
|||
echo $p->description;
|
||||
} ?></textarea>
|
||||
<br><br>
|
||||
Featured Image (optional)<br><input type="text" class="text" name="fi" value="<?php echo $oldfi ?>"/><br><br>
|
||||
Featured Image (optional)<br><input type="text" class="text" name="img" value="<?php echo $oldimg ?>"/><br><br>
|
||||
Embed Youtube Video (optional)<br><input type="text" class="text" name="vid" value="<?php echo $oldvid ?>"/><br><br>
|
||||
|
||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
||||
|
|
|
|||
19
system/admin/views/update.html.php
Normal file
19
system/admin/views/update.html.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
use \Kanti\HubUpdater;
|
||||
|
||||
$CSRF = get_csrf();
|
||||
|
||||
$updater = new HubUpdater(array(
|
||||
'name' => 'danpros/htmly',
|
||||
'prerelease' => !!config("prerelease"),
|
||||
));
|
||||
|
||||
if ($updater->able()) {
|
||||
$info = $updater->getNewestInfo();
|
||||
echo '<h3>Update Available</h3>';
|
||||
echo '<p><a href="' . $base . 'admin/update/now/' . $CSRF . '" alt="' . $info['name'] . '">Update to ' . $info['tag_name'] . '</a></p>';
|
||||
} else {
|
||||
echo '<h3>No Available Update</h3>';
|
||||
echo '<p>You are using the latest HTMLy version.</p>';
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ post('/:year/:month/:name/edit', function () {
|
|||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||
|
||||
$title = from($_REQUEST, 'title');
|
||||
$fi = from($_REQUEST, 'fi');
|
||||
$img = from($_REQUEST, 'img');
|
||||
$vid = from($_REQUEST, 'vid');
|
||||
$tag = from($_REQUEST, 'tag');
|
||||
$url = from($_REQUEST, 'url');
|
||||
|
|
@ -352,7 +352,7 @@ post('/:year/:month/:name/edit', function () {
|
|||
if (empty($url)) {
|
||||
$url = $title;
|
||||
}
|
||||
edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $fi, $vid);
|
||||
edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $img, $vid);
|
||||
} else {
|
||||
$message['error'] = '';
|
||||
if (empty($title)) {
|
||||
|
|
@ -374,7 +374,7 @@ post('/:year/:month/:name/edit', function () {
|
|||
'error' => '<ul>' . $message['error'] . '</ul>',
|
||||
'oldfile' => $oldfile,
|
||||
'postTitle' => $title,
|
||||
'postFi' => $fi,
|
||||
'postImg' => $img,
|
||||
'postVid' => $vid,
|
||||
'postTag' => $tag,
|
||||
'postUrl' => $url,
|
||||
|
|
@ -1292,6 +1292,22 @@ get('/feed/opml', function () {
|
|||
echo generate_opml();
|
||||
});
|
||||
|
||||
// Update page
|
||||
get('/admin/update', function () {
|
||||
if (login()) {
|
||||
config('views.root', 'system/admin/views');
|
||||
render('update', array(
|
||||
'head_contents' => head_contents('Check for Update - ' . blog_title(), blog_description(), site_url()),
|
||||
'bodyclass' => 'updatepage',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Update HTMLy'
|
||||
));
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
die;
|
||||
});
|
||||
|
||||
get('/admin/update/now/:csrf', function ($CSRF) {
|
||||
|
||||
$proper = is_csrf_proper($CSRF);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use \Michelf\MarkdownExtra;
|
|||
use \Suin\RSSWriter\Feed;
|
||||
use \Suin\RSSWriter\Channel;
|
||||
use \Suin\RSSWriter\Item;
|
||||
use \Kanti\HubUpdater;
|
||||
|
||||
// Get blog post path. Unsorted. Mostly used on widget.
|
||||
function get_post_unsorted()
|
||||
|
|
@ -223,7 +222,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
$url = array();
|
||||
$bc = array();
|
||||
|
||||
$t = explode(',', $arr[1]);
|
||||
$t = explode(',', rtrim($arr[1], ','));
|
||||
foreach ($t as $tt) {
|
||||
$tag[] = array($tt, site_url() . 'tag/' . $tt);
|
||||
}
|
||||
|
|
@ -243,7 +242,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
|
||||
// Extract the title and body
|
||||
$post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date));
|
||||
$post->feature = get_content_tag('fi', $content);
|
||||
$post->image = get_content_tag('img', $content);
|
||||
$post->video = get_content_tag('vid', $content);
|
||||
|
||||
// Get the contents and convert it to HTML
|
||||
|
|
@ -319,7 +318,7 @@ function get_tag($tag, $page, $perpage, $random)
|
|||
foreach ($posts as $index => $v) {
|
||||
$url = $v['filename'];
|
||||
$str = explode('_', $url);
|
||||
$mtag = explode(',', $str[1]);
|
||||
$mtag = explode(',', rtrim($str[1], ','));
|
||||
$etag = explode(',', $tag);
|
||||
foreach ($mtag as $t) {
|
||||
foreach ($etag as $e) {
|
||||
|
|
@ -727,7 +726,7 @@ function tag_cloud()
|
|||
|
||||
$arr = explode('_', $v);
|
||||
|
||||
$data = $arr[1];
|
||||
$data = rtrim($arr[1], ',');
|
||||
$mtag = explode(',', $data);
|
||||
foreach ($mtag as $etag) {
|
||||
$tags[] = $etag;
|
||||
|
|
@ -1646,13 +1645,6 @@ function toolbar()
|
|||
$role = user('role', $user);
|
||||
$base = site_url();
|
||||
|
||||
$CSRF = get_csrf();
|
||||
|
||||
$updater = new HubUpdater(array(
|
||||
'name' => 'danpros/htmly',
|
||||
'prerelease' => !!config("prerelease"),
|
||||
));
|
||||
|
||||
echo <<<EOF
|
||||
<link href="{$base}themes/default/css/toolbar.css" rel="stylesheet" />
|
||||
EOF;
|
||||
|
|
@ -1669,10 +1661,7 @@ EOF;
|
|||
echo '<li><a href="' . $base . 'admin/backup">Backup</a></li>';
|
||||
echo '<li><a href="' . $base . 'admin/config">Config</a></li>';
|
||||
echo '<li><a href="' . $base . 'admin/clear-cache">Clear cache</a></li>';
|
||||
if ($updater->able()) {
|
||||
$info = $updater->getNewestInfo();
|
||||
echo '<li><a href="' . $base . 'admin/update/now/' . $CSRF . '" alt="' . $info['name'] . '">Update to ' . $info['tag_name'] . '</a></li>';
|
||||
}
|
||||
echo '<li><a href="' . $base . 'admin/update">Update</a></li>';
|
||||
echo '<li><a href="' . $base . 'logout">Logout</a></li>';
|
||||
|
||||
echo '</ul></div>';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue