lalala 4.0.0.dev.416 → 4.1.0.dev.299
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +1 -3
- data/Haraway.md +14 -0
- data/app/assets/javascripts/lalala/base.js +8 -0
- data/app/assets/javascripts/lalala/initializers/chosen.module.js +3 -0
- data/app/assets/javascripts/lalala/initializers/haraway.module.js +8 -0
- data/app/assets/javascripts/lalala/lib/overlay.js +335 -0
- data/app/assets/javascripts/lalala/modules/collapsible_pages_tree.module.js +26 -33
- data/app/assets/javascripts/lalala/modules/editor.module.js +37 -23
- data/app/assets/javascripts/lalala/modules/file-uploader-metadata.module.js +248 -0
- data/app/assets/javascripts/lalala/modules/file-uploader.module.js +376 -0
- data/app/assets/javascripts/lalala/modules/init.module.js +1 -5
- data/app/assets/javascripts/lalala/modules/media_selector.module.js +250 -0
- data/app/assets/javascripts/lalala/modules/overlay.module.js +33 -0
- data/app/assets/stylesheets/lalala/_base.css.scss +5 -2
- data/app/assets/stylesheets/lalala/components/_buttons.css.scss +11 -3
- data/app/assets/stylesheets/lalala/components/_forms.css.scss +14 -64
- data/app/assets/stylesheets/lalala/lib/_overlay.css.scss +66 -0
- data/app/assets/stylesheets/lalala/modules/_dashboard.css.scss +10 -51
- data/app/assets/stylesheets/lalala/modules/_editor-cheatsheet.css.scss +1 -17
- data/app/assets/stylesheets/lalala/modules/_file-uploader-metadata.css.scss +118 -0
- data/app/assets/stylesheets/lalala/modules/_file-uploader.css.scss +289 -0
- data/app/assets/stylesheets/lalala/modules/_media-selector.css.scss +113 -0
- data/app/assets/stylesheets/lalala/modules/_title-bar.css.scss +0 -17
- data/app/controllers/lalala/public/errors_controller.rb +7 -0
- data/app/models/lalala/page.rb +0 -1
- data/app/views/lalala/markdown/cheatsheet.html.erb +0 -2
- data/config/routes.rb +12 -1
- data/lalala-assets.gemspec +3 -3
- data/lalala-development.gemspec +1 -1
- data/lalala-test.gemspec +1 -1
- data/lalala.gemspec +4 -5
- data/lib/formtastic/form_builder_ext.rb +10 -0
- data/lib/formtastic/inputs/haraway_input.rb +151 -0
- data/lib/generators/lalala/assets/templates/bower.json.erb +1 -1
- data/lib/generators/lalala/install/install_generator.rb +0 -23
- data/lib/lalala/admin/pages.rb +1 -26
- data/lib/lalala/engine.rb +0 -7
- data/lib/lalala/ext_action_dispatch.rb +0 -1
- data/lib/lalala/ext_active_record/i18n_translations_writer.rb +0 -1
- data/lib/lalala/ext_active_record.rb +0 -1
- data/lib/lalala/ext_i18n/input_helper.rb +0 -1
- data/lib/lalala/ext_i18n/negotiation_adapter.rb +0 -4
- data/lib/lalala/ext_i18n/test_negotiation_adapter.rb +0 -4
- data/lib/lalala/ext_rack/i18n_negotiator.rb +7 -9
- data/lib/lalala/markdown/handlers/asset.rb +24 -0
- data/lib/lalala/markdown/handlers/youtube.rb +9 -13
- data/lib/lalala/markdown/html_renderer.rb +2 -2
- data/lib/lalala/markdown.rb +2 -3
- data/lib/lalala/utils/install_template.rb +3 -9
- data/lib/lalala/version.rb +2 -2
- data/lib/lalala.rb +6 -7
- data/script/ci +33 -30
- data/test/dummy/app/admin/articles.rb +26 -12
- data/test/dummy/app/admin/dashboard.rb +5 -8
- data/test/dummy/app/admin/tags.rb +1 -3
- data/test/dummy/app/assets/stylesheets/_normalize.css +423 -0
- data/test/dummy/app/assets/stylesheets/application.css.scss +2 -0
- data/test/dummy/app/assets/stylesheets/base/_base.css.scss +4 -0
- data/test/dummy/app/controllers/pages_controller.rb +4 -0
- data/test/dummy/app/models/article.rb +10 -4
- data/test/dummy/app/pages/application_page.rb +7 -2
- data/test/dummy/app/pages/basic_page.rb +5 -6
- data/test/dummy/app/pages/home_page.rb +10 -10
- data/test/dummy/app/pages/media_page.rb +23 -0
- data/test/dummy/app/views/admin/_stats.html.erb +7 -14
- data/test/dummy/app/views/layouts/application.html.erb +6 -2
- data/test/dummy/app/views/pages/media.html.erb +3 -0
- data/test/dummy/config/initializers/haraway.rb +29 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/dummy/db/migrate/20130528092721_create_articles.rb +1 -0
- data/test/dummy/db/migrate/20130729125648_create_home_page.rb +4 -0
- data/test/dummy/db/migrate/20131122144302_enable_haraway.rb +16 -0
- data/test/dummy/db/migrate/20140228141749_create_media_page.rb +8 -0
- data/test/dummy/db/schema.rb +2 -4
- data/test/integration/aricles_test.rb +0 -1
- metadata +59 -81
- data/app/assets/javascripts/jquery-ui/sortable.js +0 -0
- data/app/assets/javascripts/lalala/lib/jquery-ui.js +0 -16617
- data/app/assets/javascripts/lalala/modules/grid.module.js +0 -284
- data/app/assets/javascripts/lalala/modules/input_group.module.js +0 -36
- data/app/assets/stylesheets/lalala/modules/_grid.css.scss +0 -197
- data/app/assets/stylesheets/lalala/modules/_index-as-sortable.css.scss +0 -89
- data/app/models/lalala/abstract_asset.rb +0 -24
- data/app/models/lalala/file_asset.rb +0 -3
- data/app/models/lalala/image_asset.rb +0 -3
- data/config/initializers/carrierwave.rb +0 -34
- data/lib/formtastic/inputs/grid_input.rb +0 -159
- data/lib/formtastic/inputs/single_file_input.rb +0 -44
- data/lib/generators/lalala/install/templates/application.html.erb +0 -64
- data/lib/generators/lalala/install/templates/helpers/application_helper.rb +0 -16
- data/lib/generators/lalala/install/templates/helpers/html_helper.rb +0 -60
- data/lib/generators/lalala/install/templates/helpers/open_graph_helper.rb.erb +0 -92
- data/lib/generators/lalala/install/templates/helpers/pages_helper.rb +0 -15
- data/lib/generators/lalala/install/templates/locales/en.yml +0 -6
- data/lib/generators/lalala/install/templates/uploaders/file_uploader.rb +0 -2
- data/lib/generators/lalala/install/templates/uploaders/image_uploader.rb +0 -11
- data/lib/lalala/ext_action_dispatch/multi_file_upload.rb +0 -55
- data/lib/lalala/ext_active_record/assets.rb +0 -25
- data/lib/lalala/markdown/handlers/soundcloud.rb +0 -36
- data/lib/lalala/markdown/handlers/vimeo.rb +0 -40
- data/lib/lalala/uploaders/file.rb +0 -50
- data/lib/lalala/uploaders/image.rb +0 -13
- data/lib/lalala/uploaders.rb +0 -6
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/models/file_asset.rb +0 -2
- data/test/dummy/app/models/image_asset.rb +0 -2
- data/test/dummy/app/uploaders/file_uploader.rb +0 -2
- data/test/dummy/app/uploaders/image_uploader.rb +0 -11
- data/test/dummy/db/migrate/20140926152646_add_pre_and_postpend_test_columns_to_articles.rb +0 -6
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
class Formtastic::Inputs::GridInput
|
|
2
|
-
include Formtastic::Inputs::Base
|
|
3
|
-
|
|
4
|
-
def to_html
|
|
5
|
-
object = builder.object
|
|
6
|
-
assets = object.send(method)
|
|
7
|
-
asset_model_class = builder.object.class.reflect_on_association(method).class_name.constantize
|
|
8
|
-
|
|
9
|
-
# build html
|
|
10
|
-
ul = template.content_tag :ul do
|
|
11
|
-
html = []
|
|
12
|
-
html << Formtastic::Inputs::GridInput.build_assets(assets, asset_model_class, builder, template, method)
|
|
13
|
-
html << Formtastic::Inputs::GridInput.build_errors(assets, asset_model_class, builder, template, method)
|
|
14
|
-
html << Formtastic::Inputs::GridInput.build_actions(assets, asset_model_class, builder, template, method)
|
|
15
|
-
template.raw html.join("")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
input_wrapping { ul }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
#
|
|
24
|
-
# Asset blocks (+ their attributes)
|
|
25
|
-
#
|
|
26
|
-
def self.build_assets(assets, asset_model_class, builder, template, method)
|
|
27
|
-
html = []
|
|
28
|
-
|
|
29
|
-
# collect attribute names
|
|
30
|
-
asset_attributes = asset_model_class.accessible_attributes.to_a
|
|
31
|
-
asset_attributes.select! { |x| x.size > 0 and !%w(asset translations_writer).include?(x) }
|
|
32
|
-
|
|
33
|
-
# build each
|
|
34
|
-
assets.each_with_index do |asset, idx|
|
|
35
|
-
li = template.content_tag :li, class: "asset", title: asset.asset.file.filename do
|
|
36
|
-
builder.fields_for(method, asset) do |f|
|
|
37
|
-
Formtastic::Inputs::GridInput.build_asset(asset, asset_attributes, f, template)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
html << li
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
template.raw(html.join(""))
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def self.build_asset(asset, asset_attributes, f, template)
|
|
50
|
-
html = []
|
|
51
|
-
|
|
52
|
-
# html -> link
|
|
53
|
-
html << Formtastic::Inputs::GridInput.build_asset_link(f, template)
|
|
54
|
-
|
|
55
|
-
# html -> attributes
|
|
56
|
-
html << template.content_tag(:ol, { class: "attributes" }) do
|
|
57
|
-
inputs = asset_attributes.map do |attribute|
|
|
58
|
-
Formtastic::Inputs::GridInput.build_asset_attribute(attribute, f)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
template.raw <<-EOS
|
|
62
|
-
#{inputs.join}
|
|
63
|
-
<a class="close-button">✕</a>
|
|
64
|
-
EOS
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# return
|
|
68
|
-
template.raw(html.join(""))
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
def self.build_asset_link(f, template)
|
|
74
|
-
inner_html = template.raw("")
|
|
75
|
-
filename = f.object.asset.file.filename
|
|
76
|
-
|
|
77
|
-
# get thumbnail
|
|
78
|
-
lalala_thumb = if f.object.asset.respond_to?(:lalala_thumb)
|
|
79
|
-
f.object.asset.lalala_thumb
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# thumbnail or file-icon + filename
|
|
83
|
-
inner_html << if url = lalala_thumb.try(:url)
|
|
84
|
-
template.image_tag(url)
|
|
85
|
-
else
|
|
86
|
-
combo = template.raw("")
|
|
87
|
-
combo << template.content_tag(:span, "", class: "file-icon")
|
|
88
|
-
combo << template.content_tag(:span, filename, class: "filename")
|
|
89
|
-
combo
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# return
|
|
93
|
-
template.link_to(inner_html, f.object.asset.url)
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def self.build_asset_attribute(attribute, f)
|
|
99
|
-
args = [attribute.to_sym]
|
|
100
|
-
collection_name = attribute.chomp("_id").pluralize.to_sym
|
|
101
|
-
|
|
102
|
-
if attribute.include?("_id") && f.object.respond_to?(collection_name)
|
|
103
|
-
args << {
|
|
104
|
-
as: :select,
|
|
105
|
-
collection: f.object.send(collection_name)
|
|
106
|
-
}
|
|
107
|
-
else
|
|
108
|
-
args << {
|
|
109
|
-
placeholder: attribute
|
|
110
|
-
}
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
f.input(*args)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
#
|
|
119
|
-
# Errors
|
|
120
|
-
#
|
|
121
|
-
def self.build_errors(assets, asset_model_class, builder, template, method)
|
|
122
|
-
html = ""
|
|
123
|
-
|
|
124
|
-
asset_errors = assets.map do |asset|
|
|
125
|
-
asset.errors.to_a
|
|
126
|
-
end.flatten
|
|
127
|
-
|
|
128
|
-
if asset_errors.present?
|
|
129
|
-
html = <<-EOS
|
|
130
|
-
<li class="errors">
|
|
131
|
-
<ul>%{items}</ul>
|
|
132
|
-
</li>
|
|
133
|
-
EOS
|
|
134
|
-
|
|
135
|
-
errors_html = template.raw("")
|
|
136
|
-
asset_errors.each do |error|
|
|
137
|
-
errors_html << template.content_tag(:li, error)
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
html.sub("%{items}", errors_html)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
template.raw(html)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
#
|
|
149
|
-
# Actions
|
|
150
|
-
#
|
|
151
|
-
def self.build_actions(assets, asset_model_class, builder, template, method)
|
|
152
|
-
template.content_tag :li, class: "actions" do
|
|
153
|
-
builder.fields_for(method, assets.build) do |f|
|
|
154
|
-
f.file_field :asset, multiple: true, accept: asset_model_class.extension_white_list
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
class Formtastic::Inputs::SingleFileInput
|
|
2
|
-
include Formtastic::Inputs::Base
|
|
3
|
-
|
|
4
|
-
def to_html
|
|
5
|
-
object = builder.object
|
|
6
|
-
model_instance = object.send(method)
|
|
7
|
-
model_class = object.class.reflect_on_association(method).klass
|
|
8
|
-
|
|
9
|
-
html = template.raw("")
|
|
10
|
-
html << label_html
|
|
11
|
-
html << builder.fields_for(method, model_instance || model_class.new) do |f|
|
|
12
|
-
f_html = template.raw("")
|
|
13
|
-
f_html << f.file_field(:asset, accept: model_class.extension_white_list, id: input_html_options[:id])
|
|
14
|
-
if model_instance
|
|
15
|
-
f_html << template.content_tag(:div, class: "delete-button") do
|
|
16
|
-
b_html = template.raw("")
|
|
17
|
-
b_html << f.label(:_destroy, "delete")
|
|
18
|
-
b_html << f.check_box(:_destroy)
|
|
19
|
-
b_html
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
f_html
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
if model_instance
|
|
26
|
-
html << template.content_tag(:div, class: "file-description") do
|
|
27
|
-
filename = model_instance.asset.file.try(:filename)
|
|
28
|
-
f_html = template.raw("")
|
|
29
|
-
|
|
30
|
-
if model_class.to_s.include?("Image")
|
|
31
|
-
f_html << template.content_tag(:img, "", src: model_instance.asset.lalala_thumb.url)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
if filename
|
|
35
|
-
f_html << template.content_tag(:span, filename)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
f_html
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
input_wrapping { html }
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
|
3
|
-
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
|
4
|
-
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
|
5
|
-
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
|
|
6
|
-
<head>
|
|
7
|
-
<meta charset="utf-8">
|
|
8
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
9
|
-
|
|
10
|
-
<title><%= og_title %></title>
|
|
11
|
-
|
|
12
|
-
<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui" />
|
|
13
|
-
|
|
14
|
-
<meta name="description" content="<%= og_description %>" />
|
|
15
|
-
<meta name="distribution" content="global" />
|
|
16
|
-
<%= meta_name_robots %>
|
|
17
|
-
<meta name="revisit-after" content="31 days" />
|
|
18
|
-
<meta name="author" content="" />
|
|
19
|
-
<meta name="publisher" content="Mr. Henry" />
|
|
20
|
-
<meta name="copyright" content="" />
|
|
21
|
-
|
|
22
|
-
<link rel="shortcut icon" href="/assets/favicon.ico"/>
|
|
23
|
-
<link rel="canonical" href="<%= canonical_url(request.original_fullpath) %>" />
|
|
24
|
-
|
|
25
|
-
<meta property="og:url" content="<%= canonical_url(request.original_fullpath) %>" />
|
|
26
|
-
<meta property="og:title" content="<%= og_title %>" />
|
|
27
|
-
<meta property="og:site_name" content="<%= site_name %>">
|
|
28
|
-
<meta property="og:description" content="<%= og_description %>" />
|
|
29
|
-
<%= meta_property_og_image %>
|
|
30
|
-
<meta property="og:image" content="<%= og_image_default_url %>" />
|
|
31
|
-
|
|
32
|
-
<%= javascript_include_tag "modernizr" %>
|
|
33
|
-
<%= stylesheet_link_tag "application", media: "all" %>
|
|
34
|
-
|
|
35
|
-
<%= csrf_meta_tags %>
|
|
36
|
-
</head>
|
|
37
|
-
<body class="<%= body_class %>">
|
|
38
|
-
|
|
39
|
-
<!--[if lt IE 9]>
|
|
40
|
-
<p class="chromeframe" style="background-color: rgb(255,65,45); color: white; font-size: 12px; margin: 0; padding: 7px; text-align: center;">
|
|
41
|
-
You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/" style="color: black;">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true" style="color: black;">activate Google Chrome Frame</a> to improve your experience.</p>
|
|
42
|
-
<![endif]-->
|
|
43
|
-
|
|
44
|
-
<%= yield %>
|
|
45
|
-
|
|
46
|
-
<script type="text/javascript">
|
|
47
|
-
// Bridge between I18n YAML & JS
|
|
48
|
-
window.translations = { };
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<%= javascript_include_tag "application" %>
|
|
52
|
-
|
|
53
|
-
<script type="text/javascript">
|
|
54
|
-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
55
|
-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
56
|
-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
57
|
-
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
58
|
-
|
|
59
|
-
ga('create', 'UA-XXXXXX-XX', 'auto');
|
|
60
|
-
ga('require', 'displayfeatures');
|
|
61
|
-
ga('send', 'pageview');
|
|
62
|
-
</script>
|
|
63
|
-
</body>
|
|
64
|
-
</html>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module ApplicationHelper
|
|
2
|
-
|
|
3
|
-
# When on .mrhenry.eu domain, we don't want a search crawler to index
|
|
4
|
-
#
|
|
5
|
-
# @return {String}
|
|
6
|
-
def meta_name_robots
|
|
7
|
-
if request.host.match /.*\.a\.mrhenry\.eu.*/
|
|
8
|
-
tag("meta", name: "robots", content: "noindex, nofollow")
|
|
9
|
-
|
|
10
|
-
else
|
|
11
|
-
tag("meta", name: "robots", content: "index, follow")
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
end
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module HtmlHelper
|
|
2
|
-
|
|
3
|
-
# Returns class_name if x equals y
|
|
4
|
-
#
|
|
5
|
-
# @param {String} class_name
|
|
6
|
-
# @param {Mixed} x
|
|
7
|
-
# @param {Mixed} y
|
|
8
|
-
# @param {Boolean} exact
|
|
9
|
-
#
|
|
10
|
-
# @return {String}
|
|
11
|
-
def css_class(class_name, x, y = true, exact = false)
|
|
12
|
-
if exact
|
|
13
|
-
class_name if (x === y)
|
|
14
|
-
|
|
15
|
-
else
|
|
16
|
-
class_name if (x == y)
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# Returns CSS body class
|
|
23
|
-
# By default it shows the current controller & action
|
|
24
|
-
# You can add items by using @body_class
|
|
25
|
-
#
|
|
26
|
-
# @return {String}
|
|
27
|
-
def body_class
|
|
28
|
-
body_class = [ params[:controller], params[:action] ]
|
|
29
|
-
body_class << @body_class if @body_class
|
|
30
|
-
body_class.join(" ")
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# Return CSS background-image style
|
|
35
|
-
#
|
|
36
|
-
# @return {String}
|
|
37
|
-
def css_bg_img(img_url = nil)
|
|
38
|
-
"background-image: url('#{img_url}');"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# Includes inline SVG
|
|
43
|
-
#
|
|
44
|
-
# @param {String} path
|
|
45
|
-
#
|
|
46
|
-
# @return {String}
|
|
47
|
-
def inline_svg(path)
|
|
48
|
-
File.open("app/assets/images/#{path}", "rb") do |file|
|
|
49
|
-
raw file.read
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# Render partial
|
|
55
|
-
#
|
|
56
|
-
def render_partial(partial_name, locals={}, &block)
|
|
57
|
-
render partial: partial_name, locals: locals.merge({ block: block })
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
end
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
module OpenGraphHelper
|
|
2
|
-
|
|
3
|
-
# Returns site name
|
|
4
|
-
#
|
|
5
|
-
# @return {String}
|
|
6
|
-
def site_name
|
|
7
|
-
"<%= Rails.application.class.name.split("::").first.titlecase.gsub("Client ", "") %>"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# Returns canonical url and following path for the given key in CANONICAL_URLS hash
|
|
12
|
-
#
|
|
13
|
-
# @params {String} path
|
|
14
|
-
#
|
|
15
|
-
# @return {String}
|
|
16
|
-
def canonical_url(path = '/', protocol = nil)
|
|
17
|
-
protocol ||= request.protocol
|
|
18
|
-
|
|
19
|
-
begin
|
|
20
|
-
"#{protocol}#{ENV["CANONICAL_DOMAIN"]}#{path}"
|
|
21
|
-
|
|
22
|
-
rescue
|
|
23
|
-
Rails.logger.error("canonical_url failed with following argument: #{path}")
|
|
24
|
-
"#{protocol}#{request.domain}#{path}"
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# Returns meta description.
|
|
31
|
-
# Default lives in locale file. Add @og_description in your controller
|
|
32
|
-
# to override default.
|
|
33
|
-
#
|
|
34
|
-
# @return {String}
|
|
35
|
-
def og_description
|
|
36
|
-
@og_description.strip_tags rescue t("meta.description")
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# Returns default OG image url based on current app name
|
|
41
|
-
#
|
|
42
|
-
# @return {String}
|
|
43
|
-
def og_image_default_url
|
|
44
|
-
"#{request.protocol}#{request.host_with_port}#{image_path("og-image.png")}"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# Returns meta og:image tags when @og_image(s) is given
|
|
49
|
-
#
|
|
50
|
-
# @return {String}
|
|
51
|
-
def meta_property_og_image
|
|
52
|
-
if @og_image
|
|
53
|
-
tag("meta", property: "og:image", content: "http:#{@og_image.url(:medium)}")
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
if @og_images
|
|
57
|
-
@og_images.each do |og_image|
|
|
58
|
-
tag("meta", property: "og:image", content: "http:#{og_image.url(:medium)}")
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
# Returns the page title, build upon the current page chain, separated by |
|
|
65
|
-
# To prefix, use @og_title in your controller.
|
|
66
|
-
#
|
|
67
|
-
# @param {Integer} offset How many page chain levels you want to skip
|
|
68
|
-
#
|
|
69
|
-
# @return {String}
|
|
70
|
-
def og_title(offset = 0)
|
|
71
|
-
page_title = []
|
|
72
|
-
|
|
73
|
-
if @og_title
|
|
74
|
-
if offset > 0
|
|
75
|
-
offset -= 1
|
|
76
|
-
else
|
|
77
|
-
page_title << @og_title
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
current_page_chain.reverse.each_with_index do |page, idx|
|
|
82
|
-
next if idx < offset
|
|
83
|
-
|
|
84
|
-
page_title << page.title unless page.type == "HomePage"
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
page_title << site_name
|
|
88
|
-
|
|
89
|
-
page_title.join(' | ')
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module PagesHelper
|
|
2
|
-
|
|
3
|
-
# Returns page by class name & puts it in an instance variable
|
|
4
|
-
#
|
|
5
|
-
# @param {Class} page_class
|
|
6
|
-
#
|
|
7
|
-
# @return {ApplicationPage}
|
|
8
|
-
def get_page(page_class)
|
|
9
|
-
key = "@#{page_class.to_s.underscore.to_sym}"
|
|
10
|
-
|
|
11
|
-
page = instance_variable_get(key)
|
|
12
|
-
page ||= instance_variable_set(key, page_class.first)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
end
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
module Lalala::ExtActionDispatch::MultiFileUpload
|
|
2
|
-
|
|
3
|
-
private
|
|
4
|
-
|
|
5
|
-
def normalize_parameters(value)
|
|
6
|
-
value = super(value)
|
|
7
|
-
|
|
8
|
-
if Hash === value
|
|
9
|
-
value.each do |key, v|
|
|
10
|
-
value[key] = correct_assets_hash_nesting(key, v)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
return value
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def correct_assets_hash_nesting(key, value)
|
|
18
|
-
unless key.to_s.ends_with?("_attributes")
|
|
19
|
-
return value
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
unless Hash === value
|
|
23
|
-
return value
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
if value.size == 0
|
|
27
|
-
return value
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
last_id = value.keys.sort_by(&:to_i).last
|
|
31
|
-
last_id = "#{last_id}"
|
|
32
|
-
|
|
33
|
-
unless /^\d+$/ === last_id
|
|
34
|
-
return value
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
assets = value[last_id].try(:[], "asset")
|
|
38
|
-
|
|
39
|
-
unless Array === assets
|
|
40
|
-
return value
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
unless assets.all?{ |i| ActionDispatch::Http::UploadedFile === i }
|
|
44
|
-
return value
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
assets.each do |file|
|
|
48
|
-
value[last_id] = { "asset" => file }.with_indifferent_access
|
|
49
|
-
last_id.succ!
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
return value
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Lalala::ExtActiveRecord::Assets
|
|
2
|
-
extend ActiveSupport::Concern
|
|
3
|
-
|
|
4
|
-
module ClassMethods
|
|
5
|
-
|
|
6
|
-
def has_many_assets(name, options={})
|
|
7
|
-
class_name = options.delete(:class_name)
|
|
8
|
-
class_name ||= if name.to_s.include?("image") then "::ImageAsset" else "::FileAsset" end
|
|
9
|
-
|
|
10
|
-
attr_accessible :"#{name}_attributes"
|
|
11
|
-
has_many name, class_name: class_name, as: :asset_owner, dependent: :destroy, conditions: { asset_owner_section: name.to_s }
|
|
12
|
-
accepts_nested_attributes_for name, allow_destroy: true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def has_one_asset(name, options={})
|
|
16
|
-
class_name = options.delete(:class_name)
|
|
17
|
-
class_name ||= if name.to_s.include?("image") then "::ImageAsset" else "::FileAsset" end
|
|
18
|
-
|
|
19
|
-
attr_accessible :"#{name}_attributes"
|
|
20
|
-
has_one name, class_name: class_name, as: :asset_owner, dependent: :destroy, conditions: { asset_owner_section: name.to_s }
|
|
21
|
-
accepts_nested_attributes_for name, allow_destroy: true
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
class Lalala::Markdown::Handlers::Soundcloud < Lalala::Markdown::Handlers::Base
|
|
2
|
-
|
|
3
|
-
def initialize(options={})
|
|
4
|
-
options.assert_valid_keys(:width, :height)
|
|
5
|
-
|
|
6
|
-
options = {
|
|
7
|
-
width: 560,
|
|
8
|
-
height: 166
|
|
9
|
-
}.merge(options)
|
|
10
|
-
|
|
11
|
-
@options = options
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def image(url, alt=nil, title=nil)
|
|
15
|
-
unless %r|^soundcloud[:]//(.+)$| === url
|
|
16
|
-
return ""
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
id = $1
|
|
20
|
-
|
|
21
|
-
helpers.content_tag :span, class: "embed-container is-soundcloud" do
|
|
22
|
-
helpers.content_tag(
|
|
23
|
-
:iframe,
|
|
24
|
-
"",
|
|
25
|
-
class: "soundcloud-embed js-soundcloud-embed",
|
|
26
|
-
width: @options[:width],
|
|
27
|
-
height: @options[:height],
|
|
28
|
-
src: "//w.soundcloud.com/player/?auto_play=false&hide_related=true&show_comments=false&show_user=false&show_reposts=false&visual=false",
|
|
29
|
-
:"data-url" => "https://soundcloud.com/oembed?format=json&url=https://soundcloud.com/#{id}",
|
|
30
|
-
frameborder: 0,
|
|
31
|
-
allowfullscreen: true
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
class Lalala::Markdown::Handlers::Vimeo < Lalala::Markdown::Handlers::Base
|
|
2
|
-
|
|
3
|
-
def initialize(options={})
|
|
4
|
-
options.assert_valid_keys(:color, :height, :show_badge, :show_byline, :show_portrait, :show_title, :width)
|
|
5
|
-
|
|
6
|
-
options = {
|
|
7
|
-
color: "ffffff",
|
|
8
|
-
height: 315,
|
|
9
|
-
show_badge: 0,
|
|
10
|
-
show_byline: 0,
|
|
11
|
-
show_portrait: 0,
|
|
12
|
-
show_title: 0,
|
|
13
|
-
width: 560
|
|
14
|
-
}.merge(options)
|
|
15
|
-
|
|
16
|
-
@options = options
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def image(url, alt=nil, title=nil)
|
|
20
|
-
unless %r|^vimeo[:]//(.+)$| === url
|
|
21
|
-
return ""
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
id = $1
|
|
25
|
-
|
|
26
|
-
helpers.content_tag :span, class: "embed-container is-vimeo" do
|
|
27
|
-
helpers.content_tag(
|
|
28
|
-
:iframe,
|
|
29
|
-
"",
|
|
30
|
-
width: @options[:width],
|
|
31
|
-
height: @options[:height],
|
|
32
|
-
src: "//player.vimeo.com/video/#{id}?portrait=#{@options[:show_portrait]}&title=#{@options[:show_title]}&badge=#{@options[:show_badge]}&byline=#{@options[:show_byline]}&color=#{@options[:color]}&wmode=transparent",
|
|
33
|
-
|
|
34
|
-
frameborder: 0,
|
|
35
|
-
allowfullscreen: true
|
|
36
|
-
)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
class Lalala::Uploaders::File < CarrierWave::Uploader::Base
|
|
2
|
-
|
|
3
|
-
def store_dir
|
|
4
|
-
if Rails.env.production? or Rails.env.staging?
|
|
5
|
-
"#{model.class.to_s.underscore}/#{model.id}"
|
|
6
|
-
else
|
|
7
|
-
"uploads/#{model.class.to_s.underscore}/#{model.id}"
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def url(*)
|
|
12
|
-
super_url = super
|
|
13
|
-
if Rails.env.production? or Rails.env.staging?
|
|
14
|
-
if super_url
|
|
15
|
-
if super_url.starts_with?('/storage/assets')
|
|
16
|
-
super_url
|
|
17
|
-
else
|
|
18
|
-
AssetURL.new(File.join("/storage/assets", super_url))
|
|
19
|
-
end
|
|
20
|
-
else
|
|
21
|
-
super_url
|
|
22
|
-
end
|
|
23
|
-
else
|
|
24
|
-
super_url
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# This class circumvents the Sprockets asset path rewriting
|
|
29
|
-
# by pretending that it is a full URL.
|
|
30
|
-
#
|
|
31
|
-
# @see
|
|
32
|
-
# https://mrhenry.basecamphq.com/projects/10235776-hetpaleis/todo_items/164031435/comments (internal)
|
|
33
|
-
# http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag
|
|
34
|
-
# http://apidock.com/rails/v3.2.13/ActionView/Helpers/AssetTagHelper/path_to_image
|
|
35
|
-
# http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_path
|
|
36
|
-
# http://apidock.com/rails/ActionView/AssetPaths/compute_public_path
|
|
37
|
-
# http://apidock.com/rails/v3.2.13/ActionView/AssetPaths/is_uri%3F
|
|
38
|
-
class AssetURL < String
|
|
39
|
-
|
|
40
|
-
def to_s
|
|
41
|
-
self
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def =~(pattern)
|
|
45
|
-
return true
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
end
|