fanforce-app-factory 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,10 +19,25 @@ class FanforceApp::Sinatra < Sinatra::Base
19
19
  helpers Sinatra::ContentFor
20
20
 
21
21
  def self.any(url,&block)
22
- get(url,&block)
23
- post(url,&block)
24
- put(url,&block)
25
- delete(url,&block)
22
+ get(url, &block)
23
+ put(url, &block)
24
+ post(url, &block)
25
+ delete(url, &block)
26
+ end
27
+
28
+ def self.default_javascript_package(package_name)
29
+
30
+ end
31
+
32
+ def self.require_controllers
33
+ require "#{FanforceApp.config.factory_root_dir}/controllers/base_controller"
34
+ Dir["#{FanforceApp.config.root_dir}/controllers/*_controller.rb"].each {|f| require f }
35
+ end
36
+
37
+ @@static_files = {}
38
+ def self.static(url, *args, &block)
39
+ @@static_files[url] = {args: args, block: block}
40
+ get(url, &block)
26
41
  end
27
42
 
28
43
  def page(page, options={})
@@ -50,6 +65,7 @@ class FanforceApp::Sinatra < Sinatra::Base
50
65
  else
51
66
  options[:layout] = false
52
67
  end
68
+
53
69
  haml page_path, options
54
70
  end
55
71
 
@@ -0,0 +1 @@
1
+ @import 'common/layouts/convert_initiative';
@@ -0,0 +1 @@
1
+ //= require common/layouts/convert_initiative
@@ -8,7 +8,7 @@ class FanforceApp::CoreConfig
8
8
  dashboard: true,
9
9
  add_initiative: true,
10
10
  edit_initiative: true,
11
- convert_pending_initiative: true,
11
+ convert_initiative: true,
12
12
  add_source: true,
13
13
  close_popup: true,
14
14
  engage: true,
@@ -71,16 +71,9 @@ class FanforceApp::CoreConfig
71
71
  $: << File.join(@root_dir,'lib') if File.directory?("#{@root_dir}/lib")
72
72
  $: << @root_dir if File.directory?("#{@root_dir}")
73
73
 
74
- require "#{@root_dir}/config/initializer" if File.exists?("#{@root_dir}/config/initializer.rb")
75
- require "#{@root_dir}/initializer" if File.exists?("#{@root_dir}/initializer.rb")
76
- if File.directory?("#{@root_dir}/initializers")
77
- Dir["#{@root_dir}/initializers/*.rb"].each {|file| require file }
78
- end
74
+ Dir["#{@root_dir}/initializers/*.rb"].each {|f| require f } if File.directory?("#{@root_dir}/initializers")
79
75
 
80
- require "#{@root_dir}/config/routes" if File.exists?("#{@root_dir}/config/routes.rb")
81
- require "#{@root_dir}/views/_routes" if File.exists?("#{@root_dir}/views/_routes.rb")
82
- require "#{@root_dir}/_routes" if File.exists?("#{@root_dir}/_routes.rb")
83
- require "#{@root_dir}/routes" if File.exists?("#{@root_dir}/routes.rb")
76
+ require "#{@root_dir}/Routes" if File.exists?("#{@root_dir}/Routes.rb")
84
77
 
85
78
  require "#{@factory_root_dir}/routes_core"
86
79
  require "#{@factory_root_dir}/routes_connector"
@@ -18,21 +18,4 @@ module Sinatra::FanforceHelpers
18
18
  $Redis.get("installed:#{addon_type}-#{addon_id}:#{organization_id}")
19
19
  end
20
20
 
21
- # Creates a string representation of a javascript object for ractive.js
22
- def compile_ractive_templates(options={}, &block)
23
- context = Object.new
24
- class << context
25
- include Haml::Helpers
26
- end
27
- context.init_haml_helpers
28
-
29
- format = options[:format] == 'html' ? :html : :json
30
-
31
- return context.capture_haml(&block) if format == :html
32
- single_line_html = context.capture_haml(&block).split(/\r?\n/).inject('') {|sl, l| sl += l.strip + ' ' }
33
- matches = single_line_html.scan(/<script id=[\"'](.*?)[\"'](?:.*?)>(.*?)(?:<\/script>)/mi)
34
-
35
- matches.inject({}) {|t,m| t[m[0]] = m[1]; t }.to_json
36
- end
37
-
38
21
  end
@@ -1,5 +1,22 @@
1
1
  module Sinatra::RactiveHelpers
2
2
 
3
+ # Creates a string representation of a javascript object for ractive.js
4
+ def compile_ractive_templates(options={}, &block)
5
+ context = Object.new
6
+ class << context
7
+ include Haml::Helpers
8
+ end
9
+ context.init_haml_helpers
10
+
11
+ format = options[:format] == 'html' ? :html : :json
12
+
13
+ return context.capture_haml(&block) if format == :html
14
+ single_line_html = context.capture_haml(&block).split(/\r?\n/).inject('') {|sl, l| sl += l.strip + ' ' }
15
+ matches = single_line_html.scan(/<script id=[\"'](.*?)[\"'](?:.*?)>(.*?)(?:<\/script>)/mi)
16
+
17
+ matches.inject({}) {|t,m| t[m[0]] = m[1]; t }.to_json
18
+ end
19
+
3
20
  def RACTIVE(helper, &block)
4
21
  begin require 'haml' rescue LoadError raise 'You must have the haml gem installed to use Fanforce.compile_jquery_templates.' end
5
22
  raise ArgumentError, "Missing block" unless block_given?
@@ -24,4 +41,17 @@ module Sinatra::RactiveHelpers
24
41
  RACTIVE(helper, &block)
25
42
  end
26
43
 
44
+ def column(size, &block)
45
+ begin require 'haml' rescue LoadError raise 'You must have the haml gem installed to use Fanforce.compile_jquery_templates.' end
46
+ if block
47
+ context = Object.new
48
+ class << context
49
+ include Haml::Helpers
50
+ end
51
+ context.init_haml_helpers
52
+ html = context.capture_haml(&block)
53
+ end
54
+ "<div class='small-12 medium-#{size} column'>\n#{html}</div>"
55
+ end
56
+
27
57
  end
@@ -0,0 +1,14 @@
1
+ class FanforceApp::BaseController
2
+
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def app; @app end
8
+ def params; @app.params end
9
+ def ff; @app.ff end
10
+ def json(*args) @app.json(*args) end
11
+ def page(*args) @app.page(*args) end
12
+ def redirect(*args) @app.redirect(*args) end
13
+
14
+ end
@@ -5,7 +5,7 @@
5
5
  %title Fanforce
6
6
  %meta{'http-equiv'=>'Content-Type', content:'text/html; charset=iso-8859-1'}/
7
7
  %meta{'http-equiv'=>'Content-Language', content: 'en-us'}/
8
- = stylesheet '/convert_pending_initiative.css'
8
+ = stylesheet '/convert_initiative.css'
9
9
  :javascript
10
10
  BASE_DOMAIN = #{Fanforce.base_domain.to_json}
11
11
  API_DOMAIN = #{Fanforce.api_domain.to_json}
@@ -15,5 +15,5 @@
15
15
  = yield
16
16
  = javascript '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'
17
17
  = javascript "//#{Fanforce.eye_domain}/devforce.js#{'?DEBUG=1&DYNAMIC=1' if ENV['RACK_ENV']=='development'}"
18
- = javascript '/convert_pending_initiative.js'
18
+ = javascript '/convert_initiative.js'
19
19
  = yield_content :after_core_js
@@ -1,44 +1,31 @@
1
1
  class FanforceApp::Sinatra
2
2
 
3
- # ARCHIVE INITIATIVE ###########################################################
4
- def route_archive_initiative(params)
5
- json status: 'finished-processing'
3
+ def route_add_initiative_ui
4
+ page :add_initiative, :layout => :add_edit_initiative, com_dir: "#{params[:com_behavior_shortid]}"
6
5
  end
7
- post '/:com_behavior_shortid/archive_initiative' do route_archive_initiative(params) end
8
6
 
9
- # DESTROY INITIATIVE ###########################################################
10
- def route_destroy_initiative(params)
11
- json status: 'finished-processing'
7
+ def route_convert_initiative_ui
8
+ page :convert_initiative, :layout => :convert_initiative, com_dir: "#{params[:com_behavior_shortid]}"
12
9
  end
13
- post '/:com_behavior_shortid/destroy_initiative' do route_destroy_initiative(params) end
14
10
 
15
- # AUTOCREATE PENDING INITIATIVE ###########################################################
16
- def route_autocreate_pending_initiative(params)
17
- json status: 'finished-processing'
11
+ def route_edit_initiative_ui
12
+ page :edit_initiative, :layout => :add_edit_initiative, com_dir: "#{params[:com_behavior_shortid]}"
18
13
  end
19
- get '/:com_behavior_shortid/autocreate_pending_initiative' do route_autocreate_pending_initiative(params) end
20
14
 
21
- # ADD INITIATIVE UI ############################################################
22
- def route_add_initiative(params)
23
- page :add_initiative, :layout => :add_edit_initiative, com_dir: "#{params[:com_behavior_shortid]}"
15
+ def route_engage_page_ui
16
+ page :engage, :layout => :engage, com_dir: "#{params[:com_behavior_shortid]}"
24
17
  end
25
- get '/:com_behavior_shortid/add_initiative.html' do route_add_initiative(params) end
26
18
 
27
- # ADD PENDING INITIATIVE UI ############################################################
28
- def route_convert_pending_initiative(params)
29
- page :convert_pending_initiative, :layout => :convert_pending_initiative, com_dir: "#{params[:com_behavior_shortid]}"
19
+ def route_archive_initiative_callback
20
+ json status: 'finished-processing'
30
21
  end
31
- get '/:com_behavior_shortid/convert_pending_initiative.html' do route_convert_pending_initiative(params) end
32
22
 
33
- # EDIT INITIATIVE UI ###########################################################
34
- def route_edit_initiative(params)
35
- page :edit_initiative, :layout => :add_edit_initiative, com_dir: "#{params[:com_behavior_shortid]}"
23
+ def route_destroy_initiative_callback
24
+ json status: 'finished-processing'
36
25
  end
37
- get '/:com_behavior_shortid/edit_initiative.html' do route_edit_initiative(params) end
38
26
 
39
- # ENGAGE #######################################################################
40
- def route_engage_page(params)
41
- page :engage, :layout => :engage, com_dir: "#{params[:com_behavior_shortid]}"
27
+ def route_autocreate_initiative_callback
28
+ json status: 'finished-processing'
42
29
  end
43
30
 
44
31
  end
@@ -1,9 +1,7 @@
1
1
  class FanforceApp::Sinatra
2
2
 
3
- # NEW MESSAGE ##################################################################
4
- def route_new_message(params)
3
+ def route_new_message_ui
5
4
  page :new_message, :layout => :new_message
6
5
  end
7
- get '/new_message.html' do route_new_message(params) end
8
6
 
9
7
  end
@@ -1,21 +1,11 @@
1
1
  class FanforceApp::Sinatra
2
2
 
3
- # ADD SOURCE ##################################################################
4
- def route_add_source(params)
3
+ def route_add_source_ui
5
4
  page :add_source, :layout => :add_source
6
5
  end
7
- get '/:com_connector_shortid/add_source.html' do route_add_source(params) end
8
6
 
9
- # CLOSE POPUP #################################################################
10
- def route_close_popup(params)
11
- page :close_popup
12
- end
13
- get '/close_popup.html' do route_close_popup(params) end
14
-
15
- # SOURCE DETAILS ##############################################################
16
- def route_source_details(params)
7
+ def route_source_details_ui
17
8
  page :source_details, :layout => :source_details
18
9
  end
19
- get '/:com_connector_shortid/source_details.html' do route_source_details(params) end
20
10
 
21
11
  end
@@ -1,15 +1,18 @@
1
1
  class FanforceApp::Sinatra
2
2
 
3
- # INDEX ########################################################################
4
- def route_index(params)
3
+ def route_index_ui
5
4
  page :index, :layout => :promotional
6
5
  end
7
- ['/', '/index.html'].each do |path|
8
- get path do route_index(params) end
6
+
7
+ def route_config_ui
8
+ page :config, :layout => :config
9
+ end
10
+
11
+ def route_close_popup_ui
12
+ page :close_popup
9
13
  end
10
14
 
11
- # INSTALL ######################################################################
12
- def route_install(params)
15
+ def route_install_callback
13
16
  raise "This is not a valid app install request: #{env['HTTP_HOST']}" if !ff.valid_install_request?(params)
14
17
  api_key = $Redis.get("installed:app-#{ff.params[:app_id]}:#{params[:organization_id]}")
15
18
 
@@ -22,10 +25,8 @@ class FanforceApp::Sinatra
22
25
 
23
26
  json status: 'finished-processing'
24
27
  end
25
- any '/install' do route_install(params) end
26
28
 
27
- # UNINSTALL ####################################################################
28
- def route_uninstall(params)
29
+ def route_uninstall_callback
29
30
  raise 'This is not a valid app uninstall request.' if !ff.valid_uninstall_request?(params)
30
31
  api_key = $Redis.get("installed:app-#{ff.params[:app_id]}:#{params[:organization_id]}")
31
32
 
@@ -37,18 +38,9 @@ class FanforceApp::Sinatra
37
38
  $Redis.del("installed:app-#{ff.params[:app_id]}:#{params[:organization_id]}")
38
39
  json status: 'finished-processing'
39
40
  end
40
- any '/uninstall' do route_uninstall(params) end
41
-
42
- # DASHBOARD ####################################################################
43
- def route_dashboard(params)
44
- page :dashboard, :layout => :dashboard
45
- end
46
- get '/dashboard.html' do route_dashboard(params) end
47
41
 
48
- # PING-PONG ####################################################################
49
- def route_ping_pong(params)
42
+ def route_ping_pong
50
43
  json success: true
51
44
  end
52
- get '/ping-pong' do route_ping_pong(params) end
53
45
 
54
46
  end
@@ -1,10 +1,8 @@
1
1
  class FanforceApp::Sinatra
2
2
 
3
- # WIDGET TEMPLATES #################################################################
4
- def route_widget_templates(params)
3
+ def route_widget_templates
5
4
  content_type 'application/javascript'
6
5
  page :widget_templates
7
6
  end
8
- get '/widget_templates' do route_widget_templates(params) end
9
7
 
10
8
  end
@@ -1,5 +1,5 @@
1
1
  class Fanforce
2
2
  module AppFactory
3
- VERSION = '1.3.0'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fanforce-app-factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -350,7 +350,7 @@ files:
350
350
  - lib/fanforce/app_factory/_init_sinatra.rb
351
351
  - lib/fanforce/app_factory/assets/css/add_edit_initiative.scss
352
352
  - lib/fanforce/app_factory/assets/css/add_source.scss
353
- - lib/fanforce/app_factory/assets/css/convert_pending_initiative.scss
353
+ - lib/fanforce/app_factory/assets/css/convert_initiative.scss
354
354
  - lib/fanforce/app_factory/assets/css/dashboard.scss
355
355
  - lib/fanforce/app_factory/assets/css/engage.scss
356
356
  - lib/fanforce/app_factory/assets/css/new_message.scss
@@ -364,7 +364,7 @@ files:
364
364
  - lib/fanforce/app_factory/assets/js/add_edit_initiative.js
365
365
  - lib/fanforce/app_factory/assets/js/add_source.js
366
366
  - lib/fanforce/app_factory/assets/js/add_source_popup.js
367
- - lib/fanforce/app_factory/assets/js/convert_pending_initiative.js
367
+ - lib/fanforce/app_factory/assets/js/convert_initiative.js
368
368
  - lib/fanforce/app_factory/assets/js/dashboard.coffee
369
369
  - lib/fanforce/app_factory/assets/js/fanforce-engager.js
370
370
  - lib/fanforce/app_factory/assets/js/fanforce-finder.js
@@ -387,7 +387,7 @@ files:
387
387
  - lib/fanforce/app_factory/assets/lib/common/icons/initiative.png
388
388
  - lib/fanforce/app_factory/assets/lib/common/layouts/_add_edit_initiative.scss
389
389
  - lib/fanforce/app_factory/assets/lib/common/layouts/_add_source.scss
390
- - lib/fanforce/app_factory/assets/lib/common/layouts/_convert_pending_initiative.scss
390
+ - lib/fanforce/app_factory/assets/lib/common/layouts/_convert_initiative.scss
391
391
  - lib/fanforce/app_factory/assets/lib/common/layouts/_dashboard.scss
392
392
  - lib/fanforce/app_factory/assets/lib/common/layouts/_engage.scss
393
393
  - lib/fanforce/app_factory/assets/lib/common/layouts/_new_message.scss
@@ -395,7 +395,7 @@ files:
395
395
  - lib/fanforce/app_factory/assets/lib/common/layouts/_source_details.scss
396
396
  - lib/fanforce/app_factory/assets/lib/common/layouts/add_edit_initiative.js
397
397
  - lib/fanforce/app_factory/assets/lib/common/layouts/add_source.js
398
- - lib/fanforce/app_factory/assets/lib/common/layouts/convert_pending_initiative.js
398
+ - lib/fanforce/app_factory/assets/lib/common/layouts/convert_initiative.js
399
399
  - lib/fanforce/app_factory/assets/lib/common/layouts/dashboard.js
400
400
  - lib/fanforce/app_factory/assets/lib/common/layouts/engage.js
401
401
  - lib/fanforce/app_factory/assets/lib/common/layouts/new_message.js
@@ -455,9 +455,10 @@ files:
455
455
  - lib/fanforce/app_factory/config/helpers/fanforce.rb
456
456
  - lib/fanforce/app_factory/config/helpers/json.rb
457
457
  - lib/fanforce/app_factory/config/helpers/ractive.rb
458
+ - lib/fanforce/app_factory/controllers/base_controller.rb
458
459
  - lib/fanforce/app_factory/layouts/add_edit_initiative.haml
459
460
  - lib/fanforce/app_factory/layouts/add_source.haml
460
- - lib/fanforce/app_factory/layouts/convert_pending_initiative.haml
461
+ - lib/fanforce/app_factory/layouts/convert_initiative.haml
461
462
  - lib/fanforce/app_factory/layouts/dashboard.haml
462
463
  - lib/fanforce/app_factory/layouts/engage.haml
463
464
  - lib/fanforce/app_factory/layouts/new_message.haml
@@ -477,7 +478,7 @@ files:
477
478
  - lib/fanforce/app_factory/views/add_initiative.haml
478
479
  - lib/fanforce/app_factory/views/add_source.haml
479
480
  - lib/fanforce/app_factory/views/close_popup.haml
480
- - lib/fanforce/app_factory/views/convert_pending_initiative.haml
481
+ - lib/fanforce/app_factory/views/convert_initiative.haml
481
482
  - lib/fanforce/app_factory/views/dashboard.haml
482
483
  - lib/fanforce/app_factory/views/edit_initiative.haml
483
484
  - lib/fanforce/app_factory/views/engage.haml
@@ -1 +0,0 @@
1
- @import 'common/layouts/convert_pending_initiative';
@@ -1 +0,0 @@
1
- //= require common/layouts/convert_pending_initiative