Skip to content

Instantly share code, notes, and snippets.

use v6;
grammar JSON::Tiny::Grammar;
rule TOP { ^[ <object> | <array> ]$ }
rule object { '{' ~ '}' <pairlist> }
rule pairlist { [ <pair> ** [ \, ] ]? }
rule pair { <string> ':' <value> }
rule array { '[' ~ ']' [ <value> ** [ \, ] ]? }
proto token value { <...> };
#!perl
package Gate;
use Data::Dumper;
use warnings;
use Carp;
sub new {
my $self = bless {}, 'Gate';
use File::Find;
use File::Copy;
use Cwd;
use File::Path qw(make_path);
my $workdir = getcwd;
find(sub {
return if -d;
return if -l;
use File::Find;
use File::Copy;
use Cwd;
my $workdir = getcwd;
find(sub {
return if -d;
return if -l;
return if /^\./;
sub _hdlr_entry_body_has_width {
my($ctx, $args, $cond) = @_;
return 0 if ( ! $ctx->stash('entry') );
unless( $args->{'width'} ) {
## tut nado chto-to sdelat s soobsheniem - ono ne sootwetstvuet logike
&MT::log('Unexpected parameter width for tag <MTIfEntryBodyHasWidth>');
return 0;
}
sub _hdlr_entry_body_has_image {
my($ctx, $args, $cond) = @_;
return 0 if (!$ctx->stash('entry'));
my $entry_text = &MT::Template::Context::_hdlr_entry_body;
my @paragraphs = split(/<p[^>]*>/i, $entry_text);
## just checking for img tag in the
## first three paragraphs, skip first array element,
## because of that element is fake element
# Setting loggers
log4perl.logger.ConsoleFile=INFO, Console, File
log4perl.logger.Console=INFO, Console
log4perl.rootLogger=INFO, Console, File
# File appender
log4perl.appender.File=Log::Log4perl::Appender::File
log4perl.appender.File.filename= sub { HP::Logger::get_log_file_name(); }
log4perl.appender.File.mode=append
package HP::Logger;
BEGIN {
use FindBin qw($Bin $Script);
$Script =~ s/.pl//;
unshift @INC, "$Bin/../lib/perl";
unshift @INC, "$Bin/../lib/mt/extlib";
}
use Exporter;
to_tz(R, Tz) ->
Tz_offset = ((Tz#timezone.hour * 60) + Tz#timezone.minute) * 60,
R_offset = (((R#timestamp.timezone)#timezone.hour * 60) + (R#timestamp.timezone)#timezone.minute) * 60,
R_seconds = calendar:datetime_to_gregorian_seconds(to_datetime(R)),
New_seconds = R_seconds - R_offset + Tz_offset,
Datetime = calendar:gregorian_seconds_to_datetime(New_seconds),
{ok, New_R} = from_datetime(Datetime),
New_R#timestamp{timezone = Tz, fraction = R#timestamp.fraction}.
parse_iso8601(Time) when is_list(Time) ->
parse_iso8601( list_to_binary(Time) );
parse_iso8601(Time) when is_binary(Time) ->
try
{ok, iso_to_rec(
year,
Time,
#timestamp{
year = 0,