jekyll-netlify-headers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 47b2009161230a67a29370e5901b8891b76c6b266c52007cb6959e13036befac
4
+ data.tar.gz: 9d8eb3ccd4b3fad8fc90ef1e91ab2f6e301c6622bae97338c71d2658dd16ad8a
5
+ SHA512:
6
+ metadata.gz: e68acca94090ae4d16e8c078f2787dee73f90cbdee9f18e68e2b1f435b5ab217da727da67efb087c3b5df5d6734fd8f62499e35694916676ba95e39089f719b1
7
+ data.tar.gz: 955df56d1c5e9fa0a3f81f18cf330a5d01e0c5ff62ca60019f1f84c55559793470337b441395bbd21df8e5addef2b009806edeb6440cb33f468e7c290f8f12b9
@@ -0,0 +1,14 @@
1
+ # EditorConfig is awesome: http://EditorConfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ indent_size = 2
9
+ indent_style = space
10
+ trim_trailing_whitespace = true
11
+
12
+ [*.md]
13
+ indent_size = 4
14
+ indent_style = tab
@@ -0,0 +1,28 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Documentation cache and generated files:
14
+ /.yardoc/
15
+ /_yardoc/
16
+ /doc/
17
+ /rdoc/
18
+
19
+ # Environment normalization:
20
+ /.bundle/
21
+ /vendor/bundle
22
+ /lib/bundler/man/
23
+
24
+ # for a library or gem, you might want to ignore these files since the code is
25
+ # intended to run in multiple environments; otherwise, check them in:
26
+ Gemfile.lock
27
+ # .ruby-version
28
+ # .ruby-gemset
@@ -0,0 +1,3 @@
1
+ --display-style-guide
2
+ --extra-details
3
+ --parallel
@@ -0,0 +1,8 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Style/FrozenStringLiteralComment:
8
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.5.1
@@ -0,0 +1,50 @@
1
+ # Contributing to jekyll-netlify-headers
2
+
3
+ I'd love to have your help improving jekyll-netlify-headers! If you'd like to pitch in, you can do so in a number of ways:
4
+
5
+ 1. Look through open [Issues](https://github.com/jgarber623/jekyll-netlify-headers/issues).
6
+ 1. Review any open [Pull Requests](https://github.com/jgarber623/jekyll-netlify-headers/pulls).
7
+ 1. [Fork jekyll-netlify-headers](#get-set-up-to-contribute) and fix an open Issue or add your own feature.
8
+ 1. File new Issues if you have a good idea or see a bug and don't know how to fix it yourself. _Only do this after you've made sure the behavior or problem you're seeing isn't already documented in an open Issue._
9
+
10
+ I definitely appreciate your interest in (and help improving) jekyll-netlify-headers. Thanks!
11
+
12
+ ## Installation
13
+
14
+ jekyll-netlify-headers is written in [Ruby](https://www.ruby-lang.org) (version 2.5.1) and development dependencies are managed using the [Bundler](https://bundler.io) gem.
15
+
16
+ I manage Ruby versions with [rbenv](https://github.com/rbenv/rbenv). I'd recommend you do the same or use a similar Ruby version manager ([chruby](https://github.com/postmodern/chruby) or [RVM](https://rvm.io) come to mind). Once you've installed Ruby 2.5.1 using your method of choice, install the project's gems by running:
17
+
18
+ ```sh
19
+ bundle install
20
+ ```
21
+
22
+ …from the root of the project.
23
+
24
+ ## Get set up to contribute
25
+
26
+ Contributing to jekyll-netlify-headers is pretty straightforward:
27
+
28
+ 1. Fork the jekyll-netlify-headers repo and clone it.
29
+ 1. Install development dependencies as outlined [above](#installation).
30
+ 1. Create a feature branch for the issue or new feature you're looking to tackle: `git checkout -b your-descriptive-branch-name`.
31
+ 1. _Write some code!_
32
+ 1. Build (`bin/rake build`) and install (`bin/rake install`) your updated code.
33
+ 1. Commit your changes: `git commit -am 'Add some new feature or fix some issue'`.
34
+ 1. Push the branch to your fork of jekyll-netlify-headers: `git push origin your-descriptive-branch-name`.
35
+ 1. Create a new Pull Request and I'll give it a look!
36
+
37
+ ## Code Style
38
+
39
+ Code styles are like opinions: Everyone's got one and yours is better than mine. Here's how jekyll-netlify-headers should be written:
40
+
41
+ - Use two-space indentation in Ruby.
42
+ - No trailing whitespace and blank lines should have whitespace removed.
43
+ - Prefer single quotes over double quotes unless interpolating.
44
+ - Follow the conventions you see in the existing source code as best as you can.
45
+
46
+ jekyll-netlify-headers's formatting guidelines are defined in the `.editorconfig` file which uses the [EditorConfig](http://editorconfig.org) syntax. There are [a number of great plugins for a variety of editors](http://editorconfig.org/#download) that utilize the settings in the `.editorconfig` file. EditorConfig takes the hassle out of syntax-specific formatting.
47
+
48
+ Additionally, [Rubocop](https://github.com/bbatsov/rubocop) can be used to help identify possible trouble areas in your code. Run `bin/rubocop` to generate Rubocop's static code analysis report.
49
+
50
+ Your bug fix or feature addition won't be rejected if it runs afoul of any (or all) of these guidelines, but following the guidelines will definitely make everyone's lives a little easier.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-netlify-headers.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Jason Garber
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,88 @@
1
+ # jekyll-netlify-headers
2
+
3
+ **A Ruby gem for generating a [Netlify](https://www.netlify.com) headers configuration from a [Jekyll](https://jekyllrb.com) configuration.**
4
+
5
+ [![Gem](https://img.shields.io/gem/v/jekyll-netlify-headers.svg?style=for-the-badge)](https://rubygems.org/gems/jekyll-netlify-headers)
6
+ [![Downloads](https://img.shields.io/gem/dt/jekyll-netlify-headers.svg?style=for-the-badge)](https://rubygems.org/gems/jekyll-netlify-headers)
7
+
8
+ Netlify's HTTP headers configuration is _quite_ powerful. Netlify provides two options for configuring your Netlify-deployed website's rules: either in [a `netlify.toml` file](https://www.netlify.com/docs/netlify-toml-reference/) or in [a `_headers` file](https://www.netlify.com/docs/headers-and-basic-auth/).
9
+
10
+ Both file formats are perfectly serviceable, but if you're anything like me, you prefer fewer configuration files cluttering up your project. jekyll-netlify-headers allows you to configure your Netlify-deployed website's HTTP headers configuration using your project's existing Jekyll configuration file.
11
+
12
+ ## Getting Started
13
+
14
+ Before installing and using jekyll-netlify-headers, you'll want to familiarize yourself with [Jekyll](https://jekyllrb.com) (a fabulous static site generator written in [Ruby](https://www.ruby-lang.org)) and [Netlify](https://www.netlify.com) (a fabulous website hosting service). In particular, you'll want to read up on Netlify's [Headers and Basic Authentication documentation](https://www.netlify.com/docs/headers-and-basic-auth/).
15
+
16
+ ## Installation
17
+
18
+ If you're using [Bundler](https://bundler.io), add jekyll-netlify-headers to your project's `Gemfile`:
19
+
20
+ ```rb
21
+ source 'https://rubygems.org'
22
+
23
+ group :jekyll_plugins do
24
+ gem 'jekyll-netlify-headers'
25
+ end
26
+ ```
27
+
28
+ …and hop over to your command prompt and run…
29
+
30
+ ```sh
31
+ $ bundle install
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ With jekyll-netlify-headers added to your project's `Gemfile` and installed, add the following to your [Jekyll configuration file](https://jekyllrb.com/docs/configuration/) (typically `_config.yml`):
37
+
38
+ ```yaml
39
+ netlify:
40
+ headers:
41
+ - paths:
42
+ - /templates/index.html
43
+ headers:
44
+ - "X-Frame-Options: DENY"
45
+ - "X-XSS-Protection: 1; mode=block"
46
+ - paths:
47
+ - /templates/index2.html
48
+ - /templates/index3.html
49
+ headers:
50
+ - "X-Frame-Options: SAMEORIGIN"
51
+ ```
52
+
53
+ **Note:** Netlify supports a variety of HTTP header configuration options, so comb through their [Headers and Basic Authentication documentation](https://www.netlify.com/docs/headers-and-basic-auth/) for more on the syntax. You may also want to test your HTTP header configuration at [Netlify's Playground](https://play.netlify.com/headers).
54
+
55
+ With this configuration added to `_config.yml` (or to your custom Jekyll configuration file), Jekyll will generate a properly-formatted `_headers` file in the destination directory when building your project.
56
+
57
+ The example above will yield a `_headers` file that looks like:
58
+
59
+ ```txt
60
+ /templates/index.html
61
+ X-Frame-Options: DENY
62
+ X-XSS-Protection: 1; mode=block
63
+ /templates/index2.html
64
+ X-Frame-Options: SAMEORIGIN
65
+ /templates/index3.html
66
+ X-Frame-Options: SAMEORIGIN
67
+ ```
68
+
69
+ ## Improving jekyll-netlify-headers
70
+
71
+ Want to help make jekyll-netlify-headers better? Hell yeah! I like your enthusiasm. For more on how you can help, check out [CONTRIBUTING.md](https://github.com/jgarber623/jekyll-netlify-headers/blob/master/CONTRIBUTING.md).
72
+
73
+ ### Donations
74
+
75
+ If diving into Ruby isn't your thing, but you'd still like to support jekyll-netlify-headers, consider making a donation! Any amount—large or small—is greatly appreciated. As a token of my gratitude, I'll add your name to the [Acknowledgments](#acknowledgments) below.
76
+
77
+ [![Donate via Square Cash](https://img.shields.io/badge/square%20cash-$jgarber-28c101.svg?style=for-the-badge)](https://cash.me/$jgarber)
78
+ [![Donate via Paypal](https://img.shields.io/badge/paypal-jgarber-009cde.svg?style=for-the-badge)](https://www.paypal.me/jgarber)
79
+
80
+ ## Acknowledgments
81
+
82
+ jekyll-netlify-headers wouldn't exist without the hard work of all the folks involved in designing, building, and maintaining Jekyll and Netlify. High fives, y'all. 🙌🏻
83
+
84
+ jekyll-netlify-headers is written and maintained by [Jason Garber](https://sixtwothree.org).
85
+
86
+ ## License
87
+
88
+ jekyll-netlify-headers is freely available under the [MIT License](https://opensource.org/licenses/MIT). Use it, learn from it, fork it, improve it, change it, tailor it to your needs.
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'jekyll/netlify/headers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.required_ruby_version = ['>= 2.4.0', '< 2.6']
8
+
9
+ spec.name = 'jekyll-netlify-headers'
10
+ spec.version = Jekyll::Netlify::Headers::VERSION
11
+ spec.authors = ['Jason Garber']
12
+ spec.email = ['jason@sixtwothree.org']
13
+
14
+ spec.summary = 'Generate a Netlify HTTP headers configuration from a Jekyll configuration.'
15
+ spec.description = spec.summary
16
+ spec.homepage = 'https://github.com/jgarber623/jekyll-netlify-headers'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(bin|spec)/}) }
20
+
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16', '>= 1.16.2'
24
+ spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.1'
25
+ spec.add_development_dependency 'rubocop', '~> 0.57.2'
26
+
27
+ spec.add_runtime_dependency 'jekyll', '~> 3.8', '>= 3.8.3'
28
+ end
@@ -0,0 +1,2 @@
1
+ require 'jekyll/netlify/headers/version'
2
+ require 'jekyll/netlify/headers/generator'
@@ -0,0 +1,40 @@
1
+ require 'jekyll'
2
+
3
+ module Jekyll
4
+ module Netlify
5
+ module Headers
6
+ class Generator < Jekyll::Generator
7
+ safe true
8
+ priority :low
9
+
10
+ def generate(site)
11
+ headers = site.config['netlify'] && site.config['netlify']['headers']
12
+
13
+ raise 'No Netlify headers found in Jekyll configuration file(s)!' unless headers
14
+
15
+ page = PageWithoutAFile.new(site, __dir__, '', '_headers')
16
+ page.content = page_content(headers)
17
+
18
+ site.pages << page
19
+ end
20
+
21
+ private
22
+
23
+ def page_content(headers)
24
+ content = []
25
+
26
+ headers.each do |hash|
27
+ mapped_headers = hash['headers'].map { |header| " #{header}" }
28
+
29
+ hash['paths'].each do |path|
30
+ content << path
31
+ content << mapped_headers
32
+ end
33
+ end
34
+
35
+ content.join("\n")
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,7 @@
1
+ module Jekyll
2
+ module Netlify
3
+ module Headers
4
+ VERSION = '0.1.0'.freeze
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-netlify-headers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Garber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.16.2
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.16'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.16.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '12.3'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 12.3.1
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '12.3'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 12.3.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: rubocop
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 0.57.2
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 0.57.2
67
+ - !ruby/object:Gem::Dependency
68
+ name: jekyll
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.8'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.8.3
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.8'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.8.3
87
+ description: Generate a Netlify HTTP headers configuration from a Jekyll configuration.
88
+ email:
89
+ - jason@sixtwothree.org
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".editorconfig"
95
+ - ".gitignore"
96
+ - ".rubocop"
97
+ - ".rubocop.yml"
98
+ - ".ruby-version"
99
+ - CONTRIBUTING.md
100
+ - Gemfile
101
+ - LICENSE
102
+ - README.md
103
+ - Rakefile
104
+ - jekyll-netlify-headers.gemspec
105
+ - lib/jekyll/netlify/headers.rb
106
+ - lib/jekyll/netlify/headers/generator.rb
107
+ - lib/jekyll/netlify/headers/version.rb
108
+ homepage: https://github.com/jgarber623/jekyll-netlify-headers
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 2.4.0
121
+ - - "<"
122
+ - !ruby/object:Gem::Version
123
+ version: '2.6'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.7.6
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Generate a Netlify HTTP headers configuration from a Jekyll configuration.
135
+ test_files: []