├── Rakefile ├── lib ├── generators │ └── mindapp │ │ ├── templates │ │ ├── app │ │ │ ├── models │ │ │ │ ├── .gitkeep │ │ │ │ ├── mindapp │ │ │ │ │ ├── role.rb │ │ │ │ │ ├── module.rb │ │ │ │ │ ├── notice.rb │ │ │ │ │ ├── service.rb │ │ │ │ │ ├── runseq.rb │ │ │ │ │ ├── xmain.rb │ │ │ │ │ └── doc.rb │ │ │ │ ├── identity.rb │ │ │ │ ├── user.rb │ │ │ │ └── param.rb │ │ │ ├── helpers │ │ │ │ ├── admins_helper.rb │ │ │ │ ├── devs_helper.rb │ │ │ │ └── users_helper.rb │ │ │ ├── controllers │ │ │ │ ├── devs_controller.rb │ │ │ │ ├── identities_controller.rb │ │ │ │ ├── admins_controller.rb │ │ │ │ ├── users_controller.rb │ │ │ │ ├── sessions_controller.rb │ │ │ │ └── mindapp_controller.rb │ │ │ ├── views │ │ │ │ ├── mindapp │ │ │ │ │ ├── pending.haml │ │ │ │ │ ├── _model.md │ │ │ │ │ ├── _pending_home.haml │ │ │ │ │ ├── _modul.md │ │ │ │ │ ├── index.html.haml │ │ │ │ │ ├── help.haml │ │ │ │ │ ├── _activity.md │ │ │ │ │ ├── logs.haml │ │ │ │ │ ├── search.haml │ │ │ │ │ ├── error_logs.haml │ │ │ │ │ ├── _service.md │ │ │ │ │ ├── feed.rss.builder │ │ │ │ │ ├── _pending_page.haml │ │ │ │ │ ├── _menu.haml │ │ │ │ │ ├── _menu_mm.haml │ │ │ │ │ ├── doc.md │ │ │ │ │ ├── _static.haml │ │ │ │ │ ├── run_form.haml │ │ │ │ │ ├── run_output.haml │ │ │ │ │ └── status.haml │ │ │ │ ├── layouts │ │ │ │ │ ├── application.haml │ │ │ │ │ ├── gmail.html.erb │ │ │ │ │ ├── _page.haml │ │ │ │ │ ├── mobile.html.erb │ │ │ │ │ ├── utf8.html.erb │ │ │ │ │ ├── _head.html.erb │ │ │ │ │ ├── _top.html.erb │ │ │ │ │ ├── print.html.erb │ │ │ │ │ ├── mobilejq.html.erb │ │ │ │ │ └── _full.haml │ │ │ │ ├── users │ │ │ │ │ ├── user │ │ │ │ │ │ └── enter_user.html.erb │ │ │ │ │ ├── pwd │ │ │ │ │ │ └── enter.html.erb │ │ │ │ │ └── index.haml │ │ │ │ ├── admins │ │ │ │ │ └── edit_role │ │ │ │ │ │ ├── edit_role.html.erb │ │ │ │ │ │ └── select_user.html.erb │ │ │ │ ├── mindapp_mailer │ │ │ │ │ └── gmail.html.erb │ │ │ │ ├── sessions │ │ │ │ │ └── new.html.erb │ │ │ │ └── identities │ │ │ │ │ └── new.html.erb │ │ │ ├── assets │ │ │ │ ├── images │ │ │ │ │ ├── add.png │ │ │ │ │ ├── cog.png │ │ │ │ │ ├── new.gif │ │ │ │ │ ├── new.png │ │ │ │ │ ├── anchor.png │ │ │ │ │ ├── cancel.png │ │ │ │ │ ├── clock.png │ │ │ │ │ ├── cross.png │ │ │ │ │ ├── delete.png │ │ │ │ │ ├── help.png │ │ │ │ │ ├── house.png │ │ │ │ │ ├── logout.png │ │ │ │ │ ├── page.png │ │ │ │ │ ├── pencil.png │ │ │ │ │ ├── report.png │ │ │ │ │ ├── tick.png │ │ │ │ │ ├── user.png │ │ │ │ │ ├── account.png │ │ │ │ │ ├── calendar.png │ │ │ │ │ ├── page_pdf.png │ │ │ │ │ ├── printer.png │ │ │ │ │ ├── refresh.png │ │ │ │ │ ├── rssmall.png │ │ │ │ │ ├── ajax-loader.gif │ │ │ │ │ ├── arrow_left.png │ │ │ │ │ ├── arrow_right.png │ │ │ │ │ ├── chart_bar.png │ │ │ │ │ ├── page_attach.png │ │ │ │ │ ├── page_green.png │ │ │ │ │ ├── page_output.png │ │ │ │ │ ├── view_code.png │ │ │ │ │ ├── control_play.png │ │ │ │ │ ├── external-link.png │ │ │ │ │ ├── logo_mindapp.png │ │ │ │ │ ├── arrow_turn_left.png │ │ │ │ │ ├── arrow_turn_right.png │ │ │ │ │ ├── ajax-loader-circle.gif │ │ │ │ │ ├── application_double.png │ │ │ │ │ ├── application_form_edit.png │ │ │ │ │ └── control_fastforward.png │ │ │ │ ├── stylesheets │ │ │ │ │ ├── images │ │ │ │ │ │ ├── bg.png │ │ │ │ │ │ ├── del2.png │ │ │ │ │ │ ├── ff.png │ │ │ │ │ │ ├── rss3.png │ │ │ │ │ │ ├── rss4.png │ │ │ │ │ │ ├── cancel.png │ │ │ │ │ │ ├── close.png │ │ │ │ │ │ ├── deli4.png │ │ │ │ │ │ ├── fbook.png │ │ │ │ │ │ ├── tech3.png │ │ │ │ │ │ ├── tech4.png │ │ │ │ │ │ ├── down-left.png │ │ │ │ │ │ ├── overlay.png │ │ │ │ │ │ ├── search_bg.png │ │ │ │ │ │ ├── stumble2.png │ │ │ │ │ │ ├── stumble4.png │ │ │ │ │ │ ├── tab-left.png │ │ │ │ │ │ ├── tab-right.png │ │ │ │ │ │ ├── twitter3.png │ │ │ │ │ │ ├── twitter4.png │ │ │ │ │ │ ├── ajax-loader.png │ │ │ │ │ │ ├── button_blue.png │ │ │ │ │ │ ├── button_red.png │ │ │ │ │ │ ├── down-right.png │ │ │ │ │ │ ├── button_black.png │ │ │ │ │ │ ├── icons-18-black.png │ │ │ │ │ │ ├── icons-18-white.png │ │ │ │ │ │ ├── icons-36-black.png │ │ │ │ │ │ ├── icons-36-white.png │ │ │ │ │ │ ├── icon-search-black.png │ │ │ │ │ │ ├── ui-anim_basic_16x16.gif │ │ │ │ │ │ ├── ui-icons_217bc0_256x240.png │ │ │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ │ │ │ ├── ui-icons_454545_256x240.png │ │ │ │ │ │ ├── ui-icons_469bdd_256x240.png │ │ │ │ │ │ ├── ui-icons_6da8d5_256x240.png │ │ │ │ │ │ ├── ui-icons_888888_256x240.png │ │ │ │ │ │ ├── ui-icons_cd0a0a_256x240.png │ │ │ │ │ │ ├── ui-icons_d8e7f3_256x240.png │ │ │ │ │ │ ├── ui-icons_f9bd01_256x240.png │ │ │ │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ │ │ │ ├── ui-bg_flat_55_fbec88_40x100.png │ │ │ │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ │ │ │ ├── ui-bg_glass_75_d0e5f5_1x400.png │ │ │ │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ │ │ │ ├── ui-bg_glass_85_dfeffc_1x400.png │ │ │ │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ │ │ │ ├── ui-bg_gloss-wave_55_5c9ccc_500x100.png │ │ │ │ │ │ ├── ui-bg_inset-hard_100_f5f8f9_1x100.png │ │ │ │ │ │ ├── ui-bg_inset-hard_100_fcfdfd_1x100.png │ │ │ │ │ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ │ │ │ ├── indicator.gif │ │ │ │ │ ├── fonts │ │ │ │ │ │ ├── sarabun.eot │ │ │ │ │ │ ├── sarabun.ttf │ │ │ │ │ │ ├── sarabun.woff │ │ │ │ │ │ ├── sarabun_bold.ttf │ │ │ │ │ │ ├── sarabun_italic.ttf │ │ │ │ │ │ ├── sarabun_bolditalic.ttf │ │ │ │ │ │ ├── thsarabunnew-webfont.eot │ │ │ │ │ │ ├── thsarabunnew-webfont.ttf │ │ │ │ │ │ ├── thsarabunnew-webfont.woff │ │ │ │ │ │ ├── thsarabunnew_bold-webfont.eot │ │ │ │ │ │ ├── thsarabunnew_bold-webfont.ttf │ │ │ │ │ │ ├── thsarabunnew_bold-webfont.woff │ │ │ │ │ │ ├── thsarabunnew_italic-webfont.eot │ │ │ │ │ │ ├── thsarabunnew_italic-webfont.ttf │ │ │ │ │ │ ├── thsarabunnew_italic-webfont.woff │ │ │ │ │ │ ├── thsarabunnew_bolditalic-webfont.eot │ │ │ │ │ │ ├── thsarabunnew_bolditalic-webfont.ttf │ │ │ │ │ │ ├── thsarabunnew_bolditalic-webfont.woff │ │ │ │ │ │ └── thsarabunnew.css │ │ │ │ │ ├── devs.css.scss │ │ │ │ │ ├── users.css.scss │ │ │ │ │ ├── admins.css.scss │ │ │ │ │ ├── application.css.scss │ │ │ │ │ ├── sarabun.css │ │ │ │ │ ├── jquery.mobile.grids.collapsible.css │ │ │ │ │ ├── jquery.mobile.splitview.css │ │ │ │ │ ├── mindapp.css │ │ │ │ │ └── jquery.mobile.datebox.css │ │ │ │ └── javascripts │ │ │ │ │ ├── admins.js.coffee │ │ │ │ │ ├── devs.js.coffee │ │ │ │ │ ├── users.js.coffee │ │ │ │ │ ├── disable_enter_key.js │ │ │ │ │ ├── mindapp.js │ │ │ │ │ ├── application.js │ │ │ │ │ ├── iscroll-wrapper.js │ │ │ │ │ └── jquery.mobile.splitview.js │ │ │ ├── mailers │ │ │ │ └── mindapp_mailer.rb │ │ │ └── mindapp │ │ │ │ ├── template │ │ │ │ └── view.html.erb │ │ │ │ └── index.mm │ │ ├── spec │ │ │ ├── controllers │ │ │ │ ├── devs_controller_spec.rb │ │ │ │ ├── admins_controller_spec.rb │ │ │ │ └── users_controller_spec.rb │ │ │ ├── helpers │ │ │ │ ├── devs_helper_spec.rb │ │ │ │ ├── users_helper_spec.rb │ │ │ │ └── admins_helper_spec.rb │ │ │ └── spec_helper.rb │ │ ├── cloudinary.yml │ │ ├── seeds.rb │ │ └── mindapp.yml │ │ ├── USAGE │ │ ├── mongoid_generator.rb │ │ └── install_generator.rb ├── mindapp │ ├── version.rb │ ├── railtie.rb │ └── helpers.rb ├── mindapp.rb └── tasks │ └── mindapp.rake ├── Gemfile ├── .gitignore ├── LICENSE.txt ├── mindapp.gemspec └── README.md /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/mindapp/version.rb: -------------------------------------------------------------------------------- 1 | module Mindapp 2 | VERSION = "0.0.8" 3 | end 4 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/helpers/admins_helper.rb: -------------------------------------------------------------------------------- 1 | module AdminsHelper 2 | end 3 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/helpers/devs_helper.rb: -------------------------------------------------------------------------------- 1 | module DevsHelper 2 | end 3 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/helpers/users_helper.rb: -------------------------------------------------------------------------------- 1 | module UsersHelper 2 | end 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in mindapp.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/controllers/devs_controller.rb: -------------------------------------------------------------------------------- 1 | class DevsController < ApplicationController 2 | end 3 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/pending.haml: -------------------------------------------------------------------------------- 1 | = render :partial=>"pending_page", :locals=>{:xmains=>@xmains} 2 | -------------------------------------------------------------------------------- /lib/mindapp.rb: -------------------------------------------------------------------------------- 1 | require "mindapp/version" 2 | require 'mindapp/railtie' 3 | 4 | module Mindapp 5 | # Your code goes here... 6 | end 7 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/spec/controllers/devs_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe DevsController do 4 | 5 | end 6 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/spec/controllers/admins_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe AdminsController do 4 | 5 | end 6 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/spec/controllers/users_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe UsersController do 4 | 5 | end 6 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/add.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/cog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/cog.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/new.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/new.gif -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/new.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/anchor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/anchor.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/cancel.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/clock.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/cross.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/delete.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/help.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/house.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/house.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/logout.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/page.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/pencil.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/report.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/tick.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/user.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/account.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/account.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/calendar.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/page_pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/page_pdf.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/printer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/printer.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/refresh.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/rssmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/rssmall.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/ajax-loader.gif -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/arrow_left.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/arrow_right.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/chart_bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/chart_bar.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/page_attach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/page_attach.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/page_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/page_green.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/page_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/page_output.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/view_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/view_code.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/control_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/control_play.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/external-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/external-link.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/logo_mindapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/logo_mindapp.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/application.haml: -------------------------------------------------------------------------------- 1 | - if request.accept=="text/html, */*; q=0.01" 2 | = render "layouts/page" 3 | - else 4 | = render "layouts/full" 5 | -------------------------------------------------------------------------------- /lib/generators/mindapp/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Explain the generator 3 | 4 | Example: 5 | rails generate new Thing 6 | 7 | This will create: 8 | what/will/it/create 9 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/arrow_turn_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/arrow_turn_left.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/arrow_turn_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/arrow_turn_right.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/bg.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/del2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/del2.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ff.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/rss3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss3.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/rss4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss4.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/indicator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/indicator.gif -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/ajax-loader-circle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/ajax-loader-circle.gif -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/application_double.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/application_double.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.eot -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/cancel.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/close.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/deli4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/deli4.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/fbook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/fbook.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/tech3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech3.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/tech4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech4.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_model.md: -------------------------------------------------------------------------------- 1 | 2 | ### <%= model %> 3 | 4 | <% model_file= "#{Rails.root}/app/models/#{model}.rb" %> 5 | <%= code_div File.read(model_file) %> 6 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/application_form_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/application_form_edit.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/images/control_fastforward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/images/control_fastforward.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.woff -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/down-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-left.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/overlay.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/search_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/search_bg.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble2.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble4.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-left.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-right.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter3.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter4.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bold.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ajax-loader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ajax-loader.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/button_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_blue.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/button_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_red.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/down-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-right.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/controllers/identities_controller.rb: -------------------------------------------------------------------------------- 1 | class IdentitiesController < ApplicationController 2 | def new 3 | @identity = env['omniauth.identity'] 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_italic.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/button_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_black.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-black.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-white.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-black.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-white.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bolditalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bolditalic.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.eot -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/icon-search-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/icon-search-black.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-anim_basic_16x16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-anim_basic_16x16.gif -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.woff -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.eot -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_217bc0_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_217bc0_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_469bdd_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_469bdd_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_6da8d5_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_6da8d5_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_d8e7f3_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_d8e7f3_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_f9bd01_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_f9bd01_256x240.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.woff -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.eot -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.woff -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_55_fbec88_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_55_fbec88_40x100.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_d0e5f5_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_d0e5f5_1x400.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_85_dfeffc_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_85_dfeffc_1x400.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.eot -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.ttf -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.woff -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_f5f8f9_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_f5f8f9_1x100.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_fcfdfd_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_fcfdfd_1x100.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/devs.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the devs controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/songrit/mindapp/HEAD/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/users.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the users controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/gmail.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <%= yield %> 8 | 9 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/admins.css.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the admins controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/users/user/enter_user.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | user = current_user 3 | %> 4 |

<%= user.code %>

5 | <%= fields_for user do |f| %> 6 | <%= f.label :email, "Email" %> 7 | <%= f.text_field :email %> 8 | <% end %> 9 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/admins/edit_role/edit_role.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | user = User.find_by :code=> $xvars["select_user"]["code"] 3 | %> 4 | Role codes seperated by comma 5 |

6 | <%= label_tag :role, "Role" %> 7 | <%= text_field_tag :role, user.role %> 8 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/mindapp/role.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Mindapp::Role 3 | include Mongoid::Document 4 | include Mongoid::Timestamps 5 | field :code, :type => String 6 | field :name, :type => String 7 | belongs_to :user 8 | end 9 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp_mailer/gmail.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <%= raw @ui %> 8 | 9 | 10 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/controllers/admins_controller.rb: -------------------------------------------------------------------------------- 1 | class AdminsController < ApplicationController 2 | def update_role 3 | user = User.find_by :code=> $xvars["select_user"]["code"] 4 | user.update_attribute :role, $xvars["edit_role"]["role"] 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/mailers/mindapp_mailer.rb: -------------------------------------------------------------------------------- 1 | class MindappMailer < ActionMailer::Base 2 | default from: "from@example.com" 3 | def gmail(ui, to="", subject="", from="") 4 | @ui = ui 5 | mail(:to => to, :subject => subject, :from => from) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_pending_home.haml: -------------------------------------------------------------------------------- 1 | #pending{"data-role" => "page"} 2 | %div{"data-role" => "header" , "data-backbtn"=>"false"} 3 | %h1 Pending Tasks 4 | %div{"data-role" => "content"} 5 | = render :partial => "pending_page", :locals=>{:xmains=>@xmains} 6 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/admins.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ 4 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/devs.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ 4 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/users.js.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ 4 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/admins/edit_role/select_user.html.erb: -------------------------------------------------------------------------------- 1 |

2 | <%= label_tag :code, 'User code' %> 3 | <%= select_tag :code, options_from_collection_for_select(User.all.asc(:code), :code, :code), "data-native-menu"=>"false" %> 4 |
5 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/cloudinary.yml: -------------------------------------------------------------------------------- 1 | development: 2 | cloud_name: "sample" 3 | api_key: "874837483274837" 4 | api_secret: "a676b67565c6767a6767d6767f676fe1" 5 | 6 | production: 7 | cloud_name: "sample" 8 | api_key: "874837483274837" 9 | api_secret: "a676b67565c6767a6767d6767f676fe1" 10 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/users/pwd/enter.html.erb: -------------------------------------------------------------------------------- 1 | <%= label_tag :epass, "Existing password" %> 2 | <%= password_field_tag :epass %> 3 | <%= label_tag :npass, "New password" %> 4 | <%= password_field_tag :npass %> 5 | <%= label_tag :npass_confirm, "New password confirmation" %> 6 | <%= password_field_tag :npass_confirm %> 7 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/seeds.rb: -------------------------------------------------------------------------------- 1 | unless Identity.where(code:"admin").exists? 2 | identity= Identity.create :code => "admin", :email => "admin@test.com", :password => "secret", 3 | :password_confirmation => "secret" 4 | User.create :provider => "identity", :uid => identity.id.to_s, :code => identity.code, 5 | :email => identity.email, :role => "M,A,D" 6 | end 7 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/mindapp.yml: -------------------------------------------------------------------------------- 1 | development: 2 | server: "http://localhost:9292/faye" 3 | secret_token: "secret" 4 | test: 5 | server: "http://localhost:9292/faye" 6 | secret_token: "secret" 7 | production: 8 | server: "http://example.com/faye" 9 | secret_token: "<%= ActiveSupport::SecureRandom.hex(32) %>" 10 | signature_expiration: 3600 # one hour 11 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/mindapp/module.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Mindapp::Module 3 | include Mongoid::Document 4 | field :uid, :type => String 5 | field :code, :type => String 6 | field :name, :type => String 7 | field :role, :type => String 8 | field :seq, :type => Integer 9 | 10 | has_many :services, :class_name => "Mindapp::Service" 11 | end 12 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_modul.md: -------------------------------------------------------------------------------- 1 | 2 | ### ระบบงาน<%= modul.name %> 3 | 4 | <%- controller_file= "#{Rails.root}/app/controllers/#{modul.code}_controller.rb" %> 5 | <%- md_file= "#{Rails.root}/app/controllers/#{modul.code}.md" %> 6 | 7 | <%= File.read md_file if File.exist?(md_file) %> 8 | 9 | <%= render :partial=>'mindapp/service.md', :collection=> modul.services.asc(:seq) %> 10 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/disable_enter_key.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("input").keypress(function (evt) { 3 | //Deterime where our character code is coming from within the event 4 | var charCode = evt.charCode || evt.keyCode; 5 | if (charCode == 13) { //Enter key's keycode 6 | alert("Please click the button"); 7 | return false; 8 | } 9 | }); 10 | }) 11 | -------------------------------------------------------------------------------- /lib/mindapp/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'mindapp' 2 | require 'mindapp/helpers' 3 | 4 | module Mindapp 5 | require 'rails' 6 | class Railtie < Rails::Railtie 7 | initializer "testing" do |app| 8 | ActionController::Base.send :include, Mindapp::Helpers 9 | end 10 | rake_tasks do 11 | load "tasks/mindapp.rake" 12 | end 13 | end 14 | end 15 | 16 | module ApplicationHelper 17 | include Mindapp::Helpers 18 | end 19 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/mindapp.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $('body').show(); 3 | $.extend( $.mobile , { 4 | loadingMessage: 'please wait', 5 | pageLoadErrorMessage: "Error" 6 | }); 7 | 8 | // TODO loop all $('.ui-header .ui-btn-text') 9 | if ($('.ui-header .ui-btn-text').first().text()=="") { 10 | $('.ui-crumbs').hide(); 11 | }; 12 | }); 13 | 14 | function validate() { return true; } 15 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/mindapp/notice.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Mindapp::Notice 3 | include Mongoid::Document 4 | include Mongoid::Timestamps 5 | field :message, :type => String 6 | field :unread, :type => Boolean 7 | field :ip, :type => String 8 | belongs_to :user 9 | 10 | def self.recent(user_id, ip) 11 | where(unread: true, ip: ip).last 12 | # where(unread: true, user_id: user_id, ip: ip).last 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/users/index.haml: -------------------------------------------------------------------------------- 1 | .field(data-role="fieldcontain") 2 | %label.ui-input-text Name 3 | = b current_user.code 4 | .field(data-role="fieldcontain") 5 | %label.ui-input-text Email 6 | = b current_user.email 7 | .field(data-role="fieldcontain") 8 | %label.ui-input-text Role 9 | = b current_user.role 10 | 11 | - if @xmains 12 | %h2 Pending Tasks 13 | = render :partial=>"mindapp/pending_page", :locals=>{:xmains=>@xmains} 14 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/index.html.haml: -------------------------------------------------------------------------------- 1 | %div(style="text-align:center") 2 | = image_tag "logo_mindapp.png" 3 | 4 | %h2 Requirements 5 | %ul 6 | %li Rails 3.2 7 | %li Rubygems 1.8 8 | 9 | %h2 Installation 10 | %ul 11 | %li gem 'mindapp', may need to uncomment therubyracer 12 | %li bundle 13 | %li rails generate mindapp:install 14 | %li rake db:seed, will create initial user admin:secret 15 | %li when update app/mindapp/index.mm, run rake mindapp:update 16 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/_page.haml: -------------------------------------------------------------------------------- 1 | - if @cache 2 | - cache = {} 3 | - else 4 | - cache = {"data-cache"=>"never"} 5 | - if @backbtn 6 | - backbtn= {"data-backbtn"=>"true"} 7 | - else 8 | - backbtn= {"data-backbtn"=>"false"} 9 | %div{{"data-role" => "page"}.merge(cache) } 10 | %div{{"data-role" => "header"}.merge(backbtn)} 11 | %h1= @title || DEFAULT_TITLE 12 | %div{"data-role" => "content"} 13 | = yield 14 | 15 | :javascript 16 | document.title= "#{@title}"; 17 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/sessions/new.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_tag "/auth/identity/callback", {'data-ajax'=>'false'} do %> 2 |
3 | <%= label_tag :auth_key, "User name" %> 4 | <%= text_field_tag :auth_key %> 5 |
6 |
7 | <%= label_tag :password, "Password" %> 8 | <%= password_field_tag :password %> 9 |
10 |
<%= submit_tag "Sign In" %>
11 | <% end %> 12 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/identity.rb: -------------------------------------------------------------------------------- 1 | class Identity 2 | include Mongoid::Document 3 | include OmniAuth::Identity::Models::Mongoid 4 | self.auth_key 'code' 5 | 6 | field :code, :type => String 7 | field :email, :type => String 8 | field :password_digest, :type => String 9 | 10 | validates_presence_of :code 11 | validates_uniqueness_of :code 12 | validates_uniqueness_of :email 13 | # validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i 14 | end 15 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/spec/helpers/devs_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the DevsHelper. For example: 5 | # 6 | # describe DevsHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # helper.concat_strings("this","that").should == "this that" 10 | # end 11 | # end 12 | # end 13 | describe DevsHelper do 14 | pending "add some examples to (or delete) #{__FILE__}" 15 | end 16 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/spec/helpers/users_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the UsersHelper. For example: 5 | # 6 | # describe UsersHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # helper.concat_strings("this","that").should == "this that" 10 | # end 11 | # end 12 | # end 13 | describe UsersHelper do 14 | pending "add some examples to (or delete) #{__FILE__}" 15 | end 16 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/help.haml: -------------------------------------------------------------------------------- 1 | %div(style="text-align:center") 2 | = image_tag "logo_mindapp.png" 3 | %h2 การติดตั้ง 4 | %ul 5 | %li 6 | ติดตั้ง Google Chrome โดยดาวน์โหลดจาก 7 | = link_to "https://www.google.com/chrome", "https://www.google.com/chrome", :target=>"_blank" 8 | %li etc. 9 | %h2 การใช้งาน 10 | %ul 11 | %li aaa 12 | %li 13 | bbb 14 | %ul 15 | %li bb1 16 | %li bb2 17 | %h2 ผู้ดูแลระบบ 18 | %ul 19 | %li การทำสำรองข้อมูล 20 | %li การบูรณาการข้อมูลกลาง 21 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/spec/helpers/admins_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the AdminsHelper. For example: 5 | # 6 | # describe AdminsHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # helper.concat_strings("this","that").should == "this that" 10 | # end 11 | # end 12 | # end 13 | describe AdminsHelper do 14 | pending "add some examples to (or delete) #{__FILE__}" 15 | end 16 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/mobile.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Worldwaypoint 8 | <%= stylesheet_link_tag 'mobile', 'molengo' %> 9 | 10 | 11 | <%= yield %> 12 | 13 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_activity.md: -------------------------------------------------------------------------------- 1 | <%- code, name = activity['TEXT'].split(':',2) %> 2 | ##### งาน <%= service.name %> ขั้นตอนที่ <%= j %> <%= name %> 3 | <%- img_file= "#{Rails.root}/app/views/#{service.module}/#{service.code}/#{code}.png" %> 4 | <%- if File.exist?(img_file)%> 5 | <%- img = Base64.encode64(File.read(img_file)) %> 6 | 7 | <%- end %> 8 | <%- md_file= "#{Rails.root}/app/views/#{service.module}/#{service.code}/#{code}.md" %> 9 | 10 | <%= File.read md_file if File.exist?(md_file) %> 11 | -------------------------------------------------------------------------------- /lib/generators/mindapp/mongoid_generator.rb: -------------------------------------------------------------------------------- 1 | module Mindapp 2 | module Generators 3 | class MongoidGenerator < Rails::Generators::Base 4 | desc "Set up mongoid config" 5 | def setup_mongoid 6 | generate "mongoid:config" 7 | inject_into_file 'config/mongoid.yml', :after => ' # raise_not_found_error: true' do 8 | "\n raise_not_found_error: false" 9 | end 10 | end 11 | def finish 12 | puts "Mongoid configured, please run rake mindapp:seed to set up admin/secret user" 13 | end 14 | 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/mindapp/service.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Mindapp::Service 3 | include Mongoid::Document 4 | field :uid, :type => String 5 | field :module_code, :type => String 6 | field :code, :type => String 7 | field :name, :type => String 8 | field :xml, :type => String 9 | field :role, :type => String 10 | field :rule, :type => String 11 | field :seq, :type => Integer 12 | field :list, :type => Boolean 13 | field :secured, :type => Boolean 14 | field :confirm, :type => Boolean 15 | 16 | belongs_to :module, :class_name => "Mindapp::Module" 17 | end 18 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/utf8.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | eLocal Output 5 | 6 | 7 | <%= stylesheet_link_tag "sarabun", :media=>"all" %> 8 | 9 | 19 | 20 | <%= yield %> 21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/_head.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | eLocal 7 | 8 | 9 | <%= stylesheet_link_tag "mindapp", "sarabun" %> 10 | 11 | <%= javascript_include_tag "jquery.tools.min.js" %> 12 | <%= javascript_include_tag "application", "flashobject", "FusionCharts" %> 13 | 14 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/_top.html.erb: -------------------------------------------------------------------------------- 1 |
  • <%= link_to "หน้าแรก","/" %>
  • 2 |
  • <%= mail_to "songrit@gmail.com", "ติดต่อ" %>
  • 3 |
  • <%= link_to "#{image_tag 'twittersmall.png'}","http://twitter.com/songrit", :title => "Twitter", :class=>"top-icon" %>
  • 4 |
  • <%= link_to "#{image_tag 'facebooksmall.png'}","http://www.facebook.com/songrit", :title => "Facebook", :class=>"top-icon" %>
  • 5 |
  • <%= link_to "#{image_tag 'help.png'}","/main/doc", :title => "คู่มือการใช้งาน", :class=>"top-icon" %>
  • 6 | 11 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/logs.haml: -------------------------------------------------------------------------------- 1 | - @title= "Mindapp Logs" 2 | = paginate @xmains 3 | %table{:id=>"pending-table", :width=>"100%"} 4 | %tr{:style=>"color:white; background-color:#97BF60;"} 5 | %th id 6 | %th task 7 | %th step 8 | %th starter 9 | %th begin 10 | %th status 11 | - @xmains.each do |xmain| 12 | - @xmain= xmain 13 | - next unless xmain.current_runseq 14 | - @runseq= Mindapp::Runseq.find(xmain.current_runseq) 15 | - next unless @runseq 16 | %tr 17 | %td= link_to xmain.xid, "/mindapp/status?xid=#{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(align="center")= status_icon(xmain.status) 23 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/print.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | eLocal 8 | 9 | <%= stylesheet_link_tag "sarabun", :media=>"all" %> 10 | 11 | 18 | 19 | <%= yield %> 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/mindapp/runseq.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Mindapp::Runseq 3 | include Mongoid::Document 4 | include Mongoid::Timestamps 5 | belongs_to :user 6 | belongs_to :xmain, :class_name => "Mindapp::Xmain" 7 | 8 | field :action, :type => String 9 | field :status, :type => String 10 | field :code, :type => String 11 | field :name, :type => String 12 | field :role, :type => String 13 | field :rule, :type => String 14 | field :rstep, :type => Integer 15 | field :form_step, :type => Integer 16 | field :start, :type => DateTime 17 | field :stop, :type => DateTime 18 | field :end, :type => Boolean 19 | field :xml, :type => String 20 | field :ip, :type => String 21 | 22 | scope :form_action, ->{where(:action.in=> ['form','output','pdf'])} 23 | 24 | end 25 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/application.css.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, 6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the top of the 9 | * compiled file, but it's generally better to create a new file per style scope. 10 | * 11 | *= require jquery.mobile 12 | *= require jquery.mobile.splitview 13 | *= require jquery.mobile.grids.collapsible 14 | 15 | *= require jquery.mobile.datebox.css 16 | *= require sarabun 17 | *= require mindapp 18 | */ 19 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/search.haml: -------------------------------------------------------------------------------- 1 | /%h3= "Search #{@q}" 2 | = will_paginate @docs, :class=>'flickr_pagination', :params=>{:q=>@q} 3 | /= will_paginate @xmains, :class=>'flickr_pagination', :params=>{:q=>@q} 4 | 5 | %table{:width=>"100%"} 6 | %tr{:style=>"color:white; background-color:#6A6A6A; text-shadow:none;"} 7 | %th id 8 | %th task 9 | %th starter 10 | %th begin 11 | %th end 12 | %th status 13 | - @xmains.each do |xmain| 14 | %tr 15 | %td= link_to xmain.id, :action=>"status", :id=>xmain.id 16 | %td= link_to xmain.name, :action=>"status", :id=>xmain.id 17 | %td{:align=>'center'}= xmain.ma_user.full_name 18 | %td= date_thai xmain.start, :date_only=>true 19 | %td= xmain.stop ? date_thai(xmain.stop, :date_only=>true) : ' ' 20 | %td(align='center')= status_icon xmain 21 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // the compiled file. 9 | // 10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 11 | // GO AFTER THE REQUIRES BELOW. 12 | // 13 | //= require jquery-1.7.1 14 | //= require jquery.mobile.splitview 15 | //= require jquery.mobile 16 | //= require iscroll-wrapper 17 | //= require iscroll 18 | //= require mindapp 19 | //= require jquery.mobile.datebox 20 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/controllers/users_controller.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class UsersController < ApplicationController 3 | def index 4 | @today = Date.today 5 | @xmains = current_user.xmains.in(status:['R','I']).asc(:created_at) 6 | end 7 | 8 | # mindapp methods 9 | def update_user 10 | # can't use session, current_user inside mindapp methods 11 | $user.update_attribute :email, $xvars["enter_user"]["user"]["email"] 12 | end 13 | def change_password 14 | # check if old password correct 15 | identity = Identity.find_by :code=> $user.code 16 | if identity.authenticate($xvars["enter"]["epass"]) 17 | identity.password = $xvars["enter"]["npass"] 18 | identity.password_confirmation = $xvars["enter"]["npass_confirm"] 19 | identity.save 20 | ma_log "Password changed" 21 | else 22 | ma_log "Unauthorized access" 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/error_logs.haml: -------------------------------------------------------------------------------- 1 | - @title= "Error Logs" 2 | = paginate @xmains 3 | %table{:id=>"pending-table", :width=>"100%"} 4 | %tr{:style=>"color:white; background-color:#97BF60;"} 5 | %th id 6 | %th task 7 | %th step 8 | %th starter 9 | %th begin 10 | %th message 11 | - @xmains.each do |xmain| 12 | - @xmain= xmain 13 | - next unless xmain.current_runseq 14 | - @runseq= Mindapp::Runseq.find(xmain.current_runseq) 15 | - next unless @runseq 16 | %tr 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) 23 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/controllers/sessions_controller.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | class SessionsController < ApplicationController 3 | def new 4 | @title= 'Sign In' 5 | end 6 | 7 | # to refresh the page, must know BEFOREHAND that the action needs refresh 8 | # then use attribute 'data-ajax'=>'false' 9 | # see app/views/sessions/new.html.erb for sample 10 | def create 11 | user = User.from_omniauth(env["omniauth.auth"]) 12 | session[:user_id] = user.id 13 | redirect_to '/mindapp/pending' 14 | rescue 15 | redirect_to root_path, :alert=> "Authentication failed, please try again." 16 | end 17 | 18 | def destroy 19 | session[:user_id] = nil 20 | # redirect_to '/mindapp/help' 21 | refresh_to root_path 22 | end 23 | 24 | def failure 25 | ma_log "Authentication failed, please try again." 26 | redirect_to root_path, :alert=> "Authentication failed, please try again." 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User 2 | include Mongoid::Document 3 | field :provider, :type => String 4 | field :uid, :type => String 5 | field :code, :type => String 6 | field :email, :type => String 7 | field :role, :type => String 8 | belongs_to :identity 9 | has_many :xmains, :class_name => "Mindapp::Xmain" 10 | 11 | def has_role(role1) 12 | return role.upcase.split(',').include?(role1.upcase) 13 | end 14 | def self.from_omniauth(auth) 15 | where(:provider=> auth["provider"], :uid=> auth["uid"]).first || create_with_omniauth(auth) 16 | end 17 | def self.create_with_omniauth(auth) 18 | identity = Identity.find auth.uid 19 | create! do |user| 20 | user.provider = auth.provider 21 | user.uid = auth.uid 22 | user.code = identity.code 23 | user.email = identity.email 24 | user.role = "M" 25 | end 26 | end 27 | def secured? 28 | role.upcase.split(',').include?(SECURED_ROLE) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_service.md: -------------------------------------------------------------------------------- 1 | <%- d= Nokogiri::XML(service.xml) %> 2 | <%- if service.code=="link" %> 3 | #### งาน<%= service.name.split(':')[0] %> 4 | <%- if !(d/'node/node').blank? && (d/'node/node')[0]['TEXT'] %> 5 | <%= uncomment (d/'node/node')[0]['TEXT'] %> 6 | <%- end %> 7 | <%- else %> 8 | #### งาน<%= service.name %> 9 | <%- md_file= "#{Rails.root}/app/views/#{service.module.code}/#{service.code}.md" %> 10 | 11 | <%= File.read md_file if File.exist?(md_file) %> 12 | <%- j= 1 %> 13 | <%- (d/'/node/node').each do |activity| %> 14 | <%- next unless (activity/'icon')[0] %> 15 | <%- action= freemind2action((activity/'icon')[0]['BUILTIN']) %> 16 | <%- next unless (action=='form') %> 17 | <%= render :partial=>'mindapp/activity.md', :locals=>{:activity=>activity, :j=>j, :service=>service} %> 18 | <%- j= j + 1 %> 19 | <%- end %> 20 | <%- end %> 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/mindapp/template/view.html.erb: -------------------------------------------------------------------------------- 1 | <%# 2 | doc = Doc.new :issue_on=> Date.today, :process_at => Time.now 3 | %> 4 | <%#= fields_for doc do |f| %> 5 | <%#= f.label :rnum, "Reference number" %> 6 | <%#= f.text_field :rnum %> 7 | 11 | <%#= f.label :issue_on, "Dated" %> 12 | <%#= f.date_field :issue_on, "blackDays"=>[0,6] %> 13 | <%#= f.label :summary, "Summary" %> 14 | <%#= f.text_area :summary, :cols=>50, :rows=>6 %> 15 | <%#= f.label :dscan, "Attached document" %> 16 | <%#= f.file_field :dscan %> 17 | <%# end %> 18 | <%#= label_tag :hotel, "Ungroup field" %> 19 | <%#= text_field_tag :hotel %> 20 | 24 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/feed.rss.builder: -------------------------------------------------------------------------------- 1 | xml.instruct! # 2 | xml.comment! "a comment" # 3 | xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do 4 | xml.title "My Atom Feed" 5 | # xml.subtitle h(@feed.subtitle), "type" => 'html' 6 | xml.link url_for( :only_path => false, 7 | :controller => 'main', 8 | :action => 'atom' ) 9 | xml.updated Time.now.iso8601 10 | xml.author do 11 | xml.name "Jens-Christian Fischer" 12 | xml.email "jcfischer@gmail.com" 13 | end 14 | @waypoints.each do |entry| 15 | xml.entry do 16 | xml.code entry.code 17 | xml.title entry.name 18 | xml.link "href" => url_for( :only_path => false, 19 | :controller => 'entries', 20 | :action => 'show', 21 | :id => entry ) 22 | xml.id entry.uid 23 | xml.updated entry.updated_at.iso8601 24 | xml.summary h(entry.description) 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 songrit 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/param.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | class Param 3 | include Mongoid::Document 4 | validates_uniqueness_of :code 5 | # mindapp begin 6 | include Mongoid::Timestamps 7 | field :code, :type => String 8 | field :pid, :type => String 9 | field :yearly, :type => Boolean 10 | field :description, :type => String 11 | # mindapp end 12 | 13 | def self.get(code) 14 | p= where(:code=> code).first 15 | p.pid 16 | end 17 | def self.set(code, pid) 18 | p= where(:code=> code).first 19 | p.pid = pid.to_s 20 | p.save 21 | end 22 | def self.gen(code) 23 | p= where(:code=> code).first 24 | unless p 25 | p= self.create! :code => code, :pid => '0', :yearly => false, :description => 'auto' 26 | end 27 | if p.yearly 28 | num, year = p.pid.split('/') 29 | y_now = (Time.now.year.to_i) -1957 30 | if year.to_i==y_now 31 | p.pid = "#{num.to_i+1}/#{y_now}" 32 | else # new year, restart counter 33 | p.pid = "1/#{y_now}" 34 | end 35 | else 36 | p.pid = (p.pid.to_i+1).to_s 37 | end 38 | p.save 39 | return p.pid 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/mobilejq.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ระบบรายงานสถานการณ์ β 6 | <%= stylesheet_link_tag '/jqtouch/jqtouch.min.css' %> 7 | <%= stylesheet_link_tag '/jqtouch/themes/apple/theme.min.css' %> 8 | <%= javascript_include_tag '/jqtouch/jquery.1.3.2.min.js' %> 9 | <%= javascript_include_tag '/jqtouch/jqtouch.min.js' %> 10 | 13 | 14 | 15 | <%= yield %> 16 |
    17 |
    18 |

    ข้อมูล

    19 | Cancel 20 |
    21 |
    22 | ระบบรายงานสถานการณ์ เป็นระบบที่รวบรวมข้อมูลยุทธศาสตร์เชิงรุก 23 | ที่เกี่ยวข้องกับสถานการณ์ในปัจจุบัน โดยมีขั้นตอนคือ 24 |

    1. ทีมงานรวบรวมข่าวประจำวัน 25 |
    2. เตรียมข้อมูลเชิงลึกสำหรับผู้บริหารสืบค้น 26 |
    3. นำข้อมูลเข้าสู่ระบบที่สามารถเรียกใช้งานได้สะดวก 27 |

    28 |
    29 | 30 | 31 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_pending_page.haml: -------------------------------------------------------------------------------- 1 | - @xmains= xmains 2 | %table{:id=>"pending-table", :width=>"100%"} 3 | %tr{:style=>"color:white; background-color:#97BF60;"} 4 | %th id 5 | %th task 6 | %th step 7 | %th starter 8 | %th begin 9 | %th cancel 10 | - @xmains.each do |xmain| 11 | - @xmain= xmain 12 | - next unless xmain.current_runseq 13 | - @runseq= Mindapp::Runseq.find(xmain.current_runseq) 14 | - next unless @runseq 15 | - next unless %w(form output pdf).include?(@runseq.action) 16 | - next if @xmain.runseqs.first==@xmain.current_runseq && @xmain.user!=current_user 17 | - next unless authorize? 18 | %tr 19 | %td= link_to xmain.xid, :controller=>"mindapp", :action=>"run", :id=>xmain.id 20 | %td= link_to xmain.name, :controller=>"mindapp", :action=>"run", :id=>xmain.id 21 | %td= @runseq.name 22 | %td{:align=>'center'}= xmain.user.try :code 23 | %td= xmain.start.strftime("%c") 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}';}" 25 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_menu.haml: -------------------------------------------------------------------------------- 1 | - head = login? ? current_user.code : DEFAULT_HEADER 2 | %div{"data-context" => "a#default", "data-hash" => "crumbs", "data-id" => "menu", "data-role" => "panel"} 3 | #main{"data-role" => "page"} 4 | %div{"data-role" => "header", "data-theme" => "b", "data-backbtn"=>"false"} 5 | %h1= head 6 | %div{"data-role" => "content"} 7 | %ul{"data-role" => "listview", "data-theme" => "g"} 8 | %li 9 | %a{"data-panel" => "main", :href => "/mindapp"} Home 10 | = render "/mindapp/menu_mm" 11 | - if login? 12 | %li 13 | %a{:href=>"/mindapp/pending", "data-rel"=>"dialog", "data-panel" => "main"} Pending Tasks 14 | %li 15 | %a{"data-panel" => "main", :href => logout_path, "data-ajax"=>"false"} Sign Out 16 | - else 17 | %li 18 | %a{:href=>new_session_path, "data-rel"=>"dialog", "data-panel" => "main"} Sign In 19 | %li 20 | %a{:href=>new_identity_path, "data-rel"=>"dialog", "data-panel" => "main"} Sign Up 21 | %li 22 | = link_to "Refresh", "#", :onclick=>"window.location.replace('/')" 23 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/iscroll-wrapper.js: -------------------------------------------------------------------------------- 1 | /* 2 | * iscroll-wrapper for jQquery. 3 | * http://sanraul.com/projects/jqloader/ 4 | * 5 | * Copyright (c) 2011 Raul Sanchez (http://www.sanraul.com) 6 | * 7 | * Dual licensed under the MIT and GPL licenses: 8 | * http://www.opensource.org/licenses/mit-license.php 9 | * http://www.gnu.org/licenses/gpl.html 10 | */ 11 | 12 | (function($){ 13 | $.fn.iscroll = function(options){ 14 | if(this.data('iScrollReady') == null){ 15 | var that = this; 16 | var options = $.extend({}, options); 17 | options.onScrollEnd = function(){ 18 | that.triggerHandler('onScrollEnd', [this]); 19 | }; 20 | arguments.callee.object = new iScroll(this.get(0), options); 21 | // NOTE: for some reason in a complex page the plugin does not register 22 | // the size of the element. This will fix that in the meantime. 23 | setTimeout(function(scroller){ 24 | scroller.refresh(); 25 | }, 1000, arguments.callee.object); 26 | this.data('iScrollReady', true); 27 | }else{ 28 | arguments.callee.object.refresh(); 29 | } 30 | return arguments.callee.object; 31 | }; 32 | })(jQuery); -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_menu_mm.haml: -------------------------------------------------------------------------------- 1 | - process_services 2 | - Mindapp::Module.all.asc(:seq).each do |m| 3 | - unless m.role.blank? 4 | - next unless login? 5 | - next unless current_user.role 6 | - next unless current_user.role.upcase.split(',').include?(m.role.upcase) 7 | %li 8 | = m.name 9 | %ul 10 | - m.services.asc(:seq).each do |s| 11 | - next unless s.list 12 | - xml= REXML::Document.new(s.xml).root 13 | - unless s.rule.blank? 14 | - next if (!eval(s.rule)) 15 | - unless s.role.blank? 16 | - next unless login? 17 | - next unless current_user.role 18 | - next unless current_user.role.upcase.split(',').include?(s.role.upcase) 19 | - if s.code.downcase=="link" 20 | - name, url = s.name.split(":", 2) 21 | - url.strip! 22 | - else 23 | - name= s.name; url= "/mindapp/init?s=#{s.module_code}:#{s.code}" 24 | - if s.confirm 25 | %li 26 | %a{"data-panel"=>"main", :onclick=>"if (confirm('Please Confirm')) {location.hash='#{url}'};"}= name 27 | - else 28 | %li 29 | %a{"data-panel"=>"main", :href=> url}= name 30 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/mindapp/xmain.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Mindapp::Xmain 3 | include Mongoid::Document 4 | field :xid, :type => String 5 | # Mindapp begin 6 | include Mongoid::Timestamps 7 | belongs_to :service, :class_name => "Mindapp::Service" 8 | field :start, :type => DateTime 9 | field :stop, :type => DateTime 10 | field :name, :type => String 11 | field :ip, :type => String 12 | field :status, :type => String 13 | belongs_to :user 14 | field :xvars, :type => Hash 15 | field :current_runseq, :type => String 16 | # Mindapp end 17 | 18 | has_many :runseqs, :class_name => "Mindapp::Runseq" 19 | has_many :docs, :class_name => "Mindapp::Doc" 20 | before_create :assign_xid 21 | 22 | 23 | # number of xmains on the specified date 24 | def self.get(xid) 25 | find_by(xid:xid) 26 | end 27 | def assign_xid 28 | self.xid = Param.gen(:xid) 29 | end 30 | def self.number(d) 31 | all(:conditions=>['DATE(created_at) =?', d.to_date]).count 32 | end 33 | def self.search(q, page, per_page=10) 34 | paginate :per_page=>per_page, :page => page, :conditions => 35 | ["LOWER(xvars) LIKE ?", "%#{q}%" ], 36 | :order=>'created_at DESC' 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/doc.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | <%= File.read('README.md') %> 4 | 5 | *** 6 | 7 | # คู่มือการใช้งาน 8 | 9 | <%= render :partial=>'mindapp/modul.md', :collection=> Mindapp::Module.all.asc(:seq) %> 10 | 11 | *** 12 | 13 | # คู่มือผู้ดูแลระบบ 14 | 15 | ## โครงสร้างข้อมูล 16 | 17 | <%- models= @app.elements["//node[@TEXT='models']"] %> 18 | 19 | <%= render :partial=>'mindapp/model.md', :collection=> models.map {|m| m.attributes["TEXT"] } %> 20 | 21 | *** 22 | 23 | # ภาคผนวก 24 | 25 | ## markdown 26 | 27 | คู่มือนี้จัดทำขึ้นโดยอัตโนมัติจาก mind map และส่วนต่างๆ ของรหัสโปรแกรม 28 | ผู้เกี่ยวข้องสามารถเขียนวิธีการใช้งานได้อย่างอิสระ โดยใช้คำสั่ง 29 | markdown 30 | ในการเขียนคู่มือประกอบเข้ากับส่วนต่างๆของระบบงาน ดังต่อไปนี้ 31 | 32 | * คำอธิบายระบบในภาพรวม อยู่ในไฟล์ `README.md` 33 | * คำอธิบายระบบงาน อยู่ในไฟล์ `app/controllers/<ระบบงาน>.md` 34 | * คำอธิบายงาน อยู่ในไฟล์ `app/views/<ระบบงาน>/<งาน>.md` 35 | * คำอธิบายงานของ link สร้างเป็นกิ่งลูกต่อจาก link นั้น 36 | * คำอธิบายขั้นตอน อยู่ในไฟล์ `app/views/<ระบบงาน>/<งาน>/<ขั้นตอน>.md` 37 | * ตัวอย่างหน้าจอ อยู่ในไฟล์ `app/views/<ระบบงาน>/<งาน>/<ขั้นตอน>.png` 38 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/identities/new.html.erb: -------------------------------------------------------------------------------- 1 | <%- @title= 'Sign Up' %> 2 | <%= form_tag "/auth/identity/register", {'data-ajax'=>'false'} do %> 3 | <% if @identity && @identity.errors.any? %> 4 |
    5 |

    <%= pluralize(@identity.errors.count, "error") %> prohibited this account from being saved:

    6 | 11 |
    12 | <% end %> 13 |
    14 | <%= label_tag :code, 'Username' %> 15 | <%= text_field_tag :code, @identity.try(:code) %> 16 |
    17 |
    18 | <%= label_tag :email %> 19 | <%= text_field_tag :email, @identity.try(:email) %> 20 |
    21 |
    22 | <%= label_tag :password, 'Password' %> 23 | <%= password_field_tag :password %> 24 |
    25 |
    26 | <%= label_tag :password_confirmation, 'Confirm password' %> 27 | <%= password_field_tag :password_confirmation %> 28 |
    29 |
    <%= submit_tag "Sign Up" %>
    30 | <% end %> 31 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/models/mindapp/doc.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Mindapp::Doc 3 | include Mongoid::Document 4 | include Mongoid::Timestamps 5 | field :name, :type => String 6 | field :filename, :type => String 7 | field :content_type, :type => String 8 | field :data_text, :type => String 9 | field :url, :type => String 10 | field :basename, :type => String 11 | field :cloudinary, :type => Boolean 12 | belongs_to :xmain, :class_name => "Mindapp::Xmain" 13 | belongs_to :runseq, :class_name => "Mindapp::Runseq" 14 | belongs_to :user 15 | belongs_to :service, :class_name => "Mindapp::Service" 16 | field :ip, :type => String 17 | field :display, :type => Boolean 18 | field :secured, :type => Boolean 19 | 20 | def self.search(q, page, per_page=PER_PAGE) 21 | paginate :per_page=>per_page, :page => page, :conditions => 22 | ["content_type=? AND data_text LIKE ? AND (secured=? OR ma_user_id=?)", 23 | "output", "%#{q}%", false, session[:user_id] ], 24 | :order=>'ma_xmain_id DESC', :select=>'DISTINCT ma_xmain_id' 25 | end 26 | def self.search_secured(q, page, per_page=PER_PAGE) 27 | paginate :per_page=>per_page, :page => page, :conditions => 28 | ["content_type=? AND data_text LIKE ?", "output", "%#{q}%" ], 29 | :order=>'ma_xmain_id DESC', :select=>'DISTINCT ma_xmain_id' 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/layouts/_full.haml: -------------------------------------------------------------------------------- 1 | !!! 5 2 | %html 3 | %head 4 | %meta(name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1") 5 | = stylesheet_link_tag "application" 6 | = javascript_include_tag "application" 7 | - if GMAP 8 | = javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" 9 | %body 10 | = render :partial => "mindapp/menu" 11 | %div{"data-id" => "main", "data-role" => "panel", "data-backbtn"=>"false"} 12 | - if @cache 13 | - cache = {} 14 | - else 15 | - cache = {"data-cache"=>"never"} 16 | - if @backbtn 17 | - backbtn= {"data-backbtn"=>"true"} 18 | - else 19 | - backbtn= {"data-backbtn"=>"false"} 20 | %div{{"data-role" => "page"}.merge(cache) } 21 | %div{{"data-role" => "header"}.merge(backbtn)} 22 | %h1= @title || DEFAULT_TITLE 23 | %div{"data-role" => "content"} 24 | = yield 25 | 26 | = render :partial => "mindapp/static" 27 | 28 | :javascript 29 | $('div').live('pagehide', function(e,ui) { 30 | var page = $(e.target); 31 | if(page.attr('data-cache') == 'never') { 32 | page.remove(); 33 | }; 34 | }); 35 | $( document ).on( "pagechange", function(){ 36 | $.get("/mindapp/ajax_notice", function(r) {$(r).appendTo('head').remove()}); 37 | }); 38 | 39 | /= raw handle_ma_notice 40 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/_static.haml: -------------------------------------------------------------------------------- 1 | #search{"data-role" => "page"} 2 | %div{"data-role" => "header", "data-backbtn" => "false"} 3 | %h1 Search 4 | %div{"data-role" => "content"} 5 | - form_tag({:controller=>"mindapp", :action=>"search"}, :method => "get" ) do 6 | = text_field_tag :q, "", :type=>"search", :required=>true, :placeholder=>"key word", :onkeypress=>"$('input').unbind('keypress');" 7 | = submit_tag "Search", "data-inline"=>"true" 8 | - form_tag({:controller=>"mindapp", :action=>"status"}, :method => "get" ) do 9 | = text_field_tag :id, nil, :required=>true, :placeholder=>"task number", :onkeypress=>"$('input').unbind('keypress');" 10 | = submit_tag "Status", "data-inline"=>"true" 11 | = link_to "Pending Tasks", "#", :onclick=>"location.hash='/mindapp/pending'", "data-role"=>"button" 12 | = link_to "Refresh", "#", :onclick=>"window.location.replace('/')", "data-role"=>"button" 13 | = link_to "About", "#", :onclick=>"location.hash='#about'", "data-role"=>"button" 14 | :javascript 15 | function notice(msg) { 16 | $("

    "+ msg +"

    ") 17 | .css({ "display": "block", "opacity": 0.96, "top": $(window).scrollTop() + 100 }) 18 | .appendTo( $('div[data-id="main"]') ) 19 | .delay( 4000 ) 20 | .fadeOut( 400, function(){ 21 | $(this).remove(); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/run_form.haml: -------------------------------------------------------------------------------- 1 | .head 2 | = step(@runseq.form_step, @xvars['total_form_steps']) 3 | %p 4 | - user = current_user || User.new 5 | - form_class = 'formtastic' 6 | - next_step = 'end_form' 7 | - if @help 8 | %div(data-role="collapsible" data-theme="e" data-content-theme="c" data-mini="true") 9 | %h3 ตำแนะนำ 10 | %p= markdown(@help) 11 | = form_tag({ :action => next_step } , {:multipart => true, :onSubmit=>'return validate()', :class=>form_class, "data-ajax"=>"#{ajax?(@ui)}"}) do 12 | = hidden_field_tag 'xmain_id', @xmain.id 13 | = hidden_field_tag 'ajax', ajax?(@ui) 14 | = hidden_field_tag 'runseq_id', @runseq.id 15 | = hidden_field_tag 'step', @xvars[:current_step] 16 | %div(data-role="fieldcontain") 17 | = render :inline=> @ui 18 | %p 19 | = submit_tag NEXT 20 | %p 21 | :javascript 22 | $(function() { 23 | $('.required').append(' *'); 24 | $('.refresh').append(" "); 25 | $("input").keypress(function (evt) { 26 | //Deterime where our character code is coming from within the event 27 | var charCode = evt.charCode || evt.keyCode; 28 | if (charCode == 13) { //Enter key's keycode 29 | alert("Please click the button"); 30 | return false; 31 | } 32 | }); 33 | }); 34 | $( document ).one( "pagechange", function(){ 35 | $('input[type="file"]').textinput({theme: 'c'}); 36 | }); 37 | 38 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/run_output.haml: -------------------------------------------------------------------------------- 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 39 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | ENV["RAILS_ENV"] ||= 'test' 3 | require File.expand_path("../../config/environment", __FILE__) 4 | require 'rspec/rails' 5 | require 'rspec/autorun' 6 | 7 | # Requires supporting ruby files with custom matchers and macros, etc, 8 | # in spec/support/ and its subdirectories. 9 | Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} 10 | 11 | RSpec.configure do |config| 12 | # ## Mock Framework 13 | # 14 | # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: 15 | # 16 | # config.mock_with :mocha 17 | # config.mock_with :flexmock 18 | # config.mock_with :rr 19 | 20 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 21 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 22 | 23 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 24 | # examples within a transaction, remove the following line or assign false 25 | # instead of true. 26 | config.use_transactional_fixtures = true 27 | 28 | # If true, the base class of anonymous controllers will be inferred 29 | # automatically. This will be the default behavior in future versions of 30 | # rspec-rails. 31 | config.infer_base_class_for_anonymous_controllers = false 32 | 33 | # Run specs in random order to surface order dependencies. If you find an 34 | # order dependency and want to debug it, you can fix the order by providing 35 | # the seed, which is printed after each run. 36 | # --seed 1234 37 | config.order = "random" 38 | end 39 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/sarabun.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'TH SarabunPSK'; 3 | src: url('fonts/thsarabunnew-webfont.eot'); 4 | src: url('fonts/thsarabunnew-webfont.eot?#iefix') format('embedded-opentype'), 5 | url('fonts/thsarabunnew-webfont.woff') format('woff'), 6 | url('fonts/thsarabunnew-webfont.ttf') format('truetype'); 7 | font-weight: normal; 8 | font-style: normal; 9 | } 10 | @font-face { 11 | font-family: 'TH SarabunPSK'; 12 | font-style: normal; 13 | font-weight: bold; 14 | src: url('fonts/thsarabunnew_bold-webfont.eot'); 15 | src: url('fonts/thsarabunnew_bold-webfont.eot?#iefix') format('embedded-opentype'), 16 | url('fonts/thsarabunnew_bold-webfont.woff') format('woff'), 17 | url('fonts/thsarabunnew_bold-webfont.ttf') format('truetype'); 18 | } 19 | @font-face { 20 | font-family: 'TH SarabunPSK'; 21 | font-style: italic; 22 | font-weight: bold; 23 | src: url('fonts/thsarabunnew_bolditalic-webfont.eot'); 24 | src: url('fonts/thsarabunnew_bolditalic-webfont.eot?#iefix') format('embedded-opentype'), 25 | url('fonts/thsarabunnew_bolditalic-webfont.woff') format('woff'), 26 | url('fonts/thsarabunnew_bolditalic-webfont.ttf') format('truetype'); 27 | } 28 | @font-face { 29 | font-family: 'TH SarabunPSK'; 30 | font-style: italic; 31 | font-weight: normal; 32 | src: url('fonts/thsarabunnew_italic-webfont.eot'); 33 | src: url('fonts/thsarabunnew_italic-webfont.eot?#iefix') format('embedded-opentype'), 34 | url('fonts/thsarabunnew_italic-webfont.woff') format('woff'), 35 | url('fonts/thsarabunnew_italic-webfont.ttf') format('truetype'); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /mindapp.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'mindapp/version' 5 | 6 | Gem::Specification.new do |gem| 7 | gem.name = "mindapp" 8 | gem.version = Mindapp::VERSION 9 | gem.authors = ["Korakot Leemakdej"] 10 | gem.email = ["songrit@gmail.com"] 11 | gem.summary = %q{generate Ruby on Rails app from mind map} 12 | gem.description = %q{generate Ruby on Rails app from mind map} 13 | gem.homepage = "https://github.com/songrit/mindapp" 14 | 15 | gem.files = `git ls-files`.split($/) 16 | gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } 17 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 18 | gem.require_paths = ["lib"] 19 | gem.license = 'MIT' 20 | 21 | # gem.add_dependency('mongo', '= 1.5.1') 22 | # gem.add_dependency('bson_ext', '= 1.5.1') 23 | # gem.add_dependency('mongoid') 24 | 25 | # gem.add_dependency('nokogiri') # for mindapp/doc 26 | # gem.add_dependency('haml-rails') 27 | # gem.add_dependency('mail') 28 | # gem.add_dependency('prawn') 29 | # gem.add_dependency('redcarpet') 30 | # gem.add_dependency('bcrypt-ruby', '=3.0.0') 31 | # gem.add_dependency('omniauth-identity') 32 | # gem.add_dependency('cloudinary') 33 | # gem.add_dependency('kaminari') 34 | # gem.add_development_dependency('debugger') 35 | # gem.add_development_dependency('rspec') 36 | # gem.add_development_dependency('rspec-rails') 37 | # gem.add_development_dependency('better_errors') 38 | # gem.add_development_dependency('binding_of_caller') 39 | end 40 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'THSarabunNew'; 3 | src: url('thsarabunnew-webfont.eot'); 4 | src: url('thsarabunnew-webfont.eot?#iefix') format('embedded-opentype'), 5 | url('thsarabunnew-webfont.woff') format('woff'), 6 | url('thsarabunnew-webfont.ttf') format('truetype'); 7 | font-weight: normal; 8 | font-style: normal; 9 | 10 | } 11 | 12 | @font-face { 13 | font-family: 'THSarabunNew'; 14 | src: url('thsarabunnew_bolditalic-webfont.eot'); 15 | src: url('thsarabunnew_bolditalic-webfont.eot?#iefix') format('embedded-opentype'), 16 | url('thsarabunnew_bolditalic-webfont.woff') format('woff'), 17 | url('thsarabunnew_bolditalic-webfont.ttf') format('truetype'); 18 | font-weight: bold; 19 | font-style: italic; 20 | 21 | } 22 | 23 | @font-face { 24 | font-family: 'THSarabunNew'; 25 | src: url('thsarabunnew_italic-webfont.eot'); 26 | src: url('thsarabunnew_italic-webfont.eot?#iefix') format('embedded-opentype'), 27 | url('thsarabunnew_italic-webfont.woff') format('woff'), 28 | url('thsarabunnew_italic-webfont.ttf') format('truetype'); 29 | font-weight: normal; 30 | font-style: italic; 31 | 32 | } 33 | 34 | @font-face { 35 | font-family: 'THSarabunNew'; 36 | src: url('thsarabunnew_bold-webfont.eot'); 37 | src: url('thsarabunnew_bold-webfont.eot?#iefix') format('embedded-opentype'), 38 | url('thsarabunnew_bold-webfont.woff') format('woff'), 39 | url('thsarabunnew_bold-webfont.ttf') format('truetype'); 40 | font-weight: bold; 41 | font-style: normal; 42 | 43 | } 44 | 45 | .thsarabunnew{ 46 | font-family: 'THSarabunNew', sans-serif; 47 | } -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/views/mindapp/status.haml: -------------------------------------------------------------------------------- 1 | %table{:width=>"100%"} 2 | %tr{:style=>"color:white; background-color:#6A6A6A;"} 3 | %th Status 4 | %th Step 5 | %th Starter 6 | %th Begin 7 | %th End 8 | - @xmain.runseqs.form_action.each do |r| 9 | %tr 10 | - if @xmain.status=='X' 11 | %td{:align=>'center'}= image_tag 'cancel.png' 12 | - else 13 | %td{:align=>'center'}= status_icon(r.status) 14 | %td= r.name 15 | %td{:align=>'center'} 16 | - if r.role.blank? && @xvars[:action] 17 | - u = @xvars[:action][:assign].blank? ? ' ' : User.find(@xvars[:action][:assign]).full_name 18 | = u 19 | - if @xvars[:action][:final]=='n' 20 | %td{:align=>'center'} - 21 | %td{:align=>'center'} - 22 | - else 23 | - if r.start 24 | %td= r.start.strftime('%c') 25 | - else 26 | %td{:align=>'center'} - 27 | - if r.stop 28 | %td= r.stop.strftime('%c') 29 | - else 30 | %td{:align=>'center'} - 31 | - else 32 | = role_name r.role 33 | - if r.start 34 | %td= r.start.strftime('%c') 35 | - else 36 | %td{:align=>'center'} - 37 | - if r.stop 38 | %td= r.stop.strftime('%c') 39 | - else 40 | %td{:align=>'center'} - 41 | .label 42 | = image_tag "cog.png" 43 | Document 44 | %table{:width=>"100%"} 45 | %tr{:style=>"color:white; background-color:#6A6A6A;"} 46 | %th Document 47 | %th Name 48 | %th User 49 | %th Date 50 | - @xmain.docs.each do |doc| 51 | - next unless doc.display 52 | %tr 53 | %td 54 | - if doc.content_type=='output' 55 | = image_tag 'page_output.png' 56 | - else 57 | = image_tag 'page_attach.png' 58 | = link_to align_text(doc.name), "/engine/document/#{doc.id}", :target=>'_blank' 59 | %td= doc.filename 60 | %td= doc.user.try(:full_name) 61 | %td= doc.created_at.strftime('%c') 62 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.grids.collapsible.css: -------------------------------------------------------------------------------- 1 | /* my addition to supply convertible grids based on www.cssgrid.net by Andy Taylor */ 2 | /* ==================================================================================================================== */ 3 | /* ! The 1140px Grid V2 by Andy Taylor \ http://cssgrid.net \ http://www.twitter.com/andytlr \ http://www.andytlr.com */ 4 | /* ==================================================================================================================== */ 5 | .row, .fixedrow { 6 | width: 100%; 7 | margin: 0 auto; 8 | overflow: hidden; 9 | } 10 | 11 | .span1, .span2, .span3, .span4, .span5, .span6, .span7, .span8, .span9, .span10, .span11 { 12 | margin-right: 3.8%; 13 | float: left; 14 | min-height: 1px; 15 | } 16 | 17 | .row .span1, .fixedrow .span1 { 18 | width: 4.85%; 19 | } 20 | 21 | .row .span2, .fixedrow .span2 { 22 | width: 13.45%; 23 | } 24 | 25 | .row .span3, .fixedrow .span3 { 26 | width: 22.05%; 27 | } 28 | 29 | .row .span4, .fixedrow .span4 { 30 | width: 30.75%; 31 | } 32 | 33 | .row .span5, .fixedrow .span5 { 34 | width: 39.45%; 35 | } 36 | 37 | .row .span6, .fixedrow .span6 { 38 | width: 48%; 39 | } 40 | 41 | .row .span7, .fixedrow .span7 { 42 | width: 56.75%; 43 | } 44 | 45 | .row .span8, .fixedrow .span8 { 46 | width: 65.4%; 47 | } 48 | 49 | .row .span9, .fixedrow .span9 { 50 | width: 74.05%; 51 | } 52 | 53 | .row .span10, .fixedrow .span10 { 54 | width: 82.7%; 55 | } 56 | 57 | .row .span11, .fixedrow .span11 { 58 | width: 91.35%; 59 | } 60 | 61 | .row .span12, .fixedrow .span12 { 62 | width: 100%; 63 | float: left; 64 | } 65 | 66 | .row .prepend1, .fixedrow .prepend1 { 67 | 68 | } 69 | 70 | .last { 71 | margin-right: 0px; 72 | } 73 | 74 | img, object, embed { 75 | max-width: 100%; 76 | } 77 | 78 | img { 79 | height: auto; 80 | } 81 | 82 | 83 | /* touchscreens */ 84 | @media (min-width:768px) { 85 | .touch body { 86 | font-size: 1em; 87 | line-height: normal; 88 | } 89 | 90 | 91 | /* Smaller screens */ 92 | body { 93 | font-size: 0.9em; 94 | line-height: normal; 95 | } 96 | } 97 | 98 | /* Mobile */ 99 | @media (max-width:480px) { 100 | body { 101 | font-size: 1em; 102 | -webkit-text-size-adjust: none; 103 | } 104 | 105 | .row, body { 106 | width: 100%; 107 | min-width: 0; 108 | margin-left: 0px; 109 | margin-right: 0px; 110 | padding-left: 0px; 111 | padding-right: 0px; 112 | } 113 | 114 | .row .span1, .row .span2, .row .span3, .row .span4, .row .span5, .row .span6, .row .span7, .row .span8, .row .span9, .row .span10, .row .span11, .row .span12 { 115 | width: auto; 116 | float: none; 117 | margin-left: 0px; 118 | margin-right: 0px; 119 | padding-left: 20px; 120 | padding-right: 20px; 121 | } 122 | } -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.splitview.css: -------------------------------------------------------------------------------- 1 | body { 2 | visibility: hidden; 3 | } 4 | 5 | .ui-panel { 6 | -moz-box-shadow: 0 0 12px rgba(0,0,0,.6); 7 | -webkit-box-shadow: 0 0 12px rgba(0,0,0,.6); 8 | box-shadow: 0 0 12px rgba(0,0,0,.6); 9 | } 10 | 11 | div[data-id="main"] { 12 | z-index: 9999; 13 | } 14 | 15 | .ui-mobile body { 16 | visibility: visible; 17 | } 18 | 19 | .ui-panel-left { 20 | position:absolute; 21 | left:0; 22 | top:0; 23 | bottom:0; 24 | } 25 | 26 | .ui-panel-right { 27 | position:absolute; 28 | right:0; 29 | top:0; 30 | bottom:0; 31 | } 32 | 33 | .ui-crumbs { 34 | max-width: 25%; 35 | } 36 | 37 | .splitview .ui-splitview-hidden { 38 | display:none; 39 | } 40 | 41 | @media (min-width:480px) { 42 | .splitview body { 43 | margin: 0; 44 | } 45 | 46 | .splitview .ui-page{ 47 | bottom: 0; 48 | } 49 | 50 | .splitview .ui-header { 51 | position:absolute; 52 | top:0; 53 | bottom:auto; 54 | left:0; 55 | right:0; 56 | z-index: 1000; 57 | } 58 | 59 | .splitview .ui-footer { 60 | position:absolute; 61 | top:auto; 62 | bottom:0; 63 | left:0; 64 | right:0; 65 | z-index:1000; 66 | } 67 | 68 | .splitview .ui-content { 69 | position:absolute; 70 | top:40px; 71 | bottom:0; 72 | left:0; 73 | right:0; 74 | overflow:auto; 75 | -webkit-overflow-scrolling:touch; 76 | z-index:1; 77 | } 78 | } 79 | 80 | /************************************************************************************************************ 81 | popover css for portrait orientation, modified from 82 | http://www.cagintranet.com/archive/create-an-ipad-like-dropdown-popover/ 83 | ************************************************************************************************************/ 84 | .panel-popover .popover_triangle {left:7px;} 85 | .panel-popover { 86 | color: black; 87 | display:none; 88 | font-weight: normal; 89 | line-height: 1; 90 | cursor: auto; 91 | position: absolute; 92 | top:55px; 93 | left:10px; 94 | background-color: white; 95 | z-index:5000000; 96 | border: 3px solid black; 97 | border-radius: 4px; 98 | -webkit-border-radius: 4px; 99 | -moz-border-radius: 4px; 100 | border-radius: 4px; 101 | -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); 102 | -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); 103 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); 104 | -webkit-transition: opacity 0.25s linear; 105 | -moz-transition: opacity 0.25s linear; 106 | transition: opacity 0.25s linear; 107 | overflow-x:visible; 108 | height:80%; 109 | } 110 | 111 | .panel-popover > .popover_triangle { 112 | position: absolute; 113 | top: -34px; 114 | font-size: 0px; 115 | line-height: 0%; 116 | width: 0px; 117 | border-top: 16px solid rgba(0,0,0,0); 118 | border-left: 16px solid rgba(0,0,0,0); 119 | border-right: 16px solid rgba(0,0,0,0); 120 | border-bottom: 16px solid black; 121 | } 122 | 123 | .panel-popover div[data-role="page"] { 124 | height: inherit; 125 | overflow-y:auto; 126 | } 127 | 128 | /********************************************************************************************************** 129 | CSS animations for panel resize using new data-width attribute. 130 | **********************************************************************************************************/ 131 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/mindapp.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 1em; 3 | } 4 | .map { 5 | margin-bottom: 1em; 6 | } 7 | .map img { 8 | max-width: none !important; 9 | } 10 | #output_link { 11 | text-align:center; 12 | border: 3px solid #999; 13 | background-color: #ddd; 14 | height: 80px; 15 | padding-top: 10px; 16 | } 17 | #output_link a { 18 | font-size:36pt; 19 | } 20 | #tooltip{ 21 | position:absolute; 22 | border:1px solid #333; 23 | background:#f7f5d1; 24 | padding:2px 5px; 25 | color:#333; 26 | display:none; 27 | } 28 | #notice { 29 | color: #F90609; 30 | background-color: #EBD1D1; 31 | font-weight: bolder; 32 | padding-left: 10px; 33 | } 34 | .step { 35 | /*display: table-row;*/ 36 | margin-top: 20px; 37 | margin-bottom: 20px; 38 | } 39 | .steps_more { 40 | font-size: 40px; 41 | font-weight: bold; 42 | vertical-align: middle; 43 | color: white; 44 | width: 80px; 45 | height: 80px; 46 | background:url(images/button_blue.png) no-repeat; 47 | display: table-cell; 48 | text-align:center; 49 | } 50 | .step_now { 51 | font-size: 40px; 52 | font-weight: bold; 53 | vertical-align: middle; 54 | color: white; 55 | width: 80px; 56 | height: 80px; 57 | background:url(images/button_red.png) no-repeat; 58 | display: table-cell; 59 | text-align:center; 60 | } 61 | .steps_done { 62 | font-size: 40px; 63 | font-weight: bold; 64 | vertical-align: middle; 65 | color: white; 66 | width: 80px; 67 | height: 80px; 68 | background:url(images/button_black.png) no-repeat; 69 | display: table-cell; 70 | text-align:center; 71 | } 72 | #title { 73 | font-size: 16pt; 74 | font-weight: bold; 75 | } 76 | #subtitle { 77 | font-weight: bold; 78 | text-align:right; 79 | } 80 | 81 | .ui-btn-inner { padding: 2px 25px; } 82 | .ui-btn-up-c, 83 | .ui-btn-hover-c, 84 | .ui-btn-down-c { 85 | font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif; 86 | /*font-size: 110%;*/ 87 | } 88 | .ui-li .ui-btn-inner a.ui-link-inherit, .ui-li-static.ui-li { padding: 7px 75px 7px 15px; display: block; } 89 | .ui-link-inherit { font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif;} 90 | label.ui-input-text { 91 | font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif; 92 | /*font-size: 110%;*/ 93 | text-shadow: none; 94 | } 95 | label.ui-select { 96 | font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif; 97 | /*font-size: 110%;*/ 98 | text-shadow: none; 99 | } 100 | .ui-body-c { 101 | font-family: 'TH SarabunPSK', Helvetica, Arial, sans-serif; 102 | /*font-size: 1.4em;*/ 103 | text-shadow: none; 104 | } 105 | .ui-header .ui-title, .ui-footer .ui-title { font-family: 'TH SarabunPSK'; text-align: center; display: block; margin: .2em 90px .3em; padding: 0; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; outline: 0 !important; } 106 | 107 | .flickr_pagination { 108 | text-align: center; 109 | padding: .3em; } 110 | .flickr_pagination a, .flickr_pagination span { 111 | padding: .2em .5em; } 112 | .flickr_pagination span.disabled { 113 | color: #AAA; } 114 | .flickr_pagination span.current { 115 | font-weight: bold; 116 | color: #FF0084; } 117 | .flickr_pagination a { 118 | border: 1px solid #DDDDDD; 119 | color: #0063DC; 120 | text-decoration: none; } 121 | .flickr_pagination a:hover, .flickr_pagination a:focus { 122 | border-color: #003366; 123 | background: #0063DC; 124 | color: white; } 125 | .flickr_pagination .page_info { 126 | color: #aaa; 127 | padding-top: .8em; } 128 | .flickr_pagination .prev_page, .flickr_pagination .next_page { 129 | border-width: 2px; } 130 | .flickr_pagination .prev_page { 131 | margin-right: 1em; } 132 | .flickr_pagination .next_page { 133 | margin-left: 1em; } 134 | 135 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.datebox.css: -------------------------------------------------------------------------------- 1 | /* jQuery-Mobile-DateBox Plugin 2 | * contains all plugin styles 3 | */ 4 | 5 | /* Base input element Styles */ 6 | 7 | /*.ui-input-datebox { width: 95%; background-image: none; padding: .4em; line-height: 1.4; font-size: 16px; display: block; width: 95%; padding-top: 0px; padding-bottom: 0px; padding-right: .4em; }*/ 8 | .ui-input-datebox { width: 60%; background-image: none; padding: .4em; line-height: 1.4; font-size: 16px; display: inline-block; padding-top: 0px; padding-bottom: 0px; padding-right: .4em; } 9 | .ui-input-datebox input { width: 70% !important; border: 1px solid transparent !important; vertical-align: middle; display: inline-block !important; background-color: transparent; zoom: 1; *display: inline; } 10 | .ui-input-datebox input:focus { outline: none;} 11 | .min-width-480px .ui-input-datebox { width: 60%; display: inline-block; zoom:1; *display: inline; } 12 | 13 | /* Calendar Mode Styles */ 14 | 15 | .ui-datebox-gridheader { text-align: center; } 16 | .ui-datebox-gridheader h4 { text-align: center; display: inline-block; margin-top: 10px; margin-bottom: 10px; zoom:1; *display: inline;} 17 | .ui-datebox-gridplus { float: right; } 18 | .ui-datebox-gridminus { float: left; } 19 | .ui-datebox-gridrow { margin-left: 5px; margin-right: 5px; } 20 | .ui-datebox-grid { clear: both; margin-bottom: 5px; } 21 | .ui-datebox-griddate { width: 36px; height: 30px; display: inline-block; vertical-align: middle; text-align: center; line-height: 30px; font-weight: bold; font-size: 12px; zoom:1; *display: inline;} 22 | .ui-datebox-griddate-empty { border: 1px solid transparent; color: #888; } 23 | .ui-datebox-griddate-label { height: 15px !important; line-height: 15px !important; color: black;} 24 | 25 | /* Android Mode Styles */ 26 | 27 | .ui-datebox-header h4 { margin-top: 5px; margin-bottom: 5px; text-align: center; } 28 | .ui-datebox-controls { text-align: center; } 29 | .ui-datebox-controls div { width: 77px; text-align: center; display: inline-block; zoom: 1; *display: inline;} 30 | .ui-datebox-scontrols { text-align: center; } 31 | .ui-datebox-scontrols div { width: 55px; text-align: center; display: inline-block; zoom: 1; *display: inline;} 32 | .ui-datebox-scontrols .ui-datebox-sinput { width: 68px; } 33 | .ui-datebox-scontrols .ui-datebox-sinput input { width: 48px; text-align: center; } 34 | .ui-datebox-input { width: 74px !important; margin-left: 1px; margin-right: 1px; text-align: center !important; display: inline-block !important; zoom:1; *display: inline; } 35 | 36 | /* Slide Mode Styles */ 37 | 38 | .ui-datebox-sliderow-d { margin-bottom: 5px; text-align: center; height: 40px; width: 280px; overflow: hidden;} 39 | .ui-datebox-sliderow-ym { margin-bottom: 5px; text-align: center; height: 32px; width: 280px; overflow: hidden;} 40 | .ui-datebox-sliderow-hi { text-align: center; height: 32px; width: 280px; overflow: hidden;} 41 | .ui-datebox-sliderow-int { display: inline-block; white-space: nowrap;} 42 | 43 | .ui-datebox-slideyear { text-align: center; display: inline-block; zoom:1; *display:inline; width: 84px; vertical-align: middle; line-height: 30px; height: 30px; font-size: 14px; font-weight: bold; } 44 | .ui-datebox-slidemonth { text-align: center; display: inline-block; zoom:1; *display:inline; width: 51px; vertical-align: middle; line-height: 30px; height: 30px; font-size: 12px; font-weight: bold; } 45 | .ui-datebox-slideday { text-align: center; display: inline-block; zoom:1; *display:inline; width: 32px; vertical-align: middle; line-height: 20px; height: 38px; font-size: 14px; font-weight: bold; } 46 | .ui-datebox-slidehour { text-align: center; display: inline-block; zoom:1; *display:inline; width: 32px; vertical-align: middle; line-height: 22px; height: 24px; font-size: 14px; font-weight: bold; } 47 | .ui-datebox-slidemins { text-align: center; display: inline-block; zoom:1; *display:inline; width: 32px; vertical-align: middle; line-height: 22px; height: 24px; font-size: 14px; font-weight: bold; } 48 | .ui-datebox-slidearrow { text-align: center; display: inline-block; zoom:1; *display:inline; width: 10px; vertical-align: middle; line-height: 38px; height: 38px; font-size: 10px; font-weight: bold; } 49 | .ui-datebox-slidewday { font-size: 10px; font-weight: normal; } 50 | 51 | /* Flip Mode Styles */ 52 | .ui-datebox-flipcontent { text-align: center; height: 125px; margin-bottom: -40px;} 53 | .ui-datebox-flipcontent div { margin-left: 3px; margin-right: 3px; width: 77px; height: 120px; display: inline-block; text-align: center; zoom: 1; *display: inline; overflow: hidden;} 54 | .ui-datebox-flipcenter { border: 1px solid #eee; height: 40px; margin-left: 10px; margin-right: 10px; position: relative; top: -45px;} 55 | .ui-datebox-flipcontent ul { list-style-type: none; display: inline; } 56 | .ui-datebox-flipcontent li { height: 30px; } 57 | .ui-datebox-flipcontent li span { margin-top: 7px; display: block; } 58 | /* Shared Styles */ 59 | 60 | .ui-datebox-container { border: 5px solid #111 !important; width: 280px; } 61 | .ui-datebox-screen { position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; } 62 | .ui-datebox-screen-modal { background-color: black; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } 63 | .ui-datebox-hidden { display: none; } 64 | .ui-dialog .ui-datebox-container { border: none !important; } 65 | .ui-dialog-datebox .ui-content { padding: 5px !important;} 66 | -------------------------------------------------------------------------------- /lib/generators/mindapp/install_generator.rb: -------------------------------------------------------------------------------- 1 | module Mindapp 2 | module Generators 3 | class InstallGenerator < Rails::Generators::Base 4 | desc "Install mindapp component to existing Rails app " 5 | def self.source_root 6 | File.dirname(__FILE__) + "/templates" 7 | end 8 | 9 | def setup_routes 10 | route "root :to => 'mindapp#index'" 11 | # route "match '/mindapp/init/:module/:service(/:id)' => 'Mindapp#init'" 12 | 13 | route "resources :identities" 14 | route "resources :sessions" 15 | route "post '/auth/:provider/callback' => 'sessions#create'" 16 | route "get '/auth/failure' => 'sessions#failure'" 17 | route "get '/logout' => 'sessions#destroy', :as => 'logout'" 18 | route "get ':controller(/:action(/:id))(.:format)'" 19 | route "post ':controller(/:action(/:id))(.:format)'" 20 | end 21 | 22 | def setup_env 23 | create_file 'README.md', '' 24 | # bug in mongo ruby driver 1.6.1, wait for mongoid 2.4.7 25 | # gem "mongo", "1.5.1" 26 | # gem "bson_ext", "1.5.1" 27 | # gem "mongoid" 28 | # run "bundle install" 29 | # generate "rspec:install" 30 | inject_into_file 'config/application.rb', :after => 'require "active_resource/railtie"' do 31 | "\nrequire 'mongoid/railtie'\n" 32 | "\nrequire 'rexml/document'\n" 33 | end 34 | application do 35 | %q{ 36 | # Mindapp default 37 | config.generators do |g| 38 | g.orm :mongoid 39 | g.template_engine :haml 40 | g.test_framework :rspec 41 | g.integration_tool :rspec 42 | end 43 | # gmail config 44 | config.action_mailer.delivery_method = :smtp 45 | config.action_mailer.smtp_settings = { 46 | :address => "smtp.gmail.com", 47 | :port => 587, 48 | :user_name => 'user@gmail.com', 49 | :password => 'secret', 50 | :authentication => 'plain', 51 | :enable_starttls_auto => true } 52 | config.action_mailer.raise_delivery_errors = true 53 | config.action_mailer.perform_deliveries = true 54 | } 55 | end 56 | initializer "mindapp.rb" do 57 | %q{# encoding: utf-8 58 | MM = "#{Rails.root}/app/mindapp/index.mm" 59 | DEFAULT_TITLE = 'Mindapp' 60 | DEFAULT_HEADER = 'Mindapp' 61 | GMAP = true 62 | NEXT = "Next >" 63 | # comment IMAGE_LOCATION to use cloudinary (specify params in config/cloudinary.yml) 64 | IMAGE_LOCATION = "upload" 65 | # for debugging 66 | # DONT_SEND_MAIL = true 67 | } 68 | end 69 | 70 | inject_into_file 'config/environment.rb', :after => "initialize!" do 71 | "\n\n# hack to fix cloudinary error https://github.com/archiloque/rest-client/issues/141" + 72 | "\nclass Hash\n remove_method :read\nrescue\nend" 73 | end 74 | inject_into_file 'config/environments/development.rb', :after => 'config.action_mailer.raise_delivery_errors = false' do 75 | "\n config.action_mailer.default_url_options = { :host => 'localhost:3000' }" 76 | end 77 | inject_into_file 'config/environments/production.rb', :after => 'config.assets.compile = false' do 78 | "\n config.assets.compile = true" 79 | end 80 | end 81 | 82 | def setup_omniauth 83 | # gem 'bcrypt-ruby', '~> 3.0.0' 84 | # gem 'omniauth-identity' 85 | initializer "omniauth.rb" do 86 | %q{ 87 | Rails.application.config.middleware.use OmniAuth::Builder do 88 | provider :identity, 89 | :fields => [:code, :email], 90 | :on_failed_registration=> lambda { |env| 91 | IdentitiesController.action(:new).call(env) 92 | } 93 | end 94 | } 95 | end 96 | end 97 | 98 | def setup_app 99 | inside("public") { run "mv index.html index.html.bak" } 100 | inside("app/views/layouts") { run "mv application.html.erb application.html.erb.bak" } 101 | inside("app/assets/javascripts") { run "mv application.js application.js.bak" } 102 | inside("app/assets/stylesheets") { run "mv application.css application.css.bak" } 103 | directory "app" 104 | end 105 | 106 | def gen_user 107 | # copy_file "seeds.rb","db/seeds.rb" 108 | end 109 | 110 | def gen_image_store 111 | copy_file "cloudinary.yml","config/cloudinary.yml" 112 | empty_directory "upload" # create upload directory just in case 113 | end 114 | 115 | def setup_gems 116 | gem "mongo", '~> 2.2' 117 | gem "bson", '~> 4.0' 118 | # gem "mongo", '1.5.1' 119 | # gem "bson_ext", '1.5.1' 120 | # gem 'mongoid', '~> 4.0.0' 121 | # for Rails 5 122 | gem 'mongoid', github: 'mongodb/mongoid' 123 | # gem "mongoid" 124 | gem "nokogiri" # use for mindapp/doc 125 | # gem "rmagick", :require => "RMagick", :platform => "ruby" 126 | gem 'haml-rails' 127 | gem "mail" 128 | gem "prawn" 129 | gem "redcarpet" 130 | gem 'bcrypt-ruby', '~> 3.0.0' 131 | gem 'omniauth-identity' 132 | gem 'cloudinary' 133 | gem 'kaminari' 134 | gem_group :development, :test do 135 | gem "rspec" 136 | gem "rspec-rails" 137 | gem "better_errors" 138 | gem "binding_of_caller" 139 | end 140 | end 141 | 142 | def finish 143 | puts "Mindapp installation finish, please run bundle install again to install additional gems. Then run rails generate mindapp:mongoid" 144 | end 145 | 146 | end 147 | end 148 | end 149 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/mindapp/index.mm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /lib/tasks/mindapp.rake: -------------------------------------------------------------------------------- 1 | require 'mindapp' 2 | require 'mindapp/helpers' 3 | include Mindapp::Helpers 4 | 5 | @btext= "# mindapp begin" 6 | @etext= "# mindapp end" 7 | 8 | namespace :mindapp do 9 | desc "generate models from mm" 10 | task :update=> :environment do 11 | @app= get_app 12 | process_models 13 | process_controllers 14 | gen_views 15 | end 16 | 17 | desc "generate admin user" 18 | task :seed=> :environment do 19 | unless Identity.where(code:"admin").exists? 20 | identity= Identity.create :code => "admin", :email => "admin@test.com", :password => "secret", 21 | :password_confirmation => "secret" 22 | User.create :provider => "identity", :uid => identity.id.to_s, :code => identity.code, 23 | :email => identity.email, :role => "M,A,D" 24 | end 25 | end 26 | 27 | desc "cancel all pending tasks" 28 | task :cancel=> :environment do 29 | Mindapp::Xmain.update_all "status='X'", "status='I' or status='R'" 30 | end 31 | end 32 | 33 | # ---------------------------- 34 | def gen_views 35 | t = ["*** generate ui ***"] 36 | Mindapp::Module.all.each do |m| 37 | m.services.each do |s| 38 | next if s.code=='link' 39 | dir ="app/views/#{s.module.code}" 40 | unless File.exists?(dir) 41 | Dir.mkdir(dir) 42 | t << "create directory #{dir}" 43 | end 44 | dir ="app/views/#{s.module.code}/#{s.code}" 45 | unless File.exists?(dir) 46 | Dir.mkdir(dir) 47 | t << "create directory #{dir}" 48 | end 49 | xml= REXML::Document.new(s.xml) 50 | xml.elements.each('*/node') do |activity| 51 | icon = activity.elements['icon'] 52 | next unless icon 53 | action= freemind2action(icon.attributes['BUILTIN']) 54 | next unless ui_action?(action) 55 | code_name = activity.attributes["TEXT"].to_s 56 | next if code_name.comment? 57 | code= name2code(code_name) 58 | if action=="pdf" 59 | f= "app/views/#{s.module.code}/#{s.code}/#{code}.pdf.prawn" 60 | else 61 | f= "app/views/#{s.module.code}/#{s.code}/#{code}.html.erb" 62 | end 63 | unless File.exists?(f) 64 | FileUtils.cp "app/mindapp/template/view.html.erb", f 65 | # ff=File.open(f, 'w'); ff.close 66 | t << "create file #{f}" 67 | end 68 | end 69 | end 70 | end 71 | puts t.join("\n") 72 | end 73 | def process_controllers 74 | process_services 75 | modules= Mindapp::Module.all 76 | modules.each do |m| 77 | next if controller_exists?(m.code) 78 | system("rails generate controller #{m.code}") 79 | end 80 | end 81 | 82 | def process_models 83 | # app= get_app 84 | # t= ["process models"] 85 | models= @app.elements["//node[@TEXT='models']"] || REXML::Document.new 86 | models.each_element('node') do |model| 87 | # t << "= "+model.attributes["TEXT"] 88 | model_name= model.attributes["TEXT"] 89 | next if model_name.comment? 90 | model_code= name2code(model_name) 91 | model_file= "#{Rails.root}/app/models/#{model_code}.rb" 92 | if File.exists?(model_file) 93 | doc= File.read(model_file) 94 | else 95 | system("rails generate model #{model_code}") 96 | doc= File.read(model_file) 97 | end 98 | doc = add_utf8(doc) 99 | attr_hash= make_fields(model) 100 | doc = add_mindapp(doc, attr_hash) 101 | # t << "modified: #{model_file}" 102 | File.open(model_file, "w") do |f| 103 | f.puts doc 104 | end 105 | end 106 | # puts t.join("\n") 107 | end 108 | 109 | def add_mindapp(doc, attr_hash) 110 | if doc =~ /#{@btext}/ 111 | s1,s2,s3= doc.partition(/ #{@btext}.*#{@etext}\n/m) 112 | s2= "" 113 | else 114 | s1,s2,s3= doc.partition("include Mongoid::Document\n") 115 | end 116 | doc= s1+s2+ <<-EOT 117 | #{@btext} 118 | include Mongoid::Timestamps 119 | EOT 120 | attr_hash.each do |a| 121 | # doc+= "\n*****"+a.to_s+"\n" 122 | if a[:edit] 123 | doc += " #{a[:text]}\n" 124 | else 125 | doc += " field :#{a[:code]}, :type => #{a[:type].capitalize}\n" 126 | end 127 | end 128 | doc += " #{@etext}\n" 129 | doc + s3 130 | end 131 | 132 | def add_utf8(doc) 133 | unless doc =~ /encoding\s*:\s*utf-8/ 134 | doc.insert 0, "# encoding: utf-8\n" 135 | else 136 | doc 137 | end 138 | end 139 | 140 | # inspect all nodes that has attached file (2 cases) and replace relative path with absolute path 141 | def make_folders_absolute(f,tt) 142 | tt.elements.each("//node") do |nn| 143 | if nn.attributes['LINK'] 144 | nn.attributes['LINK']= File.expand_path(File.dirname(f))+"/#{nn.attributes['LINK']}" 145 | end 146 | end 147 | end 148 | def name2code(s) 149 | # rather not ignore # symbol cause it could be comment 150 | code, name = s.split(':') 151 | code.downcase.strip.gsub(' ','_').gsub(/[^#_\/a-zA-Z0-9]/,'') 152 | end 153 | def model_exists?(model) 154 | File.exists? "#{Rails.root}/app/models/#{model}.rb" 155 | end 156 | def make_fields(n) 157 | # s= field string used by generate model cli (old style mindapp) 158 | s= "" 159 | # h= hash :code, :type, :edit, :text 160 | h= [] 161 | n.each_element('node') do |nn| 162 | text = nn.attributes['TEXT'] 163 | icon = nn.elements['icon'] 164 | edit= (icon && icon.attribute('BUILTIN').value=="edit") 165 | next if text.comment? && !edit 166 | 167 | # sometimes freemind puts all fields inside a blank node 168 | unless text.empty? 169 | k,v= text.split(/:\s*/,2) 170 | v ||= 'string' 171 | v= 'float' if v=~/double/i 172 | s << " #{name2code(k.strip)}:#{v.strip} " 173 | h << {:code=>name2code(k.strip), :type=>v.strip, :edit=>edit, :text=>text} 174 | else 175 | nn.each_element('node') do |nnn| 176 | icon = nnn.elements['icon'] 177 | edit1= (icon && icon.attribute('BUILTIN').value=="edit") 178 | text1 = nnn.attributes['TEXT'] 179 | next if text1 =~ /\#.*/ 180 | k,v= text1.split(/:\s*/,2) 181 | v ||= 'string' 182 | v= 'float' if v=~/double/i 183 | s << " #{name2code(k.strip)}:#{v.strip} " 184 | h << {:code=>name2code(k.strip), :type=>v.strip, :edit=>edit1, :text=>text1} 185 | end 186 | end 187 | end 188 | # f 189 | h 190 | end 191 | 192 | # ---------------------------- 193 | class String 194 | def comment? 195 | self[0]=='#' 196 | # self[0]==35 # check if first char is # 197 | end 198 | def to_code 199 | s= self.dup 200 | s.downcase.strip.gsub(' ','_').gsub(/[^#_\/a-zA-Z0-9]/,'') 201 | end 202 | end 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mindapp 2 | 3 | I like to develop application using Ruby on Rails. I find that most of my projects has some common tasks such as basic design, user administration, logging, workflow, etc. So I decide to use mind map to act as a language to explain what I want and have the tool generates the application that conform to standard framework so I can then customize everything later on. Mind map is used in design phase where it generates models and controller, in execution phase where it controls the work flow, and also use to generate documentation. System Analyst could use mind map to communicate with technical team to align their requirements and help in development. 4 | 5 | ## Changelog 6 | 7 | * v0.0.8 update for Rails 5 8 | 9 | ## Prerequisites 10 | 11 | These versions works for sure but others may do. 12 | 13 | * Ruby 2.3.0 14 | * Rails 5.0.0 15 | * MongoDB 16 | * Freemind 0.9 17 | 18 | ## Convention 19 | 20 | * database is MongoDB 21 | * images stored in upload directory, unset IMAGE_LOCATION in `initializer/mindapp.rb` to use Cloudinary 22 | * mail use Gmail SMTP, config in `config/application.rb` 23 | * authentication use omniauth-identity 24 | 25 | ## Sample Application 26 | 27 | Supposed we want to create ecommerce web site, first create a Rails 28 | app without ActiveRecord 29 | 30 | $ rails new shop --skip-test-unit --skip-bundle --skip-active-record 31 | 32 | add mindapp to your Gemfile: 33 | 34 | gem 'mindapp' 35 | 36 | depend on your operating system, you may need to uncomment 37 | 38 | gem 'therubyracer', :platforms => :ruby 39 | 40 | install gems 41 | 42 | $ bundle 43 | 44 | generate mindapp application 45 | 46 | $ rails generate mindapp:install 47 | 48 | Then run bundle again to install additional gems added by mindapp 49 | 50 | $ bundle 51 | 52 | configure mongoid 53 | 54 | $ rails generate mindapp:mongoid 55 | 56 | Please make sure mongod is running then create admin user 57 | 58 | $ rake mindapp:seed 59 | 60 | now the application is ready, start it as any Rails application 61 | 62 | $ rails server 63 | 64 | go to http://localhost:3000, click *Sign In* on the left menu, and enter user name `admin` and password `secret` 65 | 66 | ![home.mm](http://songrit.googlecode.com/files/home.png) 67 | 68 | Now open file `app/mindapp/index.mm` using Freemind 69 | 70 | ![index.mm](http://songrit.googlecode.com/files/mm.png) 71 | 72 | The 3 main branches are 73 | 74 | * models - this defines all the models to use in the application 75 | * services - this defines services which will be come the menu on the left of the screen. There will be 2 levels; the first sub branch is the main menu (modules) and the second sub branch is the sub menu (services) 76 | * roles - this defines role for all users 77 | 78 | ### models 79 | 80 | Fiirst, we need to create some product so we click on models we'll see 2 models person and address. These are sample only. You can delete them or modify them however you want. We'll take a look at them first 81 | 82 | ![models](http://songrit.googlecode.com/files/models.png) 83 | 84 | The first sub branch (e.g. person) is the model name. According to Rails convention, this should be a singular word. The next sub branch are columns in the database. Let's take a look at each: 85 | 86 | * `fname` - this create a column (field) called fname which is a String by default 87 | * `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. 88 | * `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>. 89 | * `dob: date` - use any type that mongoid provides. 90 | * `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. 91 | 92 | In this example we just want a product model, so delete the person and address model and add a product branch like so 93 | 94 | ![product](http://songrit.googlecode.com/files/product.png) 95 | 96 | Save the mind map then run: 97 | 98 | rake mindapp:update 99 | 100 | 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. 101 | 102 | ### services 103 | 104 | 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 105 | 106 | ![users](http://songrit.googlecode.com/files/users.png) 107 | 108 | The text `users:User` on the sub branch has these implications: 109 | 110 | * `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. 111 | * `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. 112 | 113 | The next sub branches has the following: 114 | 115 | * `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. 116 | * `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. 117 | * `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: 118 | 119 | * `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. 120 | * `update_user` - this icon ![bookmark](http://songrit.googlecode.com/files/bookmark.png) means to execute method update_user within `users_controller.rb` 121 | 122 | Armed with this knowledge, we are ready to add new product into our application like so: 123 | 124 | ![products](http://songrit.googlecode.com/files/products.png) 125 | 126 | To generate controller and views we save this mind map and run 127 | 128 | rake mindapp:update 129 | 130 | open file `app/views/products/add/enter.html.erb` you'll see some sample view already in there but commented. edit the file so it look like this 131 | 132 | ![enter](http://songrit.googlecode.com/files/enter.png) 133 | 134 | Note that we do not specify form_tag and submit_tag, these will be supplied by Mindapp. 135 | 136 | 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. 137 | 138 | ![products_controller](http://songrit.googlecode.com/files/products_controller.png) 139 | 140 | 141 | ... to be continued ... 142 | 143 | ## Contributing 144 | 145 | 1. Fork it 146 | 2. Create your feature branch (`git checkout -b my-new-feature`) 147 | 3. Commit your changes (`git commit -am 'Add some feature'`) 148 | 4. Push to the branch (`git push origin my-new-feature`) 149 | 5. Create new Pull Request 150 | -------------------------------------------------------------------------------- /lib/mindapp/helpers.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | module Mindapp 3 | module Helpers 4 | require "rexml/document" 5 | include REXML 6 | # methods from application_controller 7 | def b(s) 8 | "#{s}".html_safe 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 30 | def code_text(s) # old def code(s) 31 | "
    #{s}
    ".html_safe 32 | end 33 | def refresh_to(url='/', option={}) 34 | if option[:alert] 35 | ma_log option[:alert] 36 | end 37 | render :text => "" 38 | end 39 | def read_binary(path) 40 | File.open path, "rb" do |f| f.read end 41 | end 42 | def redirect_to_root 43 | redirect_to root_path 44 | end 45 | def get_option(opt, runseq=@runseq) 46 | xml= REXML::Document.new(runseq.xml).root 47 | url='' 48 | xml.each_element('///node') do |n| 49 | text= n.attributes['TEXT'] 50 | url= text if text =~/^#{opt}:\s*/ 51 | end 52 | c, h= url.split(':', 2) 53 | opt= h ? h.strip : false 54 | end 55 | def ma_comment?(s) 56 | s[0]==35 57 | end 58 | def get_ip 59 | request.env['HTTP_X_FORWARDED_FOR'] || request.env['REMOTE_ADDR'] 60 | end 61 | def get_default_role 62 | default_role= Mindapp::Role.where(:code =>'default').first 63 | return default_role ? default_role.name.to_s : '' 64 | end 65 | def name2code(s) 66 | # rather not ignore # symbol cause it could be comment 67 | code, name = s.split(':') 68 | code.downcase.strip.gsub(' ','_').gsub(/[^#_\/a-zA-Z0-9]/,'') 69 | end 70 | def name2camel(s) 71 | s.gsub(' ','_').camelcase 72 | end 73 | def true_action?(s) 74 | %w(call ws redirect invoke email).include? s 75 | end 76 | def set_global 77 | $xmain= @xmain ; $runseq = @runseq ; $user = current_user ; $xvars= @xmain.xvars; $ip = request.env["REMOTE_ADDR"] 78 | end 79 | def authorize? # use in pending tasks 80 | @runseq= @xmain.runseqs.find @xmain.current_runseq 81 | return false unless @runseq 82 | @user = current_user 83 | set_global 84 | return false unless eval(@runseq.rule) if @runseq.rule 85 | return true if true_action?(@runseq.action) 86 | # return false if check_wait 87 | return true if @runseq.role.blank? 88 | unless @runseq.role.empty? 89 | return false unless @user.role 90 | return @user.role.upcase.split(',').include?(@runseq.role.upcase) 91 | end 92 | return true 93 | end 94 | def authorize_init? # use when initialize new transaction 95 | # check module role 96 | mrole = @service.module.role 97 | return false if mrole && !current_user 98 | return false if mrole && !current_user.has_role(mrole) 99 | 100 | # check step 1 role 101 | xml= @service.xml 102 | step1 = REXML::Document.new(xml).root.elements['node'] 103 | role= get_option_xml("role", step1) || "" 104 | # rule= get_option_xml("rule", step1) || true 105 | return true if role=="" 106 | unless current_user 107 | return role.blank? 108 | else 109 | return false unless current_user.role 110 | return current_user.has_role(role) 111 | end 112 | end 113 | def ma_log(message) 114 | Mindapp::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")), 115 | :unread=> true, :ip=> ($ip || request.env["REMOTE_ADDR"]) 116 | # if session[:user_id] 117 | # Mindapp::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")), 118 | # :user_id => $user.id, :unread=> true, :ip=> env["REMOTE_ADDR"] 119 | # else 120 | # Mindapp::Notice.create :message => ERB::Util.html_escape(message.gsub("`","'")), 121 | # :unread=> true, :ip=> env["REMOTE_ADDR"] 122 | # end 123 | end 124 | 125 | alias :ma_notice :ma_log 126 | 127 | # methods from application_helper 128 | def markdown(text) 129 | erbified = ERB.new(text.html_safe).result(binding) 130 | red = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true) 131 | red.render(erbified).html_safe 132 | end 133 | def align_text(s, pixel=3) 134 | "#{s}".html_safe 135 | end 136 | def status_icon(status) 137 | case status 138 | when 'R' 139 | image_tag 'user.png' 140 | when 'F' 141 | image_tag 'tick.png' 142 | when 'I' 143 | image_tag 'control_play.png' 144 | when 'E' 145 | image_tag 'logout.png' 146 | when 'X' 147 | image_tag 'cross.png' 148 | else 149 | image_tag 'cancel.png' 150 | end 151 | end 152 | def role_name(code) 153 | role= Mindapp::Role.where(code:code).first 154 | return role ? role.name : "" 155 | end 156 | def uncomment(s) 157 | s.sub(/^#\s/,'') 158 | end 159 | def code_div(s) 160 | "
        #{s}
    ".html_safe 161 | end 162 | def ajax?(s) 163 | return s.match('file_field') ? false : true 164 | end 165 | def step(s, total) # square text 166 | s = (s==0)? 1: s.to_i 167 | total = total.to_i 168 | out ="
    " 169 | (s-1).times {|ss| out += "#{(ss+1)}" } 170 | out += %Q@@ 171 | out += s.to_s 172 | out += "" 173 | out += %Q@@ 174 | for i in s+1..total 175 | out += "#{i}" 176 | end 177 | out += "
    " 178 | out.html_safe 179 | end 180 | 181 | # methods that I don't know where they came from 182 | def current_user 183 | if session[:user_id] 184 | return @user ||= User.find(session[:user_id]['$oid']) 185 | else 186 | return nil 187 | end 188 | end 189 | def ui_action?(s) 190 | %w(form output mail pdf).include? s 191 | end 192 | # def handle_ma_notice 193 | # if Mindapp::Notice.recent.count>0 194 | # notice= Mindapp::Notice.recent.last 195 | # notice.update_attribute :unread, false 196 | # "" 197 | # else 198 | # "" 199 | # end 200 | # end 201 | def process_services 202 | # todo: persist mm_md5 203 | xml= @app||get_app 204 | if defined? session 205 | md5= Digest::MD5.hexdigest(xml.to_s) 206 | if session[:mm_md5] 207 | return if session[:mm_md5]==md5 208 | else 209 | session[:mm_md5]= md5 210 | end 211 | end 212 | protected_services = [] 213 | protected_modules = [] 214 | mseq= 0 215 | @services= xml.elements["//node[@TEXT='services']"] || REXML::Document.new 216 | @services.each_element('node') do |m| 217 | ss= m.attributes["TEXT"] 218 | code, name= ss.split(':', 2) 219 | next if code.blank? 220 | next if code.comment? 221 | module_code= code.to_code 222 | # create or update to GmaModule 223 | ma_module= Mindapp::Module.find_or_create_by :code=>module_code 224 | ma_module.update_attributes :uid=>ma_module.id.to_s 225 | protected_modules << ma_module.uid 226 | name = module_code if name.blank? 227 | ma_module.update_attributes :name=> name.strip, :seq=> mseq 228 | mseq += 1 229 | seq= 0 230 | m.each_element('node') do |s| 231 | service_name= s.attributes["TEXT"].to_s 232 | scode, sname= service_name.split(':', 2) 233 | sname ||= scode; sname.strip! 234 | scode= scode.to_code 235 | if scode=="role" 236 | ma_module.update_attribute :role, sname 237 | next 238 | end 239 | if scode.downcase=="link" 240 | role= get_option_xml("role", s) || "" 241 | rule= get_option_xml("rule", s) || "" 242 | ma_service= Mindapp::Service.find_or_create_by :module_code=> ma_module.code, :code=> scode, :name=> sname 243 | ma_service.update_attributes :xml=>s.to_s, :name=>sname, 244 | :list=>listed(s), :secured=>secured?(s), 245 | :module_id=>ma_module.id, :seq => seq, 246 | :confirm=> get_option_xml("confirm", xml), 247 | :role => role, :rule => rule, :uid=> ma_service.id.to_s 248 | seq += 1 249 | protected_services << ma_service.uid 250 | else 251 | # normal service 252 | step1 = s.elements['node'] 253 | role= get_option_xml("role", step1) || "" 254 | rule= get_option_xml("rule", step1) || "" 255 | ma_service= Mindapp::Service.find_or_create_by :module_code=> ma_module.code, :code=> scode 256 | ma_service.update_attributes :xml=>s.to_s, :name=>sname, 257 | :list=>listed(s), :secured=>secured?(s), 258 | :module_id=>ma_module.id, :seq => seq, 259 | :confirm=> get_option_xml("confirm", xml), 260 | :role => role, :rule => rule, :uid=> ma_service.id.to_s 261 | seq += 1 262 | protected_services << ma_service.uid 263 | end 264 | end 265 | end 266 | Mindapp::Module.not_in(:uid=>protected_modules).delete_all 267 | Mindapp::Service.not_in(:uid=>protected_services).delete_all 268 | end 269 | def get_app 270 | f= MM || "#{Rails.root}/app/mindapp/index.mm" 271 | dir= File.dirname(f) 272 | t= REXML::Document.new(File.read(MM).gsub("\n","")).root 273 | recheck= true ; first_pass= true 274 | while recheck 275 | recheck= false 276 | t.elements.each("//node") do |n| 277 | if n.attributes['LINK'] # has attached file 278 | if first_pass 279 | f= "#{dir}/#{n.attributes['LINK']}" 280 | else 281 | f= n.attributes['LINK'] 282 | end 283 | next unless File.exists?(f) 284 | tt= REXML::Document.new(File.read(f).gsub("\n","")).root.elements["node"] 285 | make_folders_absolute(f,tt) 286 | tt.elements.each("node") do |tt_node| 287 | n.parent.insert_before n, tt_node 288 | end 289 | recheck= true 290 | n.parent.delete_element n 291 | end 292 | end 293 | first_pass = false 294 | end 295 | return t 296 | end 297 | def controller_exists?(modul) 298 | File.exists? "#{Rails.root}/app/controllers/#{modul}_controller.rb" 299 | end 300 | def dup_hash(a) 301 | h = Hash.new(0) 302 | a.each do |aa| 303 | h[aa] += 1 304 | end 305 | return h 306 | end 307 | def login? 308 | session[:user_id] != nil 309 | end 310 | def own_xmain? 311 | if $xmain 312 | return current_user.id==$xvars['user_id'] 313 | else 314 | # if eval on first step would return true so user can start service 315 | return true 316 | end 317 | end 318 | def get_option_xml(opt, xml) 319 | if xml 320 | url='' 321 | xml.each_element('node') do |n| 322 | text= n.attributes['TEXT'] 323 | url= text if text =~/^#{opt}/ 324 | end 325 | return nil if url.blank? 326 | c, h= url.split(':', 2) 327 | opt= h ? h.strip : true 328 | else 329 | return nil 330 | end 331 | end 332 | def listed(node) 333 | icons=[] 334 | node.each_element("icon") do |nn| 335 | icons << nn.attributes["BUILTIN"] 336 | end 337 | return !icons.include?("closed") 338 | end 339 | def secured?(node) 340 | icons=[] 341 | node.each_element("icon") do |nn| 342 | icons << nn.attributes["BUILTIN"] 343 | end 344 | return icons.include?("password") 345 | end 346 | def freemind2action(s) 347 | case s.downcase 348 | #when 'bookmark' # Excellent 349 | # 'call' 350 | when 'bookmark' # Excellent 351 | 'do' 352 | when 'attach' # Look here 353 | 'form' 354 | when 'edit' # Refine 355 | 'pdf' 356 | when 'wizard' # Magic 357 | 'ws' 358 | when 'help' # Question 359 | 'if' 360 | when 'forward' # Forward 361 | 'redirect' 362 | when 'kaddressbook' #Phone 363 | 'invoke' # invoke new service along the way 364 | when 'pencil' 365 | 'output' 366 | when 'mail' 367 | 'mail' 368 | end 369 | end 370 | def affirm(s) 371 | return s =~ /[y|yes|t|true]/i ? true : false 372 | end 373 | def negate(s) 374 | return s =~ /[n|no|f|false]/i ? true : false 375 | end 376 | 377 | # module FormBuilder 378 | # def date_field(method, options = {}) 379 | # default= self.object.send(method) || Date.today 380 | # data_options= ({"mode"=>"calbox"}).merge(options) 381 | # %Q().html_safe 382 | # end 383 | # end 384 | end 385 | end 386 | 387 | class String 388 | def comment? 389 | self[0]=='#' 390 | end 391 | def to_code 392 | s= self.dup 393 | # s.downcase! 394 | # s.gsub! /[\s\-_]/, "" 395 | # s 396 | code, name = s.split(':') 397 | code.downcase.strip.gsub(' ','_').gsub(/[^#_\/a-zA-Z0-9]/,'') 398 | end 399 | end 400 | 401 | module ActionView 402 | module Helpers 403 | module DateHelper 404 | def date_field_tag(method, options = {}) 405 | default= options[:default] || Date.today 406 | data_options= ({"mode"=>"calbox"}).merge(options) 407 | %Q().html_safe 408 | end 409 | end 410 | class FormBuilder 411 | # def date_select_thai(method) 412 | # self.date_select method, :use_month_names=>THAI_MONTHS, :order=>[:day, :month, :year] 413 | # end 414 | def date_field(method, options = {}) 415 | default= options[:default] || self.object.send(method) || Date.today 416 | data_options= ({"mode"=>"calbox"}).merge(options) 417 | out= %Q() 418 | out.html_safe 419 | end 420 | def time_field(method, options = {}) 421 | default= self.object.send(method) || Time.now 422 | data_options= ({"mode"=>"timebox"}).merge(options) 423 | out=%Q() 424 | out.html_safe 425 | end 426 | def date_select_thai(method, default= Time.now, disabled=false) 427 | date_select method, :default => default, :use_month_names=>THAI_MONTHS, :order=>[:day, :month, :year], :disabled=>disabled 428 | end 429 | def datetime_select_thai(method, default= Time.now, disabled=false) 430 | datetime_select method, :default => default, :use_month_names=>THAI_MONTHS, :order=>[:day, :month, :year], :disabled=>disabled 431 | end 432 | 433 | def point(o={}) 434 | o[:zoom]= 11 unless o[:zoom] 435 | o[:width]= '100%' unless o[:width] 436 | o[:height]= '300px' unless o[:height] 437 | o[:lat] = 13.91819 unless o[:lat] 438 | o[:lng] = 100.48889 unless o[:lng] 439 | 440 | out = <<-EOT 441 | 488 |
    489 | Latitude: #{self.text_field :lat, :style=>"width:300px;" } 490 | Longitude: #{self.text_field :lng, :style=>"width:300px;" } 491 |
    492 |

    493 |

    494 | 504 | EOT 505 | out.html_safe 506 | end 507 | end 508 | end 509 | end 510 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/controllers/mindapp_controller.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class MindappController < ApplicationController 3 | def index 4 | end 5 | def logs 6 | @xmains = Mindapp::Xmain.all.desc(:created_at).page(params[:page]).per(10) 7 | end 8 | def error_logs 9 | @xmains = Mindapp::Xmain.in(status:['E']).desc(:created_at).page(params[:page]).per(10) 10 | end 11 | def pending 12 | @title= "Pending Tasks" 13 | @xmains = Mindapp::Xmain.in(status:['R','I']).asc(:created_at) 14 | end 15 | def cancel 16 | Mindapp::Xmain.find(params[:id]).update_attributes :status=>'X' 17 | if params[:return] 18 | redirect_to params[:return] 19 | else 20 | redirect_to action:"pending" 21 | end 22 | end 23 | def clear_xmains 24 | Mindapp::Xmain.where(:status =>{'$in'=>['R','I']}).update_all(:status=>'X') 25 | redirect_to action:"pending" 26 | end 27 | def ajax_notice 28 | if notice=Mindapp::Notice.recent(current_user, env["REMOTE_ADDR"]) 29 | notice.update_attribute :unread, false 30 | js = "notice('#{notice.message}');" 31 | else 32 | js = "" 33 | end 34 | render :text=> "" 35 | end 36 | def init 37 | module_code, code = params[:s].split(":") 38 | @service= Mindapp::Service.where(:module_code=> module_code, :code=> code).first 39 | # @service= Mindapp::Service.where(:module_code=> params[:module], :code=> params[:service]).first 40 | if @service && authorize_init? 41 | xmain = create_xmain(@service) 42 | result = create_runseq(xmain) 43 | unless result 44 | message = "cannot find action for xmain #{xmain.id}" 45 | ma_log("ERROR", message) 46 | flash[:notice]= message 47 | redirect_to "pending" and return 48 | end 49 | xmain.update_attribute(:xvars, @xvars) 50 | xmain.runseqs.last.update_attribute(:end,true) 51 | redirect_to :action=>'run', :id=>xmain.id 52 | else 53 | refresh_to "/", :alert => "Error: cannot process" 54 | end 55 | end 56 | def run 57 | init_vars(params[:id]) 58 | if authorize? 59 | # session[:full_layout]= false 60 | redirect_to(:action=>"run_#{@runseq.action}", :id=>@xmain.id) 61 | else 62 | redirect_to_root 63 | end 64 | end 65 | def run_form 66 | init_vars(params[:id]) 67 | if authorize? 68 | if ['F', 'X'].include? @xmain.status 69 | redirect_to_root 70 | else 71 | service= @xmain.service 72 | if service 73 | @title= "Transaction ID #{@xmain.xid}: #{@xmain.name} / #{@runseq.name}" 74 | fhelp= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.md" 75 | @help = File.read(fhelp) if File.exists?(fhelp) 76 | f= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.html.erb" 77 | @ui= File.read(f) 78 | else 79 | # flash[:notice]= "ไม่สามารถค้นหาบริการที่ต้องการได้" 80 | ma_log "Error: Service not found" 81 | redirect_to_root 82 | end 83 | end 84 | else 85 | redirect_to_root 86 | end 87 | end 88 | def run_if 89 | init_vars(params[:id]) 90 | condition= eval(@runseq.code).to_s 91 | match_found= false 92 | if condition 93 | xml= REXML::Document.new(@runseq.xml).root 94 | next_runseq= nil 95 | text = xml.elements['//node/node'].attributes['TEXT'] 96 | match, name= text.split(':',2) 97 | label= name2code(name.strip) 98 | if condition==match 99 | if label=="end" 100 | @end_job= true 101 | else 102 | next_runseq= @xmain.runseqs.where(:code=> label, :action.ne=>'redirect').first 103 | match_found= true if next_runseq 104 | @runseq_not_f= false 105 | end 106 | end 107 | end 108 | unless match_found || @end_job 109 | next_runseq= @xmain.runseqs.where( rstep:(@xvars['current_step']+1) ).first 110 | end 111 | end_action(next_runseq) 112 | end 113 | def run_redirect 114 | init_vars(params[:id]) 115 | # next_runseq= @xmain.runseqs.first :conditions=>["id != ? AND code = ?",@runseq.id, @runseq.code] 116 | next_runseq= @xmain.runseqs.where(:id.ne=>@runseq.id, :code=>@runseq.code).first 117 | @xmain.current_runseq= next_runseq.id 118 | end_action(next_runseq) 119 | end 120 | def run_do 121 | init_vars(params[:id]) 122 | @runseq.start ||= Time.now 123 | @runseq.status= 'R' # running 124 | $runseq_id= @runseq.id 125 | $user_id= current_user.try(:id) 126 | set_global 127 | controller = Kernel.const_get(@xvars['custom_controller']).new 128 | result = controller.send(@runseq.code) 129 | init_vars_by_runseq($runseq_id) 130 | @xvars = $xvars 131 | @xvars[@runseq.code.to_sym]= result.to_s 132 | @xvars['current_step']= @runseq.rstep 133 | @runseq.status= 'F' #finish 134 | @runseq.stop= Time.now 135 | @runseq.save 136 | end_action 137 | rescue => e 138 | @xmain.status='E' 139 | @xvars['error']= e.to_s+e.backtrace.to_s 140 | @xmain.xvars= $xvars 141 | @xmain.save 142 | @runseq.status= 'F' #finish 143 | @runseq.stop= Time.now 144 | @runseq.save 145 | refresh_to "/", :alert => "ขออภัย เกิดข้อผิดพลาดในรหัสการดำเนินงาน #{@xmain.id} #{@xvars['error']}" 146 | end 147 | def run_output 148 | init_vars(params[:id]) 149 | service= @xmain.service 150 | disp= get_option("display") 151 | display = (disp && !affirm(disp)) ? false : true 152 | if service 153 | f= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.html.erb" 154 | @ui= File.read(f) 155 | if Mindapp::Doc.where(:runseq_id=>@runseq.id).exists? 156 | @doc= Mindapp::Doc.where(:runseq_id=>@runseq.id).first 157 | @doc.update_attributes :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"), 158 | :xmain=>@xmain, :runseq=>@runseq, :user=>current_user, 159 | :ip=> get_ip, :service=>service, :display=>display, 160 | :secured => @xmain.service.secured 161 | else 162 | @doc= Mindapp::Doc.create :name=> @runseq.name, 163 | :content_type=>"output", :data_text=> render_to_string(:inline=>@ui, :layout=>"utf8"), 164 | :xmain=>@xmain, :runseq=>@runseq, :user=>current_user, 165 | :ip=> get_ip, :service=>service, :display=>display, 166 | :secured => @xmain.service.secured 167 | end 168 | @message = defined?(MSG_NEXT) ? MSG_NEXT : "Next >" 169 | @message = "สิ้นสุดการทำงาน" if @runseq.end 170 | eval "@xvars[@runseq.code] = url_for(:controller=>'Mindapp', :action=>'document', :id=>@doc.id)" 171 | else 172 | # flash[:notice]= "ไม่สามารถค้นหาบริการที่ต้องการได้" 173 | ma_log "Error: service not found" 174 | redirect_to_root 175 | end 176 | #display= get_option("display") 177 | unless display 178 | end_action 179 | end 180 | end 181 | def run_mail 182 | init_vars(params[:id]) 183 | service= @xmain.service 184 | f= "app/views/#{service.module.code}/#{service.code}/#{@runseq.code}.html.erb" 185 | @ui= File.read(f).html_safe 186 | @doc= Mindapp::Doc.create :name=> @runseq.name, 187 | :content_type=>"mail", :data_text=> render_to_string(:inline=>@ui, :layout=>false), 188 | :xmain=>@xmain, :runseq=>@runseq, :user=>current_user, 189 | :ip=> get_ip, :service=>service, :display=>false, 190 | :secured => @xmain.service.secured 191 | eval "@xvars[:#{@runseq.code}] = url_for(:controller=>'mindapp', :action=>'document', :id=>@doc.id)" 192 | mail_from = get_option('from') 193 | # sender= render_to_string(:inline=>mail_from) if mail_from 194 | mail_to = get_option('to') 195 | recipients= render_to_string(:inline=>mail_to) if mail_to 196 | mail_subject = get_option('subject') 197 | subject= render_to_string(:inline=>mail_subject) || "#{@runseq.name}" 198 | MindappMailer.gmail(@doc.data_text, recipients, subject).deliver unless DONT_SEND_MAIL 199 | end_action 200 | end 201 | def end_output 202 | init_vars(params[:xmain_id]) 203 | end_action 204 | end 205 | def end_form 206 | init_vars(params[:xmain_id]) 207 | eval "@xvars[@runseq.code] = {} unless @xvars[@runseq.code]" 208 | params.each { |k,v| 209 | if params[k].respond_to? :original_filename 210 | get_image(k, params[k]) 211 | elsif params[k].is_a?(Hash) 212 | eval "@xvars[@runseq.code][k] = v" 213 | params[k].each { |k1,v1| 214 | next unless v1.respond_to?(:original_filename) 215 | get_image1(k, k1, params[k][k1]) 216 | } 217 | else 218 | eval "@xvars[@runseq.code][k] = v" 219 | end 220 | } 221 | end_action 222 | end 223 | def end_action(next_runseq = nil) 224 | # @runseq.status='F' unless @runseq_not_f 225 | @xmain.xvars= @xvars 226 | @xmain.status= 'R' # running 227 | @xmain.save 228 | @runseq.status='F' 229 | @runseq.user= current_user 230 | @runseq.stop= Time.now 231 | @runseq.save 232 | next_runseq= @xmain.runseqs.where(:rstep=> @runseq.rstep+1).first unless next_runseq 233 | if @end_job || !next_runseq # job finish 234 | @xmain.xvars= @xvars 235 | @xmain.status= 'F' unless @xmain.status== 'E' # finish 236 | @xmain.stop= Time.now 237 | @xmain.save 238 | if @xvars['p']['return'] 239 | redirect_to @xvars['p']['return'] and return 240 | else 241 | if @user 242 | redirect_to :action=>'pending' and return 243 | else 244 | redirect_to_root and return 245 | end 246 | end 247 | else 248 | @xmain.update_attribute :current_runseq, next_runseq.id 249 | redirect_to :action=>'run', :id=>@xmain.id and return 250 | end 251 | end 252 | # process images from first level 253 | def get_image(key, params) 254 | doc = Mindapp::Doc.create( 255 | :name=> key.to_s, 256 | :xmain=> @xmain.id, 257 | :runseq=> @runseq.id, 258 | :filename=> params.original_filename, 259 | :content_type => params.content_type || 'application/zip', 260 | :data_text=> '', 261 | :display=>true, 262 | :secured => @xmain.service.secured ) 263 | if defined?(IMAGE_LOCATION) 264 | filename = "#{IMAGE_LOCATION}/f#{Param.gen(:asset_id)}" 265 | File.open(filename,"wb") { |f| f.write(params.read) } 266 | # File.open(filename,"wb") { |f| f.puts(params.read) } 267 | eval "@xvars[@runseq.code][key] = '#{url_for(:action=>'document', :id=>doc.id, :only_path => true )}' " 268 | doc.update_attributes :url => filename, :basename => File.basename(filename), :cloudinary => false 269 | else 270 | result = Cloudinary::Uploader.upload(params) 271 | eval %Q{ @xvars[@runseq.code][key] = '#{result["url"]}' } 272 | doc.update_attributes :url => result["url"], :basename => File.basename(result["url"]), :cloudinary => true 273 | end 274 | end 275 | # process images from second level, e.g,, fields_for 276 | def get_image1(key, key1, params) 277 | doc = Mindapp::Doc.create( 278 | :name=> "#{key}_#{key1}", 279 | :xmain=> @xmain.id, 280 | :runseq=> @runseq.id, 281 | :filename=> params.original_filename, 282 | :content_type => params.content_type || 'application/zip', 283 | :data_text=> '', 284 | :display=>true, :secured => @xmain.service.secured ) 285 | if defined?(IMAGE_LOCATION) 286 | filename = "#{IMAGE_LOCATION}/f#{Param.gen(:asset_id)}" 287 | File.open(filename,"wb") { |f| f.write(params.read) } 288 | eval "@xvars[@runseq.code][key][key1] = '#{url_for(:action=>'document', :id=>doc.id, :only_path => true)}' " 289 | doc.update_attributes :url => filename, :basename => File.basename(filename), :cloudinary => false 290 | else 291 | result = Cloudinary::Uploader.upload(params) 292 | eval %Q{ @xvars[@runseq.code][key][key1] = '#{result["url"]}' } 293 | doc.update_attributes :url => result["url"], :basename => File.basename(result["url"]), :cloudinary => true 294 | end 295 | end 296 | def doc_print 297 | render :file=>'public/doc.html', :layout=>'layouts/print' 298 | end 299 | # generate documentation for application 300 | def doc 301 | require 'rdoc' 302 | @app= get_app 303 | @intro = File.read('README.md') 304 | @print= "
    พิมพ์
    " 305 | doc= render_to_string 'doc.md', :layout => false 306 | html= Maruku.new(doc).to_html 307 | File.open('public/doc.html','w') {|f| f.puts html } 308 | respond_to do |format| 309 | format.html { 310 | render :text=> @print+html, :layout => 'layouts/_page' 311 | # render :text=> Maruku.new(doc).to_html, :layout => false 312 | # format.html { 313 | # h = RDoc::Markup::ToHtml.new 314 | # render :text=> h.convert(doc), :layout => 'layouts/_page' 315 | } 316 | format.pdf { 317 | latex= Maruku.new(doc).to_latex 318 | File.open('tmp/doc.md','w') {|f| f.puts doc} 319 | File.open('tmp/doc.tex','w') {|f| f.puts latex} 320 | # system('pdflatex tmp/doc.tex ') 321 | # send_file( 'tmp/doc.pdf', :type => ‘application/pdf’, 322 | # :disposition => ‘inline’, :filename => 'doc.pdf') 323 | render :text=>'done' 324 | } 325 | end 326 | end 327 | # handle uploaded image 328 | def document 329 | doc = Mindapp::Doc.find params[:id] 330 | if doc.cloudinary 331 | require 'net/http' 332 | require "uri" 333 | uri = URI.parse(doc.url) 334 | data = Net::HTTP.get_response(uri) 335 | send_data(data.body, :filename=>doc.filename, :type=>doc.content_type, :disposition=>"inline") 336 | else 337 | data= read_binary(doc.url) 338 | send_data(data, :filename=>doc.filename, :type=>doc.content_type, :disposition=>"inline") 339 | end 340 | end 341 | def status 342 | @xmain= Mindapp::Xmain.where(:xid=>params[:xid]).first 343 | @title= "Task number #{params[:xid]} #{@xmain.name}" 344 | @backbtn= true 345 | @xvars= @xmain.xvars 346 | # flash.now[:notice]= "รายการ #{@xmain.id} ได้ถูกยกเลิกแล้ว" if @xmain.status=='X' 347 | ma_log "Task #{@xmain.id} is cancelled" if @xmain.status=='X' 348 | # flash.now[:notice]= "transaction #{@xmain.id} was cancelled" if @xmain.status=='X' 349 | rescue 350 | refresh_to "/", :alert => "Could not find task number #{params[:xid]} " 351 | end 352 | def help 353 | end 354 | def search 355 | @q = params[:q] || params[:ma_search][:q] || "" 356 | @title = "ผลการค้นหา #{@q}" 357 | @backbtn= true 358 | @cache= true 359 | if @q.blank? 360 | redirect_to "/" 361 | else 362 | s= GmaSearch.create :q=>@q, :ip=> request.env["REMOTE_ADDR"] 363 | do_search 364 | end 365 | end 366 | def err404 367 | # ma_log 'ERROR', 'main/err404' 368 | flash[:notice] = "We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly." 369 | ma_log "We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly." 370 | redirect_to '/' 371 | end 372 | def err500 373 | # ma_log 'ERROR', 'main/err500' 374 | flash[:notice] = "We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly." 375 | ma_log "We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly." 376 | redirect_to '/' 377 | end 378 | 379 | private 380 | def create_xmain(service) 381 | c = name2camel(service.module.code) 382 | custom_controller= "#{c}Controller" 383 | Mindapp::Xmain.create :service=>service, 384 | :start=>Time.now, 385 | :name=>service.name, 386 | :ip=> get_ip, 387 | :status=>'I', # init 388 | :user=>current_user, 389 | :xvars=> { 390 | :service_id=>service.id, :p=>params, 391 | :id=>params[:id], 392 | :user_id=>current_user.try(:id), 393 | :custom_controller=>custom_controller, 394 | :host=>request.host, 395 | :referer=>request.env['HTTP_REFERER'] 396 | } 397 | end 398 | def create_runseq(xmain) 399 | @xvars= xmain.xvars 400 | default_role= get_default_role 401 | xml= xmain.service.xml 402 | root = REXML::Document.new(xml).root 403 | i= 0; j= 0 # i= step, j= form_step 404 | root.elements.each('node') do |activity| 405 | text= activity.attributes['TEXT'] 406 | next if ma_comment?(text) 407 | next if text =~/^rule:\s*/ 408 | action= freemind2action(activity.elements['icon'].attributes['BUILTIN']) if activity.elements['icon'] 409 | return false unless action 410 | i= i + 1 411 | output_display= false 412 | if action=='output' 413 | display= get_option_xml("display", activity) 414 | if display && !affirm(display) 415 | output_display= false 416 | else 417 | output_display= true 418 | end 419 | end 420 | j= j + 1 if (action=='form' || output_display) 421 | @xvars['referer'] = activity.attributes['TEXT'] if action=='redirect' 422 | if action!= 'if' 423 | scode, name= text.split(':', 2) 424 | name ||= scode; name.strip! 425 | code= name2code(scode) 426 | else 427 | code= text 428 | name= text 429 | end 430 | role= get_option_xml("role", activity) || default_role 431 | rule= get_option_xml("rule", activity) || "true" 432 | runseq= Mindapp::Runseq.create :xmain=>xmain.id, 433 | :name=> name, :action=> action, 434 | :code=> code, :role=>role.upcase, :rule=> rule, 435 | :rstep=> i, :form_step=> j, :status=>'I', 436 | :xml=>activity.to_s 437 | xmain.current_runseq= runseq.id if i==1 438 | end 439 | @xvars['total_steps']= i 440 | @xvars['total_form_steps']= j 441 | end 442 | def init_vars(xmain) 443 | @xmain= Mindapp::Xmain.find xmain 444 | @xvars= @xmain.xvars 445 | @runseq= @xmain.runseqs.find @xmain.current_runseq 446 | # authorize? 447 | @xvars['current_step']= @runseq.rstep 448 | @xvars['referrer']= request.referrer 449 | session[:xmain_id]= @xmain.id 450 | session[:runseq_id]= @runseq.id 451 | unless params[:action]=='run_call' 452 | @runseq.start ||= Time.now 453 | @runseq.status= 'R' # running 454 | @runseq.save 455 | end 456 | $xmain= @xmain; $xvars= @xvars 457 | $runseq_id= @runseq.id 458 | $user_id= current_user.try(:id) 459 | end 460 | def init_vars_by_runseq(runseq_id) 461 | @runseq= Mindapp::Runseq.find runseq_id 462 | @xmain= @runseq.xmain 463 | @xvars= @xmain.xvars 464 | #@xvars[:current_step]= @runseq.rstep 465 | @runseq.start ||= Time.now 466 | @runseq.status= 'R' # running 467 | @runseq.save 468 | end 469 | def store_asset 470 | if params[:content] 471 | doc = GmaDoc.create! :name=> 'asset', 472 | :filename=> (params[:file_name]||''), 473 | :content_type => (params[:content_type] || 'application/zip'), 474 | :data_text=> '', 475 | :display=>true 476 | path = (IMAGE_LOCATION || "tmp") 477 | File.open("#{path}/f#{doc.id}","wb") { |f| 478 | f.puts(params[:content]) 479 | } 480 | render :xml=>"" 481 | else 482 | render :xml=>"" 483 | end 484 | end 485 | def do_search 486 | if current_user.secured? 487 | @docs = GmaDoc.search_secured(@q.downcase, params[:page], PER_PAGE) 488 | else 489 | @docs = GmaDoc.search(@q.downcase, params[:page], PER_PAGE) 490 | end 491 | @xmains = GmaXmain.find(@docs.map(&:ma_xmain_id)).sort { |a,b| b.id<=>a.id } 492 | # @xmains = GmaXmain.find @docs.map(&:created_at).sort { |a,b| b<=>a } 493 | end 494 | def read_binary(path) 495 | File.open path, "rb" do |f| f.read end 496 | end 497 | end 498 | -------------------------------------------------------------------------------- /lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.splitview.js: -------------------------------------------------------------------------------- 1 | // TODO: reinstate replaceBackBtn - to include the case where people actually really want the back btn 2 | (function($,window,undefined){ 3 | $( window.document ).bind('mobileinit', function(){ 4 | //some class for css to detect touchscreens 5 | if($.support.touch){ 6 | $('html').addClass('touch'); 7 | } 8 | var $query = $.mobile.media('screen and (min-width: 480px)') && ($.mobile.media('(-webkit-max-device-pixel-ratio: 1.2)') || $.mobile.media('(max--moz-device-pixel-ratio: 1.2)')); 9 | $.support.splitview = ($query || ($.mobile.browser.ie && $(this).width() >= 480)) && $.mobile.ajaxEnabled; 10 | if ($.support.splitview) { 11 | $('html').addClass('splitview'); 12 | //on window.ready() execution: 13 | $(function() { 14 | $(document).unbind('.toolbar'); 15 | $('.ui-page').die('.toolbar'); 16 | $('div:jqmData(role="panel")').addClass('ui-mobile-viewport ui-panel'); 17 | var firstPageMain=$('div:jqmData(id="main") > div:jqmData(role="page"):first'); 18 | if( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ){ 19 | var $container=$('div:jqmData(id="main")'); 20 | $.mobile.firstPage = firstPageMain; 21 | $.mobile.changePage(firstPageMain, {transition:'none', changeHash:false, pageContainer:$container}); 22 | $.mobile.activePage=undefined; 23 | } //no need to trigger a hashchange here cause the other page is handled by core. 24 | 25 | // setup the layout for splitview and jquerymobile will handle first page init 26 | $(window).trigger('orientationchange'); 27 | setTimeout(function(){ 28 | $.mobile.firstPage = firstPageMain; 29 | }, 100) 30 | }); //end window.ready() 31 | 32 | //---------------------------------------------------------------------------------- 33 | //Main event bindings: click, form submits, hashchange and orientationchange/resize(popover) 34 | //---------------------------------------------------------------------------------- 35 | //existing base tag? 36 | var $window = $( window ), 37 | $html = $( 'html' ), 38 | $head = $( 'head' ), 39 | $base = $head.children( "base" ), 40 | //tuck away the original document URL minus any fragment. 41 | documentUrl = $.mobile.path.parseUrl( location.href ), 42 | 43 | //if the document has an embedded base tag, documentBase is set to its 44 | //initial value. If a base tag does not exist, then we default to the documentUrl. 45 | documentBase = $base.length ? $.mobile.path.parseUrl( $.mobile.path.makeUrlAbsolute( $base.attr( "href" ), documentUrl.href ) ) : documentUrl; 46 | 47 | function findClosestLink(ele) 48 | { 49 | while (ele){ 50 | if (ele.nodeName.toLowerCase() == "a"){ 51 | break; 52 | } 53 | ele = ele.parentNode; 54 | } 55 | return ele; 56 | } 57 | 58 | // The base URL for any given element depends on the page it resides in. 59 | function getClosestBaseUrl( ele ) 60 | { 61 | // Find the closest page and extract out its url. 62 | var url = $( ele ).closest( ".ui-page" ).jqmData( "url" ), 63 | base = documentBase.hrefNoHash; 64 | 65 | if ( !url || !$.mobile.path.isPath( url ) ) { 66 | url = base; 67 | } 68 | 69 | return $.mobile.path.makeUrlAbsolute( url, base); 70 | } 71 | 72 | //simply set the active page's minimum height to screen height, depending on orientation 73 | function getScreenHeight(){ 74 | var orientation = jQuery.event.special.orientationchange.orientation(), 75 | port = orientation === "portrait", 76 | winMin = port ? 480 : 320, 77 | screenHeight = port ? screen.availHeight : screen.availWidth, 78 | winHeight = Math.max( winMin, $( window ).height() ), 79 | pageMin = Math.min( screenHeight, winHeight ); 80 | 81 | return pageMin; 82 | } 83 | 84 | function newResetActivePageHeight(){ 85 | var page=$( "." + $.mobile.activePageClass ); 86 | page.each(function(){ 87 | if($(this).closest(".panel-popover").length != 1){ 88 | $(this).css("min-height", getScreenHeight()); 89 | } 90 | else { 91 | $(this).css("min-height", "100%") 92 | } 93 | }); 94 | 95 | } 96 | 97 | //override _registerInternalEvents to bind to new methods below 98 | $.mobile._registerInternalEvents = function(){ 99 | //DONE: bind form submit with this plugin 100 | $("form").live('submit', function(event){ 101 | var $this = $( this ); 102 | if( !$.mobile.ajaxEnabled || 103 | $this.is( ":jqmData(ajax='false')" ) ){ return; } 104 | 105 | var type = $this.attr("method"), 106 | target = $this.attr("target"), 107 | url = $this.attr( "action" ), 108 | $currPanel=$this.parents('div:jqmData(role="panel")'), 109 | $currPanelActivePage=$currPanel.children('div.'+$.mobile.activePageClass); 110 | 111 | // If no action is specified, browsers default to using the 112 | // URL of the document containing the form. Since we dynamically 113 | // pull in pages from external documents, the form should submit 114 | // to the URL for the source document of the page containing 115 | // the form. 116 | if ( !url ) { 117 | // Get the @data-url for the page containing the form. 118 | url = getClosestBaseUrl( $this ); 119 | if ( url === documentBase.hrefNoHash ) { 120 | // The url we got back matches the document base, 121 | // which means the page must be an internal/embedded page, 122 | // so default to using the actual document url as a browser 123 | // would. 124 | url = documentUrl.hrefNoSearch; 125 | } 126 | } 127 | 128 | url = $.mobile.path.makeUrlAbsolute( url, getClosestBaseUrl($this) ); 129 | 130 | //external submits use regular HTTP 131 | if( $.mobile.path.isExternal( url ) || target ) { 132 | return; 133 | } 134 | 135 | //temporarily put this here- eventually shud just set it immediately instead of an interim var. 136 | $.mobile.activePage=$currPanelActivePage; 137 | // $.mobile.pageContainer=$currPanel; 138 | $.mobile.changePage( 139 | url, 140 | { 141 | type: type && type.length && type.toLowerCase() || "get", 142 | data: $this.serialize(), 143 | transition: $this.jqmData("transition"), 144 | direction: $this.jqmData("direction"), 145 | reloadPage: true, 146 | pageContainer:$currPanel 147 | } 148 | ); 149 | event.preventDefault(); 150 | }); 151 | 152 | //add active state on vclick 153 | $( document ).bind( "vclick", function( event ) { 154 | var link = findClosestLink( event.target ); 155 | if ( link ) { 156 | if ( $.mobile.path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" ) { 157 | $( link ).closest( ".ui-btn" ).not( ".ui-disabled" ).addClass( $.mobile.activeBtnClass ); 158 | $( "." + $.mobile.activePageClass + " .ui-btn" ).not( link ).blur(); 159 | } 160 | } 161 | }); 162 | 163 | //DONE: link click event binding for changePage 164 | //click routing - direct to HTTP or Ajax, accordingly 165 | $(document).bind( "click", function(event) { 166 | var link = findClosestLink(event.target); 167 | if (!link){ 168 | return; 169 | } 170 | 171 | var $link = $(link), 172 | //remove active link class if external (then it won't be there if you come back) 173 | httpCleanup = function(){ 174 | window.setTimeout( function() { removeActiveLinkClass( true ); }, 200 ); 175 | }; 176 | 177 | //if there's a data-rel=back attr, go back in history 178 | if( $link.is( ":jqmData(rel='back')" ) ) { 179 | window.history.back(); 180 | return false; 181 | } 182 | 183 | //if ajax is disabled, exit early 184 | if( !$.mobile.ajaxEnabled ){ 185 | httpCleanup(); 186 | //use default click handling 187 | return; 188 | } 189 | 190 | var baseUrl = getClosestBaseUrl( $link ), 191 | 192 | //get href, if defined, otherwise fall to null # 193 | href = $.mobile.path.makeUrlAbsolute( $link.attr( "href" ) || "#", baseUrl ); 194 | 195 | // XXX_jblas: Ideally links to application pages should be specified as 196 | // an url to the application document with a hash that is either 197 | // the site relative path or id to the page. But some of the 198 | // internal code that dynamically generates sub-pages for nested 199 | // lists and select dialogs, just write a hash in the link they 200 | // create. This means the actual URL path is based on whatever 201 | // the current value of the base tag is at the time this code 202 | // is called. For now we are just assuming that any url with a 203 | // hash in it is an application page reference. 204 | if ( href.search( "#" ) != -1 ) { 205 | href = href.replace( /[^#]*#/, "" ); 206 | if ( !href ) { 207 | //link was an empty hash meant purely 208 | //for interaction, so we ignore it. 209 | event.preventDefault(); 210 | return; 211 | } else if ( $.mobile.path.isPath( href ) ) { 212 | //we have apath so make it the href we want to load. 213 | href = $.mobile.path.makeUrlAbsolute( href, baseUrl ); 214 | } else { 215 | //we have a simple id so use the documentUrl as its base. 216 | href = $.mobile.path.makeUrlAbsolute( "#" + href, documentUrl.hrefNoHash ); 217 | } 218 | } 219 | 220 | // Should we handle this link, or let the browser deal with it? 221 | var useDefaultUrlHandling = $link.is( "[rel='external']" ) || $link.is( ":jqmData(ajax='false')" ) || $link.is( "[target]" ), 222 | // Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR 223 | // requests if the document doing the request was loaded via the file:// protocol. 224 | // This is usually to allow the application to "phone home" and fetch app specific 225 | // data. We normally let the browser handle external/cross-domain urls, but if the 226 | // allowCrossDomainPages option is true, we will allow cross-domain http/https 227 | // requests to go through our page loading logic. 228 | isCrossDomainPageLoad = ( $.mobile.allowCrossDomainPages && documentUrl.protocol === "file:" && href.search( /^https?:/ ) != -1 ), 229 | 230 | //check for protocol or rel and its not an embedded page 231 | //TODO overlap in logic from isExternal, rel=external check should be 232 | // moved into more comprehensive isExternalLink 233 | isExternal = useDefaultUrlHandling || ( $.mobile.path.isExternal( href ) && !isCrossDomainPageLoad ), 234 | 235 | isRefresh=$link.jqmData('refresh'), 236 | $targetPanel=$link.jqmData('panel'), 237 | $targetContainer=$('div:jqmData(id="'+$targetPanel+'")'), 238 | $targetPanelActivePage=$targetContainer.children('div.'+$.mobile.activePageClass), 239 | $currPanel=$link.parents('div:jqmData(role="panel")'), 240 | //not sure we need this. if you want the container of the element that triggered this event, $currPanel 241 | $currContainer=$.mobile.pageContainer, 242 | $currPanelActivePage=$currPanel.children('div.'+$.mobile.activePageClass), 243 | url=$.mobile.path.stripHash($link.attr("href")), 244 | from = null; 245 | 246 | //still need this hack apparently: 247 | $('.ui-btn.'+$.mobile.activeBtnClass).removeClass($.mobile.activeBtnClass); 248 | $activeClickedLink = $link.closest( ".ui-btn" ).addClass($.mobile.activeBtnClass); 249 | 250 | if( isExternal ) { 251 | httpCleanup(); 252 | //use default click handling 253 | return; 254 | } 255 | 256 | //use ajax 257 | var transitionVal = $link.jqmData( "transition" ), 258 | direction = $link.jqmData("direction"), 259 | reverseVal = (direction && direction === "reverse") || 260 | // deprecated - remove by 1.0 261 | $link.jqmData( "back" ), 262 | //this may need to be more specific as we use data-rel more 263 | role = $link.attr( "data-" + $.mobile.ns + "rel" ) || undefined, 264 | hash = $currPanel.jqmData('hash'); 265 | 266 | //if link refers to an already active panel, stop default action and return 267 | if ($targetPanelActivePage.attr('data-url') == url || $currPanelActivePage.attr('data-url') == url) { 268 | if (isRefresh) { //then changePage below because it's a pageRefresh request 269 | $.mobile.changePage(href, {fromPage:from, transition:'fade', reverse:reverseVal, changeHash:false, pageContainer:$targetContainer, reloadPage:isRefresh}); 270 | } 271 | else { //else preventDefault and return 272 | event.preventDefault(); 273 | return; 274 | } 275 | } 276 | //if link refers to a page on another panel, changePage on that panel 277 | else if ($targetPanel && $targetPanel!=$link.parents('div:jqmData(role="panel")')) { 278 | var from=$targetPanelActivePage; 279 | $.mobile.pageContainer=$targetContainer; 280 | $.mobile.changePage(href, {fromPage:from, transition:transitionVal, reverse:reverseVal, pageContainer:$targetContainer}); 281 | } 282 | //if link refers to a page inside the same panel, changePage on that panel 283 | else { 284 | var from=$currPanelActivePage; 285 | $.mobile.pageContainer=$currPanel; 286 | var hashChange= (hash == 'false' || hash == 'crumbs')? false : true; 287 | $.mobile.changePage(href, {fromPage:from, transition:transitionVal, reverse:reverseVal, changeHash:hashChange, pageContainer:$currPanel}); 288 | //active page must always point to the active page in main - for history purposes. 289 | $.mobile.activePage=$('div:jqmData(id="main") > div.'+$.mobile.activePageClass); 290 | } 291 | event.preventDefault(); 292 | }); 293 | 294 | //prefetch pages when anchors with data-prefetch are encountered 295 | //TODO: insert pageContainer in here! 296 | $( ".ui-page" ).live( "pageshow.prefetch", function(){ 297 | var urls = [], 298 | $thisPageContainer = $(this).parents('div:jqmData(role="panel")'); 299 | $( this ).find( "a:jqmData(prefetch)" ).each(function(){ 300 | var url = $( this ).attr( "href" ), 301 | panel = $(this).jqmData('panel'), 302 | container = panel.length? $('div:jqmData(id="'+panel+'")') : $thisPageContainer; 303 | if ( url && $.inArray( url, urls ) === -1 ) { 304 | urls.push( url ); 305 | $.mobile.loadPage( url, {pageContainer: container} ); 306 | } 307 | }); 308 | }); 309 | 310 | //DONE: bind hashchange with this plugin 311 | //hashchanges are defined only for the main panel - other panels should not support hashchanges to avoid ambiguity 312 | $.mobile._handleHashChange = function( hash ) { 313 | var to = $.mobile.path.stripHash( hash ), 314 | transition = $.mobile.urlHistory.stack.length === 0 ? "none" : undefined, 315 | $mainPanel=$('div:jqmData(id="main")'), 316 | $mainPanelFirstPage=$mainPanel.children('div:jqmData(role="page"):first'), 317 | $mainPanelActivePage=$mainPanel.children('div.ui-page-active'), 318 | $menuPanel=$('div:jqmData(id="menu")'), 319 | $menuPanelFirstPage=$menuPanel.children('div:jqmData(role="page"):first'), 320 | $menuPanelActivePage=$menuPanel.children('div.ui-page-active'), 321 | //FIX: temp var for dialogHashKey 322 | dialogHashKey = "&ui-state=dialog", 323 | 324 | // default options for the changPage calls made after examining the current state 325 | // of the page and the hash 326 | changePageOptions = { 327 | transition: transition, 328 | changeHash: false, 329 | fromHashChange: true, 330 | pageContainer: $mainPanel 331 | }; 332 | 333 | if( !$.mobile.hashListeningEnabled || $.mobile.urlHistory.ignoreNextHashChange ){ 334 | $.mobile.urlHistory.ignoreNextHashChange = false; 335 | return; 336 | } 337 | 338 | // special case for dialogs 339 | if( $.mobile.urlHistory.stack.length > 1 && to.indexOf( dialogHashKey ) > -1 ) { 340 | 341 | // If current active page is not a dialog skip the dialog and continue 342 | // in the same direction 343 | if(!$.mobile.activePage.is( ".ui-dialog" )) { 344 | //determine if we're heading forward or backward and continue accordingly past 345 | //the current dialog 346 | $.mobile.urlHistory.directHashChange({ 347 | currentUrl: to, 348 | isBack: function() { window.history.back(); }, 349 | isForward: function() { window.history.forward(); } 350 | }); 351 | 352 | // prevent changepage 353 | return; 354 | } else { 355 | // var setTo = function() { to = $.mobile.urlHistory.getActive().pageUrl; }; 356 | // if the current active page is a dialog and we're navigating 357 | // to a dialog use the dialog objected saved in the stack 358 | // urlHistory.directHashChange({ currentUrl: to, isBack: setTo, isForward: setTo }); 359 | urlHistory.directHashChange({ 360 | currentUrl: to, 361 | 362 | // regardless of the direction of the history change 363 | // do the following 364 | either: function( isBack ) { 365 | var active = $.mobile.urlHistory.getActive(); 366 | 367 | to = active.pageUrl; 368 | 369 | // make sure to set the role, transition and reversal 370 | // as most of this is lost by the domCache cleaning 371 | $.extend( changePageOptions, { 372 | role: active.role, 373 | transition: active.transition, 374 | reverse: isBack 375 | }); 376 | } 377 | }); 378 | } 379 | } 380 | 381 | //if to is defined, load it 382 | if ( to ){ 383 | to = ( typeof to === "string" && !$.mobile.path.isPath( to ) ) ? ( $.mobile.path.makeUrlAbsolute( '#' + to, documentBase ) ) : to; 384 | //if this is initial deep-linked page setup, then changePage sidemenu as well 385 | if (!$('div.ui-page-active').length) { 386 | $menuPanelFirstPage='#'+$menuPanelFirstPage.attr('id'); 387 | $.mobile.changePage($menuPanelFirstPage, {transition:'none', reverse:true, changeHash:false, fromHashChange:false, pageContainer:$menuPanel}); 388 | $.mobile.activePage=undefined; 389 | } 390 | $.mobile.activePage=$mainPanelActivePage.length? $mainPanelActivePage : undefined; 391 | $.mobile.changePage(to, changePageOptions ); 392 | } else { 393 | //there's no hash, go to the first page in the main panel. 394 | $.mobile.activePage=$mainPanelActivePage? $mainPanelActivePage : undefined; 395 | $.mobile.changePage( $mainPanelFirstPage, changePageOptions ); 396 | } 397 | }; 398 | 399 | //hashchange event handler 400 | $(window).bind( "hashchange", function( e, triggered ) { 401 | $.mobile._handleHashChange( location.hash ); 402 | }); 403 | 404 | //set page min-heights to be device specific 405 | $( document ).bind( "pageshow.resetPageHeight", newResetActivePageHeight ); 406 | $( window ).bind( "throttledresize.resetPageHeight", newResetActivePageHeight ); 407 | 408 | }; //end _registerInternalEvents 409 | 410 | //DONE: bind orientationchange and resize - the popover 411 | _orientationHandler = function(event){ 412 | var $menu=$('div:jqmData(id="menu")'), 413 | $main=$('div:jqmData(id="main")'), 414 | $mainHeader=$main.find('div.'+$.mobile.activePageClass+'> div:jqmData(role="header")'), 415 | $window=$(window); 416 | 417 | function popoverBtn(header) { 418 | if(!header.children('.popover-btn').length){ 419 | if(header.children('a.ui-btn-left').length){ 420 | header.children('a.ui-btn-left').replaceWith('Menu'); 421 | header.children('a.popover-btn').addClass('ui-btn-left').buttonMarkup(); 422 | } 423 | else{ 424 | header.prepend('Menu'); 425 | header.children('a.popover-btn').addClass('ui-btn-left').buttonMarkup() 426 | } 427 | } 428 | } 429 | 430 | function replaceBackBtn(header) { 431 | if($.mobile.urlHistory.stack.length > 1 && !header.children('a:jqmData(rel="back")').length && header.jqmData('backbtn')!=false){ 432 | header.prepend("Back" ); 433 | header.children('a:jqmData(rel="back")').buttonMarkup(); 434 | } 435 | }; 436 | 437 | function popover(){ 438 | $menu.addClass('panel-popover') 439 | .removeClass('ui-panel-left') 440 | .css({'width':'25%', 'min-width':'250px', 'display':'', 'overflow-x':'visible'}); 441 | if(!$menu.children('.popover_triangle').length){ 442 | $menu.prepend('
    '); 443 | } 444 | $menu.children('.' + $.activePageClass).css('min-height', '100%'); 445 | $main.removeClass('ui-panel-right') 446 | .css('width', ''); 447 | popoverBtn($mainHeader); 448 | 449 | $main.undelegate('div:jqmData(role="page")', 'pagebeforeshow.splitview'); 450 | $main.delegate('div:jqmData(role="page")','pagebeforeshow.popover', function(){ 451 | var $thisHeader=$(this).children('div:jqmData(role="header")'); 452 | popoverBtn($thisHeader); 453 | }); 454 | // TODO: unbind resetActivePageHeight for popover pages 455 | 456 | }; 457 | 458 | function splitView(){ 459 | $menu.removeClass('panel-popover') 460 | .addClass('ui-panel-left') 461 | .css({'width':'25%', 'min-width':'250px', 'display':''}); 462 | $menu.children('.popover_triangle').remove(); 463 | $main.addClass('ui-panel-right') 464 | .width(function(){ 465 | return $(window).width()-$('div:jqmData(id="menu")').width(); 466 | }); 467 | $mainHeader.children('.popover-btn').remove(); 468 | 469 | // replaceBackBtn($mainHeader); 470 | 471 | $main.undelegate('div:jqmData(role="page")', 'pagebeforeshow.popover'); 472 | $main.delegate('div:jqmData(role="page")', 'pagebeforeshow.splitview', function(){ 473 | var $thisHeader=$(this).children('div:jqmData(role="header")'); 474 | $thisHeader.children('.popover-btn').remove(); 475 | // replaceBackBtn($thisHeader); 476 | }); 477 | 478 | } 479 | 480 | if(event.orientation){ 481 | if(event.orientation == 'portrait'){ 482 | popover(); 483 | } 484 | else if(event.orientation == 'landscape') { 485 | splitView(); 486 | } 487 | } 488 | else if($window.width() < 768 && $window.width() > 480){ 489 | popover(); 490 | } 491 | else if($window.width() > 768){ 492 | splitView(); 493 | } 494 | }; 495 | 496 | $(window).bind('orientationchange', _orientationHandler); 497 | $(window).bind('throttledresize', _orientationHandler); 498 | 499 | //popover button click handler - from http://www.cagintranet.com/archive/create-an-ipad-like-dropdown-popover/ 500 | $('.popover-btn').live('click', function(e){ 501 | e.preventDefault(); 502 | $('.panel-popover').fadeToggle('fast'); 503 | if ($('.popover-btn').hasClass($.mobile.activeBtnClass)) { 504 | $('.popover-btn').removeClass($.mobile.activeBtnClass); 505 | } else { 506 | $('.popover-btn').addClass($.mobile.activeBtnClass); 507 | } 508 | }); 509 | 510 | $('body').live('click', function(event) { 511 | if (!$(event.target).closest('.panel-popover').length && !$(event.target).closest('.popover-btn').length) { 512 | $(".panel-popover").stop(true, true).hide(); 513 | $('.popover-btn').removeClass($.mobile.activeBtnClass); 514 | }; 515 | }); 516 | 517 | 518 | //---------------------------------------------------------------------------------- 519 | //Other event bindings: scrollview, crumbs, data-context and content height adjustments 520 | //---------------------------------------------------------------------------------- 521 | 522 | //DONE: pageshow binding for scrollview - now using IScroll4! hell yeah! 523 | $('div:jqmData(role="page")').live('pagebeforeshow.scroll', function(event, ui){ 524 | if ($.support.touch && !$.support.touchOverflow) { 525 | 526 | var $page = $(this), 527 | $scrollArea = $page.find('div:jqmData(role="content")'); 528 | $scrAreaChildren = $scrollArea.children(); 529 | 530 | if ($scrAreaChildren.length > 1) { 531 | $scrAreaChildren = $scrollArea.wrapInner("
    ").children(); 532 | } 533 | $scrollArea.css({ 'width':'auto', 534 | 'height':'auto', 535 | 'overflow':'hidden'}); 536 | //TODO: if too many pages are in the DOM that have iscroll on, this might slow down the browser significantly, 537 | //in which case we'll need to destroy() the iscroll as the page hides. 538 | $scrollArea.iscroll(); 539 | } 540 | }); 541 | 542 | //data-hash 'crumbs' handler 543 | //now that data-backbtn is no longer defaulting to true, lets set crumbs to create itself even when backbtn is not available 544 | $('div:jqmData(role="page")').live('pagebeforeshow.crumbs', function(event, data){ 545 | var $this = $(this); 546 | if($this.jqmData('hash') == 'crumbs' || $this.parents('div:jqmData(role="panel")').data('hash') == 'crumbs'){ 547 | if($this.jqmData('hash')!=false && $this.find('.ui-crumbs').length < 1){ 548 | var $header=$this.find('div:jqmData(role="header")'); 549 | backBtn = $this.find('a:jqmData(rel="back")'); 550 | 551 | if(data.prevPage.jqmData('url') == $this.jqmData('url')){ //if it's a page refresh 552 | var prevCrumb = data.prevPage.find('.ui-crumbs'); 553 | crumbify(backBtn, prevCrumb.attr('href'), prevCrumb.find('.ui-btn-text').html()); 554 | } 555 | else if($.mobile.urlHistory.stack.length > 0) { 556 | var text = data.prevPage.find('div:jqmData(role="header") .ui-title').html(); 557 | crumbify(backBtn, '#'+data.prevPage.jqmData('url'), text); 558 | } 559 | else if(backBtn.length && $.mobile.urlHistory.stack.length <= 1) { 560 | backBtn.remove(); 561 | } 562 | } 563 | } 564 | 565 | function crumbify(button, href, text){ 566 | if(!button.length) { 567 | $this.find('div:jqmData(role="header")').prepend(''); 568 | button=$header.children('.ui-crumbs').buttonMarkup(); 569 | } 570 | button.removeAttr('data-rel') 571 | .jqmData('direction','reverse') 572 | .addClass('ui-crumbs') 573 | .attr('href',href); 574 | button.find('.ui-btn-text').html(text); 575 | } 576 | }); 577 | 578 | //data-context handler - a page with a link that has a data-context attribute will load that page after this page loads 579 | //this still needs work - pageTransitionQueue messes everything up. 580 | $('div:jqmData(role="panel")').live('pagechange.context', function(){ 581 | var $this=$(this), 582 | $currPanelActivePage = $this.children('.' + $.mobile.activePageClass), 583 | panelContextSelector = $this.jqmData('context'), 584 | pageContextSelector = $currPanelActivePage.jqmData('context'), 585 | contextSelector= pageContextSelector ? pageContextSelector : panelContextSelector; 586 | //if you pass a hash into data-context, you need to specify panel, url and a boolean value for refresh 587 | if($.type(contextSelector) === 'object') { 588 | var $targetContainer=$('div:jqmData(id="'+contextSelector.panel+'")'), 589 | $targetPanelActivePage=$targetContainer.children('div.'+$.mobile.activePageClass), 590 | isRefresh = contextSelector.refresh === undefined ? false : contextSelector.refresh; 591 | if(($targetPanelActivePage.jqmData('url') == contextSelector.url && contextSelector.refresh)||(!contextSelector.refresh && $targetPanelActivePage.jqmData('url') != contextSelector.url)){ 592 | $.mobile.changePage(contextSelector.url, options={transition:'fade', changeHash:false, pageContainer:$targetContainer, reloadPage:isRefresh}); 593 | } 594 | } 595 | else if(contextSelector && $currPanelActivePage.find(contextSelector).length){ 596 | $currPanelActivePage.find(contextSelector).trigger('click'); 597 | } 598 | }); 599 | 600 | //this measures the height of header and footer and sets content to the appropriate height so 601 | // that no content is concealed behind header and footer 602 | $('div:jqmData(role="page")').live('pageshow.contentHeight', function(){ 603 | var $this=$(this), 604 | $header=$this.children(':jqmData(role="header")'), 605 | $footer=$this.children(':jqmData(role="footer")'), 606 | thisHeaderHeight=$header.css('display') == 'none' ? 0 : $header.outerHeight(), 607 | thisFooterHeight=$footer.css('display') == 'none' ? 0 : $footer.outerHeight(); 608 | // $this.children(':jqmData(role="content")').css({'top':thisHeaderHeight, 'bottom':thisFooterHeight}); 609 | }) 610 | 611 | //this allows panels to change their widths upon changepage - useful for pages that need a different width than the ones provided. 612 | // $('div:jqmData(role="page")').live('') 613 | } 614 | else { 615 | //removes all panels so the page behaves like a single panel jqm 616 | $(function(){ 617 | $('div:jqmData(role="panel")').each(function(){ 618 | var $this = $(this); 619 | $this.replaceWith($this.html()); 620 | }) 621 | }); 622 | } 623 | }); 624 | })(jQuery,window); --------------------------------------------------------------------------------