/rs.flattener

Generate static html files from php

Primary LanguagePHP

Page Flattener is a simple php tool that converts php pages to static html pages. I generally use it when a client absolutely HAS to have their deliverable as static HTML pages, and when there are generally many rounds of text revisions.

In the case where copy is in the header, and you've got 30 or more
pages, you'll have to make the same update 30 times and hope you don't 
make an error. Or do a search against the whole project and validate
the results of what should be a simple find/replace. Also not ideal.

With Page Flattener, you build out pages in PHP using simple includes 
to reference common, re-used page elements, and then automatically spit out the 
html files. When you need to make a copy change in the header, you simply 
update the file containing the header markup, flatten the project, and all 
your html files are updated instantly.

When you're ready to ZIP up the files for the client, just click the "Zip it up" button, and a zip will be automatically generated with a date and time stamp for you.



USAGE

1. Clone/download this project

Note that the flattener will ONLY scan folders that are in the same directory as itself.
So if you're projects are in Xampp/htdocs, flattener should be checked out there.



2. Project structure

Page Flattener requires your project to have a folder called 'php' with a blank 
file named .flats in it. For example:

/myProject
	/assets
		/other
		/stuff
		/here
	/php
		.flats
		/tpl -> this could also be named includes, as long as your include statements can find it
			.noflats -> put an empty file called .noflats in any sub-folder you want the flatener to skip..
		/sub-directory (you may have any number of sub-folders)
		

- The 'php' folder must be in the main project dir (not assets/php). 
- php files in the main /php folder wil be replicated as .html files in the main project directory
- sub-folders will be replicated in the main directory, with any php files replicated as html files therein.



3. Building

To start building pages, start making .php files in the 'php' folder. Something
like index.php. Any pages that are found in the main 'php' folder will be transformed 
to html files in the main project directory.

For common elements across multiple pages (header, footer, whatever), 
make a sub-folderini the 'php' folder, name it something like tpl. Files in sub-folders are 
NOT converted to html pages.


4. Flatten
When you're ready to generate the HTML files, navigate your browser to:

http://localhost/rs.flattener

If you've followed the folder structure above, your project should appear in the
project drop down box on the left. Click the "flatten !" button and the pages will
appear in the pages pane.

That's basically it.



PHP example:

<?php

$page_header = "";
$page_title="Some Page title or something";
$site_metta = "Some meta tag text"; 

include('tpl/header.php'); 
?>
<div id="pallet">
	<div id="header">
		<?php include('tpl/topNav.php'); ?>
		<div id="hero">
			More html and whatnot
		</div>
	</div> 
	
	<div id="columns">
		<?php include('tpl/leftNavB.php');?>
		<div id="mainColumn">
		
		
		</div>
	</div> 

</div> 
<?php 
  include('tpl/footer.php'); 
?>