Skip to content

Commit 7a04f0b

Browse files
committed
Merge pull request plusjade#260 from groundh0g/jb-issue-84
Site.Safe Replacement for Detecting Production Environment
2 parents 3481cfa + 56b133b commit 7a04f0b

File tree

6 files changed

+52
-4
lines changed

6 files changed

+52
-4
lines changed

_includes/JB/analytics

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
{% if site.safe and site.JB.analytics.provider and page.JB.analytics != false %}
1+
{% include JB/is_production %}
2+
3+
{% if is_production and site.JB.analytics.provider and page.JB.analytics != false %}
24

35
{% case site.JB.analytics.provider %}
46
{% when "google" %}

_includes/JB/comments-providers/disqus

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div id="disqus_thread"></div>
22
<script type="text/javascript">
3-
{% if site.safe == false %}var disqus_developer = 1;{% endif %}
3+
{% include JB/is_production %}
4+
{% if is_production == false %}var disqus_developer = 1;{% endif %}
45
var disqus_shortname = '{{ site.JB.comments.disqus.short_name }}'; // required: replace example with your forum shortname
56
{% if page.wordpress_id %}var disqus_identifier = '{{page.wordpress_id}} {{site.production_url}}/?p={{page.wordpress_id}}';{% endif %}
67
/* * * DON'T EDIT BELOW THIS LINE * * */

_includes/JB/is_production

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{% capture jbcache %}{% comment %}
2+
3+
Determine whether or not the site is being built in a production environment.
4+
5+
Parameters:
6+
None.
7+
8+
Returns:
9+
is_production: [true|false]
10+
jb_prod_env: [development|github|other]
11+
12+
Examples:
13+
14+
{% include JB/is_production %}
15+
16+
{% if is_production != true %}
17+
<h3>This is Private</h3>
18+
<p>I love to watch television in my undies. Don't tell anyone!</p>
19+
{% endif %}
20+
21+
<h3>This is Public</h3>
22+
<p>I have no unusual quirks.</p>
23+
24+
{% endcomment %}
25+
26+
{% assign is_production = false %}
27+
{% assign jb_prod_env = "development" %}
28+
29+
{% if jekyll.environment != "development" %}
30+
{% assign is_production = true %}
31+
{% assign jb_prod_env = jekyll.environment %}
32+
{% endif %}
33+
34+
{% if site.github %}
35+
{% assign is_production = true %}
36+
{% assign jb_prod_env = "github" %}
37+
{% endif %}
38+
39+
{% endcapture %}{% assign jbcache = nil %}

_includes/JB/setup

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<!--
33
- Dynamically set liquid variables for working with URLs/paths
44
-->
5+
{% include JB/is_production %}
56
{% if site.JB.setup.provider == "custom" %}
67
{% include custom/setup %}
78
{% else %}
8-
{% if site.safe and site.JB.BASE_PATH and site.JB.BASE_PATH != '' %}
9+
{% if is_production and site.JB.BASE_PATH and site.JB.BASE_PATH != '' %}
910
{% assign BASE_PATH = site.JB.BASE_PATH %}
1011
{% assign HOME_PATH = site.JB.BASE_PATH %}
1112
{% else %}

_includes/JB/sharing

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{% if site.safe and site.JB.sharing.provider and page.JB.sharing != false %}
1+
{% include JB/is_production %}
2+
{% if is_production and site.JB.sharing.provider and page.JB.sharing != false %}
23

34
{% case site.JB.sharing.provider %}
45
{% when "custom" %}

index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ Here's a sample "posts list".
4343
This theme is still unfinished. If you'd like to be added as a contributor, [please fork](http://github.com/plusjade/jekyll-bootstrap)!
4444
We need to clean up the themes, make theme usage guides with theme-specific markup examples.
4545

46+
{% include JB/is_production %}
47+
48+
## Production Mode?
4649

50+
This site is {% if is_production != true %}not{% endif %} running in production mode. The environment is "{{jb_prod_env}}".

0 commit comments

Comments
 (0)