mindapp2 0.1.1.3 → 0.1.1.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +4 -4
- data/lib/generators/mindapp/install_generator.rb +11 -3
- data/lib/generators/mindapp/mongoid_generator.rb +6 -1
- data/lib/generators/mindapp/templates/app/assets/images/facebook-sign-in-button.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/logo_mindapp.png +0 -0
- data/lib/generators/mindapp/templates/app/controllers/articles_controller.rb +2 -2
- data/lib/generators/mindapp/templates/app/controllers/mindapp_controller.rb +31 -31
- data/lib/generators/mindapp/templates/app/controllers/sessions_controller.rb +3 -2
- data/lib/generators/mindapp/templates/app/controllers/users_controller.rb +2 -2
- data/lib/generators/mindapp/templates/app/models/mindapp/doc.rb +1 -1
- data/lib/generators/mindapp/templates/app/models/user.rb +18 -12
- data/lib/generators/mindapp/templates/app/views/articles/edit_article/select_article.html.erb +2 -2
- data/lib/generators/mindapp/templates/app/views/articles/index.haml +2 -2
- data/lib/generators/mindapp/templates/app/views/mindapp/_menu.haml +3 -4
- data/lib/generators/mindapp/templates/app/views/mindapp/_menu_mm.haml +4 -4
- data/lib/generators/mindapp/templates/app/views/mindapp/_pending_page.haml +1 -1
- data/lib/generators/mindapp/templates/app/views/mindapp/index.html.haml +5 -4
- data/lib/generators/mindapp/templates/app/views/mindapp/run_form.haml +1 -1
- data/lib/generators/mindapp/templates/app/views/users/index.haml +3 -3
- data/lib/generators/mindapp/templates/app/views/users/user/enter_user.html.erb +1 -1
- data/lib/mindapp2.rb +1 -1
- data/lib/mindapp2/helpers.rb +12 -12
- data/lib/mindapp2/version.rb +1 -1
- data/mindapp2.gemspec +1 -1
- metadata +5 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f98ae0e79b453c96b3885e456567ad57075fc4a3
         | 
| 4 | 
            +
              data.tar.gz: 22af5026f14c62e2476da32679445e1da618a901
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0335bf8bc98e78e3915d85bbec3cc70b50aab6791ce9cfe7cfe061018c07f92ad2ea13474df4dbd60bb0b5c8aa997ce0596726966c38b791b17637a8b3ab4212
         | 
| 7 | 
            +
              data.tar.gz: f6de98de2161ecbd0c2570681739ac5bf21d36087abb49fc926f135d2183d0da1ad15354bac0008d3e6ad8caf07e8c04e8e6556ff693a58d399d049e9e33f272
         | 
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,18 +1,18 @@ | |
| 1 1 | 
             
            # Mindapp2
         | 
| 2 | 
            -
            ## v0.1.1. | 
| 2 | 
            +
            ## v0.1.1.4
         | 
| 3 3 |  | 
| 4 4 | 
             
            This is an extended version of Mindapp with mixed workflow and rails app. Mindapp2 maintain workflow feature with upgrade to most update ruby and rails.
         | 
| 5 5 |  | 
| 6 6 | 
             
            ## Changelog
         | 
| 7 7 |  | 
| 8 | 
            -
            * update for Rails 5.1. | 
| 8 | 
            +
            * update for Rails 5.1.2
         | 
| 9 9 |  | 
| 10 10 | 
             
            ## Prerequisites
         | 
| 11 11 |  | 
| 12 12 | 
             
            These versions works for sure but others may do.
         | 
| 13 13 |  | 
| 14 14 | 
             
            * Ruby 2.4.1
         | 
| 15 | 
            -
            * Rails 5.1. | 
| 15 | 
            +
            * Rails 5.1.2
         | 
| 16 16 | 
             
            * MongoDB 6
         | 
| 17 17 | 
             
            * Freemind 1.0.1
         | 
| 18 18 |  | 
| @@ -32,7 +32,7 @@ app without ActiveRecord | |
| 32 32 |  | 
| 33 33 | 
             
            ## Add mindapp to your Gemfile:
         | 
| 34 34 |  | 
| 35 | 
            -
                gem 'mindapp2' | 
| 35 | 
            +
                gem 'mindapp2'
         | 
| 36 36 |  | 
| 37 37 | 
             
            For Development (most updated)
         | 
| 38 38 |  | 
| @@ -13,6 +13,7 @@ module Mindapp | |
| 13 13 | 
             
                    route "resources :identities"
         | 
| 14 14 | 
             
                    route "resources :sessions"
         | 
| 15 15 | 
             
                    route "post '/auth/:provider/callback' => 'sessions#create'"
         | 
| 16 | 
            +
                    route "get '/auth/:provider/callback' => 'sessions#create'"
         | 
| 16 17 | 
             
                    route "get '/auth/failure' => 'sessions#failure'"
         | 
| 17 18 | 
             
                    route "get '/logout' => 'sessions#destroy', :as => 'logout'"
         | 
| 18 19 | 
             
                    route "get ':controller(/:action(/:id))(.:format)'"
         | 
| @@ -56,8 +57,8 @@ module Mindapp | |
| 56 57 | 
             
                    initializer "mindapp.rb" do
         | 
| 57 58 | 
             
            %q{# encoding: utf-8
         | 
| 58 59 | 
             
            MM = "#{Rails.root}/app/mindapp/index.mm"
         | 
| 59 | 
            -
            DEFAULT_TITLE = ' | 
| 60 | 
            -
            DEFAULT_HEADER = ' | 
| 60 | 
            +
            DEFAULT_TITLE = 'Mindapp2'
         | 
| 61 | 
            +
            DEFAULT_HEADER = 'Mindapp2'
         | 
| 61 62 | 
             
            GMAP = false
         | 
| 62 63 | 
             
            NEXT = "Next >"
         | 
| 63 64 | 
             
            # comment IMAGE_LOCATION to use cloudinary (specify params in config/cloudinary.yml)
         | 
| @@ -103,6 +104,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do | |
| 103 104 | 
             
                :on_failed_registration=> lambda { |env|
         | 
| 104 105 | 
             
                  IdentitiesController.action(:new).call(env)
         | 
| 105 106 | 
             
              }
         | 
| 107 | 
            +
              provider :facebook, ENV['FACEBOOK_API'], ENV['FACEBOOK_KEY']
         | 
| 106 108 | 
             
            end
         | 
| 107 109 | 
             
            }
         | 
| 108 110 | 
             
                    end
         | 
| @@ -145,6 +147,8 @@ end | |
| 145 147 | 
             
                    gem "redcarpet"
         | 
| 146 148 | 
             
                    gem 'bcrypt-ruby', '~> 3.0.0'
         | 
| 147 149 | 
             
                    gem 'omniauth-identity'
         | 
| 150 | 
            +
                    gem 'omniauth-facebook'
         | 
| 151 | 
            +
                    gem 'dotenv-rails'
         | 
| 148 152 | 
             
                    gem 'cloudinary'
         | 
| 149 153 | 
             
                    gem 'kaminari'
         | 
| 150 154 | 
             
                    gem 'kaminari-mongoid'
         | 
| @@ -171,7 +175,11 @@ end | |
| 171 175 | 
             
                  end
         | 
| 172 176 |  | 
| 173 177 | 
             
                  def finish
         | 
| 174 | 
            -
                    puts "Mindapp installation finish, please run  | 
| 178 | 
            +
                    puts "Mindapp installation finish, please run the following command:\n"
         | 
| 179 | 
            +
                    puts "----------------------------------------\n"
         | 
| 180 | 
            +
                    puts "bundle install\n"
         | 
| 181 | 
            +
                    puts "rails generate mindapp:mongoid\n"
         | 
| 182 | 
            +
                    puts "----------------------------------------\n"
         | 
| 175 183 | 
             
                  end
         | 
| 176 184 |  | 
| 177 185 | 
             
                end
         | 
| @@ -22,7 +22,12 @@ module Mindapp | |
| 22 22 | 
             
                    end
         | 
| 23 23 | 
             
                  end
         | 
| 24 24 | 
             
                  def finish
         | 
| 25 | 
            -
                    puts "Mongoid finished configured for rails 5 and heroku.\ | 
| 25 | 
            +
                    puts "Mongoid finished configured for rails 5 and heroku.\n"
         | 
| 26 | 
            +
                    puts "Next: To set up user/password as admin/secret\n"
         | 
| 27 | 
            +
                    puts "Please run the following command:\n"
         | 
| 28 | 
            +
                    puts "----------------------------------------\n"
         | 
| 29 | 
            +
                    puts "rake mindapp:seed\n"
         | 
| 30 | 
            +
                    puts "----------------------------------------\n"
         | 
| 26 31 | 
             
                  end
         | 
| 27 32 | 
             
                end
         | 
| 28 33 | 
             
              end
         | 
| Binary file | 
| Binary file | 
| @@ -30,7 +30,7 @@ class ArticlesController < ApplicationController | |
| 30 30 | 
             
              end
         | 
| 31 31 |  | 
| 32 32 | 
             
              def my
         | 
| 33 | 
            -
                @articles = Article.where(user_id:  | 
| 33 | 
            +
                @articles = Article.where(user_id: current_ma_user).desc(:created_at).page(params[:page]).per(10)
         | 
| 34 34 | 
             
                @page_title       = 'Member Login'
         | 
| 35 35 | 
             
              end
         | 
| 36 36 |  | 
| @@ -48,7 +48,7 @@ class ArticlesController < ApplicationController | |
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| 50 50 | 
             
              def destroy
         | 
| 51 | 
            -
                if  | 
| 51 | 
            +
                if current_ma_user.role.upcase.split(',').include?("A") || current_ma_user == @article.user
         | 
| 52 52 | 
             
                  @article.destroy
         | 
| 53 53 | 
             
                end
         | 
| 54 54 | 
             
                  redirect_to :action=>'index'
         | 
| @@ -25,7 +25,7 @@ class MindappController < ApplicationController | |
| 25 25 | 
             
                redirect_to action:"pending"
         | 
| 26 26 | 
             
              end
         | 
| 27 27 | 
             
              def ajax_notice
         | 
| 28 | 
            -
                if notice=Mindapp::Notice.recent( | 
| 28 | 
            +
                if notice=Mindapp::Notice.recent(current_ma_user, request.env["REMOTE_ADDR"])
         | 
| 29 29 | 
             
                  notice.update_attribute :unread, false
         | 
| 30 30 | 
             
                  js = "notice('#{notice.message}');"
         | 
| 31 31 | 
             
                else
         | 
| @@ -123,7 +123,7 @@ class MindappController < ApplicationController | |
| 123 123 | 
             
                @runseq.start ||= Time.now
         | 
| 124 124 | 
             
                @runseq.status= 'R' # running
         | 
| 125 125 | 
             
                $runseq_id= @runseq.id
         | 
| 126 | 
            -
                $user_id=  | 
| 126 | 
            +
                $user_id= current_ma_user.try(:id)
         | 
| 127 127 | 
             
                set_global
         | 
| 128 128 | 
             
                controller = Kernel.const_get(@xvars['custom_controller']).new
         | 
| 129 129 | 
             
                result = controller.send(@runseq.code)
         | 
| @@ -148,23 +148,23 @@ class MindappController < ApplicationController | |
| 148 148 | 
             
              def run_output
         | 
| 149 149 | 
             
                init_vars(params[:id])
         | 
| 150 150 | 
             
                service= @xmain.service
         | 
| 151 | 
            -
                disp= get_option(" | 
| 152 | 
            -
                 | 
| 151 | 
            +
                disp= get_option("ma_display")
         | 
| 152 | 
            +
                ma_display = (disp && !affirm(disp)) ? false : true
         | 
| 153 153 | 
             
                if service
         | 
| 154 154 | 
             
                  f= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.html.erb"
         | 
| 155 155 | 
             
                  @ui= File.read(f)
         | 
| 156 156 | 
             
                  if Mindapp::Doc.where(:runseq_id=>@runseq.id).exists?
         | 
| 157 157 | 
             
                    @doc= Mindapp::Doc.where(:runseq_id=>@runseq.id).first
         | 
| 158 158 | 
             
                    @doc.update_attributes :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"),
         | 
| 159 | 
            -
                                           :xmain=>@xmain, :runseq=>@runseq, :user=> | 
| 160 | 
            -
                                           :ip=> get_ip, :service=>service, : | 
| 161 | 
            -
                                           : | 
| 159 | 
            +
                                           :xmain=>@xmain, :runseq=>@runseq, :user=>current_ma_user,
         | 
| 160 | 
            +
                                           :ip=> get_ip, :service=>service, :ma_display=>ma_display,
         | 
| 161 | 
            +
                                           :ma_secured => @xmain.service.ma_secured
         | 
| 162 162 | 
             
                  else
         | 
| 163 163 | 
             
                    @doc= Mindapp::Doc.create :name=> @runseq.name,
         | 
| 164 164 | 
             
                                              :content_type=>"output", :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"),
         | 
| 165 | 
            -
                                              :xmain=>@xmain, :runseq=>@runseq, :user=> | 
| 166 | 
            -
                                              :ip=> get_ip, :service=>service, : | 
| 167 | 
            -
                                              : | 
| 165 | 
            +
                                              :xmain=>@xmain, :runseq=>@runseq, :user=>current_ma_user,
         | 
| 166 | 
            +
                                              :ip=> get_ip, :service=>service, :ma_display=>ma_display,
         | 
| 167 | 
            +
                                              :ma_secured => @xmain.service.ma_secured
         | 
| 168 168 | 
             
                  end
         | 
| 169 169 | 
             
                  @message = defined?(MSG_NEXT) ? MSG_NEXT : "Next >"
         | 
| 170 170 | 
             
                  @message = "สิ้นสุดการทำงาน" if @runseq.end
         | 
| @@ -174,8 +174,8 @@ class MindappController < ApplicationController | |
| 174 174 | 
             
                  ma_log "Error: service not found"
         | 
| 175 175 | 
             
                  redirect_to_root
         | 
| 176 176 | 
             
                end
         | 
| 177 | 
            -
                # | 
| 178 | 
            -
                unless  | 
| 177 | 
            +
                #ma_display= get_option("ma_display")
         | 
| 178 | 
            +
                unless ma_display
         | 
| 179 179 | 
             
                  end_action
         | 
| 180 180 | 
             
                end
         | 
| 181 181 | 
             
              end
         | 
| @@ -186,9 +186,9 @@ class MindappController < ApplicationController | |
| 186 186 | 
             
                @ui= File.read(f).html_safe
         | 
| 187 187 | 
             
                @doc= Mindapp::Doc.create :name=> @runseq.name,
         | 
| 188 188 | 
             
                                          :content_type=>"mail", :data_text=> render_to_string(:inline=>@ui, :layout=>false),
         | 
| 189 | 
            -
                                          :xmain=>@xmain, :runseq=>@runseq, :user=> | 
| 190 | 
            -
                                          :ip=> get_ip, :service=>service, : | 
| 191 | 
            -
                                          : | 
| 189 | 
            +
                                          :xmain=>@xmain, :runseq=>@runseq, :user=>current_ma_user,
         | 
| 190 | 
            +
                                          :ip=> get_ip, :service=>service, :ma_display=>false,
         | 
| 191 | 
            +
                                          :ma_secured => @xmain.service.ma_secured
         | 
| 192 192 | 
             
                eval "@xvars[:#{@runseq.code}] = url_for(:controller=>'mindapp', :action=>'document', :id=>@doc.id)"
         | 
| 193 193 | 
             
                mail_from = get_option('from')
         | 
| 194 194 | 
             
                # sender= render_to_string(:inline=>mail_from) if mail_from
         | 
| @@ -228,7 +228,7 @@ class MindappController < ApplicationController | |
| 228 228 | 
             
                @xmain.status= 'R' # running
         | 
| 229 229 | 
             
                @xmain.save
         | 
| 230 230 | 
             
                @runseq.status='F'
         | 
| 231 | 
            -
                @runseq.user=  | 
| 231 | 
            +
                @runseq.user= current_ma_user
         | 
| 232 232 | 
             
                @runseq.stop= Time.now
         | 
| 233 233 | 
             
                @runseq.save
         | 
| 234 234 | 
             
                next_runseq= @xmain.runseqs.where(:rstep=> @runseq.rstep+1).first unless next_runseq
         | 
| @@ -260,8 +260,8 @@ class MindappController < ApplicationController | |
| 260 260 | 
             
                    :filename=> params.original_filename,
         | 
| 261 261 | 
             
                    :content_type => params.content_type || 'application/zip',
         | 
| 262 262 | 
             
                    :data_text=> '',
         | 
| 263 | 
            -
                    : | 
| 264 | 
            -
                    : | 
| 263 | 
            +
                    :ma_display=>true,
         | 
| 264 | 
            +
                    :ma_secured => @xmain.service.ma_secured )
         | 
| 265 265 | 
             
                if defined?(IMAGE_LOCATION)
         | 
| 266 266 | 
             
                  filename = "#{IMAGE_LOCATION}/f#{Param.gen(:asset_id)}"
         | 
| 267 267 | 
             
                  File.open(filename,"wb") { |f| f.write(params.read) }
         | 
| @@ -283,7 +283,7 @@ class MindappController < ApplicationController | |
| 283 283 | 
             
                    :filename=> params.original_filename,
         | 
| 284 284 | 
             
                    :content_type => params.content_type || 'application/zip',
         | 
| 285 285 | 
             
                    :data_text=> '',
         | 
| 286 | 
            -
                    : | 
| 286 | 
            +
                    :ma_display=>true, :ma_secured => @xmain.service.ma_secured )
         | 
| 287 287 | 
             
                if defined?(IMAGE_LOCATION)
         | 
| 288 288 | 
             
                  filename = "#{IMAGE_LOCATION}/f#{Param.gen(:asset_id)}"
         | 
| 289 289 | 
             
                  File.open(filename,"wb") { |f| f.write(params.read) }
         | 
| @@ -388,12 +388,12 @@ class MindappController < ApplicationController | |
| 388 388 | 
             
                                      :name=>service.name,
         | 
| 389 389 | 
             
                                      :ip=> get_ip,
         | 
| 390 390 | 
             
                                      :status=>'I', # init
         | 
| 391 | 
            -
                                      :user=> | 
| 391 | 
            +
                                      :user=>current_ma_user,
         | 
| 392 392 | 
             
                                      :xvars=> {
         | 
| 393 393 | 
             
                                          :service_id=>service.id,
         | 
| 394 394 | 
             
                                          :p=>params.to_unsafe_h,
         | 
| 395 395 | 
             
                                          :id=>params[:id],
         | 
| 396 | 
            -
                                          :user_id=> | 
| 396 | 
            +
                                          :user_id=>current_ma_user.try(:id),
         | 
| 397 397 | 
             
                                          :custom_controller=>custom_controller,
         | 
| 398 398 | 
             
                                          :host=>request.host,
         | 
| 399 399 | 
             
                                          :referer=>request.env['HTTP_REFERER']
         | 
| @@ -412,16 +412,16 @@ class MindappController < ApplicationController | |
| 412 412 | 
             
                  action= freemind2action(activity.elements['icon'].attributes['BUILTIN']) if activity.elements['icon']
         | 
| 413 413 | 
             
                  return false unless action
         | 
| 414 414 | 
             
                  i= i + 1
         | 
| 415 | 
            -
                   | 
| 415 | 
            +
                  output_ma_display= false
         | 
| 416 416 | 
             
                  if action=='output'
         | 
| 417 | 
            -
                     | 
| 418 | 
            -
                    if  | 
| 419 | 
            -
                       | 
| 417 | 
            +
                    ma_display= get_option_xml("ma_display", activity)
         | 
| 418 | 
            +
                    if ma_display && !affirm(ma_display)
         | 
| 419 | 
            +
                      output_ma_display= false
         | 
| 420 420 | 
             
                    else
         | 
| 421 | 
            -
                       | 
| 421 | 
            +
                      output_ma_display= true
         | 
| 422 422 | 
             
                    end
         | 
| 423 423 | 
             
                  end
         | 
| 424 | 
            -
                  j= j + 1 if (action=='form' ||  | 
| 424 | 
            +
                  j= j + 1 if (action=='form' || output_ma_display)
         | 
| 425 425 | 
             
                  @xvars['referer'] = activity.attributes['TEXT'] if action=='redirect'
         | 
| 426 426 | 
             
                  if action!= 'if'
         | 
| 427 427 | 
             
                    scode, name= text.split(':', 2)
         | 
| @@ -459,7 +459,7 @@ class MindappController < ApplicationController | |
| 459 459 | 
             
                end
         | 
| 460 460 | 
             
                $xmain= @xmain; $xvars= @xvars
         | 
| 461 461 | 
             
                $runseq_id= @runseq.id
         | 
| 462 | 
            -
                $user_id=  | 
| 462 | 
            +
                $user_id= current_ma_user.try(:id)
         | 
| 463 463 | 
             
              end
         | 
| 464 464 | 
             
              def init_vars_by_runseq(runseq_id)
         | 
| 465 465 | 
             
                @runseq= Mindapp::Runseq.find runseq_id
         | 
| @@ -476,7 +476,7 @@ class MindappController < ApplicationController | |
| 476 476 | 
             
                                       :filename=> (params[:file_name]||''),
         | 
| 477 477 | 
             
                                       :content_type => (params[:content_type] || 'application/zip'),
         | 
| 478 478 | 
             
                                       :data_text=> '',
         | 
| 479 | 
            -
                                       : | 
| 479 | 
            +
                                       :ma_display=>true
         | 
| 480 480 | 
             
                  path = (IMAGE_LOCATION || "tmp")
         | 
| 481 481 | 
             
                  File.open("#{path}/f#{doc.id}","wb") { |f|
         | 
| 482 482 | 
             
                    f.puts(params[:content])
         | 
| @@ -487,8 +487,8 @@ class MindappController < ApplicationController | |
| 487 487 | 
             
                end
         | 
| 488 488 | 
             
              end
         | 
| 489 489 | 
             
              def do_search
         | 
| 490 | 
            -
                if  | 
| 491 | 
            -
                  @docs = GmaDoc. | 
| 490 | 
            +
                if current_ma_user.ma_secured?
         | 
| 491 | 
            +
                  @docs = GmaDoc.search_ma_secured(@q.downcase, params[:page], PER_PAGE)
         | 
| 492 492 | 
             
                else
         | 
| 493 493 | 
             
                  @docs = GmaDoc.search(@q.downcase, params[:page], PER_PAGE)
         | 
| 494 494 | 
             
                end
         | 
| @@ -8,9 +8,10 @@ class SessionsController < ApplicationController | |
| 8 8 | 
             
              # then use attribute 'data-ajax'=>'false'
         | 
| 9 9 | 
             
              # see app/views/sessions/new.html.erb for sample
         | 
| 10 10 | 
             
              def create
         | 
| 11 | 
            -
                 | 
| 11 | 
            +
                auth = request.env["omniauth.auth"]
         | 
| 12 | 
            +
                user = User.from_omniauth(auth)
         | 
| 12 13 | 
             
                session[:user_id] = user.id
         | 
| 13 | 
            -
                 | 
| 14 | 
            +
                refresh_to root_path
         | 
| 14 15 | 
             
              rescue
         | 
| 15 16 | 
             
                redirect_to root_path, :alert=> "Authentication failed, please try again."
         | 
| 16 17 | 
             
              end
         | 
| @@ -2,12 +2,12 @@ | |
| 2 2 | 
             
            class UsersController < ApplicationController
         | 
| 3 3 | 
             
              def index
         | 
| 4 4 | 
             
                @today = Date.today
         | 
| 5 | 
            -
                @xmains =  | 
| 5 | 
            +
                @xmains = current_ma_user.xmains.in(status:['R','I']).asc(:created_at)
         | 
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 8 | 
             
              # mindapp methods
         | 
| 9 9 | 
             
              def update_user
         | 
| 10 | 
            -
                # can't use session,  | 
| 10 | 
            +
                # can't use session, current_ma_user inside mindapp methods
         | 
| 11 11 | 
             
                $user.update_attribute :email, $xvars["enter_user"]["user"]["email"]
         | 
| 12 12 | 
             
              end
         | 
| 13 13 | 
             
              def change_password
         | 
| @@ -14,7 +14,7 @@ class Mindapp::Doc | |
| 14 14 | 
             
              belongs_to :user
         | 
| 15 15 | 
             
              belongs_to :service, :class_name => "Mindapp::Service"
         | 
| 16 16 | 
             
              field :ip, :type => String
         | 
| 17 | 
            -
              field : | 
| 17 | 
            +
              field :ma_display, :type => Boolean
         | 
| 18 18 | 
             
              field :ma_secured, :type => Boolean
         | 
| 19 19 |  | 
| 20 20 | 
             
              def self.search(q, page, per_page=PER_PAGE)
         | 
| @@ -5,26 +5,32 @@ class User | |
| 5 5 | 
             
              field :code, :type => String
         | 
| 6 6 | 
             
              field :email, :type => String
         | 
| 7 7 | 
             
              field :role, :type => String
         | 
| 8 | 
            +
              field :user, :type => String
         | 
| 8 9 | 
             
              belongs_to :identity, :polymorphic => true, :optional => true
         | 
| 9 10 | 
             
              has_many :xmains, :class_name => "Mindapp::Xmain"
         | 
| 10 11 |  | 
| 11 12 | 
             
              def has_role(role1)
         | 
| 12 13 | 
             
                return role.upcase.split(',').include?(role1.upcase)
         | 
| 13 14 | 
             
              end
         | 
| 15 | 
            +
              
         | 
| 14 16 | 
             
              def self.from_omniauth(auth)
         | 
| 15 | 
            -
                where(: | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 24 | 
            -
             | 
| 17 | 
            +
                where(auth.slice(:uid, :provider, :email)).first_or_create do |user|
         | 
| 18 | 
            +
                  case auth.provider 
         | 
| 19 | 
            +
                    when 'identity'
         | 
| 20 | 
            +
                      identity = Identity.find auth.uid
         | 
| 21 | 
            +
                      user.code = identity.code
         | 
| 22 | 
            +
                      user.email = identity.email
         | 
| 23 | 
            +
                    else
         | 
| 24 | 
            +
                      user.email = auth.info.email
         | 
| 25 | 
            +
                      user.uid = auth.uid
         | 
| 26 | 
            +
                      user.provider = auth.provider
         | 
| 27 | 
            +
                      user.code = auth.info.name
         | 
| 28 | 
            +
                      user.role = "M"
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                  end
         | 
| 25 31 | 
             
                end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
              def  | 
| 32 | 
            +
                     
         | 
| 33 | 
            +
              def ma_secured?
         | 
| 28 34 | 
             
                role.upcase.split(',').include?(ma_secured_ROLE)
         | 
| 29 35 | 
             
              end
         | 
| 30 36 | 
             
            end
         | 
    
        data/lib/generators/mindapp/templates/app/views/articles/edit_article/select_article.html.erb
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            <%
         | 
| 2 | 
            -
              if  | 
| 2 | 
            +
              if current_ma_user.role.upcase.split(',').include?("A")
         | 
| 3 3 | 
             
                article = Article.all.desc(:created_at)
         | 
| 4 4 | 
             
              else
         | 
| 5 | 
            -
                article = Article.where(user:  | 
| 5 | 
            +
                article = Article.where(user: current_ma_user).desc(:created_at)
         | 
| 6 6 | 
             
              end
         | 
| 7 7 | 
             
            %>
         | 
| 8 8 | 
             
            <div class="field" data-role="fieldcontain">
         | 
| @@ -17,7 +17,7 @@ | |
| 17 17 | 
             
                  %td= article.updated_at
         | 
| 18 18 | 
             
                  %td(align='center')
         | 
| 19 19 | 
             
                    - next unless login?
         | 
| 20 | 
            -
                    - unless  | 
| 20 | 
            +
                    - unless current_ma_user.role.upcase.split(',').include?("A")
         | 
| 21 21 | 
             
                      - next unless article.user
         | 
| 22 | 
            -
                      - next unless  | 
| 22 | 
            +
                      - next unless current_ma_user == article.user
         | 
| 23 23 | 
             
                    = link_to image_tag('delete.png', style:'border:none; float:none;'), "#", :onclick=>"if (confirm('Please Confirm')) {location.hash='/articles/destroy/#{article.id}';}"
         | 
| @@ -1,12 +1,9 @@ | |
| 1 | 
            -
            - head = login? ?  | 
| 1 | 
            +
            - head = login? ? current_ma_user.code : DEFAULT_HEADER
         | 
| 2 2 | 
             
            %div{"data-context" => "a#default", "data-hash" => "crumbs", "data-id" => "menu", "data-role" => "panel"}
         | 
| 3 3 | 
             
              #main{"data-role" => "page"}
         | 
| 4 4 | 
             
                %div{"data-role" => "header", "data-theme" => "b", "data-backbtn"=>"false"}
         | 
| 5 5 | 
             
                  %h1= head
         | 
| 6 6 | 
             
                %div{"data-role" => "content", "data-id" => "menu_mm"}
         | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 7 | 
             
                  %ul{"data-role" => "listview", "data-theme" => "g"}
         | 
| 11 8 | 
             
                    %li
         | 
| 12 9 | 
             
                      %a{"data-panel" => "main", "data-id" => "home", :href => "/mindapp"} Home
         | 
| @@ -23,3 +20,5 @@ | |
| 23 20 | 
             
                        %a{:href=>new_identity_path, "data-panel" => "main"} Sign Up
         | 
| 24 21 | 
             
                    %li
         | 
| 25 22 | 
             
                      = link_to "Refresh", "#", :onclick=>"window.location.replace('/')"
         | 
| 23 | 
            +
                    - if !login?    
         | 
| 24 | 
            +
                      = link_to image_tag( 'facebook-sign-in-button.png'), 'auth/facebook', rel: "external"  
         | 
| @@ -2,8 +2,8 @@ | |
| 2 2 | 
             
            - Mindapp::Module.all.asc(:seq).each do |m|
         | 
| 3 3 | 
             
              - unless m.role.blank?
         | 
| 4 4 | 
             
                - next unless login?
         | 
| 5 | 
            -
                - next unless  | 
| 6 | 
            -
                - next unless  | 
| 5 | 
            +
                - next unless current_ma_user.role
         | 
| 6 | 
            +
                - next unless current_ma_user.role.upcase.split(',').include?(m.role.upcase)
         | 
| 7 7 | 
             
              %li
         | 
| 8 8 | 
             
                = m.name
         | 
| 9 9 | 
             
                %ul
         | 
| @@ -14,8 +14,8 @@ | |
| 14 14 | 
             
                      - next if (!eval(s.rule))
         | 
| 15 15 | 
             
                    - unless s.role.blank?
         | 
| 16 16 | 
             
                      - next unless login?
         | 
| 17 | 
            -
                      - next unless  | 
| 18 | 
            -
                      - next unless  | 
| 17 | 
            +
                      - next unless current_ma_user.role
         | 
| 18 | 
            +
                      - next unless current_ma_user.role.upcase.split(',').include?(s.role.upcase)
         | 
| 19 19 | 
             
                    - if s.code.downcase=="link"
         | 
| 20 20 | 
             
                      - name, url = s.name.split(":", 2)
         | 
| 21 21 | 
             
                      - url.strip!
         | 
| @@ -13,7 +13,7 @@ | |
| 13 13 | 
             
                - @runseq= Mindapp::Runseq.find(xmain.current_runseq)
         | 
| 14 14 | 
             
                - next unless @runseq
         | 
| 15 15 | 
             
                - next unless %w(form output pdf).include?(@runseq.action)
         | 
| 16 | 
            -
                - next if @xmain.runseqs.first==@xmain.current_runseq && @xmain.user!= | 
| 16 | 
            +
                - next if @xmain.runseqs.first==@xmain.current_runseq && @xmain.user!=current_ma_user
         | 
| 17 17 | 
             
                - next unless authorize?
         | 
| 18 18 | 
             
                %tr
         | 
| 19 19 | 
             
                  %td= link_to xmain.xid, :controller=>"mindapp", :action=>"run", :id=>xmain.id
         | 
| @@ -1,18 +1,19 @@ | |
| 1 1 | 
             
            %div(style="text-align:center")
         | 
| 2 | 
            -
             | 
| 2 | 
            +
            = image_tag "logo_mindapp.png"
         | 
| 3 | 
            +
             | 
| 3 4 |  | 
| 4 5 | 
             
            %h2 You are working on 
         | 
| 5 6 | 
             
            %ul
         | 
| 6 | 
            -
              %li gem 'mindapp2', '~> 0.1.1. | 
| 7 | 
            +
              %li gem 'mindapp2', '~> 0.1.1.4'
         | 
| 7 8 |  | 
| 8 9 | 
             
            %h2 Requirements
         | 
| 9 10 | 
             
            %ul
         | 
| 10 | 
            -
              %li Rails 5.1. | 
| 11 | 
            +
              %li Rails 5.1.2
         | 
| 11 12 | 
             
              %li Rubygems 2.4.1
         | 
| 12 13 |  | 
| 13 14 | 
             
            %h2 Installation
         | 
| 14 15 | 
             
            %ul
         | 
| 15 | 
            -
              %li gem 'mindapp2', '~> 0.1.1. | 
| 16 | 
            +
              %li gem 'mindapp2', '~> 0.1.1.4'
         | 
| 16 17 | 
             
              %li bundle
         | 
| 17 18 | 
             
              %li rails generate mindapp:install
         | 
| 18 19 | 
             
              %li bundle
         | 
| @@ -1,12 +1,12 @@ | |
| 1 1 | 
             
            .field(data-role="fieldcontain")
         | 
| 2 2 | 
             
              %label.ui-input-text Name
         | 
| 3 | 
            -
              = b  | 
| 3 | 
            +
              = b current_ma_user.code
         | 
| 4 4 | 
             
            .field(data-role="fieldcontain")
         | 
| 5 5 | 
             
              %label.ui-input-text Email
         | 
| 6 | 
            -
              = b  | 
| 6 | 
            +
              = b current_ma_user.email
         | 
| 7 7 | 
             
            .field(data-role="fieldcontain")
         | 
| 8 8 | 
             
              %label.ui-input-text Role
         | 
| 9 | 
            -
              = b  | 
| 9 | 
            +
              = b current_ma_user.role
         | 
| 10 10 |  | 
| 11 11 | 
             
            - if @xmains
         | 
| 12 12 | 
             
              %h2 Pending Tasks
         | 
    
        data/lib/mindapp2.rb
    CHANGED
    
    
    
        data/lib/mindapp2/helpers.rb
    CHANGED
    
    | @@ -74,12 +74,12 @@ module Mindapp | |
| 74 74 | 
             
                  %w(call ws redirect invoke email).include? s
         | 
| 75 75 | 
             
                end
         | 
| 76 76 | 
             
                def set_global
         | 
| 77 | 
            -
                  $xmain= @xmain ; $runseq = @runseq ; $user =  | 
| 77 | 
            +
                  $xmain= @xmain ; $runseq = @runseq ; $user = current_ma_user ; $xvars= @xmain.xvars; $ip = request.env["REMOTE_ADDR"]
         | 
| 78 78 | 
             
                end
         | 
| 79 79 | 
             
                def authorize? # use in pending tasks
         | 
| 80 80 | 
             
                  @runseq= @xmain.runseqs.find @xmain.current_runseq
         | 
| 81 81 | 
             
                  return false unless @runseq
         | 
| 82 | 
            -
                  @user =  | 
| 82 | 
            +
                  @user = current_ma_user
         | 
| 83 83 | 
             
                  set_global
         | 
| 84 84 | 
             
                  return false unless eval(@runseq.rule) if @runseq.rule
         | 
| 85 85 | 
             
                  return true if true_action?(@runseq.action)
         | 
| @@ -94,8 +94,8 @@ module Mindapp | |
| 94 94 | 
             
                def authorize_init? # use when initialize new transaction
         | 
| 95 95 | 
             
                  # check module role
         | 
| 96 96 | 
             
                  mrole = @service.module.role
         | 
| 97 | 
            -
                  return false if mrole && ! | 
| 98 | 
            -
                  return false if mrole && ! | 
| 97 | 
            +
                  return false if mrole && !current_ma_user
         | 
| 98 | 
            +
                  return false if mrole && !current_ma_user.has_role(mrole)
         | 
| 99 99 |  | 
| 100 100 | 
             
                  # check step 1 role
         | 
| 101 101 | 
             
                  xml= @service.xml
         | 
| @@ -103,11 +103,11 @@ module Mindapp | |
| 103 103 | 
             
                  role= get_option_xml("role", step1) || ""
         | 
| 104 104 | 
             
              #    rule= get_option_xml("rule", step1) || true
         | 
| 105 105 | 
             
                  return true if role==""
         | 
| 106 | 
            -
                  unless  | 
| 106 | 
            +
                  unless current_ma_user
         | 
| 107 107 | 
             
                    return role.blank?
         | 
| 108 108 | 
             
                  else
         | 
| 109 | 
            -
                    return false unless  | 
| 110 | 
            -
                    return  | 
| 109 | 
            +
                    return false unless current_ma_user.role
         | 
| 110 | 
            +
                    return current_ma_user.has_role(role)
         | 
| 111 111 | 
             
                  end
         | 
| 112 112 | 
             
                end
         | 
| 113 113 | 
             
                def ma_log(message)
         | 
| @@ -179,7 +179,7 @@ module Mindapp | |
| 179 179 | 
             
                end
         | 
| 180 180 |  | 
| 181 181 | 
             
                # methods that I don't know where they came from
         | 
| 182 | 
            -
                def  | 
| 182 | 
            +
                def current_ma_user
         | 
| 183 183 | 
             
                  if session[:user_id]
         | 
| 184 184 | 
             
                    return @user ||= User.find(session[:user_id]['$oid'])
         | 
| 185 185 | 
             
                  else
         | 
| @@ -241,7 +241,7 @@ module Mindapp | |
| 241 241 | 
             
                        rule= get_option_xml("rule", s) || ""
         | 
| 242 242 | 
             
                        ma_service= Mindapp::Service.find_or_create_by :module_code=> ma_module.code, :code=> scode, :name=> sname
         | 
| 243 243 | 
             
                        ma_service.update_attributes :xml=>s.to_s, :name=>sname,
         | 
| 244 | 
            -
                          :list=>listed(s), :ma_secured=> | 
| 244 | 
            +
                          :list=>listed(s), :ma_secured=>ma_secured?(s),
         | 
| 245 245 | 
             
                          :module_id=>ma_module.id, :seq => seq,
         | 
| 246 246 | 
             
                          :confirm=> get_option_xml("confirm", xml),
         | 
| 247 247 | 
             
                          :role => role, :rule => rule, :uid=> ma_service.id.to_s
         | 
| @@ -254,7 +254,7 @@ module Mindapp | |
| 254 254 | 
             
                        rule= get_option_xml("rule", step1) || ""
         | 
| 255 255 | 
             
                        ma_service= Mindapp::Service.find_or_create_by :module_code=> ma_module.code, :code=> scode
         | 
| 256 256 | 
             
                        ma_service.update_attributes :xml=>s.to_s, :name=>sname,
         | 
| 257 | 
            -
                          :list=>listed(s), :ma_secured=> | 
| 257 | 
            +
                          :list=>listed(s), :ma_secured=>ma_secured?(s),
         | 
| 258 258 | 
             
                          :module_id=>ma_module.id, :seq => seq,
         | 
| 259 259 | 
             
                          :confirm=> get_option_xml("confirm", xml),
         | 
| 260 260 | 
             
                          :role => role, :rule => rule, :uid=> ma_service.id.to_s
         | 
| @@ -309,7 +309,7 @@ module Mindapp | |
| 309 309 | 
             
                end
         | 
| 310 310 | 
             
                def own_xmain?
         | 
| 311 311 | 
             
                  if $xmain
         | 
| 312 | 
            -
                    return  | 
| 312 | 
            +
                    return current_ma_user.id==$xvars['user_id']
         | 
| 313 313 | 
             
                  else
         | 
| 314 314 | 
             
                    # if eval on first step would return true so user can start service
         | 
| 315 315 | 
             
                    return true
         | 
| @@ -336,7 +336,7 @@ module Mindapp | |
| 336 336 | 
             
                  end
         | 
| 337 337 | 
             
                  return !icons.include?("closed")
         | 
| 338 338 | 
             
                end
         | 
| 339 | 
            -
                def  | 
| 339 | 
            +
                def ma_secured?(node)
         | 
| 340 340 | 
             
                  icons=[]
         | 
| 341 341 | 
             
                  node.each_element("icon") do |nn|
         | 
| 342 342 | 
             
                    icons << nn.attributes["BUILTIN"]
         | 
    
        data/lib/mindapp2/version.rb
    CHANGED
    
    
    
        data/mindapp2.gemspec
    CHANGED
    
    | @@ -6,7 +6,7 @@ require "mindapp2/version" | |
| 6 6 | 
             
            Gem::Specification.new do |spec|
         | 
| 7 7 | 
             
              spec.name          = "mindapp2"
         | 
| 8 8 | 
             
              spec.version       = Mindapp::VERSION
         | 
| 9 | 
            -
              spec.authors       = [" | 
| 9 | 
            +
              spec.authors       = [ "Prateep Kul", "Korakot Leemakdej"]
         | 
| 10 10 | 
             
              spec.email         = ["1.0@kul.asia"]
         | 
| 11 11 |  | 
| 12 12 | 
             
              spec.summary       = %q{Rails workflow from mind map}
         | 
    
        metadata
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mindapp2
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1.1. | 
| 4 | 
            +
              version: 0.1.1.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 | 
            -
            - Korakot Leemakdej
         | 
| 8 7 | 
             
            - Prateep Kul
         | 
| 8 | 
            +
            - Korakot Leemakdej
         | 
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: exe
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2017- | 
| 12 | 
            +
            date: 2017-10-02 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: bundler
         | 
| @@ -62,6 +62,7 @@ extra_rdoc_files: [] | |
| 62 62 | 
             
            files:
         | 
| 63 63 | 
             
            - ".gitignore"
         | 
| 64 64 | 
             
            - ".travis.yml"
         | 
| 65 | 
            +
            - CHANGELOG.md
         | 
| 65 66 | 
             
            - CODE_OF_CONDUCT.md
         | 
| 66 67 | 
             
            - Gemfile
         | 
| 67 68 | 
             
            - LICENSE.txt
         | 
| @@ -97,6 +98,7 @@ files: | |
| 97 98 | 
             
            - lib/generators/mindapp/templates/app/assets/images/cross.png
         | 
| 98 99 | 
             
            - lib/generators/mindapp/templates/app/assets/images/delete.png
         | 
| 99 100 | 
             
            - lib/generators/mindapp/templates/app/assets/images/external-link.png
         | 
| 101 | 
            +
            - lib/generators/mindapp/templates/app/assets/images/facebook-sign-in-button.png
         | 
| 100 102 | 
             
            - lib/generators/mindapp/templates/app/assets/images/facebooksmall.png
         | 
| 101 103 | 
             
            - lib/generators/mindapp/templates/app/assets/images/favicon.ico
         | 
| 102 104 | 
             
            - lib/generators/mindapp/templates/app/assets/images/freemind(mm).png
         | 
| @@ -347,4 +349,3 @@ signing_key: | |
| 347 349 | 
             
            specification_version: 4
         | 
| 348 350 | 
             
            summary: Rails workflow from mind map
         | 
| 349 351 | 
             
            test_files: []
         | 
| 350 | 
            -
            has_rdoc: 
         |