Sha256: c95a123ed64b3161526c60a07f011ec8cc939c8e4d685d0467f599bb01119028

Contents?: true

Size: 1.79 KB

Versions: 24

Compression:

Stored size: 1.79 KB

Contents

    def b(s)
      "<b>#{s}</b>".html_safe
    end
    def link_to_blank(body, url_options = {}, html_options = {})
      link_to(body, url_options, html_options.merge(target: "_blank"))
    end
    def code_text(s) # old def code(s)
      "<pre style='background-color: #efffef;'><code class='ruby' lang='ruby'>#{s}</code></pre>".html_safe
    end

    def refresh_to(url='/', option={})
      if option[:alert]
        ma_log option[:alert]
      end
      # skip # 
      # Rails 5.2 not allow to use js inline call
      render inline: "<script>window.location.replace('#{url}')</script>"
      # redirect_to url
      # render js: "window.location.replace(\'#{url}\')" 
    end

    # def refresh_to
    #   respond_to do |format|
    #     format.js { render :js => "refresh();" }
    #   end
    # end

    def read_binary(path)
      File.open path, "rb" do |f| f.read end
    end
    def redirect_to_root
      redirect_to root_path
    end

    # Todo refactor code
    def get_option(opt, runseq=@runseq)
      xml= REXML::Document.new(runseq.xml).root
      url=''
      # get option from second element of node using '//node'
      xml.each_element('//node') do |n|
        if n.attributes['TEXT']
          text = n.attributes['TEXT']
          url= text if text =~ /^#{opt}:\s*/
        end
      end
      return nil if url.blank?
      c, h= url.split(':', 2)
      opt= h ? h.strip : false
    end
    def ma_comment?(s)
      s[0]==35
    end
    def get_ip
      request.env['HTTP_X_FORWARDED_FOR'] || request.env['REMOTE_ADDR']
    end
    def get_default_role
      default_role= Jinda::Role.where(:code =>'default').first
      return default_role ? default_role.name.to_s : ''
    end

    def sign_in?
      if current_ma_user.present?
        return true
      else
        return false
      end
    end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
jinda-0.8.0 lib/jinda/refresh.rb
jinda-0.7.7.4 lib/jinda/refresh.rb
jinda-0.7.7.3 lib/jinda/refresh.rb
jinda-0.7.7.2 lib/jinda/refresh.rb
jinda-0.7.7.1 lib/jinda/refresh.rb
jinda_mind-1.0.0 lib/jinda/refresh.rb
jinda-0.7.7 lib/jinda/refresh.rb
jinda-0.7.6 lib/jinda/refresh.rb
jinda-0.7.5.5 lib/jinda/refresh.rb
jinda-0.7.5.4 lib/jinda/refresh.rb
jinda-0.7.5.3 lib/jinda/refresh.rb
jinda-0.7.5.2 lib/jinda/refresh.rb
jinda-0.7.5.0 lib/jinda/refresh.rb
jinda-0.7.3 lib/jinda/refresh.rb
jinda-0.7.2 lib/jinda/refresh.rb
jinda-0.7.1 lib/jinda/refresh.rb
jinda-0.7.0.4 lib/jinda/refresh.rb
jinda-0.7.0.3 lib/jinda/refresh.rb
jinda-0.7.0.2 lib/jinda/refresh.rb
jinda-0.7.0.1 lib/jinda/refresh.rb