-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
161 lines (128 loc) · 4.52 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
require "helpers/people_helpers"
# "include" rather than "helpers" so we can use person_name in search prep
include PeopleHelpers
require "helpers/blog_helpers"
require "helpers/image_helpers"
# in this case, we need image_for_blog_article during search indexing
include BlogHelpers
include ImageHelpers
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
ANSI_COLOR_RED = "\e[31m"
ANSI_COLOR_RESET = "\e[0m"
helpers do
def nav_link(link_text, url, options = {})
options[:class] ||= ""
options[:class] << " current" if current_resource.url.start_with?(url)
link_to(link_text, url, options)
end
# this overrides the built-in helper
# see https://github.com/middleman/middleman/issues/145
def extra_page_classes
path_classes = page_classes.split(' ')
blog_classes = []
if current_page.data.tags
blog_classes << current_page.data.tags.split(',').map{|t| "tag-#{t.strip.gsub(/\s+/, '-')}"}
end
if current_page.data.category
blog_classes << "category-#{current_page.data.category.strip.gsub(/\s+/, '-')}"
end
classes = path_classes + blog_classes
return classes.join(' ')
end
def artifact_icon(artifact_name)
path = "work/images/artifact_#{artifact_name}.svg"
if resource = sitemap.find_resource_by_path(path)
file = File.open(resource.source_file, 'r')
return file.read
else
puts "#{ANSI_COLOR_RED}Unknown artifact icon #{artifact_name} in #{current_resource.path}#{ANSI_COLOR_RESET}"
# empty roundrect
return '<svg title="unknown artifact" version="1.1" xmlns="http://www.w3.org/2000/svg" width="64px" height="64px" viewBox="0 0 64 64">
<path d="M60,4c1.103,0,2,0.897,2,2v51.9c0,1.103-0.897,2-2,2H4c-1.103,0-2-0.897-2-2V6c0-1.103,0.897-2,2-2H60 M60,3 H4C2.343,3,1,4.343,1,6v51.9c0,1.657,1.343,3,3,3h56c1.657,0,3-1.343,3-3V6C63,4.343,61.657,3,60,3L60,3z"/>'
end
end
def mustache_template(path)
return File.open("source/#{path}") { |f| f.read }
end
end
set :site_url, 'https://artificial.design/'
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
Time.zone = "Amsterdam"
# serve as HTML by default so we can use the live dev server
# apparently a blog permalink ending with .html isn't obvious enough
::Rack::Mime::MIME_TYPES[''] = 'text/html'
# Blog
activate :blog do |blog|
blog.prefix = "blog"
blog.sources = "{year}/{month}-{day}-{title}.html"
blog.permalink = "{year}/{month}/{day}/{title}.html"
blog.layout = "blog_layout"
blog.default_extension = ".md"
blog.summary_separator = /READMORE/
blog.paginate = true
# blog.custom_collections = {
# author: {
# link: '/people/{author}.html',
# template: '/people/template.html'
# }
# }
end
page "blog/feed.xml", layout: false
set :markdown_engine, :redcarpet
set :markdown, fenced_code_blocks: true,
tables: true,
autolink: true,
smartypants: true,
footnotes: true
# activate :syntax
activate :search do |search|
require 'padrino-helpers'
include Padrino::Helpers::FormatHelpers
include Padrino::Helpers::TagHelpers
search.resources = ['blog/', 'work/']
search.index_path = 'search/index.json'
search.fields = {
title: {boost: 100, store: true, required: true},
path: {index: false, store: true},
tags: {boost: 100},
author: {boost: 10},
username: {boost: 10},
date: {index: false, store: true},
content: {boost: 75},
url: {index: false, store: true, required: true}
}
search.before_index = Proc.new do |to_index, to_store, resource|
throw(:skip) if resource.data.noindex == true
path = resource.path
puts("Indexing: #{path}")
to_store[:path] = path
begin
card = Cards.card_for_resource(sitemap.app, resource)
to_store[:type] = card.class.name.split('::').last.downcase
to_store.merge! card.values_hash
rescue Exception => e
warn "Error creating card: #{e.message}"
throw(:skip)
end
# to_index[:username] = card[:username]
# to_index[:author] = card[:author]
end
end
configure :build do
activate :minify_css
# activate :gzip
# default_caching_policy public: true, must_revalidate: true
# For example, change the Compass output style for deployment
# activate :minify_css
# Minify Javascript on build
# activate :minify_javascript
# Enable cache buster
# activate :asset_hash
# Use relative URLs
# activate :relative_assets
# Or use a different image path
# set :http_prefix, "/Content/images/"
end