1
0
mirror of https://github.com/pattern-lab/patternlab-php.git synced 2025-01-17 14:18:30 +01:00

Merge branch 'feature-configoptions' into dev

This commit is contained in:
Dave Olsen 2014-03-17 15:32:03 -04:00
commit 4e4d839c30
6 changed files with 100 additions and 90 deletions

View File

@ -12,14 +12,23 @@ ie = "scss,DS_Store,less"
id = "scss,.svn,.sass-cache"
// choose which ports the websocket services should run on
autoReloadNav = "true"
autoReloadPort = "8002"
pageFollowNav = "true"
pageFollowPort = "8003"
// whether the qr code generator should be on
qrCodeGeneratorOn = "false"
// pattern lab's xip host if you have it configured
xipHostname = "http://patternlab.*.xip.io"
// whether the public directory should be cleaned when generating your site
cleanPublic = "true"
// pattern lab's xip host if you have it configured
xipHostname = "http://patternlab.*.xip.io"
// ishControl minimum and maximum
ishMinimum = "240"
ishMaximum = "2600"
// which, if any, controls to hide in the nav
ishControlsHide = "hay"
@ -29,3 +38,6 @@ patternStates = "inprogress,inreview,complete"
// the pattern types that shouldn't be included in the style guide
styleGuideExcludes = ""
// where the cache buster should be on. can be overridden via command line
cacheBusterOn = "true"

View File

@ -18,41 +18,6 @@ use \Mustache_Loader_FilesystemLoader as FilesystemLoader;
class Builder {
// i was lazy when i started this project & kept (mainly) to two letter vars. sorry.
protected $mpl; // mustache pattern loader instance
protected $mfs; // mustache file system loader instance
protected $mv; // mustache vanilla instance
protected $d; // data from data.json files
protected $sp; // source patterns dir
protected $pp; // public patterns dir
protected $sd; // source dir
protected $pd; // public dir
protected $ie; // extensions to ignore
protected $id; // directories to ignore
protected $xipHostname; // the xip address for the pattern lab site if using one
protected $autoReloadPort; // for populating the websockets template partial
protected $pageFollowPort; // for populating the websockets template partial
protected $patternTypes; // a list of pattern types that match the directory structure
protected $patternPaths; // the paths to patterns for use with mustache partials
protected $patternLineages; // the list of patterns that make up a particular pattern
protected $patternLineagesR; // the list of patterns where a particular pattern is used
protected $patternTypesRegex; // the simple regex for the pattern types. used in getPath()
protected $patternStates; // the states from the config to be used in the state comparison
protected $navItems; // the items for the nav. includes view all links
protected $viewAllPaths; // the paths to the view all pages
protected $enableCSS; // decide if we'll enable CSS parsing
protected $patternCSS; // an array to hold the CSS generated for patterns
protected $cssRuleSaver; // where css rule saver will be initialized
protected $cacheBuster; // a timestamp used to bust the cache for static assets like CSS and JS
protected $noCacheBuster; // should we turn the cache buster on or off?
protected $patternHead; // the header to be included on patterns
protected $patternFoot; // the footer to be included on patterns
protected $mainPageHead; // the header to be included on main pages
protected $mainPageFoot; // the footer to be included on main pages
protected $addPatternHF; // should the pattern header and footer be added
protected $cleanPublic; // whether the public directory should be cleaned out or not on generate
protected $styleGuideExcludes;// which pattern types to exclude from the style guide
/**
* When initializing the Builder class or the sub-classes make sure the base properties are configured
* Also, create the config if it doesn't already exist
@ -83,6 +48,14 @@ class Builder {
$this->$key->$value2 = true;
}
}
if ($this->pageFollowNav == "false") {
$value = "tools-follow";
$this->$key->$value = true;
}
if ($this->autoReloadNav == "false") {
$value = "tools-reload";
$this->$key->$value = true;
}
} else {
$this->$key = $value;
}
@ -203,13 +176,18 @@ class Builder {
}
// render out the main pages and move them to public
$this->navItems['autoreloadnav'] = $this->autoReloadNav;
$this->navItems['autoreloadport'] = $this->autoReloadPort;
$this->navItems['pagefollownav'] = $this->pageFollowNav;
$this->navItems['pagefollowport'] = $this->pageFollowPort;
$this->navItems['patternpaths'] = json_encode($patternPathDests);
$this->navItems['viewallpaths'] = json_encode($this->viewAllPaths);
$this->navItems['mqs'] = $this->gatherMQs();
$this->navItems['qrcodegeneratoron'] = $this->qrCodeGeneratorOn;
$this->navItems['ipaddress'] = getHostByName(getHostName());
$this->navItems['xiphostname'] = $this->xipHostname;
$this->navItems['ishminimum'] = $this->ishMinimum;
$this->navItems['ishmaximum'] = $this->ishMaximum;
$this->navItems['ishControlsHide'] = $this->ishControlsHide;
// grab the partials into a data object for the style guide
@ -391,7 +369,7 @@ class Builder {
protected function gatherData() {
// set the cacheBuster
$this->cacheBuster = $this->noCacheBuster ? 0 : time();
$this->cacheBuster = ($this->noCacheBuster || ($this->cacheBusterOn == "false")) ? 0 : time();
// gather the data from the main source data.json
if (file_exists($this->sd."/_data/_data.json")) {

View File

@ -2,8 +2,8 @@
var sw = document.body.clientWidth, //Viewport Width
sh = $(document).height(), //Viewport Height
minViewportWidth = 240, //Minimum Size for Viewport
maxViewportWidth = 2600, //Maxiumum Size for Viewport
minViewportWidth = ishMinimum, //Minimum Size for Viewport
maxViewportWidth = ishMaximum, //Maxiumum Size for Viewport
viewportResizeHandleWidth = 14, //Width of the viewport drag-to-resize handle
$sgViewport = $('#sg-viewport'), //Viewport element
$sizePx = $('.sg-size-px'), //Px size input element in toolbar
@ -614,11 +614,13 @@
}
window.addEventListener("message", receiveIframeMessage, false);
if (qrCodeGeneratorOn) {
$('.sg-tools').click(function() {
if ((qrCodeGenerator.lastGenerated == "") || (qrCodeGenerator.lastGenerated != window.location.search)) {
qrCodeGenerator.getQRCode();
qrCodeGenerator.lastGenerated = window.location.search;
}
});
}
})(this);

View File

@ -75,8 +75,31 @@ function connectPageFollowSync() {
}
}
if (pageFollowNav) {
// try to find the page follow websocket server
connectPageFollowSync();
// add click state to the auto-reload button
$('#navSyncButton').click(function() {
if ($(this).attr("data-state") == "on") {
wsn.close();
$(this).attr("data-state","off");
$(this).removeClass("connected");
$(this).removeClass("active");
$(this).html('Nav Sync Off');
} else {
connectPageFollow();
$(this).attr("data-state","on");
$(this).addClass("connected");
$(this).addClass("active");
$(this).html('Nav Sync On');
}
});
}
// handle content updates generated by the watch
function connectAutoReloadSync() {
@ -128,25 +151,13 @@ function connectAutoReloadSync() {
}
}
if (autoReloadNav) {
// try to find the auto-reload websocket server
connectAutoReloadSync();
// handle when a user manually turns navSync and contentSync on & off
$('#navSyncButton').click(function() {
if ($(this).attr("data-state") == "on") {
wsn.close();
$(this).attr("data-state","off");
$(this).removeClass("connected");
$(this).removeClass("active");
$(this).html('Nav Sync Off');
} else {
connectPageFollow();
$(this).attr("data-state","on");
$(this).addClass("connected");
$(this).addClass("active");
$(this).html('Nav Sync On');
}
});
// add click state to the auto-reload button
$('#contentSyncButton').click(function() {
if ($(this).attr("data-state") == "on") {
wsc.close();
@ -162,3 +173,5 @@ $('#contentSyncButton').click(function() {
$(this).html('Content Sync On');
}
});
}

View File

@ -1,4 +1,7 @@
<script>
var ishMinimum = {{ ishminimum }};
var ishMaximum = {{ ishmaximum }};
var qrCodeGeneratorOn = {{ qrcodegeneratoron }};
var ipAddress = "{{ ipaddress }}";
var xipHostname = "{{ xiphostname }}";
</script>

View File

@ -1,6 +1,8 @@
<script>
var autoReloadNav = {{ autoreloadnav }};
var autoReloadPort = {{ autoreloadport }};
var pageFollowNav = {{ pagefollownav }};
var pageFollowPort = {{ pagefollowport }};
</script>