lathe 0.0.2 → 0.0.3

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.
data/lib/lathe/cli.rb CHANGED
@@ -31,6 +31,9 @@ module Lathe
31
31
  def now
32
32
  Time.now.strftime("%Y%m%d%H%M%S")
33
33
  end
34
+ def now1
35
+ (Time.now+60).strftime("%Y%m%d%H%M%S")
36
+ end
34
37
  def app_path
35
38
  @app_path
36
39
  end
@@ -1,3 +1,5 @@
1
1
  <div>
2
+ <div class="title">标题:{title}</div>
3
+
2
4
  这是web的展示表单,位置在 app/templates/mini_apps/<%=app_name%>/show.js.dust
3
5
  </div>
@@ -1,3 +1,6 @@
1
1
  <div>
2
+ <input autocomplete="off" class="title "
3
+ name="<%=app_name%>" placeholder="请输入标题"
4
+ type="text">
2
5
  这是mobile的输入表单,位置在 app/templates/mobile/mini_apps/<%=app_name%>/new.js.dust
3
6
  </div>
@@ -1,3 +1,4 @@
1
1
  <div>
2
+ <div>标题:{title}</div>
2
3
  这是mobile的展示表单,位置在 app/templates/mobile/mini_apps/<%=app_name%>/new.js.dust
3
4
  </div>
@@ -9,8 +9,9 @@ jQuery(function($) {
9
9
  return true;
10
10
  },
11
11
  getProperties: function() {
12
+ var self=this;
12
13
  return{
13
-
14
+ title:this.$(".title").val()
14
15
  }
15
16
  //return json data
16
17
  }
@@ -1,13 +1,63 @@
1
- module <%=app_path.camelize%>
1
+ module <%=package%>
2
2
  class <%=app_class%> < MiniApp
3
3
 
4
- def build(story, user)
5
-
4
+ #处理miniapp创建的请求
5
+ # * *Args* :
6
+ # - +properties+ -> 客户端请求的参数,一个hash集合,形如:{title:"my Title"}
7
+ # - +options+ -> 扩展参数
8
+ def build(properties, options={})
9
+ title = properties["title"]
10
+
11
+ model = <%=package%>::<%=app_class%>Model.create(:title=>title)
12
+
13
+ model.save!
14
+ model
6
15
  end
7
16
 
17
+ #处理miniapp修改的请求
18
+ # * *Args* :
19
+ # - +instance+ -> <%=app_class%>Model实例
20
+ # - +current_user+ -> 当前用户对象
21
+ # - +http_action+ -> http请求类型,形如:get post put delete
22
+ # - +proc_name+ -> 更新请求的函数名称,这个需要跟客户端进行约定,如 merge,update等
23
+ # - +properties+ -> 客户端请求的参数,一个hash集合,形如:{title:"my Title"}
24
+ #
25
+ def call_service(instance,current_user, http_action, proc_name, properties)
26
+
27
+ end
28
+
29
+ #通过方法返回主对象
30
+ # * *Args* :
31
+ # - +id+ -> 对象主键id
32
+ # * *Returns* :
33
+ # - <%=app_class%>Model实例
34
+ #
8
35
  def find_instance_by_id(id)
9
- # MiniappStudy::QuestionModel.find_by_id id
36
+ <%=package%>::<%=app_class%>Model.find_by_id id
37
+ end
38
+
39
+
40
+ #建立系统搜索用的索引
41
+ def call_index(instance,options={})
42
+ #package = {:object_id=>instance.id,:description=>instance.title,:created_at=>instance.created_at.to_i,:updated_at=>instance.updated_at.to_i}
10
43
  end
11
-
44
+
45
+ #返回当前miniapp对应的json
46
+ def dump_to_hash(instance)
47
+ {
48
+ :api_url=>"/#{API::prefix}/#{API::versions[0]}/mmodules/<%=app_name%>/#{instance.id}",
49
+ :m_url=>"/mini_apps/<%=app_name%>/#{id}",
50
+ :title=>instance.title
51
+ }
52
+ end
53
+
54
+ #如果当前miniapp的json中还有引用的对象,需要在此方法中进行填充,确保前端通过reference可以查询到这些引用对象
55
+ #如
56
+ def call_references(instance,keep_raw = true)
57
+ result = []
58
+ #result中存放reference对象,对象创建如:Reference.new(:user,u_id)
59
+ #result.concat(instance.user_ids.map {|u_id| Reference.new(:user,u_id) })
60
+ keep_raw ? result : result.uniq.compact
61
+ end
12
62
  end
13
63
  end
@@ -0,0 +1,9 @@
1
+ module <%=package%>
2
+ class <%=app_class%>Model < ActiveRecord::Base
3
+ include Cacheable
4
+
5
+ model_cache do
6
+ with_attribute :id
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class Create<%=package%><%=app_class%>Models < ActiveRecord::Migration
2
+ def change
3
+ create_table :<%=app_path%>_<%=app_name%>_models do |t|
4
+ t.string :title
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
data/lib/lathe/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lathe
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lathe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2013-09-06 00:00:00.000000000 Z
12
+ date: 2013-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -64,12 +64,14 @@ files:
64
64
  - lib/lathe/generators/mini_app/app/helpers/%app_path%/application_helper.rb
65
65
  - lib/lathe/generators/mini_app/app/mailers/.empty_directory
66
66
  - lib/lathe/generators/mini_app/app/models/%app_path%/%app_name%.rb.tt
67
+ - lib/lathe/generators/mini_app/app/models/%app_path%/%app_name%_model.rb.tt
67
68
  - lib/lathe/generators/mini_app/app/views/layouts/%app_path%/.empty_directory
68
69
  - lib/lathe/generators/mini_app/config/.empty_directory
69
70
  - lib/lathe/generators/mini_app/config/locales/fontend.en.yml.tt
70
71
  - lib/lathe/generators/mini_app/config/locales/fontend.zh-CN.yml.tt
71
72
  - lib/lathe/generators/mini_app/config/routes.rb.tt
72
73
  - lib/lathe/generators/mini_app/db/migrate/%now%_add_type_to_%app_path%.rb.tt
74
+ - lib/lathe/generators/mini_app/db/migrate/%now1%_create_%app_path%_%app_name%_models.rb.tt
73
75
  - lib/lathe/generators/mini_app/lib/%app_path%.rb.tt
74
76
  - lib/lathe/generators/mini_app/lib/%app_path%/engine.rb.tt
75
77
  - lib/lathe/generators/mini_app/lib/%app_path%/version.rb.tt