From efdf5cae3d465d853dd7593aa75ae7101c5b8d39 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 13 Mar 2016 19:09:09 -0400 Subject: add page-features and populate stuff --- src/guff/mime-type.cr | 6 ++++ src/guff/page-features.cr | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/guff/page-features.cr (limited to 'src/guff') 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 -- cgit v1.2.3