mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 03:26:20 +05:30
commit
82dff17469
12 changed files with 123 additions and 23 deletions
18
README.md
18
README.md
|
|
@ -55,13 +55,13 @@ Rename `config.ini.example` inside the `config` folder to `config.ini` (or you c
|
|||
|
||||
Create `YourUsername.ini` inside the `config/users` folder or simply rename the `username.ini.example` file and write down your password there:
|
||||
|
||||
````
|
||||
````cfg
|
||||
password = YourPassword
|
||||
````
|
||||
|
||||
HTMLy support admin user role either, simply add the following to your choosen user:
|
||||
|
||||
````
|
||||
````cfg
|
||||
role = admin
|
||||
````
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ You can login to admin panel at `www.example.com/login`.
|
|||
### Lighttpd
|
||||
Here a example configuration
|
||||
|
||||
````
|
||||
````php
|
||||
$HTTP["url"] =~ "^/config" {
|
||||
url.access-deny = ( "" )
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ url.rewrite-once = (
|
|||
### Nginx
|
||||
Here a basic configuration for nginx.
|
||||
|
||||
````
|
||||
````nginx
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
|
|
@ -165,13 +165,13 @@ That means the URL is `about/me`.
|
|||
Content Title
|
||||
-------------
|
||||
If you write it offline, for the title of the post you need to add a title in the following format:
|
||||
```html
|
||||
<!--t Here is the post title t-->
|
||||
|
||||
<!--t Here is the post title t-->
|
||||
|
||||
Paragraph 1
|
||||
|
||||
Paragraph 2 etc.
|
||||
Paragraph 1
|
||||
|
||||
Paragraph 2 etc.
|
||||
```
|
||||
So wrap the title with HTML comment with `t` for both side.
|
||||
|
||||
Demo
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@
|
|||
<div class="main">
|
||||
<h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2>
|
||||
<div class="date">
|
||||
<?php if (!empty($p->feature)){?>
|
||||
<div class="featured-image">
|
||||
<a href="<?php echo $p->url?>"><img src="<?php echo $p->feature; ?>" alt="<?php echo $p->title ?>"/></a>
|
||||
</div>
|
||||
<?php }?>
|
||||
<?php if (!empty($p->video)){?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php }?>
|
||||
<span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in
|
||||
<span itemprop="articleSection"><?php echo $p->tag ?></span> by
|
||||
<span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span>
|
||||
|
|
@ -45,4 +55,4 @@
|
|||
<?php endif;?>
|
||||
<?php if (disqus_count()):?>
|
||||
<?php echo disqus_count() ?>
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@
|
|||
<a name="more"></a>
|
||||
<h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1>
|
||||
<div class="date">
|
||||
<?php if (!empty($p->feature)){?>
|
||||
<div class="featured-image">
|
||||
<a href="<?php echo $p->url?>"><img src="<?php echo $p->feature; ?>" alt="<?php echo $p->title ?>"/></a>
|
||||
</div>
|
||||
<?php }?>
|
||||
<?php if (!empty($p->video)){?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php }?>
|
||||
<span itemprop="datePublished"><a href="<?php echo $p->archive ?>" title="Show all posts made on this day"><?php echo date('d F Y', $p->date)?></a></span> - Posted in
|
||||
<span itemprop="articleSection"><?php echo $p->tag ?></span> by
|
||||
<span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span> -
|
||||
|
|
@ -45,4 +55,4 @@
|
|||
<?php if (disqus()):?>
|
||||
<?php echo disqus($p->title, $p->url) ?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@
|
|||
<div class="main">
|
||||
<h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2>
|
||||
<div class="date">
|
||||
<?php if (!empty($p->feature)){?>
|
||||
<div class="featured-image">
|
||||
<a href="<?php echo $p->url?>"><img src="<?php echo $p->feature; ?>" alt="<?php echo $p->title ?>"/></a>
|
||||
</div>
|
||||
<?php }?>
|
||||
<?php if (!empty($p->video)){?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php }?>
|
||||
<span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in
|
||||
<span itemprop="articleSection"><?php echo $p->tag ?></span> by
|
||||
<span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span>
|
||||
|
|
@ -45,4 +55,4 @@
|
|||
<?php endif;?>
|
||||
<?php if (disqus_count()):?>
|
||||
<?php echo disqus_count() ?>
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@
|
|||
<a name="more"></a>
|
||||
<h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1>
|
||||
<div class="date">
|
||||
<?php if (!empty($p->feature)){?>
|
||||
<div class="featured-image">
|
||||
<a href="<?php echo $p->url?>"><img src="<?php echo $p->feature; ?>" alt="<?php echo $p->title ?>"/></a>
|
||||
</div>
|
||||
<?php }?>
|
||||
<?php if (!empty($p->video)){?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php }?>
|
||||
<span itemprop="datePublished"><a href="<?php echo $p->archive ?>" title="Show all posts made on this day"><?php echo date('d F Y', $p->date)?></a></span> - Posted in
|
||||
<span itemprop="articleSection"><?php echo $p->tag ?></span> by
|
||||
<span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span> -
|
||||
|
|
@ -45,4 +55,4 @@
|
|||
<?php if (disqus()):?>
|
||||
<?php echo disqus($p->title, $p->url) ?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,16 @@
|
|||
<div class="main">
|
||||
<h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2>
|
||||
<div class="date">
|
||||
<?php if (!empty($p->feature)){?>
|
||||
<div class="featured-image">
|
||||
<a href="<?php echo $p->url?>"><img src="<?php echo $p->feature; ?>" alt="<?php echo $p->title ?>"/></a>
|
||||
</div>
|
||||
<?php }?>
|
||||
<?php if (!empty($p->video)){?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php }?>
|
||||
<span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in
|
||||
<span itemprop="articleSection"><?php echo $p->tag ?></span> by
|
||||
<span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span>
|
||||
|
|
@ -45,4 +55,4 @@
|
|||
<?php endif;?>
|
||||
<?php if (disqus_count()):?>
|
||||
<?php echo disqus_count() ?>
|
||||
<?php endif;?>
|
||||
<?php endif;?>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,16 @@
|
|||
<a name="more"></a>
|
||||
<h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1>
|
||||
<div class="date">
|
||||
<?php if (!empty($p->feature)){?>
|
||||
<div class="featured-image">
|
||||
<a href="<?php echo $p->url?>"><img src="<?php echo $p->feature; ?>" alt="<?php echo $p->title ?>"/></a>
|
||||
</div>
|
||||
<?php }?>
|
||||
<?php if (!empty($p->video)){?>
|
||||
<div class="featured-video">
|
||||
<iframe src="https://www.youtube.com/embed/<?php echo $p->video; ?>" width="560" height="315" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
<?php }?>
|
||||
<span itemprop="datePublished"><a href="<?php echo $p->archive ?>" title="Show all posts made on this day"><?php echo date('d F Y', $p->date)?></a></span> - Posted in
|
||||
<span itemprop="articleSection"><?php echo $p->tag ?></span> by
|
||||
<span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span> -
|
||||
|
|
@ -45,4 +55,4 @@
|
|||
<?php if (disqus()):?>
|
||||
<?php echo disqus($p->title, $p->url) ?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue