Browse Source

Add offline message

pull/674/head
danpros 1 year ago
parent
commit
0663880cfb
2 changed files with 54 additions and 44 deletions
  1. +27
    -22
      system/admin/admin.php
  2. +27
    -22
      system/admin/views/update.html.php

+ 27
- 22
system/admin/admin.php View File

@ -1275,39 +1275,44 @@ function find_draft_subpage($sub_static = null)
foreach ($posts as $index => $v) { foreach ($posts as $index => $v) {
if (stripos($v['basename'], $sub_static . '.md') !== false) { if (stripos($v['basename'], $sub_static . '.md') !== false) {
$post = new stdClass;
$static = str_replace('content/static/', '', dirname($v['dirname'])); $static = str_replace('content/static/', '', dirname($v['dirname']));
// The static page URL
$url= $v['filename'];
$post->url = site_url() . $static . "/" . $url;
$post->file = $v['dirname'] . '/' . $v['basename'];
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url;
$spage = find_page($static);
$post->parent = $static;
if ($spage) {
$post = new stdClass;
// The static page URL
$url= $v['filename'];
$post->url = site_url() . $static . "/" . $url;
// Get the contents and convert it to HTML
$content = file_get_contents($post->file);
$post->file = $v['dirname'] . '/' . $v['basename'];
$post->lastMod = strtotime(date('Y-m-d H:i:s', filemtime($post->file)));
$post->md = $url;
$post->parent = $static;
// Extract the title and body
$post->title = get_content_tag('t', $content, 'Untitled static subpage: ' . format_date($post->lastMod, 'l, j F Y, H:i'));
// Get the contents and convert it to HTML
$content = file_get_contents($post->file);
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
// Extract the title and body
$post->title = get_content_tag('t', $content, 'Untitled static subpage: ' . format_date($post->lastMod, 'l, j F Y, H:i'));
$post->views = get_views($post->file);
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
$post->description = get_content_tag("d", $content, get_description($post->body));
$post->views = get_views($post->file);
$word_count = str_word_count(strip_tags($post->body));
$post->readTime = ceil($word_count / 200);
$post->description = get_content_tag("d", $content, get_description($post->body));
$tmp[] = $post;
$word_count = str_word_count(strip_tags($post->body));
$post->readTime = ceil($word_count / 200);
$tmp[] = $post;
}
} }
} }
} }


+ 27
- 22
system/admin/views/update.html.php View File

@ -9,26 +9,31 @@ $updater = new HubUpdater(array(
'name' => 'danpros/htmly', 'name' => 'danpros/htmly',
'prerelease' => !!config("prerelease"), 'prerelease' => !!config("prerelease"),
)); ));
if ($updater->able()) {
$info = $updater->getNewestInfo();
echo '<h2>'.i18n('Update_Available').'</h2><hr>';
echo '<h4>'. $info['name'] .'</h4>';
echo '<p>Version: <strong>'. $info['tag_name'] .'</strong></p>';
echo '<h5>Release Notes</h5>';
echo '<div>';
echo \Michelf\MarkdownExtra::defaultTransform($info['body']);
echo '</div>';
echo '<p><strong>Important:</strong> Please always backup your files before upgrading to newer version.</p>';
echo '<p><a class="btn btn-primary" href="' . site_url() . 'admin/update/now/' . $CSRF . '" alt="' . $info['name'] . '">'.i18n('Update_to').' '. $info['tag_name'] . ' '.i18n('now').'</a></p>';
} else {
echo '<h2>'.i18n('Congrats_You_have_the_latest_version_of_HTMLy').'</h2><hr>';
$info = $updater->getCurrentInfo();
echo '<h4>'. $info['name'] .'</h4>';
echo '<p>Installed Version: <strong>'. $info['tag_name'] .'</strong></p>';
echo '<h5>Release Notes: </h5>';
echo '<div>';
echo \Michelf\MarkdownExtra::defaultTransform($info['body']);
echo '</div>';
echo '<p><a class="btn btn-primary" target="_blank" href="' . $info['html_url'] . '">Read on Github</a></p>';
if (empty($updater->getNewestInfo())) {
echo '<h2>'.i18n('Update').'</h2><hr>';
echo "Can't check Github server for latest version. You are probably offline.";
} else {
if ($updater->able()) {
$info = $updater->getNewestInfo();
echo '<h2>'.i18n('Update_Available').'</h2><hr>';
echo '<h4>'. $info['name'] .'</h4>';
echo '<p>Version: <strong>'. $info['tag_name'] .'</strong></p>';
echo '<h5>Release Notes</h5>';
echo '<div>';
echo \Michelf\MarkdownExtra::defaultTransform($info['body']);
echo '</div>';
echo '<p><strong>Important:</strong> Please always backup your files before upgrading to newer version.</p>';
echo '<p><a class="btn btn-primary" href="' . site_url() . 'admin/update/now/' . $CSRF . '" alt="' . $info['name'] . '">'.i18n('Update_to').' '. $info['tag_name'] . ' '.i18n('now').'</a></p>';
} else {
echo '<h2>'.i18n('Congrats_You_have_the_latest_version_of_HTMLy').'</h2><hr>';
$info = $updater->getCurrentInfo();
echo '<h4>'. $info['name'] .'</h4>';
echo '<p>Installed Version: <strong>'. $info['tag_name'] .'</strong></p>';
echo '<h5>Release Notes: </h5>';
echo '<div>';
echo \Michelf\MarkdownExtra::defaultTransform($info['body']);
echo '</div>';
echo '<p><a class="btn btn-primary" target="_blank" href="' . $info['html_url'] . '">Read on Github</a></p>';
}
} }

Loading…
Cancel
Save