A1z-HTML5-Template

 view release on metacpan or  search on metacpan

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

				my ( $meta_name, $meta_cont) = split(/---/, $_, 2);
				
				$return .= qq{<meta name="$meta_name" content="$meta_cont">\n}; 
			}
			
			return qq{$return<!--360-->}; 
		}
		else 
		{
			$out .= qq{<meta name="description" content="HTML5 by Business Impact Solutions - bislinks.com"/><!--364-->}; 
			# add default meta if user has not called one of his own
			return qq{$out}; 
		}
		
	}
	else 
	{
		return qq{$out}; 	# this works but does not ask the user
	}
	
} 

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

	}
	
	# if SELECT .... 
	
	my $select; 
	
	if ($form_vars[3] and $form_vars[3] =~ /^select/) 
	{
		# get the params for the form 
		#   select,   
		my ($sel_key, $sel_name, $sel_default, $folder_or_file, $selectLabelText) = split(/\,/, $form_vars[3], 5); 

		$select .= qq{
	<label for="$sel_name">$selectLabelText</label>
	<div class="form-group"><!--begin select-->
	\t<select name="$sel_name">
	\t\t<option selected value="$sel_default">$sel_default</option>
	};
		
		#now open file/folder to fill "options" 
		if ( -f $folder_or_file ) 
		{
			# open as file 
			#$select .= qq{none}; 
		}
		elsif (-d $folder_or_file)
		{

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

	$out .= qq{<form action="$form_vars[2]" method="$form_vars[1]">};  
	
		# add hidden fields/values # from $form_vars[4] 
		for (@hidden)
		{
			my ($name, $value) = split(/\-\-\-/, $_, 2) if $_; 
			$out .= qq{\n\t<input type="hidden" name="$name" value="$value"/>} if $_; 
		}
		# add select 
		$out .= qq{$select};  
	$out .= qq{\n\t<button type="submit" class="btn btn-default">Submit</button>\n</form>\n}; 
	
	return qq{<div class="body_form">$out</div>}; 
}

# end body_form 



sub defaults_begin
{
	my $self = shift; 
	
	my $out;
	
	$out .= sprintf header(),  
		start_html(),  
		head_title("$_[0]"),  
		head_meta(), 
		head_meta("$_[1]"), 

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

		end_head(),  
		begin_body(),  
		body_topnavbar()
	;
		
		return $out; 
}



sub defaults_end 
{
	my $self = shift; 
	
	my $out;
	
	$out .= sprintf body_js_css(),
		body_js_css("$_[0]"),
		end_body(), 
		end_html() 
	;
	
	return $out;
}



# HTML 
my %HTML;

%HTML = (
	-defaultjquery => qq{\n<!-- -defaultjquery-->

		<!-- jquery-->
		<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>

		<!--bootstrap-->
		<script  src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>

		<!--blueimp gallery-->
		<script src="https://blueimp.github.io/Gallery/js/jquery.blueimp-gallery.min.js"></script>

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

		\$('#accordion1').accordion(); 
		\$('#accordion2').accordion(); 
		\$('#accordion3').accordion(); 
		\$('accordion617').accordion();
		\$('#tabs').tabs(); 

		
		</script>
	},
	
	-default_LastItem => qq{},
	
);


sub html_bootstrap_css   
{
	return qq{<!-- Bootstrap/jqueryUI -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="https://www.a1z.us/jquery/bootstrap/fixed-top/navbar-fixed-top.css" rel="stylesheet">
};

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

	    <!-- The modal dialog, which will be used to wrap the lightbox content -->
	    <div class="modal fade">
	        <div class="modal-dialog">
	            <div class="modal-content">
	                <div class="modal-header">
	                    <button type="button" class="close" aria-hidden="true">&times;</button>
	                    <h4 class="modal-title"></h4>
	                </div>
	                <div class="modal-body next"></div>
	                <div class="modal-footer">
	                    <button type="button" class="btn btn-default pull-left prev">
	                        <i class="glyphicon glyphicon-chevron-left"></i>
	                        Previous
	                    </button>
	                    <button type="button" class="btn btn-primary next">
	                        Next
	                        <i class="glyphicon glyphicon-chevron-right"></i>
	                    </button>
	                </div>
	            </div>
	        </div>

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

	my $out; 
	
	my %in; 
	
	%in = (
		-h1 => qq{A1Z .us},
		-onload => qq{setTitle();},  
		-nbhead => qq{},
		-nbpage => qq{}, 
		-nbmenu => qq{More}, 
		-defaultjquery => qq{$HTML{-defaultjquery}}, 
		-humanejs => qq{<script src="https://cdnjs.cloudflare.com/ajax/libs/humane-js/3.2.2/humane.min.js">},
		-userjquery => qq{}, 
		-navbar => html_navbar( $in{-nbmenu}, $in{-nbpage}, "", ""), 
		-content => qq{<div class="content">Content</div>}, 
		-footer => qq{All rights reserved &copy; A1Z .us}, 	
		-bootstrapbluimp => html_bootstrap_bluimp,
		-nbLinks => qq{contact-help-feedback},
		@_, 		
	); 
	

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

	$in{-bootstrapbluimp}

	$in{-h1}

	$in{-content}
	
	$in{-footer}

</div>

$in{-defaultjquery}

$in{-humanejs}
 
<script>
//<!--
$in{-userjquery}
//--> 
</script>

</body>

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

		$h->body_js_css();
		
		Includes 
			jquery 1.12.4, jquery ui 1.11.4, bootstrap 3.3.0, 
			javascript for #dialog function, #menu, #accordion, #tabs 
	
	Add your own .js file: 
		
		use $h->body_js_css("/path/to/js/file.js");
		
	You can use both to include default .js files and your own custom .js file. 

=head2 end_html 

	Provides </html>

=head2 head_title

	Provides <title></title>
	
	$h->head_title("App/Page Title");

=head2 head_meta

	Provides <meta ... >. Includes the following by default:
		IE=Edge
		HandheldFriendly
		viewport
	
	$h->head_meta();
	
	Just like body_js_css, you can use both to add default values and your own meta 

=head2 body_topnavbar

	Provides top nav bar optionally.
	
	By default it is loaded from www.a1z.us which probably be removed in a future version.
	So, get a copy from bootstrap 3 and store it on your server.

=head2 head_js_css

	provides the ability to add/include .js/.css files in the </head> tag.
	
	$h->head_js_css();
	
		Default includes the following:
		

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

	$h->end_body();

=head2 body_form

	Form, lists items from a directory in a neat drop-down list with each item's file size in KB!

	Should be in the exact format like below: 
	
	$h->body_form("vars;METHOD;Action.cgi;select,NameForSelectTag,DefaultOptionSelected,AbsPathToDir,TextForSelectLabel;hidN1---hidV1,hidN2---hidV2,hidN3---hidV3");

=head2 defaults_begin

	Internal Use Only

	Provides defaults for very lightweight template for those in a hurry; Can be used for apps/sites that are under construction! 
	
	$h->defaults_begin();

=head2 defaults_end

	Internal Use Only.

	provides defaults for lightweight or under construction app/website. 
	
	$h->defaults_end();

=head1 HTML Hash

	For Internal/Future Use

	Hash contains -defaultjquery which is used in body.

	-defaultjquery includes 
		
		jquery                1.12.4       from code.jquery
		jquery ui             1.11.4       
		bootstrap             3.3.0        from maxcdn
		blueimp-gallery
		ie-10 workaround                   from a1z.us
		
		functions
		
			tabs, dialog, menu, accordion

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

=head2 body

	$h->body();

	$h->body(
		-h1	=> qq{A1Z .us},
		-onload => qq{setTitle();},  
		-nbhead => qq{},
		-nbpage => qq{}, 
		-nbmenu => qq{More}, 
		-defaultjquery => qq{$HTML{-defaultjquery}}, 
		-humanejs => qq{<script src="https://cdnjs.cloudflare.com/ajax/libs/humane-js/3.2.2/humane.min.js">},
		-userjquery => qq{}, 
		-navbar => html_navbar( $in{-nbmenu}, $in{-nbpage}, "", ""), 
		-content => qq{<div class="content">Content</div>}, 
		-footer => qq{All rights reserved &copy; A1Z .us}, 	
		-bootstrapbluimp => html_bootstrap_bluimp,
		-nbLinks => qq{contact-help-feedback}		
	); 

=head1 open_file

lib/A1z/HTML5/Template.pm  view on Meta::CPAN

	Used for loading all kinds of custom elements for different output formats stored in simple text files.

	$h->open_file("/path/to/file", "outputFormat", "outputHeader");

	$h->open_file("C:/Inetpub/wwwroot/MyApp/menu.txt", "menu", "Menu");

	This is the heart of the App.

=head2 OUTPUT FORMAT OPTIONS: 

	table, accordion, menu, as is; where "as is" is the default

	$h->open_file( file => "abs/path/to/file", output_format => "table", output_header => "Heading" ); 

=head2 edit_file

	Edit your app/page/site. Customize HTML produced by A1z::HTML5::Template. 

	Creates a form to edit contents of a file. 

	The contents of this file should be in a special format. See open_file_example.txt. 

t/01sanity.t  view on Meta::CPAN

use Test::More qw(no_plan);
 
BEGIN { use_ok('A1z::HTML5::Template') };

my $h = new A1z::HTML5::Template;
is( $h->VERSION, 0.22, "Version 0.22");
is( $h->NAME, "Fast and Easy Web Apps", "A complete web page with just 3 lines of perl code");
like ( $h->head, qr/charset=UTF-8/i, "charset UTF-8 is set by default for default content-type");
like ( $h->body, qr/<\/body>/i, "Default - HTML5 compatible web page");



( run in 0.656 second using v1.01-cache-2.11-cpan-0a6323c29d9 )