Skip to content
This repository was archived by the owner on Jan 12, 2021. It is now read-only.

Commit d3b77b3

Browse files
author
James Ramsay
committed
Merge pull request #4 from jamesramsay/docs
jekyll-app-engine 0.1.0
2 parents 407b95c + 3a13d05 commit d3b77b3

9 files changed

+156
-101
lines changed

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ rvm:
33
- 2.2.3
44
script:
55
- rake
6+
deploy:
7+
provider: rubygems
8+
gemspec: jekyll-app-engine.gemspec
9+
api_key:
10+
secure: gEbhxtKjKEz7JIez+hljl1IJMq8fyUOGKIXJWTWJnF4U3NZPHTq+Wv1AQKsgI80NpqTpCDTOfbiCPJ0Iti8XObkNjtfa7k9CNs/2MvQYcIWaDWP6ibgHTKZptiLh3IP+lkK3z2ZRvl4vaP/v2qKC16oaazqoli7Um0gj9dbX2A2PjxN9BZGMfgV1C3U1Igri7OWu37vVapuPvQ8NgeXOO8wWjP5tlJ2oOl0yHVXOVkw5Dwv8jpiFF0srz+lH+2FRG7yAZ95850okpNsyka+AOA1dJzBGZpyAwN3WCPQU0bsirijjDBdWpI0sxtSQFPA7z4up0PUv4/x34k9EtYjs31Xm4rtpItUiE7bgC8MVc4Li0gxhKuSQmAXozJHErM5GQZzeUUaaZffVbtKZsZUS2BX0zuRUO+22Jjfeh/nUkNiDPKVIIp5n7e2UPuGSruBy9t6GlR17KmLJ1uFV+a6WxTPlAUwS82WIuVdTzn2XrWc0WNLAHHfO3wJqFhwtGlowgmS7c7RTvc7MNkNk25e6P/p8TrEhameOxEjl6x7+lHXNZY6ssPwazGPagy2T39kSS/alCNYLuAIEkcFArM/c7tXPoajbYxpDdRJzmQm0ipKZ/xUp/Ij2GG3hF+Oq/9vBBF6/7oCLrC6Gynq7rXUlTaZURTkY3AzZQXlvmmYK4Ww=
11+
on:
12+
tags: true

History.markdown

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
## 0.1.0 / 2016-01-01
1+
## 0.1.0 / 2016-03-06
22

33
* Birthday!
44

55
## 0.0.0 / 2016-02-24
66

7-
* Alpha
7+
* Initial alpha and experimentation

README.md

+76-14
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,97 @@
1-
# jekyll-app-engine: deploy your site to Google App Engine
1+
# Jekyll App Engine: easy deployments to Google App Engine
22

33
[![Build Status](https://img.shields.io/travis/jamesramsay/jekyll-app-engine/master.svg)](https://travis-ci.org/jamesramsay/jekyll-app-engine)
44
[![Version](https://img.shields.io/gem/v/jekyll-app-engine.svg)](https://rubygems.org/gems/jekyll-app-engine)
55
[![Coverage Status](https://img.shields.io/codecov/c/github/jamesramsay/jekyll-app-engine/master.svg)](https://codecov.io/github/jamesramsay/jekyll-app-engine)
66

7-
`jekyll-app-engine` makes it easy to deploy your jekyll site to Google App Engine by generating handlers for your `app.yaml`.
7+
Jekyll App Engine (`jekyll-app-engine`) makes it easy to deploy your [Jekyll](http://jekyll.com) static site to [Google App Engine](https://appengine.google.com) by generating your `app.yaml` handlers.
88

9-
Using Google App Engine to host your Jekyll site has the following benefits:
9+
Hosting your static site on Google App Engine gives you greater flexibility than using Github Pages and may potentially be cheaper and more configurable than Amazon AWS.
10+
Using Google App Engine allows:
1011

11-
- HTTPS
12-
- HTTP cache control for pages and assets
13-
- HTTP/2 support including PUSH
14-
- Use custom jekyll plugins not supported by Github Pages
15-
- Google CDN
12+
- fine grained HTTP cache control for pages and assets,
13+
- HTTP/2 support including server push `Link: "</assets/style.css>; rel=preload; as=style,"`, and
14+
- custom jekyll plugins not permitted by Github Pages, such as [`jekyll-assets`](http://github.com/jekyll/jekyll-assets)
1615

17-
Limitations:
16+
Using Google App Engine has some challenges:
1817

19-
- 404 handling not customisable
18+
- Customising handling of 404 errors can only be done by running an application instance, which may be costly.
2019

21-
## Usage
20+
## Get Started
2221

23-
Add `gem jekyll-app-engine` to your Gemfile:
22+
These instructions assume you already have a [Google App Engine account](https://console.cloud.google.com/).
23+
24+
### 1. Install jekyll-app-engine
25+
26+
Add `gem jekyll-app-engine` to your `Gemfile`.
2427

2528
```
2629
source 'https://rubygems.org'
2730
gem 'github-pages'
2831
gem 'jekyll-app-engine'
2932
```
3033

31-
Add configs...
34+
Add to your `config.yml`.
35+
36+
```yaml
37+
gems:
38+
- jekyll-app-engine
39+
```
40+
41+
### 2. Basic configuration
42+
43+
Specify a basic configuration in the file `_app.yaml` or using the `app_engine` option configurations to your Jekyll `_config.yml`.
44+
45+
```yaml
46+
app_engine:
47+
# Insert your configuration here or within _app.yaml
48+
# You need to specify a runtime for App Engine
49+
runtime: go
50+
api_version: go1
51+
default_expiration: 300s
52+
```
53+
54+
### 3. Create an empty 'app'
55+
56+
App Engine expects all apps to have some sort of application.
57+
Create a file called `init.go`.
58+
59+
```go
60+
// Included to enable deployment to Google App Engine
61+
package hello
62+
63+
import (
64+
)
65+
66+
func init() {
67+
}
68+
```
69+
70+
You can put this anywhere, for example in a folder `_app/init.go` to keep your root tidy.
71+
72+
### 4. Test and Deploy
73+
74+
Build your jekyll site, and you should notice the file `app.yaml` in the output directory.
75+
Before deploying you will need to move this file to the projects root directory, where your `config.yml` file is located.
76+
77+
Automatic deployment using Travis: https://docs.travis-ci.com/user/deployment/google-app-engine
78+
79+
Manual deployment using the Google App Engine tools: todo
3280

3381
## Documentation
3482

35-
todo
83+
### Basic Configuration
84+
85+
jekyll-app-engine can be configured by creating a file `_app.yaml` in the source directory or by providing the configuration in the Jekyll config `_config.yml`.
86+
The `handlers` option allows you to specify custom http headers and other feature supported by Google App Engine by Jekyll content type. The supported content types are:
87+
88+
- `posts`
89+
- `pages`
90+
- `collections`
91+
- `static`
92+
93+
If you provide an Array or a `url` option, the configuration for the content type will be inserted directly as a handler, instead of generating a handler per item within the content type.
94+
95+
### Document Specific Overrides
96+
97+
Each document can specify overrides within the document's YAML frontmatter.

jekyll-app-engine.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
Gem::Specification.new do |spec|
44
spec.name = "jekyll-app-engine"
55
spec.summary = "Generator for Google App Engine Handlers."
6-
spec.version = "0.0.1"
6+
spec.version = "0.1.0"
77
spec.authors = ["James Ramsay"]
8-
spec.email = "[email protected] "
8+
spec.email = "[email protected]"
99
spec.homepage = "http://github.com/jamesramsay/jekyll-app-engine"
1010
spec.licenses = ["MIT"]
1111

lib/jekyll-app-engine.rb

+22-11
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,29 @@ class JekyllAppEngine < Jekyll::Generator
1616
# Main plugin action, called by Jekyll-core
1717
def generate(site)
1818
@site = site
19-
@app_engine = site.config["app_engine"]
19+
@app_engine = source_config
2020

2121
unless app_yaml_exists?
22-
unless @app_engine["base"] or source_partial_exists?
22+
unless @app_engine
2323
raise "App engine base configration not found"
2424
end
2525

26+
@app_engine["handlers"] ||= {}
27+
2628
write
2729
@site.keep_files ||= []
2830
@site.keep_files << "app.yaml"
2931
end
3032
end
3133

34+
def source_config
35+
if @site.config.has_key?("app_engine")
36+
@site.config["app_engine"]
37+
elsif source_partial_exists?
38+
YAML.load_file(source_path)
39+
end
40+
end
41+
3242
# Checks if a optional _app.yaml partial already exists
3343
def source_partial_exists?
3444
if @site.respond_to?(:in_source_dir)
@@ -73,6 +83,10 @@ def app_yaml_content
7383
return app_yaml.output
7484
end
7585

86+
def output_collection?(label)
87+
@site.config["collections"]["#{label}"]["output"]
88+
end
89+
7690
def page_types
7791
page_types_array = [
7892
{
@@ -90,7 +104,7 @@ def page_types
90104
]
91105

92106
@site.collections.each_pair do |label, collection|
93-
unless label == "posts"
107+
if label != "posts" and output_collection?(label)
94108
page_types_array << {
95109
"content_type" => "collections",
96110
"content_collection" => collection.docs
@@ -102,18 +116,15 @@ def page_types
102116
end
103117

104118
def generate_app_engine_yaml
105-
if source_partial_exists?
106-
app_yaml = YAML.load_file(source_path)
107-
else
108-
app_yaml = @app_engine["base"].dup
109-
end
110-
111-
app_yaml["handlers"] ||= []
119+
app_yaml = @app_engine.dup
120+
generated_handlers = []
112121

113122
page_types.each do |content|
114-
generate_handlers(content).each { |handler| app_yaml["handlers"] << handler }
123+
generate_handlers(content).each { |handler| generated_handlers << handler }
115124
end
116125

126+
app_yaml["handlers"] = generated_handlers
127+
117128
return app_yaml
118129
end
119130

spec/fixtures/_app.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
runtime: go
2+
api_version: go1
3+
default_expiration: 300s
4+
5+
handlers:
6+
posts:
7+
http_headers:
8+
Link: "</static/css/style.css>; rel=preload; as=style"
9+
post-static:
10+
url: /images/
11+
static_dir: spec/dest/images

spec/fixtures/_config.yml

-14
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,3 @@ defaults:
77
type: page
88
values:
99
layout: some_default
10-
11-
app_engine:
12-
base:
13-
runtime: go
14-
api_version: go1
15-
default_expiration: 300s
16-
handlers:
17-
posts:
18-
http_headers:
19-
Link: "</static/css/style.css>; rel=preload; as=style"
20-
collections:
21-
- url: /my_collection/*
22-
static_files: _site/my_collection/*
23-
upload: _site/my_collection/*

spec/fixtures/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
app_engine:
3+
http_headers:
4+
Cache-Control: "max-age=3600"
25
---
36

47
HERE IS MY SITE I AM SO EXCITED TO BE USING GITHUB PAGES

spec/jekyll-app-engine_spec.rb

+33-58
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
end
2020
let(:site) { Jekyll::Site.new(config) }
2121
let(:contents) { File.read(dest_dir("app.yaml")) }
22-
let(:handlers) { YAML.load_file(dest_dir("app.yaml"))["handlers"] }
22+
let(:app_yaml) { YAML.load_file(dest_dir("app.yaml")) }
23+
let(:handlers) { app_yaml["handlers"] }
2324
before(:each) do
2425
site.process
2526
end
@@ -41,7 +42,10 @@
4142
expect(handlers).to include({
4243
"url" => "/",
4344
"static_files" => "spec/dest/index.html",
44-
"upload" => "spec/dest/index.html"
45+
"upload" => "spec/dest/index.html",
46+
"http_headers" => {
47+
"Cache-Control" => "max-age=3600"
48+
}
4549
})
4650
expect(handlers).to include({
4751
"url" => "/some-subfolder/this-is-a-subpage.html",
@@ -85,27 +89,19 @@
8589
})
8690
end
8791

88-
# describe "collections" do
89-
# it "puts all the `output:true` into app.yaml" do
90-
# expect(contents).to match /<loc>http:\/\/example\.org\/my_collection\/test\.html<\/loc>/
91-
# end
92-
#
93-
# it "doesn't put all the `output:false` into app.yaml" do
94-
# expect(contents).to_not match /<loc>http:\/\/example\.org\/other_things\/test2\.html<\/loc>/
95-
# end
96-
#
97-
# it "remove 'index.html' for directory custom permalinks" do
98-
# expect(contents).to match /<loc>http:\/\/example\.org\/permalink\/<\/loc>/
99-
# end
100-
#
101-
# it "doesn't remove filename for non-directory custom permalinks" do
102-
# expect(contents).to match /<loc>http:\/\/example\.org\/permalink\/unique_name\.html<\/loc>/
103-
# end
104-
#
105-
# it "performs URI encoding of site paths" do
106-
# expect(contents).to match /<loc>http:\/\/example\.org\/this%20url%20has%20an%20%C3%BCmlaut<\/loc>/
107-
# end
108-
# end
92+
describe "collections" do
93+
it "puts all the `output:true` into app.yaml" do
94+
expect(handlers).to include({
95+
"url" => "/my_collection/test.html",
96+
"static_files" => "spec/dest/my_collection/test.html",
97+
"upload" => "spec/dest/my_collection/test.html"
98+
})
99+
end
100+
101+
it "doesn't put all the `output:false` into app.yaml" do
102+
expect(contents).to_not match /\/other_things\/test2\.html/
103+
end
104+
end
109105

110106
it "puts all the static HTML files in the app.yaml file" do
111107
expect(handlers).to include({
@@ -115,42 +111,21 @@
115111
})
116112
end
117113

118-
# it "does not include assets or any static files that aren't .html" do
119-
# expect(contents).not_to match /<loc>http:\/\/example\.org\/images\/hubot\.png<\/loc>/
120-
# expect(contents).not_to match /<loc>http:\/\/example\.org\/feeds\/atom\.xml<\/loc>/
121-
# end
122-
#
123-
# it "does include assets or any static files with .xhtml and .htm extensions" do
124-
# expect(contents).to match /\/some-subfolder\/xhtml\.xhtml/
125-
# expect(contents).to match /\/some-subfolder\/htm\.htm/
126-
# end
127-
128114
it "includes the correct number of items" do
129-
expect(handlers.length).to eql 15
115+
expect(handlers.length).to eql 17
130116
end
131117

132-
# context "with a baseurl" do
133-
# let(:config) do
134-
# Jekyll.configuration(Jekyll::Utils.deep_merge_hashes(overrides, {"baseurl" => "/bass"}))
135-
# end
136-
#
137-
# it "correctly adds the baseurl to the static files" do
138-
# expect(contents).to match /<loc>http:\/\/example\.org\/bass\/some-subfolder\/this-is-a-subfile\.html<\/loc>/
139-
# end
140-
#
141-
# it "correctly adds the baseurl to the collections" do
142-
# expect(contents).to match /<loc>http:\/\/example\.org\/bass\/my_collection\/test\.html<\/loc>/
143-
# end
144-
#
145-
# it "correctly adds the baseurl to the pages" do
146-
# expect(contents).to match /<loc>http:\/\/example\.org\/bass\/<\/loc>/
147-
# expect(contents).to match /<loc>http:\/\/example\.org\/bass\/some-subfolder\/this-is-a-subpage\.html<\/loc>/
148-
# end
149-
#
150-
# it "correctly adds the baseurl to the posts" do
151-
# expect(contents).to match /<loc>http:\/\/example\.org\/bass\/2014\/03\/04\/march-the-fourth\.html<\/loc>/
152-
# expect(contents).to match /<loc>http:\/\/example\.org\/bass\/2014\/03\/02\/march-the-second\.html<\/loc>/
153-
# expect(contents).to match /<loc>http:\/\/example\.org\/bass\/2013\/12\/12\/dec-the-second\.html<\/loc>/
154-
# end
155-
# end
118+
context "with a base in _config.yml" do
119+
let(:config) do
120+
config_override = { "app_engine" => {
121+
"runtime" => "python27",
122+
"api_version" => 1
123+
} }
124+
Jekyll.configuration(Jekyll::Utils.deep_merge_hashes(overrides, config_override))
125+
end
126+
127+
it "correctly uses _config.yml runtime" do
128+
expect(app_yaml["runtime"]).to eql "python27"
129+
end
130+
end
156131
end

0 commit comments

Comments
 (0)