fl 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +44 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +173 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/app/admin/options.rb +46 -0
- data/app/admin/pages.rb +55 -0
- data/app/admin/users.rb +34 -0
- data/app/assets/javascripts/active_admin.coffee.erb +20 -0
- data/app/assets/javascripts/application.coffee.erb +40 -0
- data/app/assets/javascripts/ckeditor/basepath.coffee.erb +21 -0
- data/app/assets/javascripts/ckeditor/config.coffee.erb +146 -0
- data/app/assets/javascripts/ckeditor/plugins/autogrow/plugin.js +232 -0
- data/app/assets/javascripts/ckeditor/plugins/autogrow/samples/autogrow.html +102 -0
- data/app/assets/javascripts/ckeditor/plugins/stylesheetparser/plugin.js +158 -0
- data/app/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/assets/sample.css +70 -0
- data/app/assets/javascripts/ckeditor/plugins/stylesheetparser/samples/stylesheetparser.html +85 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/dialog.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_ie.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_ie7.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_ie8.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/dialog_iequirks.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/editor.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/editor_gecko.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/editor_ie.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/editor_ie7.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/editor_ie8.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/editor_iequirks.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/icons.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/icons_hidpi.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/arrow.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/close.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/close.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/lock-open.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/lock.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/hidpi/refresh.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/lock-open.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/lock.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/images/refresh.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/readme.md +7 -0
- data/app/assets/javascripts/ckeditor/skins/minimalist/skin.js +10 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_ie.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_ie7.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_ie8.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/dialog_iequirks.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/editor.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_gecko.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_ie.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_ie7.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_ie8.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/editor_iequirks.css +5 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/icons.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/icons_hidpi.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/arrow.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/close.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/close.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/lock-open.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/lock.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/hidpi/refresh.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/lock-open.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/lock.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/refresh.png +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/images/spinner.gif +0 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/readme.md +51 -0
- data/app/assets/javascripts/ckeditor/skins/moonocolor/skin.js +10 -0
- data/app/assets/javascripts/components/confirm.coffee +51 -0
- data/app/assets/javascripts/components/modals.coffee +29 -0
- data/app/assets/stylesheets/_defaults.yml +106 -0
- data/app/assets/stylesheets/_functions.sass.erb +75 -0
- data/app/assets/stylesheets/active_admin.sass +117 -0
- data/app/assets/stylesheets/application.sass.erb +46 -0
- data/app/assets/stylesheets/styles/reset.sass +139 -0
- data/app/assets/stylesheets/styles/structure.sass +69 -0
- data/app/assets/stylesheets/styles/ui/flash.sass +128 -0
- data/app/assets/stylesheets/styles/ui/fonts.sass +32 -0
- data/app/assets/stylesheets/styles/ui/modals.sass +61 -0
- data/app/assets/stylesheets/styles/ui/tooltips.sass +139 -0
- data/app/controllers/application_controller.rb +87 -0
- data/app/helpers/fl/application_helper.rb +53 -0
- data/app/helpers/fl/asset_helper.rb +50 -0
- data/app/helpers/fl/liquid_helper.rb +29 -0
- data/app/helpers/fl/meta_helper.rb +118 -0
- data/app/lib/active_record/concerns/base.rb +55 -0
- data/app/lib/active_record/concerns/seeds.rb +78 -0
- data/app/liquid/filters/meta_filter.rb +6 -0
- data/app/liquid/tags/google_analytics_tag.rb +32 -0
- data/app/liquid/tags/icon_tag.rb +37 -0
- data/app/liquid/tags/meta_tag.rb +120 -0
- data/app/mailers/application_mailer.rb +28 -0
- data/app/models/application_record.rb +3 -0
- data/app/models/asset.rb +95 -0
- data/app/models/association.rb +21 -0
- data/app/models/meta.rb +27 -0
- data/app/models/node.rb +59 -0
- data/app/models/profile.rb +49 -0
- data/app/models/user.rb +49 -0
- data/app/service/flash.rb +8 -0
- data/app/views/layouts/_admin.haml +6 -0
- data/app/views/layouts/_application.haml +17 -0
- data/app/views/layouts/base.haml +26 -0
- data/app/views/mailers/layouts/mailer.haml +8 -0
- data/app/views/mailers/layouts/mailer.text.erb +1 -0
- data/app/views/mailers/new_user.erb +4 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/initializers/active_admin.rb +266 -0
- data/config/initializers/ckeditor.rb +63 -0
- data/config/initializers/devise.rb +279 -0
- data/config/initializers/friendly_id.rb +92 -0
- data/config/initializers/inflections.rb +20 -0
- data/config/initializers/liquid.rb +87 -0
- data/config/initializers/sass.rb +45 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/locales/en.yml +13 -0
- data/config/puma.rb +59 -0
- data/config/routes.rb +56 -0
- data/db/migrate/20160616060637_create_nodes.rb +26 -0
- data/db/migrate/20160707080248_create_users.rb +52 -0
- data/db/migrate/20160707094704_create_slugs.rb +33 -0
- data/db/migrate/20160710095916_create_associations.rb +20 -0
- data/db/migrate/20160713061948_create_profiles.rb +27 -0
- data/db/migrate/20161115101221_create_assets.rb +25 -0
- data/db/migrate/20170725060408_create_active_admin_comments.rb +22 -0
- data/db/seeds.rb +81 -0
- data/fl.gemspec +73 -0
- data/lib/fl.rb +28 -0
- data/lib/fl/constants.rb +52 -0
- data/lib/fl/engine.rb +160 -0
- data/lib/fl/hash.rb +34 -0
- data/lib/generators/fl/sass_vars_generator.rb +16 -0
- data/lib/generators/fl/templates/sass.yml +56 -0
- data/lib/tasks/ckeditor.rake +37 -0
- data/lib/tasks/favicon.rake +37 -0
- data/readme/fl.jpg +0 -0
- metadata +416 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
/////////////////////////////////////////////
|
2
|
+
/////////////////////////////////////////////
|
3
|
+
// _____ _ _ _ //
|
4
|
+
// |_ _| | | | (_) //
|
5
|
+
// | | ___ ___ | | |_ _ _ __ //
|
6
|
+
// | |/ _ \ / _ \| | __| | '_ \ //
|
7
|
+
// | | (_) | (_) | | |_| | |_) | //
|
8
|
+
// \_/\___/ \___/|_|\__|_| .__/ //
|
9
|
+
// | | //
|
10
|
+
// |_| //
|
11
|
+
/////////////////////////////////////////////
|
12
|
+
/////////////////////////////////////////////
|
13
|
+
|
14
|
+
/// Last updated 14/08/2017
|
15
|
+
/// Bootstrap 4.0.0.beta
|
16
|
+
/// R.Peck
|
17
|
+
|
18
|
+
// Functions
|
19
|
+
// Required unless called from gem (which calls functions in application)
|
20
|
+
@import functions
|
21
|
+
|
22
|
+
/////////////////////////////////////////////
|
23
|
+
/////////////////////////////////////////////
|
24
|
+
// Tooltip
|
25
|
+
.tooltip
|
26
|
+
|
27
|
+
//Animation (from Animate.css)
|
28
|
+
animation:
|
29
|
+
name: fadeIn
|
30
|
+
duration: ($animation-duration * 1.5)
|
31
|
+
fill-mode: both
|
32
|
+
|
33
|
+
// Styling
|
34
|
+
color: $tooltip-color
|
35
|
+
position: absolute
|
36
|
+
display: block
|
37
|
+
cursor: $base-cursor-default
|
38
|
+
padding: $tooltip-padding
|
39
|
+
background:
|
40
|
+
color: $tooltip-bg
|
41
|
+
line:
|
42
|
+
height: 1.5em
|
43
|
+
text:
|
44
|
+
align: $tooltip-text-align
|
45
|
+
decoration: $tooltip-text-decoration
|
46
|
+
shadow: $tooltip-text-shadow
|
47
|
+
transform: $tooltip-text-transform
|
48
|
+
white:
|
49
|
+
space: normal
|
50
|
+
word:
|
51
|
+
break: normal
|
52
|
+
spacing: normal
|
53
|
+
wrap: ellipsis
|
54
|
+
font:
|
55
|
+
size: $tooltip-font-size
|
56
|
+
weight: $tooltip-font-weight
|
57
|
+
border:
|
58
|
+
width: $tooltip-border-width
|
59
|
+
style: $tooltip-border-style
|
60
|
+
color: $tooltip-border-color
|
61
|
+
radius: $tooltip-border-radius
|
62
|
+
box:
|
63
|
+
sizing: border-box
|
64
|
+
shadow: $tooltip-inner-shadow, $tooltip-outer-shadow
|
65
|
+
z:
|
66
|
+
index: 1500
|
67
|
+
user:
|
68
|
+
select: none
|
69
|
+
|
70
|
+
/////////////////////
|
71
|
+
|
72
|
+
&:hover
|
73
|
+
cursor: $base-cursor-default
|
74
|
+
|
75
|
+
/////////////////////
|
76
|
+
/////////////////////
|
77
|
+
|
78
|
+
// Show
|
79
|
+
.show
|
80
|
+
opacity: $tooltip-opacity
|
81
|
+
|
82
|
+
/////////////////////
|
83
|
+
|
84
|
+
// Arrow
|
85
|
+
.arrow
|
86
|
+
display: block
|
87
|
+
position: absolute
|
88
|
+
border:
|
89
|
+
style: solid
|
90
|
+
color: transparent
|
91
|
+
box:
|
92
|
+
sizing: border-box
|
93
|
+
|
94
|
+
/////////////////////
|
95
|
+
/////////////////////
|
96
|
+
|
97
|
+
@each $pos in top, right, bottom, left
|
98
|
+
|
99
|
+
$opposite: opposite($pos)
|
100
|
+
$margin: axis($pos,"top","left")
|
101
|
+
$arrow: axis($pos,"left","top")
|
102
|
+
|
103
|
+
&.bs-tooltip-#{$pos}
|
104
|
+
background:
|
105
|
+
image: linear-gradient(to #{$opposite}, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%)
|
106
|
+
margin:
|
107
|
+
#{$opposite}: $tooltip-arrow-width
|
108
|
+
.arrow
|
109
|
+
#{$opposite}: (-$tooltip-arrow-width)
|
110
|
+
border:
|
111
|
+
width: $tooltip-arrow-width
|
112
|
+
#{$pos}-color: $tooltip-bg
|
113
|
+
#{$opposite}-width: 0 !important
|
114
|
+
|
115
|
+
/////////////////////
|
116
|
+
/////////////////////
|
117
|
+
|
118
|
+
// Auto
|
119
|
+
&.bs-tooltip-auto
|
120
|
+
@each $pos in top, right, bottom, left
|
121
|
+
&[x-placement^="#{$pos}"]
|
122
|
+
@extend .bs-tooltip-#{$pos}
|
123
|
+
|
124
|
+
/////////////////////////////////////////////
|
125
|
+
/////////////////////////////////////////////
|
126
|
+
|
127
|
+
// Arrows
|
128
|
+
.tooltip-inner
|
129
|
+
overflow: hidden
|
130
|
+
width: 100%
|
131
|
+
max:
|
132
|
+
width: $tooltip-max-width
|
133
|
+
text:
|
134
|
+
overflow: ellipsis
|
135
|
+
white:
|
136
|
+
space: nowrap
|
137
|
+
|
138
|
+
/////////////////////////////////////////////
|
139
|
+
/////////////////////////////////////////////
|
@@ -0,0 +1,87 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
|
3
|
+
##################################
|
4
|
+
##################################
|
5
|
+
|
6
|
+
# => Responders Gem
|
7
|
+
respond_to :html
|
8
|
+
|
9
|
+
##################################
|
10
|
+
##################################
|
11
|
+
|
12
|
+
# => Settings
|
13
|
+
# Header & Footer content defined in ApplicationHelper
|
14
|
+
protect_from_forgery with: :exception
|
15
|
+
|
16
|
+
# => Layout
|
17
|
+
layout Proc.new { |c| Rails.application.secrets[:app][:layout] unless c.request.xhr? }
|
18
|
+
|
19
|
+
##################################
|
20
|
+
##################################
|
21
|
+
|
22
|
+
# => Specific page content
|
23
|
+
# => All slugrouter requests passed here (including root)
|
24
|
+
# => Liquid ref - https://github.com/Shopify/liquid/wiki/Liquid-for-Programmers#first-steps
|
25
|
+
# => If not using bang operator in find, use || "No Content"
|
26
|
+
def show
|
27
|
+
raise ActionController::RoutingError.new('Not Found') if params[:id] == "index"
|
28
|
+
@content = Node.find_by_slug! params[:id] || "index"
|
29
|
+
end
|
30
|
+
|
31
|
+
##################################
|
32
|
+
# => Auth
|
33
|
+
##################################
|
34
|
+
|
35
|
+
# => New
|
36
|
+
def new
|
37
|
+
@content = Node.new
|
38
|
+
respond_with @content
|
39
|
+
end
|
40
|
+
|
41
|
+
# => Create
|
42
|
+
def create
|
43
|
+
@content = Node.new node_params
|
44
|
+
respond_with @content, location: -> { application_path(@content) }
|
45
|
+
end
|
46
|
+
|
47
|
+
# => Update
|
48
|
+
def update
|
49
|
+
@content = Node.find_by_slug! params[:id]
|
50
|
+
respond_with @content, location: -> { application_path(@content) }
|
51
|
+
end
|
52
|
+
|
53
|
+
##################################
|
54
|
+
##################################
|
55
|
+
|
56
|
+
# => Robots.txt
|
57
|
+
# => http://api.rubyonrails.org/classes/ActionController/ConditionalGet.html#method-i-expires_in
|
58
|
+
def robots
|
59
|
+
expires_in 5.hours, public: true
|
60
|
+
render plain: "User-agent: *"
|
61
|
+
end
|
62
|
+
|
63
|
+
##################################
|
64
|
+
##################################
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# => Devise
|
69
|
+
# => Sign In
|
70
|
+
def after_sign_in_path_for(resource)
|
71
|
+
Rails.application.routes.named_routes[:admin_root] ? admin_root_path : root_path
|
72
|
+
end
|
73
|
+
|
74
|
+
# => Devise
|
75
|
+
# => Sign Out
|
76
|
+
def after_sign_out_path_for(resource_or_scope)
|
77
|
+
root_path
|
78
|
+
end
|
79
|
+
|
80
|
+
# => Params
|
81
|
+
def node_params
|
82
|
+
params.require(:node).permit(:ref, :val)
|
83
|
+
end
|
84
|
+
|
85
|
+
##################################
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module FL
|
2
|
+
module ApplicationHelper
|
3
|
+
|
4
|
+
##########################
|
5
|
+
##########################
|
6
|
+
|
7
|
+
# => Current Layout
|
8
|
+
# => Need to pass some sort of object to it, otherwise fails
|
9
|
+
# => http://stackoverflow.com/questions/22787021/rails-4-name-of-current-layout
|
10
|
+
def current_layout
|
11
|
+
layout = controller.send :_layout, ["test"]
|
12
|
+
layout.inspect.split("/").last.gsub(/.haml/,"").tr('"', '')
|
13
|
+
end
|
14
|
+
|
15
|
+
# => Admin?
|
16
|
+
# => Checks for namespace
|
17
|
+
# => http://stackoverflow.com/a/15028731/1143732 (comment)
|
18
|
+
# => Devise should be "devise_controller?"
|
19
|
+
def admin?
|
20
|
+
defined? Admin and controller.class.parents.include? Admin
|
21
|
+
defined? Devise and controller.class.parents.include? Devise
|
22
|
+
end
|
23
|
+
|
24
|
+
# => Icons
|
25
|
+
def i *args
|
26
|
+
gem_name = 'font-awesome-rails'
|
27
|
+
gdep = Gem::Dependency.new(gem_name)
|
28
|
+
gdep.matching_specs.max_by(&:version) ? fa_icon(*args) : ion_icon(*args)
|
29
|
+
end
|
30
|
+
|
31
|
+
##########################
|
32
|
+
##########################
|
33
|
+
|
34
|
+
## Devise ##
|
35
|
+
def resource_name
|
36
|
+
:user
|
37
|
+
end
|
38
|
+
|
39
|
+
## Class ##
|
40
|
+
def resource
|
41
|
+
@resource ||= User.new
|
42
|
+
end
|
43
|
+
|
44
|
+
## Mappings ##
|
45
|
+
def devise_mapping
|
46
|
+
@devise_mapping ||= Devise.mappings[:user]
|
47
|
+
end
|
48
|
+
|
49
|
+
##########################
|
50
|
+
##########################
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module FL
|
2
|
+
module AssetHelper
|
3
|
+
|
4
|
+
##########################
|
5
|
+
##########################
|
6
|
+
|
7
|
+
# => Sass
|
8
|
+
def sass hash
|
9
|
+
self.sass hash
|
10
|
+
end
|
11
|
+
|
12
|
+
##########################
|
13
|
+
##########################
|
14
|
+
|
15
|
+
# => Sass
|
16
|
+
# => Takes HASH or YML and turns into SASS vars
|
17
|
+
# => Used in config/initializers/sass.rb & assets/stylesheets/application.sass.erb
|
18
|
+
def self.sass hash, default=false
|
19
|
+
vars = {}
|
20
|
+
|
21
|
+
# Cycle through data
|
22
|
+
# Recursion handled by "each_nested_pair"
|
23
|
+
# Here you determine the best parts
|
24
|
+
|
25
|
+
# Determine if hash is hash or path
|
26
|
+
# If path change into hash by loading YML
|
27
|
+
hash = YAML.load_file(hash) if hash.is_a?(String) || hash.is_a?(Pathname) # => Needs some sort of rescue
|
28
|
+
|
29
|
+
# General
|
30
|
+
# http://api.rubyonrails.org/classes/Hash.html#method-i-except
|
31
|
+
hash.except("development", "production", "staging").each_nested_pair do |k,v|
|
32
|
+
vars[k] = v if v
|
33
|
+
end
|
34
|
+
|
35
|
+
# Env
|
36
|
+
if hash[Rails.env] # => Ensure that there is a key for the env
|
37
|
+
hash[Rails.env].each_nested_pair do |k,v|
|
38
|
+
vars[k] = v if v
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Return
|
43
|
+
vars.map{|k,v| "$#{k}: #{v} #{"!default" if default}"}.join("\n")
|
44
|
+
end
|
45
|
+
|
46
|
+
##########################
|
47
|
+
##########################
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module FL
|
2
|
+
module LiquidHelper
|
3
|
+
|
4
|
+
##########################
|
5
|
+
## Liquid ##
|
6
|
+
##########################
|
7
|
+
|
8
|
+
# => Liquidize
|
9
|
+
def liquidize content, *args
|
10
|
+
template = Liquid::Template.parse content
|
11
|
+
sanitize template.render
|
12
|
+
end
|
13
|
+
|
14
|
+
##########################
|
15
|
+
##########################
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# => Shortcodes
|
20
|
+
def shortcodes
|
21
|
+
cache = ActiveSupport::Cache::MemoryStore.new
|
22
|
+
cache.read :shortcodes
|
23
|
+
end
|
24
|
+
|
25
|
+
##########################
|
26
|
+
##########################
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module FL
|
2
|
+
module MetaHelper
|
3
|
+
|
4
|
+
########################################
|
5
|
+
########################################
|
6
|
+
|
7
|
+
############
|
8
|
+
# Meta #
|
9
|
+
############
|
10
|
+
|
11
|
+
# Meta
|
12
|
+
# => Main meta method
|
13
|
+
def meta type, *args
|
14
|
+
# js css title link keywords author description [robots googlebot msnbot] favicon
|
15
|
+
options = args.join(', ')
|
16
|
+
|
17
|
+
# Return Values
|
18
|
+
#-> SPLAT OPERATOR for multiple "when" cases -- http://stackoverflow.com/a/10197397/1143732
|
19
|
+
case type
|
20
|
+
when :js, :javascript, :javascripts, :script, :scripts
|
21
|
+
javascript_include_tag *args.compact #-> splat operator http://stackoverflow.com/questions/13795627/ruby-send-method-passing-multiple-parameters
|
22
|
+
when :css, :stylesheet, :stylesheets
|
23
|
+
stylesheet_link_tag *args.compact #-> splat operator http://stackoverflow.com/questions/13795627/ruby-send-method-passing-multiple-parameters
|
24
|
+
when :title
|
25
|
+
Haml::Engine.new("%title #{options}").render
|
26
|
+
when :favicon
|
27
|
+
favicon_link_tag
|
28
|
+
when :csrf
|
29
|
+
csrf_meta_tags
|
30
|
+
else
|
31
|
+
Haml::Engine.new("%meta{ name: \"#{type}\", content: \"#{options}\" }").render #-> http://stackoverflow.com/questions/9143761/meta-descritpion-in-haml-with-outside-variable
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
########################################
|
36
|
+
########################################
|
37
|
+
|
38
|
+
# => Title (needs to be more succinct)
|
39
|
+
def title args
|
40
|
+
meta :title, args
|
41
|
+
end
|
42
|
+
|
43
|
+
# => CSS
|
44
|
+
def css *args
|
45
|
+
meta :css, *args
|
46
|
+
end
|
47
|
+
|
48
|
+
# => JS
|
49
|
+
def js *args
|
50
|
+
meta :js, *args
|
51
|
+
end
|
52
|
+
|
53
|
+
# => CSRF
|
54
|
+
def csrf
|
55
|
+
meta :csrf
|
56
|
+
end
|
57
|
+
|
58
|
+
########################################
|
59
|
+
########################################
|
60
|
+
|
61
|
+
# Robots
|
62
|
+
# => http://noarchive.net/meta/
|
63
|
+
def robots *args
|
64
|
+
# => Blank for all true
|
65
|
+
|
66
|
+
# => Possible inputs:
|
67
|
+
# => { index: true, follow: true, nofollow: false, noindex: false }
|
68
|
+
# => :index, :follow, :noindex, :nofollow
|
69
|
+
# => "index", "follow", "noindex", "nofollow"
|
70
|
+
|
71
|
+
# => Inputs
|
72
|
+
# => No input = all
|
73
|
+
# => If true and false are present, only true is passed
|
74
|
+
options = args.extract_options! # => Don't need defaults
|
75
|
+
|
76
|
+
# => Results
|
77
|
+
results = Array.new(2)
|
78
|
+
# No options / args = "index, follow"
|
79
|
+
# First check for one of the following :index, index: true, noindex: false == "index"
|
80
|
+
# Second check for one of the following :follow, follow: true, nofollow: false == "follow"
|
81
|
+
# Third check for one of the following :noindex, noindex: true == "noindex"
|
82
|
+
# Forth check for one of the following :nofollow, nofollow: true == "nofollow"
|
83
|
+
results[0] = "index" if options[:index] || args.include?(:index) || options[:noindex] == false || (options.empty? && args.empty?)
|
84
|
+
results[1] = "follow" if options[:follow] || args.include?(:follow) || options[:nofollow] == false || (options.empty? && args.empty?)
|
85
|
+
results[0] = "noindex" if (options[:noindex] || args.include?(:noindex) || options[:index] == false) && (!args.include?(:index))
|
86
|
+
results[1] = "nofollow" if (options[:nofollow] || args.include?(:nofollow) || options[:follow] == false) && (!args.include?(:follow))
|
87
|
+
|
88
|
+
results.delete_at(0) if (options[:index] == false) && (options[:index] != true || !args.include?(:index))
|
89
|
+
results.delete_at(1) if (options[:follow] == false) && (options[:follow] != true || !args.include?(:follow))
|
90
|
+
|
91
|
+
# => Return
|
92
|
+
# => Options only accepts actual content (array)
|
93
|
+
meta :robots, results.compact.join(",") if results.any?
|
94
|
+
end
|
95
|
+
|
96
|
+
# Favicon
|
97
|
+
# => https://github.com/audreyr/favicon-cheat-sheet
|
98
|
+
# => http://iconhandbook.co.uk/reference/chart/favicons/
|
99
|
+
def favicon img="icons/favicon.ico", *args
|
100
|
+
|
101
|
+
# => Accepts all styles of icon
|
102
|
+
defaults = { "apple-touch-icon" => [57,60,72,76,114,120,144,152,167,180], "icon" => [16,32] }
|
103
|
+
options = args.extract_options!.merge!(defaults) { |key, v1, v2| v1 }
|
104
|
+
|
105
|
+
case options
|
106
|
+
when :all
|
107
|
+
|
108
|
+
when true
|
109
|
+
else
|
110
|
+
meta :favicon, img
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
########################################
|
115
|
+
########################################
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|