mindapp 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 41be277dcf6d2ce6dadca5d5e9c5d434c22f6bf5
4
+ data.tar.gz: f0c79d3029ddad32eed100780d5f287161bbb8bf
5
+ SHA512:
6
+ metadata.gz: 237c33dca283a4732008b80f4c290a6faa40be9859362358b353e27113491c2921bbec685bbda78586f1e64d7efefdfd3b09f5183e4f389d59e14b79e69c7280
7
+ data.tar.gz: 0e68d96ec63406d41f0d02e3c97d0224f28932bfbdcf0e3d316ae94860eec398c75b13798f4203879fd9ef149766fedea1351eb103fe952a9249a56bd5f7d54a
data/README.md CHANGED
@@ -4,6 +4,8 @@ I like to develop application using Ruby on Rails. I find that most of my projec
4
4
 
5
5
  ## Prerequisites
6
6
 
7
+ These versions works for sure but others may do.
8
+
7
9
  * Ruby 1.9
8
10
  * Rails 3.2
9
11
  * MongoDB
@@ -12,10 +14,9 @@ I like to develop application using Ruby on Rails. I find that most of my projec
12
14
  ## Convention
13
15
 
14
16
  * database is MongoDB
15
- * images stored in or Cloudinary by default, set IMAGE_LOCATION in `initializer/mindapp.rb` to use file system
16
- * mail use Gmail SMTP, set up credential in `config/application.rb`
17
+ * images stored in upload directory, unset IMAGE_LOCATION in `initializer/mindapp.rb` to use Cloudinary
18
+ * mail use Gmail SMTP, config in `config/application.rb`
17
19
  * authentication use omniauth-identity
18
- * use Rspec for test
19
20
 
20
21
  ## Installation
21
22
 
@@ -23,9 +24,9 @@ Create Rails app without ActiveRecord
23
24
 
24
25
  $ rails new app --skip-test-unit --skip-bundle --skip-active-record
25
26
 
26
- Add this line to your application's Gemfile:
27
+ Add this line to your Gemfile:
27
28
 
28
- gem 'mindapp'
29
+ gem 'mindapp', :git=> "git@github.com:songrit/mindapp.git"
29
30
 
30
31
  you may also need to enable gem `therubyracer` as well, then execute:
31
32
 
@@ -41,10 +42,6 @@ Your app is now ready at http://localhost:3000/.
41
42
 
42
43
  $ rails server
43
44
 
44
- When make changes to app/mindapp/index.mm, run
45
-
46
- $ rake mindapp:update
47
-
48
45
  ## Sample Application
49
46
 
50
47
  Supposed we want to create ecommerce web site
@@ -69,6 +66,8 @@ generate mindapp application
69
66
 
70
67
  it will ask to overwrite the seeds.rb file, enter y, then run bundle again to install additional gems added by mindapp
71
68
 
69
+ $ bundle
70
+
72
71
  The next step is create admin user
73
72
 
74
73
  $ rake db:seed
@@ -101,8 +100,8 @@ The first sub branch (e.g. person) is the model name. According to Rails convent
101
100
 
102
101
  * `fname` - this create a column (field) called fname which is a String by default
103
102
  * `sex: integer` - this create a column called sex, it is integer so must be explicity defined. The next sub branch (1: male) is disregarded by Mindapp so we can put whatever we want. Here I just put some reminder.
104
- * `belongs_to :address` - here we have ![edit](http://songrit.googlecode.com/files/edit.png) icon. this means whatever text on this line will be added as is to the model Mindapp generates. You use this to specify anything you want such as association, index, remarks in code, etc. according to mongoid gem. To draw the icon, rest mouse on the branch and hit <Alt-I>
105
- * `dob: date` - use any type that mongoid has
103
+ * `belongs_to :address` - here we have ![edit](http://songrit.googlecode.com/files/edit.png) icon. this means whatever text on this line will be added as is to the model Mindapp generates. You use this to specify anything you want such as association, index, remarks in code, etc. according to mongoid gem. To draw the icon, rest mouse on the branch and hit &ltAlt-I&gt.
104
+ * `dob: date` - use any type that mongoid provides.
106
105
  * `photo` - for file field, just use String here. Mindapp will receive the binary file and store in file system or cloudinary then generate a url link to it.
107
106
 
108
107
  In this example we just want a product model, so delete the person and address model and add a product branch like so
@@ -113,23 +112,23 @@ Save the mind map then run:
113
112
 
114
113
  rake mindapp:update
115
114
 
116
- This will create file `app/models/product.rb`. In this file, note the comment lines `# mindapp begin` and ` # mindapp end`. Everything inside these comments will get overwritten according to the mind map so if you need to put anything inside here, use the mind map instead. You can add any thing outside these comment lines which will be preserved when doing mindapp:update.
115
+ This will create file `app/models/product.rb`. In this file, note the comment lines `# mindapp begin` and ` # mindapp end`. Everything inside these comments will get overwritten when you change the models branch in the mind map so if you need to put anything inside here, use the mind map instead. You can add anything outside these comment lines which will be preserved when doing mindapp:update.
117
116
 
118
117
  ### services
119
118
 
120
- Next we'll add some product into the database, we'll first take a look at the services branch, which already has 3 sub branches; users, admins, and devs. Unlike models person and address, these branches are used by the system so I suggest that you don't delete them. Let's open the users branch
119
+ Next we'll add some product into the database, we'll first take a look at the services branch, which already has 3 sub branches; users, admins, and devs. Unlike models person and address branches, these branches are actively used by the system so I recommend that you leave them alone. Let's open the users branch
121
120
 
122
121
  ![users](http://songrit.googlecode.com/files/users.png)
123
122
 
124
123
  The text `users:User` on the sub branch has these implications:
125
124
 
126
125
  * `users` correspond to `app/controllers/users_controller.rb` which already exist when you do rails generate mindapp:install. New branch will create new controller if not exist. In Mindapp term, this will be called module.
127
- * `User` will create entry in main menu on the left of the screen
126
+ * `User` will create entry in main menu on the left of the screen. You don't see it in the screenshot above because it's controlled by the sub branch `role:m` which means this menu only available for login member. If you already signed in as admin, you should see it now.
128
127
 
129
- The next sub branch has the following:
128
+ The next sub branches has the following:
130
129
 
131
- * `role: m` - means that this whole module (menu) is available only to user who has role m (if you open the role branch now will see that role m is member). All registered user has role m by default. User who is not log on would not be able to access this module.
132
- * `link:info: /users` - means that this is a link, the format is link: *submenu label* : *url* where submenu label is the text to show in the submenu and url is the link to go to, in this case, it woud go to http://localhost:3000/users which will perform action index of users_controller.
130
+ * `role: m` - means that this module (menu) is available only to user who has role m (if you open the role branch now will see that role m is member). All registered user has role m by default. User who is not log on would not be able to access this module.
131
+ * `link:info: /users` - means that this is a link, the format is link: *submenu label* : *url* where submenu label is the text to show in the submenu and url is the link to go to, in this case, it woud go to http://localhost:3000/users which will perform index action of UsersController.
133
132
  * `user:edit` the branch that do not start with role:, rule:, nor link: will be a Mindapp service. You will then specify the sequence of the execution as in this example there are 3 sub branches - enter_user, update_user, and rule:login? Let's take a look at them:
134
133
 
135
134
  * `enter_user:edit` - the first step is to display a form to input user information, this is accompanied by icon ![attach](http://songrit.googlecode.com/files/attach.png) which means user interface screen. and will correspond to a view file `app/views/users/user/enter_user.html.erb` where `/users` comes from the module name (the sub branch of services), `/user` comes from the service name (the sub branch of users), and `enter_user.html.erb` comes from the first part of this branch. The `edit` after the colon is just a description of this step. This branch also has sub branch `rule:login? && own_xmain?` which specify rule for this step that the user must be login and can continue this task if he is the one who started it. *task* in here means each instance of service.
@@ -149,7 +148,7 @@ open file `app/views/products/add/enter.html.erb` you'll see some sample view al
149
148
 
150
149
  Note that we do not specify form_tag and submit_tag, these will be supplied by Mindapp.
151
150
 
152
- then open file `app/controllers/products_controller.rb` and edit to be as follow
151
+ then open file `app/controllers/products_controller.rb` and add `create` method as follow. The method name has to be correspond to the ![bookmark](http://songrit.googlecode.com/files/bookmark.png) branch.
153
152
 
154
153
  ![products_controller](http://songrit.googlecode.com/files/products_controller.png)
155
154
 
@@ -5,29 +5,6 @@ module Mindapp
5
5
  def self.source_root
6
6
  File.dirname(__FILE__) + "/templates"
7
7
  end
8
- def setup_gems
9
- gem "nokogiri" # use for mindapp/doc
10
- # gem "rmagick", :require => "RMagick", :platform => "ruby"
11
- gem 'haml-rails'
12
- gem "mail"
13
- gem "prawn"
14
- # bug in mongo ruby driver 1.6.1, wait for mongoid 2.4.7
15
- gem "mongo", "1.5.1"
16
- gem "bson_ext", "1.5.1"
17
- gem "mongoid"
18
- gem "redcarpet"
19
- gem 'bcrypt-ruby', '~> 3.0.0'
20
- gem 'omniauth-identity'
21
- gem 'cloudinary'
22
- gem 'kaminari'
23
- gem_group :development, :test do
24
- gem "debugger"
25
- gem "rspec"
26
- gem "rspec-rails"
27
- gem "better_errors"
28
- gem "binding_of_caller"
29
- end
30
- end
31
8
 
32
9
  def setup_routes
33
10
  route "root :to => 'mindapp#index'"
@@ -43,9 +20,13 @@ module Mindapp
43
20
 
44
21
  def setup_env
45
22
  create_file 'README.md', ''
23
+ # bug in mongo ruby driver 1.6.1, wait for mongoid 2.4.7
24
+ gem "mongo", "1.5.1"
25
+ gem "bson_ext", "1.5.1"
26
+ gem "mongoid"
46
27
  run "bundle install"
47
28
  generate "mongoid:config"
48
- generate "rspec:install"
29
+ # generate "rspec:install"
49
30
  inject_into_file 'config/application.rb', :after => 'require "active_resource/railtie"' do
50
31
  "\nrequire 'mongoid/railtie'\n"
51
32
  "\nrequire 'rexml/document'\n"
@@ -79,7 +60,7 @@ DEFAULT_TITLE = 'Mindapp'
79
60
  DEFAULT_HEADER = 'Mindapp'
80
61
  GMAP = true
81
62
  NEXT = "Next >"
82
- # comment IMAGE_LOCATION to use cloudinary
63
+ # comment IMAGE_LOCATION to use cloudinary (specify params in config/cloudinary.yml)
83
64
  IMAGE_LOCATION = "upload"
84
65
  # for debugging
85
66
  # DONT_SEND_MAIL = true
@@ -97,7 +78,7 @@ IMAGE_LOCATION = "upload"
97
78
  "\n config.assets.compile = true"
98
79
  end
99
80
  inject_into_file 'config/mongoid.yml', :after => ' # raise_not_found_error: true' do
100
- "\n raise_not_found_error: false"
81
+ "\n raise_not_found_error: false"
101
82
  end
102
83
  end
103
84
 
@@ -124,13 +105,36 @@ end
124
105
  inside("app/assets/stylesheets") { run "mv application.css application.css.bak" }
125
106
  directory "app"
126
107
  end
108
+
127
109
  def gen_user
128
110
  copy_file "seeds.rb","db/seeds.rb"
129
111
  end
112
+
130
113
  def gen_image_store
131
114
  copy_file "cloudinary.yml","config/cloudinary.yml"
132
115
  empty_directory "upload" # create upload directory just in case
133
116
  end
117
+
118
+ def setup_gems
119
+ gem "nokogiri" # use for mindapp/doc
120
+ # gem "rmagick", :require => "RMagick", :platform => "ruby"
121
+ gem 'haml-rails'
122
+ gem "mail"
123
+ gem "prawn"
124
+ gem "redcarpet"
125
+ gem 'bcrypt-ruby', '~> 3.0.0'
126
+ gem 'omniauth-identity'
127
+ gem 'cloudinary'
128
+ gem 'kaminari'
129
+ gem_group :development, :test do
130
+ gem "debugger"
131
+ gem "rspec"
132
+ gem "rspec-rails"
133
+ gem "better_errors"
134
+ gem "binding_of_caller"
135
+ end
136
+ end
137
+
134
138
  end
135
139
  end
136
140
  end
@@ -70,7 +70,7 @@ class MindappController < ApplicationController
70
70
  else
71
71
  service= @xmain.service
72
72
  if service
73
- @title= "รหัสดำเนินการ #{@xmain.xid}: #{@xmain.name} / #{@runseq.name}"
73
+ @title= "Transaction ID #{@xmain.xid}: #{@xmain.name} / #{@runseq.name}"
74
74
  fhelp= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.md"
75
75
  @help = File.read(fhelp) if File.exists?(fhelp)
76
76
  f= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.html.erb"
@@ -121,7 +121,8 @@ class MindappController < ApplicationController
121
121
  init_vars(params[:id])
122
122
  @runseq.start ||= Time.now
123
123
  @runseq.status= 'R' # running
124
- $runseq_id= @runseq.id; $user_id= current_user.id
124
+ $runseq_id= @runseq.id
125
+ $user_id= current_user.try(:id)
125
126
  set_global
126
127
  controller = Kernel.const_get(@xvars['custom_controller']).new
127
128
  result = controller.send(@runseq.code)
@@ -135,7 +136,7 @@ class MindappController < ApplicationController
135
136
  end_action
136
137
  rescue => e
137
138
  @xmain.status='E'
138
- @xvars['error']= e.to_s
139
+ @xvars['error']= e.to_s+e.backtrace.to_s
139
140
  @xmain.xvars= $xvars
140
141
  @xmain.save
141
142
  @runseq.status= 'F' #finish
@@ -257,7 +258,8 @@ class MindappController < ApplicationController
257
258
  :secured => @xmain.service.secured )
258
259
  if defined?(IMAGE_LOCATION)
259
260
  filename = "#{IMAGE_LOCATION}/f#{Param.gen(:asset_id)}"
260
- File.open(filename,"wb") { |f| f.puts(params.read) }
261
+ File.open(filename,"wb") { |f| f.write(params.read) }
262
+ # File.open(filename,"wb") { |f| f.puts(params.read) }
261
263
  eval "@xvars[@runseq.code][key] = '#{url_for(:action=>'document', :id=>doc.id, :only_path => true )}' "
262
264
  doc.update_attributes :url => filename, :basename => File.basename(filename), :cloudinary => false
263
265
  else
@@ -278,7 +280,7 @@ class MindappController < ApplicationController
278
280
  :display=>true, :secured => @xmain.service.secured )
279
281
  if defined?(IMAGE_LOCATION)
280
282
  filename = "#{IMAGE_LOCATION}/f#{Param.gen(:asset_id)}"
281
- File.open(filename,"wb") { |f| f.puts(params.read) }
283
+ File.open(filename,"wb") { |f| f.write(params.read) }
282
284
  eval "@xvars[@runseq.code][key][key1] = '#{url_for(:action=>'document', :id=>doc.id, :only_path => true)}' "
283
285
  doc.update_attributes :url => filename, :basename => File.basename(filename), :cloudinary => false
284
286
  else
@@ -326,8 +328,6 @@ class MindappController < ApplicationController
326
328
  require "uri"
327
329
  uri = URI.parse(doc.url)
328
330
  data = Net::HTTP.get_response(uri)
329
- # require 'open-uri'
330
- # data= open(doc.url)
331
331
  send_data(data.body, :filename=>doc.filename, :type=>doc.content_type, :disposition=>"inline")
332
332
  else
333
333
  data= read_binary(doc.url)
@@ -385,9 +385,11 @@ class MindappController < ApplicationController
385
385
  :xvars=> {
386
386
  :service_id=>service.id, :p=>params,
387
387
  :id=>params[:id],
388
- :user_id=>current_user.id, :custom_controller=>custom_controller,
388
+ :user_id=>current_user.try(:id),
389
+ :custom_controller=>custom_controller,
389
390
  :host=>request.host,
390
- :referer=>request.env['HTTP_REFERER'] }
391
+ :referer=>request.env['HTTP_REFERER']
392
+ }
391
393
  end
392
394
  def create_runseq(xmain)
393
395
  @xvars= xmain.xvars
@@ -448,7 +450,8 @@ class MindappController < ApplicationController
448
450
  @runseq.save
449
451
  end
450
452
  $xmain= @xmain; $xvars= @xvars
451
- $runseq_id= @runseq.id; $user_id= current_user.id
453
+ $runseq_id= @runseq.id
454
+ $user_id= current_user.try(:id)
452
455
  end
453
456
  def init_vars_by_runseq(runseq_id)
454
457
  @runseq= Mindapp::Runseq.find runseq_id
@@ -13,6 +13,7 @@
13
13
  padding: 0px;
14
14
  margin: 0px;
15
15
  size: A4;
16
+ font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;
16
17
  }
17
18
  </style>
18
19
  <body>
@@ -21,4 +21,4 @@
21
21
  %td= @runseq.name
22
22
  %td{:align=>'center'}= xmain.user.try :code
23
23
  %td= xmain.start.strftime("%c")
24
- %td(align='center')= link_to image_tag('delete.png', style:'border:none; float:none;'), "#", :onclick=>"if (confirm('กรุณายืนยัน')) {location.hash='/mindapp/cancel/#{xmain.id}';}"
24
+ %td(align='center')= link_to image_tag('delete.png', style:'border:none; float:none;'), "#", :onclick=>"if (confirm('Please Confirm')) {location.hash='/mindapp/cancel/#{xmain.id}';}"
@@ -14,9 +14,9 @@
14
14
  - @runseq= Mindapp::Runseq.find(xmain.current_runseq)
15
15
  - next unless @runseq
16
16
  %tr
17
- %td= xmain.xid
18
- %td= xmain.name
19
- %td= @runseq.name
20
- %td(align="center")= xmain.user.try :code
21
- %td= xmain.start.strftime("%c")
22
- %td(style="width:50%")= xmain.xvars["error"]
17
+ %td(style='vertical-align:top;')= xmain.xid
18
+ %td(style='vertical-align:top;')= xmain.name
19
+ %td(style='vertical-align:top;')= @runseq.name
20
+ %td(align="center" style='vertical-align:top;')= xmain.user.try :code
21
+ %td(style='vertical-align:top;')= xmain.start.strftime("%c")
22
+ %td(style="vertical-align:top;width:40%")= truncate(xmain.xvars["error"], :length=> 100)
@@ -13,22 +13,3 @@
13
13
  %li rails generate mindapp:install
14
14
  %li rake db:seed, will create initial user admin:secret
15
15
  %li when update app/mindapp/index.mm, run rake mindapp:update
16
-
17
- %h2 Convention
18
- %ul
19
- %li database is MongoDB
20
- %li images stored in or Cloudinary (default) unset IMAGE_LOCATION in initializer/mindapp.rb to use file system
21
- %li mail use Gmail SMTP
22
- %li authentication use omniauth-identity
23
-
24
- %h2 Analyst - the Freemind guy
25
- %ul
26
- %li when delete model, must run rake destroy model
27
-
28
- %h2 UI - the designer
29
- %ul
30
- %li
31
-
32
- %h2 Business Logic - the programmer
33
- %ul
34
- %li
@@ -14,7 +14,7 @@
14
14
  - @runseq= Mindapp::Runseq.find(xmain.current_runseq)
15
15
  - next unless @runseq
16
16
  %tr
17
- %td= xmain.xid
17
+ %td= link_to xmain.xid, "/mindapp/status?xid=#{xmain.xid}"
18
18
  %td= xmain.name
19
19
  %td= @runseq.name
20
20
  %td(align="center")= xmain.user.try :code
@@ -0,0 +1,38 @@
1
+ .head
2
+ - @title= @xmain.name
3
+ = step(@runseq.form_step, @xvars['total_form_steps'])
4
+ #title(style='text-align:right;')= "คลิ้กข้อความ '#{@runseq.name}' เพื่อจัดพิมพ์เอกสาร"
5
+ %p
6
+ =javascript_include_tag "disable_enter_key"
7
+ = form_tag({ :action => 'end_output' } , {:multipart => true, :onKeyPress=>'return disableEnterKey(event)', :class=>'formtastic'}) do
8
+ = hidden_field_tag 'xmain_id', @xmain.id
9
+ = hidden_field_tag 'runseq_id', @runseq.id
10
+ = hidden_field_tag 'step', @xvars[:current_step]
11
+ #output_link
12
+ = link_to @runseq.name, url_for(:controller=>'mindapp', :action=>'document', :id=>@doc.id), :target=>'_blank'
13
+ %p
14
+ .label
15
+ = image_tag "cog.png"
16
+ = t "documents"
17
+ %table{:width=>"100%"}
18
+ %tr{:style=>"color:white; background-color:#6A6A6A;"}
19
+ %th= t "id"
20
+ %th= t "document"
21
+ %th= t "file name"
22
+ %th= t "user"
23
+ %th= t "date"
24
+ - @xmain.docs.each do |doc|
25
+ - next unless doc.display
26
+ %tr
27
+ %td= doc.id
28
+ %td
29
+ - if doc.content_type=='output'
30
+ = image_tag 'page_output.png'
31
+ - else
32
+ = image_tag 'page_attach.png'
33
+ = link_to_blank align_text(doc.name), :controller=>"mindapp", :action=>:document, :id=>doc.id
34
+ %td= doc.filename
35
+ %td= doc.user.name
36
+ %td= date_thai doc.updated_at
37
+ = submit_tag @message
38
+ %p
@@ -1,6 +1,6 @@
1
1
  %table{:width=>"100%"}
2
2
  %tr{:style=>"color:white; background-color:#6A6A6A;"}
3
- %th id
3
+ %th status
4
4
  %th step
5
5
  %th starter
6
6
  %th begin
@@ -21,21 +21,21 @@
21
21
  %td{:align=>'center'} -
22
22
  - else
23
23
  - if r.start
24
- %td= date_thai r.start
24
+ %td= r.start.strftime('%c')
25
25
  - else
26
26
  %td{:align=>'center'} -
27
27
  - if r.stop
28
- %td= date_thai r.stop
28
+ %td= r.stop.strftime('%c')
29
29
  - else
30
30
  %td{:align=>'center'} -
31
31
  - else
32
32
  = role_name r.role
33
33
  - if r.start
34
- %td= date_thai r.start
34
+ %td= r.start.strftime('%c')
35
35
  - else
36
36
  %td{:align=>'center'} -
37
37
  - if r.stop
38
- %td= date_thai r.stop
38
+ %td= r.stop.strftime('%c')
39
39
  - else
40
40
  %td{:align=>'center'} -
41
41
  .label
@@ -57,5 +57,5 @@
57
57
  = image_tag 'page_attach.png'
58
58
  = link_to align_text(doc.name), "/engine/document/#{doc.id}", :target=>'_blank'
59
59
  %td= doc.filename
60
- %td= doc.ma_user.full_name
61
- %td= date_thai doc.created_at
60
+ %td= doc.user.try(:full_name)
61
+ %td= doc.created_at.strftime('%c')
@@ -1,10 +1,32 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  module Mindapp
2
3
  module Helpers
3
-
4
+ require "rexml/document"
5
+ include REXML
4
6
  # methods from application_controller
5
7
  def b(s)
6
8
  "<b>#{s}</b>".html_safe
7
9
  end
10
+ def date_thai(d= Time.now, options={})
11
+ unless d
12
+ ""
13
+ else
14
+ y = d.year+543
15
+ if options[:monthfull] || options[:month_full]
16
+ mh= ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฏาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม']
17
+ else
18
+ mh= ['ม.ค.', 'ก.พ.', 'มี.ค.', 'เม.ย.', 'พ.ค.', 'มิ.ย.', 'ก.ค.', 'ส.ค.', 'ก.ย.', 'ต.ค.', 'พ.ย.', 'ธ.ค.']
19
+ end
20
+ if options[:dateonly] || options[:date_only]
21
+ d.day.to_s+" "+mh[d.month-1]+" "+y.to_s
22
+ else
23
+ d.day.to_s+" "+mh[d.month-1]+" "+y.to_s+" เวลา "+sprintf("%02d",d.hour.to_s)+":"+sprintf("%02d",d.min.to_s)
24
+ end
25
+ end
26
+ end
27
+ def link_to_blank(body, url_options = {}, html_options = {})
28
+ link_to(body, url_options, html_options.merge(target: "_blank"))
29
+ end
8
30
  def code_text(s) # old def code(s)
9
31
  "<pre style='background-color: #efffef;'><code class='ruby' lang='ruby'>#{s}</code></pre>".html_safe
10
32
  end
@@ -89,10 +111,17 @@ module Mindapp
89
111
  end
90
112
  end
91
113
  def ma_log(message)
92
- Mindapp::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
93
- :user_id => $user.id, :unread=> true
114
+ if $user
115
+ Mindapp::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
116
+ :user_id => $user.id, :unread=> true
117
+ else
118
+ Mindapp::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")),
119
+ :unread=> true
120
+ end
94
121
  end
95
122
 
123
+ alias :ma_notice :ma_log
124
+
96
125
  # methods from application_helper
97
126
  def markdown(text)
98
127
  erbified = ERB.new(text.html_safe).result(binding)
@@ -236,8 +265,8 @@ module Mindapp
236
265
  Mindapp::Service.not_in(:uid=>protected_services).delete_all
237
266
  end
238
267
  def get_app
239
- # dir= "#{Rails.root}/app/mindapp"
240
268
  f= MM || "#{Rails.root}/app/mindapp/index.mm"
269
+ dir= File.dirname(f)
241
270
  t= REXML::Document.new(File.read(MM).gsub("\n","")).root
242
271
  recheck= true ; first_pass= true
243
272
  while recheck
@@ -278,7 +307,7 @@ module Mindapp
278
307
  end
279
308
  def own_xmain?
280
309
  if $xmain
281
- return $user.id==$xvars['user_id']
310
+ return current_user.id==$xvars['user_id']
282
311
  else
283
312
  # if eval on first step would return true so user can start service
284
313
  return true
@@ -355,7 +384,7 @@ end
355
384
 
356
385
  class String
357
386
  def comment?
358
- self[0]==35 # check if first char is #
387
+ self[0]=='#'
359
388
  end
360
389
  def to_code
361
390
  s= self.dup
@@ -381,7 +410,7 @@ module ActionView
381
410
  # self.date_select method, :use_month_names=>THAI_MONTHS, :order=>[:day, :month, :year]
382
411
  # end
383
412
  def date_field(method, options = {})
384
- default= self.object.send(method) || Date.today
413
+ default= options[:default] || self.object.send(method) || Date.today
385
414
  data_options= ({"mode"=>"calbox"}).merge(options)
386
415
  out= %Q(<input name='#{self.object_name}[#{method}]' id='#{self.object_name}_#{method}' value='#{default.strftime("%F")}' type='date' data-role='datebox' data-options='#{data_options.to_json}'>)
387
416
  out.html_safe
@@ -1,3 +1,3 @@
1
1
  module Mindapp
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -2,8 +2,8 @@ require 'mindapp'
2
2
  require 'mindapp/helpers'
3
3
  include Mindapp::Helpers
4
4
 
5
- @@btext= "# mindapp begin"
6
- @@etext= "# mindapp end"
5
+ @btext= "# mindapp begin"
6
+ @etext= "# mindapp end"
7
7
 
8
8
  namespace :mindapp do
9
9
  desc "generate models from mm"
@@ -97,14 +97,14 @@ end
97
97
  end
98
98
 
99
99
  def add_mindapp(doc, attr_hash)
100
- if doc =~ /#{@@btext}/
101
- s1,s2,s3= doc.partition(/ #{@@btext}.*#{@@etext}\n/m)
100
+ if doc =~ /#{@btext}/
101
+ s1,s2,s3= doc.partition(/ #{@btext}.*#{@etext}\n/m)
102
102
  s2= ""
103
103
  else
104
104
  s1,s2,s3= doc.partition("include Mongoid::Document\n")
105
105
  end
106
106
  doc= s1+s2+ <<-EOT
107
- #{@@btext}
107
+ #{@btext}
108
108
  include Mongoid::Timestamps
109
109
  EOT
110
110
  attr_hash.each do |a|
@@ -115,7 +115,7 @@ end
115
115
  doc += " field :#{a[:code]}, :type => #{a[:type].capitalize}\n"
116
116
  end
117
117
  end
118
- doc += " #{@@etext}\n"
118
+ doc += " #{@etext}\n"
119
119
  doc + s3
120
120
  end
121
121
 
@@ -182,7 +182,8 @@ end
182
182
  # ----------------------------
183
183
  class String
184
184
  def comment?
185
- self[0]==35 # check if first char is #
185
+ self[0]=='#'
186
+ # self[0]==35 # check if first char is #
186
187
  end
187
188
  def to_code
188
189
  s= self.dup
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mindapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - songrit
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-08 00:00:00.000000000 Z
11
+ date: 2013-07-25 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: generate Ruby on Rails app from mind map
15
14
  email:
@@ -215,6 +214,7 @@ files:
215
214
  - lib/generators/mindapp/templates/app/views/mindapp/logs.haml
216
215
  - lib/generators/mindapp/templates/app/views/mindapp/pending.haml
217
216
  - lib/generators/mindapp/templates/app/views/mindapp/run_form.haml
217
+ - lib/generators/mindapp/templates/app/views/mindapp/run_output.haml
218
218
  - lib/generators/mindapp/templates/app/views/mindapp/search.haml
219
219
  - lib/generators/mindapp/templates/app/views/mindapp/status.haml
220
220
  - lib/generators/mindapp/templates/app/views/mindapp_mailer/gmail.html.erb
@@ -240,26 +240,25 @@ files:
240
240
  - mindapp.gemspec
241
241
  homepage: https://github.com/songrit/mindapp
242
242
  licenses: []
243
+ metadata: {}
243
244
  post_install_message:
244
245
  rdoc_options: []
245
246
  require_paths:
246
247
  - lib
247
248
  required_ruby_version: !ruby/object:Gem::Requirement
248
- none: false
249
249
  requirements:
250
- - - ! '>='
250
+ - - '>='
251
251
  - !ruby/object:Gem::Version
252
252
  version: '0'
253
253
  required_rubygems_version: !ruby/object:Gem::Requirement
254
- none: false
255
254
  requirements:
256
- - - ! '>='
255
+ - - '>='
257
256
  - !ruby/object:Gem::Version
258
257
  version: '0'
259
258
  requirements: []
260
259
  rubyforge_project:
261
- rubygems_version: 1.8.24
260
+ rubygems_version: 2.0.3
262
261
  signing_key:
263
- specification_version: 3
262
+ specification_version: 4
264
263
  summary: generate Ruby on Rails app from mind map
265
264
  test_files: []