Static frontpage and improvements

Add new config: static.frontpage = "true" to enable the static
frontpage.
This commit is contained in:
Danang Probo Sayekti 2015-11-14 10:10:34 +07:00
commit eb8e0ac503
7 changed files with 281 additions and 40 deletions

View file

@ -1069,7 +1069,7 @@ function edit_category($title, $url, $content, $oldfile, $destination = null, $d
}
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
if (get_magic_quotes_gpc()) {
$post_content = stripslashes($post_content);
}
@ -1080,8 +1080,8 @@ function edit_category($title, $url, $content, $oldfile, $destination = null, $d
rename($oldfile, $newfile);
file_put_contents($newfile, print_r($post_content, true));
}
rename_category_folder($post_url, $oldfile);
rename_category_folder($post_url, $oldfile);
rebuilt_cache('all');
if ($destination == 'post') {
@ -1671,6 +1671,30 @@ function edit_profile($title, $content, $user)
}
}
// Edit homepage
function edit_frontpage($title, $content)
{
$front_title = safe_html($title);
$front_content = '<!--t ' . $front_title . ' t-->' . "\n\n" . $content;
if (!empty($front_title) && !empty($front_content)) {
if (get_magic_quotes_gpc()) {
$front_content = stripslashes($front_content);
}
$dir = 'content/data/frontpage';
$filename = 'content/data/frontpage/frontpage.md';
if (is_dir($dir)) {
file_put_contents($filename, print_r($front_content, true));
} else {
mkdir($dir, 0775, true);
file_put_contents($filename, print_r($front_content, true));
}
rebuilt_cache('all');
$redirect = site_url();
header("Location: $redirect");
}
}
// Import RSS feed
function migrate($title, $time, $tags, $content, $url, $user, $source)
{

View file

@ -0,0 +1,62 @@
<?php
$filename = 'content/data/frontpage/frontpage.md';
if (file_exists($filename)) {
$content = file_get_contents($filename);
$oldtitle = get_content_tag('t', $content, 'Welcome');
$oldcontent = remove_html_comments($content);
} else {
$oldtitle = 'Welcome';
$oldcontent = 'Welcome to our website.';
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css"/>
<script src="<?php echo site_url() ?>system/resources/js/jquery.min.js"></script>
<script src="<?php echo site_url() ?>system/resources/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Extra.js"></script>
<link rel="stylesheet" href="<?php echo site_url() ?>system/resources/css/jquery-ui.css">
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/jquery.ajaxfileupload.js"></script>
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error ?></div>
<?php } ?>
<div class="wmd-panel">
<form method="POST">
Title <span class="required">*</span> <br><input type="text" name="title"
class="text <?php if (isset($postTitle)) {
if (empty($postTitle)) {
echo 'error';
}
} ?>" value="<?php echo $oldtitle ?>"/><br><br>
<br>
<div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input <?php if (isset($postContent)) {
if (empty($postContent)) {
echo 'error';
}
} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="hidden" name="csrf_token" value="<?php echo get_csrf() ?>">
<input type="submit" name="submit" class="submit" value="Save"/>
</form>
</div>
<div id="insertImageDialog" title="Insert Image">
<h4>URL</h4>
<input type="text" placeholder="Enter image URL" />
<h4>Upload</h4>
<form method="post" action="" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
</form>
<style>
#insertImageDialog { display:none; padding: 10px; font-size:12px;}
.wmd-prompt-background {z-index:10!important;}
</style>
</div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<!-- Declare the base path. Important -->
<script type="text/javascript">var base_path = '<?php echo site_url() ?>';</script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>

View file

@ -37,7 +37,6 @@
<header id="header">
<section id="branding">
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo blog_title() ?></a></h1>
<div class="blog-tagline"><p><?php echo blog_tagline() ?></p></div>
</section>
</header>