/usr/bin/blaze-init is in blazeblogger 1.2.0-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | #!/usr/bin/perl
# blaze-init - creates or recovers a BlazeBlogger repository
# Copyright (C) 2008-2011 Jaromir Hradilek
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA-
# BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
use File::Basename;
use File::Path;
use File::Spec::Functions;
use Getopt::Long;
# General script information:
use constant NAME => basename($0, '.pl'); # Script name.
use constant VERSION => '1.2.0'; # Script version.
# General script settings:
our $blogdir = '.'; # Repository location.
our $force = 0; # Force files rewrite?
our $verbose = 1; # Verbosity level.
# Set up the __WARN__ signal handler:
$SIG{__WARN__} = sub {
print STDERR NAME . ": " . (shift);
};
# Display an error message, and terminate the script:
sub exit_with_error {
my $message = shift || 'An error has occurred.';
my $return_value = shift || 1;
# Display the error message:
print STDERR NAME . ": $message\n";
# Terminate the script:
exit $return_value;
}
# Display a warning message:
sub display_warning {
my $message = shift || 'A warning was requested.';
# Display the warning message:
print STDERR "$message\n";
# Return success:
return 1;
}
# Display usage information:
sub display_help {
my $NAME = NAME;
# Display the usage:
print << "END_HELP";
Usage: $NAME [-fqV] [-b DIRECTORY]
$NAME -h|-v
-b, --blogdir DIRECTORY specify a directory in which the BlazeBlogger
repository is to be placed
-f, --force revert existing configuration, theme, and
language files to their initial state
-q, --quiet do not display unnecessary messages
-V, --verbose display all messages, including a list of
created files
-h, --help display this help and exit
-v, --version display version information and exit
END_HELP
# Return success:
return 1;
}
# Display version information:
sub display_version {
my ($NAME, $VERSION) = (NAME, VERSION);
# Display the version:
print << "END_VERSION";
$NAME $VERSION
Copyright (C) 2008-2011 Jaromir Hradilek
This program is free software; see the source for copying conditions. It is
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PAR-
TICULAR PURPOSE.
END_VERSION
# Return success:
return 1;
}
# Create the default configuration file:
sub create_conf {
# Prepare the configuration file name:
my $file = catfile($blogdir, '.blaze', 'config');
# Unless explicitly requested, do not overwrite the existing file:
return 1 if (-e $file && !$force);
# Open the file for writing:
open(FILE, ">$file") or return 0;
# Write the default configuration to the file:
print FILE << 'END_CONFIG';
## This is the default BlazeBlogger configuration file. The recommended way
## to set up your blog is to leave this file intact, and use blaze-config
## instead. However, if you prefer to configure BlazeBlogger by hand, read
## the instructions below, and replace the value on the right of the equal
## sign.
## General blog settings. Available options are:
##
## title A title of your blog.
## subtitle A subtitle of your blog.
## description A brief description of your blog.
## keywords A comma-separated list of keywords.
## theme A theme for your blog. It must point to an existing file
## in the .blaze/theme/ directory.
## style A style sheet for your blog. It must point to an exis-
## ting file in the .blaze/style/ directory.
## lang A translation of your blog. It must point to an existing
## file in the .blaze/lang/ directory.
## posts A number of blog posts to be listed on a single page.
##
[blog]
title=Blog Title
subtitle=blog subtitle
description=blog description
keywords=blog keywords
theme=default.html
style=default.css
lang=en_US
posts=10
## Color settings. Available options are:
##
## list A boolean to enable (true) or disable (false) colors in
## the blaze-list output.
## log A boolean to enable (true) or disable (false) colors in
## the blaze-log output.
##
[color]
list=false
log=false
## Advanced BlazeBlogger settings. Available options are:
##
## doctype A document type. It can be either html for HTML, or
## xhtml for the XHTML standard.
## extension A file extension.
## encoding A character encoding. It has to be in a form that is re-
## cognized by W3C standards.
## editor An external text editor. When supplied, this option
## overrides the system-wide settings.
## processor An external application to be used to process newly ad-
## ded or edited blog posts and pages. You must supply %in%
## and %out% in place of an input and output file name res-
## pectively.
##
[core]
doctype=html
extension=html
encoding=UTF-8
editor=
processor=
## RSS feed settings. Available options are:
##
## baseurl A URL of your blog, for example "http://example.com/".
## posts A number of blog posts to be listed in the feed.
## fullposts A boolean to enable (true) or disable (false) inclusion
## of the whole content of a blog post in the feed.
##
[feed]
baseurl=
posts=10
fullposts=false
## Advanced post settings. Available options are:
##
## author A location of a blog post author name. It can either be
## placed above the post (top), below it (bottom), or no-
## where on the page (none).
## date A location of a date of publishing. It can either be
## placed above the post (top), below it (bottom), or no-
## where on the page (none).
## tags A location of post tags. They can either be placed above
## the post (top), below it (bottom), or nowhere on the
## page (none).
##
[post]
author=top
date=top
tags=top
## User settings. Available options are:
##
## name Your full name to be used in the copyright notice, and
## as the default post author.
## nickname Your nickname to be used as the default post author.
## When supplied, this option overrides the above setting.
## email Your email address.
##
[user]
name=admin
nickname=
email=admin@localhost
END_CONFIG
# Close the file:
close(FILE);
# Report success:
print "Created $file\n" if $verbose > 1;
# Return success:
return 1;
}
# Create the default theme file:
sub create_theme {
# Prepare the theme file name:
my $file = catfile($blogdir, '.blaze', 'theme', 'default.html');
# Unless explicitly requested, do not overwrite the existing file:
return 1 if (-e $file && !$force);
# Open the file for writing:
open(FILE, ">$file") or return 0;
# Write the default theme to the file:
print FILE << 'END_THEME';
<!-- START-DOCUMENT -->
<head>
<!-- content-type -->
<!-- generator -->
<!-- copyright -->
<!-- date -->
<!-- description -->
<!-- keywords -->
<!-- stylesheet -->
<!-- feed -->
<title><!-- page-title --></title>
</head>
<body>
<div id="wrapper">
<div id="shadow">
<div id="heading">
<h1><a href="%home%" rel="index"><!-- title --></a></h1>
<!-- subtitle -->
</div>
<div id="menu">
<ul>
<li><a href="%home%" rel="index">Home</a></li>
<!-- pages -->
</ul>
</div>
</div>
<div id="content">
<!-- content -->
</div>
<div id="sidebar">
<h2>Categories</h2>
<ul>
<!-- tags -->
</ul>
<h2>Archive</h2>
<ul>
<!-- archive -->
</ul>
<h2>Links</h2>
<ul>
<li><a href="http://blaze.blackened.cz">BlazeBlogger</a></li>
</ul>
</div>
<div id="footer">
Copyright © <!-- year --> <!-- name -->.
Powered by <a href="http://blaze.blackened.cz/">BlazeBlogger</a>.
</div>
</div>
</body>
<!-- END-DOCUMENT -->
END_THEME
# Close the file:
close(FILE);
# Report success:
print "Created $file\n" if $verbose > 1;
# Return success:
return 1;
}
# Create the default style sheet:
sub create_style {
# Prepare the style sheet file name:
my $file = catfile($blogdir, '.blaze', 'style', 'default.css');
# Unless explicitly requested, do not overwrite the existing file:
return 1 if (-e $file && !$force);
# Open the file for writing:
open(FILE, ">$file") or return 0;
# Write the default style style sheet to the file:
print FILE << 'END_STYLE';
/* default.css, the default theme for BlazeBlogger
* Copyright (C) 2009, 2010 Jaromir Hradilek
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA-
* BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
body {
margin: 0px 0px 10px 0px;
padding: 0px;
color: #000000;
background-color: #e7e7e7;
font-family: "DejaVu Sans", Arial, sans;
font-size: small;
}
#wrapper {
margin: auto;
padding: 0px;
width: 768px;
border-left: 1px solid #d6d6d6;
border-right: 1px solid #d6d6d6;
border-bottom: 1px solid #d6d6d6;
background-color: #ffffff;
}
#shadow {
margin: 0px;
padding: 0px;
border-bottom: 2px solid #e7e7e7;
}
#heading {
width: 728px;
padding: 20px;
background-color: #2e2e2e;
border-bottom: 2px solid #2a2a2a;
border-top: 2px solid #323232;
color: #d0d0d0;
}
#heading a, #heading h1 {
margin: 0px;
text-decoration: none;
color: #ffffff;
}
#heading a:hover {
text-decoration: underline;
}
#menu {
width: 768px;
border-top: 1px solid #5f5f5f;
border-bottom: 1px solid #3d3d3d;
background-color: #4e4e4e;
}
#menu ul {
padding: 4px 15px 4px 15px;
margin: 0px;
list-style-type: none;
}
#menu li {
display: inline;
padding: 4px 10px 5px 10px;
margin: 0px;
}
#menu li:hover {
background-color: #3d3d3d;
border-bottom: 2px solid #dddddd;
border-top: 1px solid #4e4e4e;
}
#menu a {
color: #ffffff;
font-size: x-small;
text-decoration: none;
}
#menu a:hover {
text-decoration: underline;
}
#content {
float: left;
margin: 0px;
padding: 10px 10px 20px 20px;
width: 528px;
text-align: justify;
}
#content h2.post {
margin-bottom: 0px;
padding-bottom: 0px;
}
#content .post a {
text-decoration: none;
color: #9acd32;
}
#content a {
text-decoration: none;
color: #4e9a06;
}
#content a:hover {
text-decoration: underline;
}
#content .information {
font-size: x-small;
color: #4e4e4e;
}
#content .information a {
color: #4e9a06;
text-decoration: underline;
}
#content .information a:hover {
text-decoration: none;
}
#content .post-footer {
font-size: x-small;
color: #4e4e4e;
padding: 4px 2px 4px 2px;
border-top: 1px solid #e7e7e7;
border-bottom: 1px solid #e7e7e7;
background-color: #f8f8f8;
}
#content .post-footer a {
color: #4e9a06;
text-decoration: underline;
}
#content .post-footer a:hover {
text-decoration: none;
}
#content .section {
text-align: right;
font-size: x-small;
color: #808080;
}
#content .previous {
padding: 10px 0px 10px 0px;
float: left;
}
#content .next {
padding: 10px 0px 10px 0px;
float: right;
}
#sidebar {
float: right;
margin: 0px;
padding: 10px 20px 20px 0px;
width: 180px;
}
#sidebar h2 {
font-size: small;
}
#sidebar ul {
list-style-type: none;
padding-left: 1em;
margin-left: 0px;
}
#sidebar a {
text-decoration: underline;
color: #4e9a06;
}
#sidebar a:hover {
text-decoration: none;
}
#footer {
clear: both;
margin: 0px;
padding: 10px 20px 10px 20px;
border-top: 2px solid #e7e7e7;
border-bottom: 1px solid #3d3d3d;
background-color: #4e4e4e;
text-align: right;
font-size: x-small;
color: #d0d0d0;
}
#footer a {
color: #ffffff;
text-decoration: none;
}
#footer a:hover {
text-decoration: underline;
}
END_STYLE
# Close the file:
close(FILE);
# Report success:
print "Created $file\n" if $verbose > 1;
# Return success:
return 1;
}
# Create the default localization file:
sub create_lang {
# Prepare the localization file name:
my $file = catfile($blogdir, '.blaze', 'lang', 'en_US');
# Unless explicitly requested, do not overwrite the existing file:
return 1 if (-e $file && !$force);
# Open the file for writing:
open(FILE, ">$file") or return 0;
# Write the default localization to the file:
print FILE << 'END_LANG';
[lang]
archive=Archive for
tags=Posts tagged as
taglist=List of tags
previous=« Previous
next=Next »
more=Read more »
postedon=
postedby=by
taggedas=tagged as
january=January
february=February
march=March
april=April
may=May
june=June
july=July
august=August
september=September
october=October
november=November
december=December
END_LANG
# Close the file:
close(FILE);
# Report success:
print "Created $file\n" if $verbose > 1;
# Return success:
return 1;
}
# Add the event to the log:
sub add_to_log {
my $text = shift || 'Something miraculous has just happened!';
# Prepare the log file name:
my $file = catfile($blogdir, '.blaze', 'log');
# Open the log file for appending:
open(LOG, ">>$file") or return 0;
# Write the event to the file:
print LOG localtime(time) . " - $text\n";
# Close the file:
close(LOG);
# Return success:
return 1;
}
# Set up the option parser:
Getopt::Long::Configure('no_auto_abbrev', 'no_ignore_case', 'bundling');
# Process command line options:
GetOptions(
'help|h' => sub { display_help(); exit 0; },
'version|v' => sub { display_version(); exit 0; },
'force|f' => sub { $force = 1; },
'quiet|q' => sub { $verbose = 0; },
'verbose|V' => sub { $verbose = 2; },
'blogdir|b=s' => sub { $blogdir = $_[1]; },
);
# Detect superfluous options:
exit_with_error("Invalid option `$ARGV[0]'.", 22) if (scalar(@ARGV) != 0);
# Decide whether to create or recover the repository:
my $action = (-d catdir($blogdir, '.blaze')) ? 'Recovered' : 'Created';
# Create the directory tree:
eval {
mkpath(
[
catdir($blogdir, '.blaze', 'lang'),
catdir($blogdir, '.blaze', 'theme'),
catdir($blogdir, '.blaze', 'style'),
catdir($blogdir, '.blaze', 'pages', 'head'),
catdir($blogdir, '.blaze', 'pages', 'body'),
catdir($blogdir, '.blaze', 'pages', 'raw'),
catdir($blogdir, '.blaze', 'posts', 'head'),
catdir($blogdir, '.blaze', 'posts', 'body'),
catdir($blogdir, '.blaze', 'posts', 'raw'),
],
0 # Do not be verbose.
);
};
# Make sure the directory tree creation was successful:
exit_with_error("Creating directory tree: $@", 13) if $@;
# Create the default configuration file:
create_conf()
or display_warning("Unable to create the default configuration file.");
# Create the default theme:
create_theme()
or display_warning("Unable to create the default theme.");
# Create the default style sheet:
create_style()
or display_warning("Unable to create the default style sheet.");
# Create the default localization:
create_lang()
or display_warning("Unable to create the default localization.");
# Create the default log file:
add_to_log("$action a BlazeBlogger repository.")
or display_warning("Unable to log the event.");
# Report success:
print "$action a BlazeBlogger repository in " .
catdir($blogdir, '.blaze') . ".\n" if $verbose;
# Return success:
exit 0;
__END__
=head1 NAME
blaze-init - creates or recovers a BlazeBlogger repository
=head1 SYNOPSIS
B<blaze-init> [B<-fqV>] [B<-b> I<directory>]
B<blaze-init> B<-h>|B<-v>
=head1 DESCRIPTION
B<blaze-init> either creates a fresh new BlazeBlogger repository, or
recovers an existing one in case it is corrupted. Optionally, it can also
revert a configuration and default templates to their original state,
leaving all user data (that is, both blog posts and pages) intact.
=head1 OPTIONS
=over
=item B<-b> I<directory>, B<--blogdir> I<directory>
Allows you to specify a I<directory> in which the BlazeBlogger repository
is to be blaced. The default option is a current working directory.
=item B<-f>, B<--force>
Reverts existing configuration, theme, and language files to their initial
state. By default, these files are kept intact.
=item B<-q>, B<--quiet>
Disables displaying of unnecessary messages.
=item B<-V>, B<--verbose>
Enables displaying of all messages, including a list of created files.
=item B<-h>, B<--help>
Displays usage information and exits.
=item B<-v>, B<--version>
Displays version information and exits.
=back
=head1 EXAMPLE USAGE
Create a new blog in a current directory:
~]$ blaze-init
Created a BlazeBlogger repository in .blaze.
Create a new blog in ~/public_html:
~]$ blaze-init -b ~/public_html
Created a BlazeBlogger repository in /home/joe/public_html/.blaze.
Revert a configuration file and default templates to their initial state:
~]$ blaze-init -f
Recovered a BlazeBlogger repository in .blaze.
Or if you want to see what files have been reverted:
~]$ blaze-init -fV
Created .blaze/config
Created .blaze/theme/default.html
Created .blaze/style/default.css
Created .blaze/lang/en_US
Recovered a BlazeBlogger repository in .blaze.
=head1 SEE ALSO
B<blaze-config>(1), B<blaze-add>(1)
=head1 BUGS
To report a bug or to send a patch, please, add a new issue to the bug
tracker at <http://code.google.com/p/blazeblogger/issues/>, or visit the
discussion group at <http://groups.google.com/group/blazeblogger/>.
=head1 COPYRIGHT
Copyright (C) 2008-2011 Jaromir Hradilek
This program is free software; see the source for copying conditions. It is
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
=cut
|