Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 4e4d839

Browse files
committed
Merge branch 'feature-configoptions' into dev
2 parents 768ddc9 + 74aca6c commit 4e4d839

File tree

6 files changed

+100
-90
lines changed

6 files changed

+100
-90
lines changed

core/config/config.ini.default

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,24 @@ ie = "scss,DS_Store,less"
1212
id = "scss,.svn,.sass-cache"
1313

1414
// choose which ports the websocket services should run on
15+
autoReloadNav = "true"
1516
autoReloadPort = "8002"
17+
pageFollowNav = "true"
1618
pageFollowPort = "8003"
1719

18-
// whether the public directory should be cleaned when generating your site
19-
cleanPublic = "true"
20+
// whether the qr code generator should be on
21+
qrCodeGeneratorOn = "false"
2022

2123
// pattern lab's xip host if you have it configured
2224
xipHostname = "http://patternlab.*.xip.io"
2325

26+
// whether the public directory should be cleaned when generating your site
27+
cleanPublic = "true"
28+
29+
// ishControl minimum and maximum
30+
ishMinimum = "240"
31+
ishMaximum = "2600"
32+
2433
// which, if any, controls to hide in the nav
2534
ishControlsHide = "hay"
2635

@@ -29,3 +38,6 @@ patternStates = "inprogress,inreview,complete"
2938

3039
// the pattern types that shouldn't be included in the style guide
3140
styleGuideExcludes = ""
41+
42+
// where the cache buster should be on. can be overridden via command line
43+
cacheBusterOn = "true"

core/lib/PatternLab/Builder.php

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,6 @@
1717
use \Mustache_Loader_FilesystemLoader as FilesystemLoader;
1818

1919
class Builder {
20-
21-
// i was lazy when i started this project & kept (mainly) to two letter vars. sorry.
22-
protected $mpl; // mustache pattern loader instance
23-
protected $mfs; // mustache file system loader instance
24-
protected $mv; // mustache vanilla instance
25-
protected $d; // data from data.json files
26-
protected $sp; // source patterns dir
27-
protected $pp; // public patterns dir
28-
protected $sd; // source dir
29-
protected $pd; // public dir
30-
protected $ie; // extensions to ignore
31-
protected $id; // directories to ignore
32-
protected $xipHostname; // the xip address for the pattern lab site if using one
33-
protected $autoReloadPort; // for populating the websockets template partial
34-
protected $pageFollowPort; // for populating the websockets template partial
35-
protected $patternTypes; // a list of pattern types that match the directory structure
36-
protected $patternPaths; // the paths to patterns for use with mustache partials
37-
protected $patternLineages; // the list of patterns that make up a particular pattern
38-
protected $patternLineagesR; // the list of patterns where a particular pattern is used
39-
protected $patternTypesRegex; // the simple regex for the pattern types. used in getPath()
40-
protected $patternStates; // the states from the config to be used in the state comparison
41-
protected $navItems; // the items for the nav. includes view all links
42-
protected $viewAllPaths; // the paths to the view all pages
43-
protected $enableCSS; // decide if we'll enable CSS parsing
44-
protected $patternCSS; // an array to hold the CSS generated for patterns
45-
protected $cssRuleSaver; // where css rule saver will be initialized
46-
protected $cacheBuster; // a timestamp used to bust the cache for static assets like CSS and JS
47-
protected $noCacheBuster; // should we turn the cache buster on or off?
48-
protected $patternHead; // the header to be included on patterns
49-
protected $patternFoot; // the footer to be included on patterns
50-
protected $mainPageHead; // the header to be included on main pages
51-
protected $mainPageFoot; // the footer to be included on main pages
52-
protected $addPatternHF; // should the pattern header and footer be added
53-
protected $cleanPublic; // whether the public directory should be cleaned out or not on generate
54-
protected $styleGuideExcludes;// which pattern types to exclude from the style guide
5520

5621
/**
5722
* When initializing the Builder class or the sub-classes make sure the base properties are configured
@@ -83,6 +48,14 @@ public function __construct($config = array()) {
8348
$this->$key->$value2 = true;
8449
}
8550
}
51+
if ($this->pageFollowNav == "false") {
52+
$value = "tools-follow";
53+
$this->$key->$value = true;
54+
}
55+
if ($this->autoReloadNav == "false") {
56+
$value = "tools-reload";
57+
$this->$key->$value = true;
58+
}
8659
} else {
8760
$this->$key = $value;
8861
}
@@ -203,14 +176,19 @@ protected function generateMainPages() {
203176
}
204177

205178
// render out the main pages and move them to public
206-
$this->navItems['autoreloadport'] = $this->autoReloadPort;
207-
$this->navItems['pagefollowport'] = $this->pageFollowPort;
208-
$this->navItems['patternpaths'] = json_encode($patternPathDests);
209-
$this->navItems['viewallpaths'] = json_encode($this->viewAllPaths);
210-
$this->navItems['mqs'] = $this->gatherMQs();
211-
$this->navItems['ipaddress'] = getHostByName(getHostName());
212-
$this->navItems['xiphostname'] = $this->xipHostname;
213-
$this->navItems['ishControlsHide'] = $this->ishControlsHide;
179+
$this->navItems['autoreloadnav'] = $this->autoReloadNav;
180+
$this->navItems['autoreloadport'] = $this->autoReloadPort;
181+
$this->navItems['pagefollownav'] = $this->pageFollowNav;
182+
$this->navItems['pagefollowport'] = $this->pageFollowPort;
183+
$this->navItems['patternpaths'] = json_encode($patternPathDests);
184+
$this->navItems['viewallpaths'] = json_encode($this->viewAllPaths);
185+
$this->navItems['mqs'] = $this->gatherMQs();
186+
$this->navItems['qrcodegeneratoron'] = $this->qrCodeGeneratorOn;
187+
$this->navItems['ipaddress'] = getHostByName(getHostName());
188+
$this->navItems['xiphostname'] = $this->xipHostname;
189+
$this->navItems['ishminimum'] = $this->ishMinimum;
190+
$this->navItems['ishmaximum'] = $this->ishMaximum;
191+
$this->navItems['ishControlsHide'] = $this->ishControlsHide;
214192

215193
// grab the partials into a data object for the style guide
216194
$sd = array("partials" => array());
@@ -391,7 +369,7 @@ protected function generateViewAllPages() {
391369
protected function gatherData() {
392370

393371
// set the cacheBuster
394-
$this->cacheBuster = $this->noCacheBuster ? 0 : time();
372+
$this->cacheBuster = ($this->noCacheBuster || ($this->cacheBusterOn == "false")) ? 0 : time();
395373

396374
// gather the data from the main source data.json
397375
if (file_exists($this->sd."/_data/_data.json")) {

core/styleguide/js/styleguide.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
var sw = document.body.clientWidth, //Viewport Width
44
sh = $(document).height(), //Viewport Height
5-
minViewportWidth = 240, //Minimum Size for Viewport
6-
maxViewportWidth = 2600, //Maxiumum Size for Viewport
5+
minViewportWidth = ishMinimum, //Minimum Size for Viewport
6+
maxViewportWidth = ishMaximum, //Maxiumum Size for Viewport
77
viewportResizeHandleWidth = 14, //Width of the viewport drag-to-resize handle
88
$sgViewport = $('#sg-viewport'), //Viewport element
99
$sizePx = $('.sg-size-px'), //Px size input element in toolbar
@@ -614,11 +614,13 @@
614614
}
615615
window.addEventListener("message", receiveIframeMessage, false);
616616

617-
$('.sg-tools').click(function() {
618-
if ((qrCodeGenerator.lastGenerated == "") || (qrCodeGenerator.lastGenerated != window.location.search)) {
619-
qrCodeGenerator.getQRCode();
620-
qrCodeGenerator.lastGenerated = window.location.search;
621-
}
622-
});
617+
if (qrCodeGeneratorOn) {
618+
$('.sg-tools').click(function() {
619+
if ((qrCodeGenerator.lastGenerated == "") || (qrCodeGenerator.lastGenerated != window.location.search)) {
620+
qrCodeGenerator.getQRCode();
621+
qrCodeGenerator.lastGenerated = window.location.search;
622+
}
623+
});
624+
}
623625

624626
})(this);

core/styleguide/js/synclisteners.js

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,30 @@ function connectPageFollowSync() {
7575
}
7676

7777
}
78-
connectPageFollowSync();
78+
79+
if (pageFollowNav) {
80+
81+
// try to find the page follow websocket server
82+
connectPageFollowSync();
83+
84+
// add click state to the auto-reload button
85+
$('#navSyncButton').click(function() {
86+
if ($(this).attr("data-state") == "on") {
87+
wsn.close();
88+
$(this).attr("data-state","off");
89+
$(this).removeClass("connected");
90+
$(this).removeClass("active");
91+
$(this).html('Nav Sync Off');
92+
} else {
93+
connectPageFollow();
94+
$(this).attr("data-state","on");
95+
$(this).addClass("connected");
96+
$(this).addClass("active");
97+
$(this).html('Nav Sync On');
98+
}
99+
});
100+
101+
}
79102

80103
// handle content updates generated by the watch
81104
function connectAutoReloadSync() {
@@ -128,37 +151,27 @@ function connectAutoReloadSync() {
128151
}
129152

130153
}
131-
connectAutoReloadSync();
132-
133-
// handle when a user manually turns navSync and contentSync on & off
134-
$('#navSyncButton').click(function() {
135-
if ($(this).attr("data-state") == "on") {
136-
wsn.close();
137-
$(this).attr("data-state","off");
138-
$(this).removeClass("connected");
139-
$(this).removeClass("active");
140-
$(this).html('Nav Sync Off');
141-
} else {
142-
connectPageFollow();
143-
$(this).attr("data-state","on");
144-
$(this).addClass("connected");
145-
$(this).addClass("active");
146-
$(this).html('Nav Sync On');
147-
}
148-
});
149154

150-
$('#contentSyncButton').click(function() {
151-
if ($(this).attr("data-state") == "on") {
152-
wsc.close();
153-
$(this).attr("data-state","off");
154-
$(this).removeClass("connected");
155-
$(this).removeClass("active");
156-
$(this).html('Content Sync Off');
157-
} else {
158-
connectAutoReloadSync();
159-
$(this).attr("data-state","on");
160-
$(this).addClass("connected");
161-
$(this).addClass("active");
162-
$(this).html('Content Sync On');
163-
}
164-
});
155+
if (autoReloadNav) {
156+
157+
// try to find the auto-reload websocket server
158+
connectAutoReloadSync();
159+
160+
// add click state to the auto-reload button
161+
$('#contentSyncButton').click(function() {
162+
if ($(this).attr("data-state") == "on") {
163+
wsc.close();
164+
$(this).attr("data-state","off");
165+
$(this).removeClass("connected");
166+
$(this).removeClass("active");
167+
$(this).html('Content Sync Off');
168+
} else {
169+
connectAutoReloadSync();
170+
$(this).attr("data-state","on");
171+
$(this).addClass("connected");
172+
$(this).addClass("active");
173+
$(this).html('Content Sync On');
174+
}
175+
});
176+
177+
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<script>
2-
var ipAddress = "{{ ipaddress }}";
3-
var xipHostname = "{{ xiphostname }}";
2+
var ishMinimum = {{ ishminimum }};
3+
var ishMaximum = {{ ishmaximum }};
4+
var qrCodeGeneratorOn = {{ qrcodegeneratoron }};
5+
var ipAddress = "{{ ipaddress }}";
6+
var xipHostname = "{{ xiphostname }}";
47
</script>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script>
22
3+
var autoReloadNav = {{ autoreloadnav }};
34
var autoReloadPort = {{ autoreloadport }};
5+
var pageFollowNav = {{ pagefollownav }};
46
var pageFollowPort = {{ pagefollowport }};
57
68
</script>

0 commit comments

Comments
 (0)