fanforce-plugin-factory 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +21 -0
  3. data/Gemfile +2 -0
  4. data/README.md +218 -0
  5. data/Rakefile +16 -0
  6. data/fanforce-plugin-factory.gemspec +42 -0
  7. data/lib/fanforce/plugin_factory.rake +71 -0
  8. data/lib/fanforce/plugin_factory.rb +60 -0
  9. data/lib/fanforce/plugin_factory/_init_sinatra.rb +53 -0
  10. data/lib/fanforce/plugin_factory/assets/css/add_edit_initiative.scss +1 -0
  11. data/lib/fanforce/plugin_factory/assets/css/add_source.scss +1 -0
  12. data/lib/fanforce/plugin_factory/assets/css/engage.scss +1 -0
  13. data/lib/fanforce/plugin_factory/assets/css/new_message.scss +1 -0
  14. data/lib/fanforce/plugin_factory/assets/css/promotional.scss +1 -0
  15. data/lib/fanforce/plugin_factory/assets/css/source_details.scss +1 -0
  16. data/lib/fanforce/plugin_factory/assets/img/icon-16.png +0 -0
  17. data/lib/fanforce/plugin_factory/assets/img/icon-32.png +0 -0
  18. data/lib/fanforce/plugin_factory/assets/img/icon-42.png +0 -0
  19. data/lib/fanforce/plugin_factory/assets/js/add_edit_initiative.js +1 -0
  20. data/lib/fanforce/plugin_factory/assets/js/add_source.js +1 -0
  21. data/lib/fanforce/plugin_factory/assets/js/add_source_popup.js +0 -0
  22. data/lib/fanforce/plugin_factory/assets/js/engage.js +1 -0
  23. data/lib/fanforce/plugin_factory/assets/js/new_message.js +1 -0
  24. data/lib/fanforce/plugin_factory/assets/js/promotional.js +2 -0
  25. data/lib/fanforce/plugin_factory/assets/js/source_details.js +0 -0
  26. data/lib/fanforce/plugin_factory/assets/lib/common/_mixins.scss +97 -0
  27. data/lib/fanforce/plugin_factory/assets/lib/common/_module-error.scss +11 -0
  28. data/lib/fanforce/plugin_factory/assets/lib/common/_module-search-to-add-initiative.scss +66 -0
  29. data/lib/fanforce/plugin_factory/assets/lib/common/_module-video-thumbnail.scss +15 -0
  30. data/lib/fanforce/plugin_factory/assets/lib/common/_tags.scss +83 -0
  31. data/lib/fanforce/plugin_factory/assets/lib/common/_variables.scss +27 -0
  32. data/lib/fanforce/plugin_factory/assets/lib/common/broadcaster-divider-arrow.png +0 -0
  33. data/lib/fanforce/plugin_factory/assets/lib/common/icons/dropdown-arrow.png +0 -0
  34. data/lib/fanforce/plugin_factory/assets/lib/common/icons/initiative.png +0 -0
  35. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_add_edit_initiative.scss +23 -0
  36. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_add_source.scss +17 -0
  37. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_engage.scss +39 -0
  38. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_new_message.scss +26 -0
  39. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_promotional.scss +26 -0
  40. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/_source_details.scss +16 -0
  41. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/add_edit_initiative.js +6 -0
  42. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/add_source.js +6 -0
  43. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/engage.js +0 -0
  44. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/new_message.js +5 -0
  45. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/promotional.js +1 -0
  46. data/lib/fanforce/plugin_factory/assets/lib/common/layouts/source_details.js +5 -0
  47. data/lib/fanforce/plugin_factory/assets/lib/common/module-error/arrow-left.png +0 -0
  48. data/lib/fanforce/plugin_factory/assets/lib/common/module-error/icon-error.png +0 -0
  49. data/lib/fanforce/plugin_factory/assets/lib/common/module-search-to-add-initiative/icon-search.png +0 -0
  50. data/lib/fanforce/plugin_factory/assets/lib/common/module-search-to-add-initiative/spinner.gif +0 -0
  51. data/lib/fanforce/plugin_factory/assets/lib/common/module-search-to-add-initiative/sprite-arrows.png +0 -0
  52. data/lib/fanforce/plugin_factory/assets/lib/common/module-video-thumbnail/icon-play.png +0 -0
  53. data/lib/fanforce/plugin_factory/assets/lib/promotional/fanforce_bg.png +0 -0
  54. data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-42.png +0 -0
  55. data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-behavior.png +0 -0
  56. data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-broadcaster.png +0 -0
  57. data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-data-connector.png +0 -0
  58. data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-data-processor.png +0 -0
  59. data/lib/fanforce/plugin_factory/assets/lib/promotional/icon-identifier.png +0 -0
  60. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-datepicker/datepicker.css +7 -0
  61. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-datepicker/datepicker.js +454 -0
  62. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-timepicker/timepicker.css +82 -0
  63. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap-timepicker/timepicker.js +803 -0
  64. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/css/bootstrap.css +6103 -0
  65. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/css/bootstrap.min.css +868 -0
  66. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings-white.png +0 -0
  67. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/img/glyphicons-halflings.png +0 -0
  68. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/js/bootstrap.js +2170 -0
  69. data/lib/fanforce/plugin_factory/assets/lib/vendors/bootstrap/js/bootstrap.min.js +7 -0
  70. data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/chosen-sprite.png +0 -0
  71. data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/chosen.jquery.min.js +10 -0
  72. data/lib/fanforce/plugin_factory/assets/lib/vendors/chosen/chosen.scss +399 -0
  73. data/lib/fanforce/plugin_factory/assets/lib/vendors/font-awesome/css/font-awesome.css +540 -0
  74. data/lib/fanforce/plugin_factory/assets/lib/vendors/font-awesome/css/font-awesome.min.css +33 -0
  75. data/lib/fanforce/plugin_factory/assets/lib/vendors/font-awesome/font/FontAwesome.otf +0 -0
  76. data/lib/fanforce/plugin_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.eot +0 -0
  77. data/lib/fanforce/plugin_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.svg +284 -0
  78. data/lib/fanforce/plugin_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.ttf +0 -0
  79. data/lib/fanforce/plugin_factory/assets/lib/vendors/font-awesome/font/fontawesome-webfont.woff +0 -0
  80. data/lib/fanforce/plugin_factory/assets/lib/vendors/jquery/jquery.inputHint.js +154 -0
  81. data/lib/fanforce/plugin_factory/assets/lib/vendors/jquery/jquery.tmpl.debug.js +484 -0
  82. data/lib/fanforce/plugin_factory/assets/lib/vendors/knockout/knockout.custom-handlers.coffee +131 -0
  83. data/lib/fanforce/plugin_factory/assets/lib/vendors/knockout/knockout.debug.js +3223 -0
  84. data/lib/fanforce/plugin_factory/assets/lib/vendors/underscore/underscore.debug.js +999 -0
  85. data/lib/fanforce/plugin_factory/config/_error_handling.rb +26 -0
  86. data/lib/fanforce/plugin_factory/config/helpers/assets.rb +23 -0
  87. data/lib/fanforce/plugin_factory/config/helpers/fanforce.rb +21 -0
  88. data/lib/fanforce/plugin_factory/config/helpers/json.rb +10 -0
  89. data/lib/fanforce/plugin_factory/config/sinatra_config.rb +65 -0
  90. data/lib/fanforce/plugin_factory/initializers/ff_globals.rb +72 -0
  91. data/lib/fanforce/plugin_factory/layouts/add_edit_initiative.haml +14 -0
  92. data/lib/fanforce/plugin_factory/layouts/add_source.haml +14 -0
  93. data/lib/fanforce/plugin_factory/layouts/engage.haml +27 -0
  94. data/lib/fanforce/plugin_factory/layouts/new_message.haml +14 -0
  95. data/lib/fanforce/plugin_factory/layouts/promotional.haml +14 -0
  96. data/lib/fanforce/plugin_factory/layouts/source_details.haml +14 -0
  97. data/lib/fanforce/plugin_factory/public/favicon.ico +0 -0
  98. data/lib/fanforce/plugin_factory/routes.rb +35 -0
  99. data/lib/fanforce/plugin_factory/routes_behavior.rb +28 -0
  100. data/lib/fanforce/plugin_factory/routes_broadcaster.rb +9 -0
  101. data/lib/fanforce/plugin_factory/routes_data_connector.rb +21 -0
  102. data/lib/fanforce/plugin_factory/sprockets/compiler.rb +107 -0
  103. data/lib/fanforce/plugin_factory/sprockets/hacks.rb +43 -0
  104. data/lib/fanforce/plugin_factory/version.rb +5 -0
  105. data/lib/fanforce/plugin_factory/views/add_initiative.haml +1 -0
  106. data/lib/fanforce/plugin_factory/views/add_source.haml +1 -0
  107. data/lib/fanforce/plugin_factory/views/close_popup.haml +8 -0
  108. data/lib/fanforce/plugin_factory/views/edit_initiative.haml +1 -0
  109. data/lib/fanforce/plugin_factory/views/engage.haml +1 -0
  110. data/lib/fanforce/plugin_factory/views/index.haml +38 -0
  111. data/lib/fanforce/plugin_factory/views/new_message.haml +1 -0
  112. data/lib/fanforce/plugin_factory/views/source_details.haml +1 -0
  113. data/lib/fanforce/plugin_factory/views/widget_tmpls.haml +1 -0
  114. data/lib/fanforce/plugin_factory_workers.rb +1 -0
  115. metadata +436 -0
@@ -0,0 +1,26 @@
1
+ class FanforcePlugin::Sinatra
2
+ require 'fanforce/errors'
3
+ include Fanforce::Errors
4
+
5
+ set :raise_errors, false
6
+ set :show_exceptions, false
7
+
8
+ error 400..600 do
9
+ e = env['sinatra.error'] or (next response if e.nil?)
10
+
11
+ if Object.const_defined?('Fanforce') and Fanforce.const_defined?('Api') and e.is_a?(Fanforce::Api::Error)
12
+ errors = e.errors
13
+ else
14
+ errors = e.respond_to?(:public_errors) ? e.public_errors : []
15
+ errors << {message: 'There has been an internal server error. Our developers have been notified.'} if errors.size == 0
16
+ end
17
+
18
+ admin_details = Fanforce::Errors.format_admin_details(e, errors)
19
+
20
+ body = {errors: errors}
21
+ body.merge!(admin_details.merge(backtrace: e.backtrace)).delete(:public_response) if params[:show_error_details] == '1' or FanforcePlugin.config.show_error_details
22
+
23
+ status(e.respond_to?(:code ) ? e.code : 500) and json(body)
24
+ end
25
+ end
26
+
@@ -0,0 +1,23 @@
1
+ module Sinatra::AssetHelpers
2
+
3
+ def stylesheet(s)
4
+ s += '.css' unless s.include?('.css')
5
+ s = asset_path(s) unless s =~ /^https?:\// or s =~ /^\/\/\/.+/
6
+ "<link rel='stylesheet' href='#{s}' />"
7
+ end
8
+
9
+ def javascript(s)
10
+ s += '.js' unless s.include?('.js')
11
+ s = asset_path(s) unless s =~ /^https?:\// or s =~ /^\/\/\/.+/
12
+ "<script type='text/javascript' src='#{s}'></script>"
13
+ end
14
+
15
+ def asset_path(source, options={})
16
+ source = ('/assets/' + source).gsub('//', '/').gsub('/assets/assets/', '/assets/')
17
+ end
18
+
19
+ def image_path(source)
20
+ asset_path(source)
21
+ end
22
+
23
+ end
@@ -0,0 +1,21 @@
1
+ module Sinatra::FanforceHelpers
2
+ require 'fanforce'
3
+
4
+ def fanforce_id
5
+ @fanforce_id = params[:fanforce_id] || ff.params[:fanforce_id]
6
+ end
7
+
8
+ def ff
9
+ return @ff if @ff.present?
10
+ @ff = Fanforce.new(params)
11
+ #return @ff if !@ff.valid_fanforce_request? and !@ff.valid_fanforce_js_request?
12
+
13
+ @ff.auth Sinatra::FanforceHelpers.find_api_key(ff.params[:fanforce_id])
14
+ @ff
15
+ end
16
+
17
+ def self.find_api_key(fanforce_id, addon_type=:plugin, addon_id=FanforcePlugin._id)
18
+ $Redis.get("installed:#{addon_type}-#{addon_id}:#{fanforce_id}")
19
+ end
20
+
21
+ end
@@ -0,0 +1,10 @@
1
+ require 'multi_json'
2
+
3
+ module Sinatra::JSONHelpers
4
+ def json(*args)
5
+ args[0] = {} if args.size == 0
6
+ content_type (Rack.const_defined?('JSONR') and Rack::JSONR.is_jsonp_request?(request)) ? 'application/javascript' : :json
7
+ MultiJson.dump args[0], :pretty => settings.respond_to?(:json_pretty) && settings.json_pretty
8
+ end
9
+ alias JSON json
10
+ end
@@ -0,0 +1,65 @@
1
+ class FanforcePlugin::SinatraConfig
2
+ attr_accessor :layout_for_add_initiative, :layout_for_add_source, :layout_for_close_popup, :layout_for_edit_initiative, :layout_for_engage, :layout_for_index, :layout_for_new_message, :layout_for_source_details
3
+ attr_accessor :_id, :redis_url, :factory_root_dir, :root_dir, :dir_name, :show_error_details
4
+ attr_reader :type
5
+
6
+ def initialize(root_dir)
7
+ @layout_for_add_initiative = true
8
+ @layout_for_add_source = true
9
+ @layout_for_close_popup = true
10
+ @layout_for_edit_initiative = true
11
+ @layout_for_engage = true
12
+ @layout_for_index = true
13
+ @layout_for_new_message = true
14
+ @layout_for_source_details = true
15
+
16
+ @_id = ENV['FANFORCE_PLUGIN_ID']
17
+ @type = nil
18
+ @root_dir = root_dir
19
+ @factory_root_dir = File.expand_path '../../', __FILE__
20
+ @redis_url = ENV['REDIS_URL'] || 'redis://localhost:6379'
21
+ @show_error_details = false
22
+ end
23
+
24
+ def show_error_details=(bool)
25
+ @show_error_details = [true,1,'1'].include?(bool)
26
+ end
27
+
28
+ def type=(type)
29
+ allowed = [:data_connector, :data_processor, :broadcaster, :identifier, :behavior]
30
+ raise "type (#{type}) was not found in allowed list: #{allowed}" if !allowed.include?(type.to_sym)
31
+ @type = type.to_sym
32
+ end
33
+
34
+ def load
35
+ raise 'CRITICAL: This FanforcePlugin requires config._id to be set. See documentation.' if !@_id
36
+ raise 'CRITICAL: This FanforcePlugin requires config.root_dir to be set. See documentation' if !@root_dir
37
+
38
+ FanforcePlugin::Sinatra.set :root, @root_dir
39
+ FanforcePlugin::Sinatra.set :public_folder, [@root_dir+'/public', @factory_root_dir+'/public'].inject(''){|dir, d| File.directory?(d) ? (break d) : d }
40
+ FanforcePlugin::Sinatra.set :views, [@root_dir+'/views', @factory_root_dir+'/views'].inject(''){|dir, d| File.directory?(d) ? (break d) : d }
41
+
42
+ FanforcePlugin.config.load_routes
43
+ FanforcePlugin.config.load_redis
44
+ end
45
+
46
+ def load_routes
47
+ @dir_name = /\/([^\/]+)\/?$/.match(@root_dir)[1]
48
+
49
+ $: << File.join(@root_dir,'lib') if File.directory?("#{@root_dir}/lib")
50
+
51
+ require "#{@root_dir}/config/initializer" if File.exists?("#{@root_dir}/config/initializer.rb")
52
+ require "#{@root_dir}/config/routes" if File.exists?("#{@root_dir}/config/routes.rb")
53
+
54
+ require "#{@root_dir}/initializer" if File.exists?("#{@root_dir}/initializer.rb")
55
+ require "#{@root_dir}/routes" if File.exists?("#{@root_dir}/routes.rb")
56
+
57
+ require "#{@factory_root_dir}/routes_#{@type}" if @type and File.exists?("#{@factory_root_dir}/routes_#{@type}.rb")
58
+ require "#{@factory_root_dir}/routes"
59
+ end
60
+
61
+ def load_redis
62
+ $Redis = ::Redis.new(url: @redis_url)
63
+ end
64
+
65
+ end
@@ -0,0 +1,72 @@
1
+ if ENV['RACK_ENV'] == 'development'
2
+ $BASE_DOMAIN = 'fanforce.gg'
3
+ $APP_DOMAIN = 'app.' + $BASE_DOMAIN
4
+ $API_DOMAIN = 'api.' + $BASE_DOMAIN
5
+ $I_DOMAIN = 'i.' + $BASE_DOMAIN
6
+ $WEBSITE_DOMAIN = $BASE_DOMAIN
7
+
8
+ $SMARTURL_DOMAIN = 'fanforc.gg'
9
+ $FF_PLUGIN_DOMAIN = 'ffplugin.gg'
10
+ $FF_APP_DOMAIN = 'ffapp.gg'
11
+ $FF_WIDGET_DOMAIN = 'ffwidget.gg'
12
+
13
+ $DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com' # or localhost:3000'
14
+
15
+ $PUSHER_APP_ID = '23240'
16
+ $PUSHER_KEY = '029caf227a64c8e82e99'
17
+ $PUSHER_SECRET = '3169163d2e27de9a2291'
18
+
19
+ elsif ENV['RACK_ENV'] == 'test'
20
+ $BASE_DOMAIN = 'fanforce.gg'
21
+ $APP_DOMAIN = 'app.' + $BASE_DOMAIN
22
+ $API_DOMAIN = 'api.' + $BASE_DOMAIN
23
+ $I_DOMAIN = 'i.' + $BASE_DOMAIN
24
+ $WEBSITE_DOMAIN = $BASE_DOMAIN
25
+
26
+ $SMARTURL_DOMAIN = 'fanforc.gg'
27
+ $FF_PLUGIN_DOMAIN = 'ffplugin.gg'
28
+ $FF_WIDGET_DOMAIN = 'ffwidget.gg'
29
+ $FF_APP_DOMAIN = 'ffapp.gg'
30
+
31
+ $DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com'
32
+
33
+ $PUSHER_APP_ID = '23243'
34
+ $PUSHER_KEY = '7bcc87b3c55301f687b9'
35
+ $PUSHER_SECRET = '61c760c05430e68d7e8d'
36
+
37
+ elsif ENV['RACK_ENV'] == 'qa'
38
+ $BASE_DOMAIN = 'fanforce-qa.com'
39
+ $APP_DOMAIN = 'app.' + $BASE_DOMAIN
40
+ $API_DOMAIN = 'api.' + $BASE_DOMAIN
41
+ $I_DOMAIN = 'i.' + $BASE_DOMAIN
42
+ $WEBSITE_DOMAIN = $BASE_DOMAIN
43
+
44
+ $SMARTURL_DOMAIN = 'fanforc.us'
45
+ $FF_PLUGIN_DOMAIN = 'ffplugin.us'
46
+ $FF_APP_DOMAIN = 'ffapp.us'
47
+ $FF_WIDGET_DOMAIN = 'ffwidget.us'
48
+
49
+ $DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com'
50
+
51
+ $PUSHER_APP_ID = '14778'
52
+ $PUSHER_KEY = 'b5e2e23fb9542798ef38'
53
+ $PUSHER_SECRET = '7bfba2003df078ca64e9'
54
+
55
+ elsif ENV['RACK_ENV'] == 'production'
56
+ $BASE_DOMAIN = 'fanforce.com'
57
+ $APP_DOMAIN = 'app.' + $BASE_DOMAIN
58
+ $API_DOMAIN = 'api.' + $BASE_DOMAIN
59
+ $I_DOMAIN = 'i.' + $BASE_DOMAIN
60
+ $WEBSITE_DOMAIN = $BASE_DOMAIN
61
+
62
+ $SMARTURL_DOMAIN = 'fanforce.io'
63
+ $FF_PLUGIN_DOMAIN = 'ffplugin.io'
64
+ $FF_APP_DOMAIN = 'ffapp.io'
65
+ $FF_WIDGET_DOMAIN = 'ffwidget.io'
66
+
67
+ $DEVS_DOMAIN = 'technical%40mobilizationlabs.com:zE27fdevelopers@developers-fanforce.dotcloud.com'
68
+
69
+ $PUSHER_APP_ID = '14778'
70
+ $PUSHER_KEY = 'b5e2e23fb9542798ef38'
71
+ $PUSHER_SECRET = '7bfba2003df078ca64e9'
72
+ end
@@ -0,0 +1,14 @@
1
+ <?xml version='1.0' encoding='utf-8' ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ %html
4
+ %head
5
+ %title Fanforce
6
+ %meta{'http-equiv'=>'Content-Type', content:'text/html; charset=iso-8859-1'}/
7
+ %meta{'http-equiv'=>'Content-Language', content: 'en-us'}/
8
+ = stylesheet '/add_edit_initiative.css'
9
+
10
+ %body
11
+ = yield
12
+ = javascript '///' + $I_DOMAIN + '/devforce.js'
13
+ = javascript '/add_edit_initiative.js'
14
+ = yield_content :after_core_js
@@ -0,0 +1,14 @@
1
+ <?xml version='1.0' encoding='utf-8' ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ %html
4
+ %head
5
+ %title Fanforce
6
+ %meta{'http-equiv'=>'Content-Type', content:'text/html; charset=iso-8859-1'}/
7
+ %meta{'http-equiv'=>'Content-Language', content: 'en-us'}/
8
+ = stylesheet '/add_source.css'
9
+
10
+ %body
11
+ = yield
12
+ = javascript '///' + $I_DOMAIN + '/devforce.js'
13
+ = javascript '/add_source.js'
14
+ = yield_content :after_core_js
@@ -0,0 +1,27 @@
1
+ <?xml version='1.0' encoding='utf-8' ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ %html
4
+ %head
5
+ %title Fanforce
6
+ %meta{'http-equiv'=>'Content-Type', content:'text/html; charset=iso-8859-1'}/
7
+ %meta{'http-equiv'=>'Content-Language', content: 'en-us'}/
8
+ = stylesheet '/engage.css'
9
+ %body.layout-engage
10
+ .lyt-root
11
+ .lyt-header
12
+ #logo
13
+ = yield
14
+ .lyt-root-footer
15
+ .lyt-footer
16
+ %span#distributed-by
17
+ %a{href: "http://#{$BASE_DOMAIN}"} Powered by Fanforce.
18
+
19
+ = javascript "http://#{$I_DOMAIN}/#{params[:fanforce_slug]}-fanforce.js#{'?force_compile=1&env=development' if ENV['RACK_ENV']=='development'}"
20
+ = yield_content :after_fanforce_js
21
+ :coffeescript
22
+ if FF.account.website_url
23
+ $('#distributed-by').html('Distributed by <a href="' + FF.account.website_url + '">' + FF.account.name + '</a>.&nbsp;')
24
+ $('#logo').html('<a href="' + FF.account.website_url + '"><img class="logo" src="' + FF.account.logo_url + '"></a>') if FF.account.logo_url?
25
+ else
26
+ $('#distributed-by').html('Distributed by ' + FF.account.name + '.&nbsp;')
27
+ $('#logo').html('<img class="logo" src="' + FF.account.logo_url + '">') if FF.account.logo_url
@@ -0,0 +1,14 @@
1
+ <?xml version='1.0' encoding='utf-8' ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ %html
4
+ %head
5
+ %title Fanforce
6
+ %meta{'http-equiv'=>'Content-Type', content:'text/html; charset=iso-8859-1'}/
7
+ %meta{'http-equiv'=>'Content-Language', content: 'en-us'}/
8
+ = stylesheet '/new_message.css'
9
+
10
+ %body
11
+ = yield
12
+ = javascript "///#{$I_DOMAIN}/devforce.js?force_compile=#{ENV['RACK_ENV']=='development' ? 1 : 0}&env=#{ENV['RACK_ENV']}"
13
+ = javascript '/new_message.js'
14
+ = yield_content :after_core_js
@@ -0,0 +1,14 @@
1
+ <?xml version='1.0' encoding='utf-8' ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ %html
4
+ %head
5
+ %title Fanforce
6
+ %meta{'http-equiv'=>'Content-Type', content:'text/html; charset=iso-8859-1'}/
7
+ %meta{'http-equiv'=>'Content-Language', content: 'en-us'}/
8
+ = stylesheet '/promotional.css'
9
+
10
+ %body
11
+ = yield
12
+ = javascript '///' + $I_DOMAIN + '/devforce.js'
13
+ = javascript '/promotional.js'
14
+ = yield_content :after_core_js
@@ -0,0 +1,14 @@
1
+ <?xml version='1.0' encoding='utf-8' ?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ %html
4
+ %head
5
+ %title Fanforce
6
+ %meta{'http-equiv'=>'Content-Type', content:'text/html; charset=iso-8859-1'}/
7
+ %meta{'http-equiv'=>'Content-Language', content: 'en-us'}/
8
+ = stylesheet '/source_details.css'
9
+
10
+ %body
11
+ = yield
12
+ = javascript '///' + $I_DOMAIN + '/devforce.js'
13
+ = javascript '/source_details.js'
14
+ = yield_content :after_core_js
@@ -0,0 +1,35 @@
1
+ class FanforcePlugin::Sinatra
2
+
3
+ # INDEX ########################################################################
4
+ def route_index(params)
5
+ page :index, :layout => :promotional
6
+ end
7
+ ['/', '/index.html'].each do |path|
8
+ get path do route_index(params) end
9
+ end
10
+
11
+ # INSTALL ######################################################################
12
+ def route_install(params)
13
+ raise "This is not a valid plugin install request: #{env['HTTP_HOST']}" if !ff.valid_install_request?(params)
14
+ api_key = $Redis.get("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:fanforce_id]}")
15
+
16
+ #raise 'A different API key already exists for this addon. Please uninstall first.' if api_key.present? and ff.params[:api_key] != api_key
17
+ $Redis.set("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:fanforce_id]}", ff.params[:api_key])
18
+ ff.auth(ff.params[:api_key])
19
+
20
+ json status: 'installed', success: true
21
+ end
22
+ any '/install' do route_install(params) end
23
+
24
+ # UNINSTALL ####################################################################
25
+ def route_uninstall(params)
26
+ raise 'This is not a valid plugin uninstall request.' if !ff.valid_uninstall_request?(params)
27
+ api_key = $Redis.get("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:fanforce_id]}")
28
+
29
+ raise 'API keys must match before an addon can be uninstalled.' if api_key.present? and ff.params[:api_key] != api_key
30
+ $Redis.del("installed:#{ff.params[:addon_type]}-#{ff.params[:addon_id]}:#{ff.params[:fanforce_id]}")
31
+ json status: 'uninstalled', success: true
32
+ end
33
+ any '/uninstall' do route_uninstall(params) end
34
+
35
+ end
@@ -0,0 +1,28 @@
1
+ class FanforcePlugin::Sinatra
2
+
3
+ # ADD INITIATIVE UI ############################################################
4
+ def route_add_initiative(params)
5
+ page :add_initiative, :layout => :add_edit_initiative
6
+ end
7
+ get '/add_initiative.html' do route_add_initiative(params) end
8
+
9
+ # EDIT INITIATIVE UI ###########################################################
10
+ def route_edit_initiative(params)
11
+ page :edit_initiative, :layout => :add_edit_initiative
12
+ end
13
+ get '/edit_initiative.html' do route_edit_initiative(params) end
14
+
15
+ # WIDGET TMPLS #################################################################
16
+ def route_widget_tmpls(params)
17
+ content_type 'application/javascript'
18
+ page :widget_tmpls
19
+ end
20
+ get '/widget_tmpls' do route_widget_tmpls(params) end
21
+
22
+ # ENGAGE #######################################################################
23
+ def route_engage(params)
24
+ page :engage, :layout => :engage
25
+ end
26
+ get '/:fanforce_slug/:initiative_slug/engage.html' do route_engage(params) end
27
+
28
+ end
@@ -0,0 +1,9 @@
1
+ class FanforcePlugin::Sinatra
2
+
3
+ # NEW MESSAGE ##################################################################
4
+ def route_new_message(params)
5
+ page :new_message, :layout => :new_message
6
+ end
7
+ get '/new_message.html' do route_new_message(params) end
8
+
9
+ end
@@ -0,0 +1,21 @@
1
+ class FanforcePlugin::Sinatra
2
+
3
+ # ADD SOURCE ##################################################################
4
+ def route_add_source(params)
5
+ page :add_source, :layout => :add_source
6
+ end
7
+ get '/add_source.html' do route_add_source(params) end
8
+
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)
17
+ page :source_details, :layout => :source_details
18
+ end
19
+ get '/source_details.html' do route_source_details(params) end
20
+
21
+ end
@@ -0,0 +1,107 @@
1
+ require 'sprockets'
2
+ require 'sprockets-sass'
3
+ require 'sass'
4
+
5
+ class SprocketsCompiler
6
+ # This is pretty much copy/paste from https://github.com/stevehodgkiss/guard-sprockets2/blob/master/lib/guard/sprockets2/compiler.rb
7
+ # The only method added/changed is self.sprockets()
8
+
9
+ def initialize(options = {})
10
+ configure(options)
11
+ @target = Pathname.new(@assets_path)
12
+ end
13
+
14
+ def clean
15
+ FileUtils.rm_rf @assets_path, :secure => true
16
+ end
17
+
18
+ def compile
19
+ @sprockets.send(:expire_index!)
20
+ success = true
21
+ @precompile.each do |path|
22
+ @sprockets.each_logical_path do |logical_path|
23
+ next unless path_matches?(path, logical_path)
24
+
25
+ if asset = @sprockets.find_asset(logical_path)
26
+ success = compile_asset(asset, false)
27
+ success = compile_asset(asset, true) if @digest
28
+ break unless success
29
+ end
30
+ end
31
+ end
32
+ success
33
+ end
34
+
35
+ protected
36
+
37
+ def compile_asset(asset, digest)
38
+ filename = digest ? @target.join(asset.digest_path) : @target.join(asset.logical_path)
39
+ puts filename
40
+
41
+ FileUtils.mkdir_p filename.dirname
42
+ asset.write_to(filename)
43
+ asset.write_to("#{filename}.gz") if @gz && filename.to_s =~ /\.(css|js)$/
44
+ true
45
+ rescue => e
46
+ puts unless ENV['GUARD_ENV'] == 'test'
47
+ UI.error e.message.gsub(/^Error: /, '')
48
+ false
49
+ end
50
+
51
+ def path_matches?(path, logical_path)
52
+ if path.is_a?(Regexp)
53
+ path.match(logical_path)
54
+ else
55
+ File.fnmatch(path.to_s, logical_path)
56
+ end
57
+ end
58
+
59
+ def configure(options)
60
+ @sprockets = options[:sprockets]
61
+ @assets_path = options[:assets_path]
62
+ @precompile = options[:precompile]
63
+ @digest = options[:digest]
64
+ @gz = options[:gz]
65
+ set_defaults
66
+ end
67
+
68
+ def set_defaults
69
+ if defined?(Rails)
70
+ @sprockets ||= Rails.application.assets
71
+ @assets_path ||= File.join(Rails.public_path, Rails.application.config.assets.prefix)
72
+ @precompile ||= Rails.application.config.assets.precompile
73
+ else
74
+ @assets_path ||= "#{Dir.pwd}/public/assets"
75
+ @precompile ||= [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
76
+ end
77
+ @digest = true if @digest.nil?
78
+ @gz = true if @gz.nil?
79
+ end
80
+
81
+ def self.setup(base_dir)
82
+ sprockets = ::Sprockets::Environment.new(base_dir)
83
+
84
+ sprockets.append_path 'assets/img'
85
+ sprockets.append_path 'assets/js'
86
+ sprockets.append_path 'assets/css'
87
+ sprockets.append_path 'assets/lib'
88
+
89
+ default_assets_dir = File.dirname( File.expand_path( __FILE__ ) ) + '/..'
90
+ sprockets.append_path default_assets_dir + '/assets/img'
91
+ sprockets.append_path default_assets_dir + '/assets/js'
92
+ sprockets.append_path default_assets_dir + '/assets/css'
93
+ sprockets.append_path default_assets_dir + '/assets/lib'
94
+
95
+ sprockets.append_path "#{Gem.loaded_specs['compass'].full_gem_path}/frameworks/compass/stylesheets"
96
+
97
+ if ENV['RACK_ENV'] != 'development'
98
+ require 'yui/compressor'
99
+ require 'uglifier'
100
+ sprockets.css_compressor = YUI::CssCompressor.new
101
+ sprockets.js_compressor = Uglifier.new
102
+ end
103
+
104
+ return sprockets
105
+ end
106
+
107
+ end