jinda 0.5.1 → 0.5.6

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/lib/generators/jinda/install_generator.rb +6 -0
  4. data/lib/generators/jinda/templates/README.md +1 -1
  5. data/lib/generators/jinda/templates/app/assets/stylesheets/app.scss +11 -5
  6. data/lib/generators/jinda/templates/app/assets/stylesheets/articles.scss +16 -6
  7. data/lib/generators/jinda/templates/app/controllers/concerns/jinda_general_concern.rb +179 -0
  8. data/lib/generators/jinda/templates/app/controllers/concerns/jinda_run_concern.rb +365 -0
  9. data/lib/generators/jinda/templates/app/controllers/jinda_org/docs_controller.rb +56 -0
  10. data/lib/generators/jinda/templates/app/controllers/jinda_org/jinda_controller.rb +29 -573
  11. data/lib/generators/jinda/templates/app/controllers/jinda_org/notes_controller.rb +6 -8
  12. data/lib/generators/jinda/templates/app/jinda/index.mm +71 -23
  13. data/lib/generators/jinda/templates/app/jinda/template/view.html.erb +22 -23
  14. data/lib/generators/jinda/templates/app/models/jinda/doc.rb +5 -0
  15. data/lib/generators/jinda/templates/app/views/articles/new_article/form_article.html.erb +5 -3
  16. data/lib/generators/jinda/templates/app/views/docs/doc_edit/doc_edit.html.erb +21 -0
  17. data/lib/generators/jinda/templates/app/views/docs/doc_edit/doc_select.html.erb +14 -0
  18. data/lib/generators/jinda/templates/app/views/docs/doc_new/doc_form.html.erb +26 -0
  19. data/lib/generators/jinda/templates/app/views/docs/doc_new/doc_form.md +36 -0
  20. data/lib/generators/jinda/templates/app/views/docs/doc_xedit/doc_edit.html.erb +21 -0
  21. data/lib/generators/jinda/templates/app/views/docs/edit/select_note.html.erb +14 -0
  22. data/lib/generators/jinda/templates/app/views/docs/index.haml +21 -0
  23. data/lib/generators/jinda/templates/app/views/docs/my.haml +27 -0
  24. data/lib/generators/jinda/templates/app/views/jinda/index.html.haml +3 -3
  25. data/lib/generators/jinda/templates/app/views/jinda/run_output.haml +3 -3
  26. data/lib/generators/jinda/templates/app/views/layouts/_head.html.erb +7 -10
  27. data/lib/generators/jinda/templates/app/views/layouts/{_metatag.html.erb → _meta_tag.html.erb} +0 -0
  28. data/lib/generators/jinda/templates/app/views/layouts/jqm/_full.haml +1 -9
  29. data/lib/generators/jinda/templates/app/views/notes/new/new_note.html.erb +1 -1
  30. data/lib/jinda/helpers.rb +201 -57
  31. data/lib/jinda/version.rb +1 -1
  32. metadata +16 -11
  33. data/lib/generators/jinda/templates/app/controllers/ctrs_controller.rb-gem-test +0 -2
  34. data/lib/generators/jinda/templates/app/views/layouts/_meta_tags.html.erb +0 -5
  35. data/lib/generators/jinda/templates/app/views/new.html.erb +0 -7
  36. data/lib/jinda/ template/view.html.erb +0 -25
  37. data/lib/jinda/app/jinda/index.mm +0 -308
  38. data/lib/jinda/app/jinda/template/view.html.erb +0 -27
@@ -0,0 +1,21 @@
1
+ - @title= "My Articles"
2
+ %p
3
+ - @page_title = 'All Articlces'
4
+ = paginate @articles
5
+ %table#article-table
6
+ %tr
7
+ %th Title
8
+ %th Description
9
+ %th Created
10
+ %th Updated
11
+ %th Delete
12
+ %th Edit
13
+ - @articles.each do |article|
14
+ %tr
15
+ %td= link_to article.title, :controller=>"articles", :action=>"show", :id=>article.id
16
+ %td= article.text.html_safe
17
+ %td= article.created_at.strftime('%m/%d/%Y')
18
+ %td= article.updated_at.strftime('%m/%d/%Y')
19
+ %td(align='center')= link_to image_tag('delete.png', style:'border:none; float:none;'), "#", :onclick=>"if (confirm('Please Confirm')) {location.hash='/articles/destroy/#{article.id}';}"
20
+ %td(align='center')= link_to image_tag('pencil.png', style:'border:none; float:none;'), {controller: "jinda", action: "init", s: 'articles:xedit_article', article_id: article.id}, data: { confirm: "Please Confirm" }
21
+
@@ -0,0 +1,27 @@
1
+ - @title= "My Documents"
2
+ %p
3
+ - @page_title = 'All Documents'
4
+ = paginate @docs
5
+ %table#document-table
6
+ %tr
7
+ %th File Name
8
+ %th Description
9
+ %th Category
10
+ %th Created
11
+ %th Delete
12
+ %th Edit
13
+ - @docs.each do |doc|
14
+ %tr
15
+ - @temp = doc.dscan
16
+ - if !@temp.blank?
17
+ - @dscan = @temp.scan(/document\/([^*]*)/).last.last
18
+ %td= link_to doc.filename, "#{jinda_document_path}?id=#{@dscan}", target: :_blank
19
+ - else
20
+ %td= doc.filename
21
+ %td= doc.description
22
+ %td= doc.category
23
+ %td= doc.created_at.strftime('%m/%d/%Y')
24
+ %td(align='center')= link_to image_tag('delete.png', style:'border:none; float:none;'), {controller: "docs", action: "destroy", doc_id: doc.id}, data: { confirm: "Please Confirm" }
25
+ %td(align='center')= image_tag('pencil.png', style:'border:none; float:none;')
26
+ - # To do
27
+ - # %td(align='center')= link_to image_tag('pencil.png', style:'border:none; float:none;'), {controller: "jinda", action: "init", s: 'docs:xedit_doc', doc_id: doc.id}, data: { confirm: "Please Confirm" }
@@ -13,15 +13,15 @@
13
13
 
14
14
  %h2 Recently tested with:
15
15
  %ul
16
- %li Rubygems 2.6.3
17
- %li Rails 6.0.1
16
+ %li Rubygems 2.7.1
17
+ %li Rails 6.0.3
18
18
  %li rails new YOURAPP --skip-test-unit --skip-bundle --skip-active-record --skip-javascript --skip-turbolinks
19
19
  %li (rails new YOURAPP -BOTJ)
20
20
 
21
21
 
22
22
  %h2 Installation
23
23
  %ul
24
- %li add gem 'jinda', '0.5.1'
24
+ %li add gem 'jinda', '0.5.6'
25
25
  %li bundle
26
26
  %li rails generate jinda:install
27
27
  %li (run all with "sh install.sh" )
@@ -22,7 +22,7 @@
22
22
  %th= t "user"
23
23
  %th= "date"
24
24
  - @xmain.docs.each do |doc|
25
- - next unless doc.display
25
+ - next unless doc.ma_display
26
26
  %tr
27
27
  %td= doc.id
28
28
  %td
@@ -32,7 +32,7 @@
32
32
  = image_tag 'page_attach.png'
33
33
  = link_to_blank align_text(doc.name), :controller=>"jinda", :action=>:document, :id=>doc.id
34
34
  %td= doc.filename
35
- %td= doc.user.name
36
- %td= date_thai doc.updated_at
35
+ %td= doc.user.code
36
+ %td= doc.updated_at
37
37
  = submit_tag @message
38
38
  %p
@@ -1,13 +1,10 @@
1
1
  <head>
2
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
3
- <meta name="distribution" content="global" />
4
- <meta name="robots" content="follow, all" />
5
- <meta name="language" content="en, th" />
6
- <title>eLocal</title>
7
- <link rel="shortcut icon" href="/assets/favicon.ico" />
8
- <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
9
- <%= stylesheet_link_tag "jinda", "sarabun" %>
2
+ <%= favicon_link_tag %>
3
+ <%= csrf_meta_tags %>
4
+ <%= meta_tags %>
10
5
  <meta name="description" content="Jinda" />
11
- <%= javascript_include_tag "jquery.tools.min.js" %>
12
- <%= javascript_include_tag "application", "flashobject", "FusionCharts" %>
6
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track":"reload" %>
7
+ <%= javascript_include_tag "application", "data-turbolinks-track": "reload" %>
8
+ <%= stylesheet_link_tag "jinda", "sarabun" %>
9
+ <script src = "https://ajax.aspnetcdn.com/ajax/jquery.validate/1.12.0/jquery.validate.js" ></script>
13
10
  </head>
@@ -1,15 +1,7 @@
1
1
  !!! 5
2
2
  %html
3
3
  %head
4
- = favicon_link_tag
5
- = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
6
- = javascript_include_tag "application", 'data-turbolinks-track': 'reload'
7
- = csrf_meta_tags
8
- = display_meta_tags
9
- - if GMAP
10
- = javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false"
11
- -# if ADSENSE
12
- = render :partial => 'custom/adsense'
4
+ = render :partial => "layouts/head"
13
5
  %body
14
6
  = render :partial => "jinda/menu"
15
7
  %div{"data-id" => "main", "data-role" => "panel", "data-backbtn"=>"false"}
@@ -6,7 +6,7 @@
6
6
 
7
7
  <%= fields_for doc, validate: true do |f| %>
8
8
  <%= f.label :title, "Title" %>
9
- <%= f.text_field :title %><Br>
9
+ <%= f.text_field :title, :required => true %><Br>
10
10
  <%= f.label :body, "Body Content" %>
11
11
  <%= f.text_area :body, :cols=>50, :rows=>6, required: true %>
12
12
  <% end %>
@@ -22,7 +22,7 @@ require 'active_support/core_ext'
22
22
  #
23
23
  # xvar is (become) global variable of current program including user, runseq, and services
24
24
  #
25
- ################################################################################
25
+ ########################################################################]
26
26
 
27
27
 
28
28
  module Jinda
@@ -30,6 +30,142 @@ module Jinda
30
30
  require "rexml/document"
31
31
  include REXML
32
32
  # methods from application_controller
33
+
34
+ ########################################################################]
35
+ # Each Service at one moment will create one xmain
36
+ ########################################################################]
37
+ def create_xmain(service)
38
+ c = name2camel(service.module.code)
39
+ custom_controller= "#{c}Controller"
40
+ params["return"] = request.env['HTTP_REFERER']
41
+ Jinda::Xmain.create :service=>service,
42
+ :start=>Time.now,
43
+ :name=>service.name,
44
+ :ip=> get_ip,
45
+ :status=>'I', # init
46
+ :user=>current_ma_user,
47
+ :xvars=> {
48
+ :service_id=>service.id,
49
+ :p=>params.to_unsafe_h,
50
+ :id=>params[:id],
51
+ :user_id=>current_ma_user.try(:id),
52
+ :custom_controller=>custom_controller,
53
+ :host=>request.host,
54
+ :referer=>request.env['HTTP_REFERER']
55
+ }
56
+ end
57
+ def clear_xmains
58
+ Jinda::Xmain.where(:status =>{'$in'=>['R','I']}).update_all(:status=>'X')
59
+ redirect_to action:"pending"
60
+ end
61
+ def ajax_notice
62
+ if notice=Jinda::Notice.recent(current_ma_user, request.env["REMOTE_ADDR"])
63
+ notice.update_attribute :unread, false
64
+ js = "notice('#{notice.message}');"
65
+ else
66
+ js = ""
67
+ end
68
+ render plain: "<script>#{js}</script>"
69
+ end
70
+
71
+ ########################################################################]
72
+ # Each xmain will create many run_seq as many as steps and form_steps
73
+ ########################################################################]
74
+ #
75
+ ############################## @runseq ################################]
76
+ # @runseq => #<Jinda::Runseq _id: 5df31912a54d758417a7afc9,
77
+ # created_at: 2019-12-13 04:52:34 UTC,
78
+ # updated_at: 2019-12-13 04:52:43 UTC,
79
+ # user_id: nil,
80
+ # xmain_id: BSON::ObjectId('5df31912a54d758417a7afc7'),
81
+ # action: "do",
82
+ # status: "R",
83
+ # code: "create",
84
+ # name: "Create Article",
85
+ # role: "",
86
+ # rule: "true",
87
+ # rstep: 2,
88
+ # form_step: 1,
89
+ # start: 2019-12-13 04:52:43 UTC,
90
+ # stop: nil,
91
+ # end: true,
92
+ # xml: "<node CREATED='1493419491125' ID='ID_1687683396' MODIFIED='1493483244848' TEXT='create: Create Article'><icon BUILTIN='bookmark'/></node>",
93
+ # ip: nil>
94
+ ########################################################################]
95
+
96
+ def create_runseq(xmain)
97
+ @xvars= xmain.xvars
98
+ default_role= get_default_role
99
+ xml= xmain.service.xml
100
+ root = REXML::Document.new(xml).root
101
+ i= 0; j= 0 # i= step, j= form_step
102
+ root.elements.each('node') do |activity|
103
+ text= activity.attributes['TEXT']
104
+ next if ma_comment?(text)
105
+ next if text =~/^rule:\s*/
106
+ action= freemind2action(activity.elements['icon'].attributes['BUILTIN']) if activity.elements['icon']
107
+ return false unless action
108
+ i= i + 1
109
+ output_ma_display= false
110
+ if action== ('output'|| 'list' ||'folder')
111
+ ma_display= get_option_xml("display", activity)
112
+ if ma_display && !affirm(ma_display)
113
+ output_ma_display= false
114
+ else
115
+ output_ma_display= true
116
+ end
117
+ end
118
+ j= j + 1 if (action=='form' || output_ma_display)
119
+ @xvars['referer'] = activity.attributes['TEXT'] if action=='redirect'
120
+ if action!= 'if' && !text.blank?
121
+ scode, name= text.split(':', 2)
122
+ name ||= scode; name.strip!
123
+ code= name2code(scode)
124
+ else
125
+ code= text
126
+ name= text
127
+ end
128
+ role= get_option_xml("role", activity) || default_role
129
+ rule= get_option_xml("rule", activity) || "true"
130
+ runseq= Jinda::Runseq.create :xmain=>xmain.id,
131
+ :name=> name, :action=> action,
132
+ :code=> code, :role=>role.upcase, :rule=> rule,
133
+ :rstep=> i, :form_step=> j, :status=>'I',
134
+ :xml=>activity.to_s
135
+ xmain.current_runseq= runseq.id if i==1
136
+ end
137
+ @xvars['total_steps']= i
138
+ @xvars['total_form_steps']= j
139
+ end
140
+
141
+ def init_vars(xmain)
142
+ @xmain= Jinda::Xmain.find xmain
143
+ @xvars= @xmain.xvars
144
+ @runseq= @xmain.runseqs.find @xmain.current_runseq
145
+ # authorize?
146
+ @xvars['current_step']= @runseq.rstep
147
+ @xvars['referrer']= request.referrer
148
+ session[:xmain_id]= @xmain.id
149
+ session[:runseq_id]= @runseq.id
150
+ unless params[:action]=='run_call'
151
+ @runseq.start ||= Time.now
152
+ @runseq.status= 'R' # running
153
+ @runseq.save
154
+ end
155
+ $xmain= @xmain; $xvars= @xvars
156
+ $runseq_id= @runseq.id
157
+ $user_id= current_ma_user.try(:id)
158
+ end
159
+ def init_vars_by_runseq(runseq_id)
160
+ @runseq= Jinda::Runseq.find runseq_id
161
+ @xmain= @runseq.xmain
162
+ @xvars= @xmain.xvars
163
+ #@xvars[:current_step]= @runseq.rstep
164
+ @runseq.start ||= Time.now
165
+ @runseq.status= 'R' # running
166
+ @runseq.save
167
+ end
168
+
33
169
  def b(s)
34
170
  "<b>#{s}</b>".html_safe
35
171
  end
@@ -41,9 +177,9 @@ module Jinda
41
177
  end
42
178
 
43
179
  def refresh_to(url='/', option={})
44
- if option[:alert]
45
- ma_log option[:alert]
46
- end
180
+ if option[:alert]
181
+ ma_log option[:alert]
182
+ end
47
183
  # skip #
48
184
  # Rails 5.2 not allow to use js inline call
49
185
  render inline: "<script>window.location.replace('#{url}')</script>"
@@ -63,6 +199,7 @@ module Jinda
63
199
  def redirect_to_root
64
200
  redirect_to root_path
65
201
  end
202
+
66
203
  # Todo refactor code
67
204
  def get_option(opt, runseq=@runseq)
68
205
  xml= REXML::Document.new(runseq.xml).root
@@ -156,7 +293,8 @@ module Jinda
156
293
  xml= @service.xml
157
294
  step1 = REXML::Document.new(xml).root.elements['node']
158
295
  role= get_option_xml("role", step1) || ""
159
- # rule= get_option_xml("rule", step1) || true
296
+ # rule= get_option_xml("rule", step1) || true
297
+ rule= get_option_xml("rule", step1) || true
160
298
  return true if role==""
161
299
  unless current_ma_user
162
300
  return role.blank?
@@ -164,17 +302,18 @@ module Jinda
164
302
  return false unless current_ma_user.role
165
303
  return current_ma_user.has_role(role)
166
304
  end
305
+
167
306
  end
168
307
  def ma_log(message)
169
308
  # Jinda::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
170
309
  # :unread=> true, :ip=> ($ip || request.env["REMOTE_ADDR"])
171
- if session[:user_id]
172
- Jinda::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
173
- :user_id => $user.id, :unread=> true, :ip=>request.env["REMOTE_ADDR"]
174
- else
175
- Jinda::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
176
- :unread=> true, :ip=>request.env["REMOTE_ADDR"]
177
- end
310
+ if session[:user_id]
311
+ Jinda::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
312
+ :user_id => $user.id, :unread=> true, :ip=>request.env["REMOTE_ADDR"]
313
+ else
314
+ Jinda::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
315
+ :unread=> true, :ip=>request.env["REMOTE_ADDR"]
316
+ end
178
317
  end
179
318
 
180
319
  alias :ma_notice :ma_log
@@ -241,7 +380,7 @@ module Jinda
241
380
  # end
242
381
  #@user ||= User.find_by_auth_token!(cookies[:auth_token]) if cookies[:auth_token]
243
382
  @user ||= User.where(:auth_token => cookies[:auth_token]).first if cookies[:auth_token]
244
- return @user
383
+ return @user
245
384
  end
246
385
 
247
386
  def ui_action?(s)
@@ -256,7 +395,7 @@ module Jinda
256
395
  # ""
257
396
  # end
258
397
  # end
259
-
398
+
260
399
  # ##########################################################################
261
400
  #
262
401
  # Create / Update Modules, Runseqs, Services from XML
@@ -286,9 +425,9 @@ module Jinda
286
425
  module_code= code.to_code
287
426
  menu_icon = m_icon(m)
288
427
 
289
- # ##########################################################################
290
- # First Node eg: Module Name
291
- # ##########################################################################
428
+ # ##########################################################################
429
+ # First Node eg: Module Name
430
+ # ##########################################################################
292
431
  # create or update to GmaModule
293
432
  ma_module= Jinda::Module.find_or_create_by :code=>module_code
294
433
  ma_module.update_attributes :uid=>ma_module.id.to_s, :icon=>menu_icon
@@ -298,9 +437,9 @@ module Jinda
298
437
  mseq += 1
299
438
  seq= 0
300
439
 
301
- # ##########################################################################
302
- # Second Nodes eg: Role, Link otherwise Services
303
- # ##########################################################################
440
+ # ##########################################################################
441
+ # Second Nodes eg: Role, Link otherwise Services
442
+ # ##########################################################################
304
443
  m.each_element('node') do |s|
305
444
  service_name= s.attributes["TEXT"].to_s
306
445
  scode, sname= service_name.split(':', 2)
@@ -323,9 +462,9 @@ module Jinda
323
462
  protected_services << ma_service.uid
324
463
  else
325
464
 
326
- # ##########################################################################
327
- # Second and Third Nodes eg: Role, Normal Services
328
- # ##########################################################################
465
+ # ##########################################################################
466
+ # Second and Third Nodes eg: Role, Normal Services
467
+ # ##########################################################################
329
468
  # normal service
330
469
  step1 = s.elements['node']
331
470
  role= get_option_xml("role", step1) || ""
@@ -381,7 +520,7 @@ module Jinda
381
520
  ########################################################################
382
521
  # Jinda Rake Task #
383
522
  ########################################################################
384
-
523
+
385
524
  def gen_views
386
525
  t = ["*** generate ui ***"]
387
526
 
@@ -394,7 +533,7 @@ module Jinda
394
533
  unless gen_view_file_exist?(dir)
395
534
  gen_view_mkdir(dir,t)
396
535
  end
397
-
536
+
398
537
  if s.code=='link'
399
538
  f= "app/views/#{s.module.code}/index.haml"
400
539
  $afile << f
@@ -405,7 +544,7 @@ module Jinda
405
544
  end
406
545
  next
407
546
  end
408
-
547
+
409
548
  dir ="app/views/#{s.module.code}/#{s.code}"
410
549
  unless gen_view_file_exist?(dir)
411
550
  gen_view_mkdir(dir,t)
@@ -449,18 +588,18 @@ module Jinda
449
588
 
450
589
  def process_models
451
590
 
452
- # app= get_app
453
- # t= ["process models"]
454
- # xml map sample from index.mm
455
- # node @CREATED=1273819432637 @ID=ID_1098419600 @MODIFIED=1334737006485 @TEXT=Jinda
456
- # node @CREATED=1273819462973 @ID=ID_282419531 @MODIFIED=1493705904561 @POSITION=right @TEXT=services
457
- # node @CREATED=1273819465949 @FOLDED=true @ID=ID_855471610 @MODIFIED=1493768913078 @POSITION=right @TEXT=roles
458
- # node @CREATED=1273819456867 @ID=ID_1677010054 @MODIFIED=1493418874718 @POSITION=left @TEXT=models
459
- # node @CREATED=1292122118499 @FOLDED=true @ID=ID_1957754752 @MODIFIED=1493705885123 @TEXT=person
460
- # node @CREATED=1292122236285 @FOLDED=true @ID=ID_959987887 @MODIFIED=1493768919147 @TEXT=address
461
- # node @CREATED=1493418879485 @ID=ID_1995497233 @MODIFIED=1493718770637 @TEXT=article
462
- # node @CREATED=1493418915637 @ID=ID_429078131 @MODIFIED=1493418930081 @TEXT=comment
463
-
591
+ # app= get_app
592
+ # t= ["process models"]
593
+ # xml map sample from index.mm
594
+ # node @CREATED=1273819432637 @ID=ID_1098419600 @MODIFIED=1334737006485 @TEXT=Jinda
595
+ # node @CREATED=1273819462973 @ID=ID_282419531 @MODIFIED=1493705904561 @POSITION=right @TEXT=services
596
+ # node @CREATED=1273819465949 @FOLDED=true @ID=ID_855471610 @MODIFIED=1493768913078 @POSITION=right @TEXT=roles
597
+ # node @CREATED=1273819456867 @ID=ID_1677010054 @MODIFIED=1493418874718 @POSITION=left @TEXT=models
598
+ # node @CREATED=1292122118499 @FOLDED=true @ID=ID_1957754752 @MODIFIED=1493705885123 @TEXT=person
599
+ # node @CREATED=1292122236285 @FOLDED=true @ID=ID_959987887 @MODIFIED=1493768919147 @TEXT=address
600
+ # node @CREATED=1493418879485 @ID=ID_1995497233 @MODIFIED=1493718770637 @TEXT=article
601
+ # node @CREATED=1493418915637 @ID=ID_429078131 @MODIFIED=1493418930081 @TEXT=comment
602
+
464
603
  models= @app.elements["//node[@TEXT='models']"] || REXML::Document.new
465
604
  models.each_element('node') do |model|
466
605
  # t << "= "+model.attributes["TEXT"]
@@ -468,14 +607,14 @@ module Jinda
468
607
  next if model_name.comment?
469
608
  model_code= name2code(model_name)
470
609
  model_file= "#{Rails.root}/app/models/#{model_code}.rb"
471
-
610
+
472
611
  if File.exists?(model_file)
473
612
  doc= File.read(model_file)
474
613
  else
475
614
  system("rails generate model #{model_code}")
476
615
  doc= File.read(model_file)
477
616
  end
478
-
617
+
479
618
  doc = add_utf8(doc)
480
619
  attr_hash= make_fields(model)
481
620
  doc = add_jinda(doc, attr_hash)
@@ -492,14 +631,14 @@ module Jinda
492
631
  def add_jinda(doc, attr_hash)
493
632
  if doc =~ /#{@btext}/
494
633
  s1,s2,s3= doc.partition(/ #{@btext}.*#{@etext}\n/m)
495
- s2= ""
634
+ s2= ""
496
635
  else
497
636
  s1,s2,s3= doc.partition("include Mongoid::Document\n")
498
637
  end
499
638
  doc= s1+s2+ <<-EOT
500
639
  #{@btext}
501
640
  include Mongoid::Timestamps
502
- EOT
641
+ EOT
503
642
 
504
643
  attr_hash.each do |a|
505
644
  # doc+= "\n*****"+a.to_s+"\n"
@@ -592,8 +731,8 @@ module Jinda
592
731
  ########################################################################
593
732
  # END code from jinda.rake #
594
733
  ########################################################################
595
-
596
-
734
+
735
+
597
736
  ########################################################################
598
737
  # Methods to be overrided by gemhelp #
599
738
  # for Rspec Test
@@ -613,7 +752,7 @@ module Jinda
613
752
  t << "create file #{f}"
614
753
  end
615
754
  ########################################################################
616
-
755
+
617
756
  def controller_exists?(modul)
618
757
  File.exists? "#{Rails.root}/app/controllers/#{modul}_controller.rb"
619
758
  end
@@ -659,7 +798,7 @@ module Jinda
659
798
  node.each_element("icon") do |mn|
660
799
  mcons << mn.attributes["BUILTIN"]
661
800
  end
662
- ticon = mcons[0].to_s
801
+ ticon = mcons[0].to_s
663
802
  return ticon
664
803
  end
665
804
 
@@ -689,8 +828,8 @@ module Jinda
689
828
 
690
829
  def freemind2action(s)
691
830
  case s.downcase
692
- #when 'bookmark' # Excellent
693
- # 'call'
831
+ #when 'bookmark' # Excellent
832
+ # 'call'
694
833
  when 'bookmark' # Excellent
695
834
  'do'
696
835
  when 'attach' # Look here
@@ -702,11 +841,16 @@ module Jinda
702
841
  when 'help' # Question
703
842
  'if'
704
843
  when 'forward' # Forward
705
- 'redirect'
844
+ # 'redirect'
845
+ 'direct_to'
706
846
  when 'kaddressbook' #Phone
707
847
  'invoke' # invoke new service along the way
708
- when 'list' # Output
848
+ when 'idea' # output
709
849
  'output'
850
+ when 'list' # List
851
+ 'list'
852
+ when 'folder' # Folder
853
+ 'folder'
710
854
  when 'mail'
711
855
  'mail'
712
856
  when 'xmag' # Tobe discussed
@@ -741,9 +885,9 @@ class String
741
885
  end
742
886
  def to_code
743
887
  s= self.dup
744
- # s.downcase!
745
- # s.gsub! /[\s\-_]/, ""
746
- # s
888
+ # s.downcase!
889
+ # s.gsub! /[\s\-_]/, ""
890
+ # s
747
891
  code, name = s.split(':')
748
892
  code.downcase.strip.gsub(' ','_').gsub(/[^#_\/a-zA-Z0-9]/,'')
749
893
  end
@@ -759,9 +903,9 @@ module ActionView
759
903
  end
760
904
  end
761
905
  class FormBuilder
762
- def date_select_thai(method)
763
- self.date_select method, :use_month_names=>THAI_MONTHS, :order=>[:day, :month, :year]
764
- end
906
+ def date_select_thai(method)
907
+ self.date_select method, :use_month_names=>THAI_MONTHS, :order=>[:day, :month, :year]
908
+ end
765
909
  def date_field(method, options = {})
766
910
  default= options[:default] || self.object.send(method) || Date.today
767
911
  data_options= ({"mode"=>"calbox"}).merge(options)
@@ -852,7 +996,7 @@ module ActionView
852
996
  init_map();
853
997
  });
854
998
  </script>
855
- EOT
999
+ EOT
856
1000
  out.html_safe
857
1001
  end
858
1002
  end