Pos Terbaru Kreatifa Media

Simple overlay instructions for your apps with chardin.js

Sunday, April 14, 2013

Check out a demo    -     README.md
Simple overlay instructions for your apps with chardin.js

Chardin.js is a jQuery plugin that creates a simple overlay to display instructions on existent elements. It is inspired by the recent Gmail new composer tour which I loved.

Fat Expanded Style Sheets with FESS

Tuesday, April 9, 2013


This is what we were all waiting for! Finally a CSS converter that will expand your CSS to the maximum! Watch your line numbers and properties grow as you fess up your stylesheet ;) A fun project by Dew.

Is the CSS syntax way too simple for you ? Do you think preprocessors are for losers ? Are you paid per line of code ? Do you need big stylesheets ? FESS your CSS and get more code from your source !

FESS uses an exclusive secret algorithm for a styled experience

  • Expand margin shorthand properties
  • Expand padding shorthand properties
  • Expand background shorthand
  • Expand border shorthand
  • Expand font shorthand
  • Expand border-radius
  • Expand color #hex codes
  • Expand color with HTML names

Portraits: Inspirational Website

Sunday, April 7, 2013

VIEW GALLERY        -        GET INSPIRED


Portraits has a beautiful, clean and flat design brought to the next level. Subtle effects and a great color scheme make it our pick this week.

1. choose your best photo to use as the base for your works of art!
2. Give your piece of work a little personality with color, texture and a caption.
3. Share your unique portrait with friends and family online, or get a high-quality print made!

VIEW GALLERY        -        GET INSPIRED

Tutorial: 3D-ifying Documents Using CSS Transforms


Cameron Lakenen from Crocodoc explains how they use SVG to do some fancy 3D effects when converting documents.

Note: the demos in this blog post require IE 9+ (preferably 10), Firefox, or any WebKit browser. If you’re on a mobile device, you might need to click the open in new page button to view the demos properly.


Download: Grunge Stamp Borders Multi-Pack

 
Format: AI, EPS, ABR, PSD, JPG   |  56 MB  |  20 items  | Free Licence


This resource features 12 grunge stamped style vector borders. The download includes AI and EPS vector files, as well as, PS brushes and vector shapes. A bonus 8 worn paper textures are included for use with the stamp shapes.

Tutorial Let’s Build a Lightweight Blog System Part 2

Saturday, April 6, 2013

DEMO     -     DOWNLOAD

As you remember from part 1, in this tutorial we are creating a lightweight blog system that stores posts as markdown files. It uses a number of libraries: for parsing markdown, for creating the RSS feed, and most importantly the Dispatch micro framework for giving the application structure.
In this part, we will create the views and the CSS that will make the site responsive on mobile devices.

The Views

As you remember from the first part, we used a configuration file – config.ini – to write down the configuration settings of the blog. The last two lines of the file hold the name of the file that holds the layout, and the path to the views:

app/config.ini (lines 12-14)

1views.root = app/views
2views.layout = layout
These settings are used internally by the Dispatch framework. The first line tells it where to find the views for the site (so that you only need to specify a name when rendering them) and the second is the layout. This is an HTML template that is included with every view that you render. This is a standard HTML5 document with a few additional meta tags to make it mobile-friendly:

app/views/layout.html.php

01<!DOCTYPE html>
02<html>
03<head>
04    <title><?php echo isset($title) ? _h($title) : config('blog.title') ?></title>
05
06    <meta charset="utf-8" />
07    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
08    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" />
09    <meta name="description" content="<?php echo config('blog.description')?>" />
10
11    <link rel="alternate" type="application/rss+xml" title="<?php echo config('blog.title')?>  Feed" href="<?php echo site_url()?>rss" />
12
13    <link href="<?php echo site_url() ?>assets/css/style.css" rel="stylesheet" />
14    <link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" />
15
16    <!--[if lt IE 9]>
17        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
18    <![endif]-->
19
20</head>
21<body>
22
23    <aside>
24
25        <h1><a href="<?php echo site_url() ?>"><?php echo config('blog.title') ?></a></h1>
26
27        <p class="description"><?php echo config('blog.description')?></p>
28
29        <ul>
30            <li><a href="<?php echo site_url() ?>">Home</a></li>
31            <li><a href="http://tutorialzine.com/members/">Members area</a></li>
32            <li><a href="http://tutorialzine.com/contact/">Contact Us</a></li>
33        </ul>
34
35        <p class="author"><?php echo config('blog.authorbio') ?></p>
36
37    </aside>
38
39    <section id="content">
40
41        <?php echo content()?>
42
43    </section>
44
45</body>
46</html>

In the head section I am also including a font from Google Web Fonts, and a HTML5 shim that will make it work on browsers as old as IE8. Throughout this view, I am printing the settings we put in config.ini, by using the config() function provided by Dispatch. This will let you customize the blog solely from the config file. Another function provided by dispatch is site_url() which gives you the absolute URL of your blog, so that you can include stylesheets, images or use it as the base for links.
Notice the call to the content() function. What this does, is print the HTML generated by one of the other views. This allows for other views to be “nested” inside it. For example running this code:

index.php (lines 29-33)

1render('main',array(
2    'page' => $page,
3    'posts' => $posts,
4    'has_pagination' => has_pagination($page)
5));

Will embed the main.html.php template you see below in the view. The page, posts and has_pagination members of the array will be available as variables:

app/views/main.html.php

01<?php foreach($posts as $p):?>
02    <div class="post">
03        <h2><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2>
04
05        <div class="date"><?php echo date('d F Y', $p->date)?></div>
06
07        <?php echo $p->body?>
08    </div>
09<?php endforeach;?>
10
11<?php if ($has_pagination['prev']):?>
12    <a href="?page=<?php echo $page-1?>" class="pagination-arrow newer">Newer</a>
13<?php endif;?>
14
15<?php if ($has_pagination['next']):?>
16    <a href="?page=<?php echo $page+1?>" class="pagination-arrow older">Older</a>
17<?php endif;?>

This will present a list of posts on the screen, with optional back/forward arrows. The other template that also operates with posts, is post.html.php, which shows a single post:

app/views/post.html.php

1<div class="post">
2
3    <h2><?php echo $p->title ?></h2>
4
5    <div class="date"><?php echo date('d F Y', $p->date)?></div>
6
7    <?php echo $p->body?>
8
9</div>

This is the view that you would need to edit if you want to add social sharing buttons or comment widgets from Facebook or Disqus.
And lastly, here is the 404 page:

app/views/404.html.php

01<!DOCTYPE html>
02<html>
03<head>
04    <meta charset="utf-8" />
05
06    <title>404 Not Found | <?php echo config('blog.title') ?></title>
07    <link href="<?php echo site_url() ?>assets/css/style.css" rel="stylesheet" />
08
09    <!-- Include the Open Sans font -->
10    <link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" />
11
12</head>
13<body>
14
15    <div class="center message">
16        <h1>This page doesn't exist!</h1>
17        <p>Would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p>
18    </div>
19
20</body>
21</html>

Note that this view is a complete HTML5 document. This is because it doesn’t follow the same layout as the rest of the blog. In the Dispatch framework, you can render a view that does not get embedded in the site layout, by passing false as the last argument to render:

app/includes/functions.php (lines 95-97)

1function not_found(){
2    error(404, render('404', null, false));
3}
Now that we have all the fancy HTML printed to the screen, let’s style it!

The CSS

In this part of the tutorial, we will write the CSS that will make the blog pretty and responsive. All these styles are located in the file assets/css/styles.css that you can edit to your liking. One of the reason this blog is so fast to load is because the design is entirely CSS-based, and I haven’t used any images (thanks to a data url trick that you will see in a moment).
Let’s start with the headings:

01h1{
02    font: 14px 'Open Sans Condensed', sans-serif;
03    text-transform:uppercase;
04    margin-bottom: 24px;
05}
06
07h2{
08    font: 48px 'Open Sans Condensed', sans-serif;
09}
10
11h1 a, h2 a{
12    color:#4f4f4f !important;
13    text-decoration: none !important;
14}

Next is the content and posts. Notice the background image to .post .date:before.

 01#content{
02    position: absolute;
03    font: 16px/1.5 'PT Serif', Times, Cambria, serif;
04    width: 580px;
05    left: 50%;
06    margin-left: -100px;
07}
08
09#content p,
10#content ul{
11    margin-bottom:25px;
12}
13
14#content ul{
15    padding-left:20px;
16}
17
18#content li{
19    margin-bottom:5px;
20}
21
22/* The actual post styles */
23
24.post{
25    padding: 50px 0 15px 0;
26    border-bottom: 1px solid #dfdfdf;
27}
28
29.post .date{
30    font: bold 12px 'Open Sans Condensed', sans-serif;
31    text-transform: uppercase;
32    color: #a7a7a7;
33    margin: 24px 0 30px 20px;
34    position: relative;
35}
36
37/* The calendar icon is set as a data url */
38
39.post .date:before{
40    width:18px;
41    height:18px;
42    position:absolute;
43    content:'';
44    left: -22px;
45    top: -1px;
46    background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA..')
47}

This is the Data URI scheme, which allows for data which would normally be a separate file to to be presented inline. So by encoding the icon in base64 and placing it directly in the background property, I am saving a request to the server.
Next, we have the left static bar, which always takes up the full height of the page:

01aside{
02    position: fixed;
03    width: 250px;
04    height: auto;
05    top: 0;
06    left: 50%;
07    bottom: 0;
08    margin-left: -460px;
09    padding-top: 65px;
10}
11
12aside p.description{
13    font-size: 13px;
14    line-height: 1.8;
15    margin-bottom: 40px;
16    color:#787878;
17}
18
19/* The main navigation links */
20aside ul{
21    font: bold 18px 'Open Sans Condensed', sans-serif;
22    text-transform: uppercase;
23    list-style:none;
24}
25
26aside ul li a{
27    text-decoration:none !important;
28    display:inline-block;
29    padding:0 3px;
30    margin:2px 0 2px 10px;
31}
32
33aside ul li a:hover{
34    background-color:#389dc1;
35    color:#fff;
36}
37
38aside p.author{
39    position: absolute;
40    bottom: 20px;
41    height: 30px;
42    font-size: 12px;
43    color: #888;
44}


After this, we will style the pagination arrows:
01.pagination-arrow{
02    display: inline-block;
03    font: bold 16px/1 'Open Sans Condensed', sans-serif;
04    border: 1px solid #ccc;
05    border-radius: 3px;
06    margin: 20px 15px;
07    color: #555 !important;
08    padding: 8px 12px;
09    text-decoration: none !important;
10    text-transform: uppercase;
11    position: relative;
12}
13
14.pagination-arrow.newer{
15    padding-left: 20px;
16}
17
18.pagination-arrow.older{
19    padding-right: 20px;
20    float:right;
21}
22
23.pagination-arrow.newer:before,
24.pagination-arrow.older:before{
25    content: '';
26    border: 5px solid #555;
27    border-color: transparent #555 transparent transparent;
28    width: 0;
29    height: 0;
30    position: absolute;
31    left: 3px;
32    top: 12px;
33}
34
35.pagination-arrow.older:before{
36    left:auto;
37    right:3px;
38    border-color: transparent transparent transparent #555;
39}

I am using an old border trick to create triangular arrows with CSS. Next are the styles, specific to the 404 page:

01.message{
02    padding-top:50px;
03}
04
05.message h1{
06    font-size:36px;
07    margin-bottom: 18px;
08}
09
10.message p{
11    font-size:13px;
12}
13
14.center{
15    text-align:center;
16}

And lastly, we have the media queries, that will tweak the layout depending on the resolution of the device:

01/* Small tablets */
02
03@media all and (max-width: 1024px) {
04    aside{
05        left: 5%;
06        margin-left: 0;
07        width: 25%;
08    }
09
10    #content{
11        left: 35%;
12        margin-left: 0;
13        width: 60%;
14    }
15}
16
17/* Smartphones */
18
19@media all and (max-width: 840px) {
20
21    h2{
22        font-size:36px;
23    }
24
25    aside{
26        margin-left: 0;
27        position: static;
28        width: 90%;
29        padding: 5% 5% 0 5%;
30        text-align: center;
31    }
32
33    aside .description{
34        margin-bottom: 25px;
35    }
36
37    aside li {
38        display: inline-block;
39    }
40
41    aside ul{
42        text-align: center;
43    }
44
45    aside .author{
46        display: none;
47    }
48
49    #content{
50        position: static;
51        padding: 5%;
52        padding-top: 0;
53        width: 90%;
54    }
55}

With this our lightweight flat-file blog is ready!
 by Martin Angelov
Source: http://tutorialzine.com/2013/03/simple-php-blogging-system-part-2/ 

Tutorial Let’s Build a Lightweight Blog System Part 1

DEMO      -     DOWNLOAD


In this tutorial, we will be making a lightweight blog system with PHP and CSS3. The blog posts will be stored in a folder as files (in the markdown format). The system will not use a database and will not have an admin panel, which makes it perfect for small blogs with only one author. It will have an RSS feed and a JSON read-only API, and will feature a completely responsive design that adapts to the screen size of the device.

In this first part, we are going to write the PHP backend, and in part 2, we will code the HTML and CSS. Let’s begin!

The posts

 

Posts will be named in the following pattern: 2013-03-14_url-of-the-post.md and they will be stored in the posts/ folder. The first part is the date of the post (you can optionally include a time as well if you have more than one post for that day), followed by an underscore, and the title of the post. The underscore is used by the system to separate the title from the date. This convention also has the benefit that posts can easily be sorted by publication date. When displayed on your blog, this post will have an URL like http://example.com/2013/03/url-of-the-post

Each post will be in the markdown format (hence the extension). The only requirement is that the first line of the markdown document is formatted as a H1 heading. For example:

1# The title of the blog post
2 
3Body of the blog post.  
This will make the first line a H1 heading. If this is the first time you’ve seen markdown, the next section is for you.

What is markdown

 

Markdown is a lightweight format for writing text. It has a minimal and intuitive syntax, which is transformed into HTML. This makes it perfect for our simple blog system, as it won’t have an admin panel nor database – all the posts will be stored in a folder as files.

We can’t simply display the raw markdown directly, first we have to transform it into HTML. There are a number of libraries that can do this (in every major language), but for this tutorial I chose the PHP Markdown library, as it integrates nicely with composer.

Composer

 

Composer is a dependency manager for PHP. With it, you can declare what libraries your project depends on, and they will be downloaded automatically for you. We will use it to include two libraries in this project:

You could simply download these libraries and use them straight away, but let’s see how we can do the same with composer (note that you need to follow these steps only if you are starting from scratch; the zip accompanying the tutorial already includes all the necessary files).
First we have to declare which packages the current project depends on, in a file named composer.json:

1{
2    "require": {
3    "dflydev/markdown": "v1.0.2",
4    "suin/php-rss-writer": ">=1.0"
5    }
6}

You can obtain the specific identifiers for the libraries and their versions from the composer package repository, or by following the instructions that each library included on its github repo.
The next steps are to install composer into your project (follow these instructions), and to run the install command. This will download all the appropriate libraries and place them in the vendor/ folder. All that is left is to include the composer autoloader in your php scripts:
1require 'vendor/autoload.php';
This will let you create instances of the libraries without having to include their PHP files individually.


The configuration file

 

I am using one additional PHP library - Dispatch. This is a tiny routing framework that I’ve mentioned before. It will let us listen for requests on specific URLs and render views. Unfortunately it doesn’t have Composer support at the moment, so we have to download it separately and include it into the project.
A neat feature of this framework is that it lets you write configuration settings in an INI file, which you can access with the config() function call. There are a number of settings you need to fill in for your blog to work:

app/config.ini

01; The URL of your blog
03 
04; Blog info
05 
06blog.title = "Tutorialzine Demo Blog"
07blog.description = "This is a lightweight and responsive blogging system.."
08blog.authorbio = "Created by ..."
09 
10posts.perpage = 5
11 
12; Framework config. No need to edit.
13views.root = app/views
14views.layout = layout

These settings are used throughout the views, so when you are setting up a new blog you won’t need to edit anything else.

The PHP code

 

Here is our main PHP file:

index.php

01// This is the composer autoloader. Used by
02// the markdown parser and RSS feed builder.
03require 'vendor/autoload.php';
04 
05// Explicitly including the dispatch framework,
06// and our functions.php file
07require 'app/includes/dispatch.php';
08require 'app/includes/functions.php';
09 
10// Load the configuration file
11config('source', 'app/config.ini');
12 
13// The front page of the blog.
14// This will match the root url
15get('/index', function () {
16 
17    $page = from($_GET, 'page');
18    $page = $page ? (int)$page : 1;
19 
20    $posts = get_posts($page);
21 
22    if(empty($posts) || $page < 1){
23        // a non-existing page
24        not_found();
25    }
26 
27     render('main',array(
28        'page' => $page,
29        'posts' => $posts,
30        'has_pagination' => has_pagination($page)
31    ));
32});
33 
34// The post page
35get('/:year/:month/:name',function($year, $month, $name){
36 
37    $post = find_post($year, $month, $name);
38 
39    if(!$post){
40        not_found();
41    }
42 
43    render('post', array(
44        'title' => $post->title .' ⋅ ' . config('blog.title'),
45        'p' => $post
46    ));
47});
48 
49// The JSON API
50get('/api/json',function(){
51 
52    header('Content-type: application/json');
53 
54    // Print the 10 latest posts as JSON
55    echo generate_json(get_posts(1, 10));
56});
57 
58// Show the RSS feed
59get('/rss',function(){
60 
61    header('Content-Type: application/rss+xml');
62 
63    // Show an RSS feed with the 30 latest posts
64    echo generate_rss(get_posts(1, 30));
65});
66 
67// If we get here, it means that
68// nothing has been matched above
69 
70get('.*',function(){
71    not_found();
72});
73 
74// Serve the blog
75dispatch();

The get() function of Dispatch creates a pattern that is matched against the currently visited URL. If they match, the callback function is executed and no more patterns are matched. The last get() call sets up a pattern that matches every URL in which case we show a 404 error.
Some of the functions you see above are not part of the Dispatch framework. They are specific to the blog and are defined in the functions.php file:

  • get_post_names() uses the glob function to find all the posts and to sort them in alphabetical order (as the date is the first part of the file name, this effectively sorts them by their publishing date);
  • get_posts() takes the list of names returned by get_post_names() and parses the files. It uses the Markdown library to convert them to HTML;
  • find_post() searches for a post by month, day and name;
  • has_pagination() is a helper function that is used in the views (we will look at them in the next part);
  • not_found() is a wrapper around Dispatch’s error function but renders a view as the message;
  • generate_rss() uses the RSS Library we mentioned above, and turns an array of posts into a valid RSS feed;
  • generate_json() is only a wrapper around json_encode, but I included it for consistency with the generate_rss function.

And here is the source:

app/includes/functions.php

001use dflydev\markdown\MarkdownParser;
002use \Suin\RSSWriter\Feed;
003use \Suin\RSSWriter\Channel;
004use \Suin\RSSWriter\Item;
005 
006/* General Blog Functions */
007 
008function get_post_names(){
009 
010    static $_cache = array();
011 
012    if(empty($_cache)){
013 
014        // Get the names of all the
015        // posts (newest first):
016 
017        $_cache = array_reverse(glob('posts/*.md'));
018    }
019 
020    return $_cache;
021}
022 
023// Return an array of posts.
024// Can return a subset of the results
025function get_posts($page = 1, $perpage = 0){
026 
027    if($perpage == 0){
028        $perpage = config('posts.perpage');
029    }
030 
031    $posts = get_post_names();
032 
033    // Extract a specific page with results
034    $posts = array_slice($posts, ($page-1) * $perpage, $perpage);
035 
036    $tmp = array();
037 
038    // Create a new instance of the markdown parser
039    $md = new MarkdownParser();
040 
041    foreach($posts as $k=>$v){
042 
043        $post = new stdClass;
044 
045        // Extract the date
046        $arr = explode('_', $v);
047        $post->date = strtotime(str_replace('posts/','',$arr[0]));
048 
049        // The post URL
050        $post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[1]);
051 
052        // Get the contents and convert it to HTML
053        $content = $md->transformMarkdown(file_get_contents($v));
054 
055        // Extract the title and body
056        $arr = explode('</h1>', $content);
057        $post->title = str_replace('<h1>','',$arr[0]);
058        $post->body = $arr[1];
059 
060        $tmp[] = $post;
061    }
062 
063    return $tmp;
064}
065 
066// Find post by year, month and name
067function find_post($year, $month, $name){
068 
069    foreach(get_post_names() as $index => $v){
070        if( strpos($v, "$year-$month") !== false && strpos($v, $name.'.md') !== false){
071 
072            // Use the get_posts method to return
073            // a properly parsed object
074 
075            $arr = get_posts($index+1,1);
076            return $arr[0];
077        }
078    }
079 
080    return false;
081}
082 
083// Helper function to determine whether
084// to show the pagination buttons
085function has_pagination($page = 1){
086    $total = count(get_post_names());
087 
088    return array(
089        'prev'=> $page > 1,
090        'next'=> $total > $page*config('posts.perpage')
091    );
092}
093 
094// The not found error
095function not_found(){
096    error(404, render('404', null, false));
097}
098 
099// Turn an array of posts into an RSS feed
100function generate_rss($posts){
101 
102    $feed = new Feed();
103    $channel = new Channel();
104 
105    $channel
106        ->title(config('blog.title'))
107        ->description(config('blog.description'))
108        ->url(site_url())
109        ->appendTo($feed);
110 
111    foreach($posts as $p){
112 
113        $item = new Item();
114        $item
115            ->title($p->title)
116            ->description($p->body)
117            ->url($p->url)
118            ->appendTo($channel);
119    }
120 
121    echo $feed;
122}
123 
124// Turn an array of posts into a JSON
125function generate_json($posts){
126    return json_encode($posts);
127}

At the top of the file, we have a number of use statements, which import the necessary namespaces (read more about PHP’s namespaces).

The last thing we need to do, is to rewrite all requests so they hit index.php. Otherwise our fancy routes wouldn’t work. We can do this with an .htaccess file:

1RewriteEngine On
2 
3RewriteCond %{REQUEST_FILENAME} !-f
4RewriteCond %{REQUEST_FILENAME} !-d
5 
6RewriteCond $1 !^(index\.php)
7RewriteRule ^(.*)$ index.php/$1 [L]

If a file or folder does not exist, the request will be redirected to index.php.

by Martin Angelov
source: http://tutorialzine.com/2013/03/simple-php-blogging-system/
 
Support : Femin Collection | Habitat Design | Kreatifa Media
Copyright © 2013. Kreatifa Media - All Rights Reserved
Template Created by Habitat Design Published by Kreatifa Media
Proudly powered by Blogger