mirror of
https://github.com/danpros/htmly.git
synced 2026-04-23 05:56:22 +05:30
Dynamic heading
Dynamic heading for themer, there is is_index function.
This commit is contained in:
parent
f30a857608
commit
b59d9ffd55
7 changed files with 142 additions and 105 deletions
|
|
@ -438,7 +438,7 @@ function get_keyword($keyword, $page, $perpage){
|
||||||
$arr = explode('_', $v['filename']);
|
$arr = explode('_', $v['filename']);
|
||||||
$filter = $arr[1] .' '. $arr[2];
|
$filter = $arr[1] .' '. $arr[2];
|
||||||
foreach($words as $word) {
|
foreach($words as $word) {
|
||||||
if(strpos($filter, strtolower($word)) !== false) {
|
if(stripos($filter, $word) !== false) {
|
||||||
$tmp[] = $v;
|
$tmp[] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -533,72 +533,76 @@ function archive_list() {
|
||||||
$by_year = array();
|
$by_year = array();
|
||||||
$col = array();
|
$col = array();
|
||||||
|
|
||||||
foreach($posts as $index => $v){
|
if(!empty($posts)) {
|
||||||
|
|
||||||
$arr = explode('_', $v);
|
foreach($posts as $index => $v){
|
||||||
|
|
||||||
// Replaced string
|
$arr = explode('_', $v);
|
||||||
$str = $arr[0];
|
|
||||||
$replaced = substr($str, 0,strrpos($str, '/')) . '/';
|
// Replaced string
|
||||||
|
$str = $arr[0];
|
||||||
$date = str_replace($replaced,'',$arr[0]);
|
$replaced = substr($str, 0,strrpos($str, '/')) . '/';
|
||||||
$data = explode('-', $date);
|
|
||||||
$col[] = $data;
|
$date = str_replace($replaced,'',$arr[0]);
|
||||||
|
$data = explode('-', $date);
|
||||||
}
|
$col[] = $data;
|
||||||
|
|
||||||
foreach ($col as $row){
|
|
||||||
|
|
||||||
$y = $row['0'];
|
|
||||||
$m = $row['1'];
|
|
||||||
$by_year[$y][] = $m;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# Most recent year first
|
|
||||||
krsort($by_year);
|
|
||||||
# Iterate for display
|
|
||||||
$script = <<<EOF
|
|
||||||
if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '►';} else {this.parentNode.className = 'expanded';this.innerHTML = '▼';}
|
|
||||||
EOF;
|
|
||||||
echo <<<EOF
|
|
||||||
<style>ul.archivegroup{padding:0;margin:0;}.archivegroup .expanded ul{display:block;}.archivegroup .collapsed ul{display:none;}.archivegroup li.expanded,.archivegroup li.collapsed{list-style:none;}
|
|
||||||
</style>
|
|
||||||
EOF;
|
|
||||||
echo '<h3>Archive</h3>';
|
|
||||||
$i = 0;
|
|
||||||
$len = count($by_year);
|
|
||||||
foreach ($by_year as $year => $months){
|
|
||||||
if ($i == 0) {
|
|
||||||
$class = 'expanded';
|
|
||||||
$arrow = '▼';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$class = 'collapsed';
|
|
||||||
$arrow = '►';
|
|
||||||
}
|
}
|
||||||
$i++;
|
|
||||||
|
|
||||||
echo '<ul class="archivegroup">';
|
foreach ($col as $row){
|
||||||
echo '<li class="' . $class . '">';
|
|
||||||
echo '<a href="javascript:void(0)" class="toggle" onclick="' . $script . '">' . $arrow . '</a> ';
|
$y = $row['0'];
|
||||||
echo '<a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a> ';
|
$m = $row['1'];
|
||||||
echo '<span class="count">(' . count($months) . ')</span>';
|
$by_year[$y][] = $m;
|
||||||
echo '<ul class="month">';
|
|
||||||
|
|
||||||
$by_month = array_count_values($months);
|
|
||||||
# Sort the months
|
|
||||||
krsort($by_month);
|
|
||||||
foreach ($by_month as $month => $count){
|
|
||||||
$name = date('F', mktime(0,0,0,$month,1,2010));
|
|
||||||
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
|
|
||||||
echo ' <span class="count">(' . $count . ')</span></li>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</ul>';
|
|
||||||
echo '</li>';
|
|
||||||
echo '</ul>';
|
|
||||||
|
|
||||||
|
# Most recent year first
|
||||||
|
krsort($by_year);
|
||||||
|
# Iterate for display
|
||||||
|
$script = <<<EOF
|
||||||
|
if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '►';} else {this.parentNode.className = 'expanded';this.innerHTML = '▼';}
|
||||||
|
EOF;
|
||||||
|
echo <<<EOF
|
||||||
|
<style>ul.archivegroup{padding:0;margin:0;}.archivegroup .expanded ul{display:block;}.archivegroup .collapsed ul{display:none;}.archivegroup li.expanded,.archivegroup li.collapsed{list-style:none;}
|
||||||
|
</style>
|
||||||
|
EOF;
|
||||||
|
echo '<h3>Archive</h3>';
|
||||||
|
$i = 0;
|
||||||
|
$len = count($by_year);
|
||||||
|
foreach ($by_year as $year => $months){
|
||||||
|
if ($i == 0) {
|
||||||
|
$class = 'expanded';
|
||||||
|
$arrow = '▼';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$class = 'collapsed';
|
||||||
|
$arrow = '►';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
echo '<ul class="archivegroup">';
|
||||||
|
echo '<li class="' . $class . '">';
|
||||||
|
echo '<a href="javascript:void(0)" class="toggle" onclick="' . $script . '">' . $arrow . '</a> ';
|
||||||
|
echo '<a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a> ';
|
||||||
|
echo '<span class="count">(' . count($months) . ')</span>';
|
||||||
|
echo '<ul class="month">';
|
||||||
|
|
||||||
|
$by_month = array_count_values($months);
|
||||||
|
# Sort the months
|
||||||
|
krsort($by_month);
|
||||||
|
foreach ($by_month as $month => $count){
|
||||||
|
$name = date('F', mktime(0,0,0,$month,1,2010));
|
||||||
|
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
|
||||||
|
echo ' <span class="count">(' . $count . ')</span></li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</ul>';
|
||||||
|
echo '</li>';
|
||||||
|
echo '</ul>';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -609,27 +613,31 @@ function tag_cloud() {
|
||||||
$posts = get_post_unsorted();
|
$posts = get_post_unsorted();
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
|
||||||
foreach($posts as $index => $v){
|
if(!empty($posts)) {
|
||||||
|
|
||||||
$arr = explode('_', $v);
|
foreach($posts as $index => $v){
|
||||||
|
|
||||||
$data = $arr[1];
|
$arr = explode('_', $v);
|
||||||
$mtag = explode(',', $data);
|
|
||||||
foreach($mtag as $etag) {
|
$data = $arr[1];
|
||||||
$tags[] = $etag;
|
$mtag = explode(',', $data);
|
||||||
|
foreach($mtag as $etag) {
|
||||||
|
$tags[] = $etag;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
$tag_collection = array_count_values($tags);
|
||||||
|
ksort($tag_collection);
|
||||||
|
|
||||||
|
echo '<h3>Tags</h3>';
|
||||||
|
echo '<ul class="taglist">';
|
||||||
|
foreach ($tag_collection as $tag => $count){
|
||||||
|
echo '<li class="item"><a href="' . site_url() . 'tag/' . $tag . '">' . $tag . '</a> <span class="count">(' . $count . ')</span></li>';
|
||||||
|
}
|
||||||
|
echo '</ul>';
|
||||||
|
|
||||||
$tag_collection = array_count_values($tags);
|
|
||||||
ksort($tag_collection);
|
|
||||||
|
|
||||||
echo '<h3>Tags</h3>';
|
|
||||||
echo '<ul class="taglist">';
|
|
||||||
foreach ($tag_collection as $tag => $count){
|
|
||||||
echo '<li class="item"><a href="' . site_url() . 'tag/' . $tag . '">' . $tag . '</a> <span class="count">(' . $count . ')</span></li>';
|
|
||||||
}
|
}
|
||||||
echo '</ul>';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1237,36 +1245,39 @@ function generate_sitemap($str){
|
||||||
$posts = get_post_unsorted();
|
$posts = get_post_unsorted();
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
|
||||||
foreach($posts as $index => $v){
|
if(!empty($posts)) {
|
||||||
|
foreach($posts as $index => $v){
|
||||||
$arr = explode('_', $v);
|
|
||||||
|
|
||||||
$data = $arr[1];
|
$arr = explode('_', $v);
|
||||||
$mtag = explode(',', $data);
|
|
||||||
foreach($mtag as $etag) {
|
$data = $arr[1];
|
||||||
$tags[] = $etag;
|
$mtag = explode(',', $data);
|
||||||
|
foreach($mtag as $etag) {
|
||||||
|
$tags[] = $etag;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
foreach($tags as $t) {
|
||||||
|
$tag[] = site_url() . 'tag/' . $t;
|
||||||
foreach($tags as $t) {
|
|
||||||
$tag[] = site_url() . 'tag/' . $t;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
|
||||||
|
|
||||||
if(isset($tag)) {
|
|
||||||
|
|
||||||
$tag = array_unique($tag, SORT_REGULAR);
|
|
||||||
|
|
||||||
foreach($tag as $t) {
|
|
||||||
echo '<url><loc>' . $t . '</loc><priority>0.5</priority></url>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
||||||
|
|
||||||
|
if(isset($tag)) {
|
||||||
|
|
||||||
|
$tag = array_unique($tag, SORT_REGULAR);
|
||||||
|
|
||||||
|
foreach($tag as $t) {
|
||||||
|
echo '<url><loc>' . $t . '</loc><priority>0.5</priority></url>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</urlset>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</urlset>';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif ($str == 'archive') {
|
elseif ($str == 'archive') {
|
||||||
|
|
||||||
|
|
@ -1369,6 +1380,20 @@ function is_front() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TRUE if the current page is an index page like frontpage, tag index, archive index and search index.
|
||||||
|
function is_index() {
|
||||||
|
$req = $_SERVER['REQUEST_URI'];
|
||||||
|
if(strpos($req, 'archive') !== false || strpos($req, 'tag') !== false || strpos($req, 'search') !== false){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
elseif($req == site_path() . '/') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Return blog title
|
// Return blog title
|
||||||
function blog_title() {
|
function blog_title() {
|
||||||
return config('blog.title');
|
return config('blog.title');
|
||||||
|
|
|
||||||
|
|
@ -56,19 +56,19 @@ h1{
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1.blog-title {
|
h1.blog-title, h2.blog-title {
|
||||||
text-transform:uppercase;
|
text-transform:uppercase;
|
||||||
font: 20px 'Open Sans Condensed', sans-serif;
|
font: 20px 'Open Sans Condensed', sans-serif;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1.blog-title a {
|
h1.blog-title a, h2.blog-title a {
|
||||||
color:#4f4f4f;
|
color:#4f4f4f;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1.blog-title a:hover {
|
h1.blog-title a:hover, h2.blog-title a:hover {
|
||||||
color: #389dc1;
|
color: #389dc1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,11 @@
|
||||||
<?php if(facebook()) { echo facebook();} ?>
|
<?php if(facebook()) { echo facebook();} ?>
|
||||||
<?php if(login()) { toolbar();} ?>
|
<?php if(login()) { toolbar();} ?>
|
||||||
<aside>
|
<aside>
|
||||||
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
|
<?php if(is_index()) {?>
|
||||||
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
|
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
|
||||||
|
<?php } else {?>
|
||||||
|
<h2 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h2>
|
||||||
|
<?php } ?>
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<?php echo search() ?>
|
<?php echo search() ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -469,8 +469,9 @@ p, ul {
|
||||||
margin:1em 0;
|
margin:1em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1.blog-title {
|
h1.blog-title, h2.blog-title {
|
||||||
font-style:normal;
|
font-style:normal;
|
||||||
|
font-size: 28px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1.title-post a, h2.title-index a{
|
h1.title-post a, h2.title-index a{
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,11 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<header id="header">
|
<header id="header">
|
||||||
<section id="branding">
|
<section id="branding">
|
||||||
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
|
<?php if(is_index()) {?>
|
||||||
|
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
|
||||||
|
<?php } else {?>
|
||||||
|
<h2 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h2>
|
||||||
|
<?php } ?>
|
||||||
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
|
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
|
||||||
</section>
|
</section>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ ul li, ol li{
|
||||||
margin-top:5px;
|
margin-top:5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#branding h1 {
|
#branding h1, #branding h2 {
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
font-family: Georgia,sans-serif;
|
font-family: Georgia,sans-serif;
|
||||||
margin:0;
|
margin:0;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,11 @@
|
||||||
<div id="header-wrapper">
|
<div id="header-wrapper">
|
||||||
<header id="header" class="responsive">
|
<header id="header" class="responsive">
|
||||||
<div id="branding">
|
<div id="branding">
|
||||||
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
|
<?php if(is_index()) {?>
|
||||||
|
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
|
||||||
|
<?php } else {?>
|
||||||
|
<h2 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h2>
|
||||||
|
<?php } ?>
|
||||||
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
|
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue