mirror of
https://github.com/danpros/htmly.git
synced 2026-04-20 20:46:26 +05:30
Add dynamic menu class
Add dynamic menu class. Toolbar should has global style, added toolbar.css.
This commit is contained in:
parent
6504517949
commit
b652407a3e
5 changed files with 47 additions and 123 deletions
|
|
@ -61,30 +61,21 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null)
|
||||||
$t = str_replace('-','',$dt);
|
$t = str_replace('-','',$dt);
|
||||||
$time = new DateTime($t);
|
$time = new DateTime($t);
|
||||||
$timestamp= $time->format("Y-m-d");
|
$timestamp= $time->format("Y-m-d");
|
||||||
|
|
||||||
// The post date
|
// The post date
|
||||||
$postdate = strtotime($timestamp);
|
$postdate = strtotime($timestamp);
|
||||||
|
|
||||||
// The post URL
|
// The post URL
|
||||||
$posturl = site_url().date('Y/m', $postdate).'/'.$post_url;
|
$posturl = site_url().date('Y/m', $postdate).'/'.$post_url;
|
||||||
|
|
||||||
if($destination == 'admin/posts') {
|
if ($destination == 'post') {
|
||||||
$redirect = site_url() . 'admin/posts';
|
|
||||||
header("Location: $redirect");
|
|
||||||
}
|
|
||||||
else if($destination == 'admin/mine') {
|
|
||||||
$redirect = site_url() . 'admin/mine';
|
|
||||||
header("Location: $redirect");
|
|
||||||
}
|
|
||||||
elseif($destination == 'admin') {
|
|
||||||
$redirect = site_url() . 'admin';
|
|
||||||
header("Location: $redirect");
|
|
||||||
}
|
|
||||||
elseif ($destination == 'post') {
|
|
||||||
header("Location: $posturl");
|
header("Location: $posturl");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$redirect = site_url();
|
$redirect = site_url() . $destination;
|
||||||
header("Location: $redirect");
|
header("Location: $redirect");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -115,15 +106,11 @@ function edit_page($title, $url, $content, $oldfile, $destination = null) {
|
||||||
|
|
||||||
$posturl = site_url() . $post_url;
|
$posturl = site_url() . $post_url;
|
||||||
|
|
||||||
if($destination == 'admin') {
|
if ($destination == 'post') {
|
||||||
$redirect = site_url() . 'admin';
|
|
||||||
header("Location: $redirect");
|
|
||||||
}
|
|
||||||
elseif ($destination == 'post') {
|
|
||||||
header("Location: $posturl");
|
header("Location: $posturl");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$redirect = site_url();
|
$redirect = site_url() . $destination;
|
||||||
header("Location: $redirect");
|
header("Location: $redirect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,7 +225,7 @@ function edit_profile($title, $content, $user) {
|
||||||
mkdir($dir, 0777, true);
|
mkdir($dir, 0777, true);
|
||||||
file_put_contents($filename, print_r($user_content, true));
|
file_put_contents($filename, print_r($user_content, true));
|
||||||
}
|
}
|
||||||
$redirect = site_url() . 'admin';
|
$redirect = site_url() . 'author/' . $user;
|
||||||
header("Location: $redirect");
|
header("Location: $redirect");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -273,6 +260,7 @@ function migrate($title, $time, $tags, $content, $url, $user, $source) {
|
||||||
mkdir($dir, 0777, true);
|
mkdir($dir, 0777, true);
|
||||||
file_put_contents($dir . $filename, print_r($post_content, true));
|
file_put_contents($dir . $filename, print_r($post_content, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
$redirect = site_url() . 'admin/mine';
|
$redirect = site_url() . 'admin/mine';
|
||||||
header("Location: $redirect");
|
header("Location: $redirect");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -925,15 +925,33 @@ function menu(){
|
||||||
function get_menu() {
|
function get_menu() {
|
||||||
|
|
||||||
$posts = get_static_pages();
|
$posts = get_static_pages();
|
||||||
|
$req = $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
if(!empty($posts)) {
|
if(!empty($posts)) {
|
||||||
|
|
||||||
krsort($posts);
|
krsort($posts);
|
||||||
|
|
||||||
echo '<ul>';
|
echo '<ul class="nav">';
|
||||||
echo '<li><a href="' . site_url() . '">' .config('breadcrumb.home'). '</a></li>';
|
if($req == site_path() . '/') {
|
||||||
|
echo '<li class="item first active"><a href="' . site_url() . '">' .config('breadcrumb.home'). '</a></li>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo '<li class="item first"><a href="' . site_url() . '">' .config('breadcrumb.home'). '</a></li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$len = count($posts);
|
||||||
|
|
||||||
foreach($posts as $index => $v){
|
foreach($posts as $index => $v){
|
||||||
|
|
||||||
|
if ($i == $len - 1) {
|
||||||
|
$class = 'item last';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$class = 'item';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
|
||||||
// Replaced string
|
// Replaced string
|
||||||
$replaced = substr($v, 0, strrpos($v, '/')) . '/';
|
$replaced = substr($v, 0, strrpos($v, '/')) . '/';
|
||||||
$base = str_replace($replaced,'',$v);
|
$base = str_replace($replaced,'',$v);
|
||||||
|
|
@ -951,7 +969,13 @@ function get_menu() {
|
||||||
else {
|
else {
|
||||||
$title = str_replace('-',' ', str_replace('.md','',$base));
|
$title = str_replace('-',' ', str_replace('.md','',$base));
|
||||||
}
|
}
|
||||||
echo '<li><a href="' . $url . '">' . ucwords($title) . '</a></li>';
|
|
||||||
|
if(strpos($req, str_replace('.md','',$base)) !== false){
|
||||||
|
echo '<li class="' . $class . ' active"><a href="' . $url . '">' . ucwords($title) . '</a></li>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo '<li class="' . $class . '"><a href="' . $url . '">' . ucwords($title) . '</a></li>';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
echo '</ul>';
|
echo '</ul>';
|
||||||
|
|
@ -1288,23 +1312,18 @@ function generate_json($posts){
|
||||||
return json_encode($posts);
|
return json_encode($posts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return toolbar
|
|
||||||
function toolbar() {
|
|
||||||
$user = $_SESSION['user'];
|
|
||||||
$role = user('role', $user);
|
|
||||||
|
|
||||||
echo <<<EOF
|
echo <<<EOF
|
||||||
<style> #outer-wrapper{ padding-top:30px;} @media all and (max-width: 550px) {#outer-wrapper{ padding-top:60px;}}</style>
|
<link href="{$base}themes/default/css/toolbar.css" rel="stylesheet" />
|
||||||
EOF;
|
EOF;
|
||||||
echo '<div id="toolbar"><ul>';
|
echo '<div id="toolbar"><ul>';
|
||||||
echo '<li><a href="'.site_url().'admin">Admin</a></li>';
|
echo '<li><a href="'.$base.'admin">Admin</a></li>';
|
||||||
if ($role === 'admin') {echo '<li><a href="'.site_url().'admin/posts">Posts</a></li>';}
|
if ($role === 'admin') {echo '<li><a href="'.$base.'admin/posts">Posts</a></li>';}
|
||||||
echo '<li><a href="'.site_url().'admin/mine">Mine</a></li>';
|
echo '<li><a href="'.$base.'admin/mine">Mine</a></li>';
|
||||||
echo '<li><a href="'.site_url().'add/post">Add post</a></li>';
|
echo '<li><a href="'.$base.'add/post">Add post</a></li>';
|
||||||
echo '<li><a href="'.site_url().'add/page">Add page</a></li>';
|
echo '<li><a href="'.$base.'add/page">Add page</a></li>';
|
||||||
echo '<li><a href="'.site_url().'edit/profile">Edit profile</a></li>';
|
echo '<li><a href="'.$base.'edit/profile">Edit profile</a></li>';
|
||||||
echo '<li><a href="'.site_url().'admin/import">Import</a></li>';
|
echo '<li><a href="'.$base.'admin/import">Import</a></li>';
|
||||||
echo '<li><a href="'.site_url().'logout">Logout</a></li>';
|
echo '<li><a href="'.$base.'logout">Logout</a></li>';
|
||||||
|
|
||||||
echo '</ul></div>';
|
echo '</ul></div>';
|
||||||
}
|
}
|
||||||
|
|
@ -126,48 +126,9 @@ h6{
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------
|
/*-------------------------
|
||||||
Toolbar
|
Tab
|
||||||
--------------------------*/
|
--------------------------*/
|
||||||
|
|
||||||
#toolbar {
|
|
||||||
background: #666666;
|
|
||||||
box-shadow: 0 5px 15px #000000;
|
|
||||||
color: #CCCCCC;
|
|
||||||
font-family: Georgia, sans-serif;
|
|
||||||
left: 0;
|
|
||||||
margin: 0 -20px;
|
|
||||||
padding: 0 25px;
|
|
||||||
position: fixed;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
z-index: 600;
|
|
||||||
border: 0 none;
|
|
||||||
font-size: 15px;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: baseline;
|
|
||||||
min-height:30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#toolbar ul {
|
|
||||||
margin:0;
|
|
||||||
padding-top:5px;
|
|
||||||
padding-bottom:5px;
|
|
||||||
padding-left:30px;
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#toolbar ul li, #toolbar ul li a {
|
|
||||||
float: left;
|
|
||||||
list-style: none outside none;
|
|
||||||
}
|
|
||||||
#toolbar a {
|
|
||||||
color: #FFFFFF;
|
|
||||||
font-size: 0.846em;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tab {
|
.tab {
|
||||||
width:100%;
|
width:100%;
|
||||||
margin: 0.5em 0 0.5em 0;
|
margin: 0.5em 0 0.5em 0;
|
||||||
|
|
@ -188,7 +149,6 @@ h6{
|
||||||
font-family: 'Open Sans',sans-serif;
|
font-family: 'Open Sans',sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------
|
/*----------------------------
|
||||||
Content & Posts
|
Content & Posts
|
||||||
-----------------------------*/
|
-----------------------------*/
|
||||||
|
|
|
||||||
|
|
@ -62,50 +62,6 @@ h6 {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------
|
|
||||||
Toolbar
|
|
||||||
--------------------------*/
|
|
||||||
|
|
||||||
#toolbar {
|
|
||||||
background: #666666;
|
|
||||||
box-shadow: 0 5px 15px #000000;
|
|
||||||
color: #CCCCCC;
|
|
||||||
font-family: Georgia, sans-serif;
|
|
||||||
left: 0;
|
|
||||||
margin: 0 -20px;
|
|
||||||
padding: 0 25px;
|
|
||||||
position: fixed;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
z-index: 600;
|
|
||||||
border: 0 none;
|
|
||||||
font-size: 15px;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: baseline;
|
|
||||||
min-height:30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#toolbar ul {
|
|
||||||
margin:0;
|
|
||||||
padding-top:5px;
|
|
||||||
padding-bottom:5px;
|
|
||||||
padding-left:30px;
|
|
||||||
float:left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#toolbar ul li, #toolbar ul li a {
|
|
||||||
float: left;
|
|
||||||
list-style: none outside none;
|
|
||||||
margin:0;
|
|
||||||
}
|
|
||||||
#toolbar a {
|
|
||||||
color: #FFFFFF;
|
|
||||||
font-size: 0.846em;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------
|
/*-------------------------
|
||||||
Layout
|
Layout
|
||||||
--------------------------*/
|
--------------------------*/
|
||||||
|
|
|
||||||
1
themes/default/css/toolbar.css
Normal file
1
themes/default/css/toolbar.css
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
body{ padding-top:30px;}#toolbar {background: #666666;box-shadow: 0 5px 15px #000000;color: #CCCCCC;font-family: Georgia, sans-serif;left: 0;margin: 0 -20px;padding: 0 25px;position: fixed;right: 0;top: 0;z-index: 600;border: 0 none;font-size: 15px;text-align: left;vertical-align: baseline;min-height:30px;}#toolbar ul {margin:0;padding-top:5px;padding-bottom:5px;padding-left:30px;float:left;}#toolbar ul li, #toolbar ul li a {float: left;list-style: none outside none;margin:0;}#toolbar a {color: #FFFFFF;font-size: 0.846em;text-decoration: none;border-radius: 10px;padding: 0 10px;} @media all and (max-width: 550px) {body{ padding-top:60px;}}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue