mirror of
https://github.com/danpros/htmly.git
synced 2026-04-23 05:56:22 +05:30
commit
82dff17469
12 changed files with 123 additions and 23 deletions
|
|
@ -59,7 +59,7 @@ function remove_accent($str)
|
|||
}
|
||||
|
||||
// Edit blog posts
|
||||
function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null)
|
||||
function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $fi, $vid)
|
||||
{
|
||||
$oldurl = explode('_', $oldfile);
|
||||
if ($date !== null) {
|
||||
|
|
@ -67,6 +67,8 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null,
|
|||
}
|
||||
|
||||
$post_title = $title;
|
||||
$post_fi = $fi;
|
||||
$post_vid = $vid;
|
||||
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
if ($description !== null) {
|
||||
|
|
@ -75,6 +77,7 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null,
|
|||
$post_description = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
||||
$post_content = '<!--fi ' . $post_fi . ' fi-->' . "\n\n" . '<!--vid ' . $post_vid . ' vid-->' . "\n\n" . $post_content;
|
||||
|
||||
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
||||
if (get_magic_quotes_gpc()) {
|
||||
|
|
@ -152,11 +155,13 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr
|
|||
}
|
||||
|
||||
// Add blog post
|
||||
function add_post($title, $tag, $url, $content, $user, $description = null)
|
||||
function add_post($title, $tag, $url, $content, $user, $description = null, $fi, $vid)
|
||||
{
|
||||
|
||||
|
||||
$post_date = date('Y-m-d-H-i-s');
|
||||
$post_title = $title;
|
||||
$post_fi = $fi;
|
||||
$post_vid = $vid;
|
||||
$post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag));
|
||||
$post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url)));
|
||||
if ($description !== null) {
|
||||
|
|
@ -165,6 +170,7 @@ function add_post($title, $tag, $url, $content, $user, $description = null)
|
|||
$post_description = "";
|
||||
}
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
||||
$post_content = '<!--fi ' . $post_fi . ' fi-->' . "\n\n" . '<!--vid ' . $post_vid . ' vid-->' . "\n\n" . $post_content;
|
||||
|
||||
if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
||||
if (get_magic_quotes_gpc()) {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
<span class="help">If the url leave empty we will use the post title.</span><br><br>
|
||||
Meta Description (optional)<br><textarea name="description" maxlength="200"><?php if (isset($p->description)) { echo $p->description;} ?></textarea>
|
||||
<br><br>
|
||||
Featured Image (optional)<br><input type="text" class="text" name="fi" value="<?php if (isset($postFi)) { echo $postFi;} ?>"/><br><br>
|
||||
Embed Youtube Video (optional)<br><input type="text" class="text" name="vid" value="<?php if (isset($postVid)) { echo $postVid;} ?>"/><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 if (isset($postContent)) { echo $postContent;} ?></textarea><br/>
|
||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf()?>">
|
||||
|
|
@ -28,4 +30,4 @@
|
|||
|
||||
editor.run();
|
||||
})();
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
$content = file_get_contents($url);
|
||||
$oldtitle = get_content_tag('t',$content,'Untitled');
|
||||
$oldfi = get_content_tag('fi',$content);
|
||||
$oldvid = get_content_tag('vid',$content);
|
||||
$oldcontent = remove_html_comments($content);
|
||||
|
||||
$dir = substr($url, 0, strrpos($url, '/'));
|
||||
|
|
@ -52,6 +54,8 @@
|
|||
Date Time<br><input type="date" name="date" class="text" value="<?php echo $timestamp; ?>"><br><input type="time" name="time" class="text" value="<?php echo $time->format('H:i'); ?>"><br><br>
|
||||
Meta Description (optional)<br><textarea name="description" maxlength="200"><?php if (isset($p->description)) { echo $p->description;} ?></textarea>
|
||||
<br><br>
|
||||
Featured Image (optional)<br><input type="text" class="text" name="fi" value="<?php echo $oldfi?>"/><br><br>
|
||||
Embed Youtube Video (optional)<br><input type="text" class="text" name="vid" value="<?php echo $oldvid?>"/><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="oldfile" class="text" value="<?php echo $url ?>"/>
|
||||
|
|
@ -68,4 +72,4 @@
|
|||
|
||||
editor.run();
|
||||
})();
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -333,6 +333,8 @@ post('/:year/:month/:name/edit', function () {
|
|||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||
|
||||
$title = from($_REQUEST, 'title');
|
||||
$fi = from($_REQUEST, 'fi');
|
||||
$vid = from($_REQUEST, 'vid');
|
||||
$tag = from($_REQUEST, 'tag');
|
||||
$url = from($_REQUEST, 'url');
|
||||
$content = from($_REQUEST, 'content');
|
||||
|
|
@ -350,7 +352,7 @@ post('/:year/:month/:name/edit', function () {
|
|||
if(empty($url)) {
|
||||
$url = $title;
|
||||
}
|
||||
edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime);
|
||||
edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $fi, $vid);
|
||||
} else {
|
||||
$message['error'] = '';
|
||||
if (empty($title)) {
|
||||
|
|
@ -372,6 +374,8 @@ post('/:year/:month/:name/edit', function () {
|
|||
'error' => '<ul>' . $message['error'] . '</ul>',
|
||||
'oldfile' => $oldfile,
|
||||
'postTitle' => $title,
|
||||
'postFi' => $fi,
|
||||
'postVid' => $vid,
|
||||
'postTag' => $tag,
|
||||
'postUrl' => $url,
|
||||
'postContent' => $content,
|
||||
|
|
@ -874,6 +878,8 @@ post('/add/post', function () {
|
|||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||
|
||||
$title = from($_REQUEST, 'title');
|
||||
$fi = from($_REQUEST, 'fi');
|
||||
$vid = from($_REQUEST, 'vid');
|
||||
$tag = from($_REQUEST, 'tag');
|
||||
$url = from($_REQUEST, 'url');
|
||||
$content = from($_REQUEST, 'content');
|
||||
|
|
@ -881,10 +887,10 @@ post('/add/post', function () {
|
|||
$user = $_SESSION[config("site.url")]['user'];
|
||||
if ($proper && !empty($title) && !empty($tag) && !empty($content)) {
|
||||
if (!empty($url)) {
|
||||
add_post($title, $tag, $url, $content, $user, $description);
|
||||
add_post($title, $tag, $url, $content, $user, $description, $fi, $vid);
|
||||
} else {
|
||||
$url = $title;
|
||||
add_post($title, $tag, $url, $content, $user, $description);
|
||||
add_post($title, $tag, $url, $content, $user, $description, $fi, $vid);
|
||||
}
|
||||
} else {
|
||||
$message['error'] = '';
|
||||
|
|
@ -905,6 +911,8 @@ post('/add/post', function () {
|
|||
'head_contents' => head_contents('Add post - ' . blog_title(), blog_description(), site_url()),
|
||||
'error' => '<ul>' . $message['error'] . '</ul>',
|
||||
'postTitle' => $title,
|
||||
'postFi' => $fi,
|
||||
'postVid' => $vid,
|
||||
'postTag' => $tag,
|
||||
'postUrl' => $url,
|
||||
'postContent' => $content,
|
||||
|
|
@ -932,6 +940,24 @@ get('/add/page', function () {
|
|||
}
|
||||
});
|
||||
|
||||
// Add the static page
|
||||
get('/add/page', function () {
|
||||
|
||||
if (login()) {
|
||||
|
||||
config('views.root', 'system/admin/views');
|
||||
|
||||
render('add-page', array(
|
||||
'head_contents' => head_contents('Add page - ' . blog_title(), blog_description(), site_url()),
|
||||
'bodyclass' => 'addpage',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » Add page'
|
||||
));
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
// Get submitted static page data
|
||||
post('/add/page', function () {
|
||||
|
||||
|
|
|
|||
|
|
@ -243,6 +243,8 @@ function get_posts($posts, $page = 1, $perpage = 0)
|
|||
|
||||
// Extract the title and body
|
||||
$post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date));
|
||||
$post->feature = get_content_tag('fi', $content);
|
||||
$post->video = get_content_tag('vid', $content);
|
||||
|
||||
// Get the contents and convert it to HTML
|
||||
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue