-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.rb
73 lines (56 loc) · 2.3 KB
/
config.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'pathname'
require "rack/google-analytics"
require 'nokogiri'
# Reload the browser automatically whenever files change
configure :development do
activate :livereload
end
activate :autoprefixer do |config|
config.browsers = ['last 3 versions', 'Explorer >= 8']
end
activate :dotenv
activate :directory_indexes
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
sprockets.append_path File.join root, 'bower_components'
ready do
# Build the Puzzles
data.puzzles.first[1].each_with_index do |puzzle, puzzle_index|
solution_resources = sitemap.resources.select do |resource|
resource.path.start_with?("puzzles/#{puzzle['puzzleDir']}")
end
solutions = solution_resources.map do |resource|
filename = Pathname.new(resource.path).basename(".txt")
{
filename: filename,
language: data.languages[filename.to_s],
url: "http://www.ineverylang.com/#{puzzle.puzzleDir}/#{filename.to_s}",
source: resource.metadata[:page]["source"],
puzzle: puzzle,
code: resource.render
}
end
proxy "#{puzzle['puzzleDir']}.html", "puzzle.html", :locals => { :solutions => solutions, puzzle: puzzle, index: puzzle_index, :title => "#{puzzle['prettyName']} Solutions In Every Language", :description => Nokogiri::HTML(puzzle['description']).text}
proxy "#{puzzle['puzzleDir']}.json", "puzzlejson.html", :locals => { :solutions => solutions, puzzle: puzzle}, :layout => false
proxy "ddg-#{puzzle['puzzleDir']}.json", "ddg-puzzlejson.html", :locals => { :solutions => solutions, puzzle: puzzle}, :layout => false
solutions.each do |solution|
solution[:index] = puzzle_index
solution[:title] = "#{puzzle['prettyName']} in #{solution[:language]}"
solution[:smallFooter] = "true"
solution[:description] = Nokogiri::HTML(puzzle['description']).text
proxy "#{puzzle['puzzleDir']}/#{solution[:filename]}.html", "solution.html", :locals => solution
end
end
end
ignore "puzzle.html"
ignore "puzzlejson.html"
ignore "ddg-puzzlejson.html"
ignore "solution.html"
# Build-specific configuration
configure :build do
activate :minify_css
activate :minify_javascript
activate :asset_hash
use Rack::GoogleAnalytics, :tracker => ENV['GA_CODE']
end