toronto 0.0.2 → 0.0.3

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: 1f543ee308526522fb360af9f2964ad1b76baede
4
- data.tar.gz: e55ba83c0b1de7275c79c41251d61ac459e2593e
3
+ metadata.gz: fc86ef95f32e371597fa9a8ef03e6cee559ec574
4
+ data.tar.gz: 021a63731b9e21901560d8531374c025c7a4f004
5
5
  SHA512:
6
- metadata.gz: 459e93d8873397c5b20482a5321b4cde84fb245bd9a1ccff081037c71a21beb4f05a003c9bccab85b2ccf84409c4f03e8400a749df821c54eb418a7a3d034a49
7
- data.tar.gz: 6f3f0faee3fc9f0151a92eb83dc4887a6f698cd99ec9d65085db1e5eda2a8ddd271b063d564498dbfc21d905e5d14b384ed23a2d0e67c9dd061cee1dd086c4f0
6
+ metadata.gz: 6cc1a08d590d87841dbc706767b9713db7befa06ece9dfbcf8f7f269a1993d1377b1c03701d1b6bdae69c25300d1ce9c8a6d191533270eb2754f7d5666fc97df
7
+ data.tar.gz: e47e69e24e0676339517c2913de878fb9bc33c8d94a8a9e34f04836b235e1cd16b98918918dc5c77bb83505e33d4fcebf1ca0c1a7af3d3e61cc8793a377c1c22
@@ -44,7 +44,9 @@ module Toronto
44
44
  def copy_locale_files
45
45
  copy_file 'config/initializers/locales.rb', 'config/initializers/locales.rb'
46
46
  copy_file 'controllers/locales_controller.rb', 'app/controllers/locales_controller.rb'
47
+ end
47
48
 
49
+ def patch_locale_files
48
50
  # TODO : use a template file
49
51
  data = %{
50
52
  def set_locale
@@ -54,7 +56,6 @@ module Toronto
54
56
  insert_into_file 'app/controllers/application_controller.rb', data, :before => /^end/
55
57
 
56
58
  data = "\n before_action :set_locale"
57
-
58
59
  insert_into_file 'app/controllers/application_controller.rb', data, :after => /^class ApplicationController < ActionController::Base/
59
60
  end
60
61
 
@@ -6,7 +6,9 @@
6
6
  %meta{content: 'width=device-width, initial-scale=1', name: 'viewport' }
7
7
  %meta{content: '', name: 'description' }
8
8
  %meta{content: '', name: 'author' }
9
- %title Starter Template for Bootstrap
9
+ %title
10
+ -# TODO : replace by a static string
11
+ = Rails.application.class.parent_name
10
12
 
11
13
  / HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries
12
14
  /[if lt IE 9]
@@ -29,15 +31,10 @@
29
31
  %span.icon-bar
30
32
  %span.icon-bar
31
33
  %span.icon-bar
32
- = link_to "Project name", "#", class: "navbar-brand"
34
+ -# TODO : replace by a static string
35
+ = link_to Rails.application.class.parent_name, '/', class: "navbar-brand"
33
36
  #navbar.collapse.navbar-collapse
34
37
  %ul.nav.navbar-nav
35
- %li.active
36
- = nav_link( 'Home', '#' )
37
- %li
38
- = nav_link( 'About', '#about' )
39
- %li
40
- = nav_link( 'Contact', '#contact' )
41
38
  #flags-area
42
39
  = link_to '/set_locale/en', method: :put do
43
40
  %span{ class: 'flag flag-gb' }
@@ -11,13 +11,31 @@ module Haml
11
11
  filename = filename_with_extensions(view)
12
12
  template "#{view}.html.haml", File.join("app/views", controller_file_path, filename)
13
13
  end
14
+ end
14
15
 
16
+ def copy_and_update_languages_files
15
17
  languages = %w( en fr )
16
18
 
17
19
  languages.each do |lang|
18
- template "#{lang}.yml", File.join( 'config/locales', lang, "#{name.downcase.pluralize}.yml" )
19
- end
20
+ yaml_path = File.join( 'config/locales', lang, "#{plural_table_name}.yml" )
21
+ template "#{lang}.yml", yaml_path
22
+
23
+ attributes_json = {}
24
+ attributes.each do |attribute|
25
+ attributes_json[ attribute.name ] = attribute.name.humanize
26
+ end
20
27
 
28
+ yaml_content = YAML.load( File.open( yaml_path ).read )
29
+ yaml_content[ lang ][ 'helpers' ] = {}
30
+ yaml_content[ lang ][ 'helpers' ][ 'label' ] = {}
31
+ yaml_content[ lang ][ 'helpers' ][ 'label' ][ singular_table_name ] = attributes_json
32
+
33
+ yaml_content[ lang ][ plural_table_name ][ 'menu_title' ] = name
34
+
35
+ File.open( yaml_path, 'w' ) do |f|
36
+ f.write( YAML.dump( yaml_content ) )
37
+ end
38
+ end
21
39
  end
22
40
 
23
41
  hook_for :form_builder, :as => :scaffold
@@ -32,8 +50,8 @@ module Haml
32
50
  def add_menu
33
51
  data = %{
34
52
  %li
35
- = nav_link( '#{name.humanize.pluralize}', #{name.underscore.pluralize}_path )}
36
- insert_into_file 'app/views/layouts/application.html.haml', data, :after => "= nav_link( 'Home', '#' )"
53
+ = nav_link( t( '#{plural_table_name}.menu_title' ), #{plural_table_name}_path )}
54
+ insert_into_file 'app/views/layouts/application.html.haml', data, :after => '%ul.nav.navbar-nav'
37
55
  end
38
56
 
39
57
  protected
@@ -9,7 +9,7 @@
9
9
  %thead
10
10
  %tr
11
11
  <% for attribute in attributes -%>
12
- %th= <%= "t( '." + attribute.name + "')" %>
12
+ %th= <%= "t( 'helpers.label.#{singular_table_name}.#{attribute.name}' )" %>
13
13
  <% end -%>
14
14
  %th
15
15
  %th
@@ -9,10 +9,10 @@
9
9
 
10
10
  %dl.dl-horizontal
11
11
  <%- for attribute in attributes -%>
12
- %dt= <%= "t( '." + attribute.name + "')" %> + ' :'
12
+ %dt= <%= "t( 'helpers.label.#{singular_table_name}.#{attribute.name}' )" %> + ' :'
13
13
  <% if attribute.type == :references %>
14
14
  %dd= @<%= singular_table_name %>.<%= attribute.name %>.name
15
15
  <% else %>
16
16
  %dd= @<%= singular_table_name %>.<%= attribute.name %>
17
17
  <% end %>
18
- <%- end -%>
18
+ <%- end -%>
@@ -1,3 +1,3 @@
1
1
  module Toronto
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/toronto.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'rake'
25
25
  # spec.add_development_dependency 'haml-rails', '>= 0.9.0'
26
26
 
27
- spec.add_runtime_dependency 'railties', '>= 3.1.0'
27
+ spec.add_runtime_dependency 'railties', '~> 3.1'
28
28
  # spec.add_runtime_dependency 'haml-rails', '>= 0.9.0'
29
29
 
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toronto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cédric Zuger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: railties
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 3.1.0
47
+ version: '3.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 3.1.0
54
+ version: '3.1'
55
55
  description: This is a fork of Twitter Bootstrap generators where static fields are
56
56
  translated fields.
57
57
  email: