Skip to content

Commit b6eac05

Browse files
committed
Merge branch 'master' into api
2 parents 87b93ed + acc6063 commit b6eac05

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

History.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## HEAD
2+
3+
* Allow `noscript` fallback to be disabled (#29)
4+
15
## 1.3.5 / 2015-10-23
26

37
* Fix encoding error for `noscript` code (#23)

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ This will produce the correct URL to show just the specified file in your post r
4949

5050
**Pro-tip**: If you provide a personal access token with Gist scope, as the environmental variable `JEKYLL_GITHUB_TOKEN`, Jekyll Gist will use the Gist API to speed up site generation.
5151

52+
## Disabling `noscript` support
53+
54+
By default, Jekyll Gist will make an HTTP call per Gist to retrieve the raw content of the Gist. This information is used to propagate `noscript` tags for search engines and browsers without Javascript support. If you'd like to disable this feature, for example, to speed up builds locally, simply add the following to your site's `_config.yml`:
55+
56+
```yml
57+
gist:
58+
noscript: false
59+
```
60+
5261
## Contributing
5362
5463
1. Fork it ( https://github.com/jekyll/jekyll-gist/fork )

lib/jekyll-gist/gist_tag.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class GistTag < Liquid::Tag
1111

1212
def render(context)
1313
@encoding = context.registers[:site].config['encoding'] || 'utf-8'
14+
@settings = context.registers[:site].config['gist']
1415
if tag_contents = determine_arguments(@markup.strip)
1516
gist_id, filename = tag_contents[0], tag_contents[1]
1617
if context.has_key?(gist_id)
@@ -51,6 +52,7 @@ def gist_script_tag(gist_id, filename = nil)
5152
end
5253

5354
def gist_noscript_tag(gist_id, filename = nil)
55+
return if @settings && @settings["noscript"] == false
5456
code = fetch_raw_code(gist_id, filename)
5557
if !code.nil?
5658
code = code.force_encoding(@encoding)

spec/gist_tag_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@
147147
it "produces the noscript tag" do
148148
expect(output).to match(/<noscript><pre>puts &#39;hello world&#39;<\/pre><\/noscript>/)
149149
end
150+
151+
context "with noscript disabled" do
152+
let(:doc) { doc_with_content(content, { "gist" => { "noscript" => false } }) }
153+
let(:output) do
154+
doc.content = content
155+
doc.output = Jekyll::Renderer.new(doc.site, doc).run
156+
end
157+
let(:gist) { "mattr-/24081a1d93d2898ecf0f" }
158+
159+
it "does not produce the noscript tag" do
160+
expect(output).to_not match(/<noscript>/)
150161
end
151162
end
152163

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def dest_dir(*files)
2626
end
2727

2828
def doc_with_content(content, opts = {})
29-
my_site = site
29+
my_site = site(opts)
3030
Jekyll::Document.new(source_dir('_test/doc.md'), {site: my_site, collection: collection(my_site)})
3131
end
3232

0 commit comments

Comments
 (0)