forked from skroutz/developer.skroutz.gr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rb
130 lines (104 loc) · 3.03 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
require 'lib/code_example_helper'
require 'lib/document_helper'
require 'lib/page_navigation_helper'
require 'lib/response_mate_helper'
require 'uglifier'
# Layouts
page 'index.html', layout: false
page '404.html', layout: false
# Localization
activate :i18n, langs: [:en, :el, :tr]
I18n.enforce_available_locales = false # Silence I18n deprecation warnings
# Pretty URLs
activate :directory_indexes
# Relative URLs
set :relative_links, true
# Syntax Highlight
activate :syntax, line_numbers: false
# MarkDown
set :markdown_engine, :kramdown
set :markdown, layout_engine: :erb, toc_levels: [2, 3]
# Assets
set :css_dir, 'assets/stylesheets'
set :js_dir, 'assets/javascripts'
set :images_dir, 'assets/images'
set :fonts_dir, 'assets/fonts'
# Build Configuration
configure :build do
# Ignore assets from other flavors
%w(skroutz alve scrooge).each do |f|
next if f == flavor
ignore "assets/images/#{f}/*"
ignore "assets/stylesheets/flavors/#{f}.*"
end
# Use Relative Assets
activate :relative_assets
# Enable Cache Buster Cache Method #02
activate :asset_hash
# Minify CSS
activate :minify_css
# Minify JS
activate :minify_javascript, compressor: Uglifier.new
# GZip
activate :gzip
end
# Helpers
helpers CodeExampleHelper
helpers ResponseMateHelper
helpers PageNavigationHelper
helpers DocumentHelper
helpers do
# Returns the current environment flavor
#
# @example Run Middleman for Skroutz
# FLAVOR=skroutz bundle exec middleman server
# flavor #=> 'skroutz'
#
# @example Build website for Alve
# FLAVOR=alve bundle exec middleman build
# flavor #=> 'alve'
#
# @return [String] the current flavor
def flavor
ENV['FLAVOR'] || (req.present? && req.params['flavor']) || 'skroutz'
end
# Shorthand for data[flavor]
#
# @return [String] Data of the current flavor
def settings
data[flavor]
end
# Returns the default Page title of the site
#
# @return [String] the default Page title
def site_title
"#{settings.site_name} #{t('titles.docs')}".titleize
end
# Builds the Page title of the current page
#
# Parameters can be either keys that point at the locale or literals. The
# translation lookup scope for keys is within [:titles, :docs].
#
# @param [Hash] page the page to build title for
# @return [String] the constructed Page title
def page_title(page)
return site_title if page.title.nil? || page.title.empty?
title = t("titles.#{page.title}",
flavor: settings.site_name.capitalize,
default: ["docs.#{page.parent}.#{page.title}".to_sym,
page.title.to_s.titleize])
if page.parent.nil?
parent_title = site_title
else
parent_title = t("titles.#{page.parent}",
flavor: settings.site_name.capitalize,
default: site_title)
end
"#{title} | #{parent_title}"
end
end
# Initializers
# Set API responses output directory per flavor
ResponseMate.setup do |config|
config.output_dir = "./resources/responses/#{flavor}"
end