Skip to content

Commit

Permalink
Merge pull request #4 from dignajar/master
Browse files Browse the repository at this point in the history
New pull request
  • Loading branch information
clickwork-git committed Nov 17, 2015
2 parents 47a27d7 + 8bceddd commit 1a3e00a
Show file tree
Hide file tree
Showing 84 changed files with 1,283 additions and 89 deletions.
7 changes: 0 additions & 7 deletions admin/README.md

This file was deleted.

80 changes: 66 additions & 14 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,28 @@
define('PATH_CONTENT', PATH_ROOT.'content'.DS);
define('PATH_POSTS', PATH_CONTENT.'posts'.DS);
define('PATH_UPLOADS', PATH_CONTENT.'uploads'.DS);
define('PATH_UPLOADS_PROFILES', PATH_UPLOADS.'profiles'.DS);
define('PATH_PAGES', PATH_CONTENT.'pages'.DS);
define('PATH_DATABASES', PATH_CONTENT.'databases'.DS);
define('PATH_PLUGINS_DATABASES',PATH_CONTENT.'databases'.DS.'plugins'.DS);
define('PATH_KERNEL', PATH_ROOT.'kernel'.DS);
define('PATH_HELPERS', PATH_KERNEL.'helpers'.DS);
define('PATH_LANGUAGES', PATH_ROOT.'languages'.DS);
define('PATH_ABSTRACT', PATH_KERNEL.'abstract'.DS);
define('DOMAIN', getenv('HTTP_HOST'));
define('DOMAIN', $_SERVER['HTTP_HOST']);

// HTML PATHs
$base = (dirname(getenv('SCRIPT_NAME'))==DS)?'/':dirname(getenv('SCRIPT_NAME')).'/';
$base = empty( $_SERVER['SCRIPT_NAME'] ) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$base = dirname($base);

if($base!=DS) {
$base = $base.'/';
}
else {
// Workaround for Windows Web Servers
$base = '/';
}

define('HTML_PATH_ROOT', $base);

// Log separator
Expand Down Expand Up @@ -220,6 +231,12 @@ function install($adminPassword, $email, $timezoneOffset)
error_log($errorText, 0);
}

if(!mkdir(PATH_PAGES.'about', $dirpermissions, true))
{
$errorText = 'Error when trying to created the directory=>'.PATH_PAGES.'about';
error_log($errorText, 0);
}

if(!mkdir(PATH_PLUGINS_DATABASES.'pages', $dirpermissions, true))
{
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'pages';
Expand All @@ -238,9 +255,15 @@ function install($adminPassword, $email, $timezoneOffset)
error_log($errorText, 0);
}

if(!mkdir(PATH_UPLOADS, $dirpermissions, true))
if(!mkdir(PATH_PLUGINS_DATABASES.'about', $dirpermissions, true))
{
$errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS;
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES.'about';
error_log($errorText, 0);
}

if(!mkdir(PATH_UPLOADS_PROFILES, $dirpermissions, true))
{
$errorText = 'Error when trying to created the directory=>'.PATH_UPLOADS_PROFILES;
error_log($errorText, 0);
}

Expand All @@ -259,6 +282,14 @@ function install($adminPassword, $email, $timezoneOffset)
'status'=>'published',
'date'=>$currentDate,
'position'=>0
),
'about'=>array(
'description'=>$Language->get('About your site or yourself'),
'username'=>'admin',
'tags'=>array(),
'status'=>'published',
'date'=>$currentDate,
'position'=>1
)
);

Expand All @@ -267,7 +298,7 @@ function install($adminPassword, $email, $timezoneOffset)
// File posts.php
$data = array(
$firstPostSlug=>array(
'description'=>'Welcome to Bludit',
'description'=>$Language->get('Welcome to Bludit'),
'username'=>'admin',
'status'=>'published',
'tags'=>array('bludit'=>'Bludit','cms'=>'CMS','flat-files'=>'Flat files'),
Expand All @@ -279,10 +310,10 @@ function install($adminPassword, $email, $timezoneOffset)

// File site.php
$data = array(
'title'=>'Bludit',
'slogan'=>'cms',
'title'=>'BLUDIT',
'slogan'=>'CMS',
'description'=>'',
'footer'=>Date::current('Y'),
'footer'=>'Copyright © '.Date::current('Y'),
'language'=>$Language->getCurrentLocale(),
'locale'=>$Language->getCurrentLocale(),
'timezone'=>$timezone,
Expand All @@ -306,7 +337,7 @@ function install($adminPassword, $email, $timezoneOffset)

$data = array(
'admin'=>array(
'firstName'=>'',
'firstName'=>$Language->get('Administrator'),
'lastName'=>'',
'twitter'=>'',
'role'=>'admin',
Expand Down Expand Up @@ -364,6 +395,19 @@ function install($adminPassword, $email, $timezoneOffset)
LOCK_EX
);

// File plugins/about/db.php
file_put_contents(
PATH_PLUGINS_DATABASES.'about'.DS.'db.php',
$dataHead.json_encode(
array(
'position'=>0,
'label'=>$Language->get('About'),
'text'=>$Language->get('this-is-a-brief-description-of-yourself-our-your-site')
),
JSON_PRETTY_PRINT),
LOCK_EX
);

// File plugins/simplemde/db.php
file_put_contents(
PATH_PLUGINS_DATABASES.'simplemde'.DS.'db.php',
Expand Down Expand Up @@ -391,19 +435,27 @@ function install($adminPassword, $email, $timezoneOffset)

// File index.txt for error page
$data = 'Title: '.$Language->get('Error').'
Content: '.$Language->get('The page has not been found');
Content: '.$Language->get('The page has not been found');

file_put_contents(PATH_PAGES.'error'.DS.'index.txt', $data, LOCK_EX);

// File index.txt for about page
$data = 'Title: '.$Language->get('About').'
Content:
'.$Language->get('the-about-page-is-very-important').'
'.$Language->get('change-this-pages-content-on-the-admin-panel');

file_put_contents(PATH_PAGES.'about'.DS.'index.txt', $data, LOCK_EX);

// File index.txt for welcome post
$data = 'Title: '.$Language->get('First post').'
Content:
## '.$Language->get('Congratulations you have successfully installed your Bludit').'
### '.$Language->get('Whats next').'
## '.$Language->get('Whats next').'
- '.$Language->get('Manage your Bludit from the admin panel').'
- '.$Language->get('Follow Bludit on').' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/bluditcms) / [Google+](https://plus.google.com/+Bluditcms)
- '.$Language->get('Chat with developers and users on Gitter').'
- '.$Language->get('Visit the support forum').'
- '.$Language->get('Read the documentation for more information').'
- '.$Language->get('Share with your friends and enjoy');
Expand Down Expand Up @@ -469,7 +521,7 @@ function checkPOST($args)
<!DOCTYPE HTML>
<html class="uk-height-1-1 uk-notouch">
<head>
<base href="admin/themes/default/">
<base href="kernel/admin/themes/default/">
<meta charset="<?php echo CHARSET ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

Expand Down
9 changes: 9 additions & 0 deletions kernel/abstract/dbjson.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ public function count()
return count($this->db);
}

public function getField($field)
{
if(isset($this->db[$field])) {
return $this->db[$field];
}

return $this->dbFields[$field]['value'];
}

// Save the JSON file.
public function save()
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
background: #1F5FC4;
}

.uk-form legend {
width: 70% !important;
}

.uk-navbar-nav > li > a {
border: none;
height: 70px;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added kernel/admin/themes/default/img/default.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@
<div class="uk-navbar-flip uk-hidden-small">
<ul class="uk-navbar-nav">
<li class="uk-parent" data-uk-dropdown>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><i class="uk-icon-user"></i> <?php echo $Login->username() ?></a>
<?php
$profilePictureSrc = HTML_PATH_UPLOADS_PROFILES.$Login->username().'.jpg';
if(!file_exists($profilePictureSrc)) {
$profilePictureSrc = HTML_PATH_ADMIN_THEME_IMG.'default.jpg';
}
?>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>">
<img class="uk-border-circle" width="28px" src="<?php echo $profilePictureSrc ?>" alt=""> <?php echo $Login->username() ?>
</a>
<div class="uk-dropdown uk-dropdown-navbar">
<ul class="uk-nav uk-nav-navbar">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><?php $L->p('Profile') ?></a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,64 @@ public static function uploader()
echo $html;
}

public static function profileUploader($username)
{
global $L;

$html = '
<div id="jsprogressBar" class="uk-progress uk-hidden">
<div class="uk-progress-bar" style="width: 0%;">0%</div>
</div>
<div id="upload-drop" class="uk-placeholder uk-text-center">
<i class="uk-icon-cloud-upload uk-margin-small-right"></i>'.$L->g('Upload Image').'<br><a class="uk-form-file">'.$L->g('Drag and drop or click here').'<input id="upload-select" type="file"></a>
</div>
';

$html .= '
<script>
$(document).ready(function() {
$(function()
{
var progressbar = $("#jsprogressBar");
var bar = progressbar.find(".uk-progress-bar");
var settings =
{
type: "json",
action: "'.HTML_PATH_ADMIN_ROOT.'ajax/uploader",
allow : "*.(jpg|jpeg|gif|png)",
params: {"type":"profilePicture", "username":"'.$username.'"},
loadstart: function() {
bar.css("width", "0%").text("0%");
progressbar.removeClass("uk-hidden");
},
progress: function(percent) {
percent = Math.ceil(percent);
bar.css("width", percent+"%").text(percent+"%");
},
allcomplete: function(response) {
bar.css("width", "100%").text("100%");
progressbar.addClass("uk-hidden");
$("#jsprofilePicture").attr("src", "'.HTML_PATH_UPLOADS_PROFILES.$username.'.jpg?"+new Date().getTime());
},
notallowed: function(file, settings) {
alert("'.$L->g('Supported image file types').' "+settings.allow);
}
};
var select = UIkit.uploadSelect($("#upload-select"), settings);
var drop = UIkit.uploadDrop($("#upload-drop"), settings);
});
});
</script>';

echo $html;
}

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions admin/views/edit-user.php → kernel/admin/views/edit-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

HTML::title(array('title'=>$L->g('Edit user'), 'icon'=>'user'));

echo '<div class="uk-grid">';
echo '<div class="uk-width-7-10">';

HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal'));

// Security token
Expand Down Expand Up @@ -92,6 +95,13 @@

HTML::formClose();

echo '</div>';
echo '<div class="uk-width-3-10" style="margin-top: 50px; text-align: center;">';
echo '<img id="jsprofilePicture" class="uk-border-rounded" src="'.HTML_PATH_UPLOADS_PROFILES.$_user['username'].'.jpg" alt="'.$L->g('Profile picture').'">';
HTML::profileUploader($_user['username']);
echo '</div>';
echo '</div>';

?>

<script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="login-form">

<form method="post" action="<?php echo HTML_PATH_ADMIN_ROOT.'login-email' ?>" class="uk-form" autocomplete="off">
<form method="post" action="" class="uk-form" autocomplete="off">

<input type="hidden" id="jstoken" name="tokenCSRF" value="<?php $Security->printToken() ?>">

Expand Down
2 changes: 1 addition & 1 deletion admin/views/login.php → kernel/admin/views/login.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="login-form">

<form method="post" action="<?php echo HTML_PATH_ADMIN_ROOT.'login' ?>" class="uk-form" autocomplete="off">
<form method="post" action="" class="uk-form" autocomplete="off">

<input type="hidden" id="jstoken" name="tokenCSRF" value="<?php $Security->printToken() ?>">

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($status?'<span class="label-draft">'.$status.'</span>':'').($Post->title()?$Post->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
echo '<td class="uk-text-center">'.$Post->date().'</td>';
echo '<td class="uk-text-center">'.$Post->dateRaw().'</td>';
echo '<td><a target="_blank" href="'.$Post->permalink().'">'.$Url->filters('post').'/'.$Post->key().'</a></td>';
echo '</tr>';
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
'tip'=>$L->g('you-can-use-this-field-to-define-a-set-off')
));

HTML::formInputText(array(
'name'=>'dateFormat',
'label'=>$L->g('Date format'),
'value'=>$Site->dateFormat(),
'class'=>'uk-width-1-2 uk-form-medium'
));

echo '<div class="uk-form-row">
<div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 26 additions & 4 deletions kernel/ajax/uploader.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php header('Content-Type: application/json');
<?php defined('BLUDIT') or die('Bludit CMS.');

header('Content-Type: application/json');

// Type
$type = 'other';
if(!empty($_POST['type'])) {
$type = Sanitize::html($_POST['type']);
}

// Source
$source = $_FILES['files']['tmp_name'][0];
Expand All @@ -24,12 +32,26 @@
$tmpName = $filename.'.'.$fileExtension;
}

move_uploaded_file($source, PATH_UPLOADS.$tmpName);
// --- PROFILE PICTURE ---
if($type=='profilePicture') {
$username = Sanitize::html($_POST['username']);
$tmpName = $username.'.jpg';

move_uploaded_file($source, PATH_UPLOADS_PROFILES.$tmpName);

// Resize and crop profile image.
$Image = new Image();
$Image->setImage(PATH_UPLOADS_PROFILES.$tmpName, '200', '200', 'crop');
$Image->saveImage(PATH_UPLOADS_PROFILES.$tmpName, 100, true);
}
// --- OTHERS ---
else {
move_uploaded_file($source, PATH_UPLOADS.$tmpName);
}

exit(json_encode(array(
'status'=>0,
'filename'=>$tmpName,
'date'=>date("F d Y H:i:s.", filemtime(PATH_UPLOADS.$tmpName))
'filename'=>$tmpName
)));

?>

0 comments on commit 1a3e00a

Please sign in to comment.