Skip to content

Commit 3e82c26

Browse files
authored
[DD-542] Inline API v1 resources (circleci#6716)
* Try: middleman inline plugin. * Inline all the things! * Add: correct jquery verison and missing toc code. * Clean: gemfile changes / js changes. * Clean: remove unused code.
1 parent db2ece4 commit 3e82c26

File tree

3 files changed

+770
-12
lines changed

3 files changed

+770
-12
lines changed

src-api/config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
# out the following two lines has been known to help
4545
activate :minify_css
4646
activate :minify_javascript
47+
activate :inline
4748
# activate :relative_assets
4849
# activate :asset_hash
4950
# activate :gzip
@@ -55,4 +56,5 @@
5556

5657
helpers do
5758
require './lib/toc_data.rb'
59+
require './lib/middleman-inline.rb'
5860
end

src-api/lib/middleman-inline.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require "middleman-core"
2+
3+
# original code: https://github.com/miloshadzic/middleman-inline/blob/master/lib/middleman-inline/extension.rb
4+
# I'm vendoring this because I couldn't get the gem working.
5+
class MiddlemanInline < ::Middleman::Extension
6+
helpers do
7+
def inline_css(*args)
8+
args.map do |arg|
9+
"<style type='text/css'>#{render_resource(fname(arg, '.css'))}</style>"
10+
end.join("\n")
11+
end
12+
13+
private
14+
15+
def fname(str, ext)
16+
str.concat(ext) unless str.match(ext)
17+
str
18+
end
19+
20+
def render_resource(fname)
21+
x = sitemap.resources.find { |res| res.source_file.match(fname) }
22+
x.render()
23+
end
24+
end
25+
end
26+
27+
Middleman::Extensions.register :inline do
28+
MiddlemanInline
29+
end
30+
31+

0 commit comments

Comments
 (0)