Giblog - Website and Blog builder

Giblog is Website and Blog builder written by Perl.

Website Example

This is Website initial example. Website Example


Blog Example

This is Blog initial example. Blog Example



Information Site Example

This is Information site example. Information Site Example



Do you need to create personal site or blog, or corporate site or blog?

If you are so, let's read the following description, features, tutorials.

DESCRIPTION

Giblog is Website and Blog builder written by Perl.

You can create your website and blog easily.

All created files is static HTML, so you can manage them using git.

You can customize your website by Perl.

Giblog is in beta test before 1.0 release. Note that features is changed without warnings.

SYNOPSYS

# New empty web site
giblog new mysite

# New web site
giblog new_website mysite

# New blog
giblog new_blog mysite

# Change directory
cd mysite

# Add new entry
giblog add

# Build web site
giblog build

# Serve web site(need Mojolicious)
morbo serve.pl

# Add new entry with home directory
giblog add --home /home/kimoto/mysite

# Build web site with home directory
giblog build --home /home/kimoto/mysite

FEATURES

Giblog have the following features.

  • Build Website and Blog.

  • Linux, Mac OS, Windows Support. (In Windows, recommend installation of msys2)

  • Responsive web site support. Default CSS is setup for PC and Smart phone.

  • Header, Hooter and Side bar support

  • You can customize Top and Bottom section of content.

  • Automatical Line break. p tag is automatically added.

  • Escape <, > automatically in pre tag

  • Title tag is automatically added from first h1-h6 tag.

  • Description meta tag is automatically added from first p tag.

  • You can customize your web site by Perl programming laugnage.

  • You can serve your web site in local environment. Contents changes is detected and build automatically(need Mojolicious).

  • Build 645 pages by 0.78 seconds in starndard linux environment.

  • All build files is Static. you can manage files by Git.

TUTORIAL

Create web site

1. Empty website

"new" command create empty website. "mysite" is a name of your web site.

giblog new mysite

If you want to create empty site, choice this command.

Templates and CSS is empty and provide minimal build script.

2. Website

"new_website" command create simple website. "mysite" is a name of your web site.

giblog new_website mysite

If you want to create simple website, choice this command.

Top page "templates/index.html" is created. CSS supports responsive design and provide basic build script.

3. Blog

"new_blog" command create empty website. "mysite" is a name of your web site.

giblog new_blog mysite

If you want to create blog, choice this prototype.

Top page "templates/index.html" is created, which show 7 days entries.

List page "templates/list.html" is created, which show all entries links.

CSS supports responsive design and provide basic build script.

Add blog entry page

You need to change directory to "mysite" before run "add" command if you are in other directory.

cd mysite

"add" command add entry page.

giblog add

Created file name is, for example,

templates/blog/20080108132865.html

This file name contains current date and time.

Then open this file, write h2 head and content.

<h2>How to use Giblog</h2>

How to use Giblog. This is ...

Header and footer is automatically added.

Add content page

If you want to create content page, put file, for example "access.html", or "profile.html" into "templates" directory.

templates/access.html
templates/profile.html

Then open these file, write h2 head and content.

<h2>How to use Giblog</h2>

How to use Giblog. This is ...

Header and footer is automatically added.

You can create sub directory.

templates/profile/more.html

Note that "templates/static" and "templates/common" is special directories. Don't use these directories for content page.

Add static page

If you want to add static files like css, images, JavaScript, You put these file into "templates/static" directory.

Files in "templates/static" directory is only copied to public files by build script.

templates/static/js/jquery.js
templates/static/images/logo.png
templates/static/css/more.css

Build web site

You need to change directory to "mysite" before run "build" command if you are in other directory.

cd mysite

"build" command build web site.

giblog build

What is build process?

Build script is writen in "lib/Giblog/Command/build.pm".

"build" command only execute "run" method in "Giblog::Command::build.pm" .

# "lib/Giblog/Command/build.pm" in web site created by "new_blog" command
package Giblog::Command::build;

use base 'Giblog::Command';

use strict;
use warnings;

use File::Basename 'basename';

sub run {
  my ($self, @args) = @_;
  
  # API
  my $api = $self->api;
  
  # Read config
  my $config = $api->read_config;
  
  # Copy static files to public
  $api->copy_static_files_to_public;

  # Get files in templates directory
  my $files = $api->get_templates_files;
  
  for my $file (@$files) {
    # Data
    my $data = {file => $file};
    
    # Get content from file in templates directory
    $api->get_content($data);

    # Parse Giblog syntax
    $api->parse_giblog_syntax($data);

    # Parse title
    $api->parse_title_from_first_h_tag($data);

    # Edit title
    my $site_title = $config->{site_title};
    if ($data->{file} eq 'index.html') {
      $data->{title} = $site_title;
    }
    else {
      $data->{title} = "$data->{title} - $site_title";
    }

    # Add page link
    $api->add_page_link_to_first_h_tag($data, {root => 'index.html'});

    # Parse description
    $api->parse_description_from_first_p_tag($data);

    # Read common templates
    $api->read_common_templates($data);
    
    # Add meta title
    $api->add_meta_title($data);

    # Add meta description
    $api->add_meta_description($data);

    # Build entry html
    $api->build_entry($data);
    
    # Build whole html
    $api->build_html($data);
    
    # Write to public file
    $api->write_to_public_file($data);
  }
  
  # Create index page
  $self->create_index;
  
  # Create list page
  $self->create_list;
}

You can customize build script if you need.

If you need to know Giblog API, see Giblog::API.

Serve web site

If you have Mojolicious, you can serve web site in local environment.

morbo serve.pl

You see the following message.

Server available at http://127.0.0.1:3000
Server start

If files in "templates" directory is changed, Web site is automatically rebuild.

Customize header or footer, etc

You can customize header, footer, side bar, top of content, bottom of content.

------------------------
Header
------------------------
Top of content   |
-----------------|
                 |Side
Content          |bar
                 |
-----------------|
Bottom of content|
------------------------
Footer
------------------------

If you want to edit these section, you edit these files.

templates/common/bottom.html
templates/common/footer.html
templates/common/header.html
templates/common/side.html
templates/common/top.html

Customize HTML header

You can customize HTML header.

<html>
  <head>
    <!-- HTML header -->
  </head>
  <body>
  
  </body>
</html>

If you want to edit HTML header, you edit the following file.

templates/common/meta.html

METHODS

These methods is internally methods. Normally, you don't need to know these methods. See Giblog::API to manipulate HTML contents.

new

my $api = Giblog->new(%params);

Create Giblog object.

Parameters:

  • home_dir - home directory

  • config - config

run_command

$giblog->run_command(@argv);

Run command system.

config

my $config = $giblog->config;

Get Giblog config.

home_dir

my $home_dir = $giblog->home_dir;

Get home directory.

AUTHOR

Yuki Kimoto, <kimoto.yuki at gmail.com>

LICENSE AND COPYRIGHT

Copyright 2018-2019 Yuki Kimoto.

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0