aboutsummaryrefslogtreecommitdiff
path: root/src/guff
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff')
-rw-r--r--src/guff/mime-type.cr6
-rw-r--r--src/guff/page-features.cr71
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