diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-13 19:09:09 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-13 19:09:09 -0400 |
commit | efdf5cae3d465d853dd7593aa75ae7101c5b8d39 (patch) | |
tree | 4af049794f05c0d0e4d3b1f66cb92096f5bf6978 /src/guff | |
parent | 88b71756106ba51022c38ab45b6c7d207339dd1f (diff) | |
download | old-guff-efdf5cae3d465d853dd7593aa75ae7101c5b8d39.tar.bz2 old-guff-efdf5cae3d465d853dd7593aa75ae7101c5b8d39.zip |
add page-features and populate stuff
Diffstat (limited to 'src/guff')
-rw-r--r-- | src/guff/mime-type.cr | 6 | ||||
-rw-r--r-- | src/guff/page-features.cr | 71 |
2 files changed, 77 insertions, 0 deletions
diff --git a/src/guff/mime-type.cr b/src/guff/mime-type.cr index 992521b..8f06f12 100644 --- a/src/guff/mime-type.cr +++ b/src/guff/mime-type.cr @@ -6,6 +6,12 @@ module Guff::MimeType ".png": "image/png", ".jpeg": "image/jpeg", ".jpg": "image/jpeg", + ".otf": "application/vnd.ms-opentype", + ".eot": "application/vnd.ms-fontobject", + ".svg": "image/svg+xml", + ".ttf": "application/x-font-ttf", + ".woff": "application/font-woff", + ".woff2": "application/font-woff", } def self.mime_type(path : String) : String diff --git a/src/guff/page-features.cr b/src/guff/page-features.cr new file mode 100644 index 0000000..887197e --- /dev/null +++ b/src/guff/page-features.cr @@ -0,0 +1,71 @@ + +module Guff::PageFeatures + FEATURES = { + "jquery": { + scripts: %w{ + /guff-stuff/jquery-2.2.1.min.js + }, + }, + + "luigi-template": { + scripts: %w{ + /guff-stuff/luigi-template-0.4.1.min.js + }, + }, + + "font-awesome": { + styles: %w{ + /guff-stuff/font-awesome-4.5.0/css/font-awesome.min.css + }, + }, + + "bootstrap": { + deps: %w{jquery}, + + styles: %w{ + /guff-stuff/bootstrap-3.3.6/css/bootstrap.min.css + /guff-stuff/bootstrap-3.3.6/css/bootstrap-theme.min.css + }, + + scripts: %w{ + /guff-stuff/bootstrap-3.3.6/js/bootstrap.min.js + }, + + # TODO + metas: [] of Hash(String, String), + }, + } + + def self.add(key : String, page) + raise "unknown feature: #{key}" unless FEATURES.has_key?(key) + f = FEATURES[key] + + if f.has_key?(:deps) + # add dependencies + (f[:deps] as Array(String)).each do |dep| + page.add_feature(dep) + end + end + + if f.has_key?(:scripts) + # add scripts + (f[:scripts] as Array(String)).each do |path| + page.scripts << path + end + end + + if f.has_key?(:styles) + # add styles + (f[:styles] as Array(String)).each do |path| + page.styles << path + end + end + + if f.has_key?(:metas) + # add metas + (f[:metas] as Array(Hash(String, String))).each do |meta| + page.metas << meta + end + end + end +end |