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
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGI0MzkyNmQ5MDU4ZGM0MDMzNjg1ZjQzYmFkYzdmYTFiNGU4MDI3Yg==
5
+ data.tar.gz: !binary |-
6
+ YzJmMmVlYWM1OGQzYWZkM2NkMjZiN2RhNDI3MDRlZjY0ZDliODk2ZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZDJlYjQ3NTVmNjE1YWEyYjczNjVmOGM1OGVjYTA4MzA4N2IzNTkyMTM2NWEw
10
+ OGEzMzEzNGM3YzdlNDY4ZWVkYjg3NTM3N2NlYzBiM2IxYWE5NGM1YzUwMmE3
11
+ YTRiYzliZTZkODcyMGU1ZWRiODg1ZTBhMmM4MjI0NmIzYjhiNGQ=
12
+ data.tar.gz: !binary |-
13
+ YTZlZGJiYTc1ZjFlNjBmNGNhYTNkY2UzMGQzZTUyZDc5OTIyMmQ2NzhjYmNl
14
+ ZWQ3YzUyYWMxMzQwNDM3ZDY1MThjMzQ1Yzg2ZGYxODFjZTNjZjMxY2Q5Yzc4
15
+ ZTIzNGZhODY3YjFhYjY5OTA1MDY5MDBjNmMyYzgwOWRmNmQxYzI=
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+ .idea/
15
+ .DS_STORE
16
+ Gemfile.lock
17
+
18
+ # YARD artifacts
19
+ .yardoc
20
+ _yardoc
21
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,218 @@
1
+ fanforce-plugin-factory
2
+ ========
3
+ The fanforce-plugin-factory is a gem that makes it really easy to create new Fanforce Plugins using convention over configuration.
4
+
5
+ # Easy Setup
6
+ Only two files are required to setup a new project:
7
+ 1. Gemfile
8
+ 2. config.ru
9
+
10
+ ### /Gemfile
11
+ Since the fanforce-plugin-factory gem is hosted on a private gem server so you'll need to specify the source for both rubygems and the private server.
12
+
13
+ ```ruby
14
+ source 'https://rubygems.org'
15
+ source 'https://gems.gemfury.com/xF8KY9sm8eS9yUQqw1jD/'
16
+ ruby '1.9.3'
17
+
18
+ gem 'fanforce-plugin-factory'
19
+ ```
20
+ One you've created the Gemfile you'll need to run bundler install.
21
+
22
+ ### /config.ru
23
+ Only seven lines are required (in addition to having a Redis server).
24
+
25
+ ```ruby
26
+ require 'bundler'; Bundler.setup
27
+ require 'fanforce/plugin'
28
+ FanforcePlugin.config do |config|
29
+ config._id = 'watch-youtube'
30
+ config.type = :behavior # :data_connector, :data_processor, :broadcaster, :identifier, :behavior
31
+ end
32
+ run FanforcePlugin
33
+ ```
34
+ You can replace config._id (as in the example above) with an environment variable: ENV['FANFORCE_PLUGIN_ID']
35
+
36
+ ### Ready for the Fanforce Marketplace!
37
+ Your plugin can now be added to the Fanforce Marketplace. Use the follow config settings when adding your new plugin into Fanforce
38
+
39
+ ```ruby
40
+ "public_urls": {
41
+ "icon_16": "http://${PRIMARY_DOMAIN}/assets/icon-16.png",
42
+ "icon_32": "http://${PRIMARY_DOMAIN}/assets/icon-32.png",
43
+ "icon_42": "http://${PRIMARY_DOMAIN}/assets/icon-42.png"
44
+ },
45
+ "staffer_ui_urls": {
46
+ "add_initiative": "http://${PRIMARY_DOMAIN}/add_initiative.html",
47
+ "edit_initiative": "http://${PRIMARY_DOMAIN}/edit_initiative.html"
48
+ },
49
+ "callback_urls": {
50
+ "install": "http://${PRIMARY_DOMAIN}/install",
51
+ "uninstall": "http://${PRIMARY_DOMAIN}/uninstall"
52
+ },
53
+ "widget_dependencies": [
54
+ {
55
+ "widget-name-here": "http://${PRIMARY_DOMAIN}/widget_tmpls"
56
+ }
57
+ ]
58
+ ```
59
+ Note: for development and testing we recommend using the [POW server](http://pow.cx/), but you can use rackup or any other server to run your new plugin.
60
+
61
+ ====================
62
+
63
+ # Customizing/Building Your Plugin
64
+ There are lots of ways you can start building out and customizing your plugin...
65
+
66
+ ### /assets
67
+ Use the assets folder to store all your images, css, and javascript files. There are six asset files that are required. If any are missing, the fanforce-plugin-factory sends default versions when requested.
68
+
69
+ *Default Assets:*
70
+ * /css
71
+ * /add_edit_initiative.css - this is loaded from the add_edit_initiative.haml layout.
72
+ * /add_source.css - this is loaded from the add_source.haml layout.
73
+ * /engage.css - this is loaded from the engage.haml layout.
74
+ * /new_message.css - this is loaded from the new_message.haml layout.
75
+ * /source_details.css - this is loaded from the source_details.haml layout.
76
+ * /js
77
+ * /add_edit_initiative.js - this is loaded from the add_edit_initiative.haml layout.
78
+ * /add_source.js - this is loaded from the add_source.haml layout.
79
+ * /add_source_popup.js - this is loaded from the add_source_popup.haml layout.
80
+ * /engage.js - this is loaded from the engage.haml layout.
81
+ * /new_message.js - this is loaded from the new_message.haml layout.
82
+ * /source_details.js - this is loaded from the source_details.haml layout.
83
+ * /img
84
+ * /icon-16.png - this icon must be 16px by 16px.
85
+ * /icon-32.png - this icon must be 32px by 32px.
86
+ * /icon-42.png - this icon must be 42px by 42px.
87
+
88
+ ### /views
89
+ HAML is the default layout engine. The .haml extension is converted to .html when served in the browser.
90
+
91
+ *Default Views for Behavior Plugins:*
92
+ * /add_initiative.haml - used in the Command Center.
93
+ * /edit_initiative.haml - used in the Command Center.
94
+ * /engage.haml - used in the Command Center.
95
+
96
+ *Default Views for Broadcaster Plugins:*
97
+ * /new_message.haml - used in the Command Center.
98
+
99
+ ### /layouts
100
+ You can turn off layouts from be used (see Advanced Configuration)
101
+
102
+ *Default Layouts for Behavior Plugins:*
103
+ * /add_edit_initiative.haml - the wrapper layout for views/add_initiative.haml and views/edit_initiative.haml
104
+ * /engage.haml - the wrapper layout for views/engage.haml
105
+
106
+ *Default Layouts for Broadcaster Plugins:*
107
+ * /new_message.haml - the wrapper layout for views/new_message.haml
108
+
109
+ ### /public
110
+ Anything you put in here will be publicly available. The only folder you should not use is /assets, since it is used for precompiling assets (see below).
111
+
112
+ *Default Files:*
113
+ * /favicon.ico
114
+
115
+ ### /config/routes.rb
116
+ The fanforce-plugin-factory sets up all the required routes. If you want to customize existing routes or add new ones, create a routes.rb file in your home directory with a FanforcePlugin:Sinatra class:
117
+ ```
118
+ class FanforcePlugin::Sinatra
119
+ get '/test' do
120
+ "Custom route!"
121
+ end
122
+ end
123
+ ```
124
+ Check out [Sinatra's](http://www.sinatrarb.com/documentation) documentation for more details on routes and much more. The FanforcePlugin::Sinatra inherits from the Sinatra::Base, which gives you full control to customize the fanforce-plugin-factory's sinatra implementation as much as you want.
125
+
126
+ Overwrite any existing routes by specifying them in your routes.rb. You can also pull default route logic into your new custom routes by calling route_[NAME_OF_ROUTE] method.
127
+ ```
128
+ class FanforcePlugin::Sinatra
129
+ any '/install' do
130
+ # do whatever you want here
131
+ route_install
132
+ end
133
+ end
134
+ ```
135
+ *Default Routes:*
136
+ - route_index: get ['/','/index.html']
137
+ - route_install: post '/install'
138
+ - route_uninstall: post '/uninstall'
139
+
140
+ *Default Routes for Behavior Plugins:*
141
+ - route_add_initiative: get '/add_initiative.html'
142
+ - route_edit_initiative: get '/add_initiative.html'
143
+ - route_widget_tmpls: get '/widget_tmpls.html'
144
+ - route_engage: get '/:fanforce_slug/:initiative_slug/engage.html'
145
+
146
+ *Default Routes for Broadcaster Plugins:*
147
+ - route_new_message: get '/new_message.html'
148
+
149
+ *Default Routes for Data Connector Plugins:*
150
+ - route_add_source: get '/add_source.html'
151
+ - route_source_details: get '/source_details.html'
152
+
153
+ ### /config/initializer.rb
154
+ If you need to run Sinatra middleware or other non-route code, you'll want to create a config/initializer.rb file. This file is required before config/routes.rb. As an example, if you want to use the OmniAuth Facebook Strategy, you would include the following in config/initializer.rb:
155
+ ```
156
+ require 'omniauth'
157
+ require 'omniauth-constantcontact2'
158
+
159
+ class FanforcePlugin::Sinatra
160
+
161
+ use Rack::Session::Cookie
162
+ use OmniAuth::Builder do
163
+ provider :constantcontact, ENV['CONSTANTCONTACT_API_KEY'], ENV['CONSTANTCONTACT_API_SECRET']
164
+ end
165
+
166
+ end
167
+ ```
168
+
169
+ ### /lib/*
170
+ If you create a lib/ folder in your plugin's home directory, it will be automatically added to your plugin's ruby path. This allows you to require 'any_file' that has been put in this folder.
171
+
172
+ # Using Pages/Layouts In Controllers
173
+ Fanforce-plugin-factory adds a helper method on top of the Sinatra code base to load pages and layouts. It's called page:
174
+ ```
175
+ get '/custom.html' do
176
+ page :custom, :layout => :custom
177
+ end
178
+ ```
179
+ *Other Examples*
180
+ - :custom_page
181
+ - :custom_page, :layout => :false
182
+
183
+ # Rendering JSON, JSONP, and JSONR
184
+ Fanforce-plugin-factory adds a "json" method you use in your routes to convert the object to json and set the correct application/json header:
185
+ ```
186
+ get '/custom.html' do
187
+ json first_name: 'Caleb', last_name: 'Clark'
188
+ end
189
+ ```
190
+ If a callback param is sent in the request then your json is automatically converted to JSONR[http://github.com/calebclark/rack-jsonr] (JSON Resource).
191
+
192
+ # Asset Helpers
193
+ Fanforce-plugin-factory comes with a few asset helpers you can use in your haml pages:
194
+
195
+ - stylesheet(absolute_or_relative_path) - creates style tag
196
+ - javascript(absolute_or_relative_path) - creates script tag
197
+ - asset_path(absolute_or_relative_path) - prints path to asset
198
+
199
+ # Precompile Your Assets for Faster Delivery
200
+ Heroku tries to run `rake assets:precompile` when pushing new code changes. Fanforce-plugin-factory has this rake task built-in. To activate, just create a new Rakefile in your plugin directory with the following:
201
+ ```
202
+ require 'bundler'; Bundler.setup
203
+ require 'fanforce/plugin'
204
+ FanforcePlugin.config do |config|
205
+ config.type = :behavior # :data_connector, :data_processor, :broadcaster, :identifier, :behavior
206
+ end
207
+ load 'fanforce/plugin.rake'
208
+ ```
209
+
210
+ # Configure Redis
211
+ By default fanforce-plugin-factory looks for ENV['REDIS_URL'] and if that isn't found, it falls back to redis://localhost:6379. You can specify a custom redis url with `config.redis_url = ` in config.ru:
212
+ ```
213
+ FanforcePlugin.config do |config|
214
+ config.redis_url = 'redis://USERNAME:PASSWORD@HOST:PORT'
215
+ end
216
+ ```
217
+
218
+
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # Default Rake task is compile
7
+ #task :default => :compile
8
+
9
+ ########################################################################
10
+
11
+ Rake::TestTask.new do |t|
12
+ t.libs.push "lib"
13
+ t.libs.push "test"
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fanforce/plugin_factory/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'fanforce-plugin-factory'
8
+ gem.version = Fanforce::PluginFactory::VERSION
9
+ gem.date = '2012-10-19'
10
+ gem.summary = %q{Everything needed to setup a new plugin on Fanforce}
11
+ gem.authors = ['Caleb Clark']
12
+ gem.email = ['cclark@fanforce.com']
13
+ gem.homepage = 'http://github.com/mlabs/fanforce-plugin-factory'
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.add_development_dependency 'rake', '~> 0.8.7'
20
+ gem.add_runtime_dependency 'redis', '~> 3.0'
21
+ gem.add_runtime_dependency 'sinatra', '~> 1.3'
22
+ gem.add_runtime_dependency 'multi_json', '~> 1.3.6'
23
+ gem.add_runtime_dependency 'sinatra-contrib'
24
+ gem.add_runtime_dependency 'rack-contrib'
25
+ gem.add_runtime_dependency 'haml', '~> 4'
26
+ gem.add_runtime_dependency 'coffee-script'
27
+ gem.add_runtime_dependency 'activesupport', '~> 3.2'
28
+
29
+ gem.add_runtime_dependency 'sass', '~> 3.2'
30
+ gem.add_runtime_dependency 'compass', '~> 0.12'
31
+ gem.add_runtime_dependency 'sprockets', '~> 2.9'
32
+ gem.add_runtime_dependency 'sprockets-sass', '~> 0.9'
33
+ gem.add_runtime_dependency 'yui-compressor', '~> 0.9'
34
+ gem.add_runtime_dependency 'uglifier', '~> 1.3'
35
+
36
+ gem.add_runtime_dependency 'yui-compressor', '~> 0.9'
37
+ gem.add_runtime_dependency 'uglifier', '~> 1.3'
38
+
39
+ gem.add_runtime_dependency 'rack-jsonr', '~> 0.2'
40
+ gem.add_runtime_dependency 'fanforce-api', '~> 0.8'
41
+ gem.add_runtime_dependency 'fanforce-errors', '~> 0.2'
42
+ end
@@ -0,0 +1,71 @@
1
+ require 'fanforce'
2
+ require 'fileutils'
3
+ require 'json'
4
+ require 'yaml'
5
+ require_relative 'plugin_factory/sprockets/hacks'
6
+ require_relative 'plugin_factory/sprockets/compiler'
7
+
8
+ def load_env_from_file(file)
9
+ File.open(file, 'rb') do |file|
10
+ contents = file.read
11
+ lines = contents.gsub('export ', '').split(/\n\r?/).reject{|line| line.blank?}
12
+ lines.each do |line|
13
+ keyValue = line.split('=', 2)
14
+ next unless keyValue.count == 2
15
+ ENV[keyValue.first] = keyValue.last.gsub("'",'').gsub('"','')
16
+ end
17
+ end
18
+ end
19
+
20
+ if (!ENV['RACK_ENV'] or ENV['RACK_ENV'] == 'development')
21
+ load_env_from_file("#{FanforcePlugin.config.root_dir}/.powenv") if File.exists?("#{FanforcePlugin.config.root_dir}/.powenv")
22
+ load_env_from_file("#{FanforcePlugin.config.root_dir}/.pluginenv") if File.exists?("#{FanforcePlugin.config.root_dir}/.pluginenv")
23
+ end
24
+
25
+ FanforcePlugin.config.load_redis
26
+
27
+ namespace :assets do
28
+ root_dir = FanforcePlugin.config.root_dir
29
+ factory_root_dir = FanforcePlugin.config.factory_root_dir
30
+
31
+ desc 'Precompile assets for production'
32
+ task :precompile => :clean do
33
+ sprockets = SprocketsCompiler.setup(root_dir)
34
+
35
+ puts 'PRECOMPILING ASSETS... '
36
+ SprocketsCompiler.new(sprockets: sprockets, precompile: [/(\/|^)[^_\/]+[^\/]*\.(css|js|png|gif|jpeg|jpg|otf|eot|svg|ttf|woff)/]).compile
37
+ puts 'DONE'
38
+
39
+ print 'GENERATING ASSET MANIFESTS... '
40
+ asset_list = {}
41
+ sprockets.each_logical_path do |logical_path|
42
+ if File.basename(logical_path) !~ /^[_]/ and asset = sprockets.find_asset(logical_path)
43
+ asset_list[logical_path] = "/assets/#{asset.digest_path}"
44
+ end
45
+ end
46
+ IO.write File.join(root_dir, '/public/asset_manifest.json'), JSON.generate(asset_list)
47
+ IO.write File.join(root_dir, '/public/asset_manifest.json'), "ASSETS=#{JSON.generate(asset_list)}"
48
+ IO.write File.join(root_dir, '/public/asset_manifest.json'), asset_list.to_yaml
49
+ puts 'DONE'
50
+
51
+ print 'ENSURING FAVICON EXISTS... '
52
+ if !File.exists?(root_dir+'/public/favicon.ico')
53
+ puts ''
54
+ FileUtils.cp("#{factory_root_dir}/public/favicon.ico", "#{root_dir}/public/favicon.ico")
55
+ puts "#{root_dir}/public/favicon.ico"
56
+ end
57
+ puts 'DONE'
58
+ end
59
+
60
+ desc 'Clean assets folder'
61
+ task :clean do
62
+ print 'DESTROYING PUBLIC/ASSETS... '
63
+ FileUtils.rm_rf File.join(root_dir, '/public/assets')
64
+ puts 'DONE'
65
+ end
66
+
67
+ task :test do
68
+ puts 'TEST WORKED!'
69
+ end
70
+
71
+ end
@@ -0,0 +1,60 @@
1
+ ENV['RACK_ENV'] ||= 'development'
2
+ ####################################################################################
3
+ require 'fanforce'
4
+ require 'active_support/all'
5
+ require 'sinatra/base'
6
+ require 'fileutils'
7
+ require 'redis'
8
+
9
+ if ENV['RACK_ENV'] == 'development'
10
+ require_relative 'plugin_factory/sprockets/hacks'
11
+ require_relative 'plugin_factory/sprockets/compiler'
12
+ end
13
+
14
+ caller[0].split(':')[0] =~ /^(.+(config\.ru|Rakefile))$/ ? ROOT_DIR = File.dirname($1) : nil
15
+
16
+ module FanforcePlugin
17
+
18
+ def self.config(&block)
19
+ config = @@config ||= FanforcePlugin::SinatraConfig.new(ROOT_DIR)
20
+ if block.present?
21
+ block.call(config)
22
+ config.root_dir = File.dirname($1) if !config.root_dir and caller[0].split(':')[0] =~ /^(.+(config\.ru|Rakefile))$/
23
+ end
24
+ config
25
+ end
26
+
27
+ def self.root
28
+ config.root_dir
29
+ end
30
+
31
+ def self.dir_name
32
+ config.dir_name
33
+ end
34
+
35
+ def self._id
36
+ config._id
37
+ end
38
+
39
+ def self.type
40
+ config.type
41
+ end
42
+
43
+ def self.load_config
44
+ config.load
45
+ end
46
+
47
+ def self.call(env)
48
+ if ENV['RACK_ENV'] == 'development' and env['PATH_INFO'] =~ /^\/assets\//
49
+ env['PATH_INFO'] = env['PATH_INFO'].gsub(/^\/assets/, '')
50
+ sprockets = SprocketsCompiler.setup(FanforcePlugin.config.root_dir)
51
+ return sprockets.index.call(env)
52
+ end
53
+ require_relative 'plugin_factory/_init_sinatra'
54
+ FanforcePlugin::Sinatra.new.call(env)
55
+ end
56
+
57
+ require_relative 'plugin_factory/config/sinatra_config'
58
+ require_relative 'plugin_factory/initializers/ff_globals'
59
+ end
60
+