kilt-cms 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. checksums.yaml +7 -0
  2. data/README.rdoc +28 -0
  3. data/Rakefile +7 -0
  4. data/app/assets/images/kilt/animated-overlay.gif +0 -0
  5. data/app/assets/images/kilt/ui-bg_flat_0_000_40x100.png +0 -0
  6. data/app/assets/images/kilt/ui-bg_flat_0_fff_40x100.png +0 -0
  7. data/app/assets/images/kilt/ui-bg_flat_100_fff_40x100.png +0 -0
  8. data/app/assets/images/kilt/ui-bg_flat_100_ffffff_40x100.png +0 -0
  9. data/app/assets/images/kilt/ui-bg_glass_100_fff_1x400.png +0 -0
  10. data/app/assets/images/kilt/ui-bg_glass_100_ffffff_1x400.png +0 -0
  11. data/app/assets/images/kilt/ui-bg_highlight-soft_100_fff_1x100.png +0 -0
  12. data/app/assets/images/kilt/ui-icons_404040_256x240.png +0 -0
  13. data/app/assets/images/kilt/ui-icons_e74c3c_256x240.png +0 -0
  14. data/app/assets/javascripts/kilt/application.js +17 -0
  15. data/app/assets/javascripts/kilt/kilt.js +39 -0
  16. data/app/assets/stylesheets/kilt/application.scss +1 -0
  17. data/app/assets/stylesheets/kilt/config.rb +10 -0
  18. data/app/assets/stylesheets/kilt/sass/_base.scss +25 -0
  19. data/app/assets/stylesheets/kilt/sass/_buttons.scss +58 -0
  20. data/app/assets/stylesheets/kilt/sass/_form.scss +73 -0
  21. data/app/assets/stylesheets/kilt/sass/_layout.scss +85 -0
  22. data/app/assets/stylesheets/kilt/sass/_mixins.scss +6 -0
  23. data/app/assets/stylesheets/kilt/sass/_tables.scss +65 -0
  24. data/app/assets/stylesheets/kilt/sass/_typography.scss +79 -0
  25. data/app/assets/stylesheets/kilt/sass/modules/_codemirror.scss +262 -0
  26. data/app/assets/stylesheets/kilt/sass/modules/_jquery_ui.scss +659 -0
  27. data/app/assets/stylesheets/kilt/sass/screen.scss +1 -0
  28. data/app/assets/stylesheets/kilt/stylesheets/modules/codemirror.css +1 -0
  29. data/app/assets/stylesheets/kilt/stylesheets/modules/jquery-ui.css +5 -0
  30. data/app/assets/stylesheets/kilt/stylesheets/print.css +0 -0
  31. data/app/assets/stylesheets/kilt/stylesheets/screen.css +5 -0
  32. data/app/controllers/kilt/kilt_controller.rb +122 -0
  33. data/app/views/kilt/form/_default.html.erb +4 -0
  34. data/app/views/kilt/form/boolean.html.erb +4 -0
  35. data/app/views/kilt/form/datetime.html.erb +4 -0
  36. data/app/views/kilt/form/file.html.erb +59 -0
  37. data/app/views/kilt/form/html.html.erb +4 -0
  38. data/app/views/kilt/form/image.html.erb +72 -0
  39. data/app/views/kilt/form/longtext.html.erb +4 -0
  40. data/app/views/kilt/form/number.html.erb +23 -0
  41. data/app/views/kilt/form/text.html.erb +4 -0
  42. data/app/views/kilt/form/vimeo.html.erb +100 -0
  43. data/app/views/kilt/form/youtube.html.erb +98 -0
  44. data/app/views/kilt/kilt/_form.html.erb +30 -0
  45. data/app/views/kilt/kilt/edit.html.erb +2 -0
  46. data/app/views/kilt/kilt/index.html.erb +9 -0
  47. data/app/views/kilt/kilt/list.html.erb +67 -0
  48. data/app/views/kilt/kilt/new.html.erb +2 -0
  49. data/app/views/layouts/kilt/cms.html.erb +41 -0
  50. data/config/routes.rb +13 -0
  51. data/lib/generators/kilt/backend_generator.rb +19 -0
  52. data/lib/generators/kilt/frontend_generator.rb +33 -0
  53. data/lib/generators/kilt/install_generator.rb +13 -0
  54. data/lib/generators/kilt/object_generator.rb +23 -0
  55. data/lib/generators/kilt/templates/backend/config.yml.erb +16 -0
  56. data/lib/generators/kilt/templates/backend/creds.yml.example +8 -0
  57. data/lib/generators/kilt/templates/backend/kilt.rb +11 -0
  58. data/lib/generators/kilt/templates/frontend/application.html.erb +24 -0
  59. data/lib/generators/kilt/templates/frontend/assets/images/sprite/empty +0 -0
  60. data/lib/generators/kilt/templates/frontend/assets/images/sprite/retina/empty +0 -0
  61. data/lib/generators/kilt/templates/frontend/assets/javascripts/application.js +14 -0
  62. data/lib/generators/kilt/templates/frontend/assets/javascripts/html5shiv.js +2 -0
  63. data/lib/generators/kilt/templates/frontend/assets/javascripts/mediaqueries.js +1 -0
  64. data/lib/generators/kilt/templates/frontend/assets/stylesheets/config.rb +24 -0
  65. data/lib/generators/kilt/templates/frontend/assets/stylesheets/sass/modules/_mixins.scss +81 -0
  66. data/lib/generators/kilt/templates/frontend/assets/stylesheets/sass/modules/_reset_custom.scss +31 -0
  67. data/lib/generators/kilt/templates/frontend/assets/stylesheets/sass/modules/_typography.scss +35 -0
  68. data/lib/generators/kilt/templates/frontend/assets/stylesheets/sass/screen.scss +13 -0
  69. data/lib/generators/kilt/templates/frontend/assets/stylesheets/sass/views/_layout.scss +7 -0
  70. data/lib/generators/kilt/templates/frontend/assets/stylesheets/stylesheets/screen.css +160 -0
  71. data/lib/generators/kilt/templates/frontend/dummy.js.erb +11 -0
  72. data/lib/generators/kilt/templates/frontend/home_controller.rb.erb +4 -0
  73. data/lib/generators/kilt/templates/frontend/index.html.erb +5 -0
  74. data/lib/kilt/base.rb +12 -0
  75. data/lib/kilt/engine.rb +17 -0
  76. data/lib/kilt/exceptions.rb +10 -0
  77. data/lib/kilt/form.rb +28 -0
  78. data/lib/kilt/object.rb +66 -0
  79. data/lib/kilt/object_collection.rb +52 -0
  80. data/lib/kilt/upload.rb +54 -0
  81. data/lib/kilt/utils.rb +166 -0
  82. data/lib/kilt.rb +125 -0
  83. data/lib/tasks/kilt_tasks.rake +6 -0
  84. data/test/dummy/Rakefile +6 -0
  85. data/test/dummy/app/assets/images/sprite/empty +0 -0
  86. data/test/dummy/app/assets/images/sprite/retina/empty +0 -0
  87. data/test/dummy/app/assets/javascripts/application.js +14 -0
  88. data/test/dummy/app/assets/javascripts/dummy.js +11 -0
  89. data/test/dummy/app/assets/javascripts/html5shiv.js +2 -0
  90. data/test/dummy/app/assets/javascripts/mediaqueries.js +1 -0
  91. data/test/dummy/app/assets/stylesheets/config.rb +24 -0
  92. data/test/dummy/app/assets/stylesheets/sass/modules/_mixins.scss +81 -0
  93. data/test/dummy/app/assets/stylesheets/sass/modules/_reset_custom.scss +31 -0
  94. data/test/dummy/app/assets/stylesheets/sass/modules/_typography.scss +35 -0
  95. data/test/dummy/app/assets/stylesheets/sass/screen.scss +13 -0
  96. data/test/dummy/app/assets/stylesheets/sass/views/_layout.scss +7 -0
  97. data/test/dummy/app/assets/stylesheets/stylesheets/screen.css +160 -0
  98. data/test/dummy/app/controllers/application_controller.rb +5 -0
  99. data/test/dummy/app/controllers/dummy_controller.rb +4 -0
  100. data/test/dummy/app/views/dummy/index.html.erb +5 -0
  101. data/test/dummy/app/views/layouts/application.html.erb +24 -0
  102. data/test/dummy/bin/bundle +3 -0
  103. data/test/dummy/bin/rails +4 -0
  104. data/test/dummy/bin/rake +4 -0
  105. data/test/dummy/config/application.rb +27 -0
  106. data/test/dummy/config/boot.rb +5 -0
  107. data/test/dummy/config/environment.rb +5 -0
  108. data/test/dummy/config/environments/development.rb +23 -0
  109. data/test/dummy/config/environments/test.rb +23 -0
  110. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  111. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  112. data/test/dummy/config/initializers/inflections.rb +16 -0
  113. data/test/dummy/config/initializers/kilt.rb +14 -0
  114. data/test/dummy/config/initializers/mime_types.rb +5 -0
  115. data/test/dummy/config/initializers/secret_token.rb +12 -0
  116. data/test/dummy/config/initializers/session_store.rb +3 -0
  117. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  118. data/test/dummy/config/kilt/config.yml +40 -0
  119. data/test/dummy/config/kilt/creds.yml +8 -0
  120. data/test/dummy/config/routes.rb +7 -0
  121. data/test/dummy/config.ru +4 -0
  122. data/test/dummy/log/development.log +68163 -0
  123. data/test/dummy/log/test.log +36 -0
  124. data/test/dummy/public/favicon.ico +0 -0
  125. data/test/dummy/public/uploads/file/Gemfile +3 -0
  126. data/test/dummy/public/uploads/file/Gemfile.lock +139 -0
  127. data/test/dummy/public/uploads/file/README.rdoc +28 -0
  128. data/test/dummy/public/uploads/file/Rakefile +6 -0
  129. data/test/dummy/public/uploads/file/barcelona.jpg +0 -0
  130. data/test/dummy/public/uploads/file/dodgerstadiumpix.jpg +0 -0
  131. data/test/dummy/public/uploads/file/field.jpg +0 -0
  132. data/test/dummy/public/uploads/file/fob-elton-john-08.jpg +0 -0
  133. data/test/dummy/public/uploads/file/kilt.gemspec +32 -0
  134. data/test/dummy/public/uploads/file/kilt.rb +100 -0
  135. data/test/dummy/public/uploads/image/2960116125_1158ba3c59_o.jpg +0 -0
  136. data/test/dummy/public/uploads/image/JT.jpg +0 -0
  137. data/test/dummy/public/uploads/image/barcelona.jpg +0 -0
  138. data/test/dummy/public/uploads/image/dodgerstadiumpix.jpg +0 -0
  139. data/test/dummy/public/uploads/image/field.jpg +0 -0
  140. data/test/dummy/spec/kilt_spec.rb +31 -0
  141. data/test/dummy/spec/spec_helper.rb +12 -0
  142. data/test/dummy/tmp/cache/assets/development/sprockets/03cdc43618f8bef3dfc725a1886c40ed +0 -0
  143. data/test/dummy/tmp/cache/assets/development/sprockets/0d8e5c7178ebdb79e5b9cc4ef439eae8 +0 -0
  144. data/test/dummy/tmp/cache/assets/development/sprockets/13a3d23d13c1459a86283c4fe577a775 +0 -0
  145. data/test/dummy/tmp/cache/assets/development/sprockets/18837248cb3274df9b7c6b0a5dcd56a5 +0 -0
  146. data/test/dummy/tmp/cache/assets/development/sprockets/1c198a7e1d4ae808a6adf4c4809061eb +0 -0
  147. data/test/dummy/tmp/cache/assets/development/sprockets/2e57def2c82ce30227eefea2360d5f50 +0 -0
  148. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  149. data/test/dummy/tmp/cache/assets/development/sprockets/36f9a7f6f43adb582ac6eec43b58eb30 +0 -0
  150. data/test/dummy/tmp/cache/assets/development/sprockets/36fff19076c588427464432f563a8d2d +0 -0
  151. data/test/dummy/tmp/cache/assets/development/sprockets/3878e0f19bbd21176b1bcc46160a3df3 +0 -0
  152. data/test/dummy/tmp/cache/assets/development/sprockets/3cee919b5b764629fbb01de361ad1b99 +0 -0
  153. data/test/dummy/tmp/cache/assets/development/sprockets/3d69f4783ceef2f5455635de03e6c62a +0 -0
  154. data/test/dummy/tmp/cache/assets/development/sprockets/3d8ca1585ee95c5efb388645d66cf377 +0 -0
  155. data/test/dummy/tmp/cache/assets/development/sprockets/3e0acde4cdc501f590a21ede6fac0b97 +0 -0
  156. data/test/dummy/tmp/cache/assets/development/sprockets/413be9c73d25c7febe933f4619da7cf8 +0 -0
  157. data/test/dummy/tmp/cache/assets/development/sprockets/4b5c4a1edd3823a6a6c39e06b6eb230a +0 -0
  158. data/test/dummy/tmp/cache/assets/development/sprockets/4c5736bf0bd429296d1a32930364897e +0 -0
  159. data/test/dummy/tmp/cache/assets/development/sprockets/542fc810f9cd36e7bed9a3e5e9670995 +0 -0
  160. data/test/dummy/tmp/cache/assets/development/sprockets/56f1e7d57d31bf3315e1e33732d57faa +0 -0
  161. data/test/dummy/tmp/cache/assets/development/sprockets/5bea4c2d87ec725262213ed51575b485 +0 -0
  162. data/test/dummy/tmp/cache/assets/development/sprockets/5eb5178b706a9b8bd0362b7ed487339a +0 -0
  163. data/test/dummy/tmp/cache/assets/development/sprockets/5fa6492da1cba5232b9e9799b5e2bf8f +0 -0
  164. data/test/dummy/tmp/cache/assets/development/sprockets/5fe3d26a30497da82978c9f7ee53068b +0 -0
  165. data/test/dummy/tmp/cache/assets/development/sprockets/66f697b8e4167ad9ebefbd8b5fc65b23 +0 -0
  166. data/test/dummy/tmp/cache/assets/development/sprockets/6b6e86e81f5e8f80bb2b3d1e8f7ed7f3 +0 -0
  167. data/test/dummy/tmp/cache/assets/development/sprockets/6caab0d3b759107ab41492546763aaf0 +0 -0
  168. data/test/dummy/tmp/cache/assets/development/sprockets/6d83c6efd2bf1080ba1dead9fcfdd0db +0 -0
  169. data/test/dummy/tmp/cache/assets/development/sprockets/70d4b3b9e59d0e01e90eebf94dbc2c47 +0 -0
  170. data/test/dummy/tmp/cache/assets/development/sprockets/8127282074e6ffd457b72c228a69f0c0 +0 -0
  171. data/test/dummy/tmp/cache/assets/development/sprockets/8ffacb4ba6e6ca3da12ac1100f664b30 +0 -0
  172. data/test/dummy/tmp/cache/assets/development/sprockets/9dd98bca318fb820a8451cafce020588 +0 -0
  173. data/test/dummy/tmp/cache/assets/development/sprockets/b259805c84c81064f20700498328f109 +0 -0
  174. data/test/dummy/tmp/cache/assets/development/sprockets/b7e1f059a53a1e79df01a336fb1f50f0 +0 -0
  175. data/test/dummy/tmp/cache/assets/development/sprockets/c0671678b70011547b80da0669d031cc +0 -0
  176. data/test/dummy/tmp/cache/assets/development/sprockets/c1006115f345f87cc152b851154e9e34 +0 -0
  177. data/test/dummy/tmp/cache/assets/development/sprockets/cf0d5ad037fbf541c6b982abf73b9938 +0 -0
  178. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  179. data/test/dummy/tmp/cache/assets/development/sprockets/da31523b2e8cf32dd8db9f304d5b7395 +0 -0
  180. data/test/dummy/tmp/cache/assets/development/sprockets/dc676330961fd22be77c48cb77ec065f +0 -0
  181. data/test/dummy/tmp/cache/assets/development/sprockets/ddc29f2c13cd99d017fd526b61dcb951 +0 -0
  182. data/test/dummy/tmp/cache/assets/development/sprockets/de45247cb814cafe20e9e46c79e470fe +0 -0
  183. data/test/dummy/tmp/cache/assets/development/sprockets/e22d705d0c889ec4837f183a9beec0f3 +0 -0
  184. data/test/dummy/tmp/cache/assets/development/sprockets/e7ba95a61b1b9381906a88610dceb6dd +0 -0
  185. data/test/dummy/tmp/cache/assets/development/sprockets/ef7c8ce46dfc9e9087ce84dbdfdd0011 +0 -0
  186. data/test/dummy/tmp/cache/assets/development/sprockets/f3e1a8ba304f70dccefd77356c900ebc +0 -0
  187. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  188. data/test/dummy/tmp/data/meta_request/2ff92b3b-2e2c-438e-a687-d2900c8722e3.json +1 -0
  189. data/test/dummy/tmp/data/meta_request/4a2f197b-3f28-4ade-962e-0337d56878b1.json +1 -0
  190. data/test/dummy/tmp/data/meta_request/7eb04de5-6edf-4ea2-a4cf-994e6173b529.json +1 -0
  191. data/test/dummy/tmp/data/meta_request/96ec6abc-1da4-45e1-a397-79e849741501.json +1 -0
  192. data/test/dummy/tmp/data/meta_request/a9566f73-bde1-4346-b254-011381243ddc.json +1 -0
  193. data/test/dummy/tmp/data/meta_request/a9eb2875-930e-49ed-ab2f-40aba11bb132.json +1 -0
  194. data/test/dummy/tmp/data/meta_request/bcd27bed-9cac-4c32-8030-2699415e91a1.json +1 -0
  195. data/test/dummy/tmp/data/meta_request/e6152727-3e54-4858-ad8f-6e57e247a8a5.json +1 -0
  196. data/test/dummy/tmp/data/meta_request/e7db6149-e316-4ad1-a3a8-c014d0e7092b.json +1 -0
  197. data/test/dummy/tmp/data/meta_request/fc793f84-b287-4459-b902-705b1d2b1141.json +1 -0
  198. metadata +536 -0
@@ -0,0 +1,54 @@
1
+ module Kilt
2
+ class Upload
3
+
4
+ def self.file(file_reference)
5
+ self.do('file', file_reference)
6
+ end
7
+
8
+ def self.image(file_reference)
9
+ self.do('image', file_reference)
10
+ end
11
+
12
+ def self.do(type, file_reference)
13
+ if Kilt.config.storage.strategy == 'local'
14
+ self.handle_local_upload(type, file_reference)
15
+ elsif Kilt.config.storage.strategy == 's3'
16
+ self.handle_s3_upload(type, file_reference)
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def self.handle_local_upload(type, file_reference)
23
+ Kilt::Utils.ensure_local_storage_dir_exists
24
+ if file_reference
25
+ File.open(Rails.root.join('public', 'uploads', type, file_reference.original_filename), 'wb') do |file|
26
+ file.write(file_reference.read)
27
+ end
28
+ file_reference.original_filename
29
+ else
30
+ ''
31
+ end
32
+ end
33
+
34
+ def self.handle_s3_upload(type, file_reference)
35
+ Kilt::Utils.ensure_s3_bucket_exists
36
+ if file_reference
37
+ begin
38
+ s3 = AWS::S3.new(
39
+ :access_key_id => Kilt.config.s3.key,
40
+ :secret_access_key => Kilt.config.s3.secret)
41
+ bucket = s3.buckets[Kilt.config.s3.bucket]
42
+ new_file = bucket.objects["#{type}/#{file_reference.original_filename}"]
43
+ new_file.write(Pathname.new(file_reference.tempfile), :acl => :public_read)
44
+ file_reference.original_filename
45
+ rescue
46
+ ''
47
+ end
48
+ else
49
+ ''
50
+ end
51
+ end
52
+
53
+ end
54
+ end
data/lib/kilt/utils.rb ADDED
@@ -0,0 +1,166 @@
1
+ module Kilt
2
+ class Utils
3
+
4
+ # Set up the database
5
+ def self.setup_db
6
+ if Kilt.config.db.host && Kilt.config.db.port
7
+ begin
8
+ db = r.connect(:host => Kilt.config.db.host, :port => Kilt.config.db.port).repl
9
+ rescue
10
+ raise Kilt::CantConnectToDatabaseError
11
+ end
12
+
13
+ begin
14
+
15
+ # See if the db exists and create it otherwise
16
+ dbs = r.db_list.run
17
+ if !dbs.to_a.include? Kilt.config.db.db
18
+ r.db_create(Kilt.config.db.db).run
19
+ end
20
+
21
+ # See if the table exists and create it otherwise
22
+ tables = r.db(Kilt.config.db.db).table_list.run
23
+ if !tables.to_a.include? "objects"
24
+ r.db(Kilt.config.db.db).table_create("objects", :primary_key => "unique_id").run
25
+ end
26
+
27
+ rescue
28
+ raise Kilt::CantSetupDatabaseError
29
+ ensure
30
+ db.close
31
+ end
32
+
33
+ else
34
+ raise Kilt::NoDatabaseConfigError
35
+ end
36
+ end
37
+
38
+ # Make a db call
39
+ def self.db(&block)
40
+ db = r.connect(:host => Kilt.config.db.host, :port => Kilt.config.db.port).repl
41
+ results = block.call()
42
+ db.close
43
+ results
44
+ end
45
+
46
+ # Ensure we have local storage dirs
47
+ def self.ensure_local_storage_dir_exists
48
+ Dir.mkdir(Rails.root.join('public', 'uploads')) unless File.exists?(Rails.root.join('public', 'uploads'))
49
+ Dir.mkdir(Rails.root.join('public', 'uploads', 'file')) unless File.exists?(Rails.root.join('public', 'uploads', 'file'))
50
+ Dir.mkdir(Rails.root.join('public', 'uploads', 'image')) unless File.exists?(Rails.root.join('public', 'uploads', 'image'))
51
+ end
52
+
53
+ # Ensure we have an s3 bucket
54
+ def self.ensure_s3_bucket_exists
55
+ s3 = AWS::S3.new(
56
+ :access_key_id => Kilt.config.s3.key,
57
+ :secret_access_key => Kilt.config.s3.secret)
58
+ puts s3
59
+ bucket = s3.buckets[Kilt.config.s3.bucket]
60
+ if !bucket.exists?
61
+ bucket = s3.buckets.create(Kilt.config.s3.bucket, :acl => :public_read)
62
+ end
63
+ end
64
+
65
+ # Get a file download URL
66
+ def self.download_location(type, value)
67
+ if Kilt.config.storage.strategy == 'local'
68
+ "/uploads/#{type.to_s}/#{value.to_s}"
69
+ elsif Kilt.config.storage.strategy == 's3'
70
+ "http://#{Kilt.config.s3.bucket}.s3.amazonaws.com/#{type.to_s}/#{value.to_s}"
71
+ end
72
+ end
73
+
74
+ # Determine if the string passed in is singular or not
75
+ def self.is_singular?(str)
76
+ str.pluralize != str && str.singularize == str
77
+ end
78
+
79
+ # Create a slug
80
+ def self.slugify(str)
81
+ #strip the string
82
+ ret = str.strip
83
+
84
+ #blow away apostrophes
85
+ ret.gsub! /['`]/,""
86
+
87
+ # @ --> at, and & --> and
88
+ ret.gsub! /\s*@\s*/, " at "
89
+ ret.gsub! /\s*&\s*/, " and "
90
+
91
+ #replace all non alphanumeric, underscore or periods with dash
92
+ ret.gsub! /\s*[^A-Za-z0-9\.\_]\s*/, '-'
93
+
94
+ #convert double dash to single
95
+ ret.gsub! /-+/, "-"
96
+
97
+ #strip off leading/trailing dash
98
+ ret.gsub! /\A[-\.]+|[-\.]+\z/, ""
99
+
100
+ #return a downcase string
101
+ ret.downcase
102
+ end
103
+
104
+ # Break down a slug
105
+ def self.deslugify(str)
106
+ ret = str.to_s
107
+ ret.gsub! /_/, " "
108
+ ret.capitalize
109
+ end
110
+
111
+ # Print a list of objects, functions, etc.
112
+ def self.tips
113
+ lines = []
114
+ if !Kilt.config.empty? && Kilt.config.db
115
+ lines << ''
116
+
117
+ # Store the first type so we can use it down below
118
+ first_type = nil
119
+ Kilt.types.each do |type|
120
+
121
+ if !first_type
122
+ first_type = type
123
+ end
124
+
125
+ lines << "#{type.capitalize}: "
126
+ lines << " Kilt.#{type} -> Type definition"
127
+ lines << " Kilt.#{type}.fields -> List of fields"
128
+ lines << " Kilt.#{type.pluralize} -> Array of all #{type.capitalize} objects in natural order"
129
+ lines << " Kilt.#{type.pluralize}.order -> Array of all #{type.capitalize} objects ordered by 'name' field"
130
+ lines << " Kilt.#{type.pluralize}.order('age') -> Array of all #{type.capitalize} objects ordered by 'age' field"
131
+ lines << " Kilt.#{type.pluralize}.order('age').group('section') -> Array of all #{type.capitalize} objects ordered by 'age' field, then grouped by the 'section' field"
132
+ end
133
+ lines << ''
134
+ lines << 'Get object:'
135
+ lines << ' Kilt.get(\'some-slug\')'
136
+ lines << ''
137
+ lines << 'Loop through objects:'
138
+ lines << " Kilt.#{first_type.pluralize}.each do |#{first_type}|"
139
+ lines << " puts #{first_type}['name']"
140
+ lines << ' end'
141
+ lines << ''
142
+ lines << 'Loop through objects ordered by field \'age\':'
143
+ lines << " Kilt.#{first_type.pluralize}.order('age').each do |#{first_type}|"
144
+ lines << " puts #{first_type}['name']"
145
+ lines << ' end'
146
+ lines << ''
147
+ lines << 'Loop through objects ordered by field \'name\' (the default), then grouped by field \'section\':'
148
+ lines << " Kilt.#{first_type.pluralize}.order.group(\'section\').each do |section, #{first_type.downcase.pluralize}|"
149
+ lines << ' puts section'
150
+ lines << " #{first_type.downcase.pluralize}.each do |#{first_type.downcase}|"
151
+ lines << " puts #{first_type.downcase}['name']"
152
+ lines << " end"
153
+ lines << ' end'
154
+ else
155
+ lines << 'The Kilt gem has been installed, but you haven\'t configured it yet.'
156
+ lines << 'Start configuring Kilt by running the following command:'
157
+ lines << ''
158
+ lines << ' rails g kilt:backend'
159
+ lines << ''
160
+ lines << 'Then open config/kilt/config.yml and config/kilt/creds.yml, add your database information, define your data model, start Rails, and visit http://&lt;your_app&gt;/admin'
161
+ end
162
+ lines.join("\n")
163
+ end
164
+
165
+ end
166
+ end
data/lib/kilt.rb ADDED
@@ -0,0 +1,125 @@
1
+ require "kilt/base"
2
+
3
+ # Include the Rethink shortcut module, which will among other things instantiate a new
4
+ # Rethink object (as "r") if needed
5
+ include RethinkDB::Shortcuts
6
+
7
+ module Kilt
8
+
9
+ # Hold the config object
10
+ mattr_accessor :config
11
+
12
+ # Auto-generated endpoints
13
+ def self.method_missing(method, *args)
14
+ begin
15
+
16
+ if Utils.is_singular? method.to_s
17
+ # Get the configuration for a type
18
+ # Example: Kilt.event
19
+ Kilt.config.objects[method]
20
+ else
21
+ # Get a list of objects
22
+ # Example: Kilt.events
23
+ Kilt.get_collection method.to_s
24
+ end
25
+ end
26
+ end
27
+
28
+ # Get the list of types
29
+ # Returns: array of type names
30
+ # Example: Kilt.types
31
+ def self.types
32
+ Kilt.config.objects.map { |key, value| key.to_s }
33
+ end
34
+
35
+
36
+ # Create an object
37
+ # Returns: boolean
38
+ # Example: Kilt.create(object)
39
+ def self.create(object)
40
+ object['created_at'] = object['updated_at'] = Time.now
41
+ object['unique_id'] = "#{(Time.now.to_f * 1000).to_i}"
42
+ result = Utils.db do
43
+
44
+ # Check for slug uniqueness
45
+ results = r.db(Kilt.config.db.db).table('objects').filter({'slug' => "#{object['slug'].to_s}"}).run
46
+ if results.to_a.length > 0
47
+ object['slug'] = "#{object['slug']}-#{(Time.now.to_f * 1000).to_i}"
48
+ end
49
+
50
+ # Insert the record
51
+ r.db(Kilt.config.db.db).table('objects').insert(object.values).run
52
+
53
+ end
54
+ (result['errors'] == 0)
55
+ end
56
+
57
+ # Update an object
58
+ # Returns: boolean
59
+ # Example: Kilt.update(object)
60
+ def self.update(slug, object)
61
+ object['updated_at'] = Time.now
62
+ result = Utils.db do
63
+
64
+ # Keep the original slug handy
65
+ results = r.db(Kilt.config.db.db).table('objects').filter({'slug' => "#{slug}"}).limit(1).run
66
+ original = results.to_a.first['unique_id']
67
+
68
+ # Check for slug uniqueness
69
+ results = r.db(Kilt.config.db.db).table('objects').filter({'slug' => "#{object['slug']}"}).run
70
+ if results
71
+ result = results.to_a.first
72
+ if result && result['unique_id'] != original
73
+ object['slug'] = "#{Kilt::Utils.slugify(object['name'])}-#{(Time.now.to_f * 1000).to_i}"
74
+ end
75
+ end
76
+
77
+ # Update the record
78
+ r.db(Kilt.config.db.db).table('objects').filter({'unique_id' => "#{original}"}).update(object.values).run
79
+
80
+ end
81
+ (result['errors'] == 0)
82
+ end
83
+
84
+
85
+ # Delete an object
86
+ # Returns: boolean
87
+ # Example: Kilt.delete('some-object')
88
+ def self.delete(slug)
89
+ result = Utils.db do
90
+ r.db(Kilt.config.db.db).table('objects').filter({'slug' => "#{slug.to_s}"}).delete().run
91
+ end
92
+ (result['errors'] == 0)
93
+ end
94
+
95
+ # Get the content for a specific object
96
+ # Returns: Kilt::Object instance
97
+ # Example: Kilt.object('big-event')
98
+ def self.get(slug)
99
+ # connect to the db, get the object, close the connection, return the object
100
+ values = Utils.db do
101
+ r.db(Kilt.config.db.db).table('objects').filter({'slug' => "#{slug.to_s}"}).run
102
+ end
103
+
104
+ result = values.to_a.first
105
+
106
+ # create an object and return it
107
+ Kilt::Object.new(result['type'], result)
108
+ end
109
+
110
+ # Get a list of objects
111
+ # Returns: array of hashes
112
+ # Example: Kilt.objects('events')
113
+ # Used directly or via method_missing
114
+ def self.get_collection(object_type)
115
+ # connect to the db, get the date, close the connection, return the array
116
+ results = Utils.db do
117
+ r.db(Kilt.config.db.db).table('objects').filter({'type' => "#{object_type.singularize.to_s}"}).run
118
+ end
119
+
120
+ # create an object collection
121
+ Kilt::ObjectCollection.new(results.to_a)
122
+ end
123
+
124
+ end
125
+
@@ -0,0 +1,6 @@
1
+ desc 'Show all the calls available in Kilt based on the current config'
2
+ task :kilt => :environment do
3
+
4
+ puts Kilt::Utils.tips
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
File without changes
File without changes
@@ -0,0 +1,14 @@
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
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require_tree .
@@ -0,0 +1,11 @@
1
+ var Dummy = (function(){
2
+ var self;
3
+ return {
4
+ init: function(){
5
+ self = this;
6
+ }
7
+ };
8
+ })();
9
+ $(document).ready(function(){
10
+ Dummy.init();
11
+ });
@@ -0,0 +1,2 @@
1
+ // HTML5 Shiv v3.7.0 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2
+ (function(k,m){var g="3.7.0";var d=k.html5||{};var h=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;var c=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;var q;var i="_html5shiv";var a=0;var o={};var e;(function(){try{var t=m.createElement("a");t.innerHTML="<xyz></xyz>";q=("hidden" in t);e=t.childNodes.length==1||(function(){(m.createElement)("a");var v=m.createDocumentFragment();return(typeof v.cloneNode=="undefined"||typeof v.createDocumentFragment=="undefined"||typeof v.createElement=="undefined")}())}catch(u){q=true;e=true}}());function f(t,v){var w=t.createElement("p"),u=t.getElementsByTagName("head")[0]||t.documentElement;w.innerHTML="x<style>"+v+"</style>";return u.insertBefore(w.lastChild,u.firstChild)}function l(){var t=j.elements;return typeof t=="string"?t.split(" "):t}function p(t){var u=o[t[i]];if(!u){u={};a++;t[i]=a;o[a]=u}return u}function n(w,t,v){if(!t){t=m}if(e){return t.createElement(w)}if(!v){v=p(t)}var u;if(v.cache[w]){u=v.cache[w].cloneNode()}else{if(c.test(w)){u=(v.cache[w]=v.createElem(w)).cloneNode()}else{u=v.createElem(w)}}return u.canHaveChildren&&!h.test(w)?v.frag.appendChild(u):u}function r(v,x){if(!v){v=m}if(e){return v.createDocumentFragment()}x=x||p(v);var y=x.frag.cloneNode(),w=0,u=l(),t=u.length;for(;w<t;w++){y.createElement(u[w])}return y}function s(t,u){if(!u.cache){u.cache={};u.createElem=t.createElement;u.createFrag=t.createDocumentFragment;u.frag=u.createFrag()}t.createElement=function(v){if(!j.shivMethods){return u.createElem(v)}return n(v,t,u)};t.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/[\w\-]+/g,function(v){u.createElem(v);u.frag.createElement(v);return'c("'+v+'")'})+");return n}")(j,u.frag)}function b(t){if(!t){t=m}var u=p(t);if(j.shivCSS&&!q&&!u.hasCSS){u.hasCSS=!!f(t,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")}if(!e){s(t,u)}return t}var j={elements:d.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:g,shivCSS:(d.shivCSS!==false),supportsUnknownElements:e,shivMethods:(d.shivMethods!==false),type:"default",shivDocument:b,createElement:n,createDocumentFragment:r};k.html5=j;b(m)}(this,document));
@@ -0,0 +1 @@
1
+ if(typeof Object.create!=="function"){Object.create=function(b){function a(){}a.prototype=b;return new a()}}var ua={toString:function(){return navigator.userAgent},test:function(a){return this.toString().toLowerCase().indexOf(a.toLowerCase())>-1}};ua.version=(ua.toString().toLowerCase().match(/[\s\S]+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];ua.webkit=ua.test("webkit");ua.gecko=ua.test("gecko")&&!ua.webkit;ua.opera=ua.test("opera");ua.ie=ua.test("msie")&&!ua.opera;ua.ie6=ua.ie&&document.compatMode&&typeof document.documentElement.style.maxHeight==="undefined";ua.ie7=ua.ie&&document.documentElement&&typeof document.documentElement.style.maxHeight!=="undefined"&&typeof XDomainRequest==="undefined";ua.ie8=ua.ie&&typeof XDomainRequest!=="undefined";var domReady=function(){var b=[];var a=function(){if(!arguments.callee.done){arguments.callee.done=true;for(var c=0;c<b.length;c++){b[c]()}}};if(document.addEventListener){document.addEventListener("DOMContentLoaded",a,false)}if(ua.ie){(function(){try{document.documentElement.doScroll("left")}catch(c){setTimeout(arguments.callee,50);return}a()})();document.onreadystatechange=function(){if(document.readyState==="complete"){document.onreadystatechange=null;a()}}}if(ua.webkit&&document.readyState){(function(){if(document.readyState!=="loading"){a()}else{setTimeout(arguments.callee,10)}})()}window.onload=a;return function(c){if(typeof c==="function"){b[b.length]=c}return c}}();var cssHelper=function(){var n={BLOCKS:/[^\s{][^{]*\{(?:[^{}]*\{[^{}]*\}[^{}]*|[^{}]*)*\}/g,BLOCKS_INSIDE:/[^\s{][^{]*\{[^{}]*\}/g,DECLARATIONS:/[a-zA-Z\-]+[^;]*:[^;]+;/g,RELATIVE_URLS:/url\(['"]?([^\/\)'"][^:\)'"]+)['"]?\)/g,REDUNDANT_COMPONENTS:/(?:\/\*([^*\\\\]|\*(?!\/))+\*\/|@import[^;]+;)/g,REDUNDANT_WHITESPACE:/\s*(,|:|;|\{|\})\s*/g,MORE_WHITESPACE:/\s{2,}/g,FINAL_SEMICOLONS:/;\}/g,NOT_WHITESPACE:/\S+/g};var l,k=false;var i=[];var h=function(u){if(typeof u==="function"){i[i.length]=u}};var f=function(){for(var u=0;u<i.length;u++){i[u](l)}};var d={};var o=function(y,u){if(d[y]){var w=d[y].listeners;if(w){for(var x=0;x<w.length;x++){w[x](u)}}}};var m=function(v,u,z){if(ua.ie&&!window.XMLHttpRequest){window.XMLHttpRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}if(!XMLHttpRequest){return""}var w=new XMLHttpRequest();try{w.open("get",v,true);w.setRequestHeader("X_REQUESTED_WITH","XMLHttpRequest")}catch(x){z();return}var y=false;setTimeout(function(){y=true},5000);document.documentElement.style.cursor="progress";w.onreadystatechange=function(){if(w.readyState===4&&!y){if(!w.status&&location.protocol==="file:"||(w.status>=200&&w.status<300)||w.status===304||navigator.userAgent.indexOf("Safari")>-1&&typeof w.status==="undefined"){u(w.responseText)}else{z()}document.documentElement.style.cursor="";w=null}};w.send("")};var j=function(u){u=u.replace(n.REDUNDANT_COMPONENTS,"");u=u.replace(n.REDUNDANT_WHITESPACE,"$1");u=u.replace(n.MORE_WHITESPACE," ");u=u.replace(n.FINAL_SEMICOLONS,"}");return u};var g={mediaQueryList:function(C){var u={};var B=C.indexOf("{");var y=C.substring(0,B);C=C.substring(B+1,C.length-1);var x=[],w=[];var v=y.toLowerCase().substring(7).split(",");for(var A=0;A<v.length;A++){x[x.length]=g.mediaQuery(v[A],u)}var z=C.match(n.BLOCKS_INSIDE);if(z!==null){for(A=0;A<z.length;A++){w[w.length]=g.rule(z[A],u)}}u.getMediaQueries=function(){return x};u.getRules=function(){return w};u.getListText=function(){return y};u.getCssText=function(){return C};return u},mediaQuery:function(D,C){D=D||"";var w=false,A;var z=[];var y=true;var x=D.match(n.NOT_WHITESPACE);for(var B=0;B<x.length;B++){var v=x[B];if(!A&&(v==="not"||v==="only")){if(v==="not"){w=true}}else{if(!A){A=v}else{if(v.charAt(0)==="("){var u=v.substring(1,v.length-1).split(":");z[z.length]={mediaFeature:u[0],value:u[1]||null}}}}}return{getList:function(){return C||null},getValid:function(){return y},getNot:function(){return w},getMediaType:function(){return A},getExpressions:function(){return z}}},rule:function(B,y){var u={};var z=B.indexOf("{");var A=B.substring(0,z);var C=A.split(",");var v=[];var w=B.substring(z+1,B.length-1).split(";");for(var x=0;x<w.length;x++){v[v.length]=g.declaration(w[x],u)}u.getMediaQueryList=function(){return y||null};u.getSelectors=function(){return C};u.getSelectorText=function(){return A};u.getDeclarations=function(){return v};u.getPropertyValue=function(E){for(var D=0;D<v.length;D++){if(v[D].getProperty()===E){return v[D].getValue()}}return null};return u},declaration:function(x,y){var u=x.indexOf(":");var z=x.substring(0,u);var w=x.substring(u+1);return{getRule:function(){return y||null},getProperty:function(){return z},getValue:function(){return w}}}};var a=function(x){if(typeof x.cssHelperText!=="string"){return}var w={mediaQueryLists:[],rules:[],selectors:{},declarations:[],properties:{}};var C=w.mediaQueryLists;var E=w.rules;var B=x.cssHelperText.match(n.BLOCKS);if(B!==null){for(var D=0;D<B.length;D++){if(B[D].substring(0,7)==="@media "){C[C.length]=g.mediaQueryList(B[D]);E=w.rules=E.concat(C[C.length-1].getRules())}else{E[E.length]=g.rule(B[D])}}}var u=w.selectors;var z=function(H){var G=H.getSelectors();for(var F=0;F<G.length;F++){var I=G[F];if(!u[I]){u[I]=[]}u[I][u[I].length]=H}};for(D=0;D<E.length;D++){z(E[D])}var A=w.declarations;for(D=0;D<E.length;D++){A=w.declarations=A.concat(E[D].getDeclarations())}var v=w.properties;for(D=0;D<A.length;D++){var y=A[D].getProperty();if(!v[y]){v[y]=[]}v[y][v[y].length]=A[D]}x.cssHelperParsed=w;l[l.length]=x;return w};var c=function(v,u){v.cssHelperText=j(u||v.innerHTML);return a(v)};var b=function(){k=true;l=[];var u=[];var v=function(){for(var D=0;D<u.length;D++){a(u[D])}var C=document.getElementsByTagName("style");for(D=0;D<C.length;D++){c(C[D])}k=false;f()};var B=document.getElementsByTagName("link");for(var w=0;w<B.length;w++){var z=B[w];if(z.getAttribute("rel").indexOf("style")>-1&&z.href&&z.href.length!==0&&!z.disabled){u[u.length]=z}}if(u.length>0){var A=0;var y=function(){A++;if(A===u.length){v()}};var x=function(D){var C=D.href;m(C,function(E){E=j(E).replace(n.RELATIVE_URLS,"url("+C.substring(0,C.lastIndexOf("/"))+"/$1)");D.cssHelperText=E;y()},y)};for(w=0;w<u.length;w++){x(u[w])}}else{v()}};var p={mediaQueryLists:"array",rules:"array",selectors:"object",declarations:"array",properties:"object"};var t={mediaQueryLists:null,rules:null,selectors:null,declarations:null,properties:null};var s=function(w,u){if(t[w]!==null){if(p[w]==="array"){return(t[w]=t[w].concat(u))}else{var y=t[w];for(var x in u){if(u.hasOwnProperty(x)){if(!y[x]){y[x]=u[x]}else{y[x]=y[x].concat(u[x])}}}return y}}};var r=function(u){t[u]=(p[u]==="array")?[]:{};for(var v=0;v<l.length;v++){s(u,l[v].cssHelperParsed[u])}return t[u]};domReady(function(){var v=document.body.getElementsByTagName("*");for(var u=0;u<v.length;u++){v[u].checkedByCssHelper=true}if(document.implementation.hasFeature("MutationEvents","2.0")||window.MutationEvent){document.body.addEventListener("DOMNodeInserted",function(x){var w=x.target;if(w.nodeType===1){o("DOMElementInserted",w);w.checkedByCssHelper=true}},false)}else{setInterval(function(){var x=document.body.getElementsByTagName("*");for(var w=0;w<x.length;w++){if(!x[w].checkedByCssHelper){o("DOMElementInserted",x[w]);x[w].checkedByCssHelper=true}}},1000)}});var q=function(u){if(typeof window.innerWidth!="undefined"){return window["inner"+u]}else{if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0){return document.documentElement["client"+u]}}};return{addStyle:function(w,u){var v=document.createElement("style");v.setAttribute("type","text/css");document.getElementsByTagName("head")[0].appendChild(v);if(v.styleSheet){v.styleSheet.cssText=w}else{v.appendChild(document.createTextNode(w))}v.addedWithCssHelper=true;if(typeof u==="undefined"||u===true){cssHelper.parsed(function(x){var y=c(v,w);for(var z in y){if(y.hasOwnProperty(z)){s(z,y[z])}}o("newStyleParsed",v)})}else{v.parsingDisallowed=true}return v},removeStyle:function(u){return u.parentNode.removeChild(u)},parsed:function(u){if(k){h(u)}else{if(typeof l!=="undefined"){if(typeof u==="function"){u(l)}}else{h(u);b()}}},mediaQueryLists:function(u){cssHelper.parsed(function(v){u(t.mediaQueryLists||r("mediaQueryLists"))})},rules:function(u){cssHelper.parsed(function(v){u(t.rules||r("rules"))})},selectors:function(u){cssHelper.parsed(function(v){u(t.selectors||r("selectors"))})},declarations:function(u){cssHelper.parsed(function(v){u(t.declarations||r("declarations"))})},properties:function(u){cssHelper.parsed(function(v){u(t.properties||r("properties"))})},broadcast:o,addListener:function(v,u){if(typeof u==="function"){if(!d[v]){d[v]={listeners:[]}}d[v].listeners[d[v].listeners.length]=u}},removeListener:function(x,w){if(typeof w==="function"&&d[x]){var u=d[x].listeners;for(var v=0;v<u.length;v++){if(u[v]===w){u.splice(v,1);v-=1}}}},getViewportWidth:function(){return q("Width")},getViewportHeight:function(){return q("Height")}}}();domReady(function enableCssMediaQueries(){var k;var i={LENGTH_UNIT:/[0-9]+(em|ex|px|in|cm|mm|pt|pc)$/,RESOLUTION_UNIT:/[0-9]+(dpi|dpcm)$/,ASPECT_RATIO:/^[0-9]+\/[0-9]+$/,ABSOLUTE_VALUE:/^[0-9]*(\.[0-9]+)*$/};var h=[];var n=function(){var s="css3-mediaqueries-test";var q=document.createElement("div");q.id=s;var r=cssHelper.addStyle("@media all and (width) { #"+s+" { width: 1px !important; } }",false);document.body.appendChild(q);var p=q.offsetWidth===1;r.parentNode.removeChild(r);q.parentNode.removeChild(q);n=function(){return p};return p};var m=function(){k=document.createElement("div");k.style.cssText="position:absolute;top:-9999em;left:-9999em;margin:0;border:none;padding:0;width:1em;font-size:1em;";document.body.appendChild(k);if(k.offsetWidth!==16){k.style.fontSize=16/k.offsetWidth+"em"}k.style.width=""};var l=function(q){k.style.width=q;var p=k.offsetWidth;k.style.width="";return p};var j=function(z,y){var u=z.length;var x=(z.substring(0,4)==="min-");var B=(!x&&z.substring(0,4)==="max-");if(y!==null){var w;var v;if(i.LENGTH_UNIT.exec(y)){w="length";v=l(y)}else{if(i.RESOLUTION_UNIT.exec(y)){w="resolution";v=parseInt(y,10);var t=y.substring((v+"").length)}else{if(i.ASPECT_RATIO.exec(y)){w="aspect-ratio";v=y.split("/")}else{if(i.ABSOLUTE_VALUE){w="absolute";v=y}else{w="unknown"}}}}}var s,r;if("device-width"===z.substring(u-12,u)){s=screen.width;if(y!==null){if(w==="length"){return((x&&s>=v)||(B&&s<v)||(!x&&!B&&s===v))}else{return false}}else{return s>0}}else{if("device-height"===z.substring(u-13,u)){r=screen.height;if(y!==null){if(w==="length"){return((x&&r>=v)||(B&&r<v)||(!x&&!B&&r===v))}else{return false}}else{return r>0}}else{if("width"===z.substring(u-5,u)){s=document.documentElement.clientWidth||document.body.clientWidth;if(y!==null){if(w==="length"){return((x&&s>=v)||(B&&s<v)||(!x&&!B&&s===v))}else{return false}}else{return s>0}}else{if("height"===z.substring(u-6,u)){r=document.documentElement.clientHeight||document.body.clientHeight;if(y!==null){if(w==="length"){return((x&&r>=v)||(B&&r<v)||(!x&&!B&&r===v))}else{return false}}else{return r>0}}else{if("device-aspect-ratio"===z.substring(u-19,u)){return w==="aspect-ratio"&&screen.width*v[1]===screen.height*v[0]}else{if("color-index"===z.substring(u-11,u)){var q=Math.pow(2,screen.colorDepth);if(y!==null){if(w==="absolute"){return((x&&q>=v)||(B&&q<v)||(!x&&!B&&q===v))}else{return false}}else{return q>0}}else{if("color"===z.substring(u-5,u)){var p=screen.colorDepth;if(y!==null){if(w==="absolute"){return((x&&p>=v)||(B&&p<v)||(!x&&!B&&p===v))}else{return false}}else{return p>0}}else{if("resolution"===z.substring(u-10,u)){var A;if(t==="dpcm"){A=l("1cm")}else{A=l("1in")}if(y!==null){if(w==="resolution"){return((x&&A>=v)||(B&&A<v)||(!x&&!B&&A===v))}else{return false}}else{return A>0}}else{return false}}}}}}}}};var g=function(r){var u=r.getValid();var t=r.getExpressions();var p=t.length;if(p>0){for(var q=0;q<p&&u;q++){u=j(t[q].mediaFeature,t[q].value)}var s=r.getNot();return(u&&!s||s&&!u)}};var f=function(p){var u=p.getMediaQueries();var r={};for(var q=0;q<u.length;q++){if(g(u[q])){r[u[q].getMediaType()]=true}}var v=[],x=0;for(var w in r){if(r.hasOwnProperty(w)){if(x>0){v[x++]=","}v[x++]=w}}if(v.length>0){h[h.length]=cssHelper.addStyle("@media "+v.join("")+"{"+p.getCssText()+"}",false)}};var d=function(q){for(var p=0;p<q.length;p++){f(q[p])}if(ua.ie){document.documentElement.style.display="block";setTimeout(function(){document.documentElement.style.display=""},0);setTimeout(function(){cssHelper.broadcast("cssMediaQueriesTested")},100)}else{cssHelper.broadcast("cssMediaQueriesTested")}};var c=function(){for(var p=0;p<h.length;p++){cssHelper.removeStyle(h[p])}h=[];cssHelper.mediaQueryLists(d)};var b=0;var a=function(){var s=cssHelper.getViewportWidth();var r=cssHelper.getViewportHeight();if(ua.ie){var t=document.createElement("div");t.style.position="absolute";t.style.top="-9999em";t.style.overflow="scroll";document.body.appendChild(t);b=t.offsetWidth-t.clientWidth;document.body.removeChild(t)}var q;var p=function(){var u=cssHelper.getViewportWidth();var v=cssHelper.getViewportHeight();if(Math.abs(u-s)>b||Math.abs(v-r)>b){s=u;r=v;clearTimeout(q);q=setTimeout(function(){if(!n()){c()}else{cssHelper.broadcast("cssMediaQueriesTested")}},500)}};window.onresize=function(){var u=window.onresize||function(){};return function(){u();p()}}()};var o=document.documentElement;o.style.marginLeft="-32767px";setTimeout(function(){o.style.marginTop=""},20000);return function(){if(!n()){cssHelper.addListener("newStyleParsed",function(p){d(p.cssHelperParsed.mediaQueryLists)});cssHelper.addListener("cssMediaQueriesTested",function(){if(ua.ie){o.style.width="1px"}setTimeout(function(){o.style.width="";o.style.marginLeft=""},0);cssHelper.removeListener("cssMediaQueriesTested",arguments.callee)});m();c()}else{o.style.marginLeft=""}a()}}());try{document.execCommand("BackgroundImageCache",false,true)}catch(e){};
@@ -0,0 +1,24 @@
1
+ # Require any additional compass plugins here.
2
+
3
+ # Set this to the root of your project when deployed:
4
+ http_path = "/"
5
+ css_dir = "stylesheets"
6
+ sass_dir = "sass"
7
+ images_dir = "images"
8
+ javascripts_dir = "javascripts"
9
+
10
+ # You can select your preferred output style here (can be overridden via the command line):
11
+ # output_style = :expanded or :nested or :compact or :compressed
12
+
13
+ # To enable relative paths to assets via compass helper functions. Uncomment:
14
+ # relative_assets = true
15
+
16
+ # To disable debugging comments that display the original location of your selectors. Uncomment:
17
+ # line_comments = false
18
+
19
+
20
+ # If you prefer the indented syntax, you might want to regenerate this
21
+ # project again passing --syntax sass, or you can uncomment this:
22
+ # preferred_syntax = :sass
23
+ # and then run:
24
+ # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
@@ -0,0 +1,81 @@
1
+ @mixin sprite-background($name) {
2
+ background-image: sprite-url($sprites);
3
+ background-position: sprite-position($sprites, $name);
4
+ background-repeat: no-repeat;
5
+ display: block;
6
+ height: image-height(sprite-file($sprites, $name));
7
+ text-indent: -9999em;
8
+ width: image-width(sprite-file($sprites, $name));
9
+ }
10
+
11
+ @mixin retina-sprite-background($name) {
12
+ background-image: sprite-url($retina_sprites);
13
+ background-position: sprite-position($retina_sprites, $name);
14
+ background-repeat: no-repeat;
15
+ background-size: image-width(sprite-path($retina_sprites)) / 2;
16
+ display: block;
17
+ height: image-height(sprite-file($retina_sprites, $name)) / 2;
18
+ text-indent: -9999em;
19
+ width: image-width(sprite-file($retina_sprites, $name)) / 2;
20
+ }
21
+
22
+ @mixin transition($transitions...) {
23
+ -webkit-transition: $transitions;
24
+ -moz-transition: $transitions;
25
+ -o-transition: $transitions;
26
+ transition: $transitions;
27
+ }
28
+
29
+ @mixin box-shadow($shadows...) {
30
+ -webkit-box-shadow: $shadows;
31
+ -moz-box-shadow: $shadows;
32
+ -o-box-shadow: $shadows;
33
+ box-shadow: $shadows;
34
+ }
35
+
36
+ @mixin opacity ($opacity) {
37
+ opacity: $opacity;
38
+ -moz-opacity: $opacity;
39
+ filter:alpha(opacity=($opacity * 100));
40
+ }
41
+
42
+ @mixin css-triangle($direction: "down", $size: 20px, $color: #000) {
43
+ width: 0;
44
+ height: 0;
45
+ border-left: $size solid #{setTriangleColor($direction, "left", $color)};
46
+ border-right: $size solid #{setTriangleColor($direction, "right", $color)};
47
+ border-bottom: $size solid #{setTriangleColor($direction, "bottom", $color)};
48
+ border-top: $size solid #{setTriangleColor($direction, "top", $color)};
49
+ }
50
+
51
+ @function setTriangleColor($direction, $side, $color) {
52
+ @if $direction == "left" and $side == "right"
53
+ or $direction == "right" and $side == "left"
54
+ or $direction == "down" and $side == "top"
55
+ or $direction == "up" and $side == "bottom" {
56
+ @return $color
57
+ } @else {
58
+ @return "transparent";
59
+ }
60
+ }
61
+
62
+ @mixin font-face($family, $style, $weight, $filename) {
63
+ @font-face {
64
+ font-family: $family;
65
+ font-style: $style;
66
+ font-weight: $weight;
67
+ src: url('../../font/' + $filename + '.eot');
68
+ src: url('../../font/' + $filename + '.eot?#iefix') format('embedded-opentype'),
69
+ url('../../font/' + $filename + '.woff') format('woff'),
70
+ url('../../font/' + $filename + '.ttf') format('truetype'),
71
+ url('../../font/' + $filename + '.svg#' + $family +'') format('svg');
72
+ }
73
+ }
74
+
75
+ @mixin user-select($value) {
76
+ -webkit-user-select: $value;
77
+ -moz-user-select: $value;
78
+ -ms-user-select: $value;
79
+ -o-user-select: $value;
80
+ user-select: $value;
81
+ }