Skip to content

Commit

Permalink
Merge pull request #10 from danpros/master
Browse files Browse the repository at this point in the history
update to master
  • Loading branch information
Kanti committed Feb 10, 2015
2 parents 5e5a8dc + ba11afb commit 82dff17
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 23 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
````

Expand All @@ -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 = ( "" )
}
Expand All @@ -95,7 +95,7 @@ url.rewrite-once = (
### Nginx
Here a basic configuration for nginx.

````
````nginx
server {
listen 80;
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions system/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ 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) {
$oldurl[0] = substr($oldurl[0], 0, strrpos($oldurl[0], '/')) . '/' . date('Y-m-d-h-i-s', strtotime($date));
}

$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) {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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()) {
Expand Down
4 changes: 3 additions & 1 deletion system/admin/views/add-post.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()?>">
Expand All @@ -28,4 +30,4 @@

editor.run();
})();
</script>
</script>
6 changes: 5 additions & 1 deletion system/admin/views/edit-post.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/'));
Expand Down Expand Up @@ -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 ?>"/>
Expand All @@ -68,4 +72,4 @@

editor.run();
})();
</script>
</script>
32 changes: 29 additions & 3 deletions system/htmly.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@
$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');
Expand All @@ -350,7 +352,7 @@
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)) {
Expand All @@ -372,6 +374,8 @@
'error' => '<ul>' . $message['error'] . '</ul>',
'oldfile' => $oldfile,
'postTitle' => $title,
'postFi' => $fi,
'postVid' => $vid,
'postTag' => $tag,
'postUrl' => $url,
'postContent' => $content,
Expand Down Expand Up @@ -874,17 +878,19 @@
$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');
$description = from($_REQUEST, 'description');
$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'] = '';
Expand All @@ -905,6 +911,8 @@
'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,
Expand Down Expand Up @@ -932,6 +940,24 @@
}
});

// 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> &#187; Add page'
));
} else {
$login = site_url() . 'login';
header("location: $login");
}
});

// Get submitted static page data
post('/add/page', function () {

Expand Down
2 changes: 2 additions & 0 deletions system/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
12 changes: 11 additions & 1 deletion themes/clean/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -45,4 +55,4 @@
<?php endif;?>
<?php if (disqus_count()):?>
<?php echo disqus_count() ?>
<?php endif;?>
<?php endif;?>
12 changes: 11 additions & 1 deletion themes/clean/post.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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> -
Expand Down Expand Up @@ -45,4 +55,4 @@
<?php if (disqus()):?>
<?php echo disqus($p->title, $p->url) ?>
<?php endif;?>
</div>
</div>
12 changes: 11 additions & 1 deletion themes/default/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -45,4 +55,4 @@
<?php endif;?>
<?php if (disqus_count()):?>
<?php echo disqus_count() ?>
<?php endif;?>
<?php endif;?>
12 changes: 11 additions & 1 deletion themes/default/post.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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> -
Expand Down Expand Up @@ -45,4 +55,4 @@
<?php if (disqus()):?>
<?php echo disqus($p->title, $p->url) ?>
<?php endif;?>
</div>
</div>
12 changes: 11 additions & 1 deletion themes/logs/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -45,4 +55,4 @@
<?php endif;?>
<?php if (disqus_count()):?>
<?php echo disqus_count() ?>
<?php endif;?>
<?php endif;?>
12 changes: 11 additions & 1 deletion themes/logs/post.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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> -
Expand Down Expand Up @@ -45,4 +55,4 @@
<?php if (disqus()):?>
<?php echo disqus($p->title, $p->url) ?>
<?php endif;?>
</div>
</div>

0 comments on commit 82dff17

Please sign in to comment.