-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.rb
137 lines (111 loc) · 3.06 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
###
# Compass
###
# Change Compass configuration
# compass_config do |config|
# config.output_style = :compact
# end
###
# Page options, layouts, aliases and proxies
###
# Per-page layout changes:
#
# With no layout
# page "/path/to/file.html", :layout => false
#
# With alternative layout
# page "/path/to/file.html", :layout => :otherlayout
#
# A path which all have the same layout
# with_layout :admin do
# page "/admin/*"
# end
# Proxy pages (http://middlemanapp.com/basics/dynamic-pages/)
# proxy "/this-page-has-no-template.html", "/template-file.html", :locals => {
# :which_fake_page => "Rendering a fake page with a local variable" }
###
# Helpers
###
# Automatic image dimensions on image_tag helper
# activate :automatic_image_sizes
# Reload the browser automatically whenever files change
# configure :development do
# activate :livereload
# end
# Methods defined in the helpers block are available in templates
helpers do
# active をつけるべきかどうか判断してつけるべきならつけたリンクを生成する
# @param [String] label リンクラベル
# @param [String] dest リンク先
# @param [Hash] attr li に渡す属性
def activity_list(label, dest, attr = {})
if dest == current_page.url
if attr.has_key?(:class)
attr[:class] += ' active'
else
attr.merge!(class: 'active')
end
end
content_tag(:li, attr) do
link_to label, dest
end
end
# FontAwesome
def icon(icon, text="", html_options={})
content_class = "fa fa-#{icon}"
content_class << " #{html_options[:class]}" if html_options.key?(:class)
html_options[:class] = content_class
html = content_tag(:i, nil, html_options)
html << " #{text}" unless text.blank?
html.html_safe
end
# おしらせの YAML をハッシュに変換して返す
def announcements
YAML.load_file('resources/announcements.yml')
end
# image_url を返す
def image_url(source)
'https://youcube.jp' + image_path(source)
end
# 金額表示にする
def pricing(price, unit = '')
content_tag(:strong, "¥#{price.comma}#{unit}", class: 'pricing')
end
# 消費税率を返す
def tax_rate
8
end
# 消費税額を返す
def tax_price(price)
price * tax_rate / 100
end
# 税込価格を返す
def price_including_tax(price)
price + tax_price(price)
end
end
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
# きれいな URL
activate :directory_indexes
# サイトマップは layout しない
page '/sitemap.xml', layout: false
# Build-specific configuration
configure :build do
require 'uglifier'
# Minify files
activate :minify_html do |html|
html.preserve_line_breaks = true
html.remove_http_protocol = false
html.remove_https_protocol = false
end
activate :minify_css
activate :minify_javascript, compressor: Uglifier.new(comments: :none)
# Enable cache buster
activate :asset_hash
# Use relative URLs
# activate :relative_assets
# Or use a different image path
# set :http_prefix, "/Content/images/"
end