jt-mobile-kit-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,11 +8,7 @@
8
8
  %title Title
9
9
  %link(rel="stylesheet" href="lib/js/jquery/jquery.mobile-1.2.0.min.css")
10
10
 
11
- %script(type="text/javascript" src="lib/js/cordova/cordova-2.1.0.js")
12
- %script(type="text/javascript" src="lib/js/jquery/jquery-1.8.2.min.js")
13
- %script(type="text/javascript" src="lib/js/jquery/jquery.mobile-1.2.0.min.js")
14
-
15
- %script(type="text/javascript" src="js/pages.js")
11
+ =include_js
16
12
  %body
17
13
  =render 'pages'
18
14
  %script(lang="javascript" src="js/application.js")
@@ -1,10 +1,28 @@
1
1
  require 'generators/jt'
2
+ require 'rails/generators/generated_attribute'
2
3
 
3
4
  module Jt
4
5
  module Generators
5
6
  class ScaffoldGenerator < Base
6
7
  #desc "This generator test gem generator"
7
8
  argument :scaffold_name, :type => :string, :required => true, :banner => 'ModelName'
9
+ argument :args_for_c_m, :type => :array, :default => [], :banner => 'controller_actions and model:attributes'
10
+
11
+ def initialize(*args, &block)
12
+ super
13
+
14
+ print_usage unless scaffold_name.underscore =~ /^[a-z][a-z0-9_\/]+$/
15
+
16
+ @model_attributes = []
17
+
18
+ args_for_c_m.each do |arg|
19
+ if arg.include?(':')
20
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
21
+ end
22
+ end
23
+ puts @model_attributes
24
+ end
25
+
8
26
  def template_root
9
27
  @_template_root ||= File.expand_path('../templates', __FILE__)
10
28
  end
@@ -17,6 +35,8 @@ module Jt
17
35
  def create_domain_page
18
36
  content = File.read "#{template_root}/_page.haml"
19
37
  content = content.gsub "@{scaffold_name}", scaffold_name
38
+ @model_attributes.map { |a| content +="\n = text_input name:\"#{a.name}\"" }
39
+
20
40
  create_file "public/mobile/_#{scaffold_name}_page.haml", content
21
41
  end
22
42
 
@@ -26,6 +46,23 @@ module Jt
26
46
  create_file "public/mobile/_#{scaffold_name}_list_page.haml", content
27
47
  end
28
48
 
49
+ def define_go_to_page
50
+ insert_into_file "public/mobile/js/pages.js", "__define_go_to_page([\"#{scaffold_name}\", \"#{scaffold_name}_list\"])", {:after => "// pages"}
51
+ end
52
+
53
+ #def define_md_class
54
+ # content = File.read "#{template_root}/md_class.js"
55
+ # content = content.gsub "@{scaffold_name}", scaffold_name
56
+ # content = content.gsub "@{restful_url}", "/#{scaffold_name}/:id.json"
57
+ # create_file "public/mobile/js/#{scaffold_name}.js", content
58
+ #end
59
+ #
60
+ #def define_page_md_class
61
+ # content = File.read "#{template_root}/md_class.js"
62
+ # content = content.gsub "@{scaffold_name}", scaffold_name
63
+ # content = content.gsub "@{restful_url}", "/#{scaffold_name}.json"
64
+ # create_file "public/mobile/js/#{scaffold_name}.js", content
65
+ #end
29
66
  end
30
67
  end
31
68
  end
@@ -0,0 +1,9 @@
1
+ __define_mdclass("@{scaffold_name}", '@{restful_url}');
2
+
3
+ @{scaffold_name}.prototype.specific_property = function (send_string_object) {
4
+
5
+ }
6
+
7
+ @{scaffold_name}.prototype.refresh_view = function (data) {
8
+
9
+ }
@@ -0,0 +1,9 @@
1
+ __define_page_mdclass("@{scaffold_name}", '@{restful_url}');
2
+
3
+ @{scaffold_name}.prototype.specific_property = function (send_string_object) {
4
+
5
+ }
6
+
7
+ @{scaffold_name}.prototype.refresh_view = function (data) {
8
+
9
+ }
@@ -2,7 +2,7 @@ module Jt
2
2
  module Mobile
3
3
  module Kit
4
4
  module Rails
5
- VERSION = "0.0.4"
5
+ VERSION = "0.0.5"
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jt-mobile-kit-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-12 00:00:00.000000000 Z
12
+ date: 2012-11-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: generate jt-mobile-kit in rails app
15
15
  email:
@@ -56,6 +56,8 @@ files:
56
56
  - lib/generators/jt/scaffold/scaffold_generator.rb
57
57
  - lib/generators/jt/scaffold/templates/_list_page.haml
58
58
  - lib/generators/jt/scaffold/templates/_page.haml
59
+ - lib/generators/jt/scaffold/templates/md_class.js
60
+ - lib/generators/jt/scaffold/templates/md_list_class.js
59
61
  - lib/jt-mobile-kit-rails/version.rb
60
62
  homepage: ''
61
63
  licenses: []