lalala 4.0.0.dev.372 → 4.0.0.dev.374

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f393d8585145e5e6fe97370c220369d2df74b2ab
4
- data.tar.gz: ec17150c0df816cb28deb5d6fc03647fe7fdbc66
3
+ metadata.gz: 1306f4cd947f27b96f79a64b73bf44946a096c24
4
+ data.tar.gz: 501c70e5a5ab1a4f297f1d50ba4fbf0baafffdf8
5
5
  SHA512:
6
- metadata.gz: 8f9380cfc531b77f532a5b1256b7a4bc2c9d1d6e52e78078d43a9c571879f105abe9061cbcd00693213e550e51a068e0999e2c534cf9a67c13a98c11a3e70b7b
7
- data.tar.gz: a24e369858434e5c5d43cd4902ebcd986350162716d1f317557f63bc691ff57d7e7a3996cbc7dc889b92fe71905f10e43702afdc6712c03210adf66cf1d9fed6
6
+ metadata.gz: dafc99c2cdec7e206d19ce5627c2d1c8002dc35d077c6c7319aa5b0d75c02598507920630f9b7b43d5d6855ba06973c37e1566624d2e926be01c47d2592566e3
7
+ data.tar.gz: 1ec4df9b7f58cfbca81f6b049db818cd8534da5f67647e22bfc4a9616fa94b7c07ddc48d5c4d3126dbcc3a59d1d13d59bc928425e3d4e7ebc8e4e1c6689aee89
@@ -4,7 +4,7 @@
4
4
  "version": "0.0.1",
5
5
  "main": "javascripts/application.js",
6
6
  "dependencies": {
7
- "jquery": "~1.10.2",
7
+ "jquery": "~1",
8
8
  "modernizr": "~2.7.1",
9
9
  "respond": "~1.4.2",
10
10
  "normalize-scss": "~2.1.3"
@@ -71,6 +71,19 @@ module Lalala
71
71
  gsub_file "config/environments/production.rb", " # config.assets.precompile += %w( search.js )", " config.assets.precompile += %w( modernizr.js )"
72
72
  end
73
73
 
74
+ def setup_helpers
75
+ empty_directory "app/helpers"
76
+ copy_file "helpers/application_helper.rb", "app/helpers/application_helper.rb"
77
+ template "helpers/open_graph_helper.rb.erb", "app/helpers/open_graph_helper.rb"
78
+ copy_file "helpers/html_helper.rb", "app/helpers/html_helper.rb"
79
+ copy_file "helpers/pages_helper.rb", "app/helpers/pages_helper.rb"
80
+ end
81
+
82
+ def setup_locales
83
+ empty_directory 'config/locales'
84
+ copy_file 'locales/en.yml', 'config/locales/en.yml'
85
+ end
86
+
74
87
  def setup_forklift
75
88
  empty_directory ".forklift"
76
89
  end
@@ -7,38 +7,42 @@
7
7
  <meta charset="utf-8">
8
8
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9
9
 
10
- <title></title>
10
+ <title><%= og_title %></title>
11
11
 
12
12
  <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui" />
13
13
 
14
14
  <meta name="description" content="<%= og_description %>" />
15
15
  <meta name="distribution" content="global" />
16
- <% if request.host.match /.*\.a\.mrhenry\.eu.*/ %>
17
- <meta name="robots" content="noindex, nofollow" />
18
- <% else %>
19
- <meta name="robots" content="index, follow" />
20
- <% end %>
16
+ <%= meta_name_robots %>
21
17
  <meta name="revisit-after" content="31 days" />
22
18
  <meta name="author" content="" />
23
19
  <meta name="publisher" content="Mr. Henry" />
24
20
  <meta name="copyright" content="" />
25
21
 
26
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 %>" />
27
31
 
28
32
  <%= javascript_include_tag "modernizr" %>
29
33
  <%= stylesheet_link_tag "application", media: "all" %>
30
34
 
31
35
  <%= csrf_meta_tags %>
32
36
  </head>
33
- <body>
37
+ <body class="<%= body_class %>">
34
38
 
35
39
  <!--[if lt IE 9]>
36
40
  <p class="chromeframe" style="background-color: rgb(255,65,45); color: white; font-size: 12px; margin: 0; padding: 7px; text-align: center;">
37
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>
38
42
  <![endif]-->
39
-
43
+
40
44
  <%= yield %>
41
-
45
+
42
46
  <script type="text/javascript">
43
47
  // Bridge between I18n YAML & JS
44
48
  window.translations = { };
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,60 @@
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
@@ -0,0 +1,92 @@
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
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,6 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ meta:
6
+ description: ""
@@ -5,6 +5,12 @@ class AppBuilder < Rails::AppBuilder
5
5
  RUBY_VERSION = "2.0.0"
6
6
  LALALA_VERSION = "4.0.0.dev"
7
7
 
8
+ # You can test the generator locally by pointing to your local gems:
9
+ #
10
+ # gem 'lalala', path: "~/Github/mrhenry/lalala-ng"
11
+ # gem 'lalala-development', path: "~/Github/mrhenry/lalala-ng", groups: [:development]
12
+ # gem 'lalala-assets', path: "~/Github/mrhenry/lalala-ng", groups: [:development, :assets]
13
+ # gem 'lalala-test', path: "~/Github/mrhenry/lalala-ng", groups: [:test]
8
14
  def gemfile
9
15
  create_file 'Gemfile', <<-DOC
10
16
 
@@ -1,6 +1,6 @@
1
1
  module Lalala
2
2
  VERSION = "4.0.0"
3
- BUILD = "372"
3
+ BUILD = "374"
4
4
 
5
5
  if BUILD != ("{{BUILD_NUMBER" + "}}") # prevent sed replacement (see script/ci)
6
6
  BUILD_VERSION = "#{VERSION}.dev.#{BUILD}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lalala
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.dev.372
4
+ version: 4.0.0.dev.374
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-11-04 00:00:00.000000000 Z
16
+ date: 2014-11-05 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activeadmin
@@ -1421,6 +1421,11 @@ files:
1421
1421
  - lib/generators/lalala/install/templates/dashboard.rb
1422
1422
  - lib/generators/lalala/install/templates/devise.rb.erb
1423
1423
  - lib/generators/lalala/install/templates/errors_controller.rb
1424
+ - lib/generators/lalala/install/templates/helpers/application_helper.rb
1425
+ - lib/generators/lalala/install/templates/helpers/html_helper.rb
1426
+ - lib/generators/lalala/install/templates/helpers/open_graph_helper.rb.erb
1427
+ - lib/generators/lalala/install/templates/helpers/pages_helper.rb
1428
+ - lib/generators/lalala/install/templates/locales/en.yml
1424
1429
  - lib/generators/lalala/install/templates/models/admin_user.rb
1425
1430
  - lib/generators/lalala/install/templates/models/application_page.rb
1426
1431
  - lib/generators/lalala/install/templates/models/file_asset.rb