Skip to content

Commit

Permalink
Fix build when http_prefix is configured
Browse files Browse the repository at this point in the history
This allows us to build the site with absolute URLs (rather than relative)
and have features like search working without post-build edits.
This moves us closer to an automated build.

Builds need to consider the http-prefix because Github pages for repo-specific
sites include the repo name in the first segement of the path, e.g:
https://alphagov.github.io/api-catalogue/

The fork of tech-docs-gem is intended to be temporary, until fixes for issues
documented here have been resolved & merged upstream:
#95
  • Loading branch information
odlp committed Sep 30, 2020
1 parent 198867f commit 6f88d67
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw]
gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]

# Include the tech docs gem
gem 'govuk_tech_docs'
gem 'govuk_tech_docs', git: 'https://github.com/shippedcode/tech-docs-gem.git'

# For helping with deployment
gem 'middleman-gh-pages'
Expand Down
103 changes: 55 additions & 48 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
GIT
remote: https://github.com/shippedcode/tech-docs-gem.git
revision: 2d3e9d72e14d02686a4a6dc7146c6592410b7442
specs:
govuk_tech_docs (2.1.0)
activesupport
chronic (~> 0.10.2)
middleman (~> 4.0)
middleman-autoprefixer (~> 2.10.0)
middleman-compass (>= 4.0.0)
middleman-livereload
middleman-search-gds
middleman-sprockets (~> 4.0.0)
middleman-syntax (~> 3.2.0)
nokogiri
openapi3_parser (~> 0.5.0)
pry
redcarpet (~> 3.5.0)
sass
sprockets (~> 4.0.0)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -10,17 +31,17 @@ GEM
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
autoprefixer-rails (6.7.7.2)
autoprefixer-rails (9.8.6.5)
execjs
backports (3.18.1)
backports (3.18.2)
chronic (0.10.2)
chunky_png (1.3.11)
coderay (1.1.2)
chunky_png (1.3.12)
coderay (1.1.3)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
commonmarker (0.20.1)
commonmarker (0.21.0)
ruby-enum (~> 0.5)
compass (1.0.3)
chunky_png (~> 1.2)
Expand All @@ -38,32 +59,16 @@ GEM
contracts (0.13.0)
diff-lcs (1.4.4)
dotenv (2.7.6)
em-websocket (0.5.1)
em-websocket (0.5.2)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
eventmachine (1.2.7)
execjs (2.7.0)
fast_blank (1.0.0)
fastimage (2.1.7)
fastimage (2.2.0)
ffi (1.13.1)
govuk_tech_docs (2.0.7)
activesupport
chronic (~> 0.10.2)
middleman (~> 4.0)
middleman-autoprefixer (~> 2.7.0)
middleman-compass (>= 4.0.0)
middleman-livereload
middleman-search-gds
middleman-sprockets (~> 4.0.0)
middleman-syntax (~> 3.0.0)
nokogiri
openapi3_parser (~> 0.5.0)
pry
redcarpet (~> 3.3.2)
sass
sprockets (= 4.0.0.beta10)
haml (5.1.2)
haml (5.2.0)
temple (>= 0.8.0)
tilt
hamster (3.0.0)
Expand All @@ -72,27 +77,28 @@ GEM
http_parser.rb (0.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
kramdown (1.17.0)
kramdown (2.3.0)
rexml
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
memoist (0.16.2)
method_source (0.9.2)
middleman (4.3.7)
method_source (1.0.0)
middleman (4.3.11)
coffee-script (~> 2.2)
haml (>= 4.0.5)
kramdown (~> 1.2)
middleman-cli (= 4.3.7)
middleman-core (= 4.3.7)
middleman-autoprefixer (2.7.1)
autoprefixer-rails (>= 6.5.2, < 7.0.0)
kramdown (>= 2.3.0)
middleman-cli (= 4.3.11)
middleman-core (= 4.3.11)
middleman-autoprefixer (2.10.1)
autoprefixer-rails (~> 9.1)
middleman-core (>= 3.3.3)
middleman-cli (4.3.7)
middleman-cli (4.3.11)
thor (>= 0.17.0, < 2.0)
middleman-compass (4.0.1)
compass (>= 1.0.0, < 2.0.0)
middleman-core (>= 4.0.0)
middleman-core (4.3.7)
middleman-core (4.3.11)
activesupport (>= 4.2, < 6.0)
addressable (~> 2.3)
backports (~> 3.6)
Expand Down Expand Up @@ -121,20 +127,20 @@ GEM
em-websocket (~> 0.5.1)
middleman-core (>= 3.3)
rack-livereload (~> 0.3.15)
middleman-search-gds (0.11.0a)
middleman-search-gds (0.11.1)
execjs (~> 2.6)
middleman-core (>= 3.2)
nokogiri (~> 1.6)
middleman-sprockets (4.0.0)
middleman-core (~> 4.0)
sprockets (>= 3.0)
middleman-syntax (3.0.0)
middleman-syntax (3.2.0)
middleman-core (>= 3.2)
rouge (~> 2.0)
rouge (~> 3.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
multi_json (1.14.1)
nokogiri (1.10.8)
multi_json (1.15.0)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
openapi3_parser (0.5.2)
commonmarker (~> 0.17)
Expand All @@ -145,19 +151,20 @@ GEM
padrino-support (0.13.3.4)
activesupport (>= 3.1)
parallel (1.19.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (4.0.5)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
rack (2.2.3)
rack-livereload (0.3.17)
rack
rake (13.0.0)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
redcarpet (3.3.4)
rouge (2.2.1)
redcarpet (3.5.0)
rexml (3.2.4)
rouge (3.23.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
Expand All @@ -171,13 +178,13 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
ruby-enum (0.7.2)
ruby-enum (0.8.0)
i18n
sass (3.4.25)
sassc (2.4.0)
ffi (~> 1.9)
servolux (0.13.0)
sprockets (4.0.0.beta10)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
temple (0.8.2)
Expand All @@ -194,7 +201,7 @@ PLATFORMS

DEPENDENCIES
activemodel
govuk_tech_docs
govuk_tech_docs!
middleman-gh-pages
rspec
tzinfo-data
Expand Down
12 changes: 9 additions & 3 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

GovukTechDocs.configure(self)

# use relative paths for links and sources
activate :relative_assets
set :relative_links, true
# Without prefix for 'middleman serve'
set(:govuk_assets_path, "/assets/govuk/assets/")

# Add '/api-catalogue/' for 'middleman build', for Github Pages compatibility
configure :build do
set(:build_dir, "build/api-catalogue")
set(:http_prefix, "/api-catalogue/")
set(:govuk_assets_path, "/api-catalogue/assets/govuk/assets/")
end

helpers UrlHelpers

Expand Down
3 changes: 0 additions & 3 deletions source/stylesheets/print.css.scss

This file was deleted.

4 changes: 4 additions & 0 deletions source/stylesheets/print.css.scss.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$govuk-assets-path: "<%= app.config[:govuk_assets_path] %>";
$is-print: true;

@import "govuk_tech_docs";
4 changes: 0 additions & 4 deletions source/stylesheets/screen-old-ie.css.scss

This file was deleted.

5 changes: 5 additions & 0 deletions source/stylesheets/screen-old-ie.css.scss.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$govuk-assets-path: "<%= app.config[:govuk_assets_path] %>";
$is-ie: true;
$ie-version: 8;

@import "govuk_tech_docs";
1 change: 0 additions & 1 deletion source/stylesheets/screen.css.scss

This file was deleted.

3 changes: 3 additions & 0 deletions source/stylesheets/screen.css.scss.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$govuk-assets-path: "<%= app.config[:govuk_assets_path] %>";

@import "govuk_tech_docs";

0 comments on commit 6f88d67

Please sign in to comment.