mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 12:06:22 +05:30
Improvements
This commit is contained in:
parent
08cdaefc05
commit
2a6d94fc5e
3 changed files with 32 additions and 43 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
define('HTMLY', true);
|
define('HTMLY', true);
|
||||||
|
define('HTMLY_VERSION', 'v2.8.9');
|
||||||
$config_file = 'config/config.ini';
|
$config_file = 'config/config.ini';
|
||||||
require 'system/vendor/autoload.php';
|
require 'system/vendor/autoload.php';
|
||||||
require 'system/htmly.php';
|
require 'system/htmly.php';
|
||||||
|
|
@ -238,9 +238,8 @@ get('/author/:name', function ($name) {
|
||||||
$posts = get_profile_posts($name, $page, $perpage);
|
$posts = get_profile_posts($name, $page, $perpage);
|
||||||
|
|
||||||
$total = get_count('/'.$name.'/', 'dirname');
|
$total = get_count('/'.$name.'/', 'dirname');
|
||||||
$username = 'config/users/' . $name . '.ini';
|
|
||||||
|
|
||||||
if ($total === 0 && !file_exists($username)) {
|
if ($total === 0) {
|
||||||
not_found();
|
not_found();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2299,7 +2298,7 @@ get('/archive/:req', function ($req) {
|
||||||
|
|
||||||
$posts = get_archive($req, $page, $perpage);
|
$posts = get_archive($req, $page, $perpage);
|
||||||
|
|
||||||
$total = get_count($req);
|
$total = get_count($req, 'basename');
|
||||||
|
|
||||||
if (empty($posts) || $page < 1) {
|
if (empty($posts) || $page < 1) {
|
||||||
// a non-existing page
|
// a non-existing page
|
||||||
|
|
|
||||||
|
|
@ -1063,8 +1063,6 @@ function get_author($name)
|
||||||
{
|
{
|
||||||
$names = get_author_name();
|
$names = get_author_name();
|
||||||
|
|
||||||
$username = 'config/users/' . $name . '.ini';
|
|
||||||
|
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
|
|
||||||
if (!empty($names)) {
|
if (!empty($names)) {
|
||||||
|
|
@ -1108,7 +1106,7 @@ function get_author($name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($tmp) || file_exists($username)) {
|
if (!empty($tmp)) {
|
||||||
return $tmp;
|
return $tmp;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1224,15 +1222,15 @@ function get_related($tag, $custom = null, $count = null)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return post count. Matching $var.
|
// Return post count. Matching $var and $str provided.
|
||||||
function get_count($var)
|
function get_count($var, $str)
|
||||||
{
|
{
|
||||||
$posts = get_blog_posts();
|
$posts = get_blog_posts();
|
||||||
|
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
|
|
||||||
foreach ($posts as $index => $v) {
|
foreach ($posts as $index => $v) {
|
||||||
$arr = explode('_', $v['basename']);
|
$arr = explode('_', $v[$str]);
|
||||||
$url = $arr[0];
|
$url = $arr[0];
|
||||||
if (stripos($url, "$var") !== false) {
|
if (stripos($url, "$var") !== false) {
|
||||||
$tmp[] = $v;
|
$tmp[] = $v;
|
||||||
|
|
@ -2583,6 +2581,7 @@ function generate_rss($posts, $data = null)
|
||||||
->url($data->url)
|
->url($data->url)
|
||||||
->appendTo($feed);
|
->appendTo($feed);
|
||||||
}
|
}
|
||||||
|
if ($posts) {
|
||||||
foreach ($posts as $p) {
|
foreach ($posts as $p) {
|
||||||
|
|
||||||
if (!empty($rssLength)) {
|
if (!empty($rssLength)) {
|
||||||
|
|
@ -2609,6 +2608,7 @@ function generate_rss($posts, $data = null)
|
||||||
->url($p->url)
|
->url($p->url)
|
||||||
->appendTo($channel);
|
->appendTo($channel);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $feed;
|
return $feed;
|
||||||
}
|
}
|
||||||
|
|
@ -3063,18 +3063,7 @@ function head_contents()
|
||||||
{
|
{
|
||||||
$output = '';
|
$output = '';
|
||||||
$wmt_id = config('google.wmt.id');
|
$wmt_id = config('google.wmt.id');
|
||||||
static $_version = array();
|
$version = 'HTMLy ' . constant('HTMLY_VERSION');
|
||||||
|
|
||||||
$filename = "cache/installedVersion.json";
|
|
||||||
if (file_exists($filename)) {
|
|
||||||
$_version = json_decode(file_get_contents($filename), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_version['tag_name'])) {
|
|
||||||
$version = 'HTMLy ' . $_version['tag_name'];
|
|
||||||
} else {
|
|
||||||
$version = 'HTMLy';
|
|
||||||
}
|
|
||||||
|
|
||||||
$favicon = '<link rel="icon" type="image/x-icon" href="' . site_url() . 'favicon.ico" />';
|
$favicon = '<link rel="icon" type="image/x-icon" href="' . site_url() . 'favicon.ico" />';
|
||||||
$charset = '<meta charset="utf-8" />';
|
$charset = '<meta charset="utf-8" />';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue